@coffre/ui 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 (180) hide show
  1. package/dist/chunks/audit-sentence-BhHmvQX_.js +660 -0
  2. package/dist/chunks/audit-sentence-BhHmvQX_.js.map +1 -0
  3. package/dist/chunks/connected-apps-CUOyEZXR.js +146 -0
  4. package/dist/chunks/connected-apps-CUOyEZXR.js.map +1 -0
  5. package/dist/chunks/delete-place-CRX7ntE8.js +206 -0
  6. package/dist/chunks/delete-place-CRX7ntE8.js.map +1 -0
  7. package/dist/chunks/{directory-CSjWWUQ1.js → directory-CxxrnGUL.js} +177 -60
  8. package/dist/chunks/directory-CxxrnGUL.js.map +1 -0
  9. package/dist/chunks/folders-DoBmCwOi.js +207 -0
  10. package/dist/chunks/folders-DoBmCwOi.js.map +1 -0
  11. package/dist/chunks/grants-CXcmhujY.js +669 -0
  12. package/dist/chunks/grants-CXcmhujY.js.map +1 -0
  13. package/dist/chunks/offboarding-6eAduCsM.js +305 -0
  14. package/dist/chunks/offboarding-6eAduCsM.js.map +1 -0
  15. package/dist/chunks/one-time-DXEl9hbg.js +35 -0
  16. package/dist/chunks/one-time-DXEl9hbg.js.map +1 -0
  17. package/dist/chunks/page-DvsgZ2Hd.js +391 -0
  18. package/dist/chunks/page-DvsgZ2Hd.js.map +1 -0
  19. package/dist/chunks/principal-BIN-xwZw.js +42 -0
  20. package/dist/chunks/principal-BIN-xwZw.js.map +1 -0
  21. package/dist/chunks/{principal-page-D_91OA0l.js → principal-page-B9R2zPlp.js} +259 -251
  22. package/dist/chunks/principal-page-B9R2zPlp.js.map +1 -0
  23. package/dist/chunks/project-page-SRCtRe2g.js +17 -0
  24. package/dist/chunks/project-page-SRCtRe2g.js.map +1 -0
  25. package/dist/chunks/{queries-CQ81o4so.js → queries-DVR_i3rA.js} +132 -30
  26. package/dist/chunks/queries-DVR_i3rA.js.map +1 -0
  27. package/dist/chunks/references-B6pLT1uQ.js +343 -0
  28. package/dist/chunks/references-B6pLT1uQ.js.map +1 -0
  29. package/dist/chunks/{row-state-0PsrEzOL.js → row-state-DOPUsjQK.js} +3 -3
  30. package/dist/chunks/{row-state-0PsrEzOL.js.map → row-state-DOPUsjQK.js.map} +1 -1
  31. package/dist/chunks/signin-errors--ykMFuqN.js +57 -0
  32. package/dist/chunks/signin-errors--ykMFuqN.js.map +1 -0
  33. package/dist/chunks/tabs-BmwKfUeK.js +22 -0
  34. package/dist/chunks/tabs-BmwKfUeK.js.map +1 -0
  35. package/dist/chunks/{theme-B2vQolVR.js → theme-DJuz-xLM.js} +3 -3
  36. package/dist/chunks/{theme-B2vQolVR.js.map → theme-DJuz-xLM.js.map} +1 -1
  37. package/dist/chunks/{ui-DixXLQvQ.js → ui-DJje3gST.js} +6 -3
  38. package/dist/chunks/ui-DJje3gST.js.map +1 -0
  39. package/dist/chunks/{use-change-c6CeLRin.js → use-change-CZdI2MJG.js} +75 -21
  40. package/dist/chunks/use-change-CZdI2MJG.js.map +1 -0
  41. package/dist/chunks/{use-shell-jxd7Tzd-.js → use-shell-rNKfGjdj.js} +3 -3
  42. package/dist/chunks/{use-shell-jxd7Tzd-.js.map → use-shell-rNKfGjdj.js.map} +1 -1
  43. package/dist/chunks/validation-D312_NLf.js +87 -0
  44. package/dist/chunks/validation-D312_NLf.js.map +1 -0
  45. package/dist/index.d.ts +385 -31
  46. package/dist/index.js +188 -102
  47. package/dist/index.js.map +1 -1
  48. package/dist/pages/account.d.ts +2 -2
  49. package/dist/pages/account.js +174 -135
  50. package/dist/pages/account.js.map +1 -1
  51. package/dist/pages/approval.d.ts +9 -0
  52. package/dist/pages/approval.js +207 -0
  53. package/dist/pages/approval.js.map +1 -0
  54. package/dist/pages/audit.js +17 -542
  55. package/dist/pages/audit.js.map +1 -1
  56. package/dist/pages/device-login.js +2 -3
  57. package/dist/pages/device-login.js.map +1 -1
  58. package/dist/pages/environment.js +647 -257
  59. package/dist/pages/environment.js.map +1 -1
  60. package/dist/pages/login.js +18 -7
  61. package/dist/pages/login.js.map +1 -1
  62. package/dist/pages/oauth-authorize.d.ts +10 -0
  63. package/dist/pages/oauth-authorize.js +249 -0
  64. package/dist/pages/oauth-authorize.js.map +1 -0
  65. package/dist/pages/project-access.d.ts +6 -0
  66. package/dist/pages/project-access.js +370 -0
  67. package/dist/pages/project-access.js.map +1 -0
  68. package/dist/pages/project-environments.d.ts +4 -0
  69. package/dist/pages/project-environments.js +593 -0
  70. package/dist/pages/project-environments.js.map +1 -0
  71. package/dist/pages/project-settings.d.ts +4 -0
  72. package/dist/pages/project-settings.js +242 -0
  73. package/dist/pages/project-settings.js.map +1 -0
  74. package/dist/pages/project.d.ts +10 -2
  75. package/dist/pages/project.js +57 -934
  76. package/dist/pages/project.js.map +1 -1
  77. package/dist/pages/projects.js +53 -21
  78. package/dist/pages/projects.js.map +1 -1
  79. package/dist/pages/service-account.d.ts +10 -0
  80. package/dist/pages/{token.js → service-account.js} +112 -54
  81. package/dist/pages/service-account.js.map +1 -0
  82. package/dist/pages/service-accounts.d.ts +3 -0
  83. package/dist/pages/service-accounts.js +38 -0
  84. package/dist/pages/service-accounts.js.map +1 -0
  85. package/dist/pages/settings.d.ts +1 -0
  86. package/dist/pages/settings.js +104 -42
  87. package/dist/pages/settings.js.map +1 -1
  88. package/dist/pages/unregistered.js +2 -3
  89. package/dist/pages/unregistered.js.map +1 -1
  90. package/dist/pages/user.d.ts +6 -1
  91. package/dist/pages/user.js +18 -6
  92. package/dist/pages/user.js.map +1 -1
  93. package/dist/pages/users.js +6 -10
  94. package/dist/pages/users.js.map +1 -1
  95. package/package.json +3 -3
  96. package/src/components/actions-log.tsx +117 -0
  97. package/src/components/audit-sentence.tsx +55 -0
  98. package/src/components/command-palette.tsx +4 -4
  99. package/src/components/connected-apps.tsx +138 -0
  100. package/src/components/delete-place.tsx +180 -0
  101. package/src/components/directory.tsx +266 -110
  102. package/src/components/every-project.tsx +287 -0
  103. package/src/components/expiry-field.tsx +42 -0
  104. package/src/components/folders.tsx +219 -0
  105. package/src/components/grants.tsx +11 -4
  106. package/src/components/icons.tsx +2 -0
  107. package/src/components/missing.tsx +110 -0
  108. package/src/components/offboarding.tsx +62 -34
  109. package/src/components/page.tsx +4 -1
  110. package/src/components/principal-page.tsx +154 -108
  111. package/src/components/principal-picker.tsx +5 -5
  112. package/src/components/principal.tsx +4 -4
  113. package/src/components/references.tsx +323 -0
  114. package/src/components/service-tokens.tsx +112 -93
  115. package/src/components/shell.tsx +11 -32
  116. package/src/components/tabs.tsx +18 -0
  117. package/src/components/trusted-workloads.tsx +97 -79
  118. package/src/components/ui.tsx +8 -1
  119. package/src/index.ts +13 -3
  120. package/src/layout.tsx +2 -2
  121. package/src/lib/access-plan.ts +2 -2
  122. package/src/lib/audit-sentences.ts +161 -77
  123. package/src/lib/changes.ts +77 -5
  124. package/src/lib/coffre.ts +3 -2
  125. package/src/lib/one-time.ts +32 -0
  126. package/src/lib/project-access.ts +11 -23
  127. package/src/lib/project-page.ts +14 -0
  128. package/src/lib/queries.ts +126 -32
  129. package/src/lib/search.ts +25 -0
  130. package/src/lib/signin-errors.ts +45 -1
  131. package/src/lib/validation.ts +14 -0
  132. package/src/options.ts +187 -42
  133. package/src/pages/account.tsx +176 -133
  134. package/src/pages/approval.tsx +197 -0
  135. package/src/pages/audit.tsx +9 -61
  136. package/src/pages/environment.tsx +585 -286
  137. package/src/pages/login.tsx +8 -2
  138. package/src/pages/oauth-authorize.tsx +233 -0
  139. package/src/pages/project-access.tsx +219 -0
  140. package/src/pages/project-environments.tsx +582 -0
  141. package/src/pages/project-settings.tsx +259 -0
  142. package/src/pages/project.tsx +52 -879
  143. package/src/pages/projects.tsx +55 -18
  144. package/src/pages/service-account.tsx +50 -0
  145. package/src/pages/{tokens.tsx → service-accounts.tsx} +9 -6
  146. package/src/pages/settings.tsx +62 -8
  147. package/src/pages/user.tsx +16 -4
  148. package/src/pages/users.tsx +2 -2
  149. package/src/parity.ts +160 -0
  150. package/src/register.ts +57 -10
  151. package/src/router.tsx +4 -0
  152. package/src/shared/models.ts +6 -2
  153. package/src/styles/globals.css +536 -31
  154. package/dist/chunks/directory-CSjWWUQ1.js.map +0 -1
  155. package/dist/chunks/grants-saMQagmG.js +0 -160
  156. package/dist/chunks/grants-saMQagmG.js.map +0 -1
  157. package/dist/chunks/icons-D-PfAfnH.js +0 -203
  158. package/dist/chunks/icons-D-PfAfnH.js.map +0 -1
  159. package/dist/chunks/offboarding-C6l30DZR.js +0 -263
  160. package/dist/chunks/offboarding-C6l30DZR.js.map +0 -1
  161. package/dist/chunks/page-C5HcNqf2.js +0 -190
  162. package/dist/chunks/page-C5HcNqf2.js.map +0 -1
  163. package/dist/chunks/principal-page-D_91OA0l.js.map +0 -1
  164. package/dist/chunks/queries-CQ81o4so.js.map +0 -1
  165. package/dist/chunks/signin-errors-BEFlVDbQ.js +0 -30
  166. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +0 -1
  167. package/dist/chunks/ui-DixXLQvQ.js.map +0 -1
  168. package/dist/chunks/use-action-CWsg_YWU.js +0 -49
  169. package/dist/chunks/use-action-CWsg_YWU.js.map +0 -1
  170. package/dist/chunks/use-change-c6CeLRin.js.map +0 -1
  171. package/dist/chunks/validation-BQtqPe2V.js +0 -29
  172. package/dist/chunks/validation-BQtqPe2V.js.map +0 -1
  173. package/dist/pages/token.d.ts +0 -3
  174. package/dist/pages/token.js.map +0 -1
  175. package/dist/pages/tokens.d.ts +0 -3
  176. package/dist/pages/tokens.js +0 -39
  177. package/dist/pages/tokens.js.map +0 -1
  178. package/dist/project-BqIy8gYR.d.ts +0 -5
  179. package/src/lib/instance.ts +0 -13
  180. package/src/pages/token.tsx +0 -34
