@kukeon/console 0.0.0-stage → 0.10.0-edge.g21af9f59

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 (93) hide show
  1. package/dist/auth.d.ts +39 -0
  2. package/dist/bulk-ui.d.ts +49 -0
  3. package/dist/bulk.d.mts +14 -0
  4. package/dist/catalog-CBVxh9uQ.js +5005 -0
  5. package/dist/catalog-url-Dr9e92Yq.js +19 -0
  6. package/dist/catalog-url.d.mts +4 -0
  7. package/dist/catalog.d.ts +40 -0
  8. package/dist/cell-filter.d.ts +10 -0
  9. package/dist/cell-sidebar.d.ts +26 -0
  10. package/dist/cells.d.mts +29 -0
  11. package/dist/cgroup-format.d.ts +17 -0
  12. package/dist/cgroup.d.ts +4 -0
  13. package/dist/config-form.d.mts +66 -0
  14. package/dist/connector-ui-lYy-1M3l.js +2692 -0
  15. package/dist/connector-ui.d.ts +127 -0
  16. package/dist/connectors-page-Z7acjRvr.js +1460 -0
  17. package/dist/connectors-page.d.ts +14 -0
  18. package/dist/connectors.d.mts +153 -0
  19. package/dist/container-log.d.ts +11 -0
  20. package/dist/create.d.ts +11 -0
  21. package/dist/creation-schema.d.mts +15 -0
  22. package/dist/daemon.d.ts +24 -0
  23. package/dist/display-name.d.ts +10 -0
  24. package/dist/drift-diff.d.ts +4 -0
  25. package/dist/exec.d.ts +15 -0
  26. package/dist/extensions.d.ts +111 -0
  27. package/dist/get-started.d.ts +9 -0
  28. package/dist/health.d.ts +22 -0
  29. package/dist/image-format.d.ts +6 -0
  30. package/dist/image-inventory.d.ts +12 -0
  31. package/dist/images.d.ts +5 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +5595 -0
  34. package/dist/initialize-CGmYWoaj.js +146 -0
  35. package/dist/initialize.d.ts +21 -0
  36. package/dist/inventory.d.ts +66 -0
  37. package/dist/lifecycle-policy.d.ts +11 -0
  38. package/dist/lifecycle.d.ts +24 -0
  39. package/dist/log-buffer.d.ts +8 -0
  40. package/dist/main.d.ts +13 -0
  41. package/dist/majordomo.d.ts +102 -0
  42. package/dist/manage-nav.d.ts +4 -0
  43. package/dist/manifest-diff.d.mts +11 -0
  44. package/dist/merged-values-BhW2-nlA.js +739 -0
  45. package/dist/merged-values.d.ts +24 -0
  46. package/dist/network-format.d.ts +30 -0
  47. package/dist/network.d.ts +13 -0
  48. package/dist/new-agent-24Fcf0PI.js +201 -0
  49. package/dist/new-agent.d.ts +27 -0
  50. package/dist/new-cell-u87hB9wV.js +1985 -0
  51. package/dist/new-cell.d.ts +29 -0
  52. package/dist/new-config-B_uf4R4e.js +1541 -0
  53. package/dist/new-config.d.ts +7 -0
  54. package/dist/notifications.d.ts +26 -0
  55. package/dist/onboarding-CPDpnS7K.js +395 -0
  56. package/dist/onboarding.d.mts +40 -0
  57. package/dist/panel-cells.d.mts +8 -0
  58. package/dist/registry-credentials.d.ts +13 -0
  59. package/dist/relationships.d.mts +12 -0
  60. package/dist/request.d.ts +16 -0
  61. package/dist/router.d.ts +12 -0
  62. package/dist/routes.d.ts +41 -0
  63. package/dist/schedule-B08uvsJe.js +113 -0
  64. package/dist/schedule-format.d.mts +9 -0
  65. package/dist/schedule.d.ts +16 -0
  66. package/dist/scope-actions.d.ts +9 -0
  67. package/dist/screens.d.ts +6 -0
  68. package/dist/secret-form.d.ts +24 -0
  69. package/dist/settings-nav.d.ts +5 -0
  70. package/dist/settings-page.d.ts +4 -0
  71. package/dist/settings-values.d.mts +18 -0
  72. package/dist/settings.d.ts +50 -0
  73. package/dist/sidebar-shell.d.ts +55 -0
  74. package/dist/sources-page-C4t29wxJ.js +423 -0
  75. package/dist/sources-page.d.ts +5 -0
  76. package/dist/space-subnets.d.ts +3 -0
  77. package/dist/style.css +2 -0
  78. package/dist/team-form.d.mts +56 -0
  79. package/dist/team-plan-CaBIrof0.js +735 -0
  80. package/dist/team-plan.d.ts +22 -0
  81. package/dist/team-wizard.d.ts +8 -0
  82. package/dist/teams-page-CLdQhhgo.js +2206 -0
  83. package/dist/teams-page.d.ts +9 -0
  84. package/dist/teams.d.mts +112 -0
  85. package/dist/terminal-palette.d.ts +8 -0
  86. package/dist/terminal.d.ts +98 -0
  87. package/dist/unread.d.mts +19 -0
  88. package/dist/use-unread.d.ts +4 -0
  89. package/dist/user-menu.d.ts +7 -0
  90. package/dist/views.d.mts +8 -0
  91. package/dist/workbench.d.ts +16 -0
  92. package/package.json +45 -4
  93. package/README.md +0 -3
