@coffre/ui 0.1.17 → 0.2.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.
Files changed (235) hide show
  1. package/README.md +23 -3
  2. package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
  3. package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
  4. package/dist/chunks/directory-CSjWWUQ1.js +370 -0
  5. package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
  6. package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
  7. package/dist/chunks/grants-saMQagmG.js.map +1 -0
  8. package/dist/chunks/icons-D-PfAfnH.js +203 -0
  9. package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
  10. package/dist/chunks/mounted-jJmqqV_n.js +17 -0
  11. package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
  12. package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
  13. package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
  14. package/dist/chunks/page-C5HcNqf2.js +190 -0
  15. package/dist/chunks/page-C5HcNqf2.js.map +1 -0
  16. package/dist/chunks/page-route-Drfw7lmn.js +20 -0
  17. package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
  18. package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
  19. package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
  20. package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
  21. package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
  22. package/dist/chunks/queries-CQ81o4so.js +376 -0
  23. package/dist/chunks/queries-CQ81o4so.js.map +1 -0
  24. package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
  25. package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
  26. package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
  27. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
  28. package/dist/chunks/theme-B2vQolVR.js +86 -0
  29. package/dist/chunks/theme-B2vQolVR.js.map +1 -0
  30. package/dist/chunks/ui-DixXLQvQ.js +405 -0
  31. package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
  32. package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
  33. package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
  34. package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
  35. package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
  36. package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
  37. package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
  38. package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
  39. package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
  40. package/dist/index.d.ts +386 -18
  41. package/dist/index.js +1147 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/pages/account.d.ts +9 -0
  44. package/dist/pages/account.js +334 -0
  45. package/dist/pages/account.js.map +1 -0
  46. package/dist/pages/audit.d.ts +3 -0
  47. package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
  48. package/dist/pages/audit.js.map +1 -0
  49. package/dist/pages/device-login.d.ts +9 -0
  50. package/dist/pages/device-login.js +211 -0
  51. package/dist/pages/device-login.js.map +1 -0
  52. package/dist/pages/environment.d.ts +3 -0
  53. package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
  54. package/dist/pages/environment.js.map +1 -0
  55. package/dist/pages/login.d.ts +10 -0
  56. package/dist/pages/login.js +104 -0
  57. package/dist/pages/login.js.map +1 -0
  58. package/dist/pages/project.d.ts +2 -0
  59. package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
  60. package/dist/pages/project.js.map +1 -0
  61. package/dist/pages/projects.d.ts +3 -0
  62. package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
  63. package/dist/pages/projects.js.map +1 -0
  64. package/dist/pages/settings.d.ts +3 -0
  65. package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
  66. package/dist/pages/settings.js.map +1 -0
  67. package/dist/pages/token.d.ts +3 -0
  68. package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
  69. package/dist/pages/token.js.map +1 -0
  70. package/dist/pages/tokens.d.ts +3 -0
  71. package/dist/pages/tokens.js +39 -0
  72. package/dist/pages/tokens.js.map +1 -0
  73. package/dist/pages/unregistered.d.ts +8 -0
  74. package/dist/pages/unregistered.js +54 -0
  75. package/dist/pages/unregistered.js.map +1 -0
  76. package/dist/pages/user.d.ts +3 -0
  77. package/dist/pages/user.js +16 -0
  78. package/dist/pages/user.js.map +1 -0
  79. package/dist/pages/users.d.ts +3 -0
  80. package/dist/pages/users.js +39 -0
  81. package/dist/pages/users.js.map +1 -0
  82. package/dist/project-BqIy8gYR.d.ts +5 -0
  83. package/dist/vite.d.ts +16 -0
  84. package/dist/vite.js +52 -0
  85. package/package.json +36 -21
  86. package/src/assets/icon.svg +1 -0
  87. package/src/components/affordances.ts +10 -4
  88. package/src/components/command-palette.tsx +229 -203
  89. package/src/components/directory.tsx +34 -38
  90. package/src/components/principal.tsx +7 -3
  91. package/src/components/shell.tsx +89 -127
  92. package/src/components/theme.tsx +14 -81
  93. package/src/components/ui.tsx +97 -68
  94. package/src/index.ts +29 -0
  95. package/src/layout.tsx +113 -0
  96. package/src/lib/coffre.ts +8 -4
  97. package/src/lib/mounted.ts +13 -0
  98. package/src/lib/page-context.ts +31 -0
  99. package/src/lib/page-route.ts +22 -0
  100. package/src/lib/preferences.tsx +46 -0
  101. package/src/options.ts +240 -0
  102. package/src/{routes → pages}/account.tsx +7 -24
  103. package/src/{routes → pages}/audit.tsx +5 -16
  104. package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
  105. package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
  106. package/src/{routes → pages}/login.tsx +5 -16
  107. package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
  108. package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
  109. package/src/{routes → pages}/settings.tsx +3 -10
  110. package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
  111. package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
  112. package/src/{routes → pages}/unregistered.tsx +1 -6
  113. package/src/pages/user.tsx +10 -0
  114. package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
  115. package/src/register.ts +55 -0
  116. package/src/router.tsx +31 -62
  117. package/src/styles/globals.css +104 -46
  118. package/src/vite.ts +78 -0
  119. package/dist/client/.assetsignore +0 -2
  120. package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
  121. package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
  122. package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
  123. package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
  124. package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
  125. package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
  126. package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
  127. package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
  128. package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
  129. package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
  130. package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
  131. package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
  132. package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
  133. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  134. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  135. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  136. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  137. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  138. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  139. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  140. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  141. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  142. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  143. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  144. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  145. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  146. package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
  147. package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
  148. package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
  149. package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
  150. package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
  151. package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
  152. package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
  153. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
  154. package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
  155. package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
  156. package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
  157. package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
  158. package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
  159. package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
  160. package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
  161. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
  162. package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
  163. package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
  164. package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
  165. package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
  166. package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
  167. package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
  168. package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
  169. package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
  170. package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
  171. package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
  172. package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
  173. package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
  174. package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
  175. package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
  176. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
  177. package/dist/server/.vite/manifest.json +0 -668
  178. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
  179. package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
  180. package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
  181. package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
  182. package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
  183. package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
  184. package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
  185. package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
  186. package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
  187. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
  188. package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
  189. package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
  190. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  191. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  192. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  193. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  194. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  195. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  196. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  197. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  198. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  199. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  200. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  201. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  202. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  203. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
  204. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
  205. package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
  206. package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
  207. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
  208. package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
  209. package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
  210. package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
  211. package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
  212. package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
  213. package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
  214. package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
  215. package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
  216. package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
  217. package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
  218. package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
  219. package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
  220. package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
  221. package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
  222. package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
  223. package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
  224. package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
  225. package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
  226. package/dist/server/index.js +0 -13911
  227. package/src/assets/favicon-32.png +0 -0
  228. package/src/components/agentation.tsx +0 -34
  229. package/src/entry.ts +0 -19
  230. package/src/routeTree.gen.ts +0 -367
  231. package/src/routes/__root.tsx +0 -169
  232. package/src/routes/access.tsx +0 -11
  233. package/src/routes/index.tsx +0 -15
  234. package/src/routes/users.$user.tsx +0 -13
  235. package/src/types.ts +0 -21