@@ -0,0 +1,343 @@
1
+ import { a as ErrorLine, c as Notice, n as ConfirmDialog, s as Modal, u as Timestamp } from "./ui-DJje3gST.js";
2
+ import { g as ArrowRight, t as Card, u as useCoffre } from "./page-DvsgZ2Hd.js";
3
+ import { p as queries } from "./queries-DVR_i3rA.js";
4
+ import { a as useAction, r as secretKeyProblem } from "./validation-D312_NLf.js";
5
+ import { useEffect, useId, useState } from "react";
6
+ import { Link } from "@tanstack/react-router";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { useQuery } from "@tanstack/react-query";
9
+ //#region src/components/references.tsx
10
+ /**
11
+ * References: a secret read live through another (docs/design/environments.md).
12
+ * The vault makes and checks each one; these only show them.
13
+ */
14
+ /** Why a reference does not read, in a few words; null while it does. */
15
+ function referenceProblem(state) {
16
+ switch (state) {
17
+ case "live": return null;
18
+ case "broken": return "Broken";
19
+ case "replaced": return "No value";
20
+ case "source_archived": return "Source archived";
21
+ case "source_deleted": return "Source deleted";
22
+ case "source_is_reference": return "Source is a reference";
23
+ case "source_empty": return "Source has no value";
24
+ }
25
+ }
26
+ /** A secret's path as a link to it, when you can open it there. */
27
+ function SecretPath({ path, open }) {
28
+ const [project, environment, key] = path.split("/");
29
+ if (!open) return /* @__PURE__ */ jsx("span", {
30
+ className: "mono",
31
+ title: "You can't open the source",
32
+ children: path
33
+ });
34
+ return /* @__PURE__ */ jsx(Link, {
35
+ className: "mono",
36
+ to: "/projects/$project/$environment",
37
+ params: {
38
+ project,
39
+ environment
40
+ },
41
+ search: { filter: key },
42
+ children: path
43
+ });
44
+ }
45
+ /**
46
+ * What a key that is a reference shows where its value would be: what it
47
+ * reads, and, when it does not read, why. Reading it is a reveal like any
48
+ * other, logged as a read of the source.
49
+ */
50
+ function ReferenceValue({ reference }) {
51
+ const problem = referenceProblem(reference.state);
52
+ return /* @__PURE__ */ jsxs("span", {
53
+ className: "reference-value",
54
+ children: [
55
+ /* @__PURE__ */ jsx(ArrowRight, {
56
+ size: 13,
57
+ "aria-label": "A reference to"
58
+ }),
59
+ /* @__PURE__ */ jsx(SecretPath, {
60
+ path: reference.source,
61
+ open: reference.canOpenSource
62
+ }),
63
+ problem !== null && /* @__PURE__ */ jsx("span", {
64
+ className: "tag tag-red",
65
+ title: reference.endedBy === null ? void 0 : `By ${reference.endedBy}`,
66
+ children: problem
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ /**
72
+ * The references that read a secret from elsewhere, under its row: where
73
+ * each is held, who made it, who reads through it, and Break for those who
74
+ * may.
75
+ */
76
+ function LentReferences({ references, onBreak }) {
77
+ return /* @__PURE__ */ jsx("ul", {
78
+ className: "lent-references",
79
+ "aria-label": "Read through references",
80
+ children: references.map((reference) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("span", { children: [
81
+ "Read through ",
82
+ /* @__PURE__ */ jsx(SecretPath, {
83
+ path: reference.holder,
84
+ open: false
85
+ }),
86
+ ", made by ",
87
+ reference.createdBy.replace(/^user:/, ""),
88
+ " ",
89
+ /* @__PURE__ */ jsx(Timestamp, {
90
+ iso: reference.createdAt,
91
+ display: "relative"
92
+ }),
93
+ reference.readers !== null && /* @__PURE__ */ jsxs("span", {
94
+ className: "cell-muted",
95
+ children: [
96
+ " ",
97
+ "· ",
98
+ reference.readers.length === 0 ? "no one reads it by a grant" : `${reference.readers.length} ${reference.readers.length === 1 ? "person reads" : "people read"} it: ${reference.readers.map((reader) => reader.replace(/^user:/, "").replace(/^token:/, "service:")).join(", ")}`
99
+ ]
100
+ })
101
+ ] }), reference.canBreak && /* @__PURE__ */ jsx("button", {
102
+ type: "button",
103
+ className: "btn btn-sm btn-danger-outline",
104
+ onClick: () => onBreak(reference),
105
+ children: "Break"
106
+ })] }, reference.id))
107
+ });
108
+ }
109
+ /**
110
+ * Make a key a reference to a secret you read, by path: whoever reads its
111
+ * environment reads that secret through it, as it changes. Paths you can
112
+ * read are offered as you type.
113
+ */
114
+ function MakeReference({ open, onOpenChange, holder, environments, onMake }) {
115
+ const [source, setSource] = useState("");
116
+ const listId = useId();
117
+ useEffect(() => {
118
+ if (open) setSource("");
119
+ }, [open]);
120
+ const [project, environment, key] = source.split("/");
121
+ const problem = source === "" ? null : source.split("/").length !== 3 || project === "" || environment === "" ? "A secret, as project/environment/KEY." : secretKeyProblem(key);
122
+ const holderEnvironment = holder.split("/").slice(0, 2).join("/");
123
+ return /* @__PURE__ */ jsx(Modal, {
124
+ open,
125
+ onOpenChange,
126
+ title: `Make ${holder.split("/")[2]} a reference`,
127
+ description: `Whoever can read ${holderEnvironment} will read the secret you name, as it changes, even without access to its project. It takes your own read on that secret.`,
128
+ children: /* @__PURE__ */ jsxs("form", {
129
+ className: "form",
130
+ onSubmit: (event) => {
131
+ event.preventDefault();
132
+ if (problem !== null || source === "") return;
133
+ onMake(source);
134
+ onOpenChange(false);
135
+ },
136
+ children: [/* @__PURE__ */ jsxs("label", {
137
+ className: "field",
138
+ children: [
139
+ /* @__PURE__ */ jsx("span", {
140
+ className: "label",
141
+ children: "Secret to read"
142
+ }),
143
+ /* @__PURE__ */ jsx("input", {
144
+ className: "input input-mono",
145
+ autoFocus: true,
146
+ spellCheck: false,
147
+ autoComplete: "off",
148
+ list: listId,
149
+ placeholder: "market/prod/DATABASE_URL",
150
+ value: source,
151
+ "aria-invalid": problem !== null,
152
+ onChange: (event) => setSource(event.target.value)
153
+ }),
154
+ /* @__PURE__ */ jsx("datalist", {
155
+ id: listId,
156
+ children: environments.map((each) => /* @__PURE__ */ jsx("option", { value: `${each}/` }, each))
157
+ }),
158
+ /* @__PURE__ */ jsx("span", {
159
+ className: `hint${problem !== null ? " edit-note-error" : ""}`,
160
+ children: problem ?? "A reference cannot point at a reference: name the secret it reads."
161
+ })
162
+ ]
163
+ }), /* @__PURE__ */ jsxs("div", {
164
+ className: "dialog-actions",
165
+ children: [/* @__PURE__ */ jsx("button", {
166
+ className: "btn",
167
+ type: "button",
168
+ onClick: () => onOpenChange(false),
169
+ children: "Cancel"
170
+ }), /* @__PURE__ */ jsx("button", {
171
+ className: "btn btn-primary",
172
+ type: "submit",
173
+ disabled: source === "" || problem !== null,
174
+ children: "Make reference"
175
+ })]
176
+ })]
177
+ })
178
+ });
179
+ }
180
+ /**
181
+ * A project's secrets that others read through references held elsewhere,
182
+ * and who: on its access tab, beside the grants, since "who can read this"
183
+ * includes them. Those who may break one, its source's access managers or
184
+ * whoever writes where it is held, do it here.
185
+ */
186
+ function ReferencesInto({ project }) {
187
+ const coffre = useCoffre();
188
+ const { data } = useQuery(queries.references(coffre, project));
189
+ const { run, error } = useAction();
190
+ const [breaking, setBreaking] = useState(null);
191
+ const into = data?.ok === true ? data.references.filter((reference) => reference.source.startsWith(`${project}/`)) : [];
192
+ if (into.length === 0) return null;
193
+ return /* @__PURE__ */ jsxs(Card, {
194
+ labelledBy: "references-into",
195
+ title: "Also readable through references",
196
+ description: `Secrets of ${project} that others read through references held elsewhere. Who reads a reference's environment reads its source, with no grant here.`,
197
+ children: [
198
+ /* @__PURE__ */ jsx("div", {
199
+ className: "dt-wrap",
200
+ children: /* @__PURE__ */ jsxs("table", {
201
+ className: "dt stacks",
202
+ children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
203
+ /* @__PURE__ */ jsx("th", { children: "Secret" }),
204
+ /* @__PURE__ */ jsx("th", { children: "Read through" }),
205
+ /* @__PURE__ */ jsx("th", { children: "Readers" }),
206
+ /* @__PURE__ */ jsx("th", {
207
+ className: "col-actions",
208
+ children: /* @__PURE__ */ jsx("span", {
209
+ className: "visually-hidden",
210
+ children: "Actions"
211
+ })
212
+ })
213
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: into.map((reference) => /* @__PURE__ */ jsxs("tr", { children: [
214
+ /* @__PURE__ */ jsx("td", {
215
+ className: "mono",
216
+ "data-label": "Secret",
217
+ children: reference.source
218
+ }),
219
+ /* @__PURE__ */ jsx("td", {
220
+ "data-label": "Read through",
221
+ children: /* @__PURE__ */ jsxs("span", {
222
+ className: "cell-stack",
223
+ children: [/* @__PURE__ */ jsx("span", {
224
+ className: "mono",
225
+ children: reference.holder
226
+ }), /* @__PURE__ */ jsxs("small", {
227
+ className: "cell-muted",
228
+ children: [
229
+ "Made by ",
230
+ reference.createdBy.replace(/^user:/, ""),
231
+ " ",
232
+ /* @__PURE__ */ jsx(Timestamp, {
233
+ iso: reference.createdAt,
234
+ display: "relative"
235
+ })
236
+ ]
237
+ })]
238
+ })
239
+ }),
240
+ /* @__PURE__ */ jsx("td", {
241
+ "data-label": "Readers",
242
+ children: reference.readers === null ? "—" : reference.readers.length === 0 ? /* @__PURE__ */ jsx("span", {
243
+ className: "cell-muted",
244
+ children: "No one, by a grant"
245
+ }) : reference.readers.map((reader) => reader.replace(/^user:/, "").replace(/^token:/, "service:")).join(", ")
246
+ }),
247
+ /* @__PURE__ */ jsx("td", {
248
+ className: "col-actions",
249
+ children: reference.canBreak && /* @__PURE__ */ jsx("button", {
250
+ type: "button",
251
+ className: "btn btn-sm btn-danger-outline",
252
+ onClick: () => setBreaking(reference),
253
+ children: "Break"
254
+ })
255
+ })
256
+ ] }, reference.id)) })]
257
+ })
258
+ }),
259
+ error !== null && /* @__PURE__ */ jsx(ErrorLine, { error }),
260
+ /* @__PURE__ */ jsx(ConfirmDialog, {
261
+ open: breaking !== null,
262
+ onOpenChange: (open) => !open && setBreaking(null),
263
+ title: "Break this reference?",
264
+ body: breaking === null ? "" : `Whoever reads ${breaking.holder.split("/").slice(0, 2).join("/")} stops reading ${breaking.source} through it, and a run there refuses until ${breaking.holder.split("/")[2]} gets a value.`,
265
+ confirmLabel: "Break",
266
+ onConfirm: () => {
267
+ const path = breaking.holder;
268
+ run(() => coffre.references.break(path), { affects: [["references"]] });
269
+ }
270
+ })
271
+ ]
272
+ });
273
+ }
274
+ /**
275
+ * The references that archiving `path` would stop, a project, an
276
+ * environment or a key: those reading a secret in it, held outside it in a
277
+ * place not archived itself (D58). Archiving is refused while any read
278
+ * (D41); the server decides, and this shows the dialog what it will say.
279
+ */
280
+ function archiveBlockers(path, references) {
281
+ const within = (secret) => secret === path || secret.startsWith(`${path}/`);
282
+ return references.filter((reference) => reference.state === "live" && !reference.holderArchived && within(reference.source) && !within(reference.holder));
283
+ }
284
+ /**
285
+ * What an archive dialog shows while references read what it would
286
+ * archive: each, and Break for those who may break it. Archive waits until
287
+ * none is left.
288
+ */
289
+ function ArchiveBlocked({ references }) {
290
+ const coffre = useCoffre();
291
+ const { run, error, pending } = useAction();
292
+ if (references.length === 0) return null;
293
+ const many = references.length > 1;
294
+ return /* @__PURE__ */ jsxs("div", {
295
+ className: "archive-blocked",
296
+ children: [
297
+ /* @__PURE__ */ jsxs(Notice, {
298
+ tone: "bad",
299
+ children: [
300
+ many ? `${references.length} references read it` : "A reference reads it",
301
+ " from elsewhere. Break",
302
+ " ",
303
+ many ? "them" : "it",
304
+ " first: archiving would stop ",
305
+ many ? "those reads" : "that read",
306
+ "."
307
+ ]
308
+ }),
309
+ /* @__PURE__ */ jsx("ul", {
310
+ className: "archive-blockers",
311
+ "aria-label": "References that read it",
312
+ children: references.map((reference) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("span", {
313
+ className: "cell-stack",
314
+ children: [/* @__PURE__ */ jsx("span", {
315
+ className: "mono",
316
+ children: reference.holder
317
+ }), /* @__PURE__ */ jsxs("small", { children: ["reads ", /* @__PURE__ */ jsx("span", {
318
+ className: "mono",
319
+ children: reference.source
320
+ })] })]
321
+ }), reference.canBreak ? /* @__PURE__ */ jsx("button", {
322
+ type: "button",
323
+ className: "btn btn-sm btn-danger-outline",
324
+ disabled: pending,
325
+ onClick: () => void run(() => coffre.references.break(reference.holder), { affects: [["references"], ["secrets"]] }),
326
+ children: "Break"
327
+ }) : /* @__PURE__ */ jsx("small", {
328
+ className: "cell-muted",
329
+ children: `${reference.source.split("/")[0]}'s access managers, or whoever writes ${reference.holder.split("/").slice(0, 2).join("/")}, can break it`
330
+ })] }, reference.id))
331
+ }),
332
+ /* @__PURE__ */ jsx("p", {
333
+ className: "hint",
334
+ children: "Once broken, a run where it is held refuses until that key gets a value of its own."
335
+ }),
336
+ error !== null && /* @__PURE__ */ jsx(ErrorLine, { error })
337
+ ]
338
+ });
339
+ }
340
+ //#endregion
341
+ export { ReferencesInto as a, ReferenceValue as i, LentReferences as n, archiveBlockers as o, MakeReference as r, referenceProblem as s, ArchiveBlocked as t };
342
+
343
+ //# sourceMappingURL=references-B6pLT1uQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references-B6pLT1uQ.js","names":[],"sources":["../../src/components/references.tsx"],"sourcesContent":["import { useEffect, useId, useState } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { Link } from '@tanstack/react-router';\nimport type { ListedReference, ReferenceView, SecretKey } from '@coffre/client';\n\nimport { useCoffre } from '../lib/coffre';\nimport { queries } from '../lib/queries';\nimport { useAction } from '../lib/use-action';\nimport { secretKeyProblem } from '../lib/validation';\nimport { ArrowRight } from './icons';\nimport { Card } from './page';\nimport { ConfirmDialog, ErrorLine, Modal, Notice, Timestamp } from './ui';\n\n/**\n * References: a secret read live through another (docs/design/environments.md).\n * The vault makes and checks each one; these only show them.\n */\n\n/** Why a reference does not read, in a few words; null while it does. */\nexport function referenceProblem(state: ReferenceView['state']): string | null {\n switch (state) {\n case 'live':\n return null;\n case 'broken':\n return 'Broken';\n case 'replaced':\n return 'No value';\n case 'source_archived':\n return 'Source archived';\n case 'source_deleted':\n return 'Source deleted';\n case 'source_is_reference':\n return 'Source is a reference';\n case 'source_empty':\n return 'Source has no value';\n }\n}\n\n/** A secret's path as a link to it, when you can open it there. */\nfunction SecretPath({ path, open }: { path: string; open: boolean }) {\n const [project, environment, key] = path.split('/') as [string, string, string];\n if (!open) {\n return (\n <span className=\"mono\" title=\"You can't open the source\">\n {path}\n </span>\n );\n }\n return (\n <Link className=\"mono\" to=\"/projects/$project/$environment\" params={{ project, environment }} search={{ filter: key }}>\n {path}\n </Link>\n );\n}\n\n/**\n * What a key that is a reference shows where its value would be: what it\n * reads, and, when it does not read, why. Reading it is a reveal like any\n * other, logged as a read of the source.\n */\nexport function ReferenceValue({ reference }: { reference: NonNullable<SecretKey['reference']> }) {\n const problem = referenceProblem(reference.state);\n return (\n <span className=\"reference-value\">\n <ArrowRight size={13} aria-label=\"A reference to\" />\n <SecretPath path={reference.source} open={reference.canOpenSource} />\n {problem !== null && (\n <span className=\"tag tag-red\" title={reference.endedBy === null ? undefined : `By ${reference.endedBy}`}>\n {problem}\n </span>\n )}\n </span>\n );\n}\n\n/**\n * The references that read a secret from elsewhere, under its row: where\n * each is held, who made it, who reads through it, and Break for those who\n * may.\n */\nexport function LentReferences({ references, onBreak }: { references: ListedReference[]; onBreak: (reference: ListedReference) => void }) {\n return (\n <ul className=\"lent-references\" aria-label=\"Read through references\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span>\n Read through <SecretPath path={reference.holder} open={false} />, made by {reference.createdBy.replace(/^user:/, '')}{' '}\n <Timestamp iso={reference.createdAt} display=\"relative\" />\n {reference.readers !== null && (\n <span className=\"cell-muted\">\n {' '}\n · {reference.readers.length === 0 ? 'no one reads it by a grant' : `${reference.readers.length} ${reference.readers.length === 1 ? 'person reads' : 'people read'} it: ${reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}`}\n </span>\n )}\n </span>\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => onBreak(reference)}>\n Break\n </button>\n )}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * Make a key a reference to a secret you read, by path: whoever reads its\n * environment reads that secret through it, as it changes. Paths you can\n * read are offered as you type.\n */\nexport function MakeReference({\n open,\n onOpenChange,\n holder,\n environments,\n onMake,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** `billing/prod/DATABASE_URL`. */\n holder: string;\n /** `market/prod`, each environment you read. */\n environments: readonly string[];\n onMake: (source: string) => void;\n}) {\n const [source, setSource] = useState('');\n const listId = useId();\n useEffect(() => {\n if (open) setSource('');\n }, [open]);\n const [project, environment, key] = source.split('/');\n const problem =\n source === '' ? null\n : source.split('/').length !== 3 || project === '' || environment === '' ? 'A secret, as project/environment/KEY.'\n : secretKeyProblem(key!);\n const holderEnvironment = holder.split('/').slice(0, 2).join('/');\n\n return (\n <Modal\n open={open}\n onOpenChange={onOpenChange}\n title={`Make ${holder.split('/')[2]} a reference`}\n description={`Whoever can read ${holderEnvironment} will read the secret you name, as it changes, even without access to its project. It takes your own read on that secret.`}\n >\n <form\n className=\"form\"\n onSubmit={(event) => {\n event.preventDefault();\n if (problem !== null || source === '') return;\n onMake(source);\n onOpenChange(false);\n }}\n >\n <label className=\"field\">\n <span className=\"label\">Secret to read</span>\n <input\n className=\"input input-mono\"\n autoFocus\n spellCheck={false}\n autoComplete=\"off\"\n list={listId}\n placeholder=\"market/prod/DATABASE_URL\"\n value={source}\n aria-invalid={problem !== null}\n onChange={(event) => setSource(event.target.value)}\n />\n <datalist id={listId}>\n {environments.map((each) => (\n <option key={each} value={`${each}/`} />\n ))}\n </datalist>\n <span className={`hint${problem !== null ? ' edit-note-error' : ''}`}>\n {problem ?? 'A reference cannot point at a reference: name the secret it reads.'}\n </span>\n </label>\n <div className=\"dialog-actions\">\n <button className=\"btn\" type=\"button\" onClick={() => onOpenChange(false)}>\n Cancel\n </button>\n <button className=\"btn btn-primary\" type=\"submit\" disabled={source === '' || problem !== null}>\n Make reference\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n/**\n * A project's secrets that others read through references held elsewhere,\n * and who: on its access tab, beside the grants, since \"who can read this\"\n * includes them. Those who may break one, its source's access managers or\n * whoever writes where it is held, do it here.\n */\nexport function ReferencesInto({ project }: { project: string }) {\n const coffre = useCoffre();\n const { data } = useQuery(queries.references(coffre, project));\n const { run, error } = useAction();\n const [breaking, setBreaking] = useState<ListedReference | null>(null);\n const into = data?.ok === true ? data.references.filter((reference) => reference.source.startsWith(`${project}/`)) : [];\n if (into.length === 0) return null;\n return (\n <Card\n labelledBy=\"references-into\"\n title=\"Also readable through references\"\n description={`Secrets of ${project} that others read through references held elsewhere. Who reads a reference's environment reads its source, with no grant here.`}\n >\n <div className=\"dt-wrap\">\n <table className=\"dt stacks\">\n <thead>\n <tr>\n <th>Secret</th>\n <th>Read through</th>\n <th>Readers</th>\n <th className=\"col-actions\">\n <span className=\"visually-hidden\">Actions</span>\n </th>\n </tr>\n </thead>\n <tbody>\n {into.map((reference) => (\n <tr key={reference.id}>\n <td className=\"mono\" data-label=\"Secret\">{reference.source}</td>\n <td data-label=\"Read through\">\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small className=\"cell-muted\">\n Made by {reference.createdBy.replace(/^user:/, '')} <Timestamp iso={reference.createdAt} display=\"relative\" />\n </small>\n </span>\n </td>\n <td data-label=\"Readers\">\n {reference.readers === null\n ? '—'\n : reference.readers.length === 0\n ? <span className=\"cell-muted\">No one, by a grant</span>\n : reference.readers.map((reader) => reader.replace(/^user:/, '').replace(/^token:/, 'service:')).join(', ')}\n </td>\n <td className=\"col-actions\">\n {reference.canBreak && (\n <button type=\"button\" className=\"btn btn-sm btn-danger-outline\" onClick={() => setBreaking(reference)}>\n Break\n </button>\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {error !== null && <ErrorLine error={error} />}\n <ConfirmDialog\n open={breaking !== null}\n onOpenChange={(open) => !open && setBreaking(null)}\n title=\"Break this reference?\"\n body={breaking === null ? '' : `Whoever reads ${breaking.holder.split('/').slice(0, 2).join('/')} stops reading ${breaking.source} through it, and a run there refuses until ${breaking.holder.split('/')[2]} gets a value.`}\n confirmLabel=\"Break\"\n onConfirm={() => {\n const path = breaking!.holder;\n void run(() => coffre.references.break(path), { affects: [['references']] });\n }}\n />\n </Card>\n );\n}\n\n/**\n * The references that archiving `path` would stop, a project, an\n * environment or a key: those reading a secret in it, held outside it in a\n * place not archived itself (D58). Archiving is refused while any read\n * (D41); the server decides, and this shows the dialog what it will say.\n */\nexport function archiveBlockers(path: string, references: readonly ListedReference[]): ListedReference[] {\n const within = (secret: string) => secret === path || secret.startsWith(`${path}/`);\n return references.filter((reference) => reference.state === 'live' && !reference.holderArchived && within(reference.source) && !within(reference.holder));\n}\n\n/**\n * What an archive dialog shows while references read what it would\n * archive: each, and Break for those who may break it. Archive waits until\n * none is left.\n */\nexport function ArchiveBlocked({ references }: { references: readonly ListedReference[] }) {\n const coffre = useCoffre();\n const { run, error, pending } = useAction();\n if (references.length === 0) return null;\n const many = references.length > 1;\n return (\n <div className=\"archive-blocked\">\n <Notice tone=\"bad\">\n {many ? `${references.length} references read it` : 'A reference reads it'} from elsewhere. Break{' '}\n {many ? 'them' : 'it'} first: archiving would stop {many ? 'those reads' : 'that read'}.\n </Notice>\n <ul className=\"archive-blockers\" aria-label=\"References that read it\">\n {references.map((reference) => (\n <li key={reference.id}>\n <span className=\"cell-stack\">\n <span className=\"mono\">{reference.holder}</span>\n <small>\n reads <span className=\"mono\">{reference.source}</span>\n </small>\n </span>\n {reference.canBreak ? (\n <button\n type=\"button\"\n className=\"btn btn-sm btn-danger-outline\"\n disabled={pending}\n onClick={() => void run(() => coffre.references.break(reference.holder), { affects: [['references'], ['secrets']] })}\n >\n Break\n </button>\n ) : (\n <small className=\"cell-muted\">{`${reference.source.split('/')[0]}'s access managers, or whoever writes ${reference.holder.split('/').slice(0, 2).join('/')}, can break it`}</small>\n )}\n </li>\n ))}\n </ul>\n <p className=\"hint\">Once broken, a run where it is held refuses until that key gets a value of its own.</p>\n {error !== null && <ErrorLine error={error} />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAA8C;CAC7E,QAAQ,OAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,gBACH,OAAO;CACX;AACF;;AAGA,SAAS,WAAW,EAAE,MAAM,QAAyC;CACnE,MAAM,CAAC,SAAS,aAAa,OAAO,KAAK,MAAM,GAAG;CAClD,IAAI,CAAC,MACH,OACE,oBAAC,QAAD;EAAM,WAAU;EAAO,OAAM;YAC1B;CACG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oBAAC,SAAD;KAAO,WAAU;eAAc,GAAG,UAAU,OAAO,MAAM,GAAG,CAAC,CAAC,GAAG,wCAAwC,UAAU,OAAO,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAAuB,CAAA,CAElL,EAAA,GAnBK,UAAU,EAmBf,CACL;GACC,CAAA;GACJ,oBAAC,KAAD;IAAG,WAAU;cAAO;GAAsF,CAAA;GACzG,UAAU,QAAQ,oBAAC,WAAD,EAAkB,MAAQ,CAAA;EAC1C;;AAET"}
@@ -1,5 +1,5 @@
1
- import { l as Spinner } from "./ui-DixXLQvQ.js";
2
- import { G as X, n as AlertCircle } from "./icons-D-PfAfnH.js";
1
+ import { l as Spinner } from "./ui-DJje3gST.js";
2
+ import { it as X, p as AlertCircle } from "./page-DvsgZ2Hd.js";
3
3
  import { useSyncExternalStore } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/lib/announce.ts