@@ -0,0 +1,2692 @@
1
+ import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
2
+ import { apiFetch as l } from "@kukeon/api-client";
3
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
4
+ import { Icon as p } from "@kukeon/ui";
5
+ // src/request.tsx
6
+ function m(e, t) {
7
+ let [n, i] = c({ loading: !0 }), [a, o] = c(e);
8
+ return a !== e && (o(e), i({ loading: e !== null })), r(() => {
9
+ if (e === null) return;
10
+ let t = new AbortController();
11
+ return i((e) => ({
12
+ data: e.data,
13
+ loading: !0
14
+ })), (async () => {
15
+ try {
16
+ let n = await l(e, { signal: t.signal }), r = await n.json();
17
+ if (!n.ok) throw r.error ?? {
18
+ code: "http_error",
19
+ message: `HTTP ${n.status}`
20
+ };
21
+ t.signal.aborted || i({
22
+ data: r,
23
+ loading: !1
24
+ });
25
+ } catch (e) {
26
+ if (t.signal.aborted) return;
27
+ let n = e;
28
+ i((e) => ({
29
+ data: e.data,
30
+ loading: !1,
31
+ error: {
32
+ code: n.code ?? "unavailable",
33
+ message: n.message ?? "Request failed. Try refreshing."
34
+ }
35
+ }));
36
+ }
37
+ })(), () => t.abort();
38
+ }, [e, t]), n;
39
+ }
40
+ function h(e) {
41
+ let t = e;
42
+ return t && typeof t.code == "string" ? {
43
+ code: t.code,
44
+ message: t.message ?? "Request failed."
45
+ } : {
46
+ code: "unavailable",
47
+ message: e instanceof Error ? e.message : "The request could not reach the web server."
48
+ };
49
+ }
50
+ function g(e, t = "Realm") {
51
+ return e.code === "permission_denied" ? "Permission denied" : e.code === "unavailable" ? "Daemon unavailable" : e.code === "daemon_outdated" ? "Daemon outdated" : e.code === "log_unavailable" ? "Daemon logs unavailable" : e.code === "not_found" ? `${t} no longer exists` : "Request failed";
52
+ }
53
+ function _({ error: e, kind: t = "Realm" }) {
54
+ return /* @__PURE__ */ f("div", {
55
+ className: "error",
56
+ role: "alert",
57
+ children: [/* @__PURE__ */ d("strong", { children: g(e, t) }), /* @__PURE__ */ d("p", { children: e.message })]
58
+ });
59
+ }
60
+ var v = "file", y = "stateVolume", b = "registry", x = "string", S = "opaque", C = "basic-auth", w = "ssh-key", T = [
61
+ "realm",
62
+ "space",
63
+ "stack"
64
+ ], E = "resolved", D = "pending", O = "kukeon.io/team", ee = "default", te = "logged in", k = "empty", ne = "persistent", re = "ephemeral", ie = [ne, re], A = (e) => Array.isArray(e) ? e : [], j = (e) => typeof e == "string" ? e : "", M = (e) => j(e).trim();
65
+ function N(e) {
66
+ return e === "env" || e === "file" || e === "git";
67
+ }
68
+ function P(e) {
69
+ let t = M(e?.name), n = M(e?.realm);
70
+ if (!t || !n) return;
71
+ let r = {
72
+ name: t,
73
+ realm: n
74
+ };
75
+ return M(e.space) && (r.space = M(e.space)), r.space && M(e.stack) && (r.stack = M(e.stack)), r;
76
+ }
77
+ function F(e) {
78
+ let t = P(e);
79
+ return t ? JSON.stringify([
80
+ t.realm,
81
+ t.space ?? "",
82
+ t.stack ?? "",
83
+ t.name
84
+ ]) : "";
85
+ }
86
+ function I(e, t) {
87
+ return F(e) === F(t);
88
+ }
89
+ function L(e) {
90
+ let t = P(e);
91
+ return t ? [
92
+ t.realm,
93
+ t.space,
94
+ t.stack
95
+ ].filter(Boolean) : [];
96
+ }
97
+ function R(e) {
98
+ let t = P(e);
99
+ return t ? `${t.name} — ${L(t).join(" / ")}` : "";
100
+ }
101
+ function ae(e) {
102
+ let t = P(e);
103
+ return t ? `${t.name}@${L(t).join("/")}` : "";
104
+ }
105
+ function oe(e, t) {
106
+ return A(e).filter((e) => M(e?.metadata?.name) && M(e.metadata.realm) && !M(e.metadata.cell) && !!t && j(e.spec?.connector) === t).map((e) => ({
107
+ name: e.metadata.name,
108
+ realm: e.metadata.realm,
109
+ space: j(e.metadata.space),
110
+ stack: j(e.metadata.stack),
111
+ type: j(e.spec?.type) || "opaque",
112
+ identity: Object.fromEntries(Object.entries(e.spec?.identity ?? {}).filter(([, e]) => typeof e == "string"))
113
+ })).sort((e, t) => [
114
+ e.realm,
115
+ e.space,
116
+ e.stack,
117
+ e.name
118
+ ].join("/").localeCompare([
119
+ t.realm,
120
+ t.space,
121
+ t.stack,
122
+ t.name
123
+ ].join("/")));
124
+ }
125
+ function se(e) {
126
+ return A(e?.status?.connectors).filter((e) => j(e?.connector));
127
+ }
128
+ function z(e) {
129
+ return !!e && e.state !== "resolved" && (e.required === !0 || !!e.identity);
130
+ }
131
+ function ce(e) {
132
+ return se(e).filter(z);
133
+ }
134
+ function B(e) {
135
+ return j(e?.title) || j(e?.connector);
136
+ }
137
+ function le(e, t = "") {
138
+ let n = j(e);
139
+ return T.includes(n) ? `${n[0].toUpperCase()}${n.slice(1)} default` : n === "config" ? t ? `set by team ${t}` : "picked for this Config" : n === "cell" ? "picked for this cell" : n;
140
+ }
141
+ function ue(e) {
142
+ return j(e?.metadata?.labels?.[O]);
143
+ }
144
+ function de(e) {
145
+ return {
146
+ realm: M(e?.realm),
147
+ space: M(e?.space) || "default",
148
+ stack: M(e?.stack) || "default"
149
+ };
150
+ }
151
+ function V(e, t) {
152
+ let n = { realm: M(e?.realm) };
153
+ return t !== T[0] && M(e?.space) && (n.space = M(e.space)), t === T[2] && n.space && M(e?.stack) && (n.stack = M(e.stack)), n;
154
+ }
155
+ function H(e) {
156
+ return M(e?.stack) ? T[2] : M(e?.space) ? T[1] : T[0];
157
+ }
158
+ function U(e) {
159
+ return [
160
+ M(e?.realm),
161
+ M(e?.space),
162
+ M(e?.stack)
163
+ ].filter(Boolean);
164
+ }
165
+ function fe(e) {
166
+ let [t, n, r] = A(e).map(M);
167
+ return V({
168
+ realm: t,
169
+ space: n,
170
+ stack: r
171
+ }, T[2]);
172
+ }
173
+ function pe(e) {
174
+ let t = A(e?.scopes).length ? e.scopes : T;
175
+ return T.filter((e) => t.includes(e));
176
+ }
177
+ function me(e, t) {
178
+ return pe(e).filter((e) => H(V(t, e)) === e);
179
+ }
180
+ function he(e) {
181
+ let t = new URLSearchParams();
182
+ return T.forEach((n) => {
183
+ M(e?.[n]) && t.set(n, M(e[n]));
184
+ }), t.toString();
185
+ }
186
+ function ge(e) {
187
+ let t = A(e?.methods);
188
+ return t.length ? t.filter((e) => (e?.delivery === "env" || e?.delivery === "file") && j(e.slot)).map((e) => ({
189
+ method: j(e.name),
190
+ component: j(e.component),
191
+ delivery: e.delivery,
192
+ slot: e.slot,
193
+ description: j(e.description)
194
+ })) : e?.delivery === "git" ? [{
195
+ method: "",
196
+ component: j(e.name),
197
+ delivery: "git",
198
+ slot: "",
199
+ description: ""
200
+ }] : [];
201
+ }
202
+ function _e(e, t) {
203
+ return A(e).find((e) => e?.connector === t?.connector && (t.component ? e.component === t.component : j(e.method) === j(t.method)));
204
+ }
205
+ function ve(e) {
206
+ return A(e?.methods).filter((e) => e?.delivery === y);
207
+ }
208
+ function ye(e) {
209
+ return !A(e?.methods).length && e?.delivery === "registry";
210
+ }
211
+ function be(e, t) {
212
+ let n = A(e).find((e) => e?.connector === t);
213
+ return {
214
+ configs: Number(n?.configs) || 0,
215
+ missing: A(n?.missing)
216
+ };
217
+ }
218
+ function xe(e) {
219
+ let t = [], n = [];
220
+ for (let r of A(e)) {
221
+ if (!r?.optional) continue;
222
+ if (!j(r.group)) {
223
+ n.push(r);
224
+ continue;
225
+ }
226
+ let e = t.find((e) => e.group === r.group);
227
+ e || t.push(e = {
228
+ group: r.group,
229
+ members: []
230
+ }), e.members.push(r);
231
+ }
232
+ return {
233
+ groups: t,
234
+ ungrouped: n
235
+ };
236
+ }
237
+ function Se(e, t) {
238
+ let n = {};
239
+ for (let { group: r, members: i } of xe(e).groups) n[r] = (i.find((e) => A(A(t).find((t) => t?.name === e.connector?.name)?.methods).some((t) => t?.default === !0 && (t.component === e.name || j(t.name) && t.name === e.connector?.method))) ?? i[0]).name;
240
+ return n;
241
+ }
242
+ function W(e) {
243
+ return e?.delivery === y;
244
+ }
245
+ function Ce(e) {
246
+ return N(e?.delivery) || W(e);
247
+ }
248
+ function G(e) {
249
+ return W(e) ? P(e?.volumeRef) : P(e?.identity);
250
+ }
251
+ function we(e, t) {
252
+ return A(e).filter((e) => e?.connector === t && P(e.volume)).map((e) => {
253
+ let n = {
254
+ connector: t,
255
+ method: j(e.method),
256
+ volume: P(e.volume),
257
+ exists: e.exists === !0,
258
+ tagged: e.tagged === !0,
259
+ state: j(e.login?.state),
260
+ since: j(e.login?.since),
261
+ usedBy: A(e.usedBy).filter((e) => j(e?.name))
262
+ }, r = e.session;
263
+ return j(r?.cell) && j(r.realm) && j(r.space) && j(r.stack) && (n.session = {
264
+ realm: r.realm,
265
+ space: r.space,
266
+ stack: r.stack,
267
+ cell: r.cell,
268
+ container: j(r.container)
269
+ }), n;
270
+ });
271
+ }
272
+ function Te(e) {
273
+ return e === "logged in" ? "Logged in" : e === "empty" ? "Empty" : "Unknown";
274
+ }
275
+ function Ee(e) {
276
+ return e === "logged in" ? "ok" : e === "empty" ? "stopped" : "unknown";
277
+ }
278
+ function De(e) {
279
+ return e ? [
280
+ e.realm,
281
+ e.space,
282
+ e.stack,
283
+ e.cell
284
+ ] : [];
285
+ }
286
+ function Oe(e, t, n) {
287
+ let r = {
288
+ name: M(e),
289
+ scope: V(t, H(t))
290
+ };
291
+ return M(n) && (r.method = M(n)), r;
292
+ }
293
+ function ke(e) {
294
+ let t = M(e);
295
+ return t ? /^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$/.test(t) ? "" : "Use lowercase letters, digits, dots, dashes and underscores." : "Name the login identity.";
296
+ }
297
+ function Ae(e) {
298
+ return W(e) || !j(e?.harnessState) ? "" : e.harnessState === "ephemeral" ? re : j(e.volume);
299
+ }
300
+ function je(e) {
301
+ return A(e).filter(Ce);
302
+ }
303
+ function Me(e, t) {
304
+ let n = {};
305
+ for (let r of je(e)) {
306
+ let e = P(t?.[r.connector]);
307
+ e && !I(e, G(r)) && (n[r.connector] = e);
308
+ }
309
+ return n;
310
+ }
311
+ function Ne(e) {
312
+ let t = A(e?.methods).filter((e) => j(e?.name));
313
+ return t.length > 1 ? t : [];
314
+ }
315
+ function Pe(e, t) {
316
+ let n = {};
317
+ for (let r of A(e)) {
318
+ let e = M(t?.[r.connector]);
319
+ e && j(r.method) && e !== r.method && (n[r.connector] = e);
320
+ }
321
+ return n;
322
+ }
323
+ function Fe(e, t, n) {
324
+ let r = Pe(e, n);
325
+ return A(e).map((e) => {
326
+ let n = r[e.connector], i = A(t).find((t) => t?.name === e.connector), a = n ? A(i?.methods).find((e) => e?.name === n) : void 0;
327
+ if (!a) return e;
328
+ let o = {
329
+ connector: e.connector,
330
+ component: j(a.component) || `${e.connector}-${n}`,
331
+ method: n,
332
+ delivery: j(a.delivery),
333
+ state: D
334
+ };
335
+ return e.title && (o.title = e.title), j(a.slot) && (o.slot = a.slot), o;
336
+ });
337
+ }
338
+ function Ie(e, t) {
339
+ let n = Me(e, t);
340
+ return A(e).filter((e) => z(e) && !n[e.connector]);
341
+ }
342
+ function Le(e, t) {
343
+ return A(e?.fields).filter((e) => j(e?.name) && (!A(e.secretTypes).length || e.secretTypes.includes(t))).map((e) => ({
344
+ name: e.name,
345
+ type: [
346
+ "list",
347
+ "person",
348
+ "secret"
349
+ ].includes(e.type) ? e.type : x,
350
+ required: e.required === !0,
351
+ help: j(e.help),
352
+ enum: A(e.enum).filter((e) => typeof e == "string")
353
+ }));
354
+ }
355
+ function K(e) {
356
+ let t = A(e?.secretTypes).filter((e) => [
357
+ S,
358
+ C,
359
+ w
360
+ ].includes(e));
361
+ return t.length ? t : [S];
362
+ }
363
+ function Re(e, t) {
364
+ return !A(e?.methods).length && e?.delivery === "git" && t === "opaque";
365
+ }
366
+ function ze(e) {
367
+ return !A(e?.methods).length && e?.delivery === "git";
368
+ }
369
+ function Be(e) {
370
+ let t = {
371
+ realm: M(e?.realm) || "default",
372
+ makeDefault: e?.makeDefault === !0
373
+ }, n = rt(e?.hosts);
374
+ n.length && (t.hosts = n);
375
+ for (let n of [
376
+ "name",
377
+ "key",
378
+ "passphraseFile"
379
+ ]) M(e?.[n]) && (t[n] = M(e[n]));
380
+ return t;
381
+ }
382
+ function Ve(e, t) {
383
+ let n = K(e);
384
+ return {
385
+ name: j(t?.name) || (t ? "" : q(e)?.tokenName ?? ""),
386
+ type: n.includes(t?.type) ? t.type : n[0],
387
+ fields: { ...t?.identity ?? {} },
388
+ value: "",
389
+ username: "",
390
+ password: "",
391
+ privateKey: "",
392
+ passphrase: "",
393
+ publicKey: "",
394
+ certificate: "",
395
+ knownHosts: ""
396
+ };
397
+ }
398
+ var He = "kukeon.io/token-from";
399
+ function q(e) {
400
+ let t = e?.tokenForGit;
401
+ if (t && typeof t == "object") return {
402
+ connector: j(t.connector),
403
+ hosts: A(t.hosts).filter((e) => typeof e == "string"),
404
+ username: j(t.username),
405
+ name: j(t.name),
406
+ tokenName: j(t.tokenName)
407
+ };
408
+ }
409
+ function Ue(e) {
410
+ return A(e).filter((e) => !!q(e));
411
+ }
412
+ function We(e, t, n) {
413
+ let r = q(t), i = P(n);
414
+ if (r && i) return oe(e, r.connector).find((e) => e.identity[He] === ae(i));
415
+ }
416
+ var Ge = "A login identity normally serves one role; another role may share it at your risk (its start rewrites role content in the state directory, and a Codex refresh token is single-use).";
417
+ function Ke(e) {
418
+ return Array.isArray(e?.warnings) ? e.warnings.filter((e) => typeof e == "string" && e.trim() !== "") : [];
419
+ }
420
+ function qe(e) {
421
+ let t = j(e?.staleGit?.name);
422
+ return t ? `Git identity ${t} still holds the previous token: rotate again with "Also use this token for git" checked to rotate it too.` : void 0;
423
+ }
424
+ function Je(e) {
425
+ return {
426
+ git: e === !0,
427
+ gitAuthorName: "",
428
+ gitAuthorEmail: "",
429
+ gitUsername: ""
430
+ };
431
+ }
432
+ function Ye(e) {
433
+ let t = {}, n = ot(e?.gitAuthorName, e?.gitAuthorEmail);
434
+ return n && (t.author = n), M(e?.gitUsername) && (t.username = M(e.gitUsername)), t;
435
+ }
436
+ function Xe(e) {
437
+ let t = e?.git ? st("Commit author", ot(e.gitAuthorName, e.gitAuthorEmail)) : void 0;
438
+ return t ? [t] : [];
439
+ }
440
+ var Ze = {
441
+ [w]: {
442
+ label: "SSH key",
443
+ description: "clone, push and sign"
444
+ },
445
+ [C]: {
446
+ label: "Username and password or token",
447
+ description: "HTTPS"
448
+ },
449
+ [S]: {
450
+ label: "Author only",
451
+ description: "commits without push"
452
+ }
453
+ }, Qe = {
454
+ [w]: {
455
+ label: "SSH key",
456
+ description: "a private key"
457
+ },
458
+ [C]: {
459
+ label: "Username and password or token",
460
+ description: "basic auth"
461
+ },
462
+ [S]: {
463
+ label: "Value",
464
+ description: "a single secret value"
465
+ }
466
+ };
467
+ function $e(e) {
468
+ let t = ze(e) ? Ze : Qe;
469
+ return K(e).map((e) => ({
470
+ type: e,
471
+ ...t[e]
472
+ }));
473
+ }
474
+ function et(e, t) {
475
+ let n = {
476
+ [T[0]]: `Everywhere in realm ${M(t) || "default"}`,
477
+ [T[1]]: "Only in one space…",
478
+ [T[2]]: "Only in one stack…"
479
+ };
480
+ return pe(e).map((e) => ({
481
+ level: e,
482
+ label: n[e],
483
+ recommended: e === T[0]
484
+ }));
485
+ }
486
+ function tt(e, t, n, r) {
487
+ let i = M(e?.realm);
488
+ if (!i) return;
489
+ if (t === T[0]) return { realm: i };
490
+ let a = (e, t) => {
491
+ let n = A(e);
492
+ return n.includes(t) ? t : n.includes("default") ? ee : n[0];
493
+ }, o = a(n?.(i), M(e?.space));
494
+ if (!o) return;
495
+ if (t === T[1]) return {
496
+ realm: i,
497
+ space: o
498
+ };
499
+ let s = a(r?.(i, o), M(e?.stack));
500
+ return s ? {
501
+ realm: i,
502
+ space: o,
503
+ stack: s
504
+ } : void 0;
505
+ }
506
+ function nt(e, t, n) {
507
+ return n ? !_e(e, {
508
+ connector: t?.name,
509
+ component: n.component,
510
+ method: n.method
511
+ })?.effective : !1;
512
+ }
513
+ function rt(e) {
514
+ return j(e).split(",").map((e) => e.trim()).filter(Boolean);
515
+ }
516
+ var it = /^[^<>]+<[^<>\s@]+@[^<>\s@]+>$/;
517
+ function at(e) {
518
+ let t = j(e), n = /^([^<>]*)<([^<>]*)>\s*$/.exec(t);
519
+ return n ? {
520
+ name: n[1].trim(),
521
+ email: n[2].trim()
522
+ } : {
523
+ name: t.trim(),
524
+ email: ""
525
+ };
526
+ }
527
+ function ot(e, t) {
528
+ let n = M(e), r = M(t);
529
+ return !n && !r ? "" : n ? `${n} <${r}>` : `<${r}>`;
530
+ }
531
+ function st(e, t) {
532
+ let n = M(t);
533
+ if (!n) return;
534
+ let { name: r, email: i } = at(n);
535
+ return !r || !i ? `${e} needs a name and an email.` : it.test(n) ? void 0 : `${e} needs a valid email.`;
536
+ }
537
+ function ct(e, t) {
538
+ let n = [];
539
+ M(t?.name) || n.push("Name is required.");
540
+ for (let r of Le(e, t?.type)) {
541
+ let e = M(t?.fields?.[r.name]);
542
+ if (!e) {
543
+ r.required && n.push(`${r.name} is required.`);
544
+ continue;
545
+ }
546
+ if (r.type === "person") {
547
+ let t = st(r.name, e);
548
+ t && n.push(t);
549
+ }
550
+ let i = r.type === "list" ? rt(e) : [e];
551
+ r.enum.length && i.some((e) => !r.enum.includes(e)) && n.push(`${r.name} must be one of: ${r.enum.join(", ")}.`);
552
+ }
553
+ return t?.type === "basic-auth" ? (M(t.username) || n.push("Username is required."), j(t.password) || n.push("Password or token is required.")) : t?.type === "ssh-key" ? M(t.privateKey) || n.push("Private key is required.") : !Re(e, t?.type) && !j(t?.value) && n.push("Value is required."), n;
554
+ }
555
+ function lt(e, t, n, r = {}) {
556
+ let i = K(e).includes(n?.type) ? n.type : K(e)[0], a = {
557
+ scope: V(t, H(t)),
558
+ name: M(n?.name),
559
+ type: i
560
+ }, o = {};
561
+ for (let t of Le(e, i)) {
562
+ let e = t.type === "list" ? rt(n?.fields?.[t.name]).join(",") : M(n?.fields?.[t.name]);
563
+ e && (o[t.name] = e);
564
+ }
565
+ for (let [e, t] of Object.entries(n?.fields ?? {})) e.startsWith("kukeon.io/") && M(t) && (o[e] = M(t));
566
+ if (Object.keys(o).length && (a.identity = o), i === "basic-auth") a.username = M(n.username), a.password = j(n.password);
567
+ else if (i === "ssh-key") {
568
+ a.privateKey = j(n.privateKey);
569
+ for (let e of [
570
+ "passphrase",
571
+ "publicKey",
572
+ "certificate",
573
+ "knownHosts"
574
+ ]) j(n[e]) && (a[e] = j(n[e]));
575
+ } else Re(e, i) || (a.value = j(n?.value));
576
+ return r.git && q(e) && i === "opaque" && (a.git = r.git), r.makeDefault && (a.makeDefault = !0, M(r.method) && (a.method = M(r.method))), a;
577
+ }
578
+ function ut(e) {
579
+ return {
580
+ ...e,
581
+ value: "",
582
+ password: "",
583
+ privateKey: "",
584
+ passphrase: "",
585
+ publicKey: "",
586
+ certificate: "",
587
+ knownHosts: ""
588
+ };
589
+ }
590
+ var dt = [
591
+ S,
592
+ C,
593
+ w
594
+ ];
595
+ function ft(e) {
596
+ return j(e?.spec?.type) || "opaque";
597
+ }
598
+ function pt(e) {
599
+ return {
600
+ ...Ve({ secretTypes: [e ? ft(e) : S] }),
601
+ name: j(e?.metadata?.name)
602
+ };
603
+ }
604
+ function mt(e, t = !1) {
605
+ let n = [];
606
+ return !t && !M(e?.name) && n.push("Name is required."), !t && M(e?.name).startsWith(".") && n.push("A name cannot start with a dot."), dt.includes(e?.type) || n.push(`Type must be one of: ${dt.join(", ")}.`), e?.type === "basic-auth" ? (M(e.username) || n.push("Username is required."), j(e.password) || n.push("Password or token is required.")) : e?.type === "ssh-key" ? M(e.privateKey) || n.push("Private key is required.") : j(e?.value).replace(/[\r\n]+$/, "") || n.push("Value is required."), n;
607
+ }
608
+ function ht(e, t = !1) {
609
+ let n = dt.includes(e?.type) ? e.type : S, r = { type: n };
610
+ if (t && (r.replace = !0), n === "basic-auth") r.username = M(e.username), r.password = j(e.password);
611
+ else if (n === "ssh-key") {
612
+ r.privateKey = j(e.privateKey);
613
+ for (let t of [
614
+ "passphrase",
615
+ "publicKey",
616
+ "certificate",
617
+ "knownHosts"
618
+ ]) j(e[t]) && (r[t] = j(e[t]));
619
+ } else r.value = j(e?.value);
620
+ return r;
621
+ }
622
+ function gt(e) {
623
+ return A(e).filter((e) => !ye(e));
624
+ }
625
+ function _t(e) {
626
+ return A(e?.spec?.registryCredentials).map((t) => {
627
+ let n = t?.secretRef && M(t.secretRef.name) ? {
628
+ name: M(t.secretRef.name),
629
+ realm: M(t.secretRef.realm) || M(e?.metadata?.name)
630
+ } : void 0;
631
+ return {
632
+ server: j(t?.serverAddress),
633
+ username: j(t?.username),
634
+ ...n ? { secret: n } : {}
635
+ };
636
+ });
637
+ }
638
+ // src/router.ts
639
+ var vt = {
640
+ current: () => window.location.hash.slice(1),
641
+ href: (e) => "#" + e,
642
+ navigate: (e) => {
643
+ window.location.hash = e;
644
+ },
645
+ subscribe: (e) => (window.addEventListener("hashchange", e), () => window.removeEventListener("hashchange", e))
646
+ }, J = vt;
647
+ function yt(e = vt) {
648
+ J = e;
649
+ }
650
+ function bt() {
651
+ return J.current();
652
+ }
653
+ function Y(e) {
654
+ return J.href(e);
655
+ }
656
+ function xt(e) {
657
+ J.navigate(e);
658
+ }
659
+ function St(e) {
660
+ return J.subscribe(e);
661
+ }
662
+ // src/teams.mjs
663
+ var Ct = "kuke", wt = [
664
+ "branch",
665
+ "tag",
666
+ "commit"
667
+ ], Tt = "already_exists", X = (e) => Array.isArray(e) ? e : [], Z = (e) => typeof e == "string" ? e : "", Q = (e) => Z(e).trim();
668
+ function Et(e, t) {
669
+ return e ? "/teams/" + encodeURIComponent(e) + (t === "edit" || t === "export" ? "/" + t : "") : "/teams";
670
+ }
671
+ var Dt = "/new-team";
672
+ function Ot(e) {
673
+ return "/sources" + (e ? "/" + encodeURIComponent(e) : "");
674
+ }
675
+ function kt(e, t) {
676
+ return e ? "/teams/" + encodeURIComponent(e) + (t ? "/" + t : "") : "/teams";
677
+ }
678
+ function At(e, t = {}) {
679
+ let n = [t.hostFields ? "hostFields=1" : "", t.explicit ? "explicit=1" : ""].filter(Boolean).join("&");
680
+ return kt(e, "export") + (n ? "?" + n : "");
681
+ }
682
+ function jt(e, t) {
683
+ return e ? "/sources/" + encodeURIComponent(e) + (t ? "/" + t : "") : "/sources";
684
+ }
685
+ var Mt = "/sources/inspect", Nt = "/team-defaults";
686
+ function Pt(e) {
687
+ for (let t of wt) if (Q(e?.[t])) return {
688
+ kind: t,
689
+ value: Q(e[t])
690
+ };
691
+ return {
692
+ kind: "",
693
+ value: ""
694
+ };
695
+ }
696
+ function Ft(e) {
697
+ let t = Pt(e);
698
+ return t.kind ? t.kind === "commit" ? `commit ${t.value.slice(0, 12)}` : `${t.kind} ${t.value}` : "default branch";
699
+ }
700
+ function It(e, t, n) {
701
+ let r = Q(n);
702
+ return r && wt.includes(t) && (e[t] = r), e;
703
+ }
704
+ function Lt(e, t) {
705
+ let n = Q(t);
706
+ return e === "commit" && n && !/^([0-9a-f]{40}|[0-9a-f]{64})$/i.test(n) ? ["A commit is a full commit SHA."] : n && /[\s~^:?*[\\]|\.\.|@\{/.test(n) ? ["A branch or tag name has no spaces or special characters."] : [];
707
+ }
708
+ function Rt(e) {
709
+ return /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$/.test(Q(e));
710
+ }
711
+ function zt(e, t) {
712
+ return {
713
+ name: Q(e),
714
+ declaration: Z(t)
715
+ };
716
+ }
717
+ function Bt(e) {
718
+ return e?.code === Tt;
719
+ }
720
+ function Vt(e) {
721
+ return e ? [
722
+ {
723
+ key: "create",
724
+ title: "Configs to create",
725
+ items: X(e.create)
726
+ },
727
+ {
728
+ key: "rerender",
729
+ title: "Configs to re-render",
730
+ items: X(e.rerender)
731
+ },
732
+ {
733
+ key: "prune",
734
+ title: "Configs to prune",
735
+ items: X(e.prune)
736
+ },
737
+ {
738
+ key: "createSecrets",
739
+ title: "Secrets to create",
740
+ items: X(e.createSecrets)
741
+ },
742
+ {
743
+ key: "missingSecrets",
744
+ title: "Missing secrets",
745
+ items: X(e.missingSecrets)
746
+ },
747
+ {
748
+ key: "notes",
749
+ title: "Notes",
750
+ items: X(e.notes)
751
+ }
752
+ ].filter((e) => e.items.length) : [];
753
+ }
754
+ function Ht(e) {
755
+ let t = Z(e?.kind);
756
+ return t ? Q(e.detail) ? `${t} (${Q(e.detail)})` : t : "";
757
+ }
758
+ function Ut(e) {
759
+ let t = Z(e?.name);
760
+ return Q(e?.schedule) ? `${t} (${Q(e.schedule)}${e.suspend ? ", suspended" : ""})` : t;
761
+ }
762
+ function Wt(e) {
763
+ return X(e?.pairs).map((e) => ({
764
+ key: `${Z(e.role)}:${Z(e.harness)}`,
765
+ role: Z(e.role),
766
+ harness: Z(e.harness),
767
+ config: Z(e.config),
768
+ image: Z(e.image),
769
+ components: X(e.components),
770
+ tasks: X(e.tasks).map(Ut)
771
+ }));
772
+ }
773
+ function Gt(e) {
774
+ return {
775
+ roles: X(e?.roles).map((e) => ({
776
+ ...e,
777
+ harnesses: X(e.harnesses),
778
+ default: !!e.default,
779
+ tasks: X(e.tasks).map((e) => typeof e == "string" ? { name: e } : {
780
+ name: Z(e?.name),
781
+ schedule: Z(e?.schedule),
782
+ suspend: !!e?.suspend,
783
+ args: Z(e?.args)
784
+ })
785
+ })),
786
+ harnesses: X(e?.harnesses).map((e) => ({
787
+ ...e,
788
+ default: !!e.default
789
+ }))
790
+ };
791
+ }
792
+ function Kt(e, t, n, r) {
793
+ let i = t === "harness" ? "defaultHarnesses" : "defaultRoles", a = Q(n?.name), o = X(e?.[i]).filter((e) => Z(e.name) !== a).map((e) => Z(e.name)), s = r ? [...o, `${a}=${Q(n?.source)}:${Q(n?.path)}`] : o;
794
+ return t === "harness" ? { harnesses: s } : { roles: s };
795
+ }
796
+ function qt(e, t, n, r) {
797
+ return X(e?.[t === "harness" ? "defaultHarnesses" : "defaultRoles"]).some((e) => e.source === n && e.path === r);
798
+ }
799
+ function Jt(e) {
800
+ let t = It({
801
+ name: Q(e?.name),
802
+ url: Q(e?.url)
803
+ }, e?.refKind, e?.ref);
804
+ return Q(e?.identity) && (t.identity = Q(e.identity)), e?.force && (t.force = !0), t;
805
+ }
806
+ function Yt(e) {
807
+ let t = [];
808
+ return Q(e?.name) ? Rt(e.name) && Q(e.name) !== "project" || t.push("A Source name is lowercase letters, digits, dots and hyphens, and not project.") : t.push("Name is required."), Q(e?.url) || t.push("Address is required."), [...t, ...Lt(e?.refKind, e?.ref)];
809
+ }
810
+ function Xt(e) {
811
+ let t = `${Z(e?.as)} ${Z(e?.name)}`.trim();
812
+ return Q(e?.team) ? `team ${e.team} (${t})` : t;
813
+ }
814
+ function Zt(e) {
815
+ return [...new Set(X(e?.usedBy).map((e) => Q(e?.team)).filter(Boolean))].sort();
816
+ }
817
+ function Qt(e) {
818
+ let t = X(e?.inheriting);
819
+ return t.length ? `Teams inheriting from the defaults: ${t.join(", ")}. A change reaches each only when it is reapplied.` : "No stored team inherits from the defaults.";
820
+ }
821
+ function $t(e) {
822
+ return {
823
+ removed: X(e?.removed).map((e) => `${Z(e.kind)} ${Z(e.name)}`),
824
+ liveCells: X(e?.liveCells),
825
+ keptVolumes: X(e?.keptVolumes)
826
+ };
827
+ }
828
+ function en(e) {
829
+ return e?.inherited ? "inherited" : "declared";
830
+ }
831
+ function tn(e, t) {
832
+ return "/configs/" + [...X(e), t].map(encodeURIComponent).join("/");
833
+ }
834
+ function nn(e) {
835
+ let t = {
836
+ name: Z(e?.name),
837
+ url: Z(e?.url),
838
+ branch: "",
839
+ ref: ""
840
+ }, n = Pt(e);
841
+ return n.kind === "branch" ? t.branch = n.value : n.kind && (t.ref = n.value), t;
842
+ }
843
+ // src/routes.ts
844
+ var rn = [
845
+ "realm",
846
+ "space",
847
+ "stack",
848
+ "cell",
849
+ "container"
850
+ ], an = [
851
+ "Realms",
852
+ "Spaces",
853
+ "Stacks",
854
+ "Cells"
855
+ ], on = {
856
+ blueprints: "Blueprints",
857
+ configs: "Configs",
858
+ volumes: "Volumes",
859
+ secrets: "Secrets"
860
+ }, sn = () => ({
861
+ view: "workbench",
862
+ scope: [],
863
+ parent: [],
864
+ document: !1
865
+ });
866
+ function cn() {
867
+ return Y("/");
868
+ }
869
+ function ln() {
870
+ return Y("/resources");
871
+ }
872
+ function un() {
873
+ try {
874
+ let [e, t] = bt().split("?"), n = new URLSearchParams(t);
875
+ if (!e || e === "/" || e === "/workspace") return sn();
876
+ let r = e.split("/").filter(Boolean).map(decodeURIComponent);
877
+ if (r[0] === "new-cell") {
878
+ let e;
879
+ try {
880
+ e = JSON.parse(n.get("config") ?? "null");
881
+ } catch {
882
+ e = null;
883
+ }
884
+ return {
885
+ view: "new-cell",
886
+ scope: [],
887
+ parent: [],
888
+ document: !1,
889
+ config: Array.isArray(e) && e.every((e) => typeof e == "string") ? e.slice(0, 4) : void 0
890
+ };
891
+ }
892
+ if (r[0] === "new-config") {
893
+ let e;
894
+ try {
895
+ e = JSON.parse(n.get("blueprint") ?? "null");
896
+ } catch {
897
+ e = null;
898
+ }
899
+ return {
900
+ view: "new-config",
901
+ scope: [],
902
+ parent: [],
903
+ document: !1,
904
+ blueprint: Array.isArray(e) && e.every((e) => typeof e == "string") ? e.slice(0, 4) : void 0
905
+ };
906
+ }
907
+ if (r[0] === "agents" && r[1] === "new" && r.length === 2) return {
908
+ view: "new-agent",
909
+ scope: [],
910
+ parent: [],
911
+ document: !1
912
+ };
913
+ if (r[0] === "new-secret") return {
914
+ view: "new-secret",
915
+ scope: [],
916
+ parent: [],
917
+ document: !1
918
+ };
919
+ if (r[0] === "connectors") {
920
+ let e;
921
+ try {
922
+ e = JSON.parse(n.get("scope") ?? "null");
923
+ } catch {
924
+ e = null;
925
+ }
926
+ let t;
927
+ try {
928
+ t = JSON.parse(n.get("identity") ?? "null");
929
+ } catch {
930
+ t = null;
931
+ }
932
+ let i = r[2] === "new-identity" || r[2] === "rotate-identity" ? r[2] : void 0;
933
+ return {
934
+ view: "connectors",
935
+ scope: r.slice(1, 2),
936
+ parent: [],
937
+ document: !1,
938
+ target: Array.isArray(e) && e.every((e) => typeof e == "string") ? e.slice(0, 3) : void 0,
939
+ action: i,
940
+ identity: i && Array.isArray(t) && t.length >= 2 && t.every((e) => typeof e == "string") ? t.slice(0, 4) : void 0
941
+ };
942
+ }
943
+ if (r[0] === "teams") return {
944
+ view: "teams",
945
+ scope: r.slice(1, 2),
946
+ parent: [],
947
+ document: !1,
948
+ action: r[1] && (r[2] === "edit" || r[2] === "export") ? r[2] : void 0
949
+ };
950
+ if (r[0] === "new-team") return {
951
+ view: "new-team",
952
+ scope: [],
953
+ parent: [],
954
+ document: !1
955
+ };
956
+ if (r[0] === "sources") return {
957
+ view: "sources",
958
+ scope: r.slice(1, 2),
959
+ parent: [],
960
+ document: !1
961
+ };
962
+ if (r[0] === "health") return {
963
+ view: "health",
964
+ scope: [],
965
+ parent: [],
966
+ document: !1
967
+ };
968
+ if (r[0] === "daemon") return {
969
+ view: r[1] === "logs" ? "daemon-logs" : r[1] === "health" ? "health" : "daemon",
970
+ scope: [],
971
+ parent: [],
972
+ document: !1
973
+ };
974
+ if (r[0] === "ext") return {
975
+ view: "extension",
976
+ scope: [],
977
+ parent: [],
978
+ document: !1,
979
+ extension: r[1] ?? "",
980
+ extensionPath: r.slice(2).join("/")
981
+ };
982
+ if (r[0] === "settings") return {
983
+ view: "settings",
984
+ scope: [],
985
+ parent: [],
986
+ document: !1
987
+ };
988
+ if (r[0] === "workspace") return r.length === 5 ? {
989
+ view: "workspace",
990
+ scope: r.slice(1),
991
+ parent: [],
992
+ document: !1
993
+ } : sn();
994
+ if (e === "/resources" || e === "/administration" || e === "/dashboard") return {
995
+ view: "dashboard",
996
+ scope: [],
997
+ parent: [],
998
+ document: !1
999
+ };
1000
+ if (r[0] === "images") return {
1001
+ view: "images",
1002
+ scope: r.slice(1, 3),
1003
+ parent: [],
1004
+ document: !1
1005
+ };
1006
+ if (Object.keys(on).includes(r[0])) return {
1007
+ view: r[0],
1008
+ scope: r.slice(1, 6),
1009
+ parent: [],
1010
+ document: n.has("document"),
1011
+ edit: n.has("edit")
1012
+ };
1013
+ if (r[0] === "resource") return {
1014
+ view: "resource",
1015
+ scope: r.slice(1, 6),
1016
+ parent: [],
1017
+ document: n.has("document")
1018
+ };
1019
+ if (an.some((e) => e.toLowerCase() === r[0])) {
1020
+ let e = JSON.parse(n.get("parent") ?? "[]"), t = n.get("state") ?? void 0;
1021
+ return {
1022
+ view: r[0],
1023
+ scope: [],
1024
+ parent: Array.isArray(e) && e.every((e) => typeof e == "string") ? e.slice(0, 4) : [],
1025
+ document: !1,
1026
+ ...t ? { state: t } : {}
1027
+ };
1028
+ }
1029
+ return {
1030
+ view: "resource",
1031
+ scope: r.slice(0, 5),
1032
+ parent: [],
1033
+ document: !1
1034
+ };
1035
+ } catch {
1036
+ return sn();
1037
+ }
1038
+ }
1039
+ function dn(e) {
1040
+ return Y("/workspace/" + e.map(encodeURIComponent).join("/"));
1041
+ }
1042
+ function fn(e) {
1043
+ return Y("/new-cell" + (e?.length ? `?config=${encodeURIComponent(JSON.stringify(e))}` : ""));
1044
+ }
1045
+ function pn(e) {
1046
+ return Y("/new-config" + (e?.length ? `?blueprint=${encodeURIComponent(JSON.stringify(e))}` : ""));
1047
+ }
1048
+ function mn() {
1049
+ return Y("/agents/new");
1050
+ }
1051
+ function hn() {
1052
+ return Y("/new-secret");
1053
+ }
1054
+ function gn(e, t, n = {}) {
1055
+ return Y(`/${e}/` + t.map(encodeURIComponent).join("/") + (n.document ? "?document=1" : n.edit ? "?edit=1" : ""));
1056
+ }
1057
+ function _n() {
1058
+ return Y("/settings");
1059
+ }
1060
+ function vn() {
1061
+ return Y("/daemon/health");
1062
+ }
1063
+ function yn(e) {
1064
+ return Y("/daemon" + (e ? `/${e}` : ""));
1065
+ }
1066
+ function bn(e, t) {
1067
+ return Y("/images" + [e, t].filter((e) => !!e).map((e) => "/" + encodeURIComponent(e)).join(""));
1068
+ }
1069
+ function xn(e, t = !1) {
1070
+ return Y("/resource/" + e.map(encodeURIComponent).join("/") + (t ? "?document=1" : ""));
1071
+ }
1072
+ function Sn(e, t = [], n) {
1073
+ let r = [t.length ? `parent=${encodeURIComponent(JSON.stringify(t))}` : "", n ? `state=${encodeURIComponent(n)}` : ""].filter(Boolean).join("&");
1074
+ return Y(`/${an[e].toLowerCase()}` + (r ? `?${r}` : ""));
1075
+ }
1076
+ function Cn(e, t) {
1077
+ return Y(Et(e, t));
1078
+ }
1079
+ function wn() {
1080
+ return Y(Dt);
1081
+ }
1082
+ function Tn(e) {
1083
+ return Y(Ot(e));
1084
+ }
1085
+ function En(e, t) {
1086
+ return Y(tn(e, t));
1087
+ }
1088
+ function Dn(e) {
1089
+ return "/" + e.map((e, t) => `${rn[t]}s/${encodeURIComponent(e)}`).join("/");
1090
+ }
1091
+ // src/notifications.tsx
1092
+ var On = 5e3, kn = 3, An = e({
1093
+ notify: () => {},
1094
+ dismiss: () => {}
1095
+ });
1096
+ function jn() {
1097
+ return n(An);
1098
+ }
1099
+ function Mn({ toast: e, onDismiss: t }) {
1100
+ let [n, i] = c(!1), [a, o] = c(!1), l = s(On);
1101
+ return r(() => {
1102
+ l.current = On;
1103
+ }, [e.revision]), r(() => {
1104
+ if (e.tone !== "success" || n || a) return;
1105
+ let r = Date.now(), i = window.setTimeout(() => t(e.key), l.current);
1106
+ return () => {
1107
+ window.clearTimeout(i), l.current = Math.max(0, l.current - (Date.now() - r));
1108
+ };
1109
+ }, [
1110
+ e.key,
1111
+ e.tone,
1112
+ e.revision,
1113
+ n,
1114
+ a,
1115
+ t
1116
+ ]), /* @__PURE__ */ f("div", {
1117
+ className: `toast ${e.tone}`,
1118
+ "data-toast": e.key,
1119
+ onPointerMove: () => i(!0),
1120
+ onPointerLeave: () => i(!1),
1121
+ onFocus: () => o(!0),
1122
+ onBlur: (e) => {
1123
+ e.currentTarget.contains(e.relatedTarget) || o(!1);
1124
+ },
1125
+ onKeyDown: (n) => {
1126
+ n.key === "Escape" && (n.stopPropagation(), t(e.key));
1127
+ },
1128
+ children: [
1129
+ /* @__PURE__ */ d("span", {
1130
+ className: "toast-icon",
1131
+ "aria-hidden": "true"
1132
+ }),
1133
+ /* @__PURE__ */ f("div", {
1134
+ className: "toast-body",
1135
+ children: [
1136
+ e.title && /* @__PURE__ */ d("strong", {
1137
+ className: "toast-title",
1138
+ children: e.title
1139
+ }),
1140
+ /* @__PURE__ */ d("p", { children: e.message }),
1141
+ e.link && /* @__PURE__ */ d("a", {
1142
+ className: "text-link",
1143
+ href: e.link.href,
1144
+ children: e.link.label
1145
+ })
1146
+ ]
1147
+ }),
1148
+ /* @__PURE__ */ d("button", {
1149
+ type: "button",
1150
+ className: "toast-dismiss",
1151
+ "aria-label": "Dismiss notification",
1152
+ onClick: () => t(e.key),
1153
+ children: "×"
1154
+ })
1155
+ ]
1156
+ });
1157
+ }
1158
+ function Nn({ children: e }) {
1159
+ let [n, i] = c([]), [l, u] = c(!1), [p, m] = c({
1160
+ polite: "",
1161
+ assertive: "",
1162
+ count: 0
1163
+ }), h = s(null), g = t((e) => {
1164
+ i((t) => t.find((t) => t.key === e.key) ? t.map((t) => t.key === e.key ? {
1165
+ ...e,
1166
+ revision: t.revision + 1
1167
+ } : t) : [{
1168
+ ...e,
1169
+ revision: 0
1170
+ }, ...t]);
1171
+ let t = e.title ? `${e.title}: ${e.message}` : e.message;
1172
+ m((n) => {
1173
+ let r = n.count + 1, i = r % 2 ? t : `${t}​`;
1174
+ return e.tone === "error" ? {
1175
+ polite: "",
1176
+ assertive: i,
1177
+ count: r
1178
+ } : {
1179
+ polite: i,
1180
+ assertive: "",
1181
+ count: r
1182
+ };
1183
+ });
1184
+ }, []), _ = t((e) => i((t) => t.filter((t) => t.key !== e)), []), v = o(() => ({
1185
+ notify: g,
1186
+ dismiss: _
1187
+ }), [g, _]), y = n.length > 0;
1188
+ a(() => {
1189
+ let e = h.current, t = document.querySelector(".toolbar");
1190
+ if (!y || !e) return;
1191
+ let n = () => e.style.setProperty("--toast-top", `${Math.max(0, Math.ceil(t?.getBoundingClientRect().bottom ?? 0)) + 8}px`);
1192
+ n();
1193
+ let r = new ResizeObserver(n);
1194
+ return t && r.observe(t), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
1195
+ r.disconnect(), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
1196
+ };
1197
+ }, [y]), r(() => {
1198
+ n.length <= kn && u(!1);
1199
+ }, [n.length]);
1200
+ let b = l ? n : n.slice(0, kn), x = n.length - b.length;
1201
+ return /* @__PURE__ */ f(An.Provider, {
1202
+ value: v,
1203
+ children: [
1204
+ e,
1205
+ /* @__PURE__ */ f("section", {
1206
+ className: "toast-stack",
1207
+ ref: h,
1208
+ "aria-label": "Notifications",
1209
+ hidden: !y,
1210
+ children: [
1211
+ b.map((e) => /* @__PURE__ */ d(Mn, {
1212
+ toast: e,
1213
+ onDismiss: _
1214
+ }, e.key)),
1215
+ x > 0 && /* @__PURE__ */ f("button", {
1216
+ type: "button",
1217
+ className: "toast-more",
1218
+ onClick: () => u(!0),
1219
+ children: [
1220
+ x,
1221
+ " older ",
1222
+ x === 1 ? "notification" : "notifications"
1223
+ ]
1224
+ }),
1225
+ l && n.length > kn && /* @__PURE__ */ d("button", {
1226
+ type: "button",
1227
+ className: "toast-more",
1228
+ onClick: () => u(!1),
1229
+ children: "Show fewer"
1230
+ })
1231
+ ]
1232
+ }),
1233
+ /* @__PURE__ */ d("div", {
1234
+ className: "sr-only",
1235
+ role: "status",
1236
+ "aria-live": "polite",
1237
+ "aria-atomic": "true",
1238
+ children: p.polite
1239
+ }),
1240
+ /* @__PURE__ */ d("div", {
1241
+ className: "sr-only",
1242
+ role: "alert",
1243
+ "aria-live": "assertive",
1244
+ "aria-atomic": "true",
1245
+ children: p.assertive
1246
+ })
1247
+ ]
1248
+ });
1249
+ }
1250
+ function Pn({ inventory: e }) {
1251
+ let t = s(null), n = s(null), r = e.error, i = r ? e.data ? "stale" : "unavailable" : e.data?.failures.length ? "incomplete" : "";
1252
+ if (!i) return null;
1253
+ let a = r ? r.code === "partial" ? r.message.split("; ") : [`${g(r)}: ${r.message}`] : e.data?.failures ?? [], o = i === "stale" ? "The last refresh failed. Counts and lists show the previous inventory and may be out of date." : i === "unavailable" ? "The inventory could not be retrieved." : "Some scopes could not be loaded. Counts and lists exclude unavailable resources.", c = `Inventory ${i}`;
1254
+ return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("button", {
1255
+ ref: n,
1256
+ type: "button",
1257
+ className: `icon-button inventory-indicator ${i}`,
1258
+ popoverTarget: "inventory-status",
1259
+ "aria-label": `${c}: show details`,
1260
+ "data-tooltip": c,
1261
+ onClick: () => {
1262
+ let e = n.current?.getBoundingClientRect();
1263
+ if (!e || !t.current) return;
1264
+ t.current.style.setProperty("--popover-top", `${Math.ceil(e.bottom) + 6}px`);
1265
+ let r = Math.min(360, window.innerWidth - 32);
1266
+ t.current.style.setProperty("--popover-left", `${Math.max(16, Math.min(Math.floor(e.left), window.innerWidth - 16 - r))}px`);
1267
+ },
1268
+ children: /* @__PURE__ */ d(p, { name: "warning" })
1269
+ }), /* @__PURE__ */ f("div", {
1270
+ ref: t,
1271
+ id: "inventory-status",
1272
+ className: "inventory-popover",
1273
+ popover: "auto",
1274
+ role: "dialog",
1275
+ "aria-label": "Inventory status",
1276
+ children: [
1277
+ /* @__PURE__ */ f("h2", { children: [c[0].toUpperCase(), c.slice(1)] }),
1278
+ /* @__PURE__ */ d("p", { children: o }),
1279
+ a.length > 0 && /* @__PURE__ */ d("ul", { children: a.map((e) => /* @__PURE__ */ d("li", { children: e }, e)) }),
1280
+ /* @__PURE__ */ d("p", {
1281
+ className: "description",
1282
+ children: e.data?.updatedAt ? /* @__PURE__ */ f(u, { children: ["Last successful refresh: ", /* @__PURE__ */ d("time", {
1283
+ dateTime: e.data.updatedAt,
1284
+ children: new Date(e.data.updatedAt).toLocaleString()
1285
+ })] }) : "No successful refresh yet."
1286
+ })
1287
+ ]
1288
+ })] });
1289
+ }
1290
+ // src/connector-ui.tsx
1291
+ function $(e) {
1292
+ let t = e;
1293
+ return {
1294
+ code: t?.code ?? "unavailable",
1295
+ message: t?.message ?? "Request failed. Try again."
1296
+ };
1297
+ }
1298
+ async function Fn(e, t) {
1299
+ let n = await l(e, {
1300
+ method: "POST",
1301
+ headers: {
1302
+ Accept: "application/json",
1303
+ "Content-Type": "application/json"
1304
+ },
1305
+ body: typeof t == "string" ? t : JSON.stringify(t)
1306
+ }), r = await n.json().catch(() => ({}));
1307
+ if (!n.ok) throw r.error ?? {
1308
+ code: "http_error",
1309
+ message: `HTTP ${n.status}`
1310
+ };
1311
+ return r;
1312
+ }
1313
+ function In(e, t) {
1314
+ return `/connectors/${encodeURIComponent(e)}/${t}`;
1315
+ }
1316
+ function Ln(e, t) {
1317
+ let n = U(t);
1318
+ return Y("/connectors" + (e ? `/${encodeURIComponent(e)}` : "") + (e && n.length ? `?scope=${encodeURIComponent(JSON.stringify(n))}` : ""));
1319
+ }
1320
+ function Rn(e, t) {
1321
+ let n = U(t);
1322
+ return Y(`/connectors/${encodeURIComponent(e)}/new-identity` + (n.length ? `?scope=${encodeURIComponent(JSON.stringify(n))}` : ""));
1323
+ }
1324
+ function zn(e, t, n) {
1325
+ let r = P(t), i = U(n);
1326
+ return Y(`/connectors/${encodeURIComponent(e)}/rotate-identity` + (r ? `?identity=${encodeURIComponent(JSON.stringify([...L(r), r.name]))}` : "") + (i.length ? `${r ? "&" : "?"}scope=${encodeURIComponent(JSON.stringify(i))}` : ""));
1327
+ }
1328
+ function Bn(e) {
1329
+ return `${e[0].toUpperCase()}${e.slice(1)}`;
1330
+ }
1331
+ function Vn(e, t) {
1332
+ return `${Bn(e)} — ${U(V(t, e)).join(" / ")}`;
1333
+ }
1334
+ function Hn({ status: e }) {
1335
+ let t = e.state === "resolved" ? "ok" : z(e) ? "error" : "stopped";
1336
+ return /* @__PURE__ */ f("span", {
1337
+ className: `state-badge tone-${t}`,
1338
+ children: [/* @__PURE__ */ d("span", {
1339
+ className: "state-dot",
1340
+ "aria-hidden": "true"
1341
+ }), e.state === "resolved" ? "Resolved" : z(e) ? "Unresolved" : "Not set"]
1342
+ });
1343
+ }
1344
+ function Un(e) {
1345
+ return Y("/volumes/" + [
1346
+ e.realm,
1347
+ e.space,
1348
+ e.stack,
1349
+ e.name
1350
+ ].filter(Boolean).map((e) => encodeURIComponent(e)).join("/"));
1351
+ }
1352
+ function Wn({ status: e }) {
1353
+ return e.volumeRef ? /* @__PURE__ */ d("a", {
1354
+ className: "resource-name",
1355
+ href: Un(e.volumeRef),
1356
+ children: /* @__PURE__ */ d("code", { children: e.volumeRef.name })
1357
+ }) : e.volume ? /* @__PURE__ */ d("code", { children: e.volume }) : /* @__PURE__ */ d(u, { children: "of the harness" });
1358
+ }
1359
+ function Gn({ state: e }) {
1360
+ return /* @__PURE__ */ f("span", {
1361
+ className: `state-badge tone-${Ee(e)}`,
1362
+ children: [/* @__PURE__ */ d("span", {
1363
+ className: "state-dot",
1364
+ "aria-hidden": "true"
1365
+ }), Te(e)]
1366
+ });
1367
+ }
1368
+ function Kn({ status: e }) {
1369
+ return Ae(e) ? /* @__PURE__ */ f("span", {
1370
+ className: "connector-harness-state",
1371
+ children: [" · State: ", e.harnessState === "ephemeral" ? /* @__PURE__ */ f(u, { children: ["ephemeral ", /* @__PURE__ */ d("span", {
1372
+ className: "description",
1373
+ children: "(no state volume)"
1374
+ })] }) : /* @__PURE__ */ d(Wn, { status: e })]
1375
+ }) : null;
1376
+ }
1377
+ function qn({ status: e, team: t = "" }) {
1378
+ return W(e) ? /* @__PURE__ */ f("span", { children: [
1379
+ "Login identity ",
1380
+ /* @__PURE__ */ d(Wn, { status: e }),
1381
+ e.volumeRef && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d("span", {
1382
+ className: "description",
1383
+ children: L(e.volumeRef).join(" / ")
1384
+ })] }),
1385
+ e.origin && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d("span", {
1386
+ className: "badge",
1387
+ children: le(e.origin, t)
1388
+ })] }),
1389
+ e.login && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d(Gn, { state: e.login.state })] })
1390
+ ] }) : e.identity ? /* @__PURE__ */ f("span", { children: [
1391
+ /* @__PURE__ */ d("code", { children: e.identity.name }),
1392
+ " ",
1393
+ /* @__PURE__ */ d("span", {
1394
+ className: "description",
1395
+ children: L(e.identity).join(" / ")
1396
+ }),
1397
+ e.origin && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d("span", {
1398
+ className: "badge",
1399
+ children: le(e.origin, t)
1400
+ })] }),
1401
+ /* @__PURE__ */ d(Kn, { status: e })
1402
+ ] }) : /* @__PURE__ */ f("span", { children: [
1403
+ "No identity",
1404
+ e.required ? " — required" : "",
1405
+ /* @__PURE__ */ d(Kn, { status: e })
1406
+ ] });
1407
+ }
1408
+ async function Jn(e, t, n) {
1409
+ let [r] = we([(await Fn(In(e, "login"), Oe(t.name ?? "", t, n))).identity], e);
1410
+ return r?.session && xt(dn(De(r.session))), r;
1411
+ }
1412
+ function Yn({ connector: e, title: t, volume: n, state: r, running: i = !1, method: a, disabled: o = !1, idle: s = "Log in", className: l = "subtle-button", onStarted: p }) {
1413
+ let [m, h] = c(!1), [g, v] = c(), y = i ? "Open login session" : r === "logged in" ? "Log in again" : s;
1414
+ async function b() {
1415
+ if (!m) {
1416
+ h(!0), v(void 0);
1417
+ try {
1418
+ await Jn(e, n, a), p?.();
1419
+ } catch (e) {
1420
+ v($(e));
1421
+ } finally {
1422
+ h(!1);
1423
+ }
1424
+ }
1425
+ }
1426
+ return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("button", {
1427
+ type: "button",
1428
+ className: l,
1429
+ "aria-label": `${y}: ${t} identity ${R(n)}`,
1430
+ disabled: o || m,
1431
+ onClick: () => void b(),
1432
+ children: m ? "Starting…" : y
1433
+ }), g && /* @__PURE__ */ d(_, {
1434
+ error: g,
1435
+ kind: "Identity"
1436
+ })] });
1437
+ }
1438
+ function Xn({ label: e, identities: t, value: n, onChange: r, emptyLabel: a, extra: o = [], disabled: s = !1, help: c }) {
1439
+ let l = i(), u = t.map((e) => ({
1440
+ ref: e.volume,
1441
+ text: `${R(e.volume)} — ${Te(e.state)}${e.usedBy.length ? `, used by ${e.usedBy[0].name}${e.usedBy.length > 1 ? ` (+${e.usedBy.length - 1})` : ""}` : ""}`
1442
+ }));
1443
+ for (let e of o) e && !u.some((t) => I(t.ref, e)) && u.push({
1444
+ ref: e,
1445
+ text: R(e)
1446
+ });
1447
+ let p = F(n);
1448
+ return /* @__PURE__ */ f("div", {
1449
+ className: "schema-field secret-picker",
1450
+ children: [
1451
+ /* @__PURE__ */ d("label", {
1452
+ htmlFor: l,
1453
+ children: /* @__PURE__ */ d("span", { children: e })
1454
+ }),
1455
+ /* @__PURE__ */ f("select", {
1456
+ id: l,
1457
+ value: u.some((e) => F(e.ref) === p) ? p : "",
1458
+ disabled: s,
1459
+ onChange: (e) => r(u.find((t) => F(t.ref) === e.target.value)?.ref),
1460
+ children: [/* @__PURE__ */ d("option", {
1461
+ value: "",
1462
+ children: a
1463
+ }), u.map((e) => /* @__PURE__ */ d("option", {
1464
+ value: F(e.ref),
1465
+ children: e.text
1466
+ }, F(e.ref)))]
1467
+ }),
1468
+ c && /* @__PURE__ */ d("small", { children: c })
1469
+ ]
1470
+ });
1471
+ }
1472
+ function Zn({ label: e, identities: t, value: n, onChange: r, emptyLabel: a, extra: o = [], disabled: s = !1, required: l = !1, help: u, realm: p = "", id: m, invalid: h = !1 }) {
1473
+ let g = i(), _ = m ?? g, v = t.map((e) => ({
1474
+ ref: P(e),
1475
+ text: `${R(e)} (${e.type})`
1476
+ }));
1477
+ for (let e of o) e && !v.some((t) => F(t.ref) === F(e)) && v.push({
1478
+ ref: e,
1479
+ text: `${R(e)} (not tagged)`
1480
+ });
1481
+ let y = F(n), b = v.some((e) => F(e.ref) === y), [x, S] = c(!1), C = x || !!y && !b, w = (e, t) => r({
1482
+ ...n,
1483
+ [e]: t
1484
+ });
1485
+ return /* @__PURE__ */ f("div", {
1486
+ className: "schema-field secret-picker",
1487
+ children: [
1488
+ /* @__PURE__ */ d("label", {
1489
+ htmlFor: _,
1490
+ children: /* @__PURE__ */ f("span", { children: [e, l && /* @__PURE__ */ d("b", {
1491
+ "aria-label": "required",
1492
+ children: " *"
1493
+ })] })
1494
+ }),
1495
+ /* @__PURE__ */ f("select", {
1496
+ id: _,
1497
+ value: C ? "manual" : y,
1498
+ disabled: s,
1499
+ "aria-invalid": h || void 0,
1500
+ onChange: (e) => {
1501
+ e.target.value === "manual" ? (S(!0), r({
1502
+ name: "",
1503
+ realm: p
1504
+ })) : (S(!1), r(v.find((t) => F(t.ref) === e.target.value)?.ref));
1505
+ },
1506
+ children: [
1507
+ /* @__PURE__ */ d("option", {
1508
+ value: "",
1509
+ children: a
1510
+ }),
1511
+ v.map((e) => /* @__PURE__ */ d("option", {
1512
+ value: F(e.ref),
1513
+ children: e.text
1514
+ }, F(e.ref))),
1515
+ /* @__PURE__ */ d("option", {
1516
+ value: "manual",
1517
+ children: "Name a secret…"
1518
+ })
1519
+ ]
1520
+ }),
1521
+ C && /* @__PURE__ */ f("div", {
1522
+ className: "map-entry",
1523
+ children: [
1524
+ /* @__PURE__ */ f("label", { children: ["Secret name", /* @__PURE__ */ d("input", {
1525
+ "aria-label": `${e} secret name`,
1526
+ value: n?.name ?? "",
1527
+ disabled: s,
1528
+ onChange: (e) => w("name", e.target.value)
1529
+ })] }),
1530
+ /* @__PURE__ */ f("label", { children: ["Realm", /* @__PURE__ */ d("input", {
1531
+ "aria-label": `${e} secret realm`,
1532
+ value: n?.realm ?? "",
1533
+ disabled: s,
1534
+ onChange: (e) => w("realm", e.target.value)
1535
+ })] }),
1536
+ /* @__PURE__ */ f("label", { children: ["Space (optional)", /* @__PURE__ */ d("input", {
1537
+ "aria-label": `${e} secret space`,
1538
+ value: n?.space ?? "",
1539
+ disabled: s,
1540
+ onChange: (e) => w("space", e.target.value)
1541
+ })] }),
1542
+ /* @__PURE__ */ f("label", { children: ["Stack (optional)", /* @__PURE__ */ d("input", {
1543
+ "aria-label": `${e} secret stack`,
1544
+ value: n?.stack ?? "",
1545
+ disabled: s,
1546
+ onChange: (e) => w("stack", e.target.value)
1547
+ })] })
1548
+ ]
1549
+ }),
1550
+ u && /* @__PURE__ */ d("small", { children: u })
1551
+ ]
1552
+ });
1553
+ }
1554
+ function Qn({ title: e, description: t, children: n }) {
1555
+ let r = i();
1556
+ return /* @__PURE__ */ f("div", {
1557
+ className: "connector-store",
1558
+ role: "group",
1559
+ "aria-labelledby": r,
1560
+ children: [
1561
+ /* @__PURE__ */ d("h3", {
1562
+ id: r,
1563
+ children: e
1564
+ }),
1565
+ /* @__PURE__ */ d("p", {
1566
+ className: "description",
1567
+ children: t
1568
+ }),
1569
+ n
1570
+ ]
1571
+ });
1572
+ }
1573
+ function $n({ label: e, inventory: t, levels: n, value: r, onChange: i, disabled: a = !1 }) {
1574
+ let o = t.data?.rows ?? [
1575
+ [],
1576
+ [],
1577
+ [],
1578
+ []
1579
+ ], s = (e, t) => [.../* @__PURE__ */ new Set([...e, ...t ? [t] : []])], c = s(o[0].map((e) => e.scope[0]), r.realm), l = s(o[1].filter((e) => e.scope[0] === r.realm).map((e) => e.scope[1]), r.space), u = s(o[2].filter((e) => e.scope[0] === r.realm && e.scope[1] === r.space).map((e) => e.scope[2]), r.stack), [p, m, h] = T, g = n.includes(m) || n.includes(h);
1580
+ return /* @__PURE__ */ f("div", {
1581
+ className: "schema-fields scope-picker",
1582
+ children: [
1583
+ /* @__PURE__ */ f("label", {
1584
+ className: "schema-field",
1585
+ children: [/* @__PURE__ */ d("span", { children: "Realm" }), /* @__PURE__ */ f("select", {
1586
+ "aria-label": `${e} realm`,
1587
+ value: r.realm,
1588
+ disabled: a,
1589
+ onChange: (e) => i({ realm: e.target.value }),
1590
+ children: [/* @__PURE__ */ d("option", {
1591
+ value: "",
1592
+ children: "Select a Realm…"
1593
+ }), c.map((e) => /* @__PURE__ */ d("option", { children: e }, e))]
1594
+ })]
1595
+ }),
1596
+ g && /* @__PURE__ */ f("label", {
1597
+ className: "schema-field",
1598
+ children: [/* @__PURE__ */ d("span", { children: "Space" }), /* @__PURE__ */ f("select", {
1599
+ "aria-label": `${e} space`,
1600
+ value: r.space ?? "",
1601
+ disabled: a || !r.realm,
1602
+ onChange: (e) => i({
1603
+ realm: r.realm,
1604
+ ...e.target.value ? { space: e.target.value } : {}
1605
+ }),
1606
+ children: [/* @__PURE__ */ d("option", {
1607
+ value: "",
1608
+ children: n.includes(p) ? "Realm level" : "Select a Space…"
1609
+ }), l.map((e) => /* @__PURE__ */ d("option", { children: e }, e))]
1610
+ })]
1611
+ }),
1612
+ n.includes(h) && /* @__PURE__ */ f("label", {
1613
+ className: "schema-field",
1614
+ children: [/* @__PURE__ */ d("span", { children: "Stack" }), /* @__PURE__ */ f("select", {
1615
+ "aria-label": `${e} stack`,
1616
+ value: r.stack ?? "",
1617
+ disabled: a || !r.space,
1618
+ onChange: (e) => i({
1619
+ realm: r.realm,
1620
+ space: r.space,
1621
+ ...e.target.value ? { stack: e.target.value } : {}
1622
+ }),
1623
+ children: [/* @__PURE__ */ d("option", {
1624
+ value: "",
1625
+ children: n.includes(m) ? "Space level" : "Select a Stack…"
1626
+ }), u.map((e) => /* @__PURE__ */ d("option", { children: e }, e))]
1627
+ })]
1628
+ })
1629
+ ]
1630
+ });
1631
+ }
1632
+ function er({ label: e, connector: t, inventory: n, value: r, onChange: a, disabled: o = !1 }) {
1633
+ let s = i(), c = n.data?.rows ?? [
1634
+ [],
1635
+ [],
1636
+ [],
1637
+ []
1638
+ ], l = (e, t) => [.../* @__PURE__ */ new Set([...e, ...t ? [t] : []])], p = (e) => c[1].filter((t) => t.scope[0] === e).map((e) => e.scope[1]), m = (e, t) => c[2].filter((n) => n.scope[0] === e && n.scope[1] === t).map((e) => e.scope[2]), h = l(c[0].map((e) => e.scope[0]), r.realm), g = H(r), [, _, v] = T;
1639
+ return /* @__PURE__ */ f("fieldset", {
1640
+ className: "connector-store scope-radio",
1641
+ disabled: o,
1642
+ children: [
1643
+ /* @__PURE__ */ d("legend", { children: "Where can cells use it?" }),
1644
+ h.length > 1 && /* @__PURE__ */ f("label", {
1645
+ className: "schema-field",
1646
+ children: [/* @__PURE__ */ d("span", { children: "Realm" }), /* @__PURE__ */ f("select", {
1647
+ "aria-label": `${e} realm`,
1648
+ value: r.realm,
1649
+ onChange: (e) => a(tt({ realm: e.target.value }, g, p, m) ?? { realm: e.target.value }),
1650
+ children: [/* @__PURE__ */ d("option", {
1651
+ value: "",
1652
+ children: "Select a Realm…"
1653
+ }), h.map((e) => /* @__PURE__ */ d("option", { children: e }, e))]
1654
+ })]
1655
+ }),
1656
+ et(t, r.realm).map((e) => {
1657
+ let t = tt(r, e.level, p, m);
1658
+ return /* @__PURE__ */ f("label", {
1659
+ className: "schema-check",
1660
+ children: [/* @__PURE__ */ d("input", {
1661
+ type: "radio",
1662
+ name: s,
1663
+ checked: g === e.level,
1664
+ disabled: !t,
1665
+ onChange: () => t && a(t)
1666
+ }), /* @__PURE__ */ f("span", { children: [
1667
+ e.label,
1668
+ e.recommended && /* @__PURE__ */ d("span", {
1669
+ className: "description",
1670
+ children: " (recommended)"
1671
+ }),
1672
+ !t && r.realm && /* @__PURE__ */ f("span", {
1673
+ className: "description",
1674
+ children: [" — none in ", r.realm]
1675
+ })
1676
+ ] })]
1677
+ }, e.level);
1678
+ }),
1679
+ g !== T[0] && /* @__PURE__ */ f("div", {
1680
+ className: "schema-fields scope-picker",
1681
+ children: [/* @__PURE__ */ f("label", {
1682
+ className: "schema-field",
1683
+ children: [/* @__PURE__ */ d("span", { children: "Space" }), /* @__PURE__ */ d("select", {
1684
+ "aria-label": `${e} space`,
1685
+ value: r.space ?? "",
1686
+ onChange: (e) => a(tt({
1687
+ realm: r.realm,
1688
+ space: e.target.value
1689
+ }, g, p, m) ?? {
1690
+ realm: r.realm,
1691
+ space: e.target.value
1692
+ }),
1693
+ children: l(p(r.realm), r.space).map((e) => /* @__PURE__ */ d("option", { children: e }, e))
1694
+ })]
1695
+ }), g === v && /* @__PURE__ */ f("label", {
1696
+ className: "schema-field",
1697
+ children: [/* @__PURE__ */ d("span", { children: "Stack" }), /* @__PURE__ */ d("select", {
1698
+ "aria-label": `${e} stack`,
1699
+ value: r.stack ?? "",
1700
+ onChange: (e) => a({
1701
+ realm: r.realm,
1702
+ space: r.space,
1703
+ stack: e.target.value
1704
+ }),
1705
+ children: l(m(r.realm, r.space ?? ""), r.stack).map((e) => /* @__PURE__ */ d("option", { children: e }, e))
1706
+ })]
1707
+ })]
1708
+ }),
1709
+ /* @__PURE__ */ d("p", {
1710
+ className: "description",
1711
+ children: g === T[0] ? /* @__PURE__ */ f(u, { children: [
1712
+ "Every cell in ",
1713
+ r.realm ? /* @__PURE__ */ d("code", { children: r.realm }) : "the realm",
1714
+ " can be given this identity."
1715
+ ] }) : g === _ ? /* @__PURE__ */ d(u, { children: "Only cells in this Space can be given it." }) : /* @__PURE__ */ d(u, { children: "Only cells in this Stack can be given it." })
1716
+ })
1717
+ ]
1718
+ });
1719
+ }
1720
+ function tr({ connector: e, value: t, onChange: n, disabled: r }) {
1721
+ let a = i();
1722
+ return /* @__PURE__ */ f("fieldset", {
1723
+ className: "schema-field secret-type-choice",
1724
+ disabled: r,
1725
+ children: [/* @__PURE__ */ d("legend", { children: "Secret type" }), $e(e).map((e) => /* @__PURE__ */ f("label", {
1726
+ className: "schema-check",
1727
+ children: [/* @__PURE__ */ d("input", {
1728
+ type: "radio",
1729
+ name: a,
1730
+ value: e.type,
1731
+ checked: t === e.type,
1732
+ onChange: () => n(e.type)
1733
+ }), /* @__PURE__ */ f("span", { children: [
1734
+ e.label,
1735
+ " — ",
1736
+ e.description
1737
+ ] })]
1738
+ }, e.type))]
1739
+ });
1740
+ }
1741
+ function nr({ label: e, required: t = !1, name: n, email: r, onChange: i, disabled: a, help: o }) {
1742
+ return /* @__PURE__ */ f("div", {
1743
+ className: "schema-field person-fields",
1744
+ role: "group",
1745
+ "aria-label": e,
1746
+ children: [
1747
+ /* @__PURE__ */ f("span", { children: [e, t && /* @__PURE__ */ d("b", {
1748
+ "aria-label": "required",
1749
+ children: " *"
1750
+ })] }),
1751
+ /* @__PURE__ */ f("div", {
1752
+ className: "person-fields-inputs",
1753
+ children: [/* @__PURE__ */ f("label", { children: [/* @__PURE__ */ d("span", { children: "Name" }), /* @__PURE__ */ d("input", {
1754
+ "aria-label": `${e} name`,
1755
+ value: n,
1756
+ disabled: a,
1757
+ autoComplete: "off",
1758
+ spellCheck: !1,
1759
+ onChange: (e) => i(e.target.value, r)
1760
+ })] }), /* @__PURE__ */ f("label", { children: [/* @__PURE__ */ d("span", { children: "Email" }), /* @__PURE__ */ d("input", {
1761
+ type: "email",
1762
+ "aria-label": `${e} email`,
1763
+ value: r,
1764
+ disabled: a,
1765
+ autoComplete: "off",
1766
+ spellCheck: !1,
1767
+ onChange: (e) => i(n, e.target.value)
1768
+ })] })]
1769
+ }),
1770
+ o
1771
+ ]
1772
+ });
1773
+ }
1774
+ function rr({ field: e, value: t, onChange: n, disabled: r, help: i }) {
1775
+ let [a, o] = c(() => at(t)), l = s(t);
1776
+ return t !== l.current && (l.current = t, o(at(t))), /* @__PURE__ */ d(nr, {
1777
+ label: e.name,
1778
+ required: e.required,
1779
+ name: a.name,
1780
+ email: a.email,
1781
+ disabled: r,
1782
+ help: i,
1783
+ onChange: (e, t) => {
1784
+ o({
1785
+ name: e,
1786
+ email: t
1787
+ }), l.current = ot(e, t), n(l.current);
1788
+ }
1789
+ });
1790
+ }
1791
+ function ir({ field: e, value: t, onChange: n, disabled: r, secrets: i, listId: a }) {
1792
+ let o = /* @__PURE__ */ f("span", { children: [e.name, e.required && /* @__PURE__ */ d("b", {
1793
+ "aria-label": "required",
1794
+ children: " *"
1795
+ })] }), s = e.help && /* @__PURE__ */ d("small", { children: e.help });
1796
+ if (e.type === "list" && e.enum.length) {
1797
+ let i = t.split(",").map((e) => e.trim()).filter(Boolean);
1798
+ return /* @__PURE__ */ f("div", {
1799
+ className: "schema-field",
1800
+ role: "group",
1801
+ "aria-label": e.name,
1802
+ children: [
1803
+ o,
1804
+ e.enum.map((t) => /* @__PURE__ */ f("label", {
1805
+ className: "schema-check",
1806
+ children: [/* @__PURE__ */ d("input", {
1807
+ type: "checkbox",
1808
+ checked: i.includes(t),
1809
+ disabled: r,
1810
+ onChange: (r) => n(e.enum.filter((e) => e === t ? r.target.checked : i.includes(e)).join(","))
1811
+ }), t]
1812
+ }, t)),
1813
+ s
1814
+ ]
1815
+ });
1816
+ }
1817
+ return e.enum.length ? /* @__PURE__ */ f("label", {
1818
+ className: "schema-field",
1819
+ children: [
1820
+ o,
1821
+ /* @__PURE__ */ f("select", {
1822
+ value: t,
1823
+ disabled: r,
1824
+ onChange: (e) => n(e.target.value),
1825
+ children: [/* @__PURE__ */ d("option", {
1826
+ value: "",
1827
+ children: e.required ? "Select…" : "None"
1828
+ }), e.enum.map((e) => /* @__PURE__ */ d("option", { children: e }, e))]
1829
+ }),
1830
+ s
1831
+ ]
1832
+ }) : e.type === "secret" ? /* @__PURE__ */ f("label", {
1833
+ className: "schema-field",
1834
+ children: [
1835
+ o,
1836
+ /* @__PURE__ */ d("input", {
1837
+ value: t,
1838
+ list: a,
1839
+ placeholder: "name@realm[/space[/stack]]",
1840
+ disabled: r,
1841
+ autoComplete: "off",
1842
+ spellCheck: !1,
1843
+ onChange: (e) => n(e.target.value)
1844
+ }),
1845
+ /* @__PURE__ */ d("datalist", {
1846
+ id: a,
1847
+ children: (i ?? []).map((e) => ae(e.metadata)).filter(Boolean).map((e) => /* @__PURE__ */ d("option", { value: e }, e))
1848
+ }),
1849
+ s
1850
+ ]
1851
+ }) : e.type === "person" ? /* @__PURE__ */ d(rr, {
1852
+ field: e,
1853
+ value: t,
1854
+ onChange: n,
1855
+ disabled: r,
1856
+ help: s
1857
+ }) : /* @__PURE__ */ f("label", {
1858
+ className: "schema-field",
1859
+ children: [
1860
+ o,
1861
+ /* @__PURE__ */ d("input", {
1862
+ value: t,
1863
+ placeholder: e.type === "list" ? "Comma-separated" : void 0,
1864
+ disabled: r,
1865
+ autoComplete: "off",
1866
+ spellCheck: !1,
1867
+ onChange: (e) => n(e.target.value)
1868
+ }),
1869
+ s
1870
+ ]
1871
+ });
1872
+ }
1873
+ function ar({ type: e, form: t, set: n, pending: r, authorOnly: i = !1, valueLabel: a = "Value" }) {
1874
+ let o = {
1875
+ autoComplete: "new-password",
1876
+ spellCheck: !1,
1877
+ disabled: r
1878
+ };
1879
+ return /* @__PURE__ */ d("div", {
1880
+ className: "schema-fields",
1881
+ children: e === "basic-auth" ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("label", {
1882
+ className: "schema-field",
1883
+ children: [/* @__PURE__ */ f("span", { children: ["Username", /* @__PURE__ */ d("b", {
1884
+ "aria-label": "required",
1885
+ children: " *"
1886
+ })] }), /* @__PURE__ */ d("input", {
1887
+ value: t.username,
1888
+ autoComplete: "off",
1889
+ spellCheck: !1,
1890
+ disabled: r,
1891
+ onChange: (e) => n({ username: e.target.value })
1892
+ })]
1893
+ }), /* @__PURE__ */ f("label", {
1894
+ className: "schema-field",
1895
+ children: [/* @__PURE__ */ f("span", { children: ["Password or token", /* @__PURE__ */ d("b", {
1896
+ "aria-label": "required",
1897
+ children: " *"
1898
+ })] }), /* @__PURE__ */ d("input", {
1899
+ type: "password",
1900
+ value: t.password,
1901
+ ...o,
1902
+ onChange: (e) => n({ password: e.target.value })
1903
+ })]
1904
+ })] }) : e === "ssh-key" ? /* @__PURE__ */ f(u, { children: [
1905
+ /* @__PURE__ */ f("label", {
1906
+ className: "schema-field identity-key",
1907
+ children: [/* @__PURE__ */ f("span", { children: ["Private key", /* @__PURE__ */ d("b", {
1908
+ "aria-label": "required",
1909
+ children: " *"
1910
+ })] }), /* @__PURE__ */ d("textarea", {
1911
+ value: t.privateKey,
1912
+ placeholder: "Paste the private key, armor lines included",
1913
+ ...o,
1914
+ onChange: (e) => n({ privateKey: e.target.value })
1915
+ })]
1916
+ }),
1917
+ /* @__PURE__ */ f("label", {
1918
+ className: "schema-field",
1919
+ children: [/* @__PURE__ */ d("span", { children: "Passphrase" }), /* @__PURE__ */ d("input", {
1920
+ type: "password",
1921
+ value: t.passphrase,
1922
+ ...o,
1923
+ onChange: (e) => n({ passphrase: e.target.value })
1924
+ })]
1925
+ }),
1926
+ /* @__PURE__ */ f("label", {
1927
+ className: "schema-field",
1928
+ children: [/* @__PURE__ */ d("span", { children: "Public key" }), /* @__PURE__ */ d("input", {
1929
+ value: t.publicKey,
1930
+ placeholder: "ssh-ed25519 AAAA…",
1931
+ autoComplete: "off",
1932
+ spellCheck: !1,
1933
+ disabled: r,
1934
+ onChange: (e) => n({ publicKey: e.target.value })
1935
+ })]
1936
+ }),
1937
+ /* @__PURE__ */ f("label", {
1938
+ className: "schema-field",
1939
+ children: [/* @__PURE__ */ d("span", { children: "Certificate" }), /* @__PURE__ */ d("input", {
1940
+ value: t.certificate,
1941
+ autoComplete: "off",
1942
+ spellCheck: !1,
1943
+ disabled: r,
1944
+ onChange: (e) => n({ certificate: e.target.value })
1945
+ })]
1946
+ }),
1947
+ /* @__PURE__ */ f("label", {
1948
+ className: "schema-field identity-key",
1949
+ children: [/* @__PURE__ */ d("span", { children: "Known hosts" }), /* @__PURE__ */ d("textarea", {
1950
+ value: t.knownHosts,
1951
+ placeholder: "example.com ssh-ed25519 AAAA…",
1952
+ autoComplete: "off",
1953
+ spellCheck: !1,
1954
+ disabled: r,
1955
+ onChange: (e) => n({ knownHosts: e.target.value })
1956
+ })]
1957
+ })
1958
+ ] }) : i ? /* @__PURE__ */ d("p", {
1959
+ className: "description identity-no-value",
1960
+ children: "An author-only identity: it stores no value, and gives cells the author and committer only — no credential and no signing."
1961
+ }) : /* @__PURE__ */ f("label", {
1962
+ className: "schema-field",
1963
+ children: [/* @__PURE__ */ f("span", { children: [a, /* @__PURE__ */ d("b", {
1964
+ "aria-label": "required",
1965
+ children: " *"
1966
+ })] }), /* @__PURE__ */ d("input", {
1967
+ type: "password",
1968
+ value: t.value,
1969
+ ...o,
1970
+ onChange: (e) => n({ value: e.target.value })
1971
+ })]
1972
+ })
1973
+ });
1974
+ }
1975
+ function or({ connector: e, scope: t, existing: n, secrets: r, onSaved: a, onCancel: o, offerDefault: s = !0 }) {
1976
+ let l = q(e), p = n ? We(r, e, n) : void 0, [h, g] = c(() => Ve(e, n)), [v, y] = c(() => Je(!!l && (!n || !!p))), b = s ? ge(e) : [], [x, S] = c(() => (b.find((t) => e.methods.find((e) => e.name === t.method)?.default) ?? b[0])?.method ?? ""), C = b.find((e) => e.method === x) ?? b[0], w = m(C && t.realm ? `/connectors/defaults?${he(t)}` : null, 0), [T, E] = c(), D = T ?? (!!C && (v.git && !n || !!w.data && nt(w.data, e, C))), [O, ee] = c(!1), [te, k] = c(), { notify: ne } = jn(), re = i(), ie = K(e), A = e.title || e.name, j = U(t).join(" / "), M = !!l && v.git && h.type === "opaque", N = l?.hosts.join(", ") ?? "", I = (e) => {
1977
+ g((t) => ({
1978
+ ...t,
1979
+ ...e
1980
+ })), k(void 0);
1981
+ };
1982
+ async function R(r) {
1983
+ if (r.preventDefault(), O) return;
1984
+ let i = t.realm ? [...ct(e, h), ...M ? Xe(v) : []] : ["Choose where the identity is stored."];
1985
+ if (i.length) {
1986
+ k({
1987
+ code: "invalid_request",
1988
+ message: i.join(" ")
1989
+ });
1990
+ return;
1991
+ }
1992
+ let o = JSON.stringify(lt(e, t, h, {
1993
+ makeDefault: !!C && D,
1994
+ method: C?.method,
1995
+ git: M ? Ye(v) : void 0
1996
+ }));
1997
+ g((e) => ut(e)), ee(!0), k(void 0);
1998
+ try {
1999
+ let r = await Fn(In(e.name, "identities"), o), i = P({
2000
+ name: r.name,
2001
+ ...r.scope
2002
+ }) ?? P({
2003
+ name: h.name,
2004
+ ...t
2005
+ }), s = L(i).join(" / "), c = (e) => e === "updated" ? "rotated" : "created", l = [`${A} identity ${i.name} ${c(r.action)} in ${s}.`];
2006
+ r.git && l.push(`Git identity ${r.git.name} ${c(r.git.action)} for ${N}.`), r.defaults?.length && l.push(r.defaults.length > 1 ? `Both are now the defaults in ${s}.` : `It is now the default in ${s}.`);
2007
+ let u = qe(r);
2008
+ u && l.push(u), ne({
2009
+ key: `identity:${e.name}:${F(i)}`,
2010
+ tone: u ? "warning" : "success",
2011
+ message: l.join(" ")
2012
+ }), n || g(Ve(e)), a(i, r.action);
2013
+ } catch (e) {
2014
+ k($(e));
2015
+ } finally {
2016
+ ee(!1);
2017
+ }
2018
+ }
2019
+ return /* @__PURE__ */ f("form", {
2020
+ className: "creation-form identity-form",
2021
+ "aria-label": n ? `Rotate ${A} identity ${n.name}` : `New ${A} identity`,
2022
+ method: "post",
2023
+ autoComplete: "off",
2024
+ onSubmit: R,
2025
+ children: [
2026
+ /* @__PURE__ */ d("h3", { children: n ? `Rotate ${n.name}` : `New ${A} identity` }),
2027
+ /* @__PURE__ */ f("p", {
2028
+ className: "description",
2029
+ children: [n ? /* @__PURE__ */ f(u, { children: [
2030
+ "Replaces the value stored under ",
2031
+ /* @__PURE__ */ d("code", { children: n.name }),
2032
+ " in ",
2033
+ j,
2034
+ ". Everything that uses this identity picks up the new value."
2035
+ ] }) : /* @__PURE__ */ f(u, { children: [
2036
+ "Stored as a Secret tagged ",
2037
+ /* @__PURE__ */ d("code", { children: e.name }),
2038
+ j && /* @__PURE__ */ f(u, { children: [" in ", j] }),
2039
+ "."
2040
+ ] }), " Values are write-only: they are sent once and never shown again."]
2041
+ }),
2042
+ /* @__PURE__ */ f("div", {
2043
+ className: "schema-fields",
2044
+ children: [
2045
+ /* @__PURE__ */ f("label", {
2046
+ className: "schema-field",
2047
+ children: [/* @__PURE__ */ f("span", { children: ["Identity name", /* @__PURE__ */ d("b", {
2048
+ "aria-label": "required",
2049
+ children: " *"
2050
+ })] }), /* @__PURE__ */ d("input", {
2051
+ value: h.name,
2052
+ disabled: O || !!n,
2053
+ autoComplete: "off",
2054
+ spellCheck: !1,
2055
+ onChange: (e) => I({ name: e.target.value })
2056
+ })]
2057
+ }),
2058
+ ie.length > 1 && /* @__PURE__ */ d(tr, {
2059
+ connector: e,
2060
+ value: h.type,
2061
+ disabled: O,
2062
+ onChange: (e) => I({ type: e })
2063
+ }),
2064
+ Le(e, h.type).map((e) => /* @__PURE__ */ d(ir, {
2065
+ field: e,
2066
+ value: h.fields[e.name] ?? "",
2067
+ disabled: O,
2068
+ secrets: r,
2069
+ listId: `${re}-${e.name}`,
2070
+ onChange: (t) => I({ fields: {
2071
+ ...h.fields,
2072
+ [e.name]: t
2073
+ } })
2074
+ }, e.name))
2075
+ ]
2076
+ }),
2077
+ /* @__PURE__ */ d(ar, {
2078
+ type: h.type,
2079
+ form: h,
2080
+ set: I,
2081
+ pending: O,
2082
+ authorOnly: Re(e, h.type),
2083
+ valueLabel: l ? "Token" : "Value"
2084
+ }),
2085
+ l && h.type === "opaque" && /* @__PURE__ */ f("div", {
2086
+ className: "schema-fields token-for-git",
2087
+ role: "group",
2088
+ "aria-label": "Use for git",
2089
+ children: [/* @__PURE__ */ f("label", {
2090
+ className: "schema-check",
2091
+ children: [
2092
+ /* @__PURE__ */ d("input", {
2093
+ type: "checkbox",
2094
+ checked: v.git,
2095
+ disabled: O,
2096
+ onChange: (e) => {
2097
+ y((t) => ({
2098
+ ...t,
2099
+ git: e.target.checked
2100
+ })), k(void 0);
2101
+ }
2102
+ }),
2103
+ "Also use this token for git on ",
2104
+ N
2105
+ ]
2106
+ }), v.git ? /* @__PURE__ */ f(u, { children: [
2107
+ /* @__PURE__ */ f("p", {
2108
+ className: "description",
2109
+ children: [
2110
+ p ? /* @__PURE__ */ f(u, { children: [
2111
+ "Rotates the linked git identity ",
2112
+ /* @__PURE__ */ d("code", { children: p.name }),
2113
+ " too."
2114
+ ] }) : /* @__PURE__ */ f(u, { children: [
2115
+ "Also stored as the git identity ",
2116
+ /* @__PURE__ */ d("code", { children: l.name }),
2117
+ ": username and token, for HTTPS on ",
2118
+ N,
2119
+ " only."
2120
+ ] }),
2121
+ " Signing needs an SSH key: ",
2122
+ /* @__PURE__ */ d("a", {
2123
+ href: Rn(l.connector, t),
2124
+ children: "Import from this machine"
2125
+ }),
2126
+ "."
2127
+ ]
2128
+ }),
2129
+ /* @__PURE__ */ d(nr, {
2130
+ label: "Commit author",
2131
+ name: v.gitAuthorName,
2132
+ email: v.gitAuthorEmail,
2133
+ disabled: O,
2134
+ help: /* @__PURE__ */ d("small", { children: "Optional. The name and email of commits made with this identity." }),
2135
+ onChange: (e, t) => {
2136
+ y((n) => ({
2137
+ ...n,
2138
+ gitAuthorName: e,
2139
+ gitAuthorEmail: t
2140
+ })), k(void 0);
2141
+ }
2142
+ }),
2143
+ /* @__PURE__ */ f("label", {
2144
+ className: "schema-field",
2145
+ children: [
2146
+ /* @__PURE__ */ d("span", { children: "Username" }),
2147
+ /* @__PURE__ */ d("input", {
2148
+ value: v.gitUsername,
2149
+ placeholder: l.username,
2150
+ disabled: O,
2151
+ autoComplete: "off",
2152
+ spellCheck: !1,
2153
+ onChange: (e) => {
2154
+ y((t) => ({
2155
+ ...t,
2156
+ gitUsername: e.target.value
2157
+ })), k(void 0);
2158
+ }
2159
+ }),
2160
+ /* @__PURE__ */ f("small", { children: [
2161
+ "Optional. ",
2162
+ A,
2163
+ " accepts any non-empty username with a personal access token; empty stores ",
2164
+ /* @__PURE__ */ d("code", { children: l.username }),
2165
+ "."
2166
+ ] })
2167
+ ]
2168
+ })
2169
+ ] }) : /* @__PURE__ */ f("p", {
2170
+ className: "description",
2171
+ children: ["Git is unchanged: the token reaches cells as an API token only.", p && /* @__PURE__ */ f(u, { children: [
2172
+ " The linked git identity ",
2173
+ /* @__PURE__ */ d("code", { children: p.name }),
2174
+ " keeps the previous token: check the box to rotate it too."
2175
+ ] })]
2176
+ })]
2177
+ }),
2178
+ C && /* @__PURE__ */ f("div", {
2179
+ className: "schema-fields identity-default",
2180
+ children: [
2181
+ /* @__PURE__ */ f("label", {
2182
+ className: "schema-check",
2183
+ children: [
2184
+ /* @__PURE__ */ d("input", {
2185
+ type: "checkbox",
2186
+ checked: D,
2187
+ disabled: O,
2188
+ onChange: (e) => E(e.target.checked)
2189
+ }),
2190
+ "Make this the default",
2191
+ j && /* @__PURE__ */ f(u, { children: [" in ", j] })
2192
+ ]
2193
+ }),
2194
+ b.length > 1 && /* @__PURE__ */ f("label", {
2195
+ className: "schema-field",
2196
+ children: [/* @__PURE__ */ d("span", { children: "Default for" }), /* @__PURE__ */ d("select", {
2197
+ "aria-label": `${A} default method`,
2198
+ value: C.method,
2199
+ disabled: O || !D,
2200
+ onChange: (e) => {
2201
+ S(e.target.value), E(void 0);
2202
+ },
2203
+ children: b.map((e) => /* @__PURE__ */ f("option", {
2204
+ value: e.method,
2205
+ children: [e.method, " method"]
2206
+ }, e.method))
2207
+ })]
2208
+ }),
2209
+ /* @__PURE__ */ d("small", {
2210
+ className: "description",
2211
+ children: D ? M ? /* @__PURE__ */ f(u, { children: [
2212
+ "Cells here that pick no identity get this token for ",
2213
+ A,
2214
+ " and for git."
2215
+ ] }) : /* @__PURE__ */ d(u, { children: "Cells here that pick no identity get this one." }) : /* @__PURE__ */ f(u, { children: [
2216
+ "Stored only: set a default later on the ",
2217
+ A,
2218
+ " page."
2219
+ ] })
2220
+ })
2221
+ ]
2222
+ }),
2223
+ /* @__PURE__ */ f("div", {
2224
+ className: "connector-actions",
2225
+ children: [/* @__PURE__ */ d("button", {
2226
+ type: "submit",
2227
+ disabled: O,
2228
+ children: O ? "Saving…" : n ? "Rotate identity" : "Create identity"
2229
+ }), o && /* @__PURE__ */ d("button", {
2230
+ type: "button",
2231
+ className: "subtle-button",
2232
+ disabled: O,
2233
+ onClick: o,
2234
+ children: "Cancel"
2235
+ })]
2236
+ }),
2237
+ te && /* @__PURE__ */ d(_, {
2238
+ error: te,
2239
+ kind: "Identity"
2240
+ })
2241
+ ]
2242
+ });
2243
+ }
2244
+ function sr({ status: e, connector: t, scope: n, identities: r, secrets: i, onChanged: a, onClose: o }) {
2245
+ let s = me(t, n), [l, u] = c(s[0] ?? T[0]), [p, m] = c(), [h, g] = c(!1), [v, y] = c(!1), [b, x] = c(), { notify: S } = jn(), C = B(e), w = V(n, l), E = P(p);
2246
+ async function D() {
2247
+ if (E && !v) {
2248
+ y(!0), x(void 0);
2249
+ try {
2250
+ await Fn(In(e.connector, "defaults"), {
2251
+ scope: w,
2252
+ ...e.method ? { method: e.method } : {},
2253
+ identity: E
2254
+ }), S({
2255
+ key: `connector-default:${e.connector}`,
2256
+ tone: "success",
2257
+ message: `${C} default set to ${E.name} at ${Vn(l, n)}.`
2258
+ }), a(), o();
2259
+ } catch (e) {
2260
+ x($(e));
2261
+ } finally {
2262
+ y(!1);
2263
+ }
2264
+ }
2265
+ }
2266
+ return /* @__PURE__ */ f("div", {
2267
+ className: "connector-fix",
2268
+ role: "group",
2269
+ "aria-label": `Set default for ${C}`,
2270
+ children: [
2271
+ /* @__PURE__ */ f("p", {
2272
+ className: "description",
2273
+ children: [
2274
+ "A default fills ",
2275
+ C,
2276
+ " for every Config in the scope that picked no identity of its own. No Config is rewritten."
2277
+ ]
2278
+ }),
2279
+ /* @__PURE__ */ f("div", {
2280
+ className: "schema-fields",
2281
+ children: [/* @__PURE__ */ f("label", {
2282
+ className: "schema-field",
2283
+ children: [/* @__PURE__ */ d("span", { children: "Level" }), /* @__PURE__ */ d("select", {
2284
+ "aria-label": `${C} default level`,
2285
+ value: l,
2286
+ disabled: v,
2287
+ onChange: (e) => u(e.target.value),
2288
+ children: s.map((e) => /* @__PURE__ */ d("option", {
2289
+ value: e,
2290
+ children: Vn(e, n)
2291
+ }, e))
2292
+ })]
2293
+ }), /* @__PURE__ */ d(Zn, {
2294
+ label: `${C} default identity`,
2295
+ identities: r,
2296
+ value: p,
2297
+ extra: [E],
2298
+ emptyLabel: "Select an identity…",
2299
+ disabled: v,
2300
+ realm: n.realm,
2301
+ onChange: m
2302
+ })]
2303
+ }),
2304
+ /* @__PURE__ */ f("div", {
2305
+ className: "connector-actions",
2306
+ children: [
2307
+ /* @__PURE__ */ d("button", {
2308
+ type: "button",
2309
+ disabled: !E || v || !s.length,
2310
+ onClick: () => void D(),
2311
+ children: v ? "Saving…" : "Save default"
2312
+ }),
2313
+ t && /* @__PURE__ */ d("button", {
2314
+ type: "button",
2315
+ className: "subtle-button",
2316
+ "aria-expanded": h,
2317
+ disabled: v,
2318
+ onClick: () => g((e) => !e),
2319
+ children: h ? "Hide new identity" : "Create a new identity…"
2320
+ }),
2321
+ /* @__PURE__ */ d("button", {
2322
+ type: "button",
2323
+ className: "subtle-button",
2324
+ disabled: v,
2325
+ onClick: o,
2326
+ children: "Cancel"
2327
+ })
2328
+ ]
2329
+ }),
2330
+ h && t && /* @__PURE__ */ d(or, {
2331
+ connector: t,
2332
+ scope: w,
2333
+ secrets: i,
2334
+ offerDefault: !1,
2335
+ onSaved: (e) => {
2336
+ m(e), g(!1), a();
2337
+ },
2338
+ onCancel: () => g(!1)
2339
+ }),
2340
+ b && /* @__PURE__ */ d(_, {
2341
+ error: b,
2342
+ kind: "Scope"
2343
+ })
2344
+ ]
2345
+ });
2346
+ }
2347
+ function cr({ status: e, config: t, identities: n, logins: r = [], onChanged: i, onClose: a }) {
2348
+ let o = W(e), [s, l] = c(o ? G(e) : e.origin === "config" ? e.identity : void 0), [p, m] = c(!1), [h, g] = c(), { notify: v } = jn(), y = B(e), b = P(s);
2349
+ async function x(n) {
2350
+ if (!p) {
2351
+ m(!0), g(void 0);
2352
+ try {
2353
+ let r = Ke(await Fn("/configs/connector", {
2354
+ config: {
2355
+ name: t.name,
2356
+ realm: t.realm,
2357
+ ...t.space ? { space: t.space } : {},
2358
+ ...t.stack ? { stack: t.stack } : {}
2359
+ },
2360
+ connector: e.connector,
2361
+ identity: n
2362
+ }));
2363
+ v({
2364
+ key: `connector-pick:${e.connector}:${t.name}`,
2365
+ tone: r.length ? "warning" : "success",
2366
+ message: [n ? `Config ${t.name} now uses ${n.name} for ${y}.` : `Config ${t.name} uses the ${y} default again.`, ...r].join(" ")
2367
+ }), i(), a();
2368
+ } catch (e) {
2369
+ g($(e));
2370
+ } finally {
2371
+ m(!1);
2372
+ }
2373
+ }
2374
+ }
2375
+ return /* @__PURE__ */ f("div", {
2376
+ className: "connector-fix",
2377
+ role: "group",
2378
+ "aria-label": `Pick ${y} identity for this Config`,
2379
+ children: [
2380
+ /* @__PURE__ */ d("p", {
2381
+ className: "description",
2382
+ children: o ? /* @__PURE__ */ f(u, { children: [
2383
+ "Saved in the Config as its state volume: every cell of this Config keeps its ",
2384
+ y,
2385
+ " login — and the rest of its harness state — there. ",
2386
+ Ge
2387
+ ] }) : /* @__PURE__ */ d(u, { children: "Saved in the Config itself: it wins over the Realm, Space and Stack defaults for this Config only." })
2388
+ }),
2389
+ /* @__PURE__ */ d("div", {
2390
+ className: "schema-fields",
2391
+ children: o ? /* @__PURE__ */ d(Xn, {
2392
+ label: `${y} login identity for this Config`,
2393
+ identities: r,
2394
+ value: s,
2395
+ extra: [G(e)],
2396
+ emptyLabel: "Select a login identity…",
2397
+ disabled: p,
2398
+ onChange: l
2399
+ }) : /* @__PURE__ */ d(Zn, {
2400
+ label: `${y} identity for this Config`,
2401
+ identities: n,
2402
+ value: s,
2403
+ extra: [e.identity],
2404
+ emptyLabel: "Select an identity…",
2405
+ disabled: p,
2406
+ realm: t.realm,
2407
+ onChange: l
2408
+ })
2409
+ }),
2410
+ /* @__PURE__ */ f("div", {
2411
+ className: "connector-actions",
2412
+ children: [
2413
+ /* @__PURE__ */ d("button", {
2414
+ type: "button",
2415
+ disabled: !b || p || o && I(b, G(e)),
2416
+ onClick: () => void x(b ?? null),
2417
+ children: p ? "Saving…" : "Save for this Config"
2418
+ }),
2419
+ !o && e.origin === "config" && /* @__PURE__ */ d("button", {
2420
+ type: "button",
2421
+ className: "subtle-button",
2422
+ disabled: p,
2423
+ onClick: () => void x(null),
2424
+ children: "Use the default instead"
2425
+ }),
2426
+ /* @__PURE__ */ d("button", {
2427
+ type: "button",
2428
+ className: "subtle-button",
2429
+ disabled: p,
2430
+ onClick: a,
2431
+ children: "Cancel"
2432
+ })
2433
+ ]
2434
+ }),
2435
+ h && /* @__PURE__ */ d(_, {
2436
+ error: h,
2437
+ kind: "Config"
2438
+ })
2439
+ ]
2440
+ });
2441
+ }
2442
+ function lr({ status: e, connector: t, config: n, identities: r, logins: i = [], secrets: a, onChanged: o }) {
2443
+ let [s, l] = c(""), u = B(e), p = ue({ metadata: n });
2444
+ if (W(e)) {
2445
+ let t = G(e), a = i.find((e) => I(e.volume, t));
2446
+ return /* @__PURE__ */ f("div", {
2447
+ className: "connector-fixes",
2448
+ children: [/* @__PURE__ */ f("div", {
2449
+ className: "connector-actions",
2450
+ children: [
2451
+ t && /* @__PURE__ */ d(Yn, {
2452
+ connector: e.connector,
2453
+ title: u,
2454
+ volume: t,
2455
+ state: a?.state ?? e.login?.state,
2456
+ running: !!a?.session,
2457
+ method: e.method,
2458
+ onStarted: o
2459
+ }),
2460
+ !p && /* @__PURE__ */ d("button", {
2461
+ type: "button",
2462
+ "aria-expanded": s === "pick",
2463
+ "aria-label": `Pick ${u} login identity for this Config`,
2464
+ onClick: () => l(s === "pick" ? "" : "pick"),
2465
+ children: "Pick a login identity"
2466
+ }),
2467
+ /* @__PURE__ */ f("a", {
2468
+ className: "document-action",
2469
+ href: Ln(e.connector, de(n)),
2470
+ children: [
2471
+ "Manage ",
2472
+ u,
2473
+ " login identities"
2474
+ ]
2475
+ })
2476
+ ]
2477
+ }), s === "pick" && !p && /* @__PURE__ */ d(cr, {
2478
+ status: e,
2479
+ config: n,
2480
+ identities: r,
2481
+ logins: i,
2482
+ onChanged: o,
2483
+ onClose: () => l("")
2484
+ })]
2485
+ });
2486
+ }
2487
+ return N(e.delivery) ? /* @__PURE__ */ f("div", {
2488
+ className: "connector-fixes",
2489
+ children: [
2490
+ /* @__PURE__ */ f("div", {
2491
+ className: "connector-actions",
2492
+ children: [/* @__PURE__ */ d("button", {
2493
+ type: "button",
2494
+ "aria-expanded": s === "default",
2495
+ "aria-label": `Set default for ${u}`,
2496
+ onClick: () => l(s === "default" ? "" : "default"),
2497
+ children: "Set default"
2498
+ }), !p && /* @__PURE__ */ d("button", {
2499
+ type: "button",
2500
+ "aria-expanded": s === "pick",
2501
+ "aria-label": `Pick ${u} identity for this Config`,
2502
+ onClick: () => l(s === "pick" ? "" : "pick"),
2503
+ children: "Pick for this Config"
2504
+ })]
2505
+ }),
2506
+ s === "default" && /* @__PURE__ */ d(sr, {
2507
+ status: e,
2508
+ connector: t,
2509
+ scope: de(n),
2510
+ identities: r,
2511
+ secrets: a,
2512
+ onChanged: o,
2513
+ onClose: () => l("")
2514
+ }),
2515
+ s === "pick" && !p && /* @__PURE__ */ d(cr, {
2516
+ status: e,
2517
+ config: n,
2518
+ identities: r,
2519
+ onChanged: o,
2520
+ onClose: () => l("")
2521
+ })
2522
+ ]
2523
+ }) : null;
2524
+ }
2525
+ function ur({ config: e }) {
2526
+ let t = ce(e);
2527
+ return t.length ? /* @__PURE__ */ f("span", {
2528
+ className: "badge needs-connector",
2529
+ children: ["Needs connector: ", [...new Set(t.map(B))].join(", ")]
2530
+ }) : null;
2531
+ }
2532
+ function dr({ warning: e }) {
2533
+ return e?.trim() ? /* @__PURE__ */ f("p", {
2534
+ className: "connector-warning",
2535
+ role: "note",
2536
+ children: [
2537
+ /* @__PURE__ */ d("strong", { children: "Warning:" }),
2538
+ " ",
2539
+ e
2540
+ ]
2541
+ }) : null;
2542
+ }
2543
+ function fr({ statuses: e, team: t = "" }) {
2544
+ return e.length ? /* @__PURE__ */ f("div", {
2545
+ className: "merged-values connector-identities-preview",
2546
+ children: [
2547
+ /* @__PURE__ */ d("h4", { children: "Connector identities" }),
2548
+ /* @__PURE__ */ d("p", {
2549
+ className: "description",
2550
+ children: "The identity each connector uses in this cell, and the level that decided it. Only stored secrets are named — no material is shown."
2551
+ }),
2552
+ /* @__PURE__ */ f("table", {
2553
+ "aria-label": "Connector identities",
2554
+ children: [/* @__PURE__ */ d("thead", { children: /* @__PURE__ */ f("tr", { children: [
2555
+ /* @__PURE__ */ d("th", {
2556
+ scope: "col",
2557
+ children: "Connector"
2558
+ }),
2559
+ /* @__PURE__ */ d("th", {
2560
+ scope: "col",
2561
+ children: "Method"
2562
+ }),
2563
+ /* @__PURE__ */ d("th", {
2564
+ scope: "col",
2565
+ children: "Identity"
2566
+ }),
2567
+ /* @__PURE__ */ d("th", {
2568
+ scope: "col",
2569
+ children: "State"
2570
+ })
2571
+ ] }) }), /* @__PURE__ */ d("tbody", { children: e.map((e) => /* @__PURE__ */ f("tr", { children: [
2572
+ /* @__PURE__ */ d("td", { children: B(e) }),
2573
+ /* @__PURE__ */ d("td", { children: e.method || "—" }),
2574
+ /* @__PURE__ */ f("td", { children: [
2575
+ /* @__PURE__ */ d(qn, {
2576
+ status: e,
2577
+ team: t
2578
+ }),
2579
+ e.state !== "resolved" && e.message && /* @__PURE__ */ d("p", {
2580
+ className: "setup-error",
2581
+ children: e.message
2582
+ }),
2583
+ /* @__PURE__ */ d(dr, { warning: e.warning })
2584
+ ] }),
2585
+ /* @__PURE__ */ d("td", { children: /* @__PURE__ */ d(Hn, { status: e }) })
2586
+ ] }, `${e.connector}:${e.component}`)) })]
2587
+ })
2588
+ ]
2589
+ }) : null;
2590
+ }
2591
+ function pr({ doc: e, revision: t, onChanged: n }) {
2592
+ let r = se(e), i = m(r.length ? "/connectors" : null, t), a = m(r.some((e) => N(e.delivery)) ? "/catalog/secrets" : null, t), o = m(r.some(W) ? "/connectors/logins" : null, t);
2593
+ if (!r.length) return null;
2594
+ let s = ue(e), c = r.filter(z);
2595
+ return /* @__PURE__ */ f("section", {
2596
+ className: "panel config-connectors",
2597
+ "aria-label": "Connectors",
2598
+ children: [/* @__PURE__ */ f("div", {
2599
+ className: "panel-heading",
2600
+ children: [/* @__PURE__ */ d("h2", { children: "Connectors" }), c.length ? /* @__PURE__ */ d(ur, { config: e }) : /* @__PURE__ */ d("span", {
2601
+ className: "badge",
2602
+ children: "All resolved"
2603
+ })]
2604
+ }), /* @__PURE__ */ f("div", {
2605
+ className: "panel-body",
2606
+ children: [
2607
+ /* @__PURE__ */ d("p", {
2608
+ className: "description",
2609
+ children: "What this Config needs access to, and the identity each connector uses for a cell created now. An identity comes from the Config's own pick, else the Stack, Space or Realm default."
2610
+ }),
2611
+ s && /* @__PURE__ */ f("p", {
2612
+ className: "connector-team",
2613
+ role: "note",
2614
+ children: [
2615
+ "Identities are set by team ",
2616
+ /* @__PURE__ */ d("a", {
2617
+ href: Cn(s),
2618
+ children: /* @__PURE__ */ d("code", { children: s })
2619
+ }),
2620
+ ". They are read-only here because applying the team re-renders this Config; change them on the team's Edit team screen (Credentials), or set a scope default."
2621
+ ]
2622
+ }),
2623
+ i.error && /* @__PURE__ */ f("p", {
2624
+ className: "stale",
2625
+ children: ["The connector catalog could not be loaded: ", i.error.message]
2626
+ }),
2627
+ a.error && /* @__PURE__ */ f("p", {
2628
+ className: "stale",
2629
+ children: [
2630
+ "Identities could not be listed: ",
2631
+ a.error.message,
2632
+ ". Name a secret by hand instead."
2633
+ ]
2634
+ }),
2635
+ /* @__PURE__ */ d("ul", {
2636
+ className: "state-list connector-status-list",
2637
+ children: r.map((t) => /* @__PURE__ */ d("li", {
2638
+ "aria-label": `${B(t)} connector`,
2639
+ children: /* @__PURE__ */ f("div", {
2640
+ className: "connector-status",
2641
+ children: [
2642
+ /* @__PURE__ */ f("div", { children: [
2643
+ /* @__PURE__ */ d("strong", { children: B(t) }),
2644
+ " ",
2645
+ /* @__PURE__ */ d("span", {
2646
+ className: "badge",
2647
+ children: t.connector
2648
+ }),
2649
+ t.method && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d("span", {
2650
+ className: "badge",
2651
+ children: t.method
2652
+ })] }),
2653
+ " ",
2654
+ /* @__PURE__ */ d(Hn, { status: t })
2655
+ ] }),
2656
+ /* @__PURE__ */ d("p", {
2657
+ className: "description",
2658
+ children: /* @__PURE__ */ d(qn, {
2659
+ status: t,
2660
+ team: s
2661
+ })
2662
+ }),
2663
+ t.state !== "resolved" && t.message && /* @__PURE__ */ d("p", {
2664
+ className: "setup-error",
2665
+ children: t.message
2666
+ }),
2667
+ /* @__PURE__ */ d(lr, {
2668
+ status: t,
2669
+ connector: i.data?.find((e) => e.name === t.connector),
2670
+ config: e.metadata,
2671
+ identities: oe(a.data, t.connector),
2672
+ logins: we(o.data, t.connector),
2673
+ secrets: a.data,
2674
+ onChanged: n
2675
+ }),
2676
+ W(t) && /* @__PURE__ */ f("p", {
2677
+ className: "description",
2678
+ children: [
2679
+ "Log in opens a short-lived identity cell that mounts only this login identity and runs the ",
2680
+ B(t),
2681
+ " login; every cell of the same role then reuses it."
2682
+ ]
2683
+ })
2684
+ ]
2685
+ })
2686
+ }, `${t.connector}:${t.component}`))
2687
+ })
2688
+ ]
2689
+ })]
2690
+ });
2691
+ }
2692
+ export { $t as $, ze as $t, gn as A, E as An, Y as At, fn as B, _ as Bn, _e as Bt, Jn as C, he as Cn, Kt as Ct, Nn as D, ft as Dn, yt as Dt, Pn as E, P as En, It as Et, cn as F, ue as Fn, ut as Ft, un as G, y as Gt, hn as H, h as Hn, ge as Ht, bn as I, Ue as In, pe as It, Tn as J, re as Jt, xn as K, pt as Kt, rn as L, q as Ln, se as Lt, En as M, G as Mn, z as Mt, yn as N, N as Nn, Pe as Nt, jn as O, dt as On, xt as Ot, vn as P, de as Pn, Me as Pt, Nt as Q, Be as Qt, Sn as R, Ie as Rn, B as Rt, Fn as S, U as Sn, kt as St, Un as T, ht as Tn, Rt as Tt, wn as U, m as Un, v as Ut, pn as V, g as Vn, ee as Vt, ln as W, b as Wt, an as X, ie as Xt, Cn as Y, ne as Yt, dn as Z, oe as Zt, In as _, I as _n, Jt as _t, dr as a, we as an, en as at, Rn as b, H as bn, Ct as bt, Yn as c, ke as cn, Wt as ct, ur as d, le as dn, wt as dt, ye as en, zt as et, Qn as f, F as fn, Ft as ft, qn as g, Ke as gn, Gt as gt, ar as h, _t as hn, Yt as ht, Hn as i, k as in, qt as it, on as j, Ae as jn, me as jt, Dn as k, Ge as kn, St as kt, Xn as l, Ne as ln, Vt as lt, er as m, L as mn, nn as mt, lr as n, gt as nn, Qt as nt, or as o, te as on, Bt as ot, $n as p, R as pn, Pt as pt, _n as q, xe as qt, fr as r, Oe as rn, Mt as rt, Zn as s, ve as sn, Ht as st, pr as t, W as tn, At as tt, Gn as u, Fe as un, Lt as ut, Ln as v, V as vn, Zt as vt, $ as w, mt as wn, Xt as wt, zn as x, T as xn, Ut as xt, Vn as y, fe as yn, jt as yt, mn as z, be as zn, Se as zt };