@celljs/ta-team 4.16.0 → 4.18.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 CHANGED
@@ -39,6 +39,7 @@ var TaLanguageUtil;
39
39
 
40
40
  // ../ta-protocol/esm/common/team-protocol.js
41
41
  var TA_OWNER = "owner";
42
+ var TA_INVITE_PREFIX = "invite:";
42
43
  var TA_UNDECLARED = "extensions.install";
43
44
  var TaPermissionUtil;
44
45
  (function(TaPermissionUtil2) {
@@ -87,7 +88,7 @@ var TA_ACTIONS = [
87
88
  action("commands.terminal", "Open terminals", "打开终端", "開啟終端機", "ターミナルを開く", { scoped: true, risky: true }),
88
89
  action("hosts.use", "Use remote hosts", "使用远程主机", "使用遠端主機", "リモートホストを使用", { risky: true }),
89
90
  action("models.use", "Use the models", "使用模型", "使用模型", "モデルを使用"),
90
- action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更"),
91
+ action("models.manage", "Sign in to models", "登录和更换模型账号", "登入和更換模型帳號", "モデルアカウントにサインイン・変更", { grant: "single" }),
91
92
  action("cron.view", "See scheduled tasks", "查看定时任务", "檢視定時任務", "スケジュールタスクを確認"),
92
93
  action("cron.manage", "Change scheduled tasks", "管理定时任务", "管理定時任務", "スケジュールタスクを管理"),
93
94
  action("extensions.use", "Use extensions", "使用扩展", "使用擴充功能", "拡張機能を使用"),
@@ -100,9 +101,15 @@ var TA_ACTIONS = [
100
101
  action("members.roles", "Change roles and members", "管理角色和成员", "管理角色和成員", "ロールとメンバーを管理"),
101
102
  action("audit.view", "See the record", "查看记录", "檢視記錄", "レコードを確認")
102
103
  ];
104
+ var TA_OWNER_ACTIONS = [
105
+ action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
106
+ action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
107
+ ];
108
+ var OWNER_AREAS = ["desktop"];
103
109
  var TaActionUtil;
104
110
  (function(TaActionUtil2) {
105
111
  const byId = new Map(TA_ACTIONS.map((one) => [one.id, one]));
112
+ const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map((one) => [one.id, one]));
106
113
  function info(id) {
107
114
  return byId.get(id);
108
115
  }
@@ -110,7 +117,7 @@ var TaActionUtil;
110
117
  function title(id, language) {
111
118
  var _a;
112
119
  var _b, _c;
113
- const title2 = (_a = byId.get(id)) === null || _a === undefined ? undefined : _a.title;
120
+ const title2 = (_a = titled.get(id)) === null || _a === undefined ? undefined : _a.title;
114
121
  if (!title2) {
115
122
  return id;
116
123
  }
@@ -122,6 +129,16 @@ var TaActionUtil;
122
129
  });
123
130
  }
124
131
  TaActionUtil2.title = title;
132
+ function grantable(id) {
133
+ const info2 = byId.get(id);
134
+ return !!info2 && !OWNER_AREAS.includes(info2.area);
135
+ }
136
+ TaActionUtil2.grantable = grantable;
137
+ function inRoles(id) {
138
+ var _a;
139
+ return grantable(id) && ((_a = byId.get(id)) === null || _a === undefined ? undefined : _a.grant) !== "single";
140
+ }
141
+ TaActionUtil2.inRoles = inRoles;
125
142
  function inside(dir, path) {
126
143
  const base = dir.replace(/\/+$/, "");
127
144
  return path === base || path.startsWith(`${base}/`) || base === "";
@@ -129,983 +146,238 @@ var TaActionUtil;
129
146
  TaActionUtil2.inside = inside;
130
147
  })(TaActionUtil || (TaActionUtil = {}));
131
148
 
132
- // ../ta-relay/esm/common/relay-bytes.js
133
- var RelayBytes;
134
- (function(RelayBytes2) {
135
- function random(length) {
136
- return globalThis.crypto.getRandomValues(new Uint8Array(length));
137
- }
138
- RelayBytes2.random = random;
139
- function toBase64(bytes) {
140
- let binary = "";
141
- for (const byte of bytes) {
142
- binary += String.fromCharCode(byte);
143
- }
144
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
145
- }
146
- RelayBytes2.toBase64 = toBase64;
147
- function fromBase64(text) {
148
- if (!/^[A-Za-z0-9_-]*$/.test(text)) {
149
- throw new Error("Not base64url.");
150
- }
151
- const binary = atob(text.replace(/-/g, "+").replace(/_/g, "/"));
152
- const bytes = new Uint8Array(binary.length);
153
- for (let i = 0;i < binary.length; i++) {
154
- bytes[i] = binary.charCodeAt(i);
155
- }
156
- return bytes;
157
- }
158
- RelayBytes2.fromBase64 = fromBase64;
159
- function concat(...parts) {
160
- const bytes = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));
161
- let offset = 0;
162
- for (const part of parts) {
163
- bytes.set(part, offset);
164
- offset += part.length;
165
- }
166
- return bytes;
167
- }
168
- RelayBytes2.concat = concat;
169
- })(RelayBytes || (RelayBytes = {}));
170
-
171
- // ../ta-relay/esm/common/relay-protocol.js
172
- var RELAY_CONNECT_PATH = "/v1/connect/";
173
- var RELAY_PAIR_PATH = "/pair";
174
- var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
175
- var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
176
- var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
177
- var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
178
- var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
179
- var RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
180
- var RelayCloseCode;
181
- (function(RelayCloseCode2) {
182
- RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
183
- RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
184
- RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
185
- RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
186
- RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
187
- RelayCloseCode2[RelayCloseCode2["TIMEOUT"] = 4408] = "TIMEOUT";
188
- })(RelayCloseCode || (RelayCloseCode = {}));
189
- var RELAY_PING = "ping";
190
- var RELAY_PONG = "pong";
191
- var RELAY_PING_MS = 25000;
192
- var RELAY_PROOF = "ta-relay ready";
193
- var RELAY_HUB_MAX_VALUE = 96 * 1024;
194
- var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
195
-
196
- // ../ta-relay/esm/common/relay-pairing.js
197
- var RelayPairingUtil;
198
- (function(RelayPairingUtil2) {
199
- function link(pairing) {
200
- const fragment = new URLSearchParams({ v: "1", h: pairing.host, d: pairing.device, k: pairing.key });
201
- if (pairing.name) {
202
- fragment.set("n", pairing.name);
203
- }
204
- return `${pairing.relay}${RELAY_PAIR_PATH}#${fragment}`;
205
- }
206
- RelayPairingUtil2.link = link;
207
- function parse(link2) {
208
- var _a;
209
- const url = new URL(link2.trim());
210
- const fragment = new URLSearchParams(url.hash.slice(1));
211
- const [host, device, key] = ["h", "d", "k"].map((name) => {
212
- var _a2;
213
- return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
214
- });
215
- if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_PAIR_PATH || fragment.get("v") !== "1" || !RELAY_ID.test(host) || !RELAY_ID.test(device) || !/^[A-Za-z0-9_-]{43}$/.test(key)) {
216
- throw new Error("Not a pairing link of Ta.");
217
- }
218
- return { relay: url.origin, host, device, key, name: (_a = fragment.get("n")) !== null && _a !== undefined ? _a : undefined };
219
- }
220
- RelayPairingUtil2.parse = parse;
221
- function websocketUrl(relay, path) {
222
- return relay.replace(/^http/, "ws") + path;
223
- }
224
- RelayPairingUtil2.websocketUrl = websocketUrl;
225
- })(RelayPairingUtil || (RelayPairingUtil = {}));
226
-
227
- // ../ta-relay/esm/common/relay-cipher.js
228
- var encoder = new TextEncoder;
229
- var decoder = new TextDecoder;
230
- var IV_LENGTH = 12;
231
- var PLAIN = 0;
232
- var DEFLATED = 1;
233
- var DEFLATE_MIN_BYTES = 1024;
234
-
235
- class RelayCipher {
236
- constructor(sendKey, receiveKey) {
237
- this.sendKey = sendKey;
238
- this.receiveKey = receiveKey;
239
- this.compress = false;
240
- this.sent = 0;
241
- this.received = 0;
242
- this.sealing = Promise.resolve();
243
- this.opening = Promise.resolve();
244
- }
245
- static async derive(deviceKey, clientNonce, hostNonce, side) {
246
- const subtle = globalThis.crypto.subtle;
247
- const secret = await subtle.importKey("raw", deviceKey, "HKDF", false, ["deriveKey"]);
248
- const salt = RelayBytes.concat(clientNonce, hostNonce);
249
- const key = (direction) => subtle.deriveKey({ name: "HKDF", hash: "SHA-256", salt, info: encoder.encode(`ta-relay/1 ${direction}`) }, secret, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
250
- const [toHost, toClient] = await Promise.all([key("client-to-host"), key("host-to-client")]);
251
- return side === "client" ? new RelayCipher(toHost, toClient) : new RelayCipher(toClient, toHost);
252
- }
253
- seal(text) {
254
- const iv = RelayCipher.iv(this.sent++);
255
- const sealed = this.sealing.then(async () => {
256
- const data = await globalThis.crypto.subtle.encrypt({ name: "AES-GCM", iv }, this.sendKey, await this.pack(text));
257
- return RelayBytes.toBase64(new Uint8Array(data));
258
- });
259
- this.sealing = sealed.catch(() => {
260
- return;
261
- });
262
- return sealed;
263
- }
264
- open(frame) {
265
- const iv = RelayCipher.iv(this.received++);
266
- const opened = this.opening.then(async () => {
267
- const data = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv }, this.receiveKey, RelayBytes.fromBase64(frame));
268
- return this.unpack(new Uint8Array(data));
269
- });
270
- this.opening = opened.catch(() => {
271
- return;
272
- });
273
- return opened;
274
- }
275
- async pack(text) {
276
- const bytes = encoder.encode(text);
277
- if (!this.compress) {
278
- return bytes;
279
- }
280
- const deflated = bytes.length >= DEFLATE_MIN_BYTES ? await RelayDeflate.compress(bytes) : undefined;
281
- return deflated && deflated.length < bytes.length ? RelayBytes.concat(Uint8Array.of(DEFLATED), deflated) : RelayBytes.concat(Uint8Array.of(PLAIN), bytes);
282
- }
283
- async unpack(bytes) {
284
- if (!this.compress) {
285
- return decoder.decode(bytes);
286
- }
287
- const body = bytes.subarray(1);
288
- return decoder.decode(bytes[0] === DEFLATED ? await RelayDeflate.decompress(body) : body);
289
- }
290
- static iv(counter) {
291
- const iv = new Uint8Array(IV_LENGTH);
292
- new DataView(iv.buffer).setUint32(IV_LENGTH - 8, Math.floor(counter / 2 ** 32));
293
- new DataView(iv.buffer).setUint32(IV_LENGTH - 4, counter >>> 0);
294
- return iv;
295
- }
149
+ // ../ta-web/esm/browser/extension/share-sheet-compat.js
150
+ function ShareSheetCompat({ pi, ...props }) {
151
+ const h = pi.React.createElement;
152
+ if (pi.ui.ShareSheet) {
153
+ return h(pi.ui.ShareSheet, props);
154
+ }
155
+ const { title, link, error, name, gets, notes, password, own, onClose, children } = props;
156
+ const quiet = { margin: 0, opacity: 0.7, textAlign: "center" };
157
+ return h(pi.ui.Dialog, { title, onClose }, h("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: 12 } }, error !== undefined ? h("p", { role: "alert" }, error) : [
158
+ name || gets ? h("p", { key: "who", style: { margin: 0, textAlign: "center" } }, [name, gets].filter(Boolean).join(" · ")) : null,
159
+ link && !own ? h(pi.ui.QrCode, { key: "qr", text: link, label: name || title }) : null,
160
+ h("code", { key: "link", style: { maxWidth: "100%", overflowWrap: "anywhere", userSelect: "all" } }, link !== null && link !== undefined ? link : "…"),
161
+ password ? h("code", { key: "password", style: { userSelect: "all" } }, password) : null,
162
+ link ? h("button", { key: "copy", type: "button", className: "ta-button ta-primary", onClick: () => {
163
+ var _a;
164
+ return void ((_a = navigator.clipboard) === null || _a === undefined ? undefined : _a.writeText(link));
165
+ } }, "Copy") : null,
166
+ children,
167
+ ...(notes !== null && notes !== undefined ? notes : []).filter(Boolean).map((line) => h("p", { key: String(line), style: quiet }, line))
168
+ ]));
296
169
  }
297
- var RelayDeflate;
298
- (function(RelayDeflate2) {
299
- let support;
300
- function supported() {
301
- if (support === undefined) {
302
- try {
303
- new CompressionStream("deflate-raw");
304
- new DecompressionStream("deflate-raw");
305
- support = true;
306
- } catch (_a) {
307
- support = false;
308
- }
309
- }
310
- return support;
311
- }
312
- RelayDeflate2.supported = supported;
313
- function compress(bytes) {
314
- return through(bytes, new CompressionStream("deflate-raw"));
315
- }
316
- RelayDeflate2.compress = compress;
317
- function decompress(bytes) {
318
- return through(bytes, new DecompressionStream("deflate-raw"));
319
- }
320
- RelayDeflate2.decompress = decompress;
321
- async function through(bytes, stream) {
322
- const piped = new Blob([bytes]).stream().pipeThrough(stream);
323
- return new Uint8Array(await new Response(piped).arrayBuffer());
324
- }
325
- })(RelayDeflate || (RelayDeflate = {}));
326
-
327
- // ../ta-relay/esm/common/relay-socket.js
328
- var CONNECTING = 0;
329
- var OPEN = 1;
330
- var CLOSING = 2;
331
- var CLOSED = 3;
332
- var HELLO_MS = 15000;
333
170
 