@@ -115,4 +115,4 @@ function LiveRegion() {
115
115
  //#endregion
116
116
  export { rowClass as a, RowPending as i, LiveRegion as n, announce as o, RowFailure as r, ItemFailure as t };
117
117
 
118
- //# sourceMappingURL=row-state-0PsrEzOL.js.map
118
+ //# sourceMappingURL=row-state-DOPUsjQK.js.map
@@ -1 +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,OA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AU;EAAY,eAAY;YAC7E,WAAW,QAAQ,oBAAC,QAAD,EAAA,UAAuB,OAAO,KAAW,GAA9B,OAAO,EAAuB;CAC1D,CAAA,CACL,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"row-state-DOPUsjQK.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;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O,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"}
@@ -0,0 +1,57 @@
1
+ //#region src/lib/signin-errors.ts
2
+ /**
3
+ * What went wrong with a sign-in, in words. The callback redirects with a
4
+ * code rather than a sentence so the URL stays short and nothing the provider
5
+ * said is reflected into the page.
6
+ */
7
+ var MESSAGES = {
8
+ provider_denied: "The sign-in was cancelled, or the provider refused it.",
9
+ state_mismatch: "This sign-in expired or was started in another tab. Start again from this page.",
10
+ invalid_response: "The provider answered in a way coffre could not verify. Try again; if it keeps happening, tell whoever runs coffre.",
11
+ provider_unavailable: "The provider could not be reached. Try again in a moment.",
12
+ no_verified_email: "That account has no verified email address, so coffre cannot match it to an invitation.",
13
+ wrong_domain: "That account is outside the organization this instance belongs to.",
14
+ not_in_organization: "That GitHub account is not a member of the required organization. If it is, grant coffre access to the organization when GitHub asks.",
15
+ not_registered: "Nobody has invited that account’s email address. Ask an owner to add you under Users, then sign in again.",
16
+ deactivated: "Your access to this coffre was removed. Ask an owner if that is a mistake.",
17
+ account_mismatch: "Your email already signs in with a different account. Use that one, then link this account from your account page.",
18
+ already_linked: "That account is already linked to someone else.",
19
+ tampered: "Your access record failed coffre’s integrity check: it was changed outside coffre. An owner must remove you and add you again.",
20
+ unknown_provider: "That sign-in option is not configured here.",
21
+ link_session: "Your session changed while linking. Sign in again, then retry."
22
+ };
23
+ function signinErrorMessage(code, already) {
24
+ if (code === void 0) return null;
25
+ if (code === "account_mismatch" && already !== void 0 && already.providers.length > 0) return mismatch(already);
26
+ return MESSAGES[code] ?? "The sign-in did not complete. Try again.";
27
+ }
28
+ /** "Your email already signs in with GitHub. Sign in with GitHub, then link this account from your account page." */
29
+ function mismatch({ providers, via }) {
30
+ const link = "then link this account from your account page.";
31
+ if (providers.length === 1 && providers[0] === via) return `Your email already signs in with another ${via} account. Sign in with that one, ${link}`;
32
+ const named = providers.map((provider) => provider === via ? `another ${provider} account` : provider);
33
+ const list = named.length < 3 ? named.join(" and ") : `${named.slice(0, -1).join(", ")} and ${named.at(-1)}`;
34
+ return named.length === 1 ? `Your email already signs in with ${list}. Sign in with ${list}, ${link}` : `Your email already signs in with ${list}. Sign in with one of them, ${link}`;
35
+ }
36
+ /** A sign-in provider's id, as the instance configures it. */
37
+ var PROVIDER_ID = /^[a-z0-9_-]{1,40}$/;
38
+ /**
39
+ * `/login`'s search: where to resume after signing in, same-origin paths
40
+ * only, since an absolute URL accepted here would make the sign-in page an
41
+ * open redirect; and the sign-in's `error`, with account_mismatch's `with`
42
+ * and `via`, provider ids, shown once, then taken out of the URL.
43
+ */
44
+ function loginSearch(search) {
45
+ const out = {};
46
+ const { next, error, via } = search;
47
+ if (typeof next === "string" && next.startsWith("/") && !next.startsWith("//")) out.next = next;
48
+ if (typeof error === "string" && /^[a-z_]{1,40}$/.test(error)) out.error = error;
49
+ const providers = typeof search.with === "string" ? search.with.split(",").filter((id) => PROVIDER_ID.test(id)).slice(0, 8) : [];
50
+ if (providers.length > 0) out.with = providers.join(",");
51
+ if (typeof via === "string" && PROVIDER_ID.test(via)) out.via = via;
52
+ return out;
53
+ }
54
+ //#endregion
55
+ export { signinErrorMessage as n, loginSearch as t };
56
+
57
+ //# sourceMappingURL=signin-errors--ykMFuqN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signin-errors--ykMFuqN.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\n/**\n * Where an email already signs in, for `account_mismatch`: the providers by\n * the label the sign-in page shows them under, and the one just tried. What\n * the visitor may know: the provider has just verified the email is theirs.\n */\nexport type Already = { providers: readonly string[]; via?: string };\n\nexport function signinErrorMessage(code: string | undefined, already?: Already): string | null {\n if (code === undefined) return null;\n if (code === 'account_mismatch' && already !== undefined && already.providers.length > 0) return mismatch(already);\n return MESSAGES[code] ?? 'The sign-in did not complete. Try again.';\n}\n\n/** \"Your email already signs in with GitHub. Sign in with GitHub, then link this account from your account page.\" */\nfunction mismatch({ providers, via }: Already): string {\n const link = 'then link this account from your account page.';\n // The same provider, another account of it: a second GitHub account, say.\n if (providers.length === 1 && providers[0] === via) {\n return `Your email already signs in with another ${via} account. Sign in with that one, ${link}`;\n }\n const named = providers.map((provider) => (provider === via ? `another ${provider} account` : provider));\n const list = named.length < 3 ? named.join(' and ') : `${named.slice(0, -1).join(', ')} and ${named.at(-1)}`;\n return named.length === 1\n ? `Your email already signs in with ${list}. Sign in with ${list}, ${link}`\n : `Your email already signs in with ${list}. Sign in with one of them, ${link}`;\n}\n\nexport type LoginSearch = { next?: string; error?: string; with?: string; via?: string };\n\n/** A sign-in provider's id, as the instance configures it. */\nconst PROVIDER_ID = /^[a-z0-9_-]{1,40}$/;\n\n/**\n * `/login`'s search: where to resume after signing in, same-origin paths\n * only, since an absolute URL accepted here would make the sign-in page an\n * open redirect; and the sign-in's `error`, with account_mismatch's `with`\n * and `via`, provider ids, shown once, then taken out of the URL.\n */\nexport function loginSearch(search: Record<string, unknown>): LoginSearch {\n const out: LoginSearch = {};\n const { next, error, via } = search;\n if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) out.next = next;\n if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;\n const providers = typeof search.with === 'string' ? search.with.split(',').filter((id) => PROVIDER_ID.test(id)).slice(0, 8) : [];\n if (providers.length > 0) out.with = providers.join(',');\n if (typeof via === 'string' && PROVIDER_ID.test(via)) out.via = via;\n return out;\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;AASA,SAAgB,mBAAmB,MAA0B,SAAkC;CAC7F,I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
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/tabs.tsx
4
+ /**
5
+ * A page's sections as tabs under its header. Each is a `<Link>` to a route
6
+ * nested under the page's layout, the first to its index with
7
+ * `activeOptions={{ exact: true, includeSearch: false }}`, and the router
8
+ * marks the one shown `aria-current="page"`. The caller leaves out a tab
9
+ * nobody may open.
10
+ */
11
+ function PageTabs({ label, children }) {
12
+ if (Children.toArray(children).length < 2) return null;
13
+ return /* @__PURE__ */ jsx("nav", {
14
+ className: "tabs",
15
+ "aria-label": label,
16
+ children
17
+ });
18
+ }
19
+ //#endregion
20
+ export { PageTabs as t };
21
+
22
+ //# sourceMappingURL=tabs-BmwKfUeK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs-BmwKfUeK.js","names":[],"sources":["../../src/components/tabs.tsx"],"sourcesContent":["import { Children, type ReactNode } from 'react';\n\n/**\n * A page's sections as tabs under its header. Each is a `<Link>` to a route\n * nested under the page's layout, the first to its index with\n * `activeOptions={{ exact: true, includeSearch: false }}`, and the router\n * marks the one shown `aria-current=\"page\"`. The caller leaves out a tab\n * nobody may open.\n */\nexport function PageTabs({ label, children }: { label: string; children: ReactNode }) {\n // One tab is no choice at all.\n if (Children.toArray(children).length < 2) return null;\n return (\n <nav className=\"tabs\" aria-label={label}>\n {children}\n </nav>\n );\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,SAAS,EAAE,OAAO,YAAoD;CAEpF,IAAI,SAAS,QAAQ,QAAQ,CAAC,CAAC,SAAS,GAAG,OAAO;CAClD,OACE,oBAAC,OAAD;EAAK,WAAU;EAAO,cAAY;EAC/B;CACE,CAAA;AAET"}
@@ -1,5 +1,5 @@
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";
1
+ import { y as usePreferences } from "./ui-DJje3gST.js";
2
+ import { R as Monitor, Z as Sun, _ as Check, z as Moon } from "./page-DvsgZ2Hd.js";
3
3
  import { Menu } from "@base-ui/react/menu";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/components/theme.tsx