@@ -0,0 +1,376 @@
1
+ import { c as statusOf, l as uiResult, s as memberRef } from "./page-C5HcNqf2.js";
2
+ import { QueryClient, queryOptions } from "@tanstack/react-query";
3
+ //#region src/lib/capabilities.ts
4
+ var NONE = {
5
+ canManageGrants: false,
6
+ canReadAudit: false,
7
+ canCreateProject: false
8
+ };
9
+ function deriveUiCapabilities(me, projects) {
10
+ if (me === null) return NONE;
11
+ const canManageInstance = me.instanceRole === "owner" || me.instanceRole === "root-admin";
12
+ return {
13
+ canManageGrants: canManageInstance,
14
+ canReadAudit: me.canReadAudit,
15
+ canCreateProject: canManageInstance
16
+ };
17
+ }
18
+ /** Secret values are available only where the API reports secret.read. */
19
+ function canRevealSecrets(permissions) {
20
+ return permissions.includes("secret.read");
21
+ }
22
+ //#endregion
23
+ //#region src/lib/queries.ts
24
+ /**
25
+ * Every read the pages make, cached by TanStack Query: one cache per request
26
+ * on the server, whose reads the page carries to the browser's, and one in the
27
+ * browser for the whole visit.
28
+ *
29
+ * How fresh a page is. A read is reused for `FRESH_MS`, refetched when the
30
+ * window regains focus, and refetched at once by any change made here, which
31
+ * names what it touches (`affects`), so your own changes always show.
32
+ * Someone else's change shows within that window. Nothing is decided on a
33
+ * cached read: the server authorizes every call, so a stale screen can offer
34
+ * an action the server then refuses, never grant one. The audit log and the
35
+ * chain's verification are the exception, read fresh on every visit: their
36
+ * whole point is to be current.
37
+ */
38
+ var FRESH_MS = 1e4;
39
+ function createQueryClient() {
40
+ return new QueryClient({ defaultOptions: { queries: {
41
+ staleTime: FRESH_MS,
42
+ refetchOnWindowFocus: true,
43
+ retry: false
44
+ } } });
45
+ }
46
+ /**
47
+ * The keys, which `affects` names too. A project's keys start with it, so
48
+ * one invalidation covers everything read under it.
49
+ */
50
+ var keys = {
51
+ me: ["me"],
52
+ auth: ["auth"],
53
+ projects: ["projects"],
54
+ grants: (project) => ["grants", project],
55
+ secrets: ({ project, environment }) => [
56
+ "secrets",
57
+ project,
58
+ environment
59
+ ],
60
+ directory: ["directory"],
61
+ report: (member) => ["report", member],
62
+ credentials: (member) => ["credentials", member],
63
+ bindings: (member) => ["bindings", member],
64
+ identities: ["identities"],
65
+ sessions: ["sessions"],
66
+ audit: ["audit"]
67
+ };
68
+ /** One member's grants, as rows. */
69
+ function grantRows(members) {
70
+ return members.flatMap((member) => member.grants.map((grant) => ({
71
+ id: grant.id,
72
+ principalType: member.principalType,
73
+ principalId: member.principalId,
74
+ role: grant.role,
75
+ roleName: grant.roleName,
76
+ permissions: grant.permissions,
77
+ scope: grant.environment === null ? "project" : "environment",
78
+ environmentSlug: grant.environment,
79
+ expiresAt: grant.expiresAt
80
+ })));
81
+ }
82
+ function listDirectory(client) {
83
+ return uiResult(async () => {
84
+ const { members, removed } = await client.members.list();
85
+ return {
86
+ principals: members.map(({ principalType, principalId, instanceRole, isRootAdmin, tampered }) => ({
87
+ principalType,
88
+ principalId,
89
+ instanceRole,
90
+ isRootAdmin,
91
+ tampered
92
+ })),
93
+ removed
94
+ };
95
+ });
96
+ }
97
+ var readProjects = (client) => uiResult(() => client.projects.list());
98
+ var queries = {
99
+ /** Who is looking; null when nobody is signed in. */
100
+ me: (client) => queryOptions({
101
+ queryKey: keys.me,
102
+ queryFn: async () => {
103
+ try {
104
+ return await client.me();
105
+ } catch (error) {
106
+ if (statusOf(error) === 401) return null;
107
+ throw error;
108
+ }
109
+ }
110
+ }),
111
+ /** How this instance signs people in. */
112
+ auth: (client) => queryOptions({
113
+ queryKey: keys.auth,
114
+ queryFn: () => client.auth()
115
+ }),
116
+ /** The projects you can see, each with its distinct secret count. */
117
+ projects: (client) => queryOptions({
118
+ queryKey: keys.projects,
119
+ queryFn: () => readProjects(client)
120
+ }),
121
+ /** Who holds what in a project, for those who manage its access. */
122
+ grants: (client, project) => queryOptions({
123
+ queryKey: keys.grants(project),
124
+ queryFn: () => uiResult(async () => ({ grants: grantRows((await client.members.list(project)).members) }))
125
+ }),
126
+ secrets: (client, place) => queryOptions({
127
+ queryKey: keys.secrets(place),
128
+ queryFn: () => uiResult(() => client.secrets.list(`${place.project}/${place.environment}`))
129
+ }),
130
+ /**
131
+ * Everyone in the directory, and who was removed. The API shows grant
132
+ * managers the members of their projects; the directory pages stay the
133
+ * owners' own, and asking for anyone else would only log a refusal, so
134
+ * nobody else is asked.
135
+ */
136
+ directory: (client, owner) => queryOptions({
137
+ queryKey: [...keys.directory, { owner }],
138
+ queryFn: () => owner ? listDirectory(client) : Promise.resolve({
139
+ ok: false,
140
+ error: "Only owners can manage users and service accounts.",
141
+ signedOut: false
142
+ })
143
+ }),
144
+ /** What one member can reach and has seen; null for anyone but owners, who alone may ask. */
145
+ report: (client, member, owner) => queryOptions({
146
+ queryKey: [...keys.report(member), { owner }],
147
+ queryFn: () => owner ? uiResult(async () => {
148
+ try {
149
+ return { report: await client.members.get(member) };
150
+ } catch (error) {
151
+ if (statusOf(error) === 404) return { report: null };
152
+ throw error;
153
+ }
154
+ }) : Promise.resolve(null)
155
+ }),
156
+ /**
157
+ * A token's credentials; null where they cannot be listed. Only owners
158
+ * issue and see them, and only coffre's own sign-in issues any.
159
+ */
160
+ credentials: (client, member, allowed) => queryOptions({
161
+ queryKey: [...keys.credentials(member), { allowed }],
162
+ queryFn: () => allowed ? uiResult(() => client.tokens.list(member)) : Promise.resolve(null)
163
+ }),
164
+ /**
165
+ * A token's trust bindings: the CI runs that may sign in as it. Null for
166
+ * anyone but an owner; a failure where the deployment trusts no workloads,
167
+ * which the page reads as nothing to show. Whether it does is not public.
168
+ */
169
+ bindings: (client, member, allowed) => queryOptions({
170
+ queryKey: [...keys.bindings(member), { allowed }],
171
+ queryFn: () => allowed ? uiResult(() => client.bindings.list(member)) : Promise.resolve(null)
172
+ }),
173
+ /** The accounts you sign in with, under coffre's own sign-in. */
174
+ identities: (client) => queryOptions({
175
+ queryKey: keys.identities,
176
+ queryFn: () => uiResult(() => client.identities.list())
177
+ }),
178
+ /** Where you are signed in, under coffre's own sign-in. */
179
+ sessions: (client) => queryOptions({
180
+ queryKey: keys.sessions,
181
+ queryFn: () => uiResult(() => client.sessions.list())
182
+ }),
183
+ /** A page of the log, as filtered: always read fresh. */
184
+ auditEntries: (client, search) => queryOptions({
185
+ queryKey: [
186
+ ...keys.audit,
187
+ "entries",
188
+ search
189
+ ],
190
+ staleTime: 0,
191
+ queryFn: () => uiResult(() => client.audit.list({
192
+ limit: 200,
193
+ decision: search.decision,
194
+ actor: search.actorId,
195
+ detail: search.detail
196
+ }))
197
+ }),
198
+ /**
199
+ * Whether the log holds: verified on every visit, and never waited for.
200
+ * It re-reads the whole log, so it takes as long as the log is long; the
201
+ * page shows the entries first and the verdict when it comes.
202
+ */
203
+ auditChain: (client) => queryOptions({
204
+ queryKey: [...keys.audit, "chain"],
205
+ staleTime: 0,
206
+ queryFn: () => verifyChain(client)
207
+ })
208
+ };
209
+ /**
210
+ * Whether the log holds, or why that is not known. Verifying is for owners:
211
+ * anyone else reads their projects' part of the log, and a part cannot be
212
+ * checked as a chain, so for them it is a fact about the page, not a fault.
213
+ */
214
+ async function verifyChain(client) {
215
+ try {
216
+ const result = await client.audit.verify();
217
+ return result.ok ? {
218
+ integrity: "intact",
219
+ through: result.through,
220
+ entries: result.entries,
221
+ checkpoint: result.checkpoint,
222
+ pending: result.pending ?? 0
223
+ } : {
224
+ integrity: "broken",
225
+ through: result.through,
226
+ failedAtSeq: result.failedAtSeq,
227
+ author: result.author,
228
+ reason: result.reason
229
+ };
230
+ } catch (error) {
231
+ const status = statusOf(error);
232
+ if (status === 403) return { integrity: "owners-only" };
233
+ return {
234
+ integrity: "unknown",
235
+ problem: status === void 0 ? "the request never got an answer" : `the request failed with HTTP ${status}`
236
+ };
237
+ }
238
+ }
239
+ /**
240
+ * Who is looking, how this instance signs people in, and the projects they
241
+ * can see: what the shell needs on every screen. For someone signed out or
242
+ * not yet a member the project list is refused, and they get the sign-in or
243
+ * closed-door page.
244
+ */
245
+ function shellOf(auth, me, projects) {
246
+ const listed = projects.ok ? projects.projects : [];
247
+ const member = me?.registered === true ? me : null;
248
+ return {
249
+ auth,
250
+ principal: me === null ? null : me.principal,
251
+ instanceRole: member?.instanceRole ?? null,
252
+ projects: listed,
253
+ capabilities: deriveUiCapabilities(member, listed),
254
+ registrationRequired: me !== null && !me.registered,
255
+ /** The deployment's version and migrations: told to owners and root admins only. */
256
+ instance: member?.instance ?? null,
257
+ /** A member the vault refuses: their record failed its integrity check. */
258
+ accessTampered: me?.tampered === true
259
+ };
260
+ }
261
+ /**
262
+ * The shell, as every loader reads it: from the cache while fresh, so a
263
+ * child route never asks again for what the root has.
264
+ */
265
+ async function loadShell(queryClient, client) {
266
+ const [auth, me, projects] = await Promise.all([
267
+ queryClient.fetchQuery(queries.auth(client)),
268
+ queryClient.fetchQuery(queries.me(client)),
269
+ queryClient.fetchQuery(queries.projects(client))
270
+ ]);
271
+ return shellOf(auth, me, projects);
272
+ }
273
+ /**
274
+ * One project and, when you manage its access, its grants. A project that is
275
+ * not there for you fails with no message: the page words that itself.
276
+ */
277
+ function projectOf(projects, slug) {
278
+ if (!projects.ok) return projects;
279
+ const project = projects.projects.find((entry) => entry.slug === slug);
280
+ if (project === void 0) return {
281
+ ok: false,
282
+ error: null
283
+ };
284
+ return {
285
+ ok: true,
286
+ project,
287
+ managesAccess: project.permissions.includes("grant.manage")
288
+ };
289
+ }
290
+ /** What a project page reads: the project list, and its grants when you manage them. */
291
+ async function loadProject(queryClient, client, slug) {
292
+ const found = projectOf(await queryClient.fetchQuery(queries.projects(client)), slug);
293
+ if (found.ok && found.managesAccess) await queryClient.fetchQuery(queries.grants(client, slug));
294
+ }
295
+ /** The directory pages' read: the directory, for owners. */
296
+ async function loadDirectory(queryClient, client) {
297
+ const shell = await loadShell(queryClient, client);
298
+ return queryClient.fetchQuery(queries.directory(client, shell.capabilities.canManageGrants));
299
+ }
300
+ /**
301
+ * Everything one user's or token's page reads: the report (owners only), the
302
+ * grants of every project where you manage access, and a token's
303
+ * credentials. There is no "grants of this member" call, so each project you
304
+ * manage is asked for its grants and the page keeps this member's. Projects
305
+ * where you do not hold grant.manage are skipped rather than asked: the
306
+ * refusal would land in the audit log as a denial in your name.
307
+ */
308
+ async function loadPrincipal(queryClient, client, principalType, principalId) {
309
+ const shell = await loadShell(queryClient, client);
310
+ const member = memberRef(principalType, principalId);
311
+ const owner = shell.capabilities.canManageGrants;
312
+ await Promise.all([
313
+ queryClient.fetchQuery(queries.report(client, member, owner)),
314
+ principalType === "service" ? queryClient.fetchQuery(queries.credentials(client, member, owner && shell.auth.signin !== null)) : null,
315
+ principalType === "service" ? queryClient.fetchQuery(queries.bindings(client, member, owner && shell.auth.signin !== null)) : null,
316
+ ...managedProjects(shell.projects).map((project) => queryClient.fetchQuery(queries.grants(client, project.slug)))
317
+ ]);
318
+ }
319
+ function managedProjects(projects) {
320
+ return projects.filter((project) => project.permissions.includes("grant.manage"));
321
+ }
322
+ /**
323
+ * What each change touches, which `useAction` refetches when it lands. Every
324
+ * change also lands in the audit log, which is always read fresh.
325
+ */
326
+ var affects = {
327
+ /** A project or environment made, renamed or archived: the tree, and where you hold access. */
328
+ places: () => [keys.projects, keys.me],
329
+ /** Secrets written, renamed, restored or archived: the environment and the counts. */
330
+ secrets: (place) => [keys.secrets(place), keys.projects],
331
+ /**
332
+ * Someone's access in a project changed: its grants, their report, and, as
333
+ * it may be your own, what you can see.
334
+ */
335
+ access: (project, member) => [
336
+ keys.grants(project),
337
+ keys.report(member),
338
+ keys.projects,
339
+ keys.me
340
+ ],
341
+ /** Someone let in: the directory. */
342
+ admission: () => [keys.directory],
343
+ /**
344
+ * An instance role changed: the directory, their report, and, as it may be
345
+ * your own, what you can see and do.
346
+ */
347
+ role: (member) => [
348
+ keys.directory,
349
+ keys.report(member),
350
+ keys.me,
351
+ keys.projects
352
+ ],
353
+ /** Someone removed: the directory, their report, and every project's grants, which removal ends. */
354
+ removal: (member) => [
355
+ keys.directory,
356
+ keys.report(member),
357
+ ["grants"]
358
+ ],
359
+ credentials: (member) => [keys.credentials(member)],
360
+ bindings: (member) => [keys.bindings(member)],
361
+ /** Unlinking an account also ends the sessions it signed in. */
362
+ identities: () => [keys.identities, keys.sessions],
363
+ sessions: () => [keys.sessions]
364
+ };
365
+ /**
366
+ * Refetch what a change touched: at once where it is on screen, on next use
367
+ * elsewhere. Every change lands in the audit log, so the log and its
368
+ * verification are always among them.
369
+ */
370
+ async function refresh(queryClient, touched) {
371
+ await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));
372
+ }
373
+ //#endregion
374
+ export { loadPrincipal as a, managedProjects as c, refresh as d, shellOf as f, loadDirectory as i, projectOf as l, createQueryClient as n, loadProject as o, canRevealSecrets as p, keys as r, loadShell as s, affects as t, queries as u };
375
+
376
+ //# sourceMappingURL=queries-CQ81o4so.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries-CQ81o4so.js","names":[],"sources":["../../src/lib/capabilities.ts","../../src/lib/queries.ts"],"sourcesContent":["import type { Me, Permission, ProjectSummary } from '../shared/models';\n\n/**\n * The small set of instance-wide decisions the shell has to make.\n *\n * Resource-specific controls still use the permissions returned for that\n * project or environment. These are only the capabilities whose affordances\n * live outside one resource page.\n */\nexport type UiCapabilities = {\n canManageGrants: boolean;\n canReadAudit: boolean;\n canCreateProject: boolean;\n};\n\nconst NONE: UiCapabilities = {\n canManageGrants: false,\n canReadAudit: false,\n canCreateProject: false,\n};\n\nexport function deriveUiCapabilities(\n me: Me | null,\n projects: readonly ProjectSummary[],\n): UiCapabilities {\n if (me === null) return NONE;\n\n const canManageInstance =\n me.instanceRole === 'owner' || me.instanceRole === 'root-admin';\n\n return {\n // Users and Tokens manage the instance directory, not project grants.\n // Project access managers keep their grant controls on each project page.\n canManageGrants: canManageInstance,\n canReadAudit: me.canReadAudit,\n // Project creation has no resource on which to hold a grant, so it follows\n // the instance-wide owner role (including configured root admins).\n canCreateProject: canManageInstance,\n };\n}\n\n/** Secret values are available only where the API reports secret.read. */\nexport function canRevealSecrets(permissions: readonly Permission[]): boolean {\n return permissions.includes('secret.read');\n}\n","import type { AuthInfo, CoffreClient, Member } from '@coffre/client';\nimport { QueryClient, queryOptions, type QueryKey } from '@tanstack/react-query';\n\nimport { deriveUiCapabilities } from './capabilities.ts';\nimport { memberRef, statusOf, uiResult } from './coffre.ts';\nimport type { DirectoryPrincipal, GrantRow, Me, ProjectSummary } from '../shared/models';\n\n/**\n * Every read the pages make, cached by TanStack Query: one cache per request\n * on the server, whose reads the page carries to the browser's, and one in the\n * browser for the whole visit.\n *\n * How fresh a page is. A read is reused for `FRESH_MS`, refetched when the\n * window regains focus, and refetched at once by any change made here, which\n * names what it touches (`affects`), so your own changes always show.\n * Someone else's change shows within that window. Nothing is decided on a\n * cached read: the server authorizes every call, so a stale screen can offer\n * an action the server then refuses, never grant one. The audit log and the\n * chain's verification are the exception, read fresh on every visit: their\n * whole point is to be current.\n */\nexport const FRESH_MS = 10_000;\n\nexport function createQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: FRESH_MS,\n refetchOnWindowFocus: true,\n // A read either answers or says why it cannot (`uiResult`), so a\n // throw is a fault, and asking again would only repeat it.\n retry: false,\n },\n },\n });\n}\n\ntype Place = { project: string; environment: string };\n\n/**\n * The keys, which `affects` names too. A project's keys start with it, so\n * one invalidation covers everything read under it.\n */\nexport const keys = {\n me: ['me'],\n auth: ['auth'],\n projects: ['projects'],\n grants: (project: string) => ['grants', project],\n secrets: ({ project, environment }: Place) => ['secrets', project, environment],\n directory: ['directory'],\n report: (member: string) => ['report', member],\n credentials: (member: string) => ['credentials', member],\n bindings: (member: string) => ['bindings', member],\n identities: ['identities'],\n sessions: ['sessions'],\n audit: ['audit'],\n} satisfies Record<string, QueryKey | ((...args: never[]) => QueryKey)>;\n\n/** One member's grants, as rows. */\nfunction grantRows(members: Member[]): GrantRow[] {\n return members.flatMap((member) =>\n member.grants.map((grant) => ({\n id: grant.id,\n principalType: member.principalType,\n principalId: member.principalId,\n role: grant.role,\n roleName: grant.roleName,\n permissions: grant.permissions,\n scope: grant.environment === null ? ('project' as const) : ('environment' as const),\n environmentSlug: grant.environment,\n expiresAt: grant.expiresAt,\n })),\n );\n}\n\nfunction listDirectory(client: CoffreClient) {\n return uiResult(async () => {\n const { members, removed } = await client.members.list();\n const principals: DirectoryPrincipal[] = members.map(\n ({ principalType, principalId, instanceRole, isRootAdmin, tampered }) => ({\n principalType,\n principalId,\n instanceRole,\n isRootAdmin,\n tampered,\n }),\n );\n return { principals, removed };\n });\n}\n\nconst readProjects = (client: CoffreClient) => uiResult(() => client.projects.list());\n\n/** The projects you can see, or why they could not be listed. */\nexport type ProjectsResult = Awaited<ReturnType<typeof readProjects>>;\n\nexport type AuditSearch = { decision?: 'deny'; actorId?: string; detail?: '1' };\n\nexport const AUDIT_PAGE_SIZE = 200;\n\nexport const queries = {\n /** Who is looking; null when nobody is signed in. */\n me: (client: CoffreClient) =>\n queryOptions({\n queryKey: keys.me,\n queryFn: async (): Promise<Me | null> => {\n try {\n return await client.me();\n } catch (error) {\n if (statusOf(error) === 401) return null;\n throw error;\n }\n },\n }),\n\n /** How this instance signs people in. */\n auth: (client: CoffreClient) => queryOptions({ queryKey: keys.auth, queryFn: (): Promise<AuthInfo> => client.auth() }),\n\n /** The projects you can see, each with its distinct secret count. */\n projects: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.projects, queryFn: () => readProjects(client) }),\n\n /** Who holds what in a project, for those who manage its access. */\n grants: (client: CoffreClient, project: string) =>\n queryOptions({\n queryKey: keys.grants(project),\n queryFn: () => uiResult(async () => ({ grants: grantRows((await client.members.list(project)).members) })),\n }),\n\n secrets: (client: CoffreClient, place: Place) =>\n queryOptions({\n queryKey: keys.secrets(place),\n queryFn: () => uiResult(() => client.secrets.list(`${place.project}/${place.environment}`)),\n }),\n\n /**\n * Everyone in the directory, and who was removed. The API shows grant\n * managers the members of their projects; the directory pages stay the\n * owners' own, and asking for anyone else would only log a refusal, so\n * nobody else is asked.\n */\n directory: (client: CoffreClient, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.directory, { owner }],\n queryFn: () =>\n owner\n ? listDirectory(client)\n : Promise.resolve({\n ok: false as const,\n error: 'Only owners can manage users and service accounts.',\n signedOut: false,\n }),\n }),\n\n /** What one member can reach and has seen; null for anyone but owners, who alone may ask. */\n report: (client: CoffreClient, member: string, owner: boolean) =>\n queryOptions({\n queryKey: [...keys.report(member), { owner }],\n queryFn: () =>\n owner\n ? uiResult(async () => {\n try {\n return { report: await client.members.get(member) };\n } catch (error) {\n // No such member is an answer, not a failure.\n if (statusOf(error) === 404) return { report: null };\n throw error;\n }\n })\n : Promise.resolve(null),\n }),\n\n /**\n * A token's credentials; null where they cannot be listed. Only owners\n * issue and see them, and only coffre's own sign-in issues any.\n */\n credentials: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.credentials(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.tokens.list(member)) : Promise.resolve(null)),\n }),\n\n /**\n * A token's trust bindings: the CI runs that may sign in as it. Null for\n * anyone but an owner; a failure where the deployment trusts no workloads,\n * which the page reads as nothing to show. Whether it does is not public.\n */\n bindings: (client: CoffreClient, member: string, allowed: boolean) =>\n queryOptions({\n queryKey: [...keys.bindings(member), { allowed }],\n queryFn: () => (allowed ? uiResult(() => client.bindings.list(member)) : Promise.resolve(null)),\n }),\n\n /** The accounts you sign in with, under coffre's own sign-in. */\n identities: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.identities, queryFn: () => uiResult(() => client.identities.list()) }),\n\n /** Where you are signed in, under coffre's own sign-in. */\n sessions: (client: CoffreClient) =>\n queryOptions({ queryKey: keys.sessions, queryFn: () => uiResult(() => client.sessions.list()) }),\n\n /** A page of the log, as filtered: always read fresh. */\n auditEntries: (client: CoffreClient, search: AuditSearch) =>\n queryOptions({\n queryKey: [...keys.audit, 'entries', search],\n staleTime: 0,\n // Detail is left out by the server unless asked for, and counted.\n queryFn: () =>\n uiResult(() =>\n client.audit.list({\n limit: AUDIT_PAGE_SIZE,\n decision: search.decision,\n actor: search.actorId,\n detail: search.detail,\n }),\n ),\n }),\n\n /**\n * Whether the log holds: verified on every visit, and never waited for.\n * It re-reads the whole log, so it takes as long as the log is long; the\n * page shows the entries first and the verdict when it comes.\n */\n auditChain: (client: CoffreClient) =>\n queryOptions({ queryKey: [...keys.audit, 'chain'], staleTime: 0, queryFn: () => verifyChain(client) }),\n};\n\n/**\n * Whether the log holds, or why that is not known. Verifying is for owners:\n * anyone else reads their projects' part of the log, and a part cannot be\n * checked as a chain, so for them it is a fact about the page, not a fault.\n */\nasync function verifyChain(client: CoffreClient) {\n try {\n const result = await client.audit.verify();\n return result.ok\n ? {\n integrity: 'intact' as const,\n through: result.through,\n entries: result.entries,\n checkpoint: result.checkpoint,\n pending: result.pending ?? 0,\n }\n : {\n integrity: 'broken' as const,\n through: result.through,\n failedAtSeq: result.failedAtSeq,\n author: result.author,\n reason: result.reason,\n };\n } catch (error) {\n const status = statusOf(error);\n if (status === 403) return { integrity: 'owners-only' as const };\n return {\n integrity: 'unknown' as const,\n problem: status === undefined ? 'the request never got an answer' : `the request failed with HTTP ${status}`,\n };\n }\n}\n\nexport type ChainResult = Awaited<ReturnType<typeof verifyChain>>;\n\n/**\n * Who is looking, how this instance signs people in, and the projects they\n * can see: what the shell needs on every screen. For someone signed out or\n * not yet a member the project list is refused, and they get the sign-in or\n * closed-door page.\n */\nexport function shellOf(\n auth: AuthInfo,\n me: Me | null,\n projects: ProjectsResult,\n) {\n const listed = projects.ok ? projects.projects : [];\n const member: Me | null = me?.registered === true ? me : null;\n return {\n auth,\n principal: me === null ? null : me.principal,\n instanceRole: member?.instanceRole ?? null,\n projects: listed,\n capabilities: deriveUiCapabilities(member, listed),\n registrationRequired: me !== null && !me.registered,\n /** The deployment's version and migrations: told to owners and root admins only. */\n instance: member?.instance ?? null,\n /** A member the vault refuses: their record failed its integrity check. */\n accessTampered: me?.tampered === true,\n };\n}\n\nexport type Shell = ReturnType<typeof shellOf>;\n\n/**\n * The shell, as every loader reads it: from the cache while fresh, so a\n * child route never asks again for what the root has.\n */\nexport async function loadShell(queryClient: QueryClient, client: CoffreClient): Promise<Shell> {\n const [auth, me, projects] = await Promise.all([\n queryClient.fetchQuery(queries.auth(client)),\n queryClient.fetchQuery(queries.me(client)),\n queryClient.fetchQuery(queries.projects(client)),\n ]);\n return shellOf(auth, me, projects);\n}\n\n/**\n * One project and, when you manage its access, its grants. A project that is\n * not there for you fails with no message: the page words that itself.\n */\nexport function projectOf(projects: ProjectsResult, slug: string) {\n if (!projects.ok) return projects;\n const project = projects.projects.find((entry) => entry.slug === slug);\n if (project === undefined) return { ok: false as const, error: null };\n return { ok: true as const, project, managesAccess: project.permissions.includes('grant.manage') };\n}\n\n/** What a project page reads: the project list, and its grants when you manage them. */\nexport async function loadProject(queryClient: QueryClient, client: CoffreClient, slug: string) {\n const found = projectOf(await queryClient.fetchQuery(queries.projects(client)), slug);\n if (found.ok && found.managesAccess) await queryClient.fetchQuery(queries.grants(client, slug));\n}\n\n/** The directory pages' read: the directory, for owners. */\nexport async function loadDirectory(queryClient: QueryClient, client: CoffreClient) {\n const shell = await loadShell(queryClient, client);\n return queryClient.fetchQuery(queries.directory(client, shell.capabilities.canManageGrants));\n}\n\n/**\n * Everything one user's or token's page reads: the report (owners only), the\n * grants of every project where you manage access, and a token's\n * credentials. There is no \"grants of this member\" call, so each project you\n * manage is asked for its grants and the page keeps this member's. Projects\n * where you do not hold grant.manage are skipped rather than asked: the\n * refusal would land in the audit log as a denial in your name.\n */\nexport async function loadPrincipal(\n queryClient: QueryClient,\n client: CoffreClient,\n principalType: 'user' | 'service',\n principalId: string,\n) {\n const shell = await loadShell(queryClient, client);\n const member = memberRef(principalType, principalId);\n const owner = shell.capabilities.canManageGrants;\n await Promise.all([\n queryClient.fetchQuery(queries.report(client, member, owner)),\n principalType === 'service'\n ? queryClient.fetchQuery(queries.credentials(client, member, owner && shell.auth.signin !== null))\n : null,\n principalType === 'service'\n ? queryClient.fetchQuery(queries.bindings(client, member, owner && shell.auth.signin !== null))\n : null,\n ...managedProjects(shell.projects).map((project) => queryClient.fetchQuery(queries.grants(client, project.slug))),\n ]);\n}\n\nexport function managedProjects(projects: ProjectSummary[]): ProjectSummary[] {\n return projects.filter((project) => project.permissions.includes('grant.manage'));\n}\n\n/**\n * What each change touches, which `useAction` refetches when it lands. Every\n * change also lands in the audit log, which is always read fresh.\n */\nexport const affects = {\n /** A project or environment made, renamed or archived: the tree, and where you hold access. */\n places: (): QueryKey[] => [keys.projects, keys.me],\n /** Secrets written, renamed, restored or archived: the environment and the counts. */\n secrets: (place: Place): QueryKey[] => [keys.secrets(place), keys.projects],\n /**\n * Someone's access in a project changed: its grants, their report, and, as\n * it may be your own, what you can see.\n */\n access: (project: string, member: string): QueryKey[] => [\n keys.grants(project),\n keys.report(member),\n keys.projects,\n keys.me,\n ],\n /** Someone let in: the directory. */\n admission: (): QueryKey[] => [keys.directory],\n /**\n * An instance role changed: the directory, their report, and, as it may be\n * your own, what you can see and do.\n */\n role: (member: string): QueryKey[] => [keys.directory, keys.report(member), keys.me, keys.projects],\n /** Someone removed: the directory, their report, and every project's grants, which removal ends. */\n removal: (member: string): QueryKey[] => [keys.directory, keys.report(member), ['grants']],\n credentials: (member: string): QueryKey[] => [keys.credentials(member)],\n bindings: (member: string): QueryKey[] => [keys.bindings(member)],\n /** Unlinking an account also ends the sessions it signed in. */\n identities: (): QueryKey[] => [keys.identities, keys.sessions],\n sessions: (): QueryKey[] => [keys.sessions],\n};\n\n/**\n * Refetch what a change touched: at once where it is on screen, on next use\n * elsewhere. Every change lands in the audit log, so the log and its\n * verification are always among them.\n */\nexport async function refresh(queryClient: QueryClient, touched: QueryKey[]): Promise<void> {\n await Promise.all([...touched, keys.audit].map((queryKey) => queryClient.invalidateQueries({ queryKey })));\n}\n"],"mappings":";;;AAeA,IAAM,OAAuB;CAC3B,iBAAiB;CACjB,cAAc;CACd,kBAAkB;AACpB;AAEA,SAAgB,qBACd,IACA,UACgB;CAChB,IAAI,OAAO,MAAM,OAAO;CAExB,MAAM,oBACJ,GAAG,iBAAiB,WAAW,GAAG,iBAAiB;CAErD,OAAO;EAGL,iBAAiB;EACjB,cAAc,GAAG;EAGjB,kBAAkB;CACpB;AACF;;AAGA,SAAgB,iBAAiB,aAA6C;CAC5E,OAAO,YAAY,SAAS,aAAa;AAC3C;;;;;;;;;;;;;;;;;ACvBA,IAAa,WAAW;AAExB,SAAgB,oBAAiC;CAC/C,OAAO,IAAI,YAAY,EACrB,gBAAgB,EACd,SAAS;EACP,WAAW;EACX,sBAAsB;EAGtB,OAAO;CACT,EACF,EACF,CAAC;AACH;;;;;AAQA,IAAa,OAAO;CAClB,IAAI,CAAC,IAAI;CACT,MAAM,CAAC,MAAM;CACb,UAAU,CAAC,UAAU;CACrB,SAAS,YAAoB,CAAC,UAAU,OAAO;CAC/C,UAAU,EAAE,SAAS,kBAAyB;EAAC;EAAW;EAAS;CAAW;CAC9E,WAAW,CAAC,WAAW;CACvB,SAAS,WAAmB,CAAC,UAAU,MAAM;CAC7C,cAAc,WAAmB,CAAC,eAAe,MAAM;CACvD,WAAW,WAAmB,CAAC,YAAY,MAAM;CACjD,YAAY,CAAC,YAAY;CACzB,UAAU,CAAC,UAAU;CACrB,OAAO,CAAC,OAAO;AACjB;;AAGA,SAAS,UAAU,SAA+B;CAChD,OAAO,QAAQ,SAAS,WACtB,OAAO,OAAO,KAAK,WAAW;EAC5B,IAAI,MAAM;EACV,eAAe,OAAO;EACtB,aAAa,OAAO;EACpB,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB,OAAO,MAAM,gBAAgB,OAAQ,YAAuB;EAC5D,iBAAiB,MAA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,gBAAgB,UAA8C;CAC5E,OAAO,SAAS,QAAQ,YAAY,QAAQ,YAAY,SAAS,cAAc,CAAC;AAClF;;;;;AAMA,IAAa,UAAU;;CAErB,cAA0B,CAAC,KAAK,UAAU,KAAK,EAAE;;CAEjD,UAAU,UAA6B,CAAC,KAAK,QAAQ,KAAK,GAAG,KAAK,QAAQ;;;;;CAK1E,SAAS,SAAiB,WAA+B;EACvD,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,MAAM;EAClB,KAAK;EACL,KAAK;CACP;;CAEA,iBAA6B,CAAC,KAAK,SAAS;;;;;CAK5C,OAAO,WAA+B;EAAC,KAAK;EAAW,KAAK,OAAO,MAAM;EAAG,KAAK;EAAI,KAAK;CAAQ;;CAElG,UAAU,WAA+B;EAAC,KAAK;EAAW,KAAK,OAAO,MAAM;EAAG,CAAC,QAAQ;CAAC;CACzF,cAAc,WAA+B,CAAC,KAAK,YAAY,MAAM,CAAC;CACtE,WAAW,WAA+B,CAAC,KAAK,SAAS,MAAM,CAAC;;CAEhE,kBAA8B,CAAC,KAAK,YAAY,KAAK,QAAQ;CAC7D,gBAA4B,CAAC,KAAK,QAAQ;AAC5C;;;;;;AAOA,eAAsB,QAAQ,aAA0B,SAAoC;CAC1F,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,KAAK,aAAa,YAAY,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3G"}
@@ -1,8 +1,8 @@
1
- import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
- import { c as Spinner } from "./ui-Cc0CGMtr.js";
3
- import { G as X, n as AlertCircle } from "./icons-DOFT-eWB.js";
1
+ import { l as Spinner } from "./ui-DixXLQvQ.js";
2
+ import { G as X, n as AlertCircle } from "./icons-D-PfAfnH.js";
3
+ import { useSyncExternalStore } from "react";
4
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
4
5
  //#region src/lib/announce.ts
