chirkle 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +99 -47
  2. package/bin/release/darwin-amd64/chirkle-server +4 -0
  3. package/bin/release/darwin-arm64/chirkle-server +0 -0
  4. package/bin/release/linux-amd64/chirkle-server +0 -0
  5. package/bin/release/linux-arm64/chirkle-server +0 -0
  6. package/package.json +9 -6
  7. package/pb_hooks/federation/inbox.js +2 -69
  8. package/pb_hooks/federation/messages.js +5 -3
  9. package/pb_hooks/federation/net.js +1 -0
  10. package/pb_hooks/federation/people.js +1 -0
  11. package/pb_hooks/federation.pb.js +1 -8
  12. package/pb_hooks/lib/access.js +33 -10
  13. package/pb_hooks/lib/account.js +542 -6
  14. package/pb_hooks/lib/anonymous.js +2 -129
  15. package/pb_hooks/lib/bulk.js +1 -2
  16. package/pb_hooks/lib/collections.js +4 -4
  17. package/pb_hooks/lib/dms.js +1 -1
  18. package/pb_hooks/lib/files.js +82 -120
  19. package/pb_hooks/lib/handles.js +2 -2
  20. package/pb_hooks/lib/inbox.js +40 -54
  21. package/pb_hooks/lib/invites.js +266 -0
  22. package/pb_hooks/lib/media.js +5 -43
  23. package/pb_hooks/lib/messages.js +72 -117
  24. package/pb_hooks/lib/moderation.js +2 -16
  25. package/pb_hooks/lib/reactions.js +28 -4
  26. package/pb_hooks/lib/retention.js +88 -0
  27. package/pb_hooks/lib/site.js +13 -2
  28. package/pb_hooks/lib/stats.js +6 -34
  29. package/pb_hooks/lib/users.js +88 -7
  30. package/pb_hooks/lib/worker.js +22 -1
  31. package/pb_hooks/main.pb.js +85 -94
  32. package/pb_hooks/telegram/api.js +64 -12
  33. package/pb_hooks/telegram/inbound.js +158 -31
  34. package/pb_hooks/telegram/links.js +4 -3
  35. package/pb_hooks/telegram/outbound.js +86 -45
  36. package/pb_hooks/telegram/people.js +3 -3
  37. package/pb_hooks/telegram/worker.js +59 -15
  38. package/pb_migrations/1760000045_password_reset.js +38 -0
  39. package/pb_migrations/1760000047_telegram_supergroup_ids.js +51 -0
  40. package/pb_migrations/1760000048_inbox_reactions_merged.js +24 -0
  41. package/pb_migrations/1760000049_inbox_room_index.js +22 -0
  42. package/pb_migrations/1760000050_messages_unread_index.js +22 -0
  43. package/pb_migrations/1760000051_users_kind.js +31 -0
  44. package/pb_migrations/1760000052_deleted_accounts.js +19 -0
  45. package/pb_migrations/1760000053_account_jobs.js +45 -0
  46. package/pb_migrations/1760000054_room_invites.js +39 -0
  47. package/pb_migrations/1760000055_invite_barred.js +16 -0
  48. package/pb_migrations/1760000056_telegram_fetch.js +21 -0
  49. package/pb_public/assets/{access-PB77EH4F.css → access-GPRLOZOO.css} +2 -2
  50. package/pb_public/assets/{access-PB77EH4F.css.map → access-GPRLOZOO.css.map} +2 -2
  51. package/pb_public/assets/access-UK3L54NR.js +2 -0
  52. package/pb_public/assets/access-UK3L54NR.js.map +7 -0
  53. package/pb_public/assets/account-CT2BVMAX.css +2 -0
  54. package/pb_public/assets/account-CT2BVMAX.css.map +7 -0
  55. package/pb_public/assets/account-api-J6A6IYVX.js +2 -0
  56. package/pb_public/assets/account-api-J6A6IYVX.js.map +7 -0
  57. package/pb_public/assets/app-HB3NZHQ2.js +3 -0
  58. package/pb_public/assets/app-HB3NZHQ2.js.map +7 -0
  59. package/pb_public/assets/app-XJ73EU5O.css +2 -0
  60. package/pb_public/assets/app-XJ73EU5O.css.map +7 -0
  61. package/pb_public/assets/chunk-56ACD3V5.js +2 -0
  62. package/pb_public/assets/chunk-56ACD3V5.js.map +7 -0
  63. package/pb_public/assets/chunk-AG73QNUN.js +2 -0
  64. package/pb_public/assets/chunk-AG73QNUN.js.map +7 -0
  65. package/pb_public/assets/chunk-DCLJRQ53.js +2 -0
  66. package/pb_public/assets/chunk-DCLJRQ53.js.map +7 -0
  67. package/pb_public/assets/chunk-DZC4SY4M.js +2 -0
  68. package/pb_public/assets/chunk-DZC4SY4M.js.map +7 -0
  69. package/pb_public/assets/chunk-N2OFGBCZ.js +2 -0
  70. package/pb_public/assets/chunk-N2OFGBCZ.js.map +7 -0
  71. package/pb_public/assets/chunk-OKIIBH7O.js +2 -0
  72. package/pb_public/assets/chunk-OKIIBH7O.js.map +7 -0
  73. package/pb_public/assets/chunk-RPCBA7VF.js +2 -0
  74. package/pb_public/assets/chunk-RPCBA7VF.js.map +7 -0
  75. package/pb_public/assets/chunk-UZDXAORM.js +2 -0
  76. package/pb_public/assets/chunk-UZDXAORM.js.map +7 -0
  77. package/pb_public/assets/chunk-VTOUI25E.js +4 -0
  78. package/pb_public/assets/chunk-VTOUI25E.js.map +7 -0
  79. package/pb_public/assets/chunk-WR25F7FU.js +2 -0
  80. package/pb_public/assets/chunk-WR25F7FU.js.map +7 -0
  81. package/pb_public/assets/{emoji-VA2WCEAC.css → emoji-WWNPWCF3.css} +2 -2
  82. package/pb_public/assets/{emoji-VA2WCEAC.css.map → emoji-WWNPWCF3.css.map} +2 -2
  83. package/pb_public/assets/{emoji-picker-65VVVGYW.js → emoji-picker-K6JTK2GV.js} +4 -4
  84. package/pb_public/assets/emoji-picker-K6JTK2GV.js.map +7 -0
  85. package/pb_public/assets/forward-267HRNPY.js +2 -0
  86. package/pb_public/assets/forward-267HRNPY.js.map +7 -0
  87. package/pb_public/assets/inbox-CLMYESNI.js +2 -0
  88. package/pb_public/assets/inbox-CLMYESNI.js.map +7 -0
  89. package/pb_public/assets/invite-OGT5E2MZ.js +2 -0
  90. package/pb_public/assets/invite-OGT5E2MZ.js.map +7 -0
  91. package/pb_public/assets/invite-api-7G7XPXQW.js +2 -0
  92. package/pb_public/assets/invite-api-7G7XPXQW.js.map +7 -0
  93. package/pb_public/assets/lazy-H3KIJVB5.js +2 -0
  94. package/pb_public/assets/lazy-H3KIJVB5.js.map +7 -0
  95. package/pb_public/assets/login-TK6K4WGB.js +2 -0
  96. package/pb_public/assets/login-TK6K4WGB.js.map +7 -0
  97. package/pb_public/assets/media-WZ4653L5.js +2 -0
  98. package/pb_public/assets/media-WZ4653L5.js.map +7 -0
  99. package/pb_public/assets/mention-suggest-ODJD2IC5.js +2 -0
  100. package/pb_public/assets/mention-suggest-ODJD2IC5.js.map +7 -0
  101. package/pb_public/assets/notify-EPDM772N.js +2 -0
  102. package/pb_public/assets/notify-EPDM772N.js.map +7 -0
  103. package/pb_public/assets/profile-3R6S5QYS.js +2 -0
  104. package/pb_public/assets/profile-3R6S5QYS.js.map +7 -0
  105. package/pb_public/assets/search-WCHOGAJQ.js +2 -0
  106. package/pb_public/assets/search-WCHOGAJQ.js.map +7 -0
  107. package/pb_public/assets/stats-GTO2H6PG.js +2 -0
  108. package/pb_public/assets/stats-GTO2H6PG.js.map +7 -0
  109. package/pb_public/assets/switcher-TFSO45KV.js +2 -0
  110. package/pb_public/assets/switcher-TFSO45KV.js.map +7 -0
  111. package/pb_public/assets/user-search-3HQOCQWL.js +2 -0
  112. package/pb_public/assets/user-search-3HQOCQWL.js.map +7 -0
  113. package/pb_public/assets/viewer-2Y5FJBW4.js +2 -0
  114. package/pb_public/assets/viewer-2Y5FJBW4.js.map +7 -0
  115. package/pb_public/index.html +10 -2
  116. package/pb_public/stats.html +1 -1
  117. package/scripts/service.mjs +201 -0
  118. package/scripts/start.mjs +21 -17
  119. package/pb_hooks/lib/enrich.js +0 -75
  120. package/pb_hooks/lib/lists.js +0 -179
  121. package/pb_hooks/lib/live.js +0 -137
  122. package/pb_hooks/lib/reads.js +0 -183
  123. package/pb_public/assets/access-GUDTDXIP.js +0 -2
  124. package/pb_public/assets/access-GUDTDXIP.js.map +0 -7
  125. package/pb_public/assets/app-3WX5JYL2.js +0 -3
  126. package/pb_public/assets/app-3WX5JYL2.js.map +0 -7
  127. package/pb_public/assets/app-WAFKVN2H.css +0 -2
  128. package/pb_public/assets/app-WAFKVN2H.css.map +0 -7
  129. package/pb_public/assets/emoji-picker-65VVVGYW.js.map +0 -7
  130. package/pb_public/assets/forward-66PELNWT.js +0 -2
  131. package/pb_public/assets/forward-66PELNWT.js.map +0 -7
  132. package/pb_public/assets/inbox-TZJWPRTG.js +0 -2
  133. package/pb_public/assets/inbox-TZJWPRTG.js.map +0 -7
  134. package/pb_public/assets/lazy-4CXRBHHM.js +0 -2
  135. package/pb_public/assets/lazy-4CXRBHHM.js.map +0 -7
  136. package/pb_public/assets/login-G7Y44CJ7.js +0 -2
  137. package/pb_public/assets/login-G7Y44CJ7.js.map +0 -7
  138. package/pb_public/assets/media-FPRU2QH5.js +0 -2
  139. package/pb_public/assets/media-FPRU2QH5.js.map +0 -7
  140. package/pb_public/assets/mention-suggest-R7MXUH6R.js +0 -2
  141. package/pb_public/assets/mention-suggest-R7MXUH6R.js.map +0 -7
  142. package/pb_public/assets/notify-RQ6ZLR46.js +0 -2
  143. package/pb_public/assets/notify-RQ6ZLR46.js.map +0 -7
  144. package/pb_public/assets/profile-2CNVT2KX.js +0 -2
  145. package/pb_public/assets/profile-2CNVT2KX.js.map +0 -7
  146. package/pb_public/assets/search-3UT4HMES.js +0 -2
  147. package/pb_public/assets/search-3UT4HMES.js.map +0 -7
  148. package/pb_public/assets/stats-JX52AQCO.js +0 -2
  149. package/pb_public/assets/stats-JX52AQCO.js.map +0 -7
  150. package/pb_public/assets/switcher-CEUKRLEY.js +0 -2
  151. package/pb_public/assets/switcher-CEUKRLEY.js.map +0 -7
  152. package/pb_public/assets/user-search-7GNEIXMN.js +0 -2
  153. package/pb_public/assets/user-search-7GNEIXMN.js.map +0 -7
  154. package/pb_public/assets/viewer-DXT7SKOU.js +0 -2
  155. package/pb_public/assets/viewer-DXT7SKOU.js.map +0 -7
  156. package/scripts/fetch-pocketbase.sh +0 -63