@@ -83,4 +83,4 @@ function ThemeCards() {
83
83
  //#endregion
84
84
  export { ThemeMenuItems as n, ThemeToggle as r, ThemeCards as t };
85
85
 
86
- //# sourceMappingURL=theme-B2vQolVR.js.map
86
+ //# sourceMappingURL=theme-DJuz-xLM.js.map
@@ -1 +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;EAAe,MAAK;EAAQ,cAAW;YACnD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,oBAAC,UAAD;GAEE,MAAK;GACL,gBAAc,UAAU;GACxB,cAAY;GACZ,OAAO;GACP,eAAe,SAAS,KAAK;aAE7B,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACX,GARD,KAQC,CACT;CACE,CAAA;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAc,MAAK;EAAQ,cAAW;YAClD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,UAAD;GAEE,MAAK;GACL,WAAU;GACV,gBAAc,UAAU;GACxB,eAAe,SAAS,KAAK;aAL/B,CAOE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAChB,KACK;KARD,KAQC,CACT;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"theme-DJuz-xLM.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;EAAe,MAAK;EAAQ,cAAW;YACnD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,oBAAC,UAAD;GAEE,MAAK;GACL,gBAAc,UAAU;GACxB,cAAY;GACZ,OAAO;GACP,eAAe,SAAS,KAAK;aAE7B,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EACX,GARD,KAQC,CACT;CACE,CAAA;AAET;;AAGA,SAAgB,aAAa;CAC3B,MAAM,EAAE,OAAO,aAAa,eAAe;CAC3C,OACE,oBAAC,OAAD;EAAK,WAAU;EAAc,MAAK;EAAQ,cAAW;YAClD,QAAQ,KAAK,EAAE,OAAO,OAAO,WAC5B,qBAAC,UAAD;GAEE,MAAK;GACL,WAAU;GACV,gBAAc,UAAU;GACxB,eAAe,SAAS,KAAK;aAL/B,CAOE,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA,GAChB,KACK;KARD,KAQC,CACT;CACE,CAAA;AAET"}
@@ -1,4 +1,4 @@
1
- import { G as X, S as Loader, _ as Info, a as Check, n as AlertCircle, r as AlertTriangle, u as Copy } from "./icons-D-PfAfnH.js";
1
+ import { P as Loader, S as Copy, _ as Check, it as X, k as Info, m as AlertTriangle, p as AlertCircle } from "./page-DvsgZ2Hd.js";
2
2
  import { createContext, useContext, useEffect, useRef, useState } from "react";