5
- var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
6
6
  var heard = {
7
7
  polite: null,
8
8
  urgent: null
@@ -40,7 +40,6 @@ function serverAnnouncements() {
40
40
  }
41
41
  //#endregion
42
42
  //#region src/components/row-state.tsx
43
- var import_jsx_runtime = require_jsx_runtime();
44
43
  /**
45
44
  * How a row looks while a change to it is on its way, or after the server
46
45
  * refused it. Never colour alone: a waiting row is quieter and says what it
@@ -55,19 +54,19 @@ function rowClass(status) {
55
54
  /** In place of a row's actions while its change is on its way. */
56
55
  function RowPending({ status }) {
57
56
  if (status.state !== "pending") return null;
58
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
57
+ return /* @__PURE__ */ jsxs("span", {
59
58
  className: "row-pending",
60
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 13 }), status.words.pending]
59
+ children: [/* @__PURE__ */ jsx(Spinner, { size: 13 }), status.words.pending]
61
60
  });
62
61
  }
63
62
  /** Beneath a row whose change the server refused: why, until dismissed. */
64
63
  function RowFailure({ status, columns, onDismiss, children }) {
65
64
  if (status.state !== "failed") return null;
66
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", {
65
+ return /* @__PURE__ */ jsx("tr", {
67
66
  className: "row-error row-failure",
68
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
67
+ children: /* @__PURE__ */ jsx("td", {
69
68
  colSpan: columns,
70
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFailure, {
69
+ children: /* @__PURE__ */ jsx(ItemFailure, {
71
70
  status,
72
71
  onDismiss,
73
72
  children
@@ -78,40 +77,42 @@ function RowFailure({ status, columns, onDismiss, children }) {
78
77
  /** Why the server refused a change, where it shows: under a row, or in a card. */
79
78
  function ItemFailure({ status, onDismiss, children }) {
80
79
  if (status.state !== "failed") return null;
81
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
80
+ return /* @__PURE__ */ jsxs("div", {
82
81
  className: "row-failure-line",
83
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
82
+ children: [/* @__PURE__ */ jsxs("p", {
84
83
  className: "error-line",
85
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertCircle, { size: 14 }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
86
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: children ?? status.words.failed }),
84
+ children: [/* @__PURE__ */ jsx(AlertCircle, { size: 14 }), /* @__PURE__ */ jsxs("span", { children: [
85
+ /* @__PURE__ */ jsx("strong", { children: children ?? status.words.failed }),
87
86
  " ",
88
87
  status.error
89
88
  ] })]
90
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
89
+ }), /* @__PURE__ */ jsx("button", {
91
90
  type: "button",
92
91
  className: "act act-quiet",
93
92
  onClick: onDismiss,
94
93
  "aria-label": "Dismiss",
95
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(X, { size: 13 })
94
+ children: /* @__PURE__ */ jsx(X, { size: 13 })
96
95
  })]
97
96
  });
98
97
  }
99
98
  /** Where changes are announced to screen readers (`lib/announce.ts`). */
100
99
  function LiveRegion() {
101
- const { polite, urgent } = (0, import_react.useSyncExternalStore)(subscribeAnnouncements, announcements, serverAnnouncements);
102
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
100
+ const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);
101
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
103
102
  className: "visually-hidden",
104
103
  role: "status",
105
104
  "aria-live": "polite",
106
105
  "aria-atomic": "true",
107
- children: polite !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: polite.text }, polite.id)
108
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
106
+ children: polite !== null && /* @__PURE__ */ jsx("span", { children: polite.text }, polite.id)
107
+ }), /* @__PURE__ */ jsx("div", {
109
108
  className: "visually-hidden",
110
109
  role: "alert",
111
110
  "aria-live": "assertive",
112
111
  "aria-atomic": "true",
113
- children: urgent !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: urgent.text }, urgent.id)
112
+ children: urgent !== null && /* @__PURE__ */ jsx("span", { children: urgent.text }, urgent.id)
114
113
  })] });