334
- class RelaySocket {
335
- constructor(pairing, options = {}) {
336
- var _a;
337
- this.pairing = pairing;
338
- this.options = options;
339
- this.onopen = null;
340
- this.onmessage = null;
341
- this.onclose = null;
342
- this.onerror = null;
343
- this.state = CONNECTING;
344
- this.nonce = RelayBytes.random(16);
345
- this.ponged = false;
346
- this.awaitingPong = false;
347
- this.receiving = Promise.resolve();
348
- this.socket = new WebSocket(RelayPairingUtil.websocketUrl(pairing.relay, RELAY_CONNECT_PATH + pairing.host));
349
- this.helloTimer = setTimeout(() => this.drop(RelayCloseCode.TIMEOUT, "The host did not answer."), (_a = options.helloMs) !== null && _a !== undefined ? _a : HELLO_MS);
350
- this.socket.onopen = () => {
351
- var _a2;
352
- const hello = {
353
- t: "hello",
354
- v: 1,
355
- device: pairing.device,
356
- nonce: RelayBytes.toBase64(this.nonce),
357
- ...RelayDeflate.supported() ? { z: 1 } : {}
358
- };
359
- this.socket.send(JSON.stringify(hello));
360
- this.pingTimer = setInterval(() => this.ping(), (_a2 = options.pingMs) !== null && _a2 !== undefined ? _a2 : RELAY_PING_MS);
361
- };
362
- this.socket.onmessage = (message) => {
363
- const text = String(message.data);
364
- if (text === RELAY_PONG) {
365
- this.ponged = true;
366
- this.awaitingPong = false;
367
- return;
368
- }
369
- this.receiving = this.receiving.then(() => this.receive(text));
370
- };
371
- this.socket.onerror = (event) => {
372
- var _a2;
373
- return (_a2 = this.onerror) === null || _a2 === undefined ? undefined : _a2.call(this, event);
374
- };
375
- this.socket.onclose = (event) => void this.receiving.then(() => this.finish(event.code, event.reason));
376
- }
377
- get readyState() {
378
- return this.state;
379
- }
380
- get closeCode() {
381
- return this.code;
382
- }
383
- send(text) {
384
- if (this.state !== OPEN || !this.cipher) {
385
- throw new Error("The connection is not open.");
386
- }
387
- this.cipher.seal(text).then((frame) => this.socket.readyState === OPEN && this.socket.send(frame));
388
- }
389
- close(code = 1000, reason = "") {
390
- if (this.state === CLOSED) {
391
- return;
392
- }
393
- this.state = CLOSING;
394
- this.socket.close(code, reason);
395
- }
396
- async receive(text) {
397
- var _a, _b;
398
- if (this.cipher) {
399
- if (this.options.proveFirst && text.startsWith("{")) {
400
- this.drop(RelaySocket.REFUSED, RelaySocket.refusal(text));
401
- return;
402
- }
403
- try {
404
- const data = await this.cipher.open(text);
405
- (_a = this.onmessage) === null || _a === undefined || _a.call(this, { data });
406
- } catch (_c) {
407
- this.close(4400, "A message did not open.");
408
- }
409
- return;
410
- }
411
- try {
412
- const welcome = JSON.parse(text);
413
- if (welcome.t !== "ready") {
414
- this.drop(RelaySocket.REFUSED, this.options.proveFirst ? RelaySocket.refusal(text) : "The host refused this device.");
415
- return;
416
- }
417
- const cipher = await RelayCipher.derive(RelayBytes.fromBase64(this.pairing.key), this.nonce, RelayBytes.fromBase64(welcome.nonce), "client");
418
- if (welcome.proof === undefined && this.options.proveFirst) {
419
- this.socket.send(await cipher.seal(RELAY_PROOF));
420
- } else if (welcome.proof === undefined || await cipher.open(welcome.proof) !== RELAY_PROOF) {
421
- throw new Error("The host did not show the key.");
422
- }
423
- cipher.compress = welcome.z === 1 && RelayDeflate.supported();
424
- this.cipher = cipher;
425
- clearTimeout(this.helloTimer);
426
- this.state = OPEN;
427
- (_b = this.onopen) === null || _b === undefined || _b.call(this);
428
- } catch (_d) {
429
- this.drop(RelaySocket.REFUSED, "The host refused this device.");
430
- }
431
- }
432
- static refusal(text) {
433
- try {
434
- const reason = JSON.parse(text).reason;
435
- return reason === "key" || reason === "busy" ? reason : "gone";
436
- } catch (_a) {
437
- return "gone";
438
- }
439
- }
440
- ping() {
441
- if (this.awaitingPong && this.ponged) {
442
- this.drop(RelayCloseCode.TIMEOUT, "The relay did not answer.");
443
- return;
444
- }
445
- this.awaitingPong = true;
446
- if (this.socket.readyState === OPEN) {
447
- this.socket.send(RELAY_PING);
448
- }
449
- }
450
- drop(code, reason) {
451
- this.close(code, reason);
452
- this.finish(code, reason);
453
- }
454
- finish(code, reason) {
455
- var _a;
456
- if (this.state === CLOSED) {
457
- return;
458
- }
459
- clearTimeout(this.helloTimer);
460
- clearInterval(this.pingTimer);
461
- this.state = CLOSED;
462
- this.code = code;
463
- (_a = this.onclose) === null || _a === undefined || _a.call(this, { code, reason });
464
- }
465
- }
466
- RelaySocket.CONNECTING = CONNECTING;
467
- RelaySocket.OPEN = OPEN;
468
- RelaySocket.CLOSING = CLOSING;
469
- RelaySocket.CLOSED = CLOSED;
470
- RelaySocket.REFUSED = 4403;
471
-
472
- // ../ta-relay/esm/common/relay-host-calls.js
473
- var CALL_MS = 30000;
474
- var OPEN_TRIES = 6;
475
- var OPEN_PAUSE_MS = 700;
476
-
477
- class RelayHostCalls {
478
- constructor(pairing, name) {
479
- this.pairing = pairing;
480
- this.name = name;
481
- this.next = 1;
482
- this.calls = new Map;
483
- this.closed = false;
484
- }
485
- static of(link, name) {
486
- return new RelayHostCalls(RelayPairingUtil.parse(link), name);
487
- }
488
- open() {
489
- var _a;
490
- (_a = this.opening) !== null && _a !== undefined || (this.opening = this.tryOpen(OPEN_TRIES));
491
- return this.opening;
492
- }
493
- async tryOpen(tries) {
494
- for (let left = tries;; left--) {
495
- try {
496
- await this.openOnce();
497
- return;
498
- } catch (error) {
499
- if (left <= 1 || this.closed || error.refused) {
500
- this.opening = undefined;
501
- throw error;
502
- }
503
- await new Promise((resolve) => setTimeout(resolve, OPEN_PAUSE_MS));
504
- }
505
- }
506
- }
507
- openOnce() {
508
- return new Promise((resolve, reject) => {
509
- let opened = false;
510
- const socket = new RelaySocket(this.pairing);
511
- this.socket = socket;
512
- socket.onopen = () => {
513
- opened = true;
514
- resolve();
515
- };
516
- socket.onerror = () => {
517
- if (!opened) {
518
- reject(new Error("The other Ta did not answer: is it running?"));
519
- }
520
- };
521
- socket.onclose = (event) => {
522
- const refused = event.code === RelaySocket.REFUSED;
523
- const error = Object.assign(new Error(refused ? "The other Ta no longer knows this device." : "The connection to the other Ta was lost."), {
524
- refused
525
- });
526
- if (!opened) {
527
- reject(error);
528
- return;
529
- }
530
- this.failAll(error);
531
- this.opening = undefined;
532
- };
533
- socket.onmessage = (message) => this.receive(message.data);
534
- });
535
- }
536
- async callHost(method, ...params) {
537
- await this.open();
538
- const id = this.next++;
539
- return new Promise((resolve, reject) => {
540
- var _a;
541
- const timer = setTimeout(() => {
542
- this.calls.delete(id);
543
- reject(new Error("The other Ta did not answer in time."));
544
- }, CALL_MS);
545
- this.calls.set(id, { resolve, reject, timer });
546
- (_a = this.socket) === null || _a === undefined || _a.send(JSON.stringify({ jsonrpc: "2.0", id, method: "TaPackageServer/callPackageHost", params: [this.name, method, params] }));
547
- });
548
- }
549
- close() {
550
- var _a;
551
- this.closed = true;
552
- (_a = this.socket) === null || _a === undefined || _a.close();
553
- this.failAll(new Error("Stopped."));
554
- }
555
- failAll(error) {
556
- for (const call of this.calls.values()) {
557
- clearTimeout(call.timer);
558
- call.reject(error);
559
- }
560
- this.calls.clear();
561
- }
562
- receive(data) {
563
- var _a;
564
- let message;
565
- try {
566
- message = JSON.parse(data);
567
- } catch (_b) {
568
- return;
569
- }
570
- const call = typeof message.id === "number" ? this.calls.get(message.id) : undefined;
571
- if (!call) {
572
- return;
573
- }
574
- this.calls.delete(message.id);
575
- clearTimeout(call.timer);
576
- if (message.error) {
577
- call.reject(new Error((_a = message.error.message) !== null && _a !== undefined ? _a : "Failed."));
578
- } else {
579
- call.resolve(message.result);
580
- }
581
- }
582
- }
583
-
584
- // ../ta-relay/esm/common/relay-identity.js
585
- var encoder2 = new TextEncoder;
586
- var decoder2 = new TextDecoder;
587
- var subtle = () => globalThis.crypto.subtle;
588
- var SIGN = { name: "ECDSA", namedCurve: "P-256" };
589
- var BOX = { name: "ECDH", namedCurve: "P-256" };
590
- var SIGNATURE = { name: "ECDSA", hash: "SHA-256" };
591
- var RelayKeys;
592
- (function(RelayKeys2) {
593
- async function hkdf(key, salt, info) {
594
- const secret = await subtle().importKey("raw", key, "HKDF", false, ["deriveBits"]);
595
- const bits = await subtle().deriveBits({ name: "HKDF", hash: "SHA-256", salt, info: encoder2.encode(info) }, secret, 256);
596
- return new Uint8Array(bits);
597
- }
598
- RelayKeys2.hkdf = hkdf;
599
- async function sha256(bytes) {
600
- const data = typeof bytes === "string" ? encoder2.encode(bytes) : bytes;
601
- return new Uint8Array(await subtle().digest("SHA-256", data));
602
- }
603
- RelayKeys2.sha256 = sha256;
604
- async function hash(text) {
605
- return RelayBytes.toBase64(await sha256(text));
606
- }
607
- RelayKeys2.hash = hash;
608
- async function hmac(key, text) {
609
- const imported = await subtle().importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
610
- return RelayBytes.toBase64(new Uint8Array(await subtle().sign("HMAC", imported, encoder2.encode(text))));
611
- }
612
- RelayKeys2.hmac = hmac;
613
- function aesKey(key) {
614
- return subtle().importKey("raw", key, "AES-GCM", false, ["encrypt", "decrypt"]);
615
- }
616
- RelayKeys2.aesKey = aesKey;
617
- async function seal(key, text) {
618
- const iv = RelayBytes.random(12);
619
- const sealed = await subtle().encrypt({ name: "AES-GCM", iv }, key, encoder2.encode(text));
620
- return RelayBytes.toBase64(RelayBytes.concat(iv, new Uint8Array(sealed)));
621
- }
622
- RelayKeys2.seal = seal;
623
- async function open(key, sealed) {
624
- const bytes = RelayBytes.fromBase64(sealed);
625
- const opened = await subtle().decrypt({ name: "AES-GCM", iv: bytes.subarray(0, 12) }, key, bytes.subarray(12));
626
- return decoder2.decode(opened);
627
- }
628
- RelayKeys2.open = open;
629
- })(RelayKeys || (RelayKeys = {}));
630
- var RelayIdentityUtil;
631
- (function(RelayIdentityUtil2) {
632
- async function create(name, now = Date.now()) {
633
- const sign2 = await subtle().generateKey(SIGN, true, ["sign", "verify"]);
634
- const box = await subtle().generateKey(BOX, true, ["deriveBits"]);
635
- const raw = async (key) => RelayBytes.toBase64(new Uint8Array(await subtle().exportKey("raw", key)));
636
- const [signPublic, boxPublic] = await Promise.all([raw(sign2.publicKey), raw(box.publicKey)]);
637
- return {
638
- id: await id(signPublic, boxPublic),
639
- name,
640
- sign: signPublic,
641
- box: boxPublic,
642
- signKey: await subtle().exportKey("jwk", sign2.privateKey),
643
- boxKey: await subtle().exportKey("jwk", box.privateKey),
644
- createdAt: now
645
- };
646
- }
647
- RelayIdentityUtil2.create = create;
648
- async function id(sign2, box) {
649
- const digest = await RelayKeys.sha256(RelayBytes.concat(RelayBytes.fromBase64(sign2), RelayBytes.fromBase64(box)));
650
- return RelayBytes.toBase64(digest.subarray(0, 16));
651
- }
652
- RelayIdentityUtil2.id = id;
653
- async function check(identity) {
654
- try {
655
- if (identity.id !== await id(identity.sign, identity.box)) {
656
- return false;
657
- }
658
- await Promise.all([importSign(identity.sign), importBox(identity.box)]);
659
- return true;
660
- } catch (_a) {
661
- return false;
662
- }
663
- }
664
- RelayIdentityUtil2.check = check;
665
- function publicOf(identity) {
666
- return withLook({ id: identity.id, name: identity.name, sign: identity.sign, box: identity.box }, identity.look);
667
- }
668
- RelayIdentityUtil2.publicOf = publicOf;
669
- function isLook(look) {
670
- return typeof look === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(look);
671
- }
672
- RelayIdentityUtil2.isLook = isLook;
673
- function withLook(value, look) {
674
- const { look: _, ...rest } = value;
675
- return isLook(look) ? { ...rest, look } : rest;
676
- }
677
- RelayIdentityUtil2.withLook = withLook;
678
- async function sign(identity, text) {
679
- const key = await subtle().importKey("jwk", identity.signKey, SIGN, false, ["sign"]);
680
- return RelayBytes.toBase64(new Uint8Array(await subtle().sign(SIGNATURE, key, encoder2.encode(text))));
681
- }
682
- RelayIdentityUtil2.sign = sign;
683
- async function verify(signPublic, text, signature) {
684
- try {
685
- return await subtle().verify(SIGNATURE, await importSign(signPublic), RelayBytes.fromBase64(signature), encoder2.encode(text));
686
- } catch (_a) {
687
- return false;
688
- }
689
- }
690
- RelayIdentityUtil2.verify = verify;
691
- async function agree(identity, otherBox, salt, info) {
692
- const own = await subtle().importKey("jwk", identity.boxKey, BOX, false, ["deriveBits"]);
693
- const shared = await subtle().deriveBits({ name: "ECDH", public: await importBox(otherBox) }, own, 256);
694
- return RelayKeys.hkdf(new Uint8Array(shared), encoder2.encode(salt), info);
695
- }
696
- RelayIdentityUtil2.agree = agree;
697
- function importSign(raw) {
698
- return subtle().importKey("raw", RelayBytes.fromBase64(raw), SIGN, false, ["verify"]);
699
- }
700
- function importBox(raw) {
701
- return subtle().importKey("raw", RelayBytes.fromBase64(raw), BOX, false, []);
702
- }
703
- })(RelayIdentityUtil || (RelayIdentityUtil = {}));
704
-
705
- // ../ta-relay/esm/common/relay-team.js
706
- var RELAY_JOIN_PATH = "/j";
707
- var RELAY_WEB_PATH = "/w/";
708
- var RELAY_TEAM_PACKAGE = "@celljs/ta-team";
709
- var SEAL_INFO = "ta-team/1 device";
710
- var RelayTeamSeal;
711
- (function(RelayTeamSeal2) {
712
- function keys(name) {
713
- return RelayIdentityUtil.create(name);
714
- }
715
- RelayTeamSeal2.keys = keys;
716
- async function seal(box, salt, text) {
717
- const own = await RelayIdentityUtil.create("ta");
718
- const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(own, box, salt, SEAL_INFO));
719
- return { box: own.box, sealed: await RelayKeys.seal(key, text) };
720
- }
721
- RelayTeamSeal2.seal = seal;
722
- async function open(keys2, answer, salt) {
723
- const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(keys2, answer.box, salt, SEAL_INFO));
724
- return RelayKeys.open(key, answer.sealed);
725
- }
726
- RelayTeamSeal2.open = open;
727
- function isKey(box) {
728
- return typeof box === "string" && /^[A-Za-z0-9_-]{80,100}$/.test(box) && RelayBytes.fromBase64(box).length === 65;
729
- }
730
- RelayTeamSeal2.isKey = isKey;
731
- })(RelayTeamSeal || (RelayTeamSeal = {}));
732
- var RelayTeamLinkUtil;
733
- (function(RelayTeamLinkUtil2) {
734
- const ID = /^[A-Za-z0-9_-]{16,64}$/;
735
- function format(link) {
736
- const fragment = new URLSearchParams({ v: "1", h: link.host, d: link.device, k: link.key, o: link.owner, r: link.role });
737
- if (link.what) {
738
- fragment.set("w", link.what);
739
- }
740
- if (link.language) {
741
- fragment.set("l", link.language);
742
- }
743
- return `${link.relay.replace(/\/+$/, "")}${RELAY_JOIN_PATH}#${fragment}`;
744
- }
745
- RelayTeamLinkUtil2.format = format;
746
- function parse(text) {
747
- var _a;
748
- var _b, _c, _d;
749
- let url;
750
- try {
751
- url = new URL(text.trim());
752
- } catch (_e) {
753
- return;
754
- }
755
- const fragment = new URLSearchParams(url.hash.slice(1));
756
- const [host, device, key] = ["h", "d", "k"].map((name) => {
757
- var _a2;
758
- return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
759
- });
760
- if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_JOIN_PATH || fragment.get("v") !== "1" || !ID.test(host) || !ID.test(device) || !/^[A-Za-z0-9_-]{43}$/.test(key)) {
761
- return;
762
- }
763
- const what = (_a = fragment.get("w")) === null || _a === undefined ? undefined : _a.slice(0, 80);
764
- const language = (_b = fragment.get("l")) !== null && _b !== undefined ? _b : "";
765
- return {
766
- relay: url.origin,
767
- host,
768
- device,
769
- key,
770
- owner: (_c = fragment.get("o")) !== null && _c !== undefined ? _c : "",
771
- role: (_d = fragment.get("r")) !== null && _d !== undefined ? _d : "",
772
- ...what ? { what } : {},
773
- .../^[a-z]{2}(-[A-Za-z]{2,4})?$/.test(language) ? { language } : {}
774
- };
775
- }
776
- RelayTeamLinkUtil2.parse = parse;
777
- function signInFor(link, provider, handoff) {
778
- return `${format(link)}&${new URLSearchParams({ p: provider, x: handoff })}`;
779
- }
780
- RelayTeamLinkUtil2.signInFor = signInFor;
781
- function handoffOf(text) {
782
- var _a, _b;
783
- let url;
784
- try {
785
- url = new URL(text.trim());
786
- } catch (_c) {
787
- return;
788
- }
789
- const fragment = new URLSearchParams(url.hash.slice(1));
790
- const provider = (_a = fragment.get("p")) !== null && _a !== undefined ? _a : "";
791
- const handoff = (_b = fragment.get("x")) !== null && _b !== undefined ? _b : "";
792
- return /^[a-z0-9_-]{1,32}$/.test(provider) && /^[A-Za-z0-9_-]{16,64}$/.test(handoff) ? { provider, handoff } : undefined;
793
- }
794
- RelayTeamLinkUtil2.handoffOf = handoffOf;
795
- function web(relay, pairing) {
796
- return `${relay.replace(/\/+$/, "")}${RELAY_WEB_PATH}#${new URLSearchParams({ pair: pairing })}`;
797
- }
798
- RelayTeamLinkUtil2.web = web;
799
- })(RelayTeamLinkUtil || (RelayTeamLinkUtil = {}));
800
-
801
- class RelayTeamJoining {
802
- constructor(link) {
803
- this.closed = false;
804
- this.calls = new RelayHostCalls({ relay: link.relay, host: link.host, device: link.device, key: link.key, name: link.owner }, RELAY_TEAM_PACKAGE);
805
- }
806
- get keys() {
807
- return this.own;
808
- }
809
- async ways(via) {
810
- try {
811
- return await this.calls.callHost("ways", via ? { via } : {});
812
- } catch (failure) {
813
- if (RelayTeamJoining.unreachable(failure)) {
814
- throw failure;
815
- }
816
- return { providers: [], required: false };
817
- }
818
- }
819
- static unreachable(failure) {
820
- return /did not answer|was lost/i.test(failure instanceof Error ? failure.message : String(failure));
821
- }
822
- async signIn(provider, handoff) {
823
- return await this.calls.callHost("signIn", { provider, ...handoff ? { handoff } : {} });
824
- }
825
- async signedIn(state, code) {
826
- const answer = await this.calls.callHost("signedIn", { state, code });
827
- return { account: answer.account };
828
- }
829
- async typed(state, until = Date.now() + 15 * 60000) {
830
- while (!this.closed && Date.now() < until) {
831
- let answer;
832
- try {
833
- answer = await this.calls.callHost("signedIn", { state });
834
- } catch (failure) {
835
- if (this.closed) {
836
- return;
837
- }
838
- if (!RelayTeamJoining.unreachable(failure)) {
839
- throw failure;
840
- }
841
- await new Promise((resolve) => setTimeout(resolve, 1000));
842
- continue;
843
- }
844
- if (answer.status === "done" && answer.account) {
845
- return answer.account;
846
- }
847
- }
848
- return;
849
- }
850
- async handedOff(handoff, until = Date.now() + 10 * 60000) {
851
- while (!this.closed && Date.now() < until) {
852
- try {
853
- const answer = await this.calls.callHost("handedOff", handoff);
854
- if (answer.status === "done" && answer.account) {
855
- return answer.account;
856
- }
857
- } catch (_a) {
858
- await new Promise((resolve) => setTimeout(resolve, 1000));
859
- }
860
- }
861
- return;
862
- }
863
- async ask(name, via, signIn) {
864
- const own = await RelayTeamSeal.keys(name || "ta");
865
- const answer = await this.calls.callHost("ask", { name, box: own.box, ...via ? { via } : {}, ...signIn ? { signIn } : {} });
866
- if (answer.status !== "refused") {
867
- this.own = own;
868
- }
869
- return answer;
870
- }
871
- resume(keys) {
872
- this.own = keys;
873
- }
874
- async wait(request) {
875
- for (;; ) {
876
- if (this.closed) {
877
- return { status: "gone" };
878
- }
879
- const answer = await this.calls.callHost("wait", request);
880
- if (answer.status !== "waiting") {
881
- return answer;
882
- }
883
- }
884
- }
885
- async pairing(request, answer) {
886
- if (!this.own) {
887
- throw new Error("Ask first.");
888
- }
889
- const device = JSON.parse(await RelayTeamSeal.open(this.own, answer, request));
890
- return RelayPairingUtil.link(RelayPairingUtil.parse(RelayPairingUtil.link(device)));
891
- }
892
- close() {
893
- this.closed = true;
894
- this.calls.close();
895
- }
896
- }
897
-
898
- // web-src/i18n.ts
899
- var EN = {
900
- title: "Members",
901
- loading: "Loading…",
902
- inviteTitle: "Invite people into your Ta",
903
- inviteLine: "They see your agents, conversations and tasks, and work with you; what each may do is their role",
904
- invite: "Invite",
905
- joinOther: "Join another Ta by a link",
906
- joinPlaceholder: "The link of the invitation",
907
- notInvite: "That is not a link that invites into a Ta.",
908
- meAs: "You are in {owner}’s Ta as {role}",
909
- youMay: "What you may do",
910
- myRequests: "What you asked for",
911
- waiting: "Waiting",
912
- granted: "Granted",
913
- refusedStatus: "Refused",
914
- expiredStatus: "Expired",
915
- pending: "Waiting for your answer",
916
- joinRow: "asks to come in by a link",
917
- accessRow: "asks to {action}",
918
- accessWhere: "in {path}",
919
- refuse: "Refuse",
920
- letIn: "Let in",
921
- hour: "1 hour",
922
- day: "1 day",
923
- always: "For good",
924
- members: "Members",
925
- you: "You",
926
- owner: "Owner",
927
- online: "Online",
928
- fromBrowser: "Browser",
929
- offline: "Offline",
930
- lookingAt: "Looking at {title}",
931
- typingIn: "Typing in {title}",
932
- follow: "Follow",
933
- remove: "Remove",
934
- removeTitle: "Remove {name}?",
935
- removeHint: "Their devices are cut off at once, and what they were doing stops. Conversations they started stay.",
936
- changeRole: "Role",
937
- links: "Links that invite",
938
- linkLine: "{uses} joined · until {date}",
939
- linkApprove: "you let each in",
940
- linkOpen: "in at once",
941
- copy: "Copy",
942
- copied: "Copied",
943
- stop: "Stop",
944
- send: "Send",
945
- roles: "Roles",
946
- newRole: "New role",
947
- preset: "Comes with Ta",
948
- roleActions: "{n} things",
949
- dirs: "Folders shared",
950
- dirsLine: "Files and commands of those let in stay in these, unless their role names its own",
951
- addDir: "Add a folder",
952
- dirPlaceholder: "An absolute path, such as /Users/me/work",
953
- record: "Record",
954
- nothing: "Nothing yet",
955
- inviteDialog: "Invite into your Ta",
956
- role: "Role",
957
- lasts: "The link works for",
958
- days: "{n} days",
959
- approve: "I let each one in",
960
- approveHint: "Off: whoever opens the link is in at once. Keep it on unless you sent it to people you trust only.",
961
- makeLink: "Make the link",
962
- making: "Making the link…",
963
- inviteHint: "Send it: they open it in Ta, or in a browser without Ta, and ask to come in, with a name of their own (anonymous) or signed in with an account, as they like. From a browser, only one signed in gets a role that manages members.",
964
- joinNeedsAccount: "{owner} asks you to sign in with an account: they see who you are, and it is you from any device.",
965
- orSignIn: "Without signing in you are anonymous, by the name you give. Or sign in, so that they see who you are:",
966
- anonymous: "Anonymous",
967
- signInWith: "Sign in with {provider}",
968
- signingInBrowser: "Sign in with {provider} in the browser that opened…",
969
- signingInHint: "Once signed in there, come back here: Ta goes on by itself.",
970
- signInGone: "The sign-in took too long: try again.",
971
- typeCode: "Enter this code at {provider} to show it is you:",
972
- typeCodeHint: "Once you authorize it at {provider}, Ta goes on by itself.",
973
- copyOpen: "Copy and open {provider}",
974
- codeCopied: "Copied: paste it in the page that opened.",
975
- roleDialog: "Role",
976
- roleName: "Name",
977
- roleDirs: "Its folders (one per line); empty: the folders shared",
978
- save: "Save",
979
- deleteRole: "Delete",
980
- cancel: "Cancel",
981
- risky: "reaches beyond what Ta checks: only for people you trust",
982
- requestTitle: "Ask for “{action}”",
983
- requestLead: "The owner of this Ta or an admin answers; you are told here.",
984
- reasonPlaceholder: "Why, in a sentence (optional)",
985
- ask: "Ask",
986
- asked: "Asked: you are told when they answer.",
987
- joinTitle: "Join {owner}’s Ta",
988
- joinLead: "You ask to come in as {role}. Once in, you work in their Ta: their agents, conversations and tasks, as your role lets.",
989
- yourName: "Your name, as they see it",
990
- askJoin: "Ask to come in",
991
- joinWaiting: "Waiting for {owner} to let you in…",
992
- joinRefused: "{owner} did not let you in.",
993
- joinGone: "The link no longer invites: ask for a new one.",
994
- joinConnecting: "In: connecting to {owner}’s Ta…",
995
- joinOld: "This Ta app cannot switch by itself: update it, or pair with this link in Settings.",
996
- close: "Close",
997
- inboxJoin: "{name} asks to come into your Ta",
998
- inboxAccess: "{name} asks to {action}",
999
- open: "Open",
1000
- visibility: "Who sees it",
1001
- visibilityPrivate: "Only you see this conversation. Let members see it again?",
1002
- visibilityShared: "Members see this conversation. Make it yours alone?",
1003
- makePrivate: "Only me",
1004
- makeShared: "Let members see it",
1005
- privateDone: "Only you (and those you give it) see this conversation now.",
1006
- publicDone: "Members see this conversation again.",
1007
- "role.admin": "Admin",
1008
- "role.collaborator": "Collaborator",
1009
- "role.viewer": "Viewer",
1010
- "role.guest": "Guest",
1011
- "what.invite": "{who} made a link that invites ({role})",
1012
- "what.uninvite": "{who} stopped a link",
1013
- "what.ask": "{name} asked to come in",
1014
- "what.join": "{who} let {name} in ({role})",
1015
- "what.refuse": "{who} did not let {name} in",
1016
- "what.remove": "{who} removed {name}",
1017
- "what.role": "{who} changed the role of {member} to {role}",
1018
- "what.roles": "{who} changed the roles",
1019
- "what.grant": "{who} let {member} {action}",
1020
- "what.revoke": "{who} took back {action} from {member}",
1021
- "what.request": "{who} asked to {action}",
1022
- "what.answer": "{who} answered a request",
1023
- "what.denied": "{who} was refused {action}",
1024
- "what.private": "{who} changed who sees a conversation",
1025
- "what.dirs": "{who} changed the folders shared",
1026
- tabMembers: "Members",
1027
- tabRoles: "Roles",
1028
- tabRecord: "Record",
1029
- memberTitle: "Member",
1030
- memberSince: "Joined {date} · let in by {by}",
1031
- shared: "Shared on its own",
1032
- shareSome: "Share an agent or a channel",
1033
- shareDialog: "Share with {name}",
1034
- shareLevel: "They may",
1035
- levelView: "See",
1036
- levelUse: "Use",
1037
- levelEdit: "Change",
1038
- levelViewHint: "See it and what it said",
1039
- levelUseHint: "Talk with it, ask it to work",
1040
- levelEditHint: "Also change its role and settings",
1041
- shareFiles: "Let its tools work in its folder",
1042
- shareFilesHint: "Without it, the agent works for them only where their role reaches",
1043
- shareAction: "Share",
1044
- unshare: "Stop sharing",
1045
- agentKind: "Agent",
1046
- channelKind: "Channel",
1047
- nothingToShare: "No agents or channels yet",
1048
- grants: "Granted",
1049
- grantUntil: "until {date}",
1050
- grantAlways: "for good",
1051
- revoke: "Take back",
1052
- inviteWhat: "What they get",
1053
- inviteWhole: "Work in my Ta",
1054
- inviteWholeHint: "They see what their role lets: agents, conversations, tasks",
1055
- inviteOnly: "Only some agents or channels",
1056
- inviteOnlyHint: "They see only these, and nothing else of yours",
1057
- pickShared: "Pick what to share",
1058
- scope: "Sees",
1059
- scopeAll: "Everything of the owner’s but what is private",
1060
- scopeShared: "Only what is shared with them",
1061
- outside: "Outside the folders",
1062
- outsideDeny: "Never",
1063
- outsideAsk: "Ask me each folder",
1064
- outsideRead: "Read; ask to change",
1065
- outsideAllow: "As inside",
1066
- outsideDenyHint: "Files and commands stay inside the folders",
1067
- outsideAskHint: "Ta asks you for each other folder, and goes on once you allow it",
1068
- outsideReadHint: "Reading anywhere; changing files or running commands elsewhere needs your yes",
1069
- outsideAllowHint: "Anywhere but the folders Ta keeps to itself",
1070
- limits: "Limits",
1071
- limitMembers: "Members at most",
1072
- limitOnline: "People online at once",
1073
- limitDevices: "Devices of one person at once",
1074
- limitRunning: "Their runs at once",
1075
- limitsHint: "More than this is refused, with a note to try again later",
1076
- saveLimits: "Save",
1077
- recordAll: "All",
1078
- recordNotable: "Risky only",
1079
- recordWho: "Everyone",
1080
- recordSearch: "Search the record",
1081
- analyze: "Ask Ta to look into it",
1082
- analyzeHint: "Ta reads the record and the alerts, and tells you who did what that looks risky",
1083
- alerts: "Alerts",
1084
- alertsNone: "Nothing looked risky",
1085
- markSeen: "Seen",
1086
- "rule.probing": "{name} was refused again and again: probing what is let?",
1087
- "rule.protected": "{name} tried to reach a folder Ta keeps to itself",
1088
- "rule.outside": "{name}’s run tried to work outside its folders",
1089
- "rule.dangerous": "{name}: {detail}",
1090
- "rule.burst": "{name} made more calls than a person makes",
1091
- refusedTag: "Refused",
1092
- dangerTag: "Risky",
1093
- "what.call": "{who}: {name}",
1094
- "what.tool": "{who}’s run: {name}",
1095
- "what.connect": "{who} connected",
1096
- "what.alert": "Alert about {who}",
1097
- "what.limits": "{who} changed the limits",
1098
- sharedWithMe: "Shared with you",
1099
- fromTa: "From {owner}’s Ta",
1100
- openShared: "Opening in {owner}’s Ta…",
1101
- sharedGone: "It is no longer shared with you",
1102
- inboxAlert: "Look at what {name} did in your Ta",
1103
- joinWhat: "They share {what} with you: once in, you see that and nothing else of theirs, and use it from your own Ta too.",
1104
- autoTag: "Asked by Ta"
171
+ // web-src/i18n-ja.ts
172
+ var JA = {
173
+ title: "メンバーと権限",
174
+ inviteTitle: "あなたの Ta に人を招待する",
175
+ inviteLine: "メンバーはあなたのエージェント、会話、タスクが見え、一緒に作業できます。各自ができることはロールで決まります",
176
+ invite: "招待",
177
+ joinOther: "招待リンクで他の Ta に参加",
178
+ joinPlaceholder: "招待リンク",
179
+ notInvite: "これは Ta の招待リンクではありません。",
180
+ meAs: "「{role}」として {owner} の Ta に参加しています",
181
+ youMay: "あなたができること",
182
+ myRequests: "私のリクエスト",
183
+ waiting: "待機中",
184
+ granted: "同意済み",
185
+ refusedStatus: "却下",
186
+ expiredStatus: "期限切れ",
187
+ pending: "あなたの対応を待機中",
188
+ joinRow: "リンクを通じて参加をリクエスト",
189
+ accessRow: "「{action}」をリクエスト",
190
+ accessWhere: "範囲 {path}",
191
+ refuse: "却下",
192
+ letIn: "同意",
193
+ hour: "1 時間",
194
+ day: "1 日",
195
+ always: "ずっと",
196
+ members: "メンバー",
197
+ you: "あなた",
198
+ owner: "オーナー",
199
+ online: "オンライン",
200
+ fromBrowser: "ブラウザ",
201
+ offline: "オフライン",
202
+ lookingAt: "「{title}」を見ています",
203
+ typingIn: "「{title}」に入力中",
204
+ follow: "フォロー",
205
+ remove: "削除",
206
+ removeTitle: "{name} を削除しますか?",
207
+ removeHint: "デバイスはすぐに切断され、代わりに行っていたことは停止します。開始した会話は保持されます。",
208
+ changeRole: "ロール",
209
+ links: "招待リンク",
210
+ linkLine: "{uses} 人が参加 · {date} まで有効",
211
+ linkApprove: "あなたの同意が必要",
212
+ linkOpen: "リンクを開くとすぐに参加",
213
+ copy: "コピー",
214
+ stop: "無効化",
215
+ roles: "ロール",
216
+ newRole: "新しいロール",
217
+ preset: "Ta が用意",
218
+ roleActions: "{n} 項目の権限",
219
+ dirs: "共有フォルダ",
220
+ dirsLine: "メンバーがファイルの読み書きやコマンド実行をできる場所。ロールが指定していない限り",
221
+ addDir: "フォルダを追加",
222
+ dirPlaceholder: "絶対パス(例:/Users/me/work)",
223
+ record: "レコード",
224
+ nothing: "まだなし",
225
+ inviteDialog: "あなたの Ta に招待",
226
+ inviteGets: "相手があなたの Ta への参加を申請し、許可すると参加します",
227
+ role: "ロール",
228
+ lasts: "リンクの有効期限",
229
+ days: "{n} 日",
230
+ approve: "各メンバーの参加に私の同意が必要",
231
+ approveHint: "オフの場合、リンクを開いた人は直接参加します。信頼できる人にだけ送信する場合以外は、オンのままをお勧めします。",
232
+ makeLink: "リンクを生成",
233
+ making: "リンク生成中…",
234
+ inviteHint: "リンクを送信:相手が Ta で開くか、Ta なしでもブラウザで直接開いて、参加をリクエストできます。サインインするかどうかは相手の選択:名前を入力すれば匿名で参加、またはアカウントでサインインして自分が誰かを相手に知らせることもできます。ブラウザから参加する人は管理者になるためにはサインインが必要です。",
235
+ joinNeedsAccount: "{owner} はアカウントでサインインして申請するよう求めています。相手はあなたが誰かが分かり、別のデバイスからでも同じ人です。",
236
+ orSignIn: "サインインしなければ匿名で参加:相手には入力した名前が見えます。またはサインインして、相手にあなたが誰かを知らせることもできます:",
237
+ anonymous: "匿名",
238
+ signInWith: "{provider} でサインイン",
239
+ signingInBrowser: "開いたブラウザで {provider} を使ってサインイン…",
240
+ signingInHint: "サインイン後、ここに戻ってください:Ta は自動で続行します。",
241
+ signInGone: "サインインに時間がかかりすぎました。もう一度試してください。",
242
+ typeCode: "{provider}でこのコードを入力して本人確認してください:",
243
+ typeCodeHint: "{provider}で承認すると、Ta が自動で続行します。",
244
+ copyOpen: "コピーして{provider}を開く",
245
+ codeCopied: "コピーしました。開いたページに貼り付けてください。",
246
+ roleDialog: "ロール",
247
+ roleName: "名前",
248
+ roleDirs: "制限フォルダ(1 行に 1 つ)。空欄の場合は共有フォルダを使用",
249
+ save: "保存",
250
+ deleteRole: "削除",
251
+ cancel: "キャンセル",
252
+ risky: "Ta がチェックする範囲外のものにアクセスできます。信頼できる人だけに許可してください",
253
+ requestTitle: "「{action}」をリクエスト",
254
+ requestLead: "この Ta のオーナーまたは管理者が処理します。ここに結果が表示されます。",
255
+ reasonPlaceholder: "理由を 1 文で説明(省略可能)",
256
+ ask: "リクエスト",
257
+ asked: "リクエスト済み:相手が対応したら通知されます。",
258
+ joinTitle: "{owner} の Ta に参加",
259
+ joinLead: "「{role}」として参加をリクエストします。参加後、相手の Ta で作業します:ロールに従ってエージェント、会話、タスクを使用できます。",
260
+ yourName: "あなたの名前(相手に見えます)",
261
+ askJoin: "参加をリクエスト",
262
+ joinWaiting: "{owner} の同意を待機中…",
263
+ joinRefused: "{owner} は同意しませんでした。",
264
+ joinGone: "このリンクはもう有効ではありません。相手に新しいリンクをもらってください。",
265
+ joinConnecting: "同意されました。{owner} の Ta に接続中…",
266
+ joinOld: "このバージョンの Ta は自動切り替えができません。Ta を更新してください。",
267
+ close: "閉じる",
268
+ inboxJoin: "{name} があなたの Ta への参加をリクエスト",
269
+ inboxAccess: "{name} が「{action}」をリクエスト",
270
+ open: "表示",
271
+ visibility: "誰が見ることができるか",
272
+ visibilityPrivate: "この会話は現在あなたにだけ見えます。メンバーにも見せますか?",
273
+ visibilityShared: "この会話はメンバーに見えます。あなただけに変更しますか?",
274
+ makePrivate: "自分だけが見える",
275
+ makeShared: "メンバーが見える",
276
+ privateDone: "この会話はあなた(と権限を与えた人)だけが見えるようになりました。",
277
+ publicDone: "メンバーはこの会話が見えるようになりました。",
278
+ "role.admin": "管理者",
279
+ "role.collaborator": "共同作業者",
280
+ "role.viewer": "表示のみ",
281
+ "role.guest": "ゲスト",
282
+ "what.invite": "{who} が招待リンクを生成しました({role})",
283
+ "what.uninvite": "{who} が招待リンクを無効化",
284
+ "what.ask": "{name} が参加をリクエスト",
285
+ "what.join": "{who} が {name} を参加させました({role})",
286
+ "what.refuse": "{who} が {name} を却下",
287
+ "what.remove": "{who} が {name} を削除",
288
+ "what.role": "{who} が {member} のロールを {role} に変更",
289
+ "what.roles": "{who} がロールを変更",
290
+ "what.grant": "{who} が {member} に「{action}」を許可",
291
+ "what.revoke": "{who} が {member} から「{action}」を取り消し",
292
+ "what.request": "{who} が「{action}」をリクエスト",
293
+ "what.answer": "{who} がリクエストに対応",
294
+ "what.denied": "{who} は「{action}」を却下",
295
+ "what.private": "{who} が会話の表示範囲を変更",
296
+ "what.dirs": "{who} が共有フォルダを変更",
297
+ tabMembers: "メンバー",
298
+ tabRoles: "ロールと権限",
299
+ tabRecord: "レコード",
300
+ memberTitle: "メンバー",
301
+ memberSince: "{date} に参加 · {by} に許可",
302
+ shared: "単独で共有",
303
+ shareSome: "エージェントまたはチャンネルを共有",
304
+ shareDialog: "{name} と共有",
305
+ shareLevel: "相手ができること",
306
+ levelView: "表示",
307
+ levelUse: "使用",
308
+ levelEdit: "変更",
309
+ levelViewHint: "それと言ったことが見える",
310
+ levelUseHint: "それと対話、作業を依頼",
311
+ levelEditHint: "ロールと設定も変更できます",
312
+ shareFiles: "ツールがそのフォルダで作業することを許可",
313
+ shareFilesHint: "チェックしない場合、ロールが許可する範囲内でのみ作業します",
314
+ shareAction: "共有",
315
+ unshare: "共有を停止",
316
+ agentKind: "エージェント",
317
+ channelKind: "チャンネル",
318
+ nothingToShare: "エージェントまたはチャンネルはまだなし",
319
+ grants: "許可済み",
320
+ grantUntil: "{date} まで",
321
+ grantAlways: "ずっと",
322
+ revoke: "取り消し",
323
+ inviteWhat: "相手が見ることができるもの",
324
+ inviteWhole: "私の Ta で一緒に作業",
325
+ inviteWholeHint: "ロールに従ってエージェント、会話、タスクが見える",
326
+ inviteOnly: "いくつかのエージェントまたはチャンネルだけ",
327
+ inviteOnlyHint: "相手はこれだけが見え、あなたの他のものは見えない",
328
+ pickShared: "共有するものを選択",
329
+ scope: "見ることができるもの",
330
+ scopeAll: "オーナーのすべて(非公開を除く)",
331
+ scopeShared: "共有されたものだけ",
332
+ outside: "共有フォルダ外",
333
+ outsideDeny: "許可しない",
334
+ outsideAsk: "フォルダごとに確認",
335
+ outsideRead: "読み取り可能。変更は要相談",
336
+ outsideAllow: "フォルダ内と同じ",
337
+ outsideDenyHint: "ファイルの読み書きとコマンド実行は共有フォルダ内のみ",
338
+ outsideAskHint: "Ta が他のフォルダにアクセスする前に確認してから自動で続行",
339
+ outsideReadHint: "どこからでも読み取り可能。他の場所でのファイル変更やコマンド実行は要相談",
340
+ outsideAllowHint: "Ta 自身が保留するフォルダ以外のどこでも",
341
+ limits: "制限",
342
+ limitMembers: "メンバー数上限",
343
+ limitOnline: "同時オンライン最多",
344
+ limitDevices: "1 人あたりの同時デバイス数上限",
345
+ limitRunning: "協作者の同時実行タスク数上限",
346
+ limitsHint: "超過時は却下され、後で再試行するよう提示されます",
347
+ saveLimits: "保存",
348
+ recordAll: "すべて",
349
+ recordNotable: "リスクがあるものだけ",
350
+ recordWho: "すべての人",
351
+ recordSearch: "レコードを検索",
352
+ analyze: "Ta に分析させる",
353
+ analyzeHint: "Ta はレコードとアラートを読み、誰がリスクのある操作をしたかを伝えます",
354
+ alerts: "アラート",
355
+ alertsNone: "リスクのある操作はなし",
356
+ markSeen: "既読",
357
+ "rule.probing": "{name} は何度も却下されました:権限の探索中ですか?",
358
+ "rule.protected": "{name} は Ta が保留するフォルダにアクセスしようとしました",
359
+ "rule.outside": "{name} のタスクが許可されたフォルダ外で作業しようとしました",
360
+ "rule.dangerous": "{name}:{detail}",
361
+ "rule.burst": "{name} は通常の人間が行うよりも多く呼び出しました",
362
+ refusedTag: "却下",
363
+ dangerTag: "リスク",
364
+ "what.call": "{who}:{name}",
365
+ "what.tool": "{who} のタスク:{name}",
366
+ "what.connect": "{who} が接続",
367
+ "what.alert": "{who} についてのアラート",
368
+ "what.limits": "{who} が制限を変更",
369
+ sharedWithMe: "他の人から共有",
370
+ fromTa: "{owner} の Ta から",
371
+ openShared: "{owner} の Ta で開き中…",
372
+ sharedGone: "これはもう共有されていません",
373
+ inboxAlert: "{name} があなたの Ta で何をしたか確認",
374
+ joinWhat: "相手は「{what}」を共有しています:参加後、これだけが見え、相手の他のものは見えず、自分の Ta でも使用できます。",
375
+ autoTag: "Ta が代わりにリクエスト"
1105
376
  };
377
+
378
+ // web-src/i18n-zh.ts
1106
379
  var ZH = {
1107
380
  title: "成员与权限",
1108
- loading: "正在读取…",
1109
381
  inviteTitle: "邀请别人一起用你的 Ta",
1110
382
  inviteLine: "他们能看到你的智能体、对话和任务,和你一起干活;每个人能做什么由角色决定",
1111
383
  invite: "邀请",
@@ -1146,9 +418,7 @@ var ZH = {
1146
418
  linkApprove: "需要你同意",
1147
419
  linkOpen: "打开即加入",
1148
420
  copy: "复制",
1149
- copied: "已复制",
1150
421
  stop: "停用",
1151
- send: "发送",
1152
422
  roles: "角色",
1153
423
  newRole: "新建角色",
1154
424
  preset: "Ta 自带",
@@ -1160,6 +430,7 @@ var ZH = {
1160
430
  record: "记录",
1161
431
  nothing: "暂时没有",
1162
432
  inviteDialog: "邀请加入你的 Ta",
433
+ inviteGets: "对方申请进入你的 Ta,你同意后加入",
1163
434
  role: "角色",
1164
435
  lasts: "链接有效期",
1165
436
  days: "{n} 天",
@@ -1310,9 +581,10 @@ var ZH = {
1310
581
  joinWhat: "对方把「{what}」分享给你:加入后你只看得到这些,看不到对方的其他东西,在你自己的 Ta 里也能用。",
1311
582
  autoTag: "Ta 代为申请"
1312
583
  };
584
+
585
+ // web-src/i18n-zh-tw.ts
1313
586
  var ZH_TW = {
1314
587
  title: "成員與權限",
1315
- loading: "正在讀取…",
1316
588
  inviteTitle: "邀請別人一起用你的 Ta",
1317
589
  inviteLine: "他們能看到你的智慧體、對話和任務,和你一起幹活;每個人能做什麼由角色決定",
1318
590
  invite: "邀請",
@@ -1353,9 +625,7 @@ var ZH_TW = {
1353
625
  linkApprove: "需要你同意",
1354
626
  linkOpen: "開啟即加入",
1355
627
  copy: "複製",
1356
- copied: "已複製",
1357
628
  stop: "停用",
1358
- send: "傳送",
1359
629
  roles: "角色",
1360
630
  newRole: "新建角色",
1361
631
  preset: "Ta 自帶",
@@ -1367,6 +637,7 @@ var ZH_TW = {
1367
637
  record: "記錄",
1368
638
  nothing: "暫時沒有",
1369
639
  inviteDialog: "邀請加入你的 Ta",
640
+ inviteGets: "對方申請進入你的 Ta,你同意後加入",
1370
641
  role: "角色",
1371
642
  lasts: "連結有效期",
1372
643
  days: "{n} 天",
@@ -1517,789 +788,1811 @@ var ZH_TW = {
1517
788
  joinWhat: "對方把「{what}」分享給你:加入後你只看得到這些,看不到對方的其他東西,在你自己的 Ta 裡也能用。",
1518
789
  autoTag: "Ta 代為申請"
1519
790
  };
1520
- var JA = {
1521
- title: "メンバーと権限",
1522
- loading: "読込中…",
1523
- inviteTitle: "あなたの Ta に人を招待する",
1524
- inviteLine: "メンバーはあなたのエージェント、会話、タスクが見え、一緒に作業できます。各自ができることはロールで決まります",
1525
- invite: "招待",
1526
- joinOther: "招待リンクで他の Ta に参加",
1527
- joinPlaceholder: "招待リンク",
1528
- notInvite: "これは Ta の招待リンクではありません。",
1529
- meAs: "「{role}」として {owner} の Ta に参加しています",
1530
- youMay: "あなたができること",
1531
- myRequests: "私のリクエスト",
1532
- waiting: "待機中",
1533
- granted: "同意済み",
1534
- refusedStatus: "却下",
1535
- expiredStatus: "期限切れ",
1536
- pending: "あなたの対応を待機中",
1537
- joinRow: "リンクを通じて参加をリクエスト",
1538
- accessRow: "「{action}」をリクエスト",
1539
- accessWhere: "範囲 {path}",
1540
- refuse: "却下",
1541
- letIn: "同意",
1542
- hour: "1 時間",
1543
- day: "1 日",
1544
- always: "ずっと",
1545
- members: "メンバー",
1546
- you: "あなた",
1547
- owner: "オーナー",
1548
- online: "オンライン",
1549
- fromBrowser: "ブラウザ",
1550
- offline: "オフライン",
1551
- lookingAt: "「{title}」を見ています",
1552
- typingIn: "「{title}」に入力中",
1553
- follow: "フォロー",
1554
- remove: "削除",
1555
- removeTitle: "{name} を削除しますか?",
1556
- removeHint: "デバイスはすぐに切断され、代わりに行っていたことは停止します。開始した会話は保持されます。",
1557
- changeRole: "ロール",
1558
- links: "招待リンク",
1559
- linkLine: "{uses} 人が参加 · {date} まで有効",
1560
- linkApprove: "あなたの同意が必要",
1561
- linkOpen: "リンクを開くとすぐに参加",
1562
- copy: "コピー",
1563
- copied: "コピーしました",
1564
- stop: "無効化",
1565
- send: "送信",
1566
- roles: "ロール",
1567
- newRole: "新しいロール",
1568
- preset: "Ta が用意",
1569
- roleActions: "{n} 項目の権限",
1570
- dirs: "共有フォルダ",
1571
- dirsLine: "メンバーがファイルの読み書きやコマンド実行をできる場所。ロールが指定していない限り",
1572
- addDir: "フォルダを追加",
1573
- dirPlaceholder: "絶対パス(例:/Users/me/work)",
1574
- record: "レコード",
1575
- nothing: "まだなし",
1576
- inviteDialog: "あなたの Ta に招待",
1577
- role: "ロール",
1578
- lasts: "リンクの有効期限",
1579
- days: "{n} 日",
1580
- approve: "各メンバーの参加に私の同意が必要",
1581
- approveHint: "オフの場合、リンクを開いた人は直接参加します。信頼できる人にだけ送信する場合以外は、オンのままをお勧めします。",
1582
- makeLink: "リンクを生成",
1583
- making: "リンク生成中…",
1584
- inviteHint: "リンクを送信:相手が Ta で開くか、Ta なしでもブラウザで直接開いて、参加をリクエストできます。サインインするかどうかは相手の選択:名前を入力すれば匿名で参加、またはアカウントでサインインして自分が誰かを相手に知らせることもできます。ブラウザから参加する人は管理者になるためにはサインインが必要です。",
1585
- joinNeedsAccount: "{owner} はアカウントでサインインして申請するよう求めています。相手はあなたが誰かが分かり、別のデバイスからでも同じ人です。",
1586
- orSignIn: "サインインしなければ匿名で参加:相手には入力した名前が見えます。またはサインインして、相手にあなたが誰かを知らせることもできます:",
1587
- anonymous: "匿名",
1588
- signInWith: "{provider} でサインイン",
1589
- signingInBrowser: "開いたブラウザで {provider} を使ってサインイン…",
1590
- signingInHint: "サインイン後、ここに戻ってください:Ta は自動で続行します。",
1591
- signInGone: "サインインに時間がかかりすぎました。もう一度試してください。",
1592
- typeCode: "{provider}でこのコードを入力して本人確認してください:",
1593
- typeCodeHint: "{provider}で承認すると、Ta が自動で続行します。",
1594
- copyOpen: "コピーして{provider}を開く",
1595
- codeCopied: "コピーしました。開いたページに貼り付けてください。",
1596
- roleDialog: "ロール",
1597
- roleName: "名前",
1598
- roleDirs: "制限フォルダ(1 行に 1 つ)。空欄の場合は共有フォルダを使用",
1599
- save: "保存",
1600
- deleteRole: "削除",
1601
- cancel: "キャンセル",
1602
- risky: "Ta がチェックする範囲外のものにアクセスできます。信頼できる人だけに許可してください",
1603
- requestTitle: "「{action}」をリクエスト",
1604
- requestLead: "この Ta のオーナーまたは管理者が処理します。ここに結果が表示されます。",
1605
- reasonPlaceholder: "理由を 1 文で説明(省略可能)",
1606
- ask: "リクエスト",
1607
- asked: "リクエスト済み:相手が対応したら通知されます。",
1608
- joinTitle: "{owner} の Ta に参加",
1609
- joinLead: "「{role}」として参加をリクエストします。参加後、相手の Ta で作業します:ロールに従ってエージェント、会話、タスクを使用できます。",
1610
- yourName: "あなたの名前(相手に見えます)",
1611
- askJoin: "参加をリクエスト",
1612
- joinWaiting: "{owner} の同意を待機中…",
1613
- joinRefused: "{owner} は同意しませんでした。",
1614
- joinGone: "このリンクはもう有効ではありません。相手に新しいリンクをもらってください。",
1615
- joinConnecting: "同意されました。{owner} の Ta に接続中…",
1616
- joinOld: "このバージョンの Ta は自動切り替えができません。Ta を更新してください。",
1617
- close: "閉じる",
1618
- inboxJoin: "{name} があなたの Ta への参加をリクエスト",
1619
- inboxAccess: "{name} が「{action}」をリクエスト",
1620
- open: "表示",
1621
- visibility: "誰が見ることができるか",
1622
- visibilityPrivate: "この会話は現在あなたにだけ見えます。メンバーにも見せますか?",
1623
- visibilityShared: "この会話はメンバーに見えます。あなただけに変更しますか?",
1624
- makePrivate: "自分だけが見える",
1625
- makeShared: "メンバーが見える",
1626
- privateDone: "この会話はあなた(と権限を与えた人)だけが見えるようになりました。",
1627
- publicDone: "メンバーはこの会話が見えるようになりました。",
1628
- "role.admin": "管理者",
1629
- "role.collaborator": "共同作業者",
1630
- "role.viewer": "表示のみ",
1631
- "role.guest": "ゲスト",
1632
- "what.invite": "{who} が招待リンクを生成しました({role})",
1633
- "what.uninvite": "{who} が招待リンクを無効化",
1634
- "what.ask": "{name} が参加をリクエスト",
1635
- "what.join": "{who} が {name} を参加させました({role})",
1636
- "what.refuse": "{who} が {name} を却下",
1637
- "what.remove": "{who} が {name} を削除",
1638
- "what.role": "{who} が {member} のロールを {role} に変更",
1639
- "what.roles": "{who} がロールを変更",
1640
- "what.grant": "{who} が {member} に「{action}」を許可",
1641
- "what.revoke": "{who} が {member} から「{action}」を取り消し",
1642
- "what.request": "{who} が「{action}」をリクエスト",
1643
- "what.answer": "{who} がリクエストに対応",
1644
- "what.denied": "{who} は「{action}」を却下",
1645
- "what.private": "{who} が会話の表示範囲を変更",
1646
- "what.dirs": "{who} が共有フォルダを変更",
1647
- tabMembers: "メンバー",
1648
- tabRoles: "ロールと権限",
1649
- tabRecord: "レコード",
1650
- memberTitle: "メンバー",
1651
- memberSince: "{date} に参加 · {by} に許可",
1652
- shared: "単独で共有",
1653
- shareSome: "エージェントまたはチャンネルを共有",
1654
- shareDialog: "{name} と共有",
1655
- shareLevel: "相手ができること",
1656
- levelView: "表示",
1657
- levelUse: "使用",
1658
- levelEdit: "変更",
1659
- levelViewHint: "それと言ったことが見える",
1660
- levelUseHint: "それと対話、作業を依頼",
1661
- levelEditHint: "ロールと設定も変更できます",
1662
- shareFiles: "ツールがそのフォルダで作業することを許可",
1663
- shareFilesHint: "チェックしない場合、ロールが許可する範囲内でのみ作業します",
1664
- shareAction: "共有",
1665
- unshare: "共有を停止",
1666
- agentKind: "エージェント",
1667
- channelKind: "チャンネル",
1668
- nothingToShare: "エージェントまたはチャンネルはまだなし",
1669
- grants: "許可済み",
1670
- grantUntil: "{date} まで",
1671
- grantAlways: "ずっと",
1672
- revoke: "取り消し",
1673
- inviteWhat: "相手が見ることができるもの",
1674
- inviteWhole: "私の Ta で一緒に作業",
1675
- inviteWholeHint: "ロールに従ってエージェント、会話、タスクが見える",
1676
- inviteOnly: "いくつかのエージェントまたはチャンネルだけ",
1677
- inviteOnlyHint: "相手はこれだけが見え、あなたの他のものは見えない",
1678
- pickShared: "共有するものを選択",
1679
- scope: "見ることができるもの",
1680
- scopeAll: "オーナーのすべて(非公開を除く)",
1681
- scopeShared: "共有されたものだけ",
1682
- outside: "共有フォルダ外",
1683
- outsideDeny: "許可しない",
1684
- outsideAsk: "フォルダごとに確認",
1685
- outsideRead: "読み取り可能。変更は要相談",
1686
- outsideAllow: "フォルダ内と同じ",
1687
- outsideDenyHint: "ファイルの読み書きとコマンド実行は共有フォルダ内のみ",
1688
- outsideAskHint: "Ta が他のフォルダにアクセスする前に確認してから自動で続行",
1689
- outsideReadHint: "どこからでも読み取り可能。他の場所でのファイル変更やコマンド実行は要相談",
1690
- outsideAllowHint: "Ta 自身が保留するフォルダ以外のどこでも",
1691
- limits: "制限",
1692
- limitMembers: "メンバー数上限",
1693
- limitOnline: "同時オンライン最多",
1694
- limitDevices: "1 人あたりの同時デバイス数上限",
1695
- limitRunning: "協作者の同時実行タスク数上限",
1696
- limitsHint: "超過時は却下され、後で再試行するよう提示されます",
1697
- saveLimits: "保存",
1698
- recordAll: "すべて",
1699
- recordNotable: "リスクがあるものだけ",
1700
- recordWho: "すべての人",
1701
- recordSearch: "レコードを検索",
1702
- analyze: "Ta に分析させる",
1703
- analyzeHint: "Ta はレコードとアラートを読み、誰がリスクのある操作をしたかを伝えます",
1704
- alerts: "アラート",
1705
- alertsNone: "リスクのある操作はなし",
1706
- markSeen: "既読",
1707
- "rule.probing": "{name} は何度も却下されました:権限の探索中ですか?",
1708
- "rule.protected": "{name} は Ta が保留するフォルダにアクセスしようとしました",
1709
- "rule.outside": "{name} のタスクが許可されたフォルダ外で作業しようとしました",
1710
- "rule.dangerous": "{name}:{detail}",
1711
- "rule.burst": "{name} は通常の人間が行うよりも多く呼び出しました",
1712
- refusedTag: "却下",
1713
- dangerTag: "リスク",
1714
- "what.call": "{who}:{name}",
1715
- "what.tool": "{who} のタスク:{name}",
1716
- "what.connect": "{who} が接続",
1717
- "what.alert": "{who} についてのアラート",
1718
- "what.limits": "{who} が制限を変更",
1719
- sharedWithMe: "他の人から共有",
1720
- fromTa: "{owner} の Ta から",
1721
- openShared: "{owner} の Ta で開き中…",
1722
- sharedGone: "これはもう共有されていません",
1723
- inboxAlert: "{name} があなたの Ta で何をしたか確認",
1724
- joinWhat: "相手は「{what}」を共有しています:参加後、これだけが見え、相手の他のものは見えず、自分の Ta でも使用できます。",
1725
- autoTag: "Ta が代わりにリクエスト"
791
+
792
+ // web-src/i18n.ts
793
+ var EN = {
794
+ title: "Members",
795
+ inviteTitle: "Invite people into your Ta",
796
+ inviteLine: "They see your agents, conversations and tasks, and work with you; what each may do is their role",
797
+ invite: "Invite",
798
+ joinOther: "Join another Ta by a link",
799
+ joinPlaceholder: "The link of the invitation",
800
+ notInvite: "That is not a link that invites into a Ta.",
801
+ meAs: "You are in {owner}’s Ta as {role}",
802
+ youMay: "What you may do",
803
+ myRequests: "What you asked for",
804
+ waiting: "Waiting",
805
+ granted: "Granted",
806
+ refusedStatus: "Refused",
807
+ expiredStatus: "Expired",
808
+ pending: "Waiting for your answer",
809
+ joinRow: "asks to come in by a link",
810
+ accessRow: "asks to {action}",
811
+ accessWhere: "in {path}",
812
+ refuse: "Refuse",
813
+ letIn: "Let in",
814
+ hour: "1 hour",
815
+ day: "1 day",
816
+ always: "For good",
817
+ members: "Members",
818
+ you: "You",
819
+ owner: "Owner",
820
+ online: "Online",
821
+ fromBrowser: "Browser",
822
+ offline: "Offline",
823
+ lookingAt: "Looking at {title}",
824
+ typingIn: "Typing in {title}",
825
+ follow: "Follow",
826
+ remove: "Remove",
827
+ removeTitle: "Remove {name}?",
828
+ removeHint: "Their devices are cut off at once, and what they were doing stops. Conversations they started stay.",
829
+ changeRole: "Role",
830
+ links: "Links that invite",
831
+ linkLine: "{uses} joined · until {date}",
832
+ linkApprove: "you let each in",
833
+ linkOpen: "in at once",
834
+ copy: "Copy",
835
+ stop: "Stop",
836
+ roles: "Roles",
837
+ newRole: "New role",
838
+ preset: "Comes with Ta",
839
+ roleActions: "{n} things",
840
+ dirs: "Folders shared",
841
+ dirsLine: "Files and commands of those let in stay in these, unless their role names its own",
842
+ addDir: "Add a folder",
843
+ dirPlaceholder: "An absolute path, such as /Users/me/work",
844
+ record: "Record",
845
+ nothing: "Nothing yet",
846
+ inviteDialog: "Invite into your Ta",
847
+ inviteGets: "They ask to come into your Ta; you let them in",
848
+ role: "Role",
849
+ lasts: "The link works for",
850
+ days: "{n} days",
851
+ approve: "I let each one in",
852
+ approveHint: "Off: whoever opens the link is in at once. Keep it on unless you sent it to people you trust only.",
853
+ makeLink: "Make the link",
854
+ making: "Making the link…",
855
+ inviteHint: "Send it: they open it in Ta, or in a browser without Ta, and ask to come in, with a name of their own (anonymous) or signed in with an account, as they like. From a browser, only one signed in gets a role that manages members.",
856
+ joinNeedsAccount: "{owner} asks you to sign in with an account: they see who you are, and it is you from any device.",
857
+ orSignIn: "Without signing in you are anonymous, by the name you give. Or sign in, so that they see who you are:",
858
+ anonymous: "Anonymous",
859
+ signInWith: "Sign in with {provider}",
860
+ signingInBrowser: "Sign in with {provider} in the browser that opened…",
861
+ signingInHint: "Once signed in there, come back here: Ta goes on by itself.",
862
+ signInGone: "The sign-in took too long: try again.",
863
+ typeCode: "Enter this code at {provider} to show it is you:",
864
+ typeCodeHint: "Once you authorize it at {provider}, Ta goes on by itself.",
865
+ copyOpen: "Copy and open {provider}",
866
+ codeCopied: "Copied: paste it in the page that opened.",
867
+ roleDialog: "Role",
868
+ roleName: "Name",
869
+ roleDirs: "Its folders (one per line); empty: the folders shared",
870
+ save: "Save",
871
+ deleteRole: "Delete",
872
+ cancel: "Cancel",
873
+ risky: "reaches beyond what Ta checks: only for people you trust",
874
+ requestTitle: "Ask for “{action}”",
875
+ requestLead: "The owner of this Ta or an admin answers; you are told here.",
876
+ reasonPlaceholder: "Why, in a sentence (optional)",
877
+ ask: "Ask",
878
+ asked: "Asked: you are told when they answer.",
879
+ joinTitle: "Join {owner}’s Ta",
880
+ joinLead: "You ask to come in as {role}. Once in, you work in their Ta: their agents, conversations and tasks, as your role lets.",
881
+ yourName: "Your name, as they see it",
882
+ askJoin: "Ask to come in",
883
+ joinWaiting: "Waiting for {owner} to let you in…",
884
+ joinRefused: "{owner} did not let you in.",
885
+ joinGone: "The link no longer invites: ask for a new one.",
886
+ joinConnecting: "In: connecting to {owner}’s Ta…",
887
+ joinOld: "This Ta app cannot switch by itself: update it, or pair with this link in Settings.",
888
+ close: "Close",
889
+ inboxJoin: "{name} asks to come into your Ta",
890
+ inboxAccess: "{name} asks to {action}",
891
+ open: "Open",
892
+ visibility: "Who sees it",
893
+ visibilityPrivate: "Only you see this conversation. Let members see it again?",
894
+ visibilityShared: "Members see this conversation. Make it yours alone?",
895
+ makePrivate: "Only me",
896
+ makeShared: "Let members see it",
897
+ privateDone: "Only you (and those you give it) see this conversation now.",
898
+ publicDone: "Members see this conversation again.",
899
+ "role.admin": "Admin",
900
+ "role.collaborator": "Collaborator",
901
+ "role.viewer": "Viewer",
902
+ "role.guest": "Guest",
903
+ "what.invite": "{who} made a link that invites ({role})",
904
+ "what.uninvite": "{who} stopped a link",
905
+ "what.ask": "{name} asked to come in",
906
+ "what.join": "{who} let {name} in ({role})",
907
+ "what.refuse": "{who} did not let {name} in",
908
+ "what.remove": "{who} removed {name}",
909
+ "what.role": "{who} changed the role of {member} to {role}",
910
+ "what.roles": "{who} changed the roles",
911
+ "what.grant": "{who} let {member} {action}",
912
+ "what.revoke": "{who} took back {action} from {member}",
913
+ "what.request": "{who} asked to {action}",
914
+ "what.answer": "{who} answered a request",
915
+ "what.denied": "{who} was refused {action}",
916
+ "what.private": "{who} changed who sees a conversation",
917
+ "what.dirs": "{who} changed the folders shared",
918
+ tabMembers: "Members",
919
+ tabRoles: "Roles",
920
+ tabRecord: "Record",
921
+ memberTitle: "Member",
922
+ memberSince: "Joined {date} · let in by {by}",
923
+ shared: "Shared on its own",
924
+ shareSome: "Share an agent or a channel",
925
+ shareDialog: "Share with {name}",
926
+ shareLevel: "They may",
927
+ levelView: "See",
928
+ levelUse: "Use",
929
+ levelEdit: "Change",
930
+ levelViewHint: "See it and what it said",
931
+ levelUseHint: "Talk with it, ask it to work",
932
+ levelEditHint: "Also change its role and settings",
933
+ shareFiles: "Let its tools work in its folder",
934
+ shareFilesHint: "Without it, the agent works for them only where their role reaches",
935
+ shareAction: "Share",
936
+ unshare: "Stop sharing",
937
+ agentKind: "Agent",
938
+ channelKind: "Channel",
939
+ nothingToShare: "No agents or channels yet",
940
+ grants: "Granted",
941
+ grantUntil: "until {date}",
942
+ grantAlways: "for good",
943
+ revoke: "Take back",
944
+ inviteWhat: "What they get",
945
+ inviteWhole: "Work in my Ta",
946
+ inviteWholeHint: "They see what their role lets: agents, conversations, tasks",
947
+ inviteOnly: "Only some agents or channels",
948
+ inviteOnlyHint: "They see only these, and nothing else of yours",
949
+ pickShared: "Pick what to share",
950
+ scope: "Sees",
951
+ scopeAll: "Everything of the owner’s but what is private",
952
+ scopeShared: "Only what is shared with them",
953
+ outside: "Outside the folders",
954
+ outsideDeny: "Never",
955
+ outsideAsk: "Ask me each folder",
956
+ outsideRead: "Read; ask to change",
957
+ outsideAllow: "As inside",
958
+ outsideDenyHint: "Files and commands stay inside the folders",
959
+ outsideAskHint: "Ta asks you for each other folder, and goes on once you allow it",
960
+ outsideReadHint: "Reading anywhere; changing files or running commands elsewhere needs your yes",
961
+ outsideAllowHint: "Anywhere but the folders Ta keeps to itself",
962
+ limits: "Limits",
963
+ limitMembers: "Members at most",
964
+ limitOnline: "People online at once",
965
+ limitDevices: "Devices of one person at once",
966
+ limitRunning: "Their runs at once",
967
+ limitsHint: "More than this is refused, with a note to try again later",
968
+ saveLimits: "Save",
969
+ recordAll: "All",
970
+ recordNotable: "Risky only",
971
+ recordWho: "Everyone",
972
+ recordSearch: "Search the record",
973
+ analyze: "Ask Ta to look into it",
974
+ analyzeHint: "Ta reads the record and the alerts, and tells you who did what that looks risky",
975
+ alerts: "Alerts",
976
+ alertsNone: "Nothing looked risky",
977
+ markSeen: "Seen",
978
+ "rule.probing": "{name} was refused again and again: probing what is let?",
979
+ "rule.protected": "{name} tried to reach a folder Ta keeps to itself",
980
+ "rule.outside": "{name}’s run tried to work outside its folders",
981
+ "rule.dangerous": "{name}: {detail}",
982
+ "rule.burst": "{name} made more calls than a person makes",
983
+ refusedTag: "Refused",
984
+ dangerTag: "Risky",
985
+ "what.call": "{who}: {name}",
986
+ "what.tool": "{who}’s run: {name}",
987
+ "what.connect": "{who} connected",
988
+ "what.alert": "Alert about {who}",
989
+ "what.limits": "{who} changed the limits",
990
+ sharedWithMe: "Shared with you",
991
+ fromTa: "From {owner}’s Ta",
992
+ openShared: "Opening in {owner}’s Ta…",
993
+ sharedGone: "It is no longer shared with you",
994
+ inboxAlert: "Look at what {name} did in your Ta",
995
+ joinWhat: "They share {what} with you: once in, you see that and nothing else of theirs, and use it from your own Ta too.",
996
+ autoTag: "Asked by Ta"
997
+ };
998
+ var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
999
+ var TeamWords;
1000
+ ((TeamWords) => {
1001
+ function of(language) {
1002
+ return TaLanguageUtil.pick(language, WORDS);
1003
+ }
1004
+ TeamWords.of = of;
1005
+ function format(text, values) {
1006
+ return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
1007
+ }
1008
+ TeamWords.format = format;
1009
+ })(TeamWords ||= {});
1010
+
1011
+ // web-src/protocol.ts
1012
+ var NAME = "@celljs/ta-team";
1013
+ var INBOX_KEY = "inbox";
1014
+ var JOINED_KEY = "joined";
1015
+ var LIMIT_RANGE = {
1016
+ members: [1, 500],
1017
+ online: [1, 200],
1018
+ devices: [1, 20],
1019
+ running: [1, 50]
1020
+ };
1021
+ var ALL_ACTIONS = TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id)).map((action2) => action2.id);
1022
+ var PRESET_ROLES = [
1023
+ { id: "admin", name: "admin", preset: true, scope: "all", outside: "allow", dirs: ["/"], actions: ALL_ACTIONS },
1024
+ {
1025
+ id: "collaborator",
1026
+ name: "collaborator",
1027
+ preset: true,
1028
+ scope: "all",
1029
+ outside: "ask",
1030
+ actions: [
1031
+ "chat.view",
1032
+ "chat.send",
1033
+ "chat.create",
1034
+ "chat.stop",
1035
+ "chat.share",
1036
+ "agent.view",
1037
+ "agent.use",
1038
+ "channel.view",
1039
+ "channel.post",
1040
+ "task.view",
1041
+ "task.create",
1042
+ "files.read",
1043
+ "files.write",
1044
+ "models.use",
1045
+ "extensions.use",
1046
+ "settings.view",
1047
+ "members.view"
1048
+ ]
1049
+ },
1050
+ {
1051
+ id: "viewer",
1052
+ name: "viewer",
1053
+ preset: true,
1054
+ scope: "all",
1055
+ outside: "deny",
1056
+ actions: ["chat.view", "agent.view", "channel.view", "task.view", "files.read", "extensions.use", "settings.view", "members.view"]
1057
+ },
1058
+ { id: "guest", name: "guest", preset: true, scope: "shared", outside: "deny", actions: ["models.use", "extensions.use"] }
1059
+ ];
1060
+ var DEFAULT_ROLE = "collaborator";
1061
+
1062
+ // web-src/react.ts
1063
+ var React;
1064
+ function bind(react) {
1065
+ React = react;
1066
+ }
1067
+
1068
+ // web-src/page.ts
1069
+ var pi;
1070
+ function bindPage(api) {
1071
+ pi = api;
1072
+ }
1073
+ function t(key, values = {}) {
1074
+ return TeamWords.format(TeamWords.of(pi.ui.language)[key], values);
1075
+ }
1076
+ function actionTitle(action2) {
1077
+ return TaActionUtil.title(action2, pi.ui.language);
1078
+ }
1079
+ function roleName(role) {
1080
+ if (!role) {
1081
+ return "?";
1082
+ }
1083
+ const key = `role.${role.id}`;
1084
+ return role.preset && key in TeamWords.of("en") ? t(key) : role.name;
1085
+ }
1086
+ var PROVIDERS = { github: "GitHub", google: "Google", wechat: "WeChat", oidc: "SSO" };
1087
+ function accountLine(account) {
1088
+ if (!account) {
1089
+ return "";
1090
+ }
1091
+ const at = account.id.indexOf(":");
1092
+ const provider = account.id.slice(0, at);
1093
+ const name = book.get().overview?.providers.find((one) => one.id === provider)?.name ?? PROVIDERS[provider] ?? provider;
1094
+ return provider === "wechat" ? TaLanguageUtil.pick(pi.ui.language, { "zh-CN": "微信", "zh-TW": "微信", "en-US": name, "ja-JP": name }) : `${name} ${account.id.slice(at + 1)}`;
1095
+ }
1096
+ function icon(name) {
1097
+ return pi.ui.icons[name] ?? pi.ui.icons.Users ?? pi.ui.icons.Circle;
1098
+ }
1099
+ function message(error) {
1100
+ return error instanceof Error ? error.message : String(error);
1101
+ }
1102
+ function call(method, ...params) {
1103
+ return pi.callHost(method, ...params);
1104
+ }
1105
+
1106
+ class TeamBook {
1107
+ state = {};
1108
+ listeners = new Set;
1109
+ loading;
1110
+ get() {
1111
+ return this.state;
1112
+ }
1113
+ subscribe(listener) {
1114
+ this.listeners.add(listener);
1115
+ return () => this.listeners.delete(listener);
1116
+ }
1117
+ load() {
1118
+ this.loading ??= (async () => {
1119
+ try {
1120
+ const me = await call("me");
1121
+ let overview;
1122
+ if (me.owner || me.actions.includes("members.view")) {
1123
+ overview = await call("overview").catch(() => {
1124
+ return;
1125
+ });
1126
+ }
1127
+ this.set({ me, overview, error: undefined });
1128
+ } catch (error) {
1129
+ this.set({ error: message(error) });
1130
+ } finally {
1131
+ this.loading = undefined;
1132
+ }
1133
+ })();
1134
+ return this.loading;
1135
+ }
1136
+ set(state) {
1137
+ this.state = { ...this.state, ...state };
1138
+ for (const listener of this.listeners) {
1139
+ listener();
1140
+ }
1141
+ }
1142
+ }
1143
+ var book = new TeamBook;
1144
+ function useBook() {
1145
+ return React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get());
1146
+ }
1147
+ async function act(action2) {
1148
+ try {
1149
+ await action2();
1150
+ return true;
1151
+ } catch (error) {
1152
+ pi.ui.notify(message(error), "error");
1153
+ return false;
1154
+ } finally {
1155
+ await book.load();
1156
+ }
1157
+ }
1158
+ function watchInbox() {
1159
+ let last;
1160
+ const read = async () => {
1161
+ const inbox = await pi.storage.get(INBOX_KEY).catch(() => {
1162
+ return;
1163
+ });
1164
+ const latest = inbox?.latest;
1165
+ if (latest && latest.at !== last?.latest?.at && Date.now() - latest.at < 60000) {
1166
+ pi.ui.notify(latest.kind === "join" ? t("inboxJoin", { name: latest.name }) : t("inboxAccess", { name: latest.name, action: actionTitle(latest.action ?? "") }));
1167
+ }
1168
+ last = inbox;
1169
+ book.load();
1170
+ };
1171
+ pi.storage.get(INBOX_KEY).then((inbox) => {
1172
+ last = inbox;
1173
+ });
1174
+ return pi.storage.onChange((keys) => {
1175
+ if (keys.includes(INBOX_KEY)) {
1176
+ read();
1177
+ }
1178
+ });
1179
+ }
1180
+ function dateOf(at) {
1181
+ return new Date(at).toLocaleDateString(pi.ui.language, { month: "numeric", day: "numeric" });
1182
+ }
1183
+ function timeOf(at) {
1184
+ const date = new Date(at);
1185
+ const today = new Date;
1186
+ return date.toDateString() === today.toDateString() ? date.toLocaleTimeString(pi.ui.language, { hour: "2-digit", minute: "2-digit" }) : date.toLocaleDateString(pi.ui.language, { month: "numeric", day: "numeric" });
1187
+ }
1188
+
1189
+ // web-src/parts.tsx
1190
+ function Section({ title, children, end }) {
1191
+ return /* @__PURE__ */ React.createElement("section", {
1192
+ className: "ttm-section"
1193
+ }, /* @__PURE__ */ React.createElement("h3", null, /* @__PURE__ */ React.createElement("span", null, title), end), /* @__PURE__ */ React.createElement("ul", {
1194
+ className: "ttm-card"
1195
+ }, children));
1196
+ }
1197
+ function Face({ seed, name, online, size = 34, double }) {
1198
+ return pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
1199
+ seed,
1200
+ size,
1201
+ online,
1202
+ double
1203
+ }) : /* @__PURE__ */ React.createElement("span", {
1204
+ className: "ttm-letter",
1205
+ style: { width: size, height: size }
1206
+ }, name.slice(0, 1).toUpperCase());
1207
+ }
1208
+ function LinkRow({ title, line, onClick, tag }) {
1209
+ const Chevron = icon("ChevronRight");
1210
+ return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
1211
+ type: "button",
1212
+ className: "ttm-row ttm-button-row",
1213
+ onClick
1214
+ }, /* @__PURE__ */ React.createElement("div", {
1215
+ className: "ttm-row-text"
1216
+ }, /* @__PURE__ */ React.createElement("span", {
1217
+ className: "ttm-row-title"
1218
+ }, title, tag), line && /* @__PURE__ */ React.createElement("span", {
1219
+ className: "ttm-row-line ttm-ellipsis"
1220
+ }, line)), /* @__PURE__ */ React.createElement(Chevron, {
1221
+ size: 15
1222
+ })));
1223
+ }
1224
+ function Segments({
1225
+ value,
1226
+ items,
1227
+ onChange
1228
+ }) {
1229
+ return /* @__PURE__ */ React.createElement("div", {
1230
+ className: "ta-segmented ttm-segments",
1231
+ role: "tablist"
1232
+ }, items.map((item) => /* @__PURE__ */ React.createElement("button", {
1233
+ key: item.id,
1234
+ type: "button",
1235
+ role: "tab",
1236
+ "aria-selected": item.id === value,
1237
+ className: item.id === value ? "ta-on" : undefined,
1238
+ onClick: () => onChange(item.id)
1239
+ }, item.label, item.badge ? /* @__PURE__ */ React.createElement("span", {
1240
+ className: "ttm-badge"
1241
+ }, item.badge > 99 ? "99+" : item.badge) : null)));
1242
+ }
1243
+ function Choices({
1244
+ value,
1245
+ items,
1246
+ onChange
1247
+ }) {
1248
+ return /* @__PURE__ */ React.createElement("div", {
1249
+ className: "ttm-choices",
1250
+ role: "radiogroup"
1251
+ }, items.map((item) => /* @__PURE__ */ React.createElement("label", {
1252
+ key: item.id,
1253
+ className: `ttm-choice${item.id === value ? " ttm-on" : ""}`
1254
+ }, /* @__PURE__ */ React.createElement("input", {
1255
+ type: "radio",
1256
+ checked: item.id === value,
1257
+ onChange: () => onChange(item.id)
1258
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, item.label), item.hint && /* @__PURE__ */ React.createElement("small", null, item.hint)))));
1259
+ }
1260
+
1261
+ // web-src/team-error.ts
1262
+ class TeamError extends Error {
1263
+ }
1264
+
1265
+ // web-src/policy.ts
1266
+ var SCOPED = new Set(["files.read", "files.write", "commands.run", "commands.terminal"]);
1267
+ var IMPLIES = {
1268
+ "agent.edit": ["agent.use", "agent.view"],
1269
+ "agent.use": ["agent.view"],
1270
+ "channel.manage": ["channel.post", "channel.view"],
1271
+ "channel.post": ["channel.view"],
1272
+ "chat.manage": ["chat.send", "chat.view", "chat.stop"],
1273
+ "chat.send": ["chat.view", "chat.stop"],
1274
+ "files.write": ["files.read"]
1726
1275
  };