3
3
  import { Dialog } from "@base-ui/react/dialog";
4
4
  import { Menu } from "@base-ui/react/menu";
@@ -145,6 +145,7 @@ var NOTICE_ICON = {
145
145
  info: Info,
146
146
  good: Check,
147
147
  bad: AlertTriangle,
148
+ warn: AlertTriangle,
148
149
  neutral: Info
149
150
  };
150
151
  function Notice({ tone = "neutral", children }) {
@@ -236,7 +237,7 @@ function CopyButton({ value, label = "Copy", variant = "icon" }) {
236
237
  })
237
238
  });
238
239
  }
239
- function ConfirmContent({ title, body, confirmLabel, destructive, onConfirm }) {
240
+ function ConfirmContent({ title, body, detail, confirmLabel, destructive, confirmDisabled, onConfirm }) {
240
241
  const { portal } = usePreferences();
241
242
  return /* @__PURE__ */ jsxs(AlertDialog.Portal, {
242
243
  container: portal,
@@ -251,6 +252,7 @@ function ConfirmContent({ title, body, confirmLabel, destructive, onConfirm }) {
251
252
  className: "dialog-body",
252
253
  children: body
253
254
  }),
255
+ detail,
254
256
  /* @__PURE__ */ jsxs("div", {
255
257
  className: "dialog-actions",
256
258
  children: [/* @__PURE__ */ jsx(AlertDialog.Close, {
@@ -259,6 +261,7 @@ function ConfirmContent({ title, body, confirmLabel, destructive, onConfirm }) {
259
261
  }), /* @__PURE__ */ jsx(AlertDialog.Close, {
260
262
  className: `btn ${destructive === false ? "btn-primary" : "btn-danger"}`,
261
263
  onClick: onConfirm,
264
+ disabled: confirmDisabled,
262
265
  children: confirmLabel
263
266
  })]
264
267
  })
@@ -402,4 +405,4 @@ function Timestamp({ iso, precise = false, display = "absolute" }) {
402
405
  //#endregion
403
406
  export { rememberSidebar as _, ErrorLine as a, Notice as c, Tip as d, Toggletip as f, browserPreferences as g, PreferencesContext as h, EmptyState as i, Spinner as l, breakAfterUnderscores as m, ConfirmDialog as n, MenuPopup as o, TooltipProvider as p, CopyButton as r, Modal as s, ConfirmButton as t, Timestamp as u, rememberTheme as v, usePreferences as y };
404
407
 
405
- //# sourceMappingURL=ui-DixXLQvQ.js.map
408
+ //# sourceMappingURL=ui-DJje3gST.js.map