115
114
  }
116
115
  //#endregion
117
116
  export { rowClass as a, RowPending as i, LiveRegion as n, announce as o, RowFailure as r, ItemFailure as t };
117
+
118
+ //# sourceMappingURL=row-state-0PsrEzOL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row-state-0PsrEzOL.js","names":[],"sources":["../../src/lib/announce.ts","../../src/components/row-state.tsx"],"sourcesContent":["/**\n * What a screen reader hears of a change: that it is on its way, that it\n * landed, or why it did not. Changes show on screen as dimmed or struck-out\n * rows; this says the same in words, through two live regions in the shell\n * (`LiveRegion`), one polite and one for failures, which interrupts.\n */\nexport type Announcement = { text: string; id: number };\n\ntype Heard = { polite: Announcement | null; urgent: Announcement | null };\n\nlet heard: Heard = { polite: null, urgent: null };\nlet next = 0;\nconst listeners = new Set<() => void>();\n\nexport function announce(text: string, { urgent = false }: { urgent?: boolean } = {}): void {\n // A fresh id, so the same words said twice are heard twice.\n const said = { text, id: next++ };\n heard = urgent ? { ...heard, urgent: said } : { ...heard, polite: said };\n for (const listener of listeners) listener();\n}\n\nexport function subscribeAnnouncements(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nexport function announcements(): Heard {\n return heard;\n}\n\nconst nobody: Heard = { polite: null, urgent: null };\n\n/** On the server nothing has been said yet. */\nexport function serverAnnouncements(): Heard {\n return nobody;\n}\n","import { useSyncExternalStore, type ReactNode } from 'react';\n\nimport { announcements, serverAnnouncements, subscribeAnnouncements } from '../lib/announce';\nimport type { ItemStatus } from '../lib/optimistic';\nimport { Spinner } from './ui';\nimport { AlertCircle, X } from './icons';\n\n/**\n * How a row looks while a change to it is on its way, or after the server\n * refused it. Never colour alone: a waiting row is quieter and says what it\n * waits for, a row being removed is struck through as well, and a refused\n * change says so in words beneath its row.\n */\nexport function rowClass(status: ItemStatus): string {\n if (status.state === 'pending') return status.kind === 'removing' ? 'is-removing' : 'is-saving';\n if (status.state === 'failed') return 'is-failed';\n return '';\n}\n\n/** In place of a row's actions while its change is on its way. */\nexport function RowPending({ status }: { status: ItemStatus }) {\n if (status.state !== 'pending') return null;\n return (\n <span className=\"row-pending\">\n <Spinner size={13} />\n {status.words.pending}\n </span>\n );\n}\n\n/** Beneath a row whose change the server refused: why, until dismissed. */\nexport function RowFailure({\n status,\n columns,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n columns: number;\n onDismiss: () => void;\n /** Said before the reason; by default, what did not happen. */\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <tr className=\"row-error row-failure\">\n <td colSpan={columns}>\n <ItemFailure status={status} onDismiss={onDismiss}>\n {children}\n </ItemFailure>\n </td>\n </tr>\n );\n}\n\n/** Why the server refused a change, where it shows: under a row, or in a card. */\nexport function ItemFailure({\n status,\n onDismiss,\n children,\n}: {\n status: ItemStatus;\n onDismiss: () => void;\n children?: ReactNode;\n}) {\n if (status.state !== 'failed') return null;\n return (\n <div className=\"row-failure-line\">\n <p className=\"error-line\">\n <AlertCircle size={14} />\n <span>\n <strong>{children ?? status.words.failed}</strong> {status.error}\n </span>\n </p>\n <button type=\"button\" className=\"act act-quiet\" onClick={onDismiss} aria-label=\"Dismiss\">\n <X size={13} />\n </button>\n </div>\n );\n}\n\n/** Where changes are announced to screen readers (`lib/announce.ts`). */\nexport function LiveRegion() {\n const { polite, urgent } = useSyncExternalStore(subscribeAnnouncements, announcements, serverAnnouncements);\n return (\n <>\n <div className=\"visually-hidden\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {polite !== null && <span key={polite.id}>{polite.text}</span>}\n </div>\n <div className=\"visually-hidden\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {urgent !== null && <span key={urgent.id}>{urgent.text}</span>}\n </div>\n </>\n );\n}\n"],"mappings":";;;;;AAUA,IAAI,QAAe;CAAE,QAAQ;CAAM,QAAQ;AAAK;AAChD,IAAI,OAAO;AACX,IAAM,4BAAY,IAAI,IAAgB;AAEtC,SAAgB,SAAS,MAAc,EAAE,SAAS,UAAgC,CAAC,GAAS;CAE1F,MAAM,OAAO;EAAE;EAAM,IAAI;CAAO;CAChC,QAAQ,SAAS;EAAE,GAAG;EAAO,QAAQ;CAAK,IAAI;EAAE,GAAG;EAAO,QAAQ;CAAK;CACvE,KAAK,MAAM,YAAY,WAAW,SAAS;AAC7C;AAEA,SAAgB,uBAAuB,UAAkC;CACvE,UAAU,IAAI,QAAQ;CACtB,aAAa,UAAU,OAAO,QAAQ;AACxC;AAEA,SAAgB,gBAAuB;CACrC,OAAO;AACT;AAEA,IAAM,SAAgB;CAAE,QAAQ;CAAM,QAAQ;AAAK;;AAGnD,SAAgB,sBAA6B;CAC3C,OAAO;AACT;;;;;;;;;ACtBA,SAAgB,SAAS,QAA4B;CACnD,IAAI,OAAO,UAAU,WAAW,OAAO,OAAO,SAAS,aAAa,gBAAgB;CACpF,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO;AACT;;AAGA,SAAgB,WAAW,EAAE,UAAkC;CAC7D,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,oBAAC,SAAD,EAAS,MAAM,GAAK,CAAA,GACnB,OAAO,MAAM,OACV;;AAEV;;AAGA,SAAgB,WAAW,EACzB,QACA,SACA,WACA,YAOC;CACD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,oBAAC,MAAD;EAAI,WAAU;YACZ,oBAAC,MAAD;GAAI,SAAS;aACX,oBAAC,aAAD;IAAqB;IAAmB;IACrC;GACU,CAAA;EACX,CAAA;CACF,CAAA;AAER;;AAGA,SAAgB,YAAY,EAC1B,QACA,WACA,YAKC;CACD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,KAAD;GAAG,WAAU;aAAb,CACE,oBAAC,aAAD,EAAa,MAAM,GAAK,CAAA,GACxB,qBAAC,QAAD,EAAA,UAAA;IACE,oBAAC,UAAD,EAAA,UAAS,YAAY,OAAO,MAAM,OAAe,CAAA;IAAC;IAAE,OAAO;GACvD,EAAA,CAAA,CACL;MACH,oBAAC,UAAD;GAAQ,MAAK;GAAS,WAAU;GAAgB,SAAS;GAAW,cAAW;aAC7E,oBAAC,GAAD,EAAG,MAAM,GAAK,CAAA;EACR,CAAA,CACL;;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,QAAQ,WAAW,qBAAqB,wBAAwB,eAAe,mBAAmB;CAC1G,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAS,aAAU;EAAS,eAAY;YAC3E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,GACL,oBAAC,OAAD;EAAK,WAAU;EAAkB,MAAK;EAAQ,aAAU;EAAY,eAAY;YAC7E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,CACL,EAAA,CAAA;AAEN"}
@@ -26,3 +26,5 @@ function signinErrorMessage(code) {
26
26
  }