1727
- var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
1728
- var TeamWords;
1729
- ((TeamWords) => {
1730
- function of(language) {
1731
- return TaLanguageUtil.pick(language, WORDS);
1276
+ function ofAction(action2, of) {
1277
+ const agent = of.kind === "agent";
1278
+ switch (action2) {
1279
+ case "chat.view":
1280
+ return agent ? "agent.view" : "channel.view";
1281
+ case "chat.send":
1282
+ case "chat.stop":
1283
+ return agent ? "agent.use" : "channel.post";
1284
+ case "chat.manage":
1285
+ case "chat.share":
1286
+ return agent ? "agent.edit" : "channel.manage";
1287
+ default:
1288
+ return;
1289
+ }
1290
+ }
1291
+ var TeamPolicy;
1292
+ ((TeamPolicy) => {
1293
+ TeamPolicy.MANAGING = ["members.invite", "members.approve", "members.roles"];
1294
+ function catalog() {
1295
+ return TA_ACTIONS.filter((action2) => TaActionUtil.inRoles(action2.id));
1296
+ }
1297
+ TeamPolicy.catalog = catalog;
1298
+ function manages(actions2) {
1299
+ return actions2.some((action2) => TeamPolicy.MANAGING.includes(action2));
1300
+ }
1301
+ TeamPolicy.manages = manages;
1302
+ function mayManage(member) {
1303
+ return !member.web || !!member.account;
1304
+ }
1305
+ TeamPolicy.mayManage = mayManage;
1306
+ function mayHold(member, role) {
1307
+ if (!mayManage(member) && manages(role.actions)) {
1308
+ throw new TeamError("Who came in from a browser without an account gets no role that manages members: they sign in with one, or join in the Ta app.");
1309
+ }
1310
+ }
1311
+ TeamPolicy.mayHold = mayHold;
1312
+ function mayBeGiven(member, action2) {
1313
+ if (member && !mayManage(member) && TeamPolicy.MANAGING.includes(action2)) {
1314
+ throw new TeamError("Who came in from a browser without an account is given nothing that manages members: they sign in with one, or join in the Ta app.");
1315
+ }
1316
+ }
1317
+ TeamPolicy.mayBeGiven = mayBeGiven;
1318
+ function roles(data) {
1319
+ return [...PRESET_ROLES, ...data.roles.filter((role) => !PRESET_ROLES.some((preset) => preset.id === role.id))];
1320
+ }
1321
+ TeamPolicy.roles = roles;
1322
+ function roleOf(data, id) {
1323
+ return roles(data).find((role) => role.id === id);
1324
+ }
1325
+ TeamPolicy.roleOf = roleOf;
1326
+ function valid(grant, now) {
1327
+ return grant.until === undefined || grant.until > now;
1328
+ }
1329
+ TeamPolicy.valid = valid;
1330
+ function gives(given, action2) {
1331
+ return given === action2 || (IMPLIES[given]?.includes(action2) ?? false);
1332
+ }
1333
+ TeamPolicy.gives = gives;
1334
+ function actions(data, principal, now) {
1335
+ const member = data.members.find((one) => one.id === principal);
1336
+ if (!member) {
1337
+ return [];
1338
+ }
1339
+ const role = roleOf(data, member.role);
1340
+ const granted = data.grants.filter((grant) => grant.member === principal && valid(grant, now) && !grant.resource).map((grant) => grant.action);
1341
+ return [...new Set([...role?.actions ?? [], ...granted])];
1342
+ }
1343
+ TeamPolicy.actions = actions;
1344
+ function isProtected(path, context) {
1345
+ return context.protectedDirs.some((dir) => TaActionUtil.inside(dir, path));
1346
+ }
1347
+ TeamPolicy.isProtected = isProtected;
1348
+ function check(data, principal, action2, resource, context) {
1349
+ const refuse = (reason, refused = action2, on2 = resource) => ({
1350
+ action: refused,
1351
+ ...on2 ? { resource: on2 } : {},
1352
+ reason,
1353
+ ...reason === "protected" || reason === "never" ? { askable: false } : {}
1354
+ });
1355
+ if (!TaActionUtil.grantable(action2)) {
1356
+ return refuse("never");
1357
+ }
1358
+ if (principal.startsWith(TA_INVITE_PREFIX)) {
1359
+ return refuse("never");
1360
+ }
1361
+ const member = data.members.find((one) => one.id === principal);
1362
+ if (!member) {
1363
+ return refuse("never");
1364
+ }
1365
+ const role = roleOf(data, member.role);
1366
+ const shared = role?.scope === "shared";
1367
+ const has = (role?.actions.includes(action2) ?? false) && TaActionUtil.inRoles(action2);
1368
+ const grants = data.grants.filter((grant) => grant.member === principal && valid(grant, context.now) && gives(grant.action, action2));
1369
+ const on = (kind, id) => grants.some((grant) => grant.resource?.kind === kind && grant.resource.id === id);
1370
+ const anywhere = grants.some((grant) => !grant.resource);
1371
+ switch (resource?.kind) {
1372
+ case "agent":
1373
+ case "channel":
1374
+ return on(resource.kind, resource.id) || !shared && (has || anywhere) || refuse(shared ? "hidden" : "role");
1375
+ case "session": {
1376
+ const author = data.authors[resource.id];
1377
+ if (author === principal && action2.startsWith("chat.")) {
1378
+ return true;
1379
+ }
1380
+ if (on("session", resource.id)) {
1381
+ return true;
1382
+ }
1383
+ if (data.private.includes(resource.id) && author !== principal) {
1384
+ return refuse("hidden");
1385
+ }
1386
+ const of = resource.of && ofAction(action2, resource.of);
1387
+ if (resource.of && of) {
1388
+ return check(data, principal, of, { kind: resource.of.kind, id: resource.of.id }, context) === true || refuse(shared ? "hidden" : "role");
1389
+ }
1390
+ if (SCOPED.has(action2)) {
1391
+ return checkPath(data, role, grants, action2, resource.cwd, context, refuse);
1392
+ }
1393
+ if (shared) {
1394
+ return refuse("hidden");
1395
+ }
1396
+ return has || anywhere || refuse("role");
1397
+ }
1398
+ default:
1399
+ if (SCOPED.has(action2)) {
1400
+ return checkPath(data, role, grants, action2, resource?.kind === "dir" ? resource.id : undefined, context, refuse);
1401
+ }
1402
+ return has || anywhere || refuse("role");
1403
+ }
1404
+ }
1405
+ TeamPolicy.check = check;
1406
+ function checkPath(data, role, grants, action2, path, context, refuse) {
1407
+ const has = role?.actions.includes(action2) ?? false;
1408
+ if (path === undefined) {
1409
+ return has || grants.some((grant) => !grant.resource) || refuse("role");
1410
+ }
1411
+ if (isProtected(path, context)) {
1412
+ return refuse("protected");
1413
+ }
1414
+ const within = (dirs) => dirs.some((dir) => TaActionUtil.inside(dir, path));
1415
+ if (grants.some((grant) => !grant.resource || grant.resource.kind === "dir" && within([grant.resource.id]))) {
1416
+ return true;
1417
+ }
1418
+ if (within(role?.dirs ?? data.dirs)) {
1419
+ return has || refuse("role");
1420
+ }
1421
+ const outside = role?.outside ?? "deny";
1422
+ if (outside === "allow" && has) {
1423
+ return true;
1424
+ }
1425
+ if (outside === "read" && action2 === "files.read" && (role?.actions.includes("files.read") ?? false)) {
1426
+ return true;
1427
+ }
1428
+ return refuse(outside === "deny" ? "never" : "outside");
1429
+ }
1430
+ function resolve(cwd, path, home) {
1431
+ let given = typeof path === "string" && path.trim() ? path.trim() : ".";
1432
+ if (home && (given === "~" || given.startsWith("~/"))) {
1433
+ given = home.replace(/\/+$/, "") + given.slice(1);
1434
+ }
1435
+ if (given.startsWith("/") || /^[a-z][a-z0-9+.-]*:\/\//i.test(given)) {
1436
+ return normalize(given);
1437
+ }
1438
+ return normalize(`${cwd.replace(/\/+$/, "")}/${given}`);
1439
+ }
1440
+ TeamPolicy.resolve = resolve;
1441
+ function normalize(path) {
1442
+ const [, scheme = "", rest] = /^([a-z][a-z0-9+.-]*:\/\/[^/]*)?(.*)$/i.exec(path) ?? [];
1443
+ const parts = [];
1444
+ for (const part of (rest ?? "").split("/")) {
1445
+ if (part === "..") {
1446
+ parts.pop();
1447
+ } else if (part && part !== ".") {
1448
+ parts.push(part);
1449
+ }
1450
+ }
1451
+ return `${scheme}/${parts.join("/")}`;
1452
+ }
1453
+ TeamPolicy.normalize = normalize;
1454
+ const READ_TOOLS = new Set(["read", "ls", "grep", "find"]);
1455
+ const WRITE_TOOLS = new Set(["edit", "write"]);
1456
+ const FREE_TOOLS = new Set(["codemode", "tool_search"]);
1457
+ function toolNeeds(tool, input, cwd, home, declared) {
1458
+ if (FREE_TOOLS.has(tool)) {
1459
+ return;
1460
+ }
1461
+ if (READ_TOOLS.has(tool)) {
1462
+ return { action: "files.read", resource: { kind: "dir", id: resolve(cwd, input?.path, home) } };
1463
+ }
1464
+ if (WRITE_TOOLS.has(tool)) {
1465
+ return { action: "files.write", resource: { kind: "dir", id: resolve(cwd, input?.path, home) } };
1466
+ }
1467
+ if (declared === "anyone") {
1468
+ return;
1469
+ }
1470
+ if (declared) {
1471
+ return { action: declared };
1472
+ }
1473
+ return { action: "commands.run", resource: { kind: "dir", id: resolve(cwd, ".") } };
1474
+ }
1475
+ TeamPolicy.toolNeeds = toolNeeds;
1476
+ })(TeamPolicy ||= {});
1477
+
1478
+ // web-src/dialogs.tsx
1479
+ function show(component) {
1480
+ if (!pi.ui.custom) {
1481
+ pi.ui.notify(t("joinOld"), "warning");
1482
+ return;
1483
+ }
1484
+ return pi.ui.custom(component);
1485
+ }
1486
+ function InviteSheet({ link, close }) {
1487
+ const Users = icon("Users");
1488
+ return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
1489
+ pi,
1490
+ title: t("inviteDialog"),
1491
+ link,
1492
+ face: /* @__PURE__ */ React.createElement(Users, {
1493
+ size: 22
1494
+ }),
1495
+ name: t("inviteDialog"),
1496
+ gets: t("inviteGets"),
1497
+ notes: [t("inviteHint")],
1498
+ onClose: close
1499
+ });
1500
+ }
1501
+ function InviteDialog({ roles, close }) {
1502
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
1503
+ const [role, setRole] = React.useState(DEFAULT_ROLE);
1504
+ const [what, setWhat] = React.useState("whole");
1505
+ const [items, setItems] = React.useState();
1506
+ const [picked, setPicked] = React.useState([]);
1507
+ const [level, setLevel] = React.useState("use");
1508
+ React.useEffect(() => {
1509
+ if (what === "only" && !items) {
1510
+ call("shareable").then(setItems, () => setItems([]));
1511
+ }
1512
+ }, [what, items]);
1513
+ const [days, setDays] = React.useState(7);
1514
+ const [approve, setApprove] = React.useState(true);
1515
+ const [invite, setInvite] = React.useState();
1516
+ const [busy, setBusy] = React.useState(false);
1517
+ const [error, setError] = React.useState();
1518
+ const make = async () => {
1519
+ setBusy(true);
1520
+ setError(undefined);
1521
+ try {
1522
+ const share = what === "only" ? (items ?? []).filter((item) => picked.includes(`${item.kind}:${item.id}`)).map((item) => ({ kind: item.kind, id: item.id })) : [];
1523
+ setInvite(await call("createInvite", { role: what === "only" ? "guest" : role, days, approve, share, level, language: pi.ui.language }));
1524
+ book.load();
1525
+ } catch (failure) {
1526
+ setError(message(failure));
1527
+ }
1528
+ setBusy(false);
1529
+ };
1530
+ if (invite) {
1531
+ return /* @__PURE__ */ React.createElement(InviteSheet, {
1532
+ link: invite.link,
1533
+ close
1534
+ });
1535
+ }
1536
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1537
+ title: t("inviteDialog"),
1538
+ onClose: close
1539
+ }, /* @__PURE__ */ React.createElement("div", {
1540
+ className: "ttm-dialog"
1541
+ }, /* @__PURE__ */ React.createElement("div", {
1542
+ className: "ttm-field"
1543
+ }, /* @__PURE__ */ React.createElement("span", null, t("inviteWhat")), /* @__PURE__ */ React.createElement(Choices, {
1544
+ value: what,
1545
+ onChange: setWhat,
1546
+ items: [
1547
+ { id: "whole", label: t("inviteWhole"), hint: t("inviteWholeHint") },
1548
+ { id: "only", label: t("inviteOnly"), hint: t("inviteOnlyHint") }
1549
+ ]
1550
+ })), what === "only" && /* @__PURE__ */ React.createElement("div", {
1551
+ className: "ttm-field"
1552
+ }, /* @__PURE__ */ React.createElement("span", null, t("pickShared")), !items ? /* @__PURE__ */ React.createElement(Loading, {
1553
+ compact: true
1554
+ }) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
1555
+ title: t("nothingToShare"),
1556
+ compact: true
1557
+ }) : /* @__PURE__ */ React.createElement("ul", {
1558
+ className: "ttm-picks"
1559
+ }, items.map((item) => {
1560
+ const key = `${item.kind}:${item.id}`;
1561
+ const on = picked.includes(key);
1562
+ return /* @__PURE__ */ React.createElement("li", {
1563
+ key
1564
+ }, /* @__PURE__ */ React.createElement("button", {
1565
+ type: "button",
1566
+ className: `ttm-pick${on ? " ttm-on" : ""}`,
1567
+ "aria-pressed": on,
1568
+ onClick: () => setPicked(on ? picked.filter((one) => one !== key) : [...picked, key])
1569
+ }, pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
1570
+ face: item.face,
1571
+ seed: item.id,
1572
+ size: 28
1573
+ }) : null, /* @__PURE__ */ React.createElement("span", {
1574
+ className: "ttm-row-text"
1575
+ }, /* @__PURE__ */ React.createElement("span", {
1576
+ className: "ttm-row-title"
1577
+ }, item.name), /* @__PURE__ */ React.createElement("span", {
1578
+ className: "ttm-row-line"
1579
+ }, item.kind === "agent" ? t("agentKind") : t("channelKind")))));
1580
+ })), /* @__PURE__ */ React.createElement(Choices, {
1581
+ value: level,
1582
+ onChange: setLevel,
1583
+ items: [
1584
+ { id: "view", label: t("levelView"), hint: t("levelViewHint") },
1585
+ { id: "use", label: t("levelUse"), hint: t("levelUseHint") },
1586
+ { id: "edit", label: t("levelEdit"), hint: t("levelEditHint") }
1587
+ ]
1588
+ })), /* @__PURE__ */ React.createElement("label", {
1589
+ className: `ttm-field${what === "only" ? " ttm-hidden" : ""}`
1590
+ }, /* @__PURE__ */ React.createElement("span", null, t("role")), /* @__PURE__ */ React.createElement("select", {
1591
+ className: "ttm-select",
1592
+ value: role,
1593
+ onChange: (event) => setRole(event.target.value)
1594
+ }, roles.filter((one) => one.id !== "admin" || book.get().me?.owner).map((one) => /* @__PURE__ */ React.createElement("option", {
1595
+ key: one.id,
1596
+ value: one.id
1597
+ }, roleName(one))))), /* @__PURE__ */ React.createElement("label", {
1598
+ className: "ttm-field"
1599
+ }, /* @__PURE__ */ React.createElement("span", null, t("lasts")), /* @__PURE__ */ React.createElement("select", {
1600
+ className: "ttm-select",
1601
+ value: days,
1602
+ onChange: (event) => setDays(Number(event.target.value))
1603
+ }, [1, 7, 30].map((n) => /* @__PURE__ */ React.createElement("option", {
1604
+ key: n,
1605
+ value: n
1606
+ }, t("days", { n }))))), /* @__PURE__ */ React.createElement("label", {
1607
+ className: "ttm-check"
1608
+ }, /* @__PURE__ */ React.createElement("input", {
1609
+ type: "checkbox",
1610
+ checked: approve,
1611
+ onChange: (event) => setApprove(event.target.checked)
1612
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, t("approve")), /* @__PURE__ */ React.createElement("small", null, t("approveHint")))), error && /* @__PURE__ */ React.createElement("p", {
1613
+ className: "ttm-error"
1614
+ }, error), /* @__PURE__ */ React.createElement("div", {
1615
+ className: "ttm-actions"
1616
+ }, /* @__PURE__ */ React.createElement("button", {
1617
+ type: "button",
1618
+ className: "ta-button",
1619
+ onClick: close
1620
+ }, t("cancel")), /* @__PURE__ */ React.createElement("button", {
1621
+ type: "button",
1622
+ className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
1623
+ disabled: busy || what === "only" && picked.length === 0,
1624
+ onClick: () => void make()
1625
+ }, busy ? t("making") : t("makeLink")))));
1626
+ }
1627
+ function openInvite(roles) {
1628
+ show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog, {
1629
+ roles,
1630
+ close
1631
+ }));
1632
+ }
1633
+ function openLink(link) {
1634
+ show(({ close }) => /* @__PURE__ */ React.createElement(InviteSheet, {
1635
+ link,
1636
+ close
1637
+ }));
1638
+ }
1639
+ function areas() {
1640
+ const by = new Map;
1641
+ for (const action2 of TeamPolicy.catalog()) {
1642
+ by.set(action2.area, [...by.get(action2.area) ?? [], action2]);
1643
+ }
1644
+ return [...by];
1645
+ }
1646
+ function RoleDialog({ role, close }) {
1647
+ const fixed = !!role?.preset;
1648
+ const [name, setName] = React.useState(role ? roleName(role) : "");
1649
+ const [actions, setActions] = React.useState(new Set(role?.actions ?? []));
1650
+ const [dirs, setDirs] = React.useState((role?.dirs ?? []).join(`
1651
+ `));
1652
+ const [scope, setScope] = React.useState(role?.scope ?? "all");
1653
+ const [outside, setOutside] = React.useState(role?.outside ?? "deny");
1654
+ const toggle = (id) => {
1655
+ const next = new Set(actions);
1656
+ if (next.has(id)) {
1657
+ next.delete(id);
1658
+ } else {
1659
+ next.add(id);
1660
+ }
1661
+ setActions(next);
1662
+ };
1663
+ const [busy, run] = pi.ui.useBusy();
1664
+ const save = async () => {
1665
+ const saved = await act(() => call("saveRole", {
1666
+ id: role?.id,
1667
+ name: name.trim(),
1668
+ actions: [...actions],
1669
+ scope,
1670
+ outside,
1671
+ dirs: dirs.split(`
1672
+ `).map((line) => line.trim()).filter(Boolean)
1673
+ }));
1674
+ if (saved) {
1675
+ close();
1676
+ }
1677
+ };
1678
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1679
+ title: t("roleDialog"),
1680
+ onClose: close
1681
+ }, /* @__PURE__ */ React.createElement("div", {
1682
+ className: "ttm-dialog ttm-role"
1683
+ }, /* @__PURE__ */ React.createElement("label", {
1684
+ className: "ttm-field"
1685
+ }, /* @__PURE__ */ React.createElement("span", null, t("roleName")), /* @__PURE__ */ React.createElement("input", {
1686
+ className: "ttm-input",
1687
+ value: name,
1688
+ disabled: fixed,
1689
+ onChange: (event) => setName(event.target.value)
1690
+ })), /* @__PURE__ */ React.createElement("fieldset", {
1691
+ className: "ttm-field ttm-plain",
1692
+ disabled: fixed
1693
+ }, /* @__PURE__ */ React.createElement("span", null, t("scope")), /* @__PURE__ */ React.createElement(Choices, {
1694
+ value: scope,
1695
+ onChange: setScope,
1696
+ items: [
1697
+ { id: "all", label: t("scopeAll") },
1698
+ { id: "shared", label: t("scopeShared") }
1699
+ ]
1700
+ })), /* @__PURE__ */ React.createElement("fieldset", {
1701
+ className: "ttm-field ttm-plain",
1702
+ disabled: fixed
1703
+ }, /* @__PURE__ */ React.createElement("span", null, t("outside")), /* @__PURE__ */ React.createElement(Choices, {
1704
+ value: outside,
1705
+ onChange: setOutside,
1706
+ items: [
1707
+ { id: "deny", label: t("outsideDeny"), hint: t("outsideDenyHint") },
1708
+ { id: "ask", label: t("outsideAsk"), hint: t("outsideAskHint") },
1709
+ { id: "read", label: t("outsideRead"), hint: t("outsideReadHint") },
1710
+ { id: "allow", label: t("outsideAllow"), hint: t("outsideAllowHint") }
1711
+ ]
1712
+ })), areas().map(([area, list]) => /* @__PURE__ */ React.createElement("fieldset", {
1713
+ key: area,
1714
+ className: "ttm-area"
1715
+ }, list.map((action2) => /* @__PURE__ */ React.createElement("label", {
1716
+ key: action2.id,
1717
+ className: "ttm-check ttm-check-small"
1718
+ }, /* @__PURE__ */ React.createElement("input", {
1719
+ type: "checkbox",
1720
+ disabled: fixed,
1721
+ checked: actions.has(action2.id),
1722
+ onChange: () => toggle(action2.id)
1723
+ }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, actionTitle(action2.id)), action2.risky && /* @__PURE__ */ React.createElement("small", {
1724
+ className: "ttm-risky"
1725
+ }, t("risky"))))))), /* @__PURE__ */ React.createElement("label", {
1726
+ className: "ttm-field"
1727
+ }, /* @__PURE__ */ React.createElement("span", null, t("roleDirs")), /* @__PURE__ */ React.createElement("textarea", {
1728
+ className: "ttm-input",
1729
+ rows: 3,
1730
+ value: dirs,
1731
+ disabled: fixed,
1732
+ onChange: (event) => setDirs(event.target.value)
1733
+ })), /* @__PURE__ */ React.createElement("div", {
1734
+ className: "ttm-actions"
1735
+ }, role && !fixed && /* @__PURE__ */ React.createElement("button", {
1736
+ type: "button",
1737
+ className: "ta-button ta-danger",
1738
+ disabled: busy,
1739
+ onClick: () => void run(() => act(() => call("deleteRole", role.id)).then((done) => {
1740
+ if (done) {
1741
+ close();
1742
+ }
1743
+ }))
1744
+ }, t("deleteRole")), /* @__PURE__ */ React.createElement("span", {
1745
+ className: "ttm-grow"
1746
+ }), /* @__PURE__ */ React.createElement("button", {
1747
+ type: "button",
1748
+ className: "ta-button",
1749
+ onClick: close
1750
+ }, fixed ? t("close") : t("cancel")), !fixed && /* @__PURE__ */ React.createElement("button", {
1751
+ type: "button",
1752
+ className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
1753
+ "aria-busy": busy || undefined,
1754
+ disabled: busy || !name.trim(),
1755
+ onClick: () => void run(save)
1756
+ }, busy && /* @__PURE__ */ React.createElement("span", {
1757
+ className: "ta-spinner ta-busy-mark ta-on-brand"
1758
+ }), /* @__PURE__ */ React.createElement("span", null, t("save"))))));
1759
+ }
1760
+ function openRole(role) {
1761
+ show(({ close }) => /* @__PURE__ */ React.createElement(RoleDialog, {
1762
+ role,
1763
+ close
1764
+ }));
1765
+ }
1766
+ function RequestDialog({ denial, close }) {
1767
+ const [reason, setReason] = React.useState("");
1768
+ const [busy, setBusy] = React.useState(false);
1769
+ const [error, setError] = React.useState();
1770
+ const ask = async () => {
1771
+ setBusy(true);
1772
+ try {
1773
+ await call("requestAccess", { action: denial.action, resource: denial.resource, reason });
1774
+ pi.ui.notify(t("asked"));
1775
+ book.load();
1776
+ close();
1777
+ } catch (failure) {
1778
+ setError(message(failure));
1779
+ setBusy(false);
1780
+ }
1781
+ };
1782
+ const where = denial.resource?.kind === "dir" ? denial.resource.id : undefined;
1783
+ return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
1784
+ title: t("requestTitle", { action: actionTitle(denial.action) }),
1785
+ onClose: close
1786
+ }, /* @__PURE__ */ React.createElement("div", {
1787
+ className: "ttm-dialog"
1788
+ }, /* @__PURE__ */ React.createElement("p", {
1789
+ className: "ttm-lead"
1790
+ }, t("requestLead")), where && /* @__PURE__ */ React.createElement("p", {
1791
+ className: "ttm-hint"
1792
+ }, t("accessWhere", { path: where })), /* @__PURE__ */ React.createElement("input", {
1793
+ className: "ttm-input",
1794
+ placeholder: t("reasonPlaceholder"),
1795
+ value: reason,
1796
+ onChange: (event) => setReason(event.target.value)
1797
+ }), error && /* @__PURE__ */ React.createElement("p", {
1798
+ className: "ttm-error"
1799
+ }, error), /* @__PURE__ */ React.createElement("div", {
1800
+ className: "ttm-actions"
1801
+ }, /* @__PURE__ */ React.createElement("button", {
1802
+ type: "button",
1803
+ className: "ta-button",
1804
+ onClick: close
1805
+ }, t("cancel")), /* @__PURE__ */ React.createElement("button", {
1806
+ type: "button",
1807
+ className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
1808
+ disabled: busy,
1809
+ onClick: () => void ask()
1810
+ }, t("ask")))));
1811
+ }
1812
+ function openRequest(denial) {
1813
+ show(({ close }) => /* @__PURE__ */ React.createElement(RequestDialog, {
1814
+ denial,
1815
+ close
1816
+ }));
1817
+ }
1818
+
1819
+ // ../ta-relay/esm/common/relay-bytes.js
1820
+ var RelayBytes;
1821
+ (function(RelayBytes2) {
1822
+ function random(length) {
1823
+ return globalThis.crypto.getRandomValues(new Uint8Array(length));
1824
+ }
1825
+ RelayBytes2.random = random;
1826
+ function toBase64(bytes) {
1827
+ let binary = "";
1828
+ for (const byte of bytes) {
1829
+ binary += String.fromCharCode(byte);
1830
+ }
1831
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1832
+ }
1833
+ RelayBytes2.toBase64 = toBase64;
1834
+ function fromBase64(text) {
1835
+ if (!/^[A-Za-z0-9_-]*$/.test(text)) {
1836
+ throw new Error("Not base64url.");
1837
+ }
1838
+ const binary = atob(text.replace(/-/g, "+").replace(/_/g, "/"));
1839
+ const bytes = new Uint8Array(binary.length);
1840
+ for (let i = 0;i < binary.length; i++) {
1841
+ bytes[i] = binary.charCodeAt(i);
1842
+ }
1843
+ return bytes;
1844
+ }
1845
+ RelayBytes2.fromBase64 = fromBase64;
1846
+ function concat(...parts) {
1847
+ const bytes = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));
1848
+ let offset = 0;
1849
+ for (const part of parts) {
1850
+ bytes.set(part, offset);
1851
+ offset += part.length;
1852
+ }
1853
+ return bytes;
1854
+ }
1855
+ RelayBytes2.concat = concat;
1856
+ })(RelayBytes || (RelayBytes = {}));
1857
+
1858
+ // ../ta-relay/esm/common/relay-protocol.js
1859
+ var RELAY_CONNECT_PATH = "/v1/connect/";
1860
+ var RELAY_PAIR_PATH = "/pair";
1861
+ var RELAY_FRAME_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:; style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:; media-src https: data: blob:; connect-src 'none'; form-action 'none'";
1862
+ var RELAY_FRAME_HEADER_CSP = `${RELAY_FRAME_CSP}; frame-ancestors 'self'; sandbox allow-scripts allow-popups allow-popups-to-escape-sandbox`;
1863
+ var OPEN_IN_TA = `<p><a id="open" style="display:inline-block;padding:10px 18px;border-radius:20px;background:#111;color:#fff;text-decoration:none;font-weight:600">Open in Ta · 在 Ta 中打开</a></p>
1864
+ <script>document.getElementById('open').href='ta://open?link='+encodeURIComponent(location.href)</script>`;
1865
+ var RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
1866
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
1867
+ <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
1868
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p>${OPEN_IN_TA}</body>`;
1869
+ var RELAY_SHARE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
1870
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
1871
+ <h1>Ta</h1><p>Someone shared an extension of Ta. Scan the code in the Ta app, or paste this link in its Quick open, to open it.</p>
1872
+ <p>有人分享了一个 Ta 扩展。在 Ta 应用里扫码,或把这个链接粘贴到“快捷打开”,就能打开它。</p>${OPEN_IN_TA}</body>`;
1873
+ var RELAY_SHARE_MAX_BYTES = 8 * 1024 * 1024;
1874
+ var RELAY_SHARE_CHUNK_BYTES = 192 * 1024;
1875
+ var RELAY_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
1876
+ var RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
1877
+ var RelayCloseCode;
1878
+ (function(RelayCloseCode2) {
1879
+ RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
1880
+ RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
1881
+ RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
1882
+ RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
1883
+ RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
1884
+ RelayCloseCode2[RelayCloseCode2["TIMEOUT"] = 4408] = "TIMEOUT";
1885
+ })(RelayCloseCode || (RelayCloseCode = {}));
1886
+ var RELAY_PING = "ping";
1887
+ var RELAY_PONG = "pong";
1888
+ var RELAY_PING_MS = 25000;
1889
+ var RELAY_PROOF = "ta-relay ready";
1890
+ var RELAY_HUB_MAX_VALUE = 96 * 1024;
1891
+ var RELAY_HUB_MAX_STATE = 3 * 1024 * 1024;
1892
+
1893
+ // ../ta-relay/esm/common/relay-pairing.js
1894
+ var RelayPairingUtil;
1895
+ (function(RelayPairingUtil2) {
1896
+ function link(pairing) {
1897
+ const fragment = new URLSearchParams({ v: "1", h: pairing.host, d: pairing.device, k: pairing.key });
1898
+ if (pairing.name) {
1899
+ fragment.set("n", pairing.name);
1900
+ }
1901
+ return `${pairing.relay}${RELAY_PAIR_PATH}#${fragment}`;
1902
+ }
1903
+ RelayPairingUtil2.link = link;
1904
+ function parse(link2) {
1905
+ var _a;
1906
+ const url = new URL(link2.trim());
1907
+ const fragment = new URLSearchParams(url.hash.slice(1));
1908
+ const [host, device, key] = ["h", "d", "k"].map((name) => {
1909
+ var _a2;
1910
+ return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
1911
+ });
1912
+ if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_PAIR_PATH || fragment.get("v") !== "1" || !RELAY_ID.test(host) || !RELAY_ID.test(device) || !/^[A-Za-z0-9_-]{43}$/.test(key)) {
1913
+ throw new Error("Not a pairing link of Ta.");
1914
+ }
1915
+ return { relay: url.origin, host, device, key, name: (_a = fragment.get("n")) !== null && _a !== undefined ? _a : undefined };
1916
+ }
1917
+ RelayPairingUtil2.parse = parse;
1918
+ function websocketUrl(relay, path) {
1919
+ return relay.replace(/^http/, "ws") + path;
1920
+ }
1921
+ RelayPairingUtil2.websocketUrl = websocketUrl;
1922
+ })(RelayPairingUtil || (RelayPairingUtil = {}));
1923
+
1924
+ // ../ta-relay/esm/common/relay-cipher.js
1925
+ var encoder = new TextEncoder;
1926
+ var decoder = new TextDecoder;
1927
+ var IV_LENGTH = 12;
1928
+ var PLAIN = 0;
1929
+ var DEFLATED = 1;
1930
+ var DEFLATE_MIN_BYTES = 1024;
1931
+
1932
+ class RelayCipher {
1933
+ constructor(sendKey, receiveKey) {
1934
+ this.sendKey = sendKey;
1935
+ this.receiveKey = receiveKey;
1936
+ this.compress = false;
1937
+ this.sent = 0;
1938
+ this.received = 0;
1939
+ this.sealing = Promise.resolve();
1940
+ this.opening = Promise.resolve();
1941
+ }
1942
+ static async derive(deviceKey, clientNonce, hostNonce, side) {
1943
+ const subtle = globalThis.crypto.subtle;
1944
+ const secret = await subtle.importKey("raw", deviceKey, "HKDF", false, ["deriveKey"]);
1945
+ const salt = RelayBytes.concat(clientNonce, hostNonce);
1946
+ const key = (direction) => subtle.deriveKey({ name: "HKDF", hash: "SHA-256", salt, info: encoder.encode(`ta-relay/1 ${direction}`) }, secret, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
1947
+ const [toHost, toClient] = await Promise.all([key("client-to-host"), key("host-to-client")]);
1948
+ return side === "client" ? new RelayCipher(toHost, toClient) : new RelayCipher(toClient, toHost);
1949
+ }
1950
+ seal(text) {
1951
+ const iv = RelayCipher.iv(this.sent++);
1952
+ const sealed = this.sealing.then(async () => {
1953
+ const data = await globalThis.crypto.subtle.encrypt({ name: "AES-GCM", iv }, this.sendKey, await this.pack(text));
1954
+ return RelayBytes.toBase64(new Uint8Array(data));
1955
+ });
1956
+ this.sealing = sealed.catch(() => {
1957
+ return;
1958
+ });
1959
+ return sealed;
1960
+ }
1961
+ open(frame) {
1962
+ const iv = RelayCipher.iv(this.received++);
1963
+ const opened = this.opening.then(async () => {
1964
+ const data = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv }, this.receiveKey, RelayBytes.fromBase64(frame));
1965
+ return this.unpack(new Uint8Array(data));
1966
+ });
1967
+ this.opening = opened.catch(() => {
1968
+ return;
1969
+ });
1970
+ return opened;
1971
+ }
1972
+ async pack(text) {
1973
+ const bytes = encoder.encode(text);
1974
+ if (!this.compress) {
1975
+ return bytes;
1976
+ }
1977
+ const deflated = bytes.length >= DEFLATE_MIN_BYTES ? await RelayDeflate.compress(bytes) : undefined;
1978
+ return deflated && deflated.length < bytes.length ? RelayBytes.concat(Uint8Array.of(DEFLATED), deflated) : RelayBytes.concat(Uint8Array.of(PLAIN), bytes);
1979
+ }
1980
+ async unpack(bytes) {
1981
+ if (!this.compress) {
1982
+ return decoder.decode(bytes);
1983
+ }
1984
+ const body = bytes.subarray(1);
1985
+ return decoder.decode(bytes[0] === DEFLATED ? await RelayDeflate.decompress(body) : body);
1986
+ }
1987
+ static iv(counter) {
1988
+ const iv = new Uint8Array(IV_LENGTH);
1989
+ new DataView(iv.buffer).setUint32(IV_LENGTH - 8, Math.floor(counter / 2 ** 32));
1990
+ new DataView(iv.buffer).setUint32(IV_LENGTH - 4, counter >>> 0);
1991
+ return iv;
1992
+ }
1993
+ }
1994
+ var RelayDeflate;
1995
+ (function(RelayDeflate2) {
1996
+ let support;
1997
+ function supported() {
1998
+ if (support === undefined) {
1999
+ try {
2000
+ new CompressionStream("deflate-raw");
2001
+ new DecompressionStream("deflate-raw");
2002
+ support = true;
2003
+ } catch (_a) {
2004
+ support = false;
2005
+ }
2006
+ }
2007
+ return support;
2008
+ }
2009
+ RelayDeflate2.supported = supported;
2010
+ function compress(bytes) {
2011
+ return through(bytes, new CompressionStream("deflate-raw"));
2012
+ }
2013
+ RelayDeflate2.compress = compress;
2014
+ function decompress(bytes) {
2015
+ return through(bytes, new DecompressionStream("deflate-raw"));
2016
+ }
2017
+ RelayDeflate2.decompress = decompress;
2018
+ async function through(bytes, stream) {
2019
+ const piped = new Blob([bytes]).stream().pipeThrough(stream);
2020
+ return new Uint8Array(await new Response(piped).arrayBuffer());
2021
+ }
2022
+ })(RelayDeflate || (RelayDeflate = {}));
2023
+
2024
+ // ../ta-relay/esm/common/relay-socket.js
2025
+ var CONNECTING = 0;
2026
+ var OPEN = 1;
2027
+ var CLOSING = 2;
2028
+ var CLOSED = 3;
2029
+ var HELLO_MS = 15000;
2030
+
2031
+ class RelaySocket {
2032
+ constructor(pairing, options = {}) {
2033
+ var _a;
2034
+ this.pairing = pairing;
2035
+ this.options = options;
2036
+ this.onopen = null;
2037
+ this.onmessage = null;
2038
+ this.onclose = null;
2039
+ this.onerror = null;
2040
+ this.state = CONNECTING;
2041
+ this.nonce = RelayBytes.random(16);
2042
+ this.ponged = false;
2043
+ this.awaitingPong = false;
2044
+ this.receiving = Promise.resolve();
2045
+ this.socket = new WebSocket(RelayPairingUtil.websocketUrl(pairing.relay, RELAY_CONNECT_PATH + pairing.host));
2046
+ this.helloTimer = setTimeout(() => this.drop(RelayCloseCode.TIMEOUT, "The host did not answer."), (_a = options.helloMs) !== null && _a !== undefined ? _a : HELLO_MS);
2047
+ this.socket.onopen = () => {
2048
+ var _a2;
2049
+ const hello = {
2050
+ t: "hello",
2051
+ v: 1,
2052
+ device: pairing.device,
2053
+ nonce: RelayBytes.toBase64(this.nonce),
2054
+ ...RelayDeflate.supported() ? { z: 1 } : {}
2055
+ };
2056
+ this.socket.send(JSON.stringify(hello));
2057
+ this.pingTimer = setInterval(() => this.ping(), (_a2 = options.pingMs) !== null && _a2 !== undefined ? _a2 : RELAY_PING_MS);
2058
+ };
2059
+ this.socket.onmessage = (message2) => {
2060
+ const text = String(message2.data);
2061
+ if (text === RELAY_PONG) {
2062
+ this.ponged = true;
2063
+ this.awaitingPong = false;
2064
+ return;
2065
+ }
2066
+ this.receiving = this.receiving.then(() => this.receive(text));
2067
+ };
2068
+ this.socket.onerror = (event) => {
2069
+ var _a2;
2070
+ return (_a2 = this.onerror) === null || _a2 === undefined ? undefined : _a2.call(this, event);
2071
+ };
2072
+ this.socket.onclose = (event) => void this.receiving.then(() => this.finish(event.code, event.reason));
1732
2073
  }
1733
- TeamWords.of = of;
1734
- function format(text, values) {
1735
- return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
2074
+ get readyState() {
2075
+ return this.state;
1736
2076
  }
1737
- TeamWords.format = format;
1738
- })(TeamWords ||= {});
1739
-
1740
- // web-src/protocol.ts
1741
- var NAME = "@celljs/ta-team";
1742
- var INBOX_KEY = "inbox";
1743
- var JOINED_KEY = "joined";
1744
- var LIMIT_RANGE = {
1745
- members: [1, 500],
1746
- online: [1, 200],
1747
- devices: [1, 20],
1748
- running: [1, 50]
1749
- };
1750
- var DEFAULT_ROLE = "collaborator";
1751
-
1752
- // web-src/react.ts
1753
- var React;
1754
- function bind(react) {
1755
- React = react;
1756
- }
1757
-
1758
- // web-src/page.ts
1759
- var pi;
1760
- function bindPage(api) {
1761
- pi = api;
1762
- }
1763
- function t(key, values = {}) {
1764
- return TeamWords.format(TeamWords.of(pi.ui.language)[key], values);
1765
- }
1766
- function actionTitle(action2) {
1767
- return TaActionUtil.title(action2, pi.ui.language);
1768
- }
1769
- function roleName(role) {
1770
- if (!role) {
1771
- return "?";
2077
+ get closeCode() {
2078
+ return this.code;
1772
2079
  }
1773
- const key = `role.${role.id}`;
1774
- return role.preset && key in TeamWords.of("en") ? t(key) : role.name;
1775
- }
1776
- var PROVIDERS = { github: "GitHub", google: "Google", wechat: "WeChat", oidc: "SSO" };
1777
- function accountLine(account) {
1778
- if (!account) {
1779
- return "";
2080
+ send(text) {
2081
+ if (this.state !== OPEN || !this.cipher) {
2082
+ throw new Error("The connection is not open.");
2083
+ }
2084
+ this.cipher.seal(text).then((frame) => this.socket.readyState === OPEN && this.socket.send(frame));
2085
+ }
2086
+ close(code = 1000, reason = "") {
2087
+ if (this.state === CLOSED) {
2088
+ return;
2089
+ }
2090
+ this.state = CLOSING;
2091
+ this.socket.close(code, reason);
2092
+ }
2093
+ async receive(text) {
2094
+ var _a, _b;
2095
+ if (this.cipher) {
2096
+ if (this.options.proveFirst && text.startsWith("{")) {
2097
+ this.drop(RelaySocket.REFUSED, RelaySocket.refusal(text));
2098
+ return;
2099
+ }
2100
+ try {
2101
+ const data = await this.cipher.open(text);
2102
+ (_a = this.onmessage) === null || _a === undefined || _a.call(this, { data });
2103
+ } catch (_c) {
2104
+ this.close(4400, "A message did not open.");
2105
+ }
2106
+ return;
2107
+ }
2108
+ try {
2109
+ const welcome = JSON.parse(text);
2110
+ if (welcome.t !== "ready") {
2111
+ this.drop(RelaySocket.REFUSED, this.options.proveFirst ? RelaySocket.refusal(text) : "The host refused this device.");
2112
+ return;
2113
+ }
2114
+ const cipher = await RelayCipher.derive(RelayBytes.fromBase64(this.pairing.key), this.nonce, RelayBytes.fromBase64(welcome.nonce), "client");
2115
+ if (welcome.proof === undefined && this.options.proveFirst) {
2116
+ this.socket.send(await cipher.seal(RELAY_PROOF));
2117
+ } else if (welcome.proof === undefined || await cipher.open(welcome.proof) !== RELAY_PROOF) {
2118
+ throw new Error("The host did not show the key.");
2119
+ }
2120
+ cipher.compress = welcome.z === 1 && RelayDeflate.supported();
2121
+ this.cipher = cipher;
2122
+ clearTimeout(this.helloTimer);
2123
+ this.state = OPEN;
2124
+ (_b = this.onopen) === null || _b === undefined || _b.call(this);
2125
+ } catch (_d) {
2126
+ this.drop(RelaySocket.REFUSED, "The host refused this device.");
2127
+ }
2128
+ }
2129
+ static refusal(text) {
2130
+ try {
2131
+ const reason = JSON.parse(text).reason;
2132
+ return reason === "key" || reason === "busy" ? reason : "gone";
2133
+ } catch (_a) {
2134
+ return "gone";
2135
+ }
2136
+ }
2137
+ ping() {
2138
+ if (this.awaitingPong && this.ponged) {
2139
+ this.drop(RelayCloseCode.TIMEOUT, "The relay did not answer.");
2140
+ return;
2141
+ }
2142
+ this.awaitingPong = true;
2143
+ if (this.socket.readyState === OPEN) {
2144
+ this.socket.send(RELAY_PING);
2145
+ }
2146
+ }
2147
+ drop(code, reason) {
2148
+ this.close(code, reason);
2149
+ this.finish(code, reason);
2150
+ }
2151
+ finish(code, reason) {
2152
+ var _a;
2153
+ if (this.state === CLOSED) {
2154
+ return;
2155
+ }
2156
+ clearTimeout(this.helloTimer);
2157
+ clearInterval(this.pingTimer);
2158
+ this.state = CLOSED;
2159
+ this.code = code;
2160
+ (_a = this.onclose) === null || _a === undefined || _a.call(this, { code, reason });
1780
2161
  }
1781
- const at = account.id.indexOf(":");
1782
- const provider = account.id.slice(0, at);
1783
- const name = book.get().overview?.providers.find((one) => one.id === provider)?.name ?? PROVIDERS[provider] ?? provider;
1784
- return provider === "wechat" ? TaLanguageUtil.pick(pi.ui.language, { "zh-CN": "微信", "zh-TW": "微信", "en-US": name, "ja-JP": name }) : `${name} ${account.id.slice(at + 1)}`;
1785
- }
1786
- function icon(name) {
1787
- return pi.ui.icons[name] ?? pi.ui.icons.Users ?? pi.ui.icons.Circle;
1788
- }
1789
- function message(error) {
1790
- return error instanceof Error ? error.message : String(error);
1791
- }
1792
- function call(method, ...params) {
1793
- return pi.callHost(method, ...params);
1794
2162
  }
2163
+ RelaySocket.CONNECTING = CONNECTING;
2164
+ RelaySocket.OPEN = OPEN;
2165
+ RelaySocket.CLOSING = CLOSING;
2166
+ RelaySocket.CLOSED = CLOSED;
2167
+ RelaySocket.REFUSED = 4403;
1795
2168
 
1796
- class TeamBook {
1797
- state = {};
1798
- listeners = new Set;
1799
- loading;
1800
- get() {
1801
- return this.state;
2169
+ // ../ta-relay/esm/common/relay-host-calls.js
2170
+ var CALL_MS = 30000;
2171
+ var OPEN_TRIES = 6;
2172
+ var OPEN_PAUSE_MS = 700;
2173
+
2174
+ class RelayHostCalls {
2175
+ constructor(pairing, name) {
2176
+ this.pairing = pairing;
2177
+ this.name = name;
2178
+ this.next = 1;
2179
+ this.calls = new Map;
2180
+ this.closed = false;
1802
2181
  }
1803
- subscribe(listener) {
1804
- this.listeners.add(listener);
1805
- return () => this.listeners.delete(listener);
2182
+ static of(link, name) {
2183
+ return new RelayHostCalls(RelayPairingUtil.parse(link), name);
2184
+ }
2185
+ open() {
2186
+ var _a;
2187
+ (_a = this.opening) !== null && _a !== undefined || (this.opening = this.tryOpen(OPEN_TRIES));
2188
+ return this.opening;
2189
+ }
2190
+ async tryOpen(tries) {
2191
+ for (let left = tries;; left--) {
2192
+ try {
2193
+ await this.openOnce();
2194
+ return;
2195
+ } catch (error) {
2196
+ if (left <= 1 || this.closed || error.refused) {
2197
+ this.opening = undefined;
2198
+ throw error;
2199
+ }
2200
+ await new Promise((resolve) => setTimeout(resolve, OPEN_PAUSE_MS));
2201
+ }
2202
+ }
2203
+ }
2204
+ openOnce() {
2205
+ return new Promise((resolve, reject) => {
2206
+ let opened = false;
2207
+ const socket = new RelaySocket(this.pairing);
2208
+ this.socket = socket;
2209
+ socket.onopen = () => {
2210
+ opened = true;
2211
+ resolve();
2212
+ };
2213
+ socket.onerror = () => {
2214
+ if (!opened) {
2215
+ reject(new Error("The other Ta did not answer: is it running?"));
2216
+ }
2217
+ };
2218
+ socket.onclose = (event) => {
2219
+ const refused = event.code === RelaySocket.REFUSED;
2220
+ const error = Object.assign(new Error(refused ? "The other Ta no longer knows this device." : "The connection to the other Ta was lost."), {
2221
+ refused
2222
+ });
2223
+ if (!opened) {
2224
+ reject(error);
2225
+ return;
2226
+ }
2227
+ this.failAll(error);
2228
+ this.opening = undefined;
2229
+ };
2230
+ socket.onmessage = (message2) => this.receive(message2.data);
2231
+ });
2232
+ }
2233
+ async callHost(method, ...params) {
2234
+ await this.open();
2235
+ const id = this.next++;
2236
+ return new Promise((resolve, reject) => {
2237
+ var _a;
2238
+ const timer = setTimeout(() => {
2239
+ this.calls.delete(id);
2240
+ reject(new Error("The other Ta did not answer in time."));
2241
+ }, CALL_MS);
2242
+ this.calls.set(id, { resolve, reject, timer });
2243
+ (_a = this.socket) === null || _a === undefined || _a.send(JSON.stringify({ jsonrpc: "2.0", id, method: "TaPackageServer/callPackageHost", params: [this.name, method, params] }));
2244
+ });
1806
2245
  }
1807
- load() {
1808
- this.loading ??= (async () => {
1809
- try {
1810
- const me = await call("me");
1811
- let overview;
1812
- if (me.owner || me.actions.includes("members.view")) {
1813
- overview = await call("overview").catch(() => {
1814
- return;
1815
- });
1816
- }
1817
- this.set({ me, overview, error: undefined });
1818
- } catch (error) {
1819
- this.set({ error: message(error) });
1820
- } finally {
1821
- this.loading = undefined;
1822
- }
1823
- })();
1824
- return this.loading;
2246
+ close() {
2247
+ var _a;
2248
+ this.closed = true;
2249
+ (_a = this.socket) === null || _a === undefined || _a.close();
2250
+ this.failAll(new Error("Stopped."));
1825
2251
  }
1826
- set(state) {
1827
- this.state = { ...this.state, ...state };
1828
- for (const listener of this.listeners) {
1829
- listener();
2252
+ failAll(error) {
2253
+ for (const call2 of this.calls.values()) {
2254
+ clearTimeout(call2.timer);
2255
+ call2.reject(error);
1830
2256
  }
2257
+ this.calls.clear();
1831
2258
  }
1832
- }
1833
- var book = new TeamBook;
1834
- function useBook() {
1835
- return React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get());
1836
- }
1837
- async function act(action2) {
1838
- try {
1839
- await action2();
1840
- return true;
1841
- } catch (error) {
1842
- pi.ui.notify(message(error), "error");
1843
- return false;
1844
- } finally {
1845
- await book.load();
1846
- }
1847
- }
1848
- function watchInbox() {
1849
- let last;
1850
- const read = async () => {
1851
- const inbox = await pi.storage.get(INBOX_KEY).catch(() => {
2259
+ receive(data) {
2260
+ var _a;
2261
+ let message2;
2262
+ try {
2263
+ message2 = JSON.parse(data);
2264
+ } catch (_b) {
1852
2265
  return;
1853
- });
1854
- const latest = inbox?.latest;
1855
- if (latest && latest.at !== last?.latest?.at && Date.now() - latest.at < 60000) {
1856
- pi.ui.notify(latest.kind === "join" ? t("inboxJoin", { name: latest.name }) : t("inboxAccess", { name: latest.name, action: actionTitle(latest.action ?? "") }));
1857
2266
  }
1858
- last = inbox;
1859
- book.load();
1860
- };
1861
- pi.storage.get(INBOX_KEY).then((inbox) => {
1862
- last = inbox;
1863
- });
1864
- return pi.storage.onChange((keys) => {
1865
- if (keys.includes(INBOX_KEY)) {
1866
- read();
2267
+ const call2 = typeof message2.id === "number" ? this.calls.get(message2.id) : undefined;
2268
+ if (!call2) {
2269
+ return;
1867
2270
  }
1868
- });
1869
- }
1870
- function dateOf(at) {
1871
- return new Date(at).toLocaleDateString(pi.ui.language, { month: "numeric", day: "numeric" });
1872
- }
1873
- function timeOf(at) {
1874
- const date = new Date(at);
1875
- const today = new Date;
1876
- return date.toDateString() === today.toDateString() ? date.toLocaleTimeString(pi.ui.language, { hour: "2-digit", minute: "2-digit" }) : date.toLocaleDateString(pi.ui.language, { month: "numeric", day: "numeric" });
2271
+ this.calls.delete(message2.id);
2272
+ clearTimeout(call2.timer);
2273
+ if (message2.error) {
2274
+ call2.reject(new Error((_a = message2.error.message) !== null && _a !== undefined ? _a : "Failed."));
2275
+ } else {
2276
+ call2.resolve(message2.result);
2277
+ }
2278
+ }
1877
2279
  }
1878
2280
 
1879
- // web-src/parts.tsx
1880
- function Section({ title, children, end }) {
1881
- return /* @__PURE__ */ React.createElement("section", {
1882
- className: "ttm-section"
1883
- }, /* @__PURE__ */ React.createElement("h3", null, /* @__PURE__ */ React.createElement("span", null, title), end), /* @__PURE__ */ React.createElement("ul", {
1884
- className: "ttm-card"
1885
- }, children));
1886
- }
1887
- function Face({ seed, name, online, size = 34, double }) {
1888
- return pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
1889
- seed,
1890
- size,
1891
- online,
1892
- double
1893
- }) : /* @__PURE__ */ React.createElement("span", {
1894
- className: "ttm-letter",
1895
- style: { width: size, height: size }
1896
- }, name.slice(0, 1).toUpperCase());
1897
- }
1898
- function LinkRow({ title, line, onClick, tag }) {
1899
- const Chevron = icon("ChevronRight");
1900
- return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
1901
- type: "button",
1902
- className: "ttm-row ttm-button-row",
1903
- onClick
1904
- }, /* @__PURE__ */ React.createElement("div", {
1905
- className: "ttm-row-text"
1906
- }, /* @__PURE__ */ React.createElement("span", {
1907
- className: "ttm-row-title"
1908
- }, title, tag), line && /* @__PURE__ */ React.createElement("span", {
1909
- className: "ttm-row-line ttm-ellipsis"
1910
- }, line)), /* @__PURE__ */ React.createElement(Chevron, {
1911
- size: 15
1912
- })));
1913
- }
1914
- function Segments({
1915
- value,
1916
- items,
1917
- onChange
1918
- }) {
1919
- return /* @__PURE__ */ React.createElement("div", {
1920
- className: "ta-segmented ttm-segments",
1921
- role: "tablist"
1922
- }, items.map((item) => /* @__PURE__ */ React.createElement("button", {
1923
- key: item.id,
1924
- type: "button",
1925
- role: "tab",
1926
- "aria-selected": item.id === value,
1927
- className: item.id === value ? "ta-on" : undefined,
1928
- onClick: () => onChange(item.id)
1929
- }, item.label, item.badge ? /* @__PURE__ */ React.createElement("span", {
1930
- className: "ttm-badge"
1931
- }, item.badge > 99 ? "99+" : item.badge) : null)));
1932
- }
1933
- function Choices({
1934
- value,
1935
- items,
1936
- onChange
1937
- }) {
1938
- return /* @__PURE__ */ React.createElement("div", {
1939
- className: "ttm-choices",
1940
- role: "radiogroup"
1941
- }, items.map((item) => /* @__PURE__ */ React.createElement("label", {
1942
- key: item.id,
1943
- className: `ttm-choice${item.id === value ? " ttm-on" : ""}`
1944
- }, /* @__PURE__ */ React.createElement("input", {
1945
- type: "radio",
1946
- checked: item.id === value,
1947
- onChange: () => onChange(item.id)
1948
- }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, item.label), item.hint && /* @__PURE__ */ React.createElement("small", null, item.hint)))));
1949
- }
2281
+ // ../ta-relay/esm/common/relay-identity.js
2282
+ var encoder2 = new TextEncoder;
2283
+ var decoder2 = new TextDecoder;
2284
+ var subtle = () => globalThis.crypto.subtle;
2285
+ var SIGN = { name: "ECDSA", namedCurve: "P-256" };
2286
+ var BOX = { name: "ECDH", namedCurve: "P-256" };
2287
+ var SIGNATURE = { name: "ECDSA", hash: "SHA-256" };
2288
+ var RelayKeys;
2289
+ (function(RelayKeys2) {
2290
+ async function hkdf(key, salt, info) {
2291
+ const secret = await subtle().importKey("raw", key, "HKDF", false, ["deriveBits"]);
2292
+ const bits = await subtle().deriveBits({ name: "HKDF", hash: "SHA-256", salt, info: encoder2.encode(info) }, secret, 256);
2293
+ return new Uint8Array(bits);
2294
+ }
2295
+ RelayKeys2.hkdf = hkdf;
2296
+ async function sha256(bytes) {
2297
+ const data = typeof bytes === "string" ? encoder2.encode(bytes) : bytes;
2298
+ return new Uint8Array(await subtle().digest("SHA-256", data));
2299
+ }
2300
+ RelayKeys2.sha256 = sha256;
2301
+ async function hash(text) {
2302
+ return RelayBytes.toBase64(await sha256(text));
2303
+ }
2304
+ RelayKeys2.hash = hash;
2305
+ async function hmac(key, text) {
2306
+ const imported = await subtle().importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
2307
+ return RelayBytes.toBase64(new Uint8Array(await subtle().sign("HMAC", imported, encoder2.encode(text))));
2308
+ }
2309
+ RelayKeys2.hmac = hmac;
2310
+ function aesKey(key) {
2311
+ return subtle().importKey("raw", key, "AES-GCM", false, ["encrypt", "decrypt"]);
2312
+ }
2313
+ RelayKeys2.aesKey = aesKey;
2314
+ async function seal(key, text) {
2315
+ const iv = RelayBytes.random(12);
2316
+ const sealed = await subtle().encrypt({ name: "AES-GCM", iv }, key, encoder2.encode(text));
2317
+ return RelayBytes.toBase64(RelayBytes.concat(iv, new Uint8Array(sealed)));
2318
+ }
2319
+ RelayKeys2.seal = seal;
2320
+ async function open(key, sealed) {
2321
+ const bytes = RelayBytes.fromBase64(sealed);
2322
+ const opened = await subtle().decrypt({ name: "AES-GCM", iv: bytes.subarray(0, 12) }, key, bytes.subarray(12));
2323
+ return decoder2.decode(opened);
2324
+ }
2325
+ RelayKeys2.open = open;
2326
+ })(RelayKeys || (RelayKeys = {}));
2327
+ var RelayIdentityUtil;
2328
+ (function(RelayIdentityUtil2) {
2329
+ async function create(name, now = Date.now()) {
2330
+ const sign2 = await subtle().generateKey(SIGN, true, ["sign", "verify"]);
2331
+ const box = await subtle().generateKey(BOX, true, ["deriveBits"]);
2332
+ const raw = async (key) => RelayBytes.toBase64(new Uint8Array(await subtle().exportKey("raw", key)));
2333
+ const [signPublic, boxPublic] = await Promise.all([raw(sign2.publicKey), raw(box.publicKey)]);
2334
+ return {
2335
+ id: await id(signPublic, boxPublic),
2336
+ name,
2337
+ sign: signPublic,
2338
+ box: boxPublic,
2339
+ signKey: await subtle().exportKey("jwk", sign2.privateKey),
2340
+ boxKey: await subtle().exportKey("jwk", box.privateKey),
2341
+ createdAt: now
2342
+ };
2343
+ }
2344
+ RelayIdentityUtil2.create = create;
2345
+ async function id(sign2, box) {
2346
+ const digest = await RelayKeys.sha256(RelayBytes.concat(RelayBytes.fromBase64(sign2), RelayBytes.fromBase64(box)));
2347
+ return RelayBytes.toBase64(digest.subarray(0, 16));
2348
+ }
2349
+ RelayIdentityUtil2.id = id;
2350
+ async function check(identity) {
2351
+ try {
2352
+ if (identity.id !== await id(identity.sign, identity.box)) {
2353
+ return false;
2354
+ }
2355
+ await Promise.all([importSign(identity.sign), importBox(identity.box)]);
2356
+ return true;
2357
+ } catch (_a) {
2358
+ return false;
2359
+ }
2360
+ }
2361
+ RelayIdentityUtil2.check = check;
2362
+ function publicOf(identity) {
2363
+ return withLook({ id: identity.id, name: identity.name, sign: identity.sign, box: identity.box }, identity.look);
2364
+ }
2365
+ RelayIdentityUtil2.publicOf = publicOf;
2366
+ function isLook(look) {
2367
+ return typeof look === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(look);
2368
+ }
2369
+ RelayIdentityUtil2.isLook = isLook;
2370
+ function withLook(value, look) {
2371
+ const { look: _, ...rest } = value;
2372
+ return isLook(look) ? { ...rest, look } : rest;
2373
+ }
2374
+ RelayIdentityUtil2.withLook = withLook;
2375
+ async function sign(identity, text) {
2376
+ const key = await subtle().importKey("jwk", identity.signKey, SIGN, false, ["sign"]);
2377
+ return RelayBytes.toBase64(new Uint8Array(await subtle().sign(SIGNATURE, key, encoder2.encode(text))));
2378
+ }
2379
+ RelayIdentityUtil2.sign = sign;
2380
+ async function verify(signPublic, text, signature) {
2381
+ try {
2382
+ return await subtle().verify(SIGNATURE, await importSign(signPublic), RelayBytes.fromBase64(signature), encoder2.encode(text));
2383
+ } catch (_a) {
2384
+ return false;
2385
+ }
2386
+ }
2387
+ RelayIdentityUtil2.verify = verify;
2388
+ async function agree(identity, otherBox, salt, info) {
2389
+ const own = await subtle().importKey("jwk", identity.boxKey, BOX, false, ["deriveBits"]);
2390
+ const shared = await subtle().deriveBits({ name: "ECDH", public: await importBox(otherBox) }, own, 256);
2391
+ return RelayKeys.hkdf(new Uint8Array(shared), encoder2.encode(salt), info);
2392
+ }
2393
+ RelayIdentityUtil2.agree = agree;
2394
+ function importSign(raw) {
2395
+ return subtle().importKey("raw", RelayBytes.fromBase64(raw), SIGN, false, ["verify"]);
2396
+ }
2397
+ function importBox(raw) {
2398
+ return subtle().importKey("raw", RelayBytes.fromBase64(raw), BOX, false, []);
2399
+ }
2400
+ })(RelayIdentityUtil || (RelayIdentityUtil = {}));
1950
2401
 
1951
- // web-src/dialogs.tsx
1952
- function show(component) {
1953
- if (!pi.ui.custom) {
1954
- pi.ui.notify(t("joinOld"), "warning");
1955
- return;
2402
+ // ../ta-relay/esm/common/relay-team.js
2403
+ var RELAY_JOIN_PATH = "/j";
2404
+ var RELAY_WEB_PATH = "/w/";
2405
+ var RELAY_TEAM_PACKAGE = "@celljs/ta-team";
2406
+ var SEAL_INFO = "ta-team/1 device";
2407
+ var RelayTeamSeal;
2408
+ (function(RelayTeamSeal2) {
2409
+ function keys(name) {
2410
+ return RelayIdentityUtil.create(name);
1956
2411
  }
1957
- return pi.ui.custom(component);
1958
- }
1959
- function LinkBox({ link, title }) {
1960
- const [copied, setCopied] = React.useState(false);
1961
- const canSend = typeof navigator !== "undefined" && typeof navigator.share === "function";
1962
- return /* @__PURE__ */ React.createElement(React.Fragment, null, pi.ui.QrCode && /* @__PURE__ */ React.createElement("div", {
1963
- className: "ttm-qr"
1964
- }, /* @__PURE__ */ React.createElement(pi.ui.QrCode, {
1965
- text: link,
1966
- label: title
1967
- })), /* @__PURE__ */ React.createElement("p", {
1968
- className: "ttm-hint"
1969
- }, t("inviteHint")), /* @__PURE__ */ React.createElement("div", {
1970
- className: "ttm-link-box"
1971
- }, link), /* @__PURE__ */ React.createElement("div", {
1972
- className: "ttm-actions ttm-center"
1973
- }, /* @__PURE__ */ React.createElement("button", {
1974
- type: "button",
1975
- className: "ta-button ta-primary",
1976
- onClick: () => void navigator.clipboard?.writeText(link).then(() => setCopied(true))
1977
- }, copied ? t("copied") : t("copy")), canSend && /* @__PURE__ */ React.createElement("button", {
1978
- type: "button",
1979
- className: "ta-button",
1980
- onClick: () => void navigator.share({ title, url: link }).catch(() => {
2412
+ RelayTeamSeal2.keys = keys;
2413
+ async function seal(box, salt, text) {
2414
+ const own = await RelayIdentityUtil.create("ta");
2415
+ const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(own, box, salt, SEAL_INFO));
2416
+ return { box: own.box, sealed: await RelayKeys.seal(key, text) };
2417
+ }
2418
+ RelayTeamSeal2.seal = seal;
2419
+ async function open(keys2, answer, salt) {
2420
+ const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(keys2, answer.box, salt, SEAL_INFO));
2421
+ return RelayKeys.open(key, answer.sealed);
2422
+ }
2423
+ RelayTeamSeal2.open = open;
2424
+ function isKey(box) {
2425
+ return typeof box === "string" && /^[A-Za-z0-9_-]{80,100}$/.test(box) && RelayBytes.fromBase64(box).length === 65;
2426
+ }
2427
+ RelayTeamSeal2.isKey = isKey;
2428
+ })(RelayTeamSeal || (RelayTeamSeal = {}));
2429
+ var RelayTeamLinkUtil;
2430
+ (function(RelayTeamLinkUtil2) {
2431
+ const ID = /^[A-Za-z0-9_-]{16,64}$/;
2432
+ function format(link) {
2433
+ const fragment = new URLSearchParams({ v: "1", h: link.host, d: link.device, k: link.key, o: link.owner, r: link.role });
2434
+ if (link.what) {
2435
+ fragment.set("w", link.what);
2436
+ }
2437
+ if (link.language) {
2438
+ fragment.set("l", link.language);
2439
+ }
2440
+ return `${link.relay.replace(/\/+$/, "")}${RELAY_JOIN_PATH}#${fragment}`;
2441
+ }
2442
+ RelayTeamLinkUtil2.format = format;
2443
+ function parse(text) {
2444
+ var _a;
2445
+ var _b, _c, _d;
2446
+ let url;
2447
+ try {
2448
+ url = new URL(text.trim());
2449
+ } catch (_e) {
1981
2450
  return;
1982
- })
1983
- }, t("send"))));
1984
- }
1985
- function InviteDialog({ roles, close }) {
1986
- const [role, setRole] = React.useState(DEFAULT_ROLE);
1987
- const [what, setWhat] = React.useState("whole");
1988
- const [items, setItems] = React.useState();
1989
- const [picked, setPicked] = React.useState([]);
1990
- const [level, setLevel] = React.useState("use");
1991
- React.useEffect(() => {
1992
- if (what === "only" && !items) {
1993
- call("shareable").then(setItems, () => setItems([]));
1994
2451
  }
1995
- }, [what, items]);
1996
- const [days, setDays] = React.useState(7);
1997
- const [approve, setApprove] = React.useState(true);
1998
- const [invite, setInvite] = React.useState();
1999
- const [busy, setBusy] = React.useState(false);
2000
- const [error, setError] = React.useState();
2001
- const make = async () => {
2002
- setBusy(true);
2003
- setError(undefined);
2452
+ const fragment = new URLSearchParams(url.hash.slice(1));
2453
+ const [host, device, key] = ["h", "d", "k"].map((name) => {
2454
+ var _a2;
2455
+ return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
2456
+ });
2457
+ if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_JOIN_PATH || fragment.get("v") !== "1" || !ID.test(host) || !ID.test(device) || !/^[A-Za-z0-9_-]{43}$/.test(key)) {
2458
+ return;
2459
+ }
2460
+ const what = (_a = fragment.get("w")) === null || _a === undefined ? undefined : _a.slice(0, 80);
2461
+ const language = (_b = fragment.get("l")) !== null && _b !== undefined ? _b : "";
2462
+ return {
2463
+ relay: url.origin,
2464
+ host,
2465
+ device,
2466
+ key,
2467
+ owner: (_c = fragment.get("o")) !== null && _c !== undefined ? _c : "",
2468
+ role: (_d = fragment.get("r")) !== null && _d !== undefined ? _d : "",
2469
+ ...what ? { what } : {},
2470
+ .../^[a-z]{2}(-[A-Za-z]{2,4})?$/.test(language) ? { language } : {}
2471
+ };
2472
+ }
2473
+ RelayTeamLinkUtil2.parse = parse;
2474
+ function signInFor(link, provider, handoff) {
2475
+ return `${format(link)}&${new URLSearchParams({ p: provider, x: handoff })}`;
2476
+ }
2477
+ RelayTeamLinkUtil2.signInFor = signInFor;
2478
+ function handoffOf(text) {
2479
+ var _a, _b;
2480
+ let url;
2004
2481
  try {
2005
- const share = what === "only" ? (items ?? []).filter((item) => picked.includes(`${item.kind}:${item.id}`)).map((item) => ({ kind: item.kind, id: item.id })) : [];
2006
- setInvite(await call("createInvite", { role: what === "only" ? "guest" : role, days, approve, share, level, language: pi.ui.language }));
2007
- book.load();
2008
- } catch (failure) {
2009
- setError(message(failure));
2482
+ url = new URL(text.trim());
2483
+ } catch (_c) {
2484
+ return;
2010
2485
  }
2011
- setBusy(false);
2012
- };
2013
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2014
- title: t("inviteDialog"),
2015
- onClose: close
2016
- }, /* @__PURE__ */ React.createElement("div", {
2017
- className: "ttm-dialog"
2018
- }, invite ? /* @__PURE__ */ React.createElement(LinkBox, {
2019
- link: invite.link,
2020
- title: t("inviteDialog")
2021
- }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
2022
- className: "ttm-field"
2023
- }, /* @__PURE__ */ React.createElement("span", null, t("inviteWhat")), /* @__PURE__ */ React.createElement(Choices, {
2024
- value: what,
2025
- onChange: setWhat,
2026
- items: [
2027
- { id: "whole", label: t("inviteWhole"), hint: t("inviteWholeHint") },
2028
- { id: "only", label: t("inviteOnly"), hint: t("inviteOnlyHint") }
2029
- ]
2030
- })), what === "only" && /* @__PURE__ */ React.createElement("div", {
2031
- className: "ttm-field"
2032
- }, /* @__PURE__ */ React.createElement("span", null, t("pickShared")), !items ? /* @__PURE__ */ React.createElement("p", {
2033
- className: "ttm-hint"
2034
- }, t("loading")) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2035
- title: t("nothingToShare"),
2036
- compact: true
2037
- }) : /* @__PURE__ */ React.createElement("ul", {
2038
- className: "ttm-picks"
2039
- }, items.map((item) => {
2040
- const key = `${item.kind}:${item.id}`;
2041
- const on = picked.includes(key);
2042
- return /* @__PURE__ */ React.createElement("li", {
2043
- key
2044
- }, /* @__PURE__ */ React.createElement("button", {
2045
- type: "button",
2046
- className: `ttm-pick${on ? " ttm-on" : ""}`,
2047
- "aria-pressed": on,
2048
- onClick: () => setPicked(on ? picked.filter((one) => one !== key) : [...picked, key])
2049
- }, pi.ui.Face ? /* @__PURE__ */ React.createElement(pi.ui.Face, {
2050
- face: item.face,
2051
- seed: item.id,
2052
- size: 28
2053
- }) : null, /* @__PURE__ */ React.createElement("span", {
2054
- className: "ttm-row-text"
2055
- }, /* @__PURE__ */ React.createElement("span", {
2056
- className: "ttm-row-title"
2057
- }, item.name), /* @__PURE__ */ React.createElement("span", {
2058
- className: "ttm-row-line"
2059
- }, item.kind === "agent" ? t("agentKind") : t("channelKind")))));
2060
- })), /* @__PURE__ */ React.createElement(Choices, {
2061
- value: level,
2062
- onChange: setLevel,
2063
- items: [
2064
- { id: "view", label: t("levelView"), hint: t("levelViewHint") },
2065
- { id: "use", label: t("levelUse"), hint: t("levelUseHint") },
2066
- { id: "edit", label: t("levelEdit"), hint: t("levelEditHint") }
2067
- ]
2068
- })), /* @__PURE__ */ React.createElement("label", {
2069
- className: `ttm-field${what === "only" ? " ttm-hidden" : ""}`
2070
- }, /* @__PURE__ */ React.createElement("span", null, t("role")), /* @__PURE__ */ React.createElement("select", {
2071
- className: "ttm-select",
2072
- value: role,
2073
- onChange: (event) => setRole(event.target.value)
2074
- }, roles.filter((one) => one.id !== "admin" || book.get().me?.owner).map((one) => /* @__PURE__ */ React.createElement("option", {
2075
- key: one.id,
2076
- value: one.id
2077
- }, roleName(one))))), /* @__PURE__ */ React.createElement("label", {
2078
- className: "ttm-field"
2079
- }, /* @__PURE__ */ React.createElement("span", null, t("lasts")), /* @__PURE__ */ React.createElement("select", {
2080
- className: "ttm-select",
2081
- value: days,
2082
- onChange: (event) => setDays(Number(event.target.value))
2083
- }, [1, 7, 30].map((n) => /* @__PURE__ */ React.createElement("option", {
2084
- key: n,
2085
- value: n
2086
- }, t("days", { n }))))), /* @__PURE__ */ React.createElement("label", {
2087
- className: "ttm-check"
2088
- }, /* @__PURE__ */ React.createElement("input", {
2089
- type: "checkbox",
2090
- checked: approve,
2091
- onChange: (event) => setApprove(event.target.checked)
2092
- }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, t("approve")), /* @__PURE__ */ React.createElement("small", null, t("approveHint")))), error && /* @__PURE__ */ React.createElement("p", {
2093
- className: "ttm-error"
2094
- }, error), /* @__PURE__ */ React.createElement("div", {
2095
- className: "ttm-actions"
2096
- }, /* @__PURE__ */ React.createElement("button", {
2097
- type: "button",
2098
- className: "ta-button",
2099
- onClick: close
2100
- }, t("cancel")), /* @__PURE__ */ React.createElement("button", {
2101
- type: "button",
2102
- className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
2103
- disabled: busy || what === "only" && picked.length === 0,
2104
- onClick: () => void make()
2105
- }, busy ? t("making") : t("makeLink"))))));
2106
- }
2107
- function openInvite(roles) {
2108
- show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog, {
2109
- roles,
2110
- close
2111
- }));
2112
- }
2113
- function openLink(link) {
2114
- show(({ close }) => /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2115
- title: t("links"),
2116
- onClose: close
2117
- }, /* @__PURE__ */ React.createElement("div", {
2118
- className: "ttm-dialog"
2119
- }, /* @__PURE__ */ React.createElement(LinkBox, {
2120
- link,
2121
- title: t("inviteDialog")
2122
- }))));
2123
- }
2124
- function areas() {
2125
- const by = new Map;
2126
- for (const action2 of TA_ACTIONS) {
2127
- by.set(action2.area, [...by.get(action2.area) ?? [], action2]);
2486
+ const fragment = new URLSearchParams(url.hash.slice(1));
2487
+ const provider = (_a = fragment.get("p")) !== null && _a !== undefined ? _a : "";
2488
+ const handoff = (_b = fragment.get("x")) !== null && _b !== undefined ? _b : "";
2489
+ return /^[a-z0-9_-]{1,32}$/.test(provider) && /^[A-Za-z0-9_-]{16,64}$/.test(handoff) ? { provider, handoff } : undefined;
2490
+ }
2491
+ RelayTeamLinkUtil2.handoffOf = handoffOf;
2492
+ function web(relay, pairing) {
2493
+ return `${relay.replace(/\/+$/, "")}${RELAY_WEB_PATH}#${new URLSearchParams({ pair: pairing })}`;
2494
+ }
2495
+ RelayTeamLinkUtil2.web = web;
2496
+ })(RelayTeamLinkUtil || (RelayTeamLinkUtil = {}));
2497
+
2498
+ class RelayTeamJoining {
2499
+ constructor(link) {
2500
+ this.closed = false;
2501
+ this.calls = new RelayHostCalls({ relay: link.relay, host: link.host, device: link.device, key: link.key, name: link.owner }, RELAY_TEAM_PACKAGE);
2502
+ }
2503
+ get keys() {
2504
+ return this.own;
2128
2505
  }
2129
- return [...by];
2130
- }
2131
- function RoleDialog({ role, close }) {
2132
- const fixed = !!role?.preset;
2133
- const [name, setName] = React.useState(role ? roleName(role) : "");
2134
- const [actions, setActions] = React.useState(new Set(role?.actions ?? []));
2135
- const [dirs, setDirs] = React.useState((role?.dirs ?? []).join(`
2136
- `));
2137
- const [scope, setScope] = React.useState(role?.scope ?? "all");
2138
- const [outside, setOutside] = React.useState(role?.outside ?? "deny");
2139
- const toggle = (id) => {
2140
- const next = new Set(actions);
2141
- if (next.has(id)) {
2142
- next.delete(id);
2143
- } else {
2144
- next.add(id);
2506
+ async ways(via) {
2507
+ try {
2508
+ return await this.calls.callHost("ways", via ? { via } : {});
2509
+ } catch (failure) {
2510
+ if (RelayTeamJoining.unreachable(failure)) {
2511
+ throw failure;
2512
+ }
2513
+ return { providers: [], required: false };
2145
2514
  }
2146
- setActions(next);
2147
- };
2148
- const [busy, run] = pi.ui.useBusy();
2149
- const save = async () => {
2150
- const saved = await act(() => call("saveRole", {
2151
- id: role?.id,
2152
- name: name.trim(),
2153
- actions: [...actions],
2154
- scope,
2155
- outside,
2156
- dirs: dirs.split(`
2157
- `).map((line) => line.trim()).filter(Boolean)
2158
- }));
2159
- if (saved) {
2160
- close();
2515
+ }
2516
+ static unreachable(failure) {
2517
+ return /did not answer|was lost/i.test(failure instanceof Error ? failure.message : String(failure));
2518
+ }
2519
+ async signIn(provider, handoff) {
2520
+ return await this.calls.callHost("signIn", { provider, ...handoff ? { handoff } : {} });
2521
+ }
2522
+ async signedIn(state, code) {
2523
+ const answer = await this.calls.callHost("signedIn", { state, code });
2524
+ return { account: answer.account };
2525
+ }
2526
+ async typed(state, until = Date.now() + 15 * 60000) {
2527
+ while (!this.closed && Date.now() < until) {
2528
+ let answer;
2529
+ try {
2530
+ answer = await this.calls.callHost("signedIn", { state });
2531
+ } catch (failure) {
2532
+ if (this.closed) {
2533
+ return;
2534
+ }
2535
+ if (!RelayTeamJoining.unreachable(failure)) {
2536
+ throw failure;
2537
+ }
2538
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2539
+ continue;
2540
+ }
2541
+ if (answer.status === "done" && answer.account) {
2542
+ return answer.account;
2543
+ }
2161
2544
  }
2162
- };
2163
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2164
- title: t("roleDialog"),
2165
- onClose: close
2166
- }, /* @__PURE__ */ React.createElement("div", {
2167
- className: "ttm-dialog ttm-role"
2168
- }, /* @__PURE__ */ React.createElement("label", {
2169
- className: "ttm-field"
2170
- }, /* @__PURE__ */ React.createElement("span", null, t("roleName")), /* @__PURE__ */ React.createElement("input", {
2171
- className: "ttm-input",
2172
- value: name,
2173
- disabled: fixed,
2174
- onChange: (event) => setName(event.target.value)
2175
- })), /* @__PURE__ */ React.createElement("fieldset", {
2176
- className: "ttm-field ttm-plain",
2177
- disabled: fixed
2178
- }, /* @__PURE__ */ React.createElement("span", null, t("scope")), /* @__PURE__ */ React.createElement(Choices, {
2179
- value: scope,
2180
- onChange: setScope,
2181
- items: [
2182
- { id: "all", label: t("scopeAll") },
2183
- { id: "shared", label: t("scopeShared") }
2184
- ]
2185
- })), /* @__PURE__ */ React.createElement("fieldset", {
2186
- className: "ttm-field ttm-plain",
2187
- disabled: fixed
2188
- }, /* @__PURE__ */ React.createElement("span", null, t("outside")), /* @__PURE__ */ React.createElement(Choices, {
2189
- value: outside,
2190
- onChange: setOutside,
2191
- items: [
2192
- { id: "deny", label: t("outsideDeny"), hint: t("outsideDenyHint") },
2193
- { id: "ask", label: t("outsideAsk"), hint: t("outsideAskHint") },
2194
- { id: "read", label: t("outsideRead"), hint: t("outsideReadHint") },
2195
- { id: "allow", label: t("outsideAllow"), hint: t("outsideAllowHint") }
2196
- ]
2197
- })), areas().map(([area, list]) => /* @__PURE__ */ React.createElement("fieldset", {
2198
- key: area,
2199
- className: "ttm-area"
2200
- }, list.map((action2) => /* @__PURE__ */ React.createElement("label", {
2201
- key: action2.id,
2202
- className: "ttm-check ttm-check-small"
2203
- }, /* @__PURE__ */ React.createElement("input", {
2204
- type: "checkbox",
2205
- disabled: fixed,
2206
- checked: actions.has(action2.id),
2207
- onChange: () => toggle(action2.id)
2208
- }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", null, actionTitle(action2.id)), action2.risky && /* @__PURE__ */ React.createElement("small", {
2209
- className: "ttm-risky"
2210
- }, t("risky"))))))), /* @__PURE__ */ React.createElement("label", {
2211
- className: "ttm-field"
2212
- }, /* @__PURE__ */ React.createElement("span", null, t("roleDirs")), /* @__PURE__ */ React.createElement("textarea", {
2213
- className: "ttm-input",
2214
- rows: 3,
2215
- value: dirs,
2216
- disabled: fixed,
2217
- onChange: (event) => setDirs(event.target.value)
2218
- })), /* @__PURE__ */ React.createElement("div", {
2219
- className: "ttm-actions"
2220
- }, role && !fixed && /* @__PURE__ */ React.createElement("button", {
2221
- type: "button",
2222
- className: "ta-button ta-danger",
2223
- disabled: busy,
2224
- onClick: () => void run(() => act(() => call("deleteRole", role.id)).then((done) => {
2225
- if (done) {
2226
- close();
2545
+ return;
2546
+ }
2547
+ async handedOff(handoff, until = Date.now() + 10 * 60000) {
2548
+ while (!this.closed && Date.now() < until) {
2549
+ try {
2550
+ const answer = await this.calls.callHost("handedOff", handoff);
2551
+ if (answer.status === "done" && answer.account) {
2552
+ return answer.account;
2553
+ }
2554
+ } catch (_a) {
2555
+ await new Promise((resolve) => setTimeout(resolve, 1000));
2227
2556
  }
2228
- }))
2229
- }, t("deleteRole")), /* @__PURE__ */ React.createElement("span", {
2230
- className: "ttm-grow"
2231
- }), /* @__PURE__ */ React.createElement("button", {
2232
- type: "button",
2233
- className: "ta-button",
2234
- onClick: close
2235
- }, fixed ? t("close") : t("cancel")), !fixed && /* @__PURE__ */ React.createElement("button", {
2236
- type: "button",
2237
- className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
2238
- "aria-busy": busy || undefined,
2239
- disabled: busy || !name.trim(),
2240
- onClick: () => void run(save)
2241
- }, busy && /* @__PURE__ */ React.createElement("span", {
2242
- className: "ta-spinner ta-busy-mark ta-on-brand"
2243
- }), /* @__PURE__ */ React.createElement("span", null, t("save"))))));
2244
- }
2245
- function openRole(role) {
2246
- show(({ close }) => /* @__PURE__ */ React.createElement(RoleDialog, {
2247
- role,
2248
- close
2249
- }));
2250
- }
2251
- function RequestDialog({ denial, close }) {
2252
- const [reason, setReason] = React.useState("");
2253
- const [busy, setBusy] = React.useState(false);
2254
- const [error, setError] = React.useState();
2255
- const ask = async () => {
2256
- setBusy(true);
2257
- try {
2258
- await call("requestAccess", { action: denial.action, resource: denial.resource, reason });
2259
- pi.ui.notify(t("asked"));
2260
- book.load();
2261
- close();
2262
- } catch (failure) {
2263
- setError(message(failure));
2264
- setBusy(false);
2265
2557
  }
2266
- };
2267
- const where = denial.resource?.kind === "dir" ? denial.resource.id : undefined;
2268
- return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
2269
- title: t("requestTitle", { action: actionTitle(denial.action) }),
2270
- onClose: close
2271
- }, /* @__PURE__ */ React.createElement("div", {
2272
- className: "ttm-dialog"
2273
- }, /* @__PURE__ */ React.createElement("p", {
2274
- className: "ttm-lead"
2275
- }, t("requestLead")), where && /* @__PURE__ */ React.createElement("p", {
2276
- className: "ttm-hint"
2277
- }, t("accessWhere", { path: where })), /* @__PURE__ */ React.createElement("input", {
2278
- className: "ttm-input",
2279
- placeholder: t("reasonPlaceholder"),
2280
- value: reason,
2281
- onChange: (event) => setReason(event.target.value)
2282
- }), error && /* @__PURE__ */ React.createElement("p", {
2283
- className: "ttm-error"
2284
- }, error), /* @__PURE__ */ React.createElement("div", {
2285
- className: "ttm-actions"
2286
- }, /* @__PURE__ */ React.createElement("button", {
2287
- type: "button",
2288
- className: "ta-button",
2289
- onClick: close
2290
- }, t("cancel")), /* @__PURE__ */ React.createElement("button", {
2291
- type: "button",
2292
- className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
2293
- disabled: busy,
2294
- onClick: () => void ask()
2295
- }, t("ask")))));
2296
- }
2297
- function openRequest(denial) {
2298
- show(({ close }) => /* @__PURE__ */ React.createElement(RequestDialog, {
2299
- denial,
2300
- close
2301
- }));
2558
+ return;
2559
+ }
2560
+ async ask(name, via, signIn) {
2561
+ const own = await RelayTeamSeal.keys(name || "ta");
2562
+ const answer = await this.calls.callHost("ask", { name, box: own.box, ...via ? { via } : {}, ...signIn ? { signIn } : {} });
2563
+ if (answer.status !== "refused") {
2564
+ this.own = own;
2565
+ }
2566
+ return answer;
2567
+ }
2568
+ resume(keys) {
2569
+ this.own = keys;
2570
+ }
2571
+ async wait(request) {
2572
+ for (;; ) {
2573
+ if (this.closed) {
2574
+ return { status: "gone" };
2575
+ }
2576
+ const answer = await this.calls.callHost("wait", request);
2577
+ if (answer.status !== "waiting") {
2578
+ return answer;
2579
+ }
2580
+ }
2581
+ }
2582
+ async pairing(request, answer) {
2583
+ if (!this.own) {
2584
+ throw new Error("Ask first.");
2585
+ }
2586
+ const device = JSON.parse(await RelayTeamSeal.open(this.own, answer, request));
2587
+ return RelayPairingUtil.link(RelayPairingUtil.parse(RelayPairingUtil.link(device)));
2588
+ }
2589
+ close() {
2590
+ this.closed = true;
2591
+ this.calls.close();
2592
+ }
2302
2593
  }