@@ -0,0 +1,38 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Forgot password (DESIGN.md §39): PocketBase's own reset, with the email's link opening the app's page
3
+ // (/reset-password/{TOKEN}, web/src/views/reset.ts) instead of the admin dashboard's. A template an admin already
4
+ // changed keeps its own link. Asking for emails is limited per IP, beyond PocketBase's one email per address every
5
+ // two minutes.
6
+
7
+ const DASHBOARD_LINK = "{APP_URL}/_/#/auth/confirm-password-reset/{TOKEN}";
8
+ const APP_LINK = "{APP_URL}/reset-password/{TOKEN}";
9
+ const RESET_LIMIT = { label: "users:requestPasswordReset", audience: "", duration: 600, maxRequests: 5 };
10
+
11
+ /**
12
+ * @param {Parameters<Parameters<typeof migrate>[0]>[0]} app
13
+ * @param {string} from
14
+ * @param {string} to
15
+ */
16
+ function relink(app, from, to) {
17
+ const users = app.findCollectionByNameOrId("users");
18
+ const body = users.resetPasswordTemplate.body;
19
+ if (!body.includes(from)) return;
20
+ users.resetPasswordTemplate.body = body.split(from).join(to);
21
+ app.save(users);
22
+ }
23
+
24
+ migrate(
25
+ (app) => {
26
+ relink(app, DASHBOARD_LINK, APP_LINK);
27
+ const settings = app.settings();
28
+ const rest = settings.rateLimits.rules.filter((r) => r.label !== RESET_LIMIT.label);
29
+ settings.rateLimits.rules = [/** @type {any} */ (RESET_LIMIT), ...rest];
30
+ app.save(settings);
31
+ },
32
+ (app) => {
33
+ relink(app, APP_LINK, DASHBOARD_LINK);
34
+ const settings = app.settings();
35
+ settings.rateLimits.rules = settings.rateLimits.rules.filter((r) => r.label !== RESET_LIMIT.label);
36
+ app.save(settings);
37
+ },
38
+ );
@@ -0,0 +1,51 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // QA BUG-257: a Telegram group that became a supergroup had its tg_messages moved to the new chat id, but the new group
3
+ // numbers its messages afresh. Its new messages then took the old ones' ids: what Telegram sent was dropped as brought
4
+ // over already, and what the room sent failed on the unique (chat_id, tg_message_id, part) after going out, so the
5
+ // worker sent it again, up to 8 times. The code no longer moves them (links.js moveLink); this drops the rows it moved.
6
+ //
7
+ // Which rows were moved isn't recorded, so only a chat with the evidence in the logs is repaired: a "telegram: send"
8
+ // that failed on that unique index. Its rows from before the move go: from before the link was last saved (the move
9
+ // saves it) or the first such failure, whichever came first. They stood for the old group's messages, which can't be
10
+ // edited or deleted any more, so nothing that works is lost.
11
+
12
+ migrate(
13
+ (app) => {
14
+ /** @type {{ chat: string, first: string }[]} */
15
+ let chats = [];
16
+ try {
17
+ const rows = arrayOf(new DynamicModel({ chat: "", first: "" }));
18
+ app
19
+ .auxDB()
20
+ .newQuery(
21
+ `SELECT json_extract(data, '$.chat') AS chat, MIN(created) AS first FROM _logs
22
+ WHERE message = 'telegram: send' AND json_extract(data, '$.error') LIKE '%tg_message_id: Value must be unique%'
23
+ GROUP BY chat`,
24
+ )
25
+ .all(rows);
26
+ chats = rows.map((r) => ({ chat: String(r.chat || ""), first: String(r.first || "") })).filter((r) => r.chat && r.first);
27
+ } catch (err) {
28
+ app.logger().warn("migration 1760000047: no logs to read", "error", String(err));
29
+ return;
30
+ }
31
+ for (const { chat, first } of chats) {
32
+ let link;
33
+ try {
34
+ link = app.findFirstRecordByFilter("tg_links", "chat_id = {:chat}", { chat });
35
+ } catch {
36
+ continue;
37
+ }
38
+ const saved = link.getDateTime("updated").string();
39
+ const cutoff = saved && saved < first ? saved : first;
40
+ const res = app
41
+ .db()
42
+ .newQuery("DELETE FROM tg_messages WHERE chat_id = {:chat} AND created < {:cutoff}")
43
+ .bind({ chat, cutoff })
44
+ .execute();
45
+ app
46
+ .logger()
47
+ .info("migration 1760000047: stale Telegram mappings dropped", "chat", chat, "before", cutoff, "rows", res.rowsAffected());
48
+ }
49
+ },
50
+ () => {},
51
+ );
@@ -0,0 +1,24 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // One inbox row for all of someone's reactions to a message (2026-11-11, user: "make all reactions from one user to
3
+ // one message a single notification"): before, each emoji was a row. Keeps the newest row of each person's reactions to
4
+ // a message, with `emoji` "" (GET /api/chat/inbox names their emoji from the message, pb_hooks/lib/inbox.js).
5
+
6
+ migrate(
7
+ (app) => {
8
+ app
9
+ .db()
10
+ .newQuery(
11
+ `DELETE FROM inbox WHERE kind = 'reaction' AND id NOT IN (
12
+ SELECT id FROM (
13
+ SELECT id, ROW_NUMBER() OVER (PARTITION BY user, message, actor ORDER BY created DESC, id DESC) AS n
14
+ FROM inbox WHERE kind = 'reaction'
15
+ ) WHERE n = 1
16
+ )`,
17
+ )
18
+ .execute();
19
+ app.db().newQuery("UPDATE inbox SET emoji = '' WHERE kind = 'reaction'").execute();
20
+ },
21
+ () => {
22
+ // Nothing to undo: one row per emoji can't be told apart again, and one per person still works.
23
+ },
24
+ );
@@ -0,0 +1,22 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // The inbox's counts per room (REFACTOR item 49, server/unread.go inboxMentionsSQL): an index on (user, room, created),
3
+ // so each room's count starts at the caller's read position there instead of going through every row of theirs. The
4
+ // list (newest first, all rooms) keeps using idx_inbox_user_created.
5
+
6
+ const INBOX_ROOM_INDEX = "CREATE INDEX idx_inbox_user_room_created ON inbox (user, room, created)";
7
+
8
+ /**
9
+ * @param {Parameters<Parameters<typeof migrate>[0]>[0]} app
10
+ * @param {boolean} up
11
+ */
12
+ function apply(app, up) {
13
+ const inbox = app.findCollectionByNameOrId("inbox");
14
+ const indexes = /** @type {string[]} */ (/** @type {any} */ (inbox).indexes).filter((i) => i !== INBOX_ROOM_INDEX);
15
+ /** @type {any} */ (inbox).indexes = up ? [...indexes, INBOX_ROOM_INDEX] : indexes;
16
+ app.save(inbox);
17
+ }
18
+
19
+ migrate(
20
+ (app) => apply(app, true),
21
+ (app) => apply(app, false),
22
+ );
@@ -0,0 +1,22 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Unread counts read only an index (REFACTOR item 26, server/unread.go unreadSQL): other people's messages that aren't
3
+ // deleted, by room and time, with their author. Each room's count is then a range scan of this index from the
4
+ // caller's read position, never a read of the messages themselves. Pages keep idx_messages_room_created.
5
+
6
+ const UNREAD_INDEX = "CREATE INDEX idx_messages_unread ON messages (room, created, author) WHERE deleted = FALSE";
7
+
8
+ /**
9
+ * @param {Parameters<Parameters<typeof migrate>[0]>[0]} app
10
+ * @param {boolean} up
11
+ */
12
+ function apply(app, up) {
13
+ const messages = app.findCollectionByNameOrId("messages");
14
+ const indexes = /** @type {string[]} */ (/** @type {any} */ (messages).indexes).filter((i) => i !== UNREAD_INDEX);
15
+ /** @type {any} */ (messages).indexes = up ? [...indexes, UNREAD_INDEX] : indexes;
16
+ app.save(messages);
17
+ }
18
+
19
+ migrate(
20
+ (app) => apply(app, true),
21
+ (app) => apply(app, false),
22
+ );
@@ -0,0 +1,31 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // What kind of account a user is (REFACTOR item 50, DESIGN.md §5.1): `users.kind`, "person" (signs in here),
3
+ // "telegram" (a Telegram sender's stand-in, §26.3) or "peer" (a linked instance's person, §33.4). Set by the hooks that
4
+ // make the account (lib/users.js for people, the bridges for their stand-ins), never by a client; hidden from the API.
5
+ // Until now the hooks told them apart by the made-up e-mail's domain, by tg_people or by `peer`; the backfill uses all
6
+ // of those.
7
+
8
+ const C_NO_KIND = "@request.body.kind:isset = false";
9
+
10
+ const BACKFILL = `UPDATE users SET kind = CASE
11
+ WHEN id IN (SELECT user FROM tg_people) OR email LIKE '%@telegram.invalid' THEN 'telegram'
12
+ WHEN peer != '' OR email LIKE '%@federation.invalid' THEN 'peer'
13
+ ELSE 'person' END`;
14
+
15
+ migrate(
16
+ (app) => {
17
+ const users = app.findCollectionByNameOrId("users");
18
+ users.fields.add(new SelectField({ name: "kind", values: ["person", "telegram", "peer"], maxSelect: 1, hidden: true }));
19
+ users.createRule = `${users.createRule} && ${C_NO_KIND}`;
20
+ users.updateRule = `${users.updateRule} && ${C_NO_KIND}`;
21
+ app.save(users);
22
+ app.db().newQuery(BACKFILL).execute();
23
+ },
24
+ (app) => {
25
+ const users = app.findCollectionByNameOrId("users");
26
+ users.fields.removeByName("kind");
27
+ users.createRule = (users.createRule ?? "").replace(` && ${C_NO_KIND}`, "");
28
+ users.updateRule = (users.updateRule ?? "").replace(` && ${C_NO_KIND}`, "");
29
+ app.save(users);
30
+ },
31
+ );
@@ -0,0 +1,19 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Deleted accounts (DESIGN.md §43): `users.kind` gets "deleted", what an account is once its person deleted it
3
+ // (POST /api/chat/account/delete, pb_hooks/lib/account.js). The row stays, as "Deleted account", so that the messages
4
+ // and rooms naming it still have an author; nobody can sign in to it.
5
+
6
+ migrate(
7
+ (app) => {
8
+ const users = app.findCollectionByNameOrId("users");
9
+ const kind = /** @type {SelectField} */ (users.fields.getByName("kind"));
10
+ kind.values = ["person", "telegram", "peer", "deleted"];
11
+ app.save(users);
12
+ },
13
+ (app) => {
14
+ const users = app.findCollectionByNameOrId("users");
15
+ const kind = /** @type {SelectField} */ (users.fields.getByName("kind"));
16
+ kind.values = ["person", "telegram", "peer"];
17
+ app.save(users);
18
+ },
19
+ );
@@ -0,0 +1,45 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Account jobs (DESIGN.md §43.5): the work of "Your data" and "Delete account" that can be long on a big server, done
3
+ // by a worker (pb_hooks/lib/account.js) instead of in the request.
4
+ // - kind "export": a person's data, written a page at a time into `file` (a protected file, served only to them by
5
+ // GET /api/chat/export/file); kept 7 days.
6
+ // - kind "erase": a deleted account's collections, deleted a batch of items at a time, then with `messages` its
7
+ // messages, soft-deleted a batch at a time.
8
+ // No API rules: only the hooks read and write it.
9
+
10
+ const JOBS_ACCESS = { listRule: null, viewRule: null, createRule: null, updateRule: null, deleteRule: null };
11
+
12
+ migrate(
13
+ (app) => {
14
+ const users = app.findCollectionByNameOrId("users");
15
+ app.save(
16
+ new Collection(
17
+ /** @type {any} */ ({
18
+ type: "base",
19
+ name: "account_jobs",
20
+ ...JOBS_ACCESS,
21
+ fields: [
22
+ { type: "relation", name: "user", collectionId: users.id, cascadeDelete: true, maxSelect: 1, required: true },
23
+ { type: "select", name: "kind", values: ["export", "erase"], maxSelect: 1, required: true },
24
+ { type: "select", name: "state", values: ["queued", "done", "failed"], maxSelect: 1, required: true },
25
+ { type: "file", name: "file", maxSelect: 1, maxSize: 4 * 1024 * 1024 * 1024, protected: true },
26
+ { type: "number", name: "size", onlyInt: true, min: 0 },
27
+ { type: "bool", name: "messages" },
28
+ { type: "number", name: "tries", onlyInt: true, min: 0 },
29
+ { type: "text", name: "error", max: 500 },
30
+ { type: "date", name: "finished" },
31
+ { type: "autodate", name: "created", onCreate: true },
32
+ { type: "autodate", name: "updated", onCreate: true, onUpdate: true },
33
+ ],
34
+ indexes: [
35
+ "CREATE INDEX idx_account_jobs_state ON account_jobs (state, updated)",
36
+ "CREATE INDEX idx_account_jobs_user ON account_jobs (user, kind, created)",
37
+ ],
38
+ }),
39
+ ),
40
+ );
41
+ },
42
+ (app) => {
43
+ app.delete(app.findCollectionByNameOrId("account_jobs"));
44
+ },
45
+ );
@@ -0,0 +1,39 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Room invite links (DESIGN.md §44): a private room's link, which adds whoever opens it (signed in) to its members. One
3
+ // per room at a time: a new one replaces it, and revoking deletes it. `token` is the secret in the link
4
+ // (/invite/<token>); `expires` is when it stops working; `uses` counts the people it added.
5
+ // No API rules: only the routes (pb_hooks/lib/invites.js) read and write it.
6
+
7
+ const INVITES_ACCESS = { listRule: null, viewRule: null, createRule: null, updateRule: null, deleteRule: null };
8
+
9
+ migrate(
10
+ (app) => {
11
+ const rooms = app.findCollectionByNameOrId("rooms");
12
+ const users = app.findCollectionByNameOrId("users");
13
+ app.save(
14
+ new Collection(
15
+ /** @type {any} */ ({
16
+ type: "base",
17
+ name: "room_invites",
18
+ ...INVITES_ACCESS,
19
+ fields: [
20
+ { type: "relation", name: "room", collectionId: rooms.id, cascadeDelete: true, maxSelect: 1, required: true },
21
+ { type: "text", name: "token", min: 24, max: 24, required: true },
22
+ { type: "relation", name: "created_by", collectionId: users.id, cascadeDelete: false, maxSelect: 1 },
23
+ { type: "date", name: "expires", required: true },
24
+ { type: "number", name: "uses", onlyInt: true, min: 0 },
25
+ { type: "autodate", name: "created", onCreate: true },
26
+ ],
27
+ indexes: [
28
+ "CREATE UNIQUE INDEX idx_room_invites_room ON room_invites (room)",
29
+ "CREATE UNIQUE INDEX idx_room_invites_token ON room_invites (token)",
30
+ "CREATE INDEX idx_room_invites_expires ON room_invites (expires)",
31
+ ],
32
+ }),
33
+ ),
34
+ );
35
+ },
36
+ (app) => {
37
+ app.delete(app.findCollectionByNameOrId("room_invites"));
38
+ },
39
+ );
@@ -0,0 +1,16 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Room invite links (DESIGN.md §44.2, QA BUG-280): `room_invites.barred`, the people the room's managers took out of
3
+ // its members while the link worked. The link no longer lets them in; a new link (a new row) starts with nobody barred.
4
+
5
+ migrate(
6
+ (app) => {
7
+ const invites = app.findCollectionByNameOrId("room_invites");
8
+ invites.fields.add(new JSONField({ name: "barred", maxSize: 0 }));
9
+ app.save(invites);
10
+ },
11
+ (app) => {
12
+ const invites = app.findCollectionByNameOrId("room_invites");
13
+ invites.fields.removeByName("barred");
14
+ app.save(invites);
15
+ },
16
+ );
@@ -0,0 +1,21 @@
1
+ /// <reference path="../types/pocketbase.d.ts" />
2
+ // Telegram bridge (DESIGN.md §26.4): tg_queue's "fetch" op, Telegram messages whose files couldn't be downloaded for
3
+ // now (no answer from Telegram), which the worker brings over once they can be.
4
+
5
+ /**
6
+ * @param {MigrationApp} app
7
+ * @param {string[]} values
8
+ */
9
+ function setOps(app, values) {
10
+ const queue = app.findCollectionByNameOrId("tg_queue");
11
+ /** @type {any} */ (queue.fields.getByName("op")).values = values;
12
+ app.save(queue);
13
+ }
14
+
15
+ migrate(
16
+ (app) => setOps(app, ["send", "edit", "delete", "album", "react", "fetch"]),
17
+ (app) => {
18
+ app.db().newQuery("DELETE FROM tg_queue WHERE op = 'fetch'").execute();
19
+ setOps(app, ["send", "edit", "delete", "album", "react"]);
20
+ },
21
+ );
@@ -1,2 +1,2 @@
1
- dialog.access[open],.access-body{display:flex;flex-direction:column}.dialog-head{display:flex;gap:12px;align-items:center;padding:18px 16px 14px 24px;border-bottom:1px solid var(--border)}.dialog-head>div{flex:1;min-width:0}dialog.access h2{margin:0;font-size:1.125rem;letter-spacing:-.01em}.dialog-sub{margin:2px 0 0;color:var(--muted);font-size:.8125rem}.access-body{gap:22px;min-height:0;padding:18px 24px 22px;overflow-y:auto}dialog.access .dialog-actions{padding:14px 24px;border-top:1px solid var(--border);background:var(--bg)}dialog.access .cancel{border-color:transparent;background:none}.vis-choices{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;border:0}.vis-choices legend,dialog.access h3{margin:0;padding:0 0 8px;color:var(--text);font-size:.8125rem;font-weight:600}.vis-choice{display:flex;gap:14px;align-items:center;padding:12px 14px;border:1px solid var(--border);border-radius:12px;cursor:pointer}.vis-choice:has(input:checked){border-color:color-mix(in srgb,var(--accent) 60%,transparent);background:var(--tint)}.vis-choice input{appearance:none;flex:none;order:1;width:20px;height:20px;margin:0 0 0 auto;padding:0;border:2px solid color-mix(in srgb,var(--dim) 55%,transparent);border-radius:50%}.vis-choice input:checked{border-color:var(--accent);background:radial-gradient(var(--accent) 4.5px,transparent 5.5px)}.vis-icon{display:flex;flex:none;align-items:center;justify-content:center;width:38px;height:38px;border-radius:10px;background:var(--hover);color:var(--muted);font-size:1rem;font-weight:700}.vis-choice:has(:checked) .vis-icon{background:color-mix(in srgb,var(--fill) 22%,transparent);color:var(--fg)}.vis-text{display:flex;flex-direction:column;gap:2px}.vis-label{font-weight:600}.vis-hint{color:var(--muted);font-size:.8125rem;line-height:1.4}.members,.writers{display:flex;flex-direction:column;gap:6px}.people-head{display:flex;align-items:center;justify-content:space-between}dialog.access .people-head h3{padding:0}.add-member{gap:6px;height:32px;padding:0 10px;border:0;border-radius:8px;background:var(--tint);color:var(--accent);font-size:.8125rem}.add-member:before{width:14px;height:14px}.member-list{margin:0;padding:0;border:1px solid var(--border);border-radius:12px;list-style:none}.member-list:empty{display:none}.member{display:flex;gap:12px;align-items:center;height:52px;padding:0 8px 0 12px}.member+.member{border-top:1px solid var(--line)}.member .avatar{width:30px;height:30px;font-size:.6875rem}.member-name{flex:1;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.member-name span{color:var(--muted);font-weight:400}.member-role{padding:3px 8px;border-radius:6px;background:var(--hover);color:var(--muted);font-size:.75rem;font-weight:600}.remove-member{height:32px;padding:0 10px;border:0;background:none;color:var(--muted);font-size:.8125rem}.member .remove-member,.search-results [aria-pressed]:after{margin-left:auto}.search-results [aria-pressed=true]:after{content:"\2713 Added";flex:none;color:var(--muted);font-size:.8rem}.access-warning:empty,dialog.access .field-error:empty{display:none}.access-warning,.access-shared{margin:0;padding:.5rem .7rem;border-radius:var(--radius);background:var(--highlight);font-size:.85rem}.dialog-actions{display:flex;gap:.5rem;justify-content:flex-end}dialog.access{width:min(32.5rem,calc(100% - 2rem));max-height:min(52rem,calc(100dvh - 2rem));padding:0;overflow:hidden}
2
- /*# sourceMappingURL=access-PB77EH4F.css.map */
1
+ dialog.access[open],.access-body{display:flex;flex-direction:column}.dialog-head{display:flex;gap:12px;align-items:center;padding:18px 16px 14px 24px;border-bottom:1px solid var(--border)}.dialog-head>div{flex:1;min-width:0}dialog.access h2{margin:0;font-size:1.125rem;letter-spacing:-.01em}.dialog-sub{margin:2px 0 0;color:var(--muted);font-size:.8125rem}.access-body{gap:22px;min-height:0;padding:18px 24px 22px;overflow-y:auto}dialog.access .dialog-actions{padding:14px 24px;border-top:1px solid var(--border);background:var(--bg)}dialog.access .cancel{border-color:transparent;background:none}.vis-choices{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;border:0}.vis-choices legend,dialog.access h3{margin:0;padding:0 0 8px;color:var(--text);font-size:.8125rem;font-weight:600}.vis-choice{display:flex;gap:14px;align-items:center;padding:12px 14px;border:1px solid var(--border);border-radius:12px;cursor:pointer}.vis-choice:has(input:checked){border-color:color-mix(in srgb,var(--accent) 60%,transparent);background:var(--tint)}.vis-choice input{appearance:none;flex:none;order:1;width:20px;height:20px;margin:0 0 0 auto;padding:0;border:2px solid color-mix(in srgb,var(--dim) 55%,transparent);border-radius:50%}.vis-choice input:checked{border-color:var(--accent);background:radial-gradient(var(--accent) 4.5px,transparent 5.5px)}.vis-icon{display:flex;flex:none;align-items:center;justify-content:center;width:38px;height:38px;border-radius:10px;background:var(--hover);color:var(--muted);font-size:1rem;font-weight:700}.vis-choice:has(:checked) .vis-icon{background:color-mix(in srgb,var(--fill) 22%,transparent);color:var(--fg)}.vis-text{display:flex;flex-direction:column;gap:2px}.vis-label{font-weight:600}.vis-hint{color:var(--muted);font-size:.8125rem;line-height:1.4}.members,.writers{display:flex;flex-direction:column;gap:6px}.people-head{display:flex;align-items:center;justify-content:space-between}dialog.access .people-head h3{padding:0}.add-member{gap:6px;height:32px;padding:0 10px;border:0;border-radius:8px;background:var(--tint);color:var(--accent);font-size:.8125rem}.add-member:before{width:14px;height:14px}.member-list{margin:0;padding:0;border:1px solid var(--border);border-radius:12px;list-style:none}.member-list:empty{display:none}.member{display:flex;gap:12px;align-items:center;height:52px;padding:0 8px 0 12px}.member+.member{border-top:1px solid var(--line)}.member .avatar{width:30px;height:30px;font-size:.6875rem}.member-name{flex:1;min-width:0;overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.member-name span{color:var(--muted);font-weight:400}.member-role{padding:3px 8px;border-radius:6px;background:var(--hover);color:var(--muted);font-size:.75rem;font-weight:600}.remove-member{height:32px;padding:0 10px;border:0;background:none;color:var(--muted);font-size:.8125rem}.member .remove-member,.search-results [aria-pressed]:after{margin-left:auto}.search-results [aria-pressed=true]:after{content:"\2713 Added";flex:none;color:var(--muted);font-size:.8rem}.access-warning:empty,dialog.access .field-error:empty{display:none}.access-warning,.access-shared{margin:0;padding:.5rem .7rem;border-radius:var(--radius);background:var(--highlight);font-size:.85rem}.dialog-actions{display:flex;gap:.5rem;justify-content:flex-end}dialog.access{width:min(32.5rem,calc(100% - 2rem));max-height:min(52rem,calc(100dvh - 2rem));padding:0;overflow:hidden}.invite{display:flex;flex-direction:column;gap:8px}dialog.access .invite h3{padding:0}.invite-row,.invite-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.invite-url{flex:1;min-width:0;padding:.45rem .6rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);font-size:.8125rem}.invite-days{display:flex;gap:6px;align-items:center;margin-right:auto;color:var(--muted);font-size:.8125rem}.invite-meta,.invite-status{margin:0;color:var(--muted);font-size:.8125rem}.invite-status:empty{display:none}
2
+ /*# sourceMappingURL=access-GPRLOZOO.css.map */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../web/styles/access.css"],
4
- "sourcesContent": ["/* The room access dialog (DESIGN.md \u00A723.2). Not part of app.css: the dialog's chunk links this file when it first\n opens. Uses app.css's custom properties; the dialog's card, shared with the forward dialog, is in app.css. */\n\ndialog.access[open],\n.access-body {\n display: flex;\n flex-direction: column;\n}\n\n/* The title, the room under it and \u00D7; a line under them and over the buttons. Only the body between scrolls, so the\n buttons stay in view however long the lists get. */\n.dialog-head {\n display: flex;\n gap: 12px;\n align-items: center;\n padding: 18px 16px 14px 24px;\n border-bottom: 1px solid var(--border);\n}\n\n.dialog-head > div {\n flex: 1;\n min-width: 0;\n}\n\ndialog.access h2 {\n margin: 0;\n font-size: 1.125rem;\n letter-spacing: -0.01em;\n}\n\n.dialog-sub {\n margin: 2px 0 0;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.access-body {\n gap: 22px;\n min-height: 0;\n padding: 18px 24px 22px;\n overflow-y: auto;\n}\n\ndialog.access .dialog-actions {\n padding: 14px 24px;\n border-top: 1px solid var(--border);\n background: var(--bg);\n}\n\ndialog.access .cancel {\n border-color: transparent;\n background: none;\n}\n\n.vis-choices {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n.vis-choices legend,\ndialog.access h3 {\n margin: 0;\n padding: 0 0 8px;\n color: var(--text);\n font-size: 0.8125rem;\n font-weight: 600;\n}\n\n/* A choice: an icon tile, its name and what it means, and a radio ring on the right. */\n.vis-choice {\n display: flex;\n gap: 14px;\n align-items: center;\n padding: 12px 14px;\n border: 1px solid var(--border);\n border-radius: 12px;\n cursor: pointer;\n}\n\n.vis-choice:has(input:checked) {\n border-color: color-mix(in srgb, var(--accent) 60%, transparent);\n background: var(--tint);\n}\n\n.vis-choice input {\n appearance: none;\n flex: none;\n order: 1;\n width: 20px;\n height: 20px;\n margin: 0 0 0 auto;\n padding: 0;\n border: 2px solid color-mix(in srgb, var(--dim) 55%, transparent);\n border-radius: 50%;\n}\n\n.vis-choice input:checked {\n border-color: var(--accent);\n background: radial-gradient(var(--accent) 4.5px, transparent 5.5px);\n}\n\n.vis-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 38px;\n height: 38px;\n border-radius: 10px;\n background: var(--hover);\n color: var(--muted);\n font-size: 1rem;\n font-weight: 700;\n}\n\n.vis-choice:has(:checked) .vis-icon {\n background: color-mix(in srgb, var(--fill) 22%, transparent);\n color: var(--fg);\n}\n\n.vis-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.vis-label {\n font-weight: 600;\n}\n\n.vis-hint {\n color: var(--muted);\n font-size: 0.8125rem;\n line-height: 1.4;\n}\n\n.members,\n.writers {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/* \"Members \u00B7 3\" and Add people. */\n.people-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\ndialog.access .people-head h3 {\n padding: 0;\n}\n\n.add-member {\n gap: 6px;\n height: 32px;\n padding: 0 10px;\n border: 0;\n border-radius: 8px;\n background: var(--tint);\n color: var(--accent);\n font-size: 0.8125rem;\n}\n\n.add-member::before {\n width: 14px;\n height: 14px;\n}\n\n/* The people: rows of a card, a line between them. */\n.member-list {\n margin: 0;\n padding: 0;\n border: 1px solid var(--border);\n border-radius: 12px;\n list-style: none;\n}\n\n.member-list:empty {\n display: none;\n}\n\n.member {\n display: flex;\n gap: 12px;\n align-items: center;\n height: 52px;\n padding: 0 8px 0 12px;\n}\n\n.member + .member {\n border-top: 1px solid var(--line);\n}\n\n.member .avatar {\n width: 30px;\n height: 30px;\n font-size: 0.6875rem;\n}\n\n.member-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n font-weight: 500;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.member-name span {\n color: var(--muted);\n font-weight: 400;\n}\n\n.member-role {\n padding: 3px 8px;\n border-radius: 6px;\n background: var(--hover);\n color: var(--muted);\n font-size: 0.75rem;\n font-weight: 600;\n}\n\n.remove-member {\n height: 32px;\n padding: 0 10px;\n border: 0;\n background: none;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.member .remove-member,\n.search-results [aria-pressed]::after {\n margin-left: auto;\n}\n\n.search-results [aria-pressed=\"true\"]::after {\n content: \"\u2713 Added\";\n flex: none;\n color: var(--muted);\n font-size: 0.8rem;\n}\n\n.access-warning:empty,\ndialog.access .field-error:empty {\n display: none;\n}\n\n/* A change of visibility's warning, and where else a shared room's messages are kept (\u00A733.9). */\n.access-warning,\n.access-shared {\n margin: 0;\n padding: 0.5rem 0.7rem;\n border-radius: var(--radius);\n background: var(--highlight);\n font-size: 0.85rem;\n}\n\n.dialog-actions {\n display: flex;\n gap: 0.5rem;\n justify-content: flex-end;\n}\n\ndialog.access {\n width: min(32.5rem, calc(100% - 2rem));\n max-height: min(52rem, calc(100dvh - 2rem));\n padding: 0;\n overflow: hidden;\n}\n"],
5
- "mappings": "AAGA,MAAM,CAAC,MAAM,CAAC,MACd,CAAC,YACC,QAAS,KACT,eAAgB,MAClB,CAIA,CAAC,YACC,QAAS,KACT,IAAK,KACL,YAAa,OAdf,QAeW,KAAK,KAAK,KAAK,KACxB,cAAe,IAAI,MAAM,IAAI,SAC/B,CAEA,CARC,WAQY,CAAE,IACb,KAAM,EACN,UAAW,CACb,CAEA,MAAM,CArBC,OAqBO,GAxBd,OAyBU,EACR,UAAW,SACX,eAA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X,YAAa,GACf,CAEA,CAAC,cACC,OAAQ,KArOV,QAsOW,EAAE,KACX,OAAQ,EACR,WAAY,KACZ,MAAO,IAAI,SACX,UAAW,QACb,CAEA,CAlDC,OAkDO,CATP,cAUD,CAAC,eAAe,CAAC,aAAa,OAC5B,YAAa,IACf,CAEA,CAJC,eAIe,CAAC,kBAAoB,OACnC,QAAS,eACT,KAAM,KACN,MAAO,IAAI,SACX,UAAW,KACb,CAEA,CAAC,cAAc,OACf,MAAM,CAvPC,OAuPO,CAAC,WAAW,OACxB,QAAS,IACX,CAGA,CANC,eAOD,CAAC,cAhQD,OAiQU,EAjQV,QAkQW,MAAO,MAChB,cAAe,IAAI,UACnB,WAAY,IAAI,aAChB,UAAW,MACb,CAEA,CA7Ne,eA8Nb,QAAS,KACT,IAAK,MACL,gBAAiB,QACnB,CAEA,MAAM,CA3QC,OA4QL,MAAO,IAAI,OAAO,CAAE,KAAK,KAAK,EAAE,OAChC,WAAY,IAAI,KAAK,CAAE,KAAK,OAAO,EAAE,OAhRvC,QAiRW,EACT,SAAU,MACZ",
4
+ "sourcesContent": ["/* The room access dialog (DESIGN.md \u00A723.2). Not part of app.css: the dialog's chunk links this file when it first\n opens. Uses app.css's custom properties; the dialog's card, shared with the forward dialog, is in app.css. */\n\ndialog.access[open],\n.access-body {\n display: flex;\n flex-direction: column;\n}\n\n/* The title, the room under it and \u00D7; a line under them and over the buttons. Only the body between scrolls, so the\n buttons stay in view however long the lists get. */\n.dialog-head {\n display: flex;\n gap: 12px;\n align-items: center;\n padding: 18px 16px 14px 24px;\n border-bottom: 1px solid var(--border);\n}\n\n.dialog-head > div {\n flex: 1;\n min-width: 0;\n}\n\ndialog.access h2 {\n margin: 0;\n font-size: 1.125rem;\n letter-spacing: -0.01em;\n}\n\n.dialog-sub {\n margin: 2px 0 0;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.access-body {\n gap: 22px;\n min-height: 0;\n padding: 18px 24px 22px;\n overflow-y: auto;\n}\n\ndialog.access .dialog-actions {\n padding: 14px 24px;\n border-top: 1px solid var(--border);\n background: var(--bg);\n}\n\ndialog.access .cancel {\n border-color: transparent;\n background: none;\n}\n\n.vis-choices {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n.vis-choices legend,\ndialog.access h3 {\n margin: 0;\n padding: 0 0 8px;\n color: var(--text);\n font-size: 0.8125rem;\n font-weight: 600;\n}\n\n/* A choice: an icon tile, its name and what it means, and a radio ring on the right. */\n.vis-choice {\n display: flex;\n gap: 14px;\n align-items: center;\n padding: 12px 14px;\n border: 1px solid var(--border);\n border-radius: 12px;\n cursor: pointer;\n}\n\n.vis-choice:has(input:checked) {\n border-color: color-mix(in srgb, var(--accent) 60%, transparent);\n background: var(--tint);\n}\n\n.vis-choice input {\n appearance: none;\n flex: none;\n order: 1;\n width: 20px;\n height: 20px;\n margin: 0 0 0 auto;\n padding: 0;\n border: 2px solid color-mix(in srgb, var(--dim) 55%, transparent);\n border-radius: 50%;\n}\n\n.vis-choice input:checked {\n border-color: var(--accent);\n background: radial-gradient(var(--accent) 4.5px, transparent 5.5px);\n}\n\n.vis-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 38px;\n height: 38px;\n border-radius: 10px;\n background: var(--hover);\n color: var(--muted);\n font-size: 1rem;\n font-weight: 700;\n}\n\n.vis-choice:has(:checked) .vis-icon {\n background: color-mix(in srgb, var(--fill) 22%, transparent);\n color: var(--fg);\n}\n\n.vis-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.vis-label {\n font-weight: 600;\n}\n\n.vis-hint {\n color: var(--muted);\n font-size: 0.8125rem;\n line-height: 1.4;\n}\n\n.members,\n.writers {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/* \"Members \u00B7 3\" and Add people. */\n.people-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\ndialog.access .people-head h3 {\n padding: 0;\n}\n\n.add-member {\n gap: 6px;\n height: 32px;\n padding: 0 10px;\n border: 0;\n border-radius: 8px;\n background: var(--tint);\n color: var(--accent);\n font-size: 0.8125rem;\n}\n\n.add-member::before {\n width: 14px;\n height: 14px;\n}\n\n/* The people: rows of a card, a line between them. */\n.member-list {\n margin: 0;\n padding: 0;\n border: 1px solid var(--border);\n border-radius: 12px;\n list-style: none;\n}\n\n.member-list:empty {\n display: none;\n}\n\n.member {\n display: flex;\n gap: 12px;\n align-items: center;\n height: 52px;\n padding: 0 8px 0 12px;\n}\n\n.member + .member {\n border-top: 1px solid var(--line);\n}\n\n.member .avatar {\n width: 30px;\n height: 30px;\n font-size: 0.6875rem;\n}\n\n.member-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n font-weight: 500;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.member-name span {\n color: var(--muted);\n font-weight: 400;\n}\n\n.member-role {\n padding: 3px 8px;\n border-radius: 6px;\n background: var(--hover);\n color: var(--muted);\n font-size: 0.75rem;\n font-weight: 600;\n}\n\n.remove-member {\n height: 32px;\n padding: 0 10px;\n border: 0;\n background: none;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.member .remove-member,\n.search-results [aria-pressed]::after {\n margin-left: auto;\n}\n\n.search-results [aria-pressed=\"true\"]::after {\n content: \"\u2713 Added\";\n flex: none;\n color: var(--muted);\n font-size: 0.8rem;\n}\n\n.access-warning:empty,\ndialog.access .field-error:empty {\n display: none;\n}\n\n/* A change of visibility's warning, and where else a shared room's messages are kept (\u00A733.9). */\n.access-warning,\n.access-shared {\n margin: 0;\n padding: 0.5rem 0.7rem;\n border-radius: var(--radius);\n background: var(--highlight);\n font-size: 0.85rem;\n}\n\n.dialog-actions {\n display: flex;\n gap: 0.5rem;\n justify-content: flex-end;\n}\n\ndialog.access {\n width: min(32.5rem, calc(100% - 2rem));\n max-height: min(52rem, calc(100dvh - 2rem));\n padding: 0;\n overflow: hidden;\n}\n\n/* The invite link (\u00A744): the link and Copy on one line, what it does under them. */\n.invite {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\ndialog.access .invite h3 {\n padding: 0;\n}\n\n.invite-row,\n.invite-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n align-items: center;\n}\n\n.invite-url {\n flex: 1;\n min-width: 0;\n padding: 0.45rem 0.6rem;\n border: 1px solid var(--border);\n border-radius: var(--radius);\n background: var(--bg);\n font-size: 0.8125rem;\n}\n\n.invite-days {\n display: flex;\n gap: 6px;\n align-items: center;\n margin-right: auto;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.invite-meta,\n.invite-status {\n margin: 0;\n color: var(--muted);\n font-size: 0.8125rem;\n}\n\n.invite-status:empty {\n display: none;\n}\n"],
5
+ "mappings": "AAGA,MAAM,CAAC,MAAM,CAAC,MACd,CAAC,YACC,QAAS,KACT,eAAgB,MAClB,CAIA,CAAC,YACC,QAAS,KACT,IAAK,KACL,YAAa,OAdf,QAeW,KAAK,KAAK,KAAK,KACxB,cAAe,IAAI,MAAM,IAAI,SAC/B,CAEA,CARC,WAQY,CAAE,IACb,KAAM,EACN,UAAW,CACb,CAEA,MAAM,CArBC,OAqBO,GAxBd,OAyBU,EACR,UAAW,SACX,eAAgB,MAClB,CAEA,CAAC,WA9BD,OA+BU,IAAI,EAAE,EACd,MAAO,IAAI,SACX,UAAW,QACb,CAEA,CAhCC,YAiCC,IAAK,KACL,WAAY,EAtCd,QAuCW,KAAK,KAAK,KACnB,WAAY,IACd,CAEA,MAAM,CAxCC,OAwCO,CAAC,eA3Cf,QA4CW,KAAK,KACd,WAAY,IAAI,MAAM,IAAI,UAC1B,WAAY,IAAI,KAClB,CAEA,MAAM,CA9CC,OA8CO,CAAC,OACb,aAAc,YACd,WAAY,IACd,CAEA,CAAC,YACC,QAAS,KACT,eAAgB,OAChB,IAAK,IAzDP,OA0DU,EA1DV,QA2DW,EACT,OAAQ,CACV,CAEA,CATC,YASY,OACb,MAAM,CA7DC,OA6DO,GAhEd,OAiEU,EA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,QAAS,KACT,IAAK,MACL,gBAAiB,QACnB,CAEA,MAAM,CA3QC,OA4QL,MAAO,IAAI,OAAO,CAAE,KAAK,KAAK,EAAE,OAChC,WAAY,IAAI,KAAK,CAAE,KAAK,OAAO,EAAE,OAhRvC,QAiRW,EACT,SAAU,MACZ,CAGA,CAAC,OACC,QAAS,KACT,eAAgB,OAChB,IAAK,GACP,CAEA,MAAM,CAzRC,OAyRO,CANb,OAMqB,GA5RtB,QA6RW,CACX,CAEA,CAAC,WACD,CAAC,eACC,QAAS,KACT,UAAW,KACX,IAAK,IACL,YAAa,MACf,CAEA,CAAC,WACC,KAAM,EACN,UAAW,EA1Sb,QA2SW,OAAQ,MACjB,OAAQ,IAAI,MAAM,IAAI,UACtB,cAAe,IAAI,UACnB,WAAY,IAAI,MAChB,UAAW,QACb,CAEA,CAAC,YACC,QAAS,KACT,IAAK,IACL,YAAa,OACb,aAAc,KACd,MAAO,IAAI,SACX,UAAW,QACb,CAEA,CAAC,YACD,CAAC,cA5TD,OA6TU,EACR,MAAO,IAAI,SACX,UAAW,QACb,CAEA,CANC,aAMa,OACZ,QAAS,IACX",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{b as Ce,c as xe}from"./chunk-56ACD3V5.js";import{a as Ee}from"./chunk-UZDXAORM.js";import{l as Z,m as ue,o as ve,s as fe}from"./chunk-N2OFGBCZ.js";import{c as F,d as me,g as be,i as ye}from"./chunk-DZC4SY4M.js";import{a as ge}from"./chunk-RPCBA7VF.js";import{a as he}from"./chunk-DCLJRQ53.js";import{a as t,b as pe}from"./chunk-VTOUI25E.js";var we=i=>`Only ${i?"you and the people you add":"its creator and the people added"} will see this room. Everyone else loses it from their list.`;var ee=(i,s)=>`A room can have up to ${i} ${s?"members":"people who post"}.`,_e=(i,s)=>`Shared with ${i.join(", ")}: its messages are kept there too.${s?` Add people there by their address, like ann@${i[0]}.`:""}`;var ke=i=>i===1?"1 day":`${i} days`;var Se=(i,s)=>`Works until ${i} \xB7 ${s===0?"nobody has joined by it yet":s===1?"1 person joined by it":`${s} people joined by it`}`;var te=null;function He(i){return te??=new Promise(s=>{let x=i("link",{rel:"stylesheet",href:"/assets/access-GPRLOZOO.css",on:{load:()=>s(),error:()=>{x.remove(),te=null,s()}}});document.head.append(x)}),te}var Ve=["private","public","open"],Ae={private:"ic i-lock",open:"ic i-globe",everyone:"ic i-users",selected:"ic i-check"},Ye={everyone:{label:"Everyone who can see it",icon:"",hint:"Guests of an Open Air room only read."},selected:{label:"Only people you choose",icon:"",hint:"Everyone else reads and reacts, but can't post."}};function Ke(i,s,S){return i===s?"":s==="open"?"Everything ever written here, and everything to come, becomes readable by anyone on the web.":i==="private"?"Everyone with an account will be able to read the whole history.":s==="private"?we(S):"People without an account won't see this room any more."}function Xe(i){let{signal:s}=i,S=Ee.roomMembers,x=pe("access"),j=t("h2",{id:`${x}-title`}),ne=t("p",{class:"dialog-sub"});function oe(e,n,o){let c=t("legend",{}),h=new Map;return{el:t("fieldset",{class:"vis-choices"},[c,...e.map(a=>{let f=t("input",{type:"radio",name:`${x}-${e[0]}`,value:a,"aria-labelledby":`${x}-${a}-label`,"aria-describedby":`${x}-${a}-hint`,on:{change:()=>o(a)},signal:s});return h.set(a,f),t("label",{class:`vis-choice vis-${a}`},[f,t("span",{class:`vis-icon ${Ae[a]??""}`,"aria-hidden":"true"},Ae[a]?"":n[a].icon),t("span",{class:"vis-text"},[t("span",{id:`${x}-${a}-label`,class:"vis-label"},n[a].label),t("span",{id:`${x}-${a}-hint`,class:"vis-hint"},n[a].hint)])])})]),legend:c,radios:h}}let N=oe(Ve,be,e=>{C=e,ae()});N.legend.textContent="Who can see it";let D=oe(["everyone","selected"],Ye,e=>{P=e,ae()});D.legend.textContent="Who can post";function se(e,n,o){let c=t("h3",{}),h=t("ul",{class:"member-list","aria-label":e}),l=t("button",{type:"button",class:"add-member ic i-plus",on:{click:()=>O(g)},signal:s},"Add people"),a=t("div",{class:"member-search"}),f=t("section",{class:n},[t("div",{class:"people-head"},[c,l]),a,h]),g={el:f,addBtn:l,slot:a,pickable:o,list:[],render(){let T=f.hidden?[]:g.list.filter(re);c.textContent=`${e} \xB7 ${T.length}`;let E=g.list.length>=S;l.hidden=!b||_?.p===g,l.disabled=E,l.title=E?ee(S,g===m):"",h.replaceChildren(...T.map(y=>{let L=y.id===r?.created_by;return t("li",{class:"member",dataset:{userId:y.id}},[ge(y,32,i.avatarUrl),t("span",{class:"member-name"},[y.name,y.id===V?t("span",{}," (you)"):null]),L?t("span",{class:"member-role"},"Creator"):null,y.instance?t("span",{class:"member-role"},y.instance):null,b&&!L?t("button",{type:"button",class:"remove-member","aria-label":`Remove ${y.name}`,on:{click:()=>Re(g,y.id)},signal:s},"Remove"):null])}))}};return g}let m=se("Members","members",()=>!0),v=se("Who can post","writers",e=>C!=="private"||Y(m,e)),G=Ne(),ie=t("p",{class:"access-warning",role:"status"}),q=t("p",{class:"access-shared"}),A=t("p",{class:"field-error",role:"alert"}),R=t("button",{type:"button",class:"cancel",on:{click:()=>U()},signal:s},"Cancel"),H=t("button",{type:"button",class:"primary save",on:{click:()=>{Ue()}},signal:s},"Save"),Ie=t("div",{class:"dialog-actions"},[R,H]),J=t("button",{type:"button",class:"icon-button ic i-x",tabindex:"-1","aria-hidden":"true",on:{click:()=>U()},signal:s}),Oe=t("div",{class:"dialog-head"},[t("div",{},[j,ne]),J]),Te=t("div",{class:"access-body"},[q,N.el,m.el,G.el,D.el,v.el,ie,A]),w=t("dialog",{class:"access","aria-labelledby":j.id},[Oe,Te,Ie]),r=null,V,b=!1,C="public",P="everyone",Y=(e,n)=>e.list.some(o=>o.id===n.id),re=e=>!e.no_dms||!!e.instance,le=()=>r?.shared?.with??[],_=null,K=!1;function Ne(){let e=t("h3",{},"Invite link"),n=t("p",{class:"vis-hint"},"Anyone with the link who has an account here can join as a member."),o=t("input",{type:"text",readOnly:!0,class:"invite-url","aria-label":"Invite link",on:{focus:()=>o.select()},signal:s}),c=t("p",{class:"invite-meta"}),h=t("select",{signal:s},he.map(d=>t("option",{value:String(d),selected:d===7},ke(d)))),l=(d,u,k="")=>t("button",{type:"button",class:k,on:{click:u},signal:s},d),a=l("Copy link",()=>{We()},"primary"),f=l("Create link",()=>{X(d=>d.make(r.id,Number(h.value)))},"primary"),g=l("New link",()=>{X(d=>d.make(r.id,Number(h.value)))}),T=l("Revoke",()=>{X(async d=>(await d.revoke(r.id),null))}),E=t("p",{class:"invite-status",role:"status"}),y=t("div",{class:"invite-shown"},[t("div",{class:"invite-row"},[o,a]),c]),L=t("label",{class:"invite-days"},["Works for",h]),Le=t("div",{class:"invite-actions"},[L,f,g,T]),z=t("section",{class:"invite"},[e,n,y,Le,E]),p,$=null,Q=null,W=!1,de=()=>(Q??=i.invites().catch(d=>{throw Q=null,d}),Q),$e=()=>!!r&&!!i.invites&&b&&C==="private"&&F(r)==="private"&&!r.shared?.home;async function X(d){if(W||!r)return;let u=r,k=!!p;W=!0,E.textContent="",M();try{let B=await d(await de());if(s.aborted||r!==u)return;p=B,E.textContent=B?k?"A new link is ready. The old one no longer works.":"The link is ready to share.":"The link no longer works."}catch(B){r===u&&(E.textContent=`Couldn't change the link: ${Z(B)}`)}finally{W=!1,M()}}async function We(){o.select();try{await navigator.clipboard.writeText(o.value),E.textContent="Copied."}catch{E.textContent="Press Ctrl+C to copy it."}}function Me(){let d=r;if(!d)return;$=new AbortController;let u=$;s.addEventListener("abort",()=>u.abort(),{once:!0}),de().then(k=>k.get(d.id,u.signal)).then(k=>{u.signal.aborted||r!==d||(p=k,M())},k=>{u.signal.aborted||r!==d||(p=null,E.textContent=`Couldn't load the invite link: ${Z(k)}`,M())})}function M(){if(z.hidden=!$e(),z.hidden)return;p===void 0&&!$&&Me();let d=!!p,u=!!r?.archived;n.textContent=u?"The room is archived: its link doesn't work until the room is unarchived.":"Anyone with the link who has an account here can join as a member.",y.hidden=!d||u,L.hidden=u,f.hidden=d||u,g.hidden=!d||u,T.hidden=!d,f.disabled=g.disabled=T.disabled=W||p===void 0,p&&(o.value=i.inviteUrl?i.inviteUrl(p.token):p.token,c.textContent=Se(fe(ve(p.expires)),p.uses))}return{el:z,render:M,reset(){$?.abort(),$=null,p=void 0,W=!1,E.textContent=""}}}function ae(){A.textContent="",C==="private"&&(v.list=v.list.filter(e=>Y(m,e))),I()}function I(){if(!r)return;for(let[n,o]of N.radios)o.checked=n===C;for(let[n,o]of D.radios)o.checked=n===P;N.el.hidden=D.el.hidden=!b,m.el.hidden=C!=="private",v.el.hidden=P!=="selected",m.render(),v.render(),G.render(),ie.textContent=b?Ke(F(r),C,r.created_by===V):"";let e=le();q.hidden=!e.length,q.textContent=e.length?r.shared?.home?`This room's home is ${r.shared.home}: who is in it is decided there.`:_e(e,b):"",H.hidden=!b,R.textContent=b?"Cancel":"Close"}function Re(e,n){let o=e.el.querySelector("ul"),c=[...o.children].findIndex(l=>l.dataset.userId===n);e.list=e.list.filter(l=>l.id!==n),e===m&&(v.list=v.list.filter(l=>l.id!==n)),I();let h=[...o.querySelectorAll("button.remove-member")];(h[Math.min(c-1,h.length-1)]??e.addBtn).focus()}function Pe(e,n){if(Y(e,n))e.list=e.list.filter(o=>o.id!==n.id),e===m&&(v.list=v.list.filter(o=>o.id!==n.id));else if(e.list.length>=S){A.textContent=ee(S,e===m);return}else e.list=[...e.list,n];A.textContent="",I(),_?.ui.mark()}function O(e){if(e!==(_?.p??null))if(_?.ac.abort(),_?.p.slot.replaceChildren(),_=null,e){let n=new AbortController;s.addEventListener("abort",()=>n.abort(),{once:!0});let o=xe({search:async(c,h)=>{if(!ye(c)||!r||!le().length||!i.remoteUser)return(await i.searchUsers(c,h)).filter(l=>re(l)&&e.pickable(l));try{let l=await i.remoteUser(c,r.id);return e.pickable(l)?[l]:[]}catch(l){throw new Ce(ue(l))}},avatarUrl:i.avatarUrl,onPick:c=>Pe(e,c),isPicked:c=>Y(e,c),label:e===m?"Find someone to add as a member":"Find someone who can post",onClose:()=>{O(null),e.addBtn.focus()},signal:n.signal});_={ac:n,ui:o,p:e},e.slot.replaceChildren(o.el),I(),o.focus(),e.el.firstElementChild?.scrollIntoView?.({block:"start"})}else I()}async function Ue(){if(K||!r||!b)return;K=!0,H.disabled=R.disabled=J.disabled=!0,A.textContent="";let e=o=>o.list.map(c=>c.id),n=await i.onSave(C,e(m),P,e(v));if(K=!1,H.disabled=R.disabled=J.disabled=!1,!s.aborted){if(n===null)return U();A.textContent=n,w.open||w.showModal()}}function U(){O(null),w.open&&w.close()}w.addEventListener("cancel",e=>{if(K)e.preventDefault();else if(_){e.preventDefault();let n=_.p;O(null),n.addBtn.focus()}},{signal:s}),w.addEventListener("close",()=>O(null),{signal:s}),s.addEventListener("abort",U,{once:!0});function ce(e,n,o,c){let h=new Map([...e.expand?.members??[],...o??[]].map(a=>[a.id,a]));return c&&!h.has(c.id)&&h.set(c.id,c),[...new Set(n.length?n:[e.created_by,V||e.created_by])].map(a=>h.get(a)??{id:a,name:"Unknown"}).sort((a,f)=>+(f.id===e.created_by)-+(a.id===e.created_by))}return{el:w,open(e,n,o){r=e,V=o?.id,b=n,C=F(e),P=me(e),m.list=ce(e,e.members??[],void 0,o),v.list=ce(e,e.writers??[],e.expand?.writers,o),j.textContent=b?"Room access":"Members",ne.textContent=`#${e.name}`,A.textContent="",O(null),G.reset(),I(),He(t).then(()=>{s.aborted||r!==e||(w.open||w.showModal(),(b?N.radios.get(C):R)?.focus())})},close:U}}export{Xe as createAccessDialog};
2
+ //# sourceMappingURL=access-UK3L54NR.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../web/src/strings/room-access.ts", "../../web/src/views/room/access.ts"],
4
+ "sourcesContent": ["// The user-facing text of views/room/access.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const GUESTS_OF_AN_OPEN_AIR_ROOM = \"Guests of an Open Air room only read.\";\nexport const EVERYONE_WHO_CAN_SEE_IT = \"Everyone who can see it\";\nexport const EVERYONE_ELSE_READS_AND_REACTS_BUT = \"Everyone else reads and reacts, but can't post.\";\nexport const ONLY_PEOPLE_YOU_CHOOSE = \"Only people you choose\";\nexport const EVERYTHING_EVER_WRITTEN_HERE_AND_EVERYTHING =\n \"Everything ever written here, and everything to come, becomes readable by anyone on the web.\";\nexport const EVERYONE_WITH_AN_ACCOUNT_WILL_BE = \"Everyone with an account will be able to read the whole history.\";\nexport const onlyWillSeeThisRoomEveryone = (mine: boolean) =>\n `Only ${mine ? \"you and the people you add\" : \"its creator and the people added\"} will see this room. Everyone else loses it from their list.`;\nexport const PEOPLE_WITHOUT_AN_ACCOUNT_WONT_SEE = \"People without an account won't see this room any more.\";\nexport const WHO_CAN_SEE_IT = \"Who can see it\";\nexport const WHO_CAN_POST = \"Who can post\";\nexport const ADD_PEOPLE = \"Add people\";\nexport const CREATOR = \"Creator\";\nexport const remove = (name: string | number) => `Remove ${name}`;\nexport const REMOVE = \"Remove\";\nexport const MEMBERS = \"Members\";\nexport const CANCEL = \"Cancel\";\nexport const SAVE = \"Save\";\nexport const thisRoomsHomeIsWhoIs = (home: string | number) => `This room's home is ${home}: who is in it is decided there.`;\nexport const CLOSE = \"Close\";\nexport const FIND_SOMEONE_WHO_CAN_POST = \"Find someone who can post\";\nexport const FIND_SOMEONE_TO_ADD_AS_A = \"Find someone to add as a member\";\nexport const UNKNOWN = \"Unknown\";\nexport const ROOM_ACCESS = \"Room access\";\nexport const upTo = (max: number, members: boolean) => `A room can have up to ${max} ${members ? \"members\" : \"people who post\"}.`;\n/** A linked room's hosts; who may add people is told how to add someone from there. */\nexport const sharedWith = (hosts: string[], editable: boolean) =>\n `Shared with ${hosts.join(\", \")}: its messages are kept there too.${editable ? ` Add people there by their address, like ann@${hosts[0]}.` : \"\"}`;\n\n// The invite link (\u00A744).\nexport const INVITE_LINK = \"Invite link\";\nexport const ANYONE_WITH_THE_LINK_CAN_JOIN = \"Anyone with the link who has an account here can join as a member.\";\nexport const WORKS_FOR = \"Works for\";\nexport const days = (n: number) => (n === 1 ? \"1 day\" : `${n} days`);\nexport const COPY_LINK = \"Copy link\";\nexport const CREATE_LINK = \"Create link\";\nexport const NEW_LINK = \"New link\";\nexport const REVOKE = \"Revoke\";\nexport const LINK_READY = \"The link is ready to share.\";\nexport const NEW_LINK_READY = \"A new link is ready. The old one no longer works.\";\nexport const LINK_REVOKED = \"The link no longer works.\";\nexport const ARCHIVED_LINK = \"The room is archived: its link doesn't work until the room is unarchived.\";\nexport const COPIED = \"Copied.\";\nexport const PRESS_CTRL_C_TO_COPY = \"Press Ctrl+C to copy it.\";\nexport const couldntChangeLink = (why: string) => `Couldn't change the link: ${why}`;\nexport const couldntLoadLink = (why: string) => `Couldn't load the invite link: ${why}`;\nexport const expiresUsed = (when: string, uses: number) =>\n `Works until ${when} \u00B7 ${uses === 0 ? \"nobody has joined by it yet\" : uses === 1 ? \"1 person joined by it\" : `${uses} people joined by it`}`;\n", "// Room access dialog (\u00A723.2, \u00A723.6): the creator (or a moderator, \u00A736) chooses who can see the room (Private, Public or Open Air) and, for a\n// private room, who its members are; then who can post: everyone who can see it, or only the people they choose.\n// Anyone else in a private room gets the same dialog to see who is in it (and who can post), read-only.\n// Under a private room's members, those who manage it share an invite link (\u00A744): made, copied, made again or revoked at\n// once, not on Save; its calls are invite-api.ts, loaded when the section is first shown.\n// Telegram stand-ins (no_dms, \u00A726.3) are left out of it: the bridge adds them itself, so adding or removing one does\n// nothing. They stay members (and writers) when it is saved. People on linked instances (\u00A733) are listed with their\n// instance; in a room shared with theirs, the creator adds them by address (\"ann@b.example\"), and the dialog says\n// where else the room's messages are kept (\u00A733.9).\n// A modal <dialog>: it keeps focus inside, Escape closes it, and focus goes back to where it was.\n//\n// A lazy chunk, like search (\u00A729): the room view import()s it when the dialog is first opened, and it links its own\n// stylesheet (web/styles/access.css) before showing. Members are added with the people search (ui/user-search.ts).\n\nimport { errorMessage, reasonOf } from \"../../api.ts\";\nimport { h, uniqueId } from \"../../dom.ts\";\nimport { INVITE_DAYS, type Invite, type InviteApi, type InviteDays } from \"../../invite-api.ts\";\nimport { LIMITS } from \"../../lib/limits.ts\";\nimport { isAddress, postingOf, VISIBILITY, visibilityOf } from \"../../lib/rooms.ts\";\nimport { formatFull, parsePb } from \"../../lib/time.ts\";\nimport type { Posting, Room, User, Visibility } from \"../../lib/types.ts\";\nimport * as S from \"../../strings/room-access.ts\";\nimport { type AvatarUrl, avatar } from \"../../ui/avatar.ts\";\nimport { createUserSearch, SearchError, type UserSearch } from \"../../ui/user-search.ts\";\n\nexport interface AccessDialog {\n readonly el: HTMLDialogElement;\n /** Open it for `room`: to change its access when `editable`, else to see its members. `me` names you in the list. */\n open(room: Room, editable: boolean, me: User | null): void;\n close(): void;\n}\n\ndeclare const ACCESS_CSS: string;\n\nlet stylesheet: Promise<void> | null = null;\n/** The dialog's stylesheet, linked once, like the media grid's: a failed load is tried again next time, and it opens anyway. */\nfunction loadStylesheet(h: typeof import(\"../../dom.ts\")[\"h\"]): Promise<void> {\n stylesheet ??= new Promise((resolve) => {\n const failed = () => {\n link.remove();\n stylesheet = null;\n resolve();\n };\n const link = h(\"link\", { rel: \"stylesheet\", href: ACCESS_CSS, on: { load: () => resolve(), error: failed } });\n document.head.append(link);\n });\n return stylesheet;\n}\n\nconst CHOICES: readonly Visibility[] = [\"private\", \"public\", \"open\"];\n\n/** Who can post (\u00A723.6), shown like the visibilities. */\n/** The choices' icons (.i-* in icons.css); Public keeps its \"#\". */\nconst ICONS: Record<string, string> = { private: \"ic i-lock\", open: \"ic i-globe\", everyone: \"ic i-users\", selected: \"ic i-check\" };\n\nconst POSTING: Record<Posting, { label: string; icon: string; hint: string }> = {\n everyone: { label: \"Everyone who can see it\", icon: \"\", hint: \"Guests of an Open Air room only read.\" },\n selected: { label: \"Only people you choose\", icon: \"\", hint: \"Everyone else reads and reacts, but can't post.\" },\n};\n\n/** What a change of visibility does that may not be obvious, or \"\". */\nfunction warning(from: Visibility, to: Visibility, mine: boolean): string {\n if (from === to) return \"\";\n if (to === \"open\") return \"Everything ever written here, and everything to come, becomes readable by anyone on the web.\";\n if (from === \"private\") return \"Everyone with an account will be able to read the whole history.\";\n if (to === \"private\") return S.onlyWillSeeThisRoomEveryone(mine);\n return \"People without an account won't see this room any more.\";\n}\n\n/** A list of people with Add and Remove: the members, or who can post. */\ninterface People {\n readonly el: HTMLElement;\n readonly addBtn: HTMLButtonElement;\n /** Where its search goes. */\n readonly slot: HTMLElement;\n /** Who its search offers. */\n pickable(u: User): boolean;\n list: User[];\n render(): void;\n}\n\nexport function createAccessDialog(opts: {\n searchUsers: (query: string, signal: AbortSignal) => Promise<User[]>;\n /** Someone on a linked instance by address, to add to this shared room (\u00A733.5). */\n remoteUser?: (address: string, room: string) => Promise<User>;\n avatarUrl: AvatarUrl;\n /** The invite links' calls (\u00A744), loaded when first needed. Without it, no invite link section. */\n invites?: () => Promise<InviteApi>;\n /** The full address of an invite link. */\n inviteUrl?: (token: string) => string;\n /** Save. Resolves to what went wrong, or null once it is saved (the dialog then closes). */\n onSave: (visibility: Visibility, members: string[], posting: Posting, writers: string[]) => Promise<string | null>;\n signal: AbortSignal;\n}): AccessDialog {\n const { signal } = opts;\n const maxMembers = LIMITS.roomMembers;\n const id = uniqueId(\"access\");\n const title = h(\"h2\", { id: `${id}-title` });\n const sub = h(\"p\", { class: \"dialog-sub\" });\n\n /** Radio cards: one fieldset of `values`, each with its icon, label and hint. */\n function cards<T extends string>(\n values: readonly T[],\n info: Record<T, { label: string; icon: string; hint: string }>,\n set: (v: T) => void,\n ) {\n const legend = h(\"legend\", {});\n const radios = new Map<T, HTMLInputElement>();\n const el = h(\"fieldset\", { class: \"vis-choices\" }, [\n legend,\n ...values.map((v) => {\n const input = h(\"input\", {\n type: \"radio\",\n name: `${id}-${values[0]}`,\n value: v,\n \"aria-labelledby\": `${id}-${v}-label`,\n \"aria-describedby\": `${id}-${v}-hint`,\n on: { change: () => set(v) },\n signal,\n });\n radios.set(v, input);\n return h(\"label\", { class: `vis-choice vis-${v}` }, [\n input,\n h(\"span\", { class: `vis-icon ${ICONS[v] ?? \"\"}`, \"aria-hidden\": \"true\" }, ICONS[v] ? \"\" : info[v].icon),\n h(\"span\", { class: \"vis-text\" }, [\n h(\"span\", { id: `${id}-${v}-label`, class: \"vis-label\" }, info[v].label),\n h(\"span\", { id: `${id}-${v}-hint`, class: \"vis-hint\" }, info[v].hint),\n ]),\n ]);\n }),\n ]);\n return { el, legend, radios };\n }\n\n const choices = cards(CHOICES, VISIBILITY, (v) => {\n visibility = v;\n changed();\n });\n choices.legend.textContent = \"Who can see it\";\n const postingChoices = cards([\"everyone\", \"selected\"] as const, POSTING, (p) => {\n posting = p;\n changed();\n });\n postingChoices.legend.textContent = \"Who can post\";\n\n /**\n * One list of people. `pickable` says who its search offers: the members are anyone; who can post, in a private\n * room, only its members.\n */\n function people(label: string, cls: string, pickable: (u: User) => boolean): People {\n const head = h(\"h3\", {});\n const ul = h(\"ul\", { class: \"member-list\", \"aria-label\": label });\n const addBtn = h(\n \"button\",\n { type: \"button\", class: \"add-member ic i-plus\", on: { click: () => toggleSearch(p) }, signal },\n \"Add people\",\n );\n const slot = h(\"div\", { class: \"member-search\" });\n // Search above the list, so it stays in reach however many people there are.\n const el = h(\"section\", { class: cls }, [h(\"div\", { class: \"people-head\" }, [head, addBtn]), slot, ul]);\n const p: People = {\n el,\n addBtn,\n slot,\n pickable,\n list: [],\n render() {\n // Hidden, it lists nobody: only the lists in use are in the page.\n const shown = el.hidden ? [] : p.list.filter(listed);\n head.textContent = `${label} \u00B7 ${shown.length}`;\n const full = p.list.length >= maxMembers;\n addBtn.hidden = !editable || search?.p === p;\n addBtn.disabled = full;\n addBtn.title = full ? S.upTo(maxMembers, p === members) : \"\";\n ul.replaceChildren(\n ...shown.map((u) => {\n const owner = u.id === room?.created_by;\n return h(\"li\", { class: \"member\", dataset: { userId: u.id } }, [\n avatar(u, 32, opts.avatarUrl),\n h(\"span\", { class: \"member-name\" }, [u.name, u.id === myId ? h(\"span\", {}, \" (you)\") : null]),\n owner ? h(\"span\", { class: \"member-role\" }, \"Creator\") : null,\n u.instance ? h(\"span\", { class: \"member-role\" }, u.instance) : null,\n editable && !owner\n ? h(\n \"button\",\n {\n type: \"button\",\n class: \"remove-member\",\n \"aria-label\": `Remove ${u.name}`,\n on: { click: () => remove(p, u.id) },\n signal,\n },\n \"Remove\",\n )\n : null,\n ]);\n }),\n );\n },\n };\n return p;\n }\n\n const members = people(\"Members\", \"members\", () => true);\n const writers = people(\"Who can post\", \"writers\", (u) => visibility !== \"private\" || has(members, u));\n const invite = inviteSection();\n const warn = h(\"p\", { class: \"access-warning\", role: \"status\" });\n const sharedEl = h(\"p\", { class: \"access-shared\" });\n const error = h(\"p\", { class: \"field-error\", role: \"alert\" });\n const cancel = h(\"button\", { type: \"button\", class: \"cancel\", on: { click: () => close() }, signal }, \"Cancel\");\n const save = h(\"button\", { type: \"button\", class: \"primary save\", on: { click: () => void submit() }, signal }, \"Save\");\n const buttons = h(\"div\", { class: \"dialog-actions\" }, [cancel, save]);\n // For the pointer only: the footer's Cancel/Close and Escape do the same, so it isn't a second \"Close\" to tab to or hear.\n const x = h(\"button\", {\n type: \"button\",\n class: \"icon-button ic i-x\",\n tabindex: \"-1\",\n \"aria-hidden\": \"true\",\n on: { click: () => close() },\n signal,\n });\n const head = h(\"div\", { class: \"dialog-head\" }, [h(\"div\", {}, [title, sub]), x]);\n // The body scrolls; the title and the buttons stay put.\n const body = h(\"div\", { class: \"access-body\" }, [\n sharedEl,\n choices.el,\n members.el,\n invite.el,\n postingChoices.el,\n writers.el,\n warn,\n error,\n ]);\n const el = h(\"dialog\", { class: \"access\", \"aria-labelledby\": title.id }, [head, body, buttons]);\n\n let room: Room | null = null;\n let myId: string | undefined;\n let editable = false;\n let visibility: Visibility = \"public\";\n let posting: Posting = \"everyone\";\n const has = (p: People, u: User) => p.list.some((x) => x.id === u.id);\n /** Who the lists show: not Telegram's stand-ins, but people on linked instances (\u00A733.4) even without DMs. */\n const listed = (u: User) => !u.no_dms || !!u.instance;\n const sharedHosts = () => room?.shared?.with ?? [];\n let search: { ac: AbortController; ui: UserSearch; p: People } | null = null;\n let busy = false;\n\n /**\n * The invite link (\u00A744): shown to those who manage a room saved as private (not a copy of another instance's room,\n * whose members are changed there) while Private is chosen. Each button acts at once.\n */\n function inviteSection() {\n const head = h(\"h3\", {}, \"Invite link\");\n const hint = h(\"p\", { class: \"vis-hint\" }, \"Anyone with the link who has an account here can join as a member.\");\n const url = h(\"input\", {\n type: \"text\",\n readOnly: true,\n class: \"invite-url\",\n \"aria-label\": \"Invite link\",\n on: { focus: () => url.select() },\n signal,\n });\n const meta = h(\"p\", { class: \"invite-meta\" });\n const days = h(\n \"select\",\n { signal },\n INVITE_DAYS.map((d) => h(\"option\", { value: String(d), selected: d === 7 }, S.days(d))),\n );\n const btn = (label: string, run: () => void, cls = \"\") =>\n h(\"button\", { type: \"button\", class: cls, on: { click: run }, signal }, label);\n const copy = btn(\"Copy link\", () => void copyLink(), \"primary\");\n const make = btn(\"Create link\", () => void act((api) => api.make(room!.id, Number(days.value) as InviteDays)), \"primary\");\n const again = btn(\"New link\", () => void act((api) => api.make(room!.id, Number(days.value) as InviteDays)));\n const revoke = btn(\n \"Revoke\",\n () =>\n void act(async (api) => {\n await api.revoke(room!.id);\n return null;\n }),\n );\n const status = h(\"p\", { class: \"invite-status\", role: \"status\" });\n const shown = h(\"div\", { class: \"invite-shown\" }, [h(\"div\", { class: \"invite-row\" }, [url, copy]), meta]);\n const choose = h(\"label\", { class: \"invite-days\" }, [\"Works for\", days]);\n const actions = h(\"div\", { class: \"invite-actions\" }, [choose, make, again, revoke]);\n const el = h(\"section\", { class: \"invite\" }, [head, hint, shown, actions, status]);\n /** undefined: not loaded yet; null: none. */\n let current: Invite | null | undefined;\n let loading: AbortController | null = null;\n let api: Promise<InviteApi> | null = null;\n let busy = false;\n const loadApi = () => {\n api ??= opts.invites!().catch((e: unknown) => {\n api = null;\n throw e;\n });\n return api;\n };\n const wanted = () =>\n !!room && !!opts.invites && editable && visibility === \"private\" && visibilityOf(room) === \"private\" && !room.shared?.home;\n\n async function act(run: (api: InviteApi) => Promise<Invite | null>) {\n if (busy || !room) return;\n const r = room;\n const had = !!current;\n busy = true;\n status.textContent = \"\";\n render();\n try {\n const next = await run(await loadApi());\n if (signal.aborted || room !== r) return;\n current = next;\n status.textContent = next ? (had ? \"A new link is ready. The old one no longer works.\" : \"The link is ready to share.\") : \"The link no longer works.\";\n } catch (e) {\n if (room === r) status.textContent = `Couldn't change the link: ${errorMessage(e)}`;\n } finally {\n busy = false;\n render();\n }\n }\n\n async function copyLink() {\n url.select();\n try {\n await navigator.clipboard.writeText(url.value);\n status.textContent = \"Copied.\";\n } catch {\n status.textContent = \"Press Ctrl+C to copy it.\";\n }\n }\n\n function load() {\n const r = room;\n if (!r) return;\n loading = new AbortController();\n const ac = loading;\n signal.addEventListener(\"abort\", () => ac.abort(), { once: true });\n loadApi()\n .then((a) => a.get(r.id, ac.signal))\n .then(\n (inv) => {\n if (ac.signal.aborted || room !== r) return;\n current = inv;\n render();\n },\n (e: unknown) => {\n if (ac.signal.aborted || room !== r) return;\n current = null;\n status.textContent = `Couldn't load the invite link: ${errorMessage(e)}`;\n render();\n },\n );\n }\n\n function render() {\n el.hidden = !wanted();\n if (el.hidden) return;\n if (current === undefined && !loading) load();\n const has = !!current;\n // Archived, the link doesn't work and no new one can be made (\u00A744.1, QA BUG-282): it can only be revoked.\n const archived = !!room?.archived;\n hint.textContent = archived ? \"The room is archived: its link doesn't work until the room is unarchived.\" : \"Anyone with the link who has an account here can join as a member.\";\n shown.hidden = !has || archived;\n choose.hidden = archived;\n make.hidden = has || archived;\n again.hidden = !has || archived;\n revoke.hidden = !has;\n make.disabled = again.disabled = revoke.disabled = busy || current === undefined;\n if (current) {\n url.value = opts.inviteUrl ? opts.inviteUrl(current.token) : current.token;\n meta.textContent = S.expiresUsed(formatFull(parsePb(current.expires)), current.uses);\n }\n }\n\n return {\n el,\n render,\n /** A new room shown: what the last one had is forgotten. */\n reset() {\n loading?.abort();\n loading = null;\n current = undefined;\n busy = false;\n status.textContent = \"\";\n },\n };\n }\n\n function changed() {\n error.textContent = \"\";\n // Made private: only members can post.\n if (visibility === \"private\") writers.list = writers.list.filter((u) => has(members, u));\n render();\n }\n\n function render() {\n if (!room) return;\n for (const [v, input] of choices.radios) input.checked = v === visibility;\n for (const [v, input] of postingChoices.radios) input.checked = v === posting;\n choices.el.hidden = postingChoices.el.hidden = !editable;\n members.el.hidden = visibility !== \"private\";\n writers.el.hidden = posting !== \"selected\";\n members.render();\n writers.render();\n invite.render();\n warn.textContent = editable ? warning(visibilityOf(room), visibility, room.created_by === myId) : \"\";\n const hosts = sharedHosts();\n sharedEl.hidden = !hosts.length;\n sharedEl.textContent = !hosts.length\n ? \"\"\n : room.shared?.home\n ? `This room's home is ${room.shared.home}: who is in it is decided there.`\n : S.sharedWith(hosts, editable);\n save.hidden = !editable;\n cancel.textContent = editable ? \"Cancel\" : \"Close\";\n }\n\n function remove(p: People, userId: string) {\n const ul = p.el.querySelector(\"ul\")!;\n const at = [...ul.children].findIndex((li) => (li as HTMLElement).dataset.userId === userId);\n p.list = p.list.filter((u) => u.id !== userId);\n // A member taken out can't post either.\n if (p === members) writers.list = writers.list.filter((u) => u.id !== userId);\n render();\n // Focus stays in the list: on the next person's Remove, else the previous one's, else Add people.\n const buttons = [...ul.querySelectorAll<HTMLButtonElement>(\"button.remove-member\")];\n (buttons[Math.min(at - 1, buttons.length - 1)] ?? p.addBtn).focus();\n }\n\n /** A search result picked: add them, or take them out again when they are in. */\n function toggle(p: People, u: User) {\n if (has(p, u)) {\n p.list = p.list.filter((x) => x.id !== u.id);\n if (p === members) writers.list = writers.list.filter((x) => x.id !== u.id);\n } else if (p.list.length >= maxMembers) {\n error.textContent = S.upTo(maxMembers, p === members);\n return;\n } else p.list = [...p.list, u];\n error.textContent = \"\";\n render();\n search?.ui.mark();\n }\n\n /** Open the people search under `p`'s Add button (closing any other), or close it (null). */\n function toggleSearch(p: People | null) {\n if (p === (search?.p ?? null)) return;\n search?.ac.abort();\n search?.p.slot.replaceChildren();\n search = null;\n if (p) {\n const ac = new AbortController();\n signal.addEventListener(\"abort\", () => ac.abort(), { once: true });\n const ui = createUserSearch({\n search: async (q, sig) => {\n if (!isAddress(q) || !room || !sharedHosts().length || !opts.remoteUser) {\n return (await opts.searchUsers(q, sig)).filter((u) => listed(u) && p.pickable(u));\n }\n try {\n const u = await opts.remoteUser(q, room.id);\n return p.pickable(u) ? [u] : [];\n } catch (e) {\n throw new SearchError(reasonOf(e));\n }\n },\n avatarUrl: opts.avatarUrl,\n onPick: (u) => toggle(p, u),\n isPicked: (u) => has(p, u),\n label: p === members ? \"Find someone to add as a member\" : \"Find someone who can post\",\n onClose: () => {\n toggleSearch(null);\n p.addBtn.focus();\n },\n signal: ac.signal,\n });\n search = { ac, ui, p };\n p.slot.replaceChildren(ui.el);\n render();\n ui.focus();\n // Room for the results under it, on a small screen too.\n p.el.firstElementChild?.scrollIntoView?.({ block: \"start\" });\n } else render();\n }\n\n async function submit() {\n if (busy || !room || !editable) return;\n busy = true;\n save.disabled = cancel.disabled = x.disabled = true;\n error.textContent = \"\";\n const ids = (p: People) => p.list.map((u) => u.id);\n const problem = await opts.onSave(visibility, ids(members), posting, ids(writers));\n busy = false;\n save.disabled = cancel.disabled = x.disabled = false;\n if (signal.aborted) return;\n if (problem === null) return close();\n error.textContent = problem;\n if (!el.open) el.showModal();\n }\n\n function close() {\n toggleSearch(null);\n if (el.open) el.close();\n }\n\n // Escape in the people search closes the search, not the dialog; while saving, nothing closes it.\n el.addEventListener(\n \"cancel\",\n (e) => {\n if (busy) e.preventDefault();\n else if (search) {\n e.preventDefault();\n const p = search.p;\n toggleSearch(null);\n p.addBtn.focus();\n }\n },\n { signal },\n );\n el.addEventListener(\"close\", () => toggleSearch(null), { signal });\n signal.addEventListener(\"abort\", close, { once: true });\n\n /** The people `ids` names, as expanded, the creator first (as the server keeps them). */\n function users(r: Room, ids: string[], expanded: User[] | undefined, me: User | null) {\n const known = new Map([...(r.expand?.members ?? []), ...(expanded ?? [])].map((u) => [u.id, u]));\n // A room made private (or posting chosen) starts with its creator, who isn't expanded yet, and a moderator making\n // it so with themselves (\u00A736), who would otherwise lose it.\n if (me && !known.has(me.id)) known.set(me.id, me);\n const list = [...new Set(ids.length ? ids : [r.created_by, myId || r.created_by])].map(\n (uid) => known.get(uid) ?? { id: uid, name: \"Unknown\" },\n );\n return list.sort((a, b) => Number(b.id === r.created_by) - Number(a.id === r.created_by));\n }\n\n return {\n el,\n open(r, canEdit, me) {\n room = r;\n myId = me?.id;\n editable = canEdit;\n visibility = visibilityOf(r);\n posting = postingOf(r);\n members.list = users(r, r.members ?? [], undefined, me);\n writers.list = users(r, r.writers ?? [], r.expand?.writers, me);\n title.textContent = editable ? \"Room access\" : \"Members\";\n sub.textContent = `#${r.name}`;\n error.textContent = \"\";\n toggleSearch(null);\n invite.reset();\n render();\n void loadStylesheet(h).then(() => {\n if (signal.aborted || room !== r) return;\n if (!el.open) el.showModal();\n (editable ? choices.radios.get(visibility) : cancel)?.focus();\n });\n },\n close,\n };\n}\n"],
5
+ "mappings": "4VAUO,IAAMA,GAA+BC,GAC1C,QAAQA,EAAO,6BAA+B,kCAAkC,+DAiB3E,IAAMC,GAAO,CAACC,EAAaC,IAAqB,yBAAyBD,CAAG,IAAIC,EAAU,UAAY,iBAAiB,IAEjHC,GAAa,CAACC,EAAiBC,IAC1C,eAAeD,EAAM,KAAK,IAAI,CAAC,qCAAqCC,EAAW,gDAAgDD,EAAM,CAAC,CAAC,IAAM,EAAE,GAM1I,IAAME,GAAQC,GAAeA,IAAM,EAAI,QAAU,GAAGA,CAAC,QAarD,IAAMC,GAAc,CAACC,EAAcC,IACxC,eAAeD,CAAI,SAAMC,IAAS,EAAI,8BAAgCA,IAAS,EAAI,wBAA0B,GAAGA,CAAI,sBAAsB,GCjB5I,IAAIC,GAAmC,KAEv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,CAAC,CAAC,EAAE,IAChFgC,GAAQD,EAAM,IAAIC,CAAG,GAAK,CAAE,GAAIA,EAAK,KAAM,SAAU,CACxD,EACY,KAAK,CAAC,EAAGC,IAAM,EAAOA,EAAE,KAAOjC,EAAE,YAAc,EAAO,EAAE,KAAOA,EAAE,WAAW,CAC1F,CAEA,MAAO,CACL,GAAArD,EACA,KAAKqD,EAAGkC,EAASJ,EAAI,CACnBzE,EAAO2C,EACPzC,EAAOuE,GAAI,GACX/E,EAAWmF,EACXrG,EAAakE,EAAaC,CAAC,EAC3B/D,EAAUkG,GAAUnC,CAAC,EACrB9C,EAAQ,KAAO0E,GAAM5B,EAAGA,EAAE,SAAW,CAAC,EAAG,OAAW8B,CAAE,EACtDrE,EAAQ,KAAOmE,GAAM5B,EAAGA,EAAE,SAAW,CAAC,EAAGA,EAAE,QAAQ,QAAS8B,CAAE,EAC9D7G,EAAM,YAAc8B,EAAW,cAAgB,UAC/C7B,GAAI,YAAc,IAAI8E,EAAE,IAAI,GAC5BjC,EAAM,YAAc,GACpBtB,EAAa,IAAI,EACjBkB,EAAO,MAAM,EACbuC,EAAO,EACFpG,GAAeC,CAAC,EAAE,KAAK,IAAM,CAC5Ba,EAAO,SAAWyC,IAAS2C,IAC1BrD,EAAG,MAAMA,EAAG,UAAU,GAC1BI,EAAWpB,EAAQ,OAAO,IAAIE,CAAU,EAAImC,IAAS,MAAM,EAC9D,CAAC,CACH,EACA,MAAAC,CACF,CACF",
6
+ "names": ["onlyWillSeeThisRoomEveryone", "mine", "upTo", "max", "members", "sharedWith", "hosts", "editable", "days", "n", "expiresUsed", "when", "uses", "stylesheet", "loadStylesheet", "h", "resolve", "link", "CHOICES", "ICONS", "POSTING", "warning", "from", "to", "mine", "onlyWillSeeThisRoomEveryone", "createAccessDialog", "opts", "signal", "maxMembers", "LIMITS", "id", "uniqueId", "title", "sub", "cards", "values", "info", "set", "legend", "radios", "v", "input", "choices", "VISIBILITY", "visibility", "changed", "postingChoices", "p", "posting", "people", "label", "cls", "pickable", "head", "ul", "addBtn", "toggleSearch", "slot", "el", "shown", "listed", "full", "editable", "search", "upTo", "members", "u", "owner", "room", "avatar", "myId", "remove", "writers", "has", "invite", "inviteSection", "warn", "sharedEl", "error", "cancel", "close", "save", "submit", "buttons", "x", "body", "sharedHosts", "busy", "hint", "url", "meta", "days", "INVITE_DAYS", "btn", "run", "copy", "copyLink", "make", "act", "api", "again", "revoke", "status", "choose", "actions", "current", "loading", "loadApi", "e", "wanted", "visibilityOf", "r", "had", "render", "next", "errorMessage", "load", "ac", "a", "inv", "archived", "expiresUsed", "formatFull", "parsePb", "hosts", "sharedWith", "userId", "at", "li", "toggle", "ui", "createUserSearch", "q", "sig", "isAddress", "SearchError", "reasonOf", "ids", "problem", "users", "expanded", "me", "known", "uid", "b", "canEdit", "postingOf"]
7
+ }
@@ -0,0 +1,2 @@
1
+ .profile-delete>*{margin:0}.profile-delete-choice{display:grid;gap:8px;padding:0;border:0}.profile-delete-choice label,.profile-export-actions{display:flex;gap:8px;align-items:center}.profile-delete button{align-self:flex-start}.profile-delete-choice input{flex:none;width:auto;margin:0;padding:0;accent-color:var(--fill)}.profile-export{flex-wrap:wrap;gap:12px}.profile-export>div:first-child{flex:1 1 16rem}.profile-export-actions button{white-space:nowrap}
2
+ /*# sourceMappingURL=account-CT2BVMAX.css.map */
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../web/styles/account.css"],
4
+ "sourcesContent": ["/* Settings' \"Your data\" and \"Delete account\" cards (DESIGN.md \u00A743): a stylesheet the profile chunk links\n (ACCOUNT_CSS, views/profile.ts), so the critical path's app.css doesn't grow for them. */\n\n/* The choices one per line, the buttons at their width. */\n.profile-delete > * {\n margin: 0;\n}\n\n.profile-delete-choice {\n display: grid;\n gap: 8px;\n padding: 0;\n border: 0;\n}\n\n.profile-delete-choice label,\n.profile-export-actions {\n display: flex;\n gap: 8px;\n align-items: center;\n}\n\n.profile-delete button {\n align-self: flex-start;\n}\n\n/* The radios at their own size, not every input's full width (QA BUG-286: the dot sat mid-card, the words pushed right). */\n.profile-delete-choice input {\n flex: none;\n width: auto;\n margin: 0;\n padding: 0;\n accent-color: var(--fill);\n}\n\n/* \"Your data\": the text and its two buttons side by side when there is room, else the buttons under the text\n (QA BUG-284: on a phone the text was squeezed into a column a few words wide). */\n.profile-export {\n flex-wrap: wrap;\n gap: 12px;\n}\n\n.profile-export > div:first-child {\n flex: 1 1 16rem;\n}\n\n.profile-export-actions button {\n white-space: nowrap;\n}\n"],
5
+ "mappings": "AAIA,CAAC,cAAe,CAAE,EAJlB,OAKU,CACV,CAEA,CAAC,sBACC,QAAS,KACT,IAAK,IAVP,QAWW,EACT,OAAQ,CACV,CAEA,CAPC,sBAOsB,MACvB,CAAC,uBACC,QAAS,KACT,IAAK,IACL,YAAa,MACf,CAEA,CAlBC,eAkBe,OACd,WAAY,UACd,CAGA,CAnBC,sBAmBsB,MACrB,KAAM,KACN,MAAO,KA7BT,OA8BU,EA9BV,QA+BW,EACT,aAAc,IAAI,OACpB,CAIA,CAAC,eACC,UAAW,KACX,IAAK,IACP,CAEA,CALC,cAKe,CAAE,GAAG,aACnB,KAAM,EAAE,EAAE,KACZ,CAEA,CA9BC,uBA8BuB,OACtB,YAAa,MACf",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ function i(e,o){return{exportStatus:t=>o(e.send("/api/chat/export",{signal:t})),startExport:()=>o(e.send("/api/chat/export",{method:"POST"})),async exportFileUrl(){let{token:t}=await o(e.send("/api/files/token",{method:"POST"}));return`/api/chat/export/file?token=${encodeURIComponent(t)}`},async deleteAccount(t,r){await o(e.send("/api/chat/account/delete",{method:"POST",body:{password:t,messages:r}}))}}}export{i as createAccountApi};
2
+ //# sourceMappingURL=account-api-J6A6IYVX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../web/src/account-api.ts"],
4
+ "sourcesContent": ["// Your data and deleting your account (DESIGN.md \u00A743): the part of the API (api.ts) only Settings uses, split out so it\n// loads with that page (a lazy chunk, `Api.account()`), not on the app's critical path (\u00A77.7).\n\nimport type { PbClient } from \"./pb.ts\";\n\n/** Where your newest export is (\u00A743.2, GET /api/chat/export). */\nexport interface ExportStatus {\n id: string;\n state: \"none\" | \"queued\" | \"done\" | \"failed\";\n created: string;\n finished: string;\n /** Until when it can be downloaded (\"done\" only). */\n expires: string;\n /** Its size in bytes (\"done\" only). */\n size: number;\n}\n\nexport interface AccountApi {\n /** Where your newest export is (\u00A743.2): none, being made, made (to download until `expires`), or failed. */\n exportStatus(signal?: AbortSignal): Promise<ExportStatus>;\n /** Ask for your data as a file (\u00A743.2): the server makes it in the background. Asked again soon, the same one. */\n startExport(): Promise<ExportStatus>;\n /**\n * A link that downloads your made export (with a fresh file token: a plain link sends no session). Relative: the app\n * is served by its server (main.ts uses location.origin).\n */\n exportFileUrl(): Promise<string>;\n /**\n * Delete your account (\u00A743.3), checked by your password: your messages stay under \"Deleted account\" (\"keep\") or are\n * deleted too (\"delete\"). Every session ends, this one included (log out after). Rejects with field errors on\n * `password` or `messages`.\n */\n deleteAccount(password: string, messages: \"keep\" | \"delete\"): Promise<void>;\n}\n\n/** Built by api.ts with its client (which tells onRejected listeners) and its error wrapping. */\nexport function createAccountApi(pb: PbClient, wrap: <T>(p: Promise<T>) => Promise<T>): AccountApi {\n return {\n exportStatus: (signal) => wrap(pb.send<ExportStatus>(\"/api/chat/export\", { signal })),\n startExport: () => wrap(pb.send<ExportStatus>(\"/api/chat/export\", { method: \"POST\" })),\n async exportFileUrl() {\n const { token } = await wrap(pb.send<{ token: string }>(\"/api/files/token\", { method: \"POST\" }));\n return `/api/chat/export/file?token=${encodeURIComponent(token)}`;\n },\n async deleteAccount(password, messages) {\n await wrap(pb.send(\"/api/chat/account/delete\", { method: \"POST\", body: { password, messages } }));\n },\n };\n}\n"],
5
+ "mappings": "AAoCO,SAASA,EAAiBC,EAAcC,EAAoD,CACjG,MAAO,CACL,aAAeC,GAAWD,EAAKD,EAAG,KAAmB,mBAAoB,CAAE,OAAAE,CAAO,CAAC,CAAC,EACpF,YAAa,IAAMD,EAAKD,EAAG,KAAmB,mBAAoB,CAAE,OAAQ,MAAO,CAAC,CAAC,EACrF,MAAM,eAAgB,CACpB,GAAM,CAAE,MAAAG,CAAM,EAAI,MAAMF,EAAKD,EAAG,KAAwB,mBAAoB,CAAE,OAAQ,MAAO,CAAC,CAAC,EAC/F,MAAO,+BAA+B,mBAAmBG,CAAK,CAAC,EACjE,EACA,MAAM,cAAcC,EAAUC,EAAU,CACtC,MAAMJ,EAAKD,EAAG,KAAK,2BAA4B,CAAE,OAAQ,OAAQ,KAAM,CAAE,SAAAI,EAAU,SAAAC,CAAS,CAAE,CAAC,CAAC,CAClG,CACF,CACF",
6
+ "names": ["createAccountApi", "pb", "wrap", "signal", "token", "password", "messages"]
7
+ }