27
27
  //#endregion
28
28
  export { signinErrorMessage as t };
29
+
30
+ //# sourceMappingURL=signin-errors-BEFlVDbQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signin-errors-BEFlVDbQ.js","names":[],"sources":["../../src/lib/signin-errors.ts"],"sourcesContent":["/**\n * What went wrong with a sign-in, in words. The callback redirects with a\n * code rather than a sentence so the URL stays short and nothing the provider\n * said is reflected into the page.\n */\nconst MESSAGES: Record<string, string> = {\n provider_denied: 'The sign-in was cancelled, or the provider refused it.',\n state_mismatch:\n 'This sign-in expired or was started in another tab. Start again from this page.',\n invalid_response:\n 'The provider answered in a way coffre could not verify. Try again; if it keeps happening, tell whoever runs coffre.',\n provider_unavailable: 'The provider could not be reached. Try again in a moment.',\n no_verified_email:\n 'That account has no verified email address, so coffre cannot match it to an invitation.',\n wrong_domain: 'That account is outside the organization this instance belongs to.',\n not_in_organization:\n 'That GitHub account is not a member of the required organization. If it is, grant coffre access to the organization when GitHub asks.',\n not_registered:\n 'Nobody has invited that account’s email address. Ask an owner to add you under Users, then sign in again.',\n deactivated: 'Your access to this coffre was removed. Ask an owner if that is a mistake.',\n account_mismatch:\n 'Your email already signs in with a different account. Use that one, then link this account from your account page.',\n already_linked: 'That account is already linked to someone else.',\n tampered:\n 'Your access record failed coffre’s integrity check: it was changed outside coffre. An owner must remove you and add you again.',\n unknown_provider: 'That sign-in option is not configured here.',\n link_session: 'Your session changed while linking. Sign in again, then retry.',\n};\n\nexport function signinErrorMessage(code: string | undefined): string | null {\n if (code === undefined) return null;\n return MESSAGES[code] ?? 'The sign-in did not complete. Try again.';\n}\n"],"mappings":";;;;;;AAKA,IAAM,WAAmC;CACvC,iBAAiB;CACjB,gBACE;CACF,kBACE;CACF,sBAAsB;CACtB,mBACE;CACF,cAAc;CACd,qBACE;CACF,gBACE;CACF,aAAa;CACb,kBACE;CACF,gBAAgB;CAChB,UACE;CACF,kBAAkB;CAClB,cAAc;AAChB;AAEA,SAAgB,mBAAmB,MAAyC;CAC1E,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,OAAO,SAAS,SAAS;AAC3B"}
@@ -0,0 +1,86 @@
1
+ import { y as usePreferences } from "./ui-DixXLQvQ.js";
2
+ import { D as Moon, E as Monitor, a as Check, z as Sun } from "./icons-D-PfAfnH.js";
3
+ import { Menu } from "@base-ui/react/menu";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ //#region src/components/theme.tsx
6
+ var OPTIONS = [
7
+ {
8
+ value: "system",
9
+ label: "Match system",
10
+ Icon: Monitor
11
+ },
12
+ {
13
+ value: "light",
14
+ label: "Light",
15
+ Icon: Sun
16
+ },
17
+ {
18
+ value: "dark",
19
+ label: "Dark",
20
+ Icon: Moon
21
+ }
22
+ ];
23
+ /** The theme as a radio group inside a dropdown menu (the account menu). */
24
+ function ThemeMenuItems() {
25
+ const { theme, setTheme } = usePreferences();
26
+ return /* @__PURE__ */ jsxs(Menu.RadioGroup, {
27
+ value: theme,
28
+ onValueChange: (value) => setTheme(value),
29
+ children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
30
+ className: "menu-label",
31
+ children: "Theme"
32
+ }), OPTIONS.map(({ value, label, Icon }) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
33
+ value,
34
+ className: "menu-item",
35
+ closeOnClick: true,
36
+ children: [
37
+ /* @__PURE__ */ jsx(Icon, { size: 15 }),
38
+ label,
39
+ /* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
40
+ className: "menu-check",
41
+ children: /* @__PURE__ */ jsx(Check, { size: 14 })
42
+ })
43
+ ]
44
+ }, value))]
45
+ });
46
+ }
47
+ /**
48
+ * Three glyphs, one of them pressed, for pages without the account menu.
49
+ * A menu for a three-way choice costs a click to find out the current value.
50
+ */
51
+ function ThemeToggle() {
52
+ const { theme, setTheme } = usePreferences();
53
+ return /* @__PURE__ */ jsx("div", {
54
+ className: "theme-choice",
55
+ role: "group",
56
+ "aria-label": "Colour scheme",
57
+ children: OPTIONS.map(({ value, label, Icon }) => /* @__PURE__ */ jsx("button", {
58
+ type: "button",
59
+ "aria-pressed": theme === value,
60
+ "aria-label": label,
61
+ title: label,
62
+ onClick: () => setTheme(value),
63
+ children: /* @__PURE__ */ jsx(Icon, { size: 14 })
64
+ }, value))
65
+ });
66
+ }
67
+ /** The theme as three large choices, for the Settings page. */
68
+ function ThemeCards() {
69
+ const { theme, setTheme } = usePreferences();
70
+ return /* @__PURE__ */ jsx("div", {
71
+ className: "choice-grid",
72
+ role: "group",
73
+ "aria-label": "Colour scheme",
74
+ children: OPTIONS.map(({ value, label, Icon }) => /* @__PURE__ */ jsxs("button", {
75
+ type: "button",
76
+ className: "choice",
77
+ "aria-pressed": theme === value,
78
+ onClick: () => setTheme(value),
79
+ children: [/* @__PURE__ */ jsx(Icon, { size: 16 }), label]
80
+ }, value))
81
+ });
82
+ }
83
+ //#endregion
84
+ export { ThemeMenuItems as n, ThemeToggle as r, ThemeCards as t };
85
+
86
+ //# sourceMappingURL=theme-B2vQolVR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-B2vQolVR.js","names":[],"sources":["../../src/components/theme.tsx"],"sourcesContent":["import { Menu } from '@base-ui/react/menu';\nimport { usePreferences, type Theme } from '../lib/preferences';\nimport { Check, Monitor, Moon, Sun } from './icons';\n\nconst OPTIONS: { value: Theme; label: string; Icon: typeof Sun }[] = [\n { value: 'system', label: 'Match system', Icon: Monitor },\n { value: 'light', label: 'Light', Icon: Sun },\n { value: 'dark', label: 'Dark', Icon: Moon },\n];\n\n/** The theme as a radio group inside a dropdown menu (the account menu). */\nexport function ThemeMenuItems() {\n const { theme, setTheme } = usePreferences();\n return (\n <Menu.RadioGroup value={theme} onValueChange={(value: Theme) => setTheme(value)}>\n <Menu.GroupLabel className=\"menu-label\">Theme</Menu.GroupLabel>\n {OPTIONS.map(({ value, label, Icon }) => (\n <Menu.RadioItem key={value} value={value} className=\"menu-item\" closeOnClick>\n <Icon size={15} />\n {label}\n <Menu.RadioItemIndicator className=\"menu-check\">\n <Check size={14} />\n </Menu.RadioItemIndicator>\n </Menu.RadioItem>\n ))}\n </Menu.RadioGroup>\n );\n}\n\n/**\n * Three glyphs, one of them pressed, for pages without the account menu.\n * A menu for a three-way choice costs a click to find out the current value.\n */\nexport function ThemeToggle() {\n const { theme, setTheme } = usePreferences();\n\n return (\n <div className=\"theme-choice\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n aria-pressed={theme === value}\n aria-label={label}\n title={label}\n onClick={() => setTheme(value)}\n >\n <Icon size={14} />\n </button>\n ))}\n </div>\n );\n}\n\n/** The theme as three large choices, for the Settings page. */\nexport function ThemeCards() {\n const { theme, setTheme } = usePreferences();\n return (\n <div className=\"choice-grid\" role=\"group\" aria-label=\"Colour scheme\">\n {OPTIONS.map(({ value, label, Icon }) => (\n <button\n key={value}\n type=\"button\"\n className=\"choice\"\n aria-pressed={theme === value}\n onClick={() => setTheme(value)}\n >\n <Icon size={16} />\n {label}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAIA,IAAM,UAA+D;CACnE;EAAE,OAAO;EAAU,OAAO;EAAgB,MAAM;CAAQ;CACxD;EAAE,OAAO;EAAS,OAAO;EAAS,MAAM;CAAI;CAC5C;EAAE,OAAO;EAAQ,OAAO;EAAQ,MAAM;CAAK;AAC7C;;AAGA,SAAgB,iBAAiB;CAC/B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,qBAAC,KAAK,YAAN;EAAiB,OAAO;EAAO,gBAAgB,UAAiB,SAAS,KAAK;YAA9E,CACE,oBAAC,KAAK,YAAN;GAAiB,WAAU;aAAa;EAAsB,CAAA,GAC7D,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,KAAK,WAAN;GAAmC;GAAO,WAAU;GAAY,cAAA;aAAhE;IACE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;IAChB;IACD,oBAAC,KAAK,oBAAN;KAAyB,WAAU;eACjC,oBAAC,OAAD,EAAO,MAAM,GAAK,CAAA;IACK,CAAA;GACX;KANK,KAML,CACjB,CACc;;AAErB;;;;;AAMA,SAAgB,cAAc;CAC5B,MAAM,EAAE,OAAO,aAAa,eAAe;CAE3C,OACE,oBAAC,OAAD;EAAK,WAAU;EA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