2594
+
2595
+ // web-src/join-dialog.tsx
2303
2596
  function JoinDialog({ link, close }) {
2304
2597
  const [name, setName] = React.useState("");
2305
2598
  const [state, setState] = React.useState("form");
@@ -2641,7 +2934,8 @@ class TeamSharedHome {
2641
2934
  // web-src/style.ts
2642
2935
  var STYLE = `
2643
2936
  .ttm-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; }
2644
- .ttm-list { display: flex; flex-direction: column; gap: 12px; max-width: 720px; margin: 0 auto; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); box-sizing: border-box; }
2937
+ .ttm-page:has(> .ta-loading) { display: flex; flex-direction: column; }
2938
+ .ttm-list { display: flex; flex-direction: column; gap: 12px; max-width: var(--ta-page-width); margin: 0 auto; padding: 8px 12px calc(24px + env(safe-area-inset-bottom)); box-sizing: border-box; }
2645
2939
  .ttm-pad { padding: 16px; }
2646
2940
  .ttm-hero { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; background: var(--ta-raised); }
2647
2941
  .ttm-hero strong { font-size: calc(15px * var(--ta-font-scale)); font-weight: 600; }
@@ -2698,7 +2992,6 @@ var STYLE = `
2698
2992
  .ttm-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
2699
2993
  .ttm-center { justify-content: center; }
2700
2994
  .ttm-grow { flex: 1; }
2701
- .ttm-qr { display: flex; justify-content: center; }
2702
2995
  /* The tabs of the page are the page's segmented control (.ta-segmented); only what it lacks: they size to their labels and carry a count */
2703
2996
  .ttm-segments { align-self: flex-start; max-width: 100%; overflow-x: auto; }
2704
2997
  .ttm-segments button { position: relative; padding: 0 14px; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
@@ -2734,7 +3027,6 @@ fieldset.ttm-plain:disabled .ttm-choice { cursor: default; opacity: .75; }
2734
3027
  .ttm-seen { opacity: .6; }
2735
3028
  [data-layout='compact'] .ttm-hero-row { flex-direction: column; align-items: stretch; }
2736
3029
  [data-layout='compact'] .ttm-record { flex-direction: column; gap: 2px; }
2737
- .ttm-link-box { padding: 8px 10px; border-radius: 8px; background: var(--ta-hover); font-family: var(--ta-mono, ui-monospace, monospace); font-size: calc(11.5px * var(--ta-font-scale)); word-break: break-all; user-select: all; }
2738
3030
  `;
2739
3031
  function injectStyle() {
2740
3032
  const style = document.createElement("style");
@@ -2751,6 +3043,7 @@ function grantLine(grant) {
2751
3043
  return `${actionTitle(grant.action)}${on} · ${until}`;
2752
3044
  }
2753
3045
  function ShareDialog({ member, name, close }) {
3046
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
2754
3047
  const [items, setItems] = React.useState();
2755
3048
  const [picked, setPicked] = React.useState();
2756
3049
  const [level, setLevel] = React.useState("use");
@@ -2771,9 +3064,11 @@ function ShareDialog({ member, name, close }) {
2771
3064
  onClose: close
2772
3065
  }, /* @__PURE__ */ React.createElement("div", {
2773
3066
  className: "ttm-dialog"
2774
- }, !items ? /* @__PURE__ */ React.createElement("p", {
3067
+ }, !items ? error ? /* @__PURE__ */ React.createElement("p", {
2775
3068
  className: "ttm-hint"
2776
- }, error ?? t("loading")) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
3069
+ }, error) : /* @__PURE__ */ React.createElement(Loading, {
3070
+ compact: true
3071
+ }) : items.length === 0 ? /* @__PURE__ */ React.createElement(pi.ui.Empty, {
2777
3072
  title: t("nothingToShare"),
2778
3073
  compact: true
2779
3074
  }) : /* @__PURE__ */ React.createElement("ul", {
@@ -3234,6 +3529,7 @@ function alertLine(alert, overview) {
3234
3529
  return t(`rule.${alert.rule}`, { name, detail: alert.detail ?? alert.text });
3235
3530
  }
3236
3531
  function RecordTab({ overview }) {
3532
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
3237
3533
  const [filter, setFilter] = React.useState("notable");
3238
3534
  const [who, setWho] = React.useState("");
3239
3535
  const [text, setText] = React.useState("");
@@ -3318,9 +3614,9 @@ function RecordTab({ overview }) {
3318
3614
  onChange: (event) => setText(event.target.value)
3319
3615
  })), /* @__PURE__ */ React.createElement(Section, {
3320
3616
  title: t("record")
3321
- }, !entries ? /* @__PURE__ */ React.createElement("li", {
3322
- className: "ttm-row ttm-quiet"
3323
- }, t("loading")) : entries.length === 0 ? /* @__PURE__ */ React.createElement("li", {
3617
+ }, !entries ? /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(Loading, {
3618
+ compact: true
3619
+ })) : entries.length === 0 ? /* @__PURE__ */ React.createElement("li", {
3324
3620
  className: "ttm-row ttm-quiet"
3325
3621
  }, t("nothing")) : entries.map((entry, index) => /* @__PURE__ */ React.createElement("li", {
3326
3622
  key: `${entry.at}:${index}`,
@@ -3448,6 +3744,7 @@ function RolesTab({ me, overview }) {
3448
3744
  // web-src/team-page.tsx
3449
3745
  function TeamPage() {
3450
3746
  const { me, overview, error } = useBook();
3747
+ const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
3451
3748
  const [tab, setTab] = React.useState("members");
3452
3749
  React.useEffect(() => {
3453
3750
  book.load();
@@ -3459,9 +3756,7 @@ function TeamPage() {
3459
3756
  className: "ttm-page"
3460
3757
  }, error ? /* @__PURE__ */ React.createElement("p", {
3461
3758
  className: "ttm-error ttm-pad"
3462
- }, error) : /* @__PURE__ */ React.createElement("p", {
3463
- className: "ttm-quiet ttm-pad"
3464
- }, t("loading")));
3759
+ }, error) : /* @__PURE__ */ React.createElement(Loading, null));
3465
3760
  }
3466
3761
  if (!overview) {
3467
3762
  return /* @__PURE__ */ React.createElement("div", {
@@ -3525,7 +3820,7 @@ function activate(pi2) {
3525
3820
  title: () => t("title"),
3526
3821
  icon: icon("ShieldCheck"),
3527
3822
  render: TeamPage,
3528
- discover: true,
3823
+ group: "share",
3529
3824
  order: 82
3530
3825
  });
3531
3826
  pi2.registerOpener((link) => link.type === "url" && openJoin(link.url), { specific: true });