asta-ui 0.9.4 → 0.9.6

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 (130) hide show
  1. package/css/asta.css +2 -2
  2. package/css/asta.js +1461 -1
  3. package/css/components.css +1900 -138
  4. package/css/runtime/agent.css +136 -0
  5. package/css/runtime/agent.js +173 -0
  6. package/css/runtime/assist.css +79 -0
  7. package/css/runtime/assist.js +799 -0
  8. package/css/runtime/controls.css +48 -0
  9. package/css/runtime/controls.js +482 -0
  10. package/css/src/agent.css +484 -0
  11. package/css/src/assist.css +598 -0
  12. package/css/src/controls.css +424 -0
  13. package/css/tokens.css +16 -0
  14. package/dist/agent-plan.d.ts +2 -0
  15. package/dist/agent-plan.js +11 -0
  16. package/dist/agent-team.d.ts +2 -0
  17. package/dist/agent-team.js +7 -0
  18. package/dist/api-keys.d.ts +2 -0
  19. package/dist/api-keys.js +10 -0
  20. package/dist/autonomy-dial.d.ts +2 -0
  21. package/dist/autonomy-dial.js +7 -0
  22. package/dist/base/agent-plan.d.ts +2 -0
  23. package/dist/base/agent-plan.js +11 -0
  24. package/dist/base/agent-team.d.ts +2 -0
  25. package/dist/base/agent-team.js +7 -0
  26. package/dist/base/api-keys.d.ts +2 -0
  27. package/dist/base/api-keys.js +10 -0
  28. package/dist/base/autonomy-dial.d.ts +2 -0
  29. package/dist/base/autonomy-dial.js +7 -0
  30. package/dist/base/change-ledger.d.ts +2 -0
  31. package/dist/base/change-ledger.js +7 -0
  32. package/dist/base/citations.d.ts +2 -0
  33. package/dist/base/citations.js +9 -0
  34. package/dist/base/context-meter.d.ts +2 -0
  35. package/dist/base/context-meter.js +14 -0
  36. package/dist/base/fallback-chain.d.ts +2 -0
  37. package/dist/base/fallback-chain.js +7 -0
  38. package/dist/base/model-picker.d.ts +2 -0
  39. package/dist/base/model-picker.js +9 -0
  40. package/dist/base/prompt-composer.d.ts +2 -0
  41. package/dist/base/prompt-composer.js +9 -0
  42. package/dist/base/scrub-input.d.ts +2 -0
  43. package/dist/base/scrub-input.js +13 -0
  44. package/dist/base/thinking.d.ts +2 -0
  45. package/dist/base/thinking.js +11 -0
  46. package/dist/base/tool-approval.d.ts +2 -0
  47. package/dist/base/tool-approval.js +9 -0
  48. package/dist/base/trace-waterfall.d.ts +2 -0
  49. package/dist/base/trace-waterfall.js +9 -0
  50. package/dist/base.js +202 -134
  51. package/dist/change-ledger.d.ts +2 -0
  52. package/dist/change-ledger.js +7 -0
  53. package/dist/chunk-24O5V2PQ.js +253 -0
  54. package/dist/chunk-44DNL43W.js +490 -0
  55. package/dist/chunk-45IXJ7W7.js +245 -0
  56. package/dist/chunk-ANL6VX4X.js +326 -0
  57. package/dist/chunk-DNROUJ62.js +432 -0
  58. package/dist/chunk-F4CWSZXK.js +226 -0
  59. package/dist/chunk-GBOJUMMY.js +163 -0
  60. package/dist/chunk-H4NFBYKY.js +275 -0
  61. package/dist/chunk-KFPGQ5RT.js +321 -0
  62. package/dist/chunk-OIIMYSVT.js +342 -0
  63. package/dist/chunk-TL32C2SQ.js +221 -0
  64. package/dist/chunk-UBTYMAKF.js +240 -0
  65. package/dist/chunk-W6YVDJHX.js +235 -0
  66. package/dist/chunk-XYQI4ZYV.js +314 -0
  67. package/dist/citations.d.ts +2 -0
  68. package/dist/citations.js +9 -0
  69. package/dist/context-meter.d.ts +2 -0
  70. package/dist/context-meter.js +14 -0
  71. package/dist/fallback-chain.d.ts +2 -0
  72. package/dist/fallback-chain.js +7 -0
  73. package/dist/index.js +202 -134
  74. package/dist/model-picker.d.ts +2 -0
  75. package/dist/model-picker.js +9 -0
  76. package/dist/prompt-composer.d.ts +2 -0
  77. package/dist/prompt-composer.js +9 -0
  78. package/dist/scrub-input.d.ts +2 -0
  79. package/dist/scrub-input.js +13 -0
  80. package/dist/thinking.d.ts +2 -0
  81. package/dist/thinking.js +11 -0
  82. package/dist/tool-approval.d.ts +2 -0
  83. package/dist/tool-approval.js +9 -0
  84. package/dist/trace-waterfall.d.ts +2 -0
  85. package/dist/trace-waterfall.js +9 -0
  86. package/dist/types/components/kit/agent-plan.d.ts +34 -0
  87. package/dist/types/components/kit/api-keys.d.ts +62 -0
  88. package/dist/types/components/kit/citations.d.ts +34 -0
  89. package/dist/types/components/kit/context-meter.d.ts +38 -0
  90. package/dist/types/components/kit/model-picker.d.ts +46 -0
  91. package/dist/types/components/kit/prompt-composer.d.ts +61 -0
  92. package/dist/types/components/kit/scrub-input.d.ts +44 -0
  93. package/dist/types/components/kit/thinking.d.ts +28 -0
  94. package/dist/types/components/kit/tool-approval.d.ts +43 -0
  95. package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
  96. package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
  97. package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
  98. package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
  99. package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
  100. package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
  101. package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
  102. package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
  103. package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
  104. package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
  105. package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
  106. package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
  107. package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
  108. package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
  109. package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
  110. package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
  111. package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
  112. package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
  113. package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
  114. package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
  115. package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
  116. package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
  117. package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
  118. package/dist/types/packages/asta-ui/src/base.d.ts +25 -1
  119. package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
  120. package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
  121. package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
  122. package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
  123. package/dist/types/packages/asta-ui/src/index.d.ts +25 -1
  124. package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
  125. package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
  126. package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
  127. package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
  128. package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
  129. package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
  130. package/package.json +1 -1
@@ -0,0 +1,432 @@
1
+ "use client";
2
+ import {
3
+ ClipboardButton
4
+ } from "./chunk-EAUUUVUR.js";
5
+
6
+ // components/kit/api-keys.tsx
7
+ import { useEffect, useId, useRef, useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ var cx = (...c) => c.filter(Boolean).join(" ");
10
+ var CURVE = "cubic-bezier(.16,1,.3,1)";
11
+ var DEFAULT_SCOPES = [
12
+ { value: "projects:read", label: "Read projects", hint: "List projects and their settings" },
13
+ { value: "projects:write", label: "Change projects", hint: "Create, rename and archive" },
14
+ { value: "deploys:write", label: "Start deploys", hint: "Trigger and roll back builds" },
15
+ { value: "billing:read", label: "Read billing", hint: "Invoices and usage" }
16
+ ];
17
+ var DEFAULT_EXPIRY = [
18
+ { label: "30 days", days: 30 },
19
+ { label: "90 days", days: 90 },
20
+ { label: "1 year", days: 365 },
21
+ { label: "Never", days: null }
22
+ ];
23
+ var KEYFRAMES = `@keyframes kit-ak-in { from { opacity: 0; transform: translateY(6px) } }
24
+ @keyframes kit-ak-count { from { transform: scaleX(1) } to { transform: scaleX(0) } }
25
+ @keyframes kit-ak-pulse { 50% { opacity: .45 } }
26
+ @media (prefers-reduced-motion: reduce) { .kit-ak, .kit-ak * { animation-duration: 0s !important; transition-duration: 0s !important } .kit-ak [data-ak-count] { animation: none !important; opacity: .5 } }`;
27
+ var BTN = "inline-flex shrink-0 select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-md font-medium tracking-[-0.01em] outline-none transition-[background-color,color,box-shadow,transform,opacity] duration-200 active:scale-[0.97] focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper disabled:pointer-events-none disabled:opacity-45";
28
+ var SOLID = `${BTN} h-8 px-3 text-[13px] bg-ink text-paper shadow-[inset_0_1px_0_rgb(255_255_255/0.18),0_1px_2px_rgb(0_0_0/0.16),0_6px_14px_-8px_rgb(0_0_0/0.45)] hover:bg-[color-mix(in_srgb,var(--ink)_84%,var(--paper))]`;
29
+ var GHOST = `${BTN} h-8 px-3 text-[13px] text-ink-2 hover:bg-paper-2 hover:text-ink`;
30
+ var GHOST_XS = `${BTN} h-7 px-2.5 text-[12px] text-ink-2 hover:bg-ink/7 hover:text-ink`;
31
+ var LBL = "text-[13px] font-medium";
32
+ var LINE = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_14%,transparent)]";
33
+ var FIELD = `h-10 w-full rounded-lg bg-paper px-3 text-[16px] text-ink outline-none transition-shadow duration-200 placeholder:text-mute sm:text-[14px] ${LINE} hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_24%,transparent)] focus:!shadow-[inset_0_0_0_1px_var(--brand),0_0_0_3px_color-mix(in_srgb,var(--brand)_18%,transparent)] aria-[invalid=true]:shadow-[inset_0_0_0_1.5px_var(--ink)]`;
34
+ var DAY = 864e5;
35
+ var mask = (k) => `${k.prefix}_\u2026${k.last4}`;
36
+ var dateFmt = (d, now) => d.toLocaleDateString("en-US", { month: "short", day: "numeric", ...d.getFullYear() !== now.getFullYear() && { year: "numeric" } });
37
+ function ago(d, now) {
38
+ if (!d) return "Never";
39
+ const s = Math.max(0, (now.getTime() - d.getTime()) / 1e3);
40
+ if (s < 60) return "Just now";
41
+ if (s < 3600) return `${Math.floor(s / 60)} min ago`;
42
+ if (s < 86400) return `${Math.floor(s / 3600)} h ago`;
43
+ if (s < 86400 * 30) return `${Math.floor(s / 86400)} d ago`;
44
+ return dateFmt(d, now);
45
+ }
46
+ var Icon = ({ d, className = "h-4 w-4" }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className, fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
47
+ var KEY = "M10.5 2.5a3 3 0 1 1-2.6 4.5L3 11.9V13.5h1.6v-1.2h1.2v-1.2H7l1.1-1.1A3 3 0 0 1 10.5 2.5ZM11 5h.01";
48
+ var PLUS = "M8 3.5v9M3.5 8h9";
49
+ var WARN = "M8 2.5 14 13H2zM8 6.5v3M8 11.2h.01";
50
+ function Status({ k, now }) {
51
+ const left = k.expires ? k.expires.getTime() - now.getTime() : Infinity;
52
+ return /* @__PURE__ */ jsxs("span", { className: cx("inline-flex items-center gap-1.5 whitespace-nowrap", left <= 0 ? "text-mute" : "text-ink"), children: [
53
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("h-2 w-2 shrink-0 rounded-full", left <= 0 ? "shadow-[inset_0_0_0_1.5px_currentColor]" : "bg-brand") }),
54
+ left <= 0 ? "Expired" : left < 14 * DAY ? `Expires in ${Math.ceil(left / DAY)} d` : "Active"
55
+ ] });
56
+ }
57
+ var Msg = ({ id, error, hint }) => /* @__PURE__ */ jsxs("p", { id, className: cx("flex min-h-4 items-center gap-1.5 text-[12px]", error ? "font-medium text-ink" : "text-mute"), children: [
58
+ error && /* @__PURE__ */ jsx(Icon, { d: WARN, className: "h-3.5 w-3.5 shrink-0" }),
59
+ error ?? hint
60
+ ] });
61
+ function Scopes({ list }) {
62
+ const [first, ...rest] = list;
63
+ return /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-wrap gap-1", children: [
64
+ first && /* @__PURE__ */ jsx("span", { className: "rounded-[5px] bg-ink/6 px-1.5 font-mono text-[11.5px] leading-5 text-ink-2", children: first }),
65
+ rest.length > 0 && /* @__PURE__ */ jsxs("span", { title: rest.join(", "), className: "rounded-[5px] bg-ink/6 px-1.5 text-[11.5px] leading-5 text-mute", children: [
66
+ "+",
67
+ rest.length,
68
+ /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
69
+ " more: ",
70
+ rest.join(", ")
71
+ ] })
72
+ ] })
73
+ ] });
74
+ }
75
+ var COLS = "@2xl:grid-cols-[minmax(0,1.3fr)_120px_minmax(0,1.4fr)_minmax(0,.7fr)_minmax(0,1fr)_64px]";
76
+ var CELL_LABEL = "text-[11.5px] text-mute @2xl:sr-only";
77
+ var CELL = "col-span-2 flex min-w-0 items-center gap-2 @2xl:col-span-1 @2xl:row-start-1";
78
+ var META = "flex flex-col gap-0.5 text-[12.5px] @2xl:row-start-1";
79
+ var seq = 0;
80
+ function demoCreate({ name, scopes, expiresInDays: days }) {
81
+ const tail = Array.from({ length: 24 }, () => "abcdefghjkmnpqrstuvwxyz23456789"[Math.floor(Math.random() * 31)]).join("");
82
+ const now = Date.now();
83
+ return {
84
+ secret: `ak_live_demo_${tail}`,
85
+ key: { id: `k${now.toString(36)}${seq++}`, name, prefix: "ak_live", last4: tail.slice(-4), scopes, created: new Date(now), expires: days ? new Date(now + days * DAY) : null }
86
+ };
87
+ }
88
+ function ApiKeys({
89
+ defaultKeys = [],
90
+ scopes = DEFAULT_SCOPES,
91
+ expiryOptions = DEFAULT_EXPIRY,
92
+ onCreate = demoCreate,
93
+ onRevoke,
94
+ loading,
95
+ error,
96
+ onRetry,
97
+ undoMs = 8e3,
98
+ now: nowProp,
99
+ title = "API keys",
100
+ description = "Keys let your servers call the Astabyte API. Keep them out of client code and rotate them often.",
101
+ className
102
+ }) {
103
+ const [keys, setKeys] = useState(defaultKeys);
104
+ const [mounted] = useState(() => /* @__PURE__ */ new Date());
105
+ const [open, setOpen] = useState(false);
106
+ const [busy, setBusy] = useState(false);
107
+ const [formError, setFormError] = useState({});
108
+ const [form, setForm] = useState({ name: "", scopes: [scopes[0]?.value].filter(Boolean), expiry: String(Math.min(1, expiryOptions.length - 1)) });
109
+ const [reveal, setReveal] = useState(null);
110
+ const [confirm, setConfirm] = useState(null);
111
+ const [revoked, setRevoked] = useState([]);
112
+ const [status, setStatus] = useState("");
113
+ const [focusTick, setFocusTick] = useState(0);
114
+ const focusRef = useRef(null);
115
+ const root = useRef(null);
116
+ const timers = useRef(/* @__PURE__ */ new Map());
117
+ const id = useId();
118
+ const clock = nowProp ?? mounted;
119
+ useEffect(() => {
120
+ const all = timers.current;
121
+ return () => all.forEach(clearTimeout);
122
+ }, []);
123
+ const setFocusTo = (key) => {
124
+ focusRef.current = key;
125
+ setFocusTick((t) => t + 1);
126
+ };
127
+ useEffect(() => {
128
+ if (!focusRef.current) return;
129
+ root.current?.querySelector(`[data-ak-focus="${focusRef.current}"]`)?.focus();
130
+ focusRef.current = null;
131
+ }, [focusTick]);
132
+ const startCreate = () => {
133
+ setOpen(true);
134
+ setFormError({});
135
+ setFocusTo("name");
136
+ };
137
+ const cancelCreate = () => {
138
+ setOpen(false);
139
+ setFormError({});
140
+ setForm((f) => ({ ...f, name: "" }));
141
+ setFocusTo("create");
142
+ };
143
+ const submit = async (e) => {
144
+ e.preventDefault();
145
+ const err = {};
146
+ if (!form.name.trim()) err.name = "Give the key a name so you can tell it apart later.";
147
+ if (!form.scopes.length) err.scopes = "Pick at least one permission.";
148
+ setFormError(err);
149
+ if (err.name || err.scopes) return setFocusTo(err.name ? "name" : "scope-0");
150
+ setBusy(true);
151
+ try {
152
+ const { key, secret } = await onCreate({ name: form.name.trim(), scopes: form.scopes, expiresInDays: expiryOptions[Number(form.expiry)]?.days ?? null });
153
+ setKeys((all) => [key, ...all]);
154
+ setReveal({ id: key.id, secret, copied: false, warned: false });
155
+ setOpen(false);
156
+ setForm((f) => ({ ...f, name: "" }));
157
+ setStatus(`Key ${key.name} created. Copy it now, it won't be shown again.`);
158
+ setFocusTo("copy");
159
+ } catch {
160
+ setFormError({ form: "Couldn't create the key. Check your connection and try again." });
161
+ } finally {
162
+ setBusy(false);
163
+ }
164
+ };
165
+ const dismiss = () => {
166
+ if (!reveal) return;
167
+ if (!reveal.copied && !reveal.warned) {
168
+ setReveal({ ...reveal, warned: true });
169
+ setStatus("You haven't copied the key yet. Close anyway?");
170
+ return;
171
+ }
172
+ setReveal(null);
173
+ setStatus("Key hidden. Only its last four characters stay visible.");
174
+ setFocusTo("list");
175
+ };
176
+ const revoke = (k) => {
177
+ setConfirm(null);
178
+ setRevoked((r) => [...r, k.id]);
179
+ setStatus(`${k.name} revoked. Undo within ${Math.round(undoMs / 1e3)} seconds.`);
180
+ setFocusTo(`undo-${k.id}`);
181
+ timers.current.set(
182
+ k.id,
183
+ setTimeout(() => {
184
+ timers.current.delete(k.id);
185
+ const btn = document.activeElement;
186
+ if (btn instanceof HTMLElement && btn.dataset.akFocus === `undo-${k.id}`) {
187
+ const li = btn.closest("li");
188
+ const next = (li?.nextElementSibling ?? li?.previousElementSibling)?.querySelector("[data-ak-focus]");
189
+ setFocusTo(next?.dataset.akFocus ?? "create");
190
+ }
191
+ setKeys((all) => all.filter((x) => x.id !== k.id));
192
+ setRevoked((r) => r.filter((x) => x !== k.id));
193
+ onRevoke?.(k.id);
194
+ }, undoMs)
195
+ );
196
+ };
197
+ const keep = (k) => {
198
+ setConfirm(null);
199
+ setFocusTo(`revoke-${k.id}`);
200
+ };
201
+ const undo = (k) => {
202
+ clearTimeout(timers.current.get(k.id));
203
+ timers.current.delete(k.id);
204
+ setRevoked((r) => r.filter((x) => x !== k.id));
205
+ setStatus(`${k.name} restored.`);
206
+ setFocusTo(`revoke-${k.id}`);
207
+ };
208
+ const live = keys.filter((k) => !revoked.includes(k.id)).length;
209
+ const toggleScope = (v) => setForm((f) => ({ ...f, scopes: f.scopes.includes(v) ? f.scopes.filter((s) => s !== v) : [...f.scopes, v] }));
210
+ return /* @__PURE__ */ jsxs("div", { ref: root, className: cx("kit-ak @container w-full text-ink", className), children: [
211
+ /* @__PURE__ */ jsx("style", { href: "asta-api-keys", precedence: "asta", children: KEYFRAMES }),
212
+ /* @__PURE__ */ jsx("p", { className: "sr-only", role: "status", "aria-live": "polite", children: status }),
213
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-wrap items-start justify-between gap-x-6 gap-y-3", children: [
214
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 max-w-[520px]", children: [
215
+ /* @__PURE__ */ jsx("h3", { className: "text-[17px] font-medium tracking-[-0.02em]", children: title }),
216
+ description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[13px] leading-relaxed text-mute", children: description })
217
+ ] }),
218
+ /* @__PURE__ */ jsxs("button", { type: "button", "data-ak-focus": "create", "aria-expanded": open, "aria-controls": `${id}-form`, onClick: startCreate, disabled: loading || !!error, className: SOLID, children: [
219
+ /* @__PURE__ */ jsx(Icon, { d: PLUS, className: "h-3.5 w-3.5" }),
220
+ "Create key"
221
+ ] })
222
+ ] }),
223
+ open && /* @__PURE__ */ jsxs("form", { id: `${id}-form`, onSubmit: submit, noValidate: true, onKeyDown: (e) => e.key === "Escape" && (e.preventDefault(), cancelCreate()), className: "mt-5 rounded-[12px] bg-paper-2 p-4 sm:p-5", style: { animation: `kit-ak-in .3s ${CURVE}` }, children: [
224
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-5 @min-[640px]:grid-cols-[1fr_200px]", children: [
225
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
226
+ /* @__PURE__ */ jsx("label", { htmlFor: `${id}-name`, className: LBL, children: "Key name" }),
227
+ /* @__PURE__ */ jsx(
228
+ "input",
229
+ {
230
+ id: `${id}-name`,
231
+ "data-ak-focus": "name",
232
+ name: "name",
233
+ type: "text",
234
+ autoComplete: "off",
235
+ maxLength: 60,
236
+ placeholder: "e.g. Production server",
237
+ value: form.name,
238
+ "aria-invalid": !!formError.name,
239
+ "aria-describedby": `${id}-name-msg`,
240
+ onChange: (e) => setForm((f) => ({ ...f, name: e.target.value })),
241
+ className: FIELD
242
+ }
243
+ ),
244
+ /* @__PURE__ */ jsx(Msg, { id: `${id}-name-msg`, error: formError.name, hint: "Only your team sees this." })
245
+ ] }),
246
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
247
+ /* @__PURE__ */ jsx("label", { htmlFor: `${id}-exp`, className: LBL, children: "Expires" }),
248
+ /* @__PURE__ */ jsxs("span", { className: "relative", children: [
249
+ /* @__PURE__ */ jsx("select", { id: `${id}-exp`, name: "expires", value: form.expiry, onChange: (e) => setForm((f) => ({ ...f, expiry: e.target.value })), className: cx(FIELD, "cursor-pointer appearance-none pr-9"), children: expiryOptions.map((o, i) => /* @__PURE__ */ jsx("option", { value: i, children: o.label }, o.label)) }),
250
+ /* @__PURE__ */ jsx(Icon, { d: "m4.5 6.5 3.5 3.5 3.5-3.5", className: "pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-mute" })
251
+ ] })
252
+ ] })
253
+ ] }),
254
+ /* @__PURE__ */ jsxs("fieldset", { className: "mt-5", "aria-describedby": `${id}-scope-msg`, children: [
255
+ /* @__PURE__ */ jsx("legend", { className: LBL, children: "Permissions" }),
256
+ /* @__PURE__ */ jsx("div", { className: "mt-2 grid gap-1 @min-[560px]:grid-cols-2", children: scopes.map((s, i) => /* @__PURE__ */ jsxs("label", { className: "flex cursor-pointer items-start gap-3 rounded-lg p-2 transition-colors hover:bg-ink/4", children: [
257
+ /* @__PURE__ */ jsxs("span", { className: "relative mt-px grid h-[18px] w-[18px] shrink-0 place-items-center", children: [
258
+ /* @__PURE__ */ jsx(
259
+ "input",
260
+ {
261
+ type: "checkbox",
262
+ name: "scopes",
263
+ value: s.value,
264
+ "data-ak-focus": `scope-${i}`,
265
+ checked: form.scopes.includes(s.value),
266
+ onChange: () => toggleScope(s.value),
267
+ className: "peer col-start-1 row-start-1 h-[18px] w-[18px] cursor-pointer appearance-none rounded-[6px] bg-paper shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--ink)_22%,transparent)] outline-none transition-[background-color,box-shadow] duration-200 checked:bg-brand checked:shadow-none focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper-2"
268
+ }
269
+ ),
270
+ /* @__PURE__ */ jsx(Icon, { d: "m4 8.5 2.5 2.5 5.5-6", className: "pointer-events-none col-start-1 row-start-1 h-3 w-3 scale-50 text-white opacity-0 transition-[opacity,transform] duration-300 peer-checked:scale-100 peer-checked:opacity-100" })
271
+ ] }),
272
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
273
+ /* @__PURE__ */ jsx("span", { className: "block text-[13.5px] leading-[18px] text-ink", children: s.label }),
274
+ /* @__PURE__ */ jsxs("span", { className: "mt-0.5 block text-[12px] text-mute", children: [
275
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-[11.5px] text-ink-2", children: s.value }),
276
+ s.hint && ` \xB7 ${s.hint}`
277
+ ] })
278
+ ] })
279
+ ] }, s.value)) }),
280
+ /* @__PURE__ */ jsx(Msg, { id: `${id}-scope-msg`, error: formError.scopes, hint: "Give it only what it needs." })
281
+ ] }),
282
+ formError.form && /* @__PURE__ */ jsxs("p", { role: "alert", className: cx("mt-4 flex items-center gap-2 rounded-lg bg-paper px-3 py-2 text-[13px] text-ink", LINE), children: [
283
+ /* @__PURE__ */ jsx(Icon, { d: WARN, className: "h-4 w-4 shrink-0" }),
284
+ formError.form
285
+ ] }),
286
+ /* @__PURE__ */ jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [
287
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: cancelCreate, className: GHOST, children: "Cancel" }),
288
+ /* @__PURE__ */ jsx("button", { type: "submit", disabled: busy, "aria-busy": busy || void 0, className: cx(SOLID, "disabled:opacity-70"), children: busy ? "Creating key\u2026" : "Create key" })
289
+ ] })
290
+ ] }),
291
+ /* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
292
+ /* @__PURE__ */ jsxs("div", { className: cx("hidden gap-4 px-3 pb-2 text-[12px] text-mute", (loading || !error && keys.length > 0) && "@2xl:grid", COLS), "aria-hidden": true, children: [
293
+ /* @__PURE__ */ jsx("span", { children: "Name" }),
294
+ /* @__PURE__ */ jsx("span", { children: "Key" }),
295
+ /* @__PURE__ */ jsx("span", { children: "Permissions" }),
296
+ /* @__PURE__ */ jsx("span", { children: "Last used" }),
297
+ /* @__PURE__ */ jsx("span", { children: "Status" }),
298
+ /* @__PURE__ */ jsx("span", {})
299
+ ] }),
300
+ /* @__PURE__ */ jsxs("h4", { "data-ak-focus": "list", tabIndex: -1, className: "sr-only", children: [
301
+ live,
302
+ " ",
303
+ live === 1 ? "key" : "keys"
304
+ ] }),
305
+ loading ? /* @__PURE__ */ jsx("ul", { "aria-busy": "true", "aria-label": "Loading API keys", className: "flex flex-col gap-2 @2xl:gap-0.5", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx("li", { className: cx("grid h-[76px] grid-cols-[1fr_auto] items-center gap-4 rounded-[12px] bg-paper-2 px-4 @2xl:h-[60px] @2xl:bg-transparent @2xl:px-3", COLS), style: { animation: `kit-ak-pulse 1.6s ease-in-out ${i * 150}ms infinite` }, children: ["w-36", "w-28", "w-32", "w-16", "w-14", "w-16 justify-self-end"].map((w, j) => /* @__PURE__ */ jsx("span", { className: cx("h-3 rounded-full bg-ink/8", w, j > 0 && j < 5 && "hidden @2xl:block") }, j)) }, i)) }) : error ? /* @__PURE__ */ jsxs("div", { role: "alert", className: "flex flex-col items-center rounded-[12px] bg-paper-2 px-6 py-10 text-center", children: [
306
+ /* @__PURE__ */ jsx(Icon, { d: WARN, className: "h-5 w-5 text-ink" }),
307
+ /* @__PURE__ */ jsx("p", { className: "mt-3 text-[14px] font-medium", children: error }),
308
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-[12.5px] text-mute", children: "Your keys still work. Only this page couldn't load them." }),
309
+ onRetry && /* @__PURE__ */ jsx("button", { type: "button", onClick: onRetry, className: cx(GHOST, "mt-4 bg-paper", LINE), children: "Try again" })
310
+ ] }) : keys.length === 0 ? !open && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center rounded-[12px] bg-paper-2 px-6 py-12 text-center", style: { animation: `kit-ak-in .4s ${CURVE}` }, children: [
311
+ /* @__PURE__ */ jsx("span", { className: "grid h-11 w-11 place-items-center rounded-full bg-paper text-mute shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_8%,transparent)]", children: /* @__PURE__ */ jsx(Icon, { d: KEY, className: "h-5 w-5" }) }),
312
+ /* @__PURE__ */ jsx("p", { className: "mt-4 text-[14px] font-medium", children: "No API keys yet" }),
313
+ /* @__PURE__ */ jsx("p", { className: "mt-1 max-w-[300px] text-[12.5px] text-mute", children: "Create one to call the Astabyte API from your server or CI." }),
314
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: startCreate, className: cx(SOLID, "mt-5"), children: [
315
+ /* @__PURE__ */ jsx(Icon, { d: PLUS, className: "h-3.5 w-3.5" }),
316
+ "Create your first key"
317
+ ] })
318
+ ] }) : /* @__PURE__ */ jsx("ul", { "aria-label": title, className: "flex flex-col gap-2 @2xl:gap-0.5", children: keys.map((k) => {
319
+ const expired = !!k.expires && k.expires.getTime() <= clock.getTime();
320
+ const warn = reveal?.warned && !reveal.copied;
321
+ if (reveal?.id === k.id)
322
+ return /* @__PURE__ */ jsxs("li", { className: "rounded-[12px] bg-[color-mix(in_srgb,var(--brand)_6%,var(--paper))] p-4 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--brand)_35%,transparent)] sm:p-5", style: { animation: `kit-ak-in .4s ${CURVE}` }, children: [
323
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
324
+ /* @__PURE__ */ jsx("p", { className: "min-w-0 break-words text-[14px] font-medium", children: k.name }),
325
+ /* @__PURE__ */ jsx("span", { className: "rounded-[5px] bg-brand px-1.5 text-[11px] font-medium leading-5 text-white", children: "New" })
326
+ ] }),
327
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-[12.5px] text-ink-2", children: "Copy this key and store it somewhere safe, like a secrets manager." }),
328
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-col gap-2 @min-[480px]:flex-row", children: [
329
+ /* @__PURE__ */ jsx(
330
+ "input",
331
+ {
332
+ readOnly: true,
333
+ "aria-label": `Secret for ${k.name}`,
334
+ value: reveal.secret,
335
+ onFocus: (e) => e.target.select(),
336
+ className: cx("h-10 min-w-0 shrink-0 rounded-lg @min-[480px]:flex-1 bg-paper px-3 font-mono text-[13px] text-ink outline-none focus:shadow-[inset_0_0_0_1px_var(--brand)]", LINE)
337
+ }
338
+ ),
339
+ /* @__PURE__ */ jsx(ClipboardButton, { "data-ak-focus": "copy", value: reveal.secret, label: "Copy key", variant: "outline", onCopy: () => setReveal((r) => r && { ...r, copied: true }), className: "h-10 bg-paper" })
340
+ ] }),
341
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-wrap items-center justify-between gap-3", children: [
342
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-[12.5px] font-medium text-ink", children: [
343
+ /* @__PURE__ */ jsx(Icon, { d: WARN, className: "h-3.5 w-3.5 shrink-0" }),
344
+ warn ? "You haven't copied it. It can't be shown again." : "You won't see this key again."
345
+ ] }),
346
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: dismiss, className: warn ? SOLID : GHOST, children: warn ? "Close anyway" : "I've saved it" })
347
+ ] })
348
+ ] }, k.id);
349
+ if (revoked.includes(k.id))
350
+ return /* @__PURE__ */ jsxs("li", { className: "relative flex min-h-[60px] items-center gap-3 overflow-hidden rounded-[10px] bg-paper-2 px-3 py-2", style: { animation: `kit-ak-in .3s ${CURVE}` }, children: [
351
+ /* @__PURE__ */ jsxs("p", { className: "min-w-0 flex-1 text-[13px] text-ink-2", children: [
352
+ "Revoked ",
353
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ink", children: k.name }),
354
+ /* @__PURE__ */ jsxs("span", { className: "hidden text-mute @min-[480px]:inline", children: [
355
+ ". Requests with ",
356
+ mask(k),
357
+ " now fail."
358
+ ] })
359
+ ] }),
360
+ /* @__PURE__ */ jsx("button", { type: "button", "data-ak-focus": `undo-${k.id}`, onClick: () => undo(k), className: cx(GHOST_XS, "text-brand hover:text-brand"), children: "Undo" }),
361
+ /* @__PURE__ */ jsx("span", { "data-ak-count": true, "aria-hidden": true, className: "absolute inset-x-0 bottom-0 h-0.5 origin-left bg-brand/40", style: { animation: `kit-ak-count ${undoMs}ms linear forwards` } })
362
+ ] }, k.id);
363
+ const asking = confirm === k.id;
364
+ return /* @__PURE__ */ jsxs("li", { className: cx("rounded-[12px] transition-colors duration-200 @2xl:rounded-[10px]", asking ? "bg-paper-2" : "bg-paper-2 @2xl:bg-transparent @2xl:hover:bg-paper-2/60"), style: { animation: `kit-ak-in .35s ${CURVE}` }, children: [
365
+ /* @__PURE__ */ jsxs("div", { className: cx("grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-3 p-4 @2xl:min-h-[60px] @2xl:px-3 @2xl:py-2.5", COLS), children: [
366
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
367
+ /* @__PURE__ */ jsx("p", { title: k.name, className: "line-clamp-2 break-words text-[13.5px] font-medium @2xl:line-clamp-1 @2xl:truncate", children: k.name }),
368
+ /* @__PURE__ */ jsxs("p", { className: "mt-0.5 text-[12px] text-mute", children: [
369
+ "Created ",
370
+ dateFmt(k.created, clock)
371
+ ] })
372
+ ] }),
373
+ /* @__PURE__ */ jsx("div", { className: "row-start-1 col-start-2 @2xl:col-start-6 @2xl:justify-self-end", children: /* @__PURE__ */ jsx(
374
+ "button",
375
+ {
376
+ type: "button",
377
+ "data-ak-focus": `revoke-${k.id}`,
378
+ "aria-label": `Revoke ${k.name}`,
379
+ "aria-expanded": asking,
380
+ onClick: () => {
381
+ setConfirm(asking ? null : k.id);
382
+ if (!asking) setFocusTo(`keep-${k.id}`);
383
+ },
384
+ className: GHOST_XS,
385
+ children: "Revoke"
386
+ }
387
+ ) }),
388
+ /* @__PURE__ */ jsxs("div", { className: cx(CELL, "@2xl:col-start-2"), children: [
389
+ /* @__PURE__ */ jsx("span", { className: CELL_LABEL, children: "Key" }),
390
+ /* @__PURE__ */ jsx("code", { className: "truncate font-mono text-[12.5px] text-ink-2", children: mask(k) })
391
+ ] }),
392
+ /* @__PURE__ */ jsxs("div", { className: cx(CELL, "@2xl:col-start-3"), children: [
393
+ /* @__PURE__ */ jsx("span", { className: CELL_LABEL, children: "Permissions" }),
394
+ /* @__PURE__ */ jsx(Scopes, { list: k.scopes })
395
+ ] }),
396
+ /* @__PURE__ */ jsxs("div", { className: cx(META, "@2xl:col-start-4"), children: [
397
+ /* @__PURE__ */ jsx("span", { className: CELL_LABEL, children: "Last used" }),
398
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums text-ink-2", children: ago(k.lastUsed, clock) })
399
+ ] }),
400
+ /* @__PURE__ */ jsxs("div", { className: cx(META, "@2xl:col-start-5"), children: [
401
+ /* @__PURE__ */ jsx("span", { className: CELL_LABEL, children: "Status" }),
402
+ /* @__PURE__ */ jsx(Status, { k, now: clock })
403
+ ] })
404
+ ] }),
405
+ asking && /* @__PURE__ */ jsxs(
406
+ "div",
407
+ {
408
+ role: "group",
409
+ "aria-label": `Confirm revoking ${k.name}`,
410
+ onKeyDown: (e) => e.key === "Escape" && (e.preventDefault(), keep(k)),
411
+ className: "flex flex-wrap items-center justify-between gap-3 px-4 pb-4 @2xl:px-3 @2xl:pb-3",
412
+ style: { animation: `kit-ak-in .25s ${CURVE}` },
413
+ children: [
414
+ /* @__PURE__ */ jsx("p", { className: "text-[12.5px] text-ink-2", children: expired ? "It has already expired. Revoking removes it from the list." : `Apps using ${mask(k)} stop working right away.` }),
415
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
416
+ /* @__PURE__ */ jsx("button", { type: "button", "data-ak-focus": `keep-${k.id}`, onClick: () => keep(k), className: GHOST, children: "Keep key" }),
417
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => revoke(k), className: SOLID, children: "Revoke key" })
418
+ ] })
419
+ ]
420
+ }
421
+ )
422
+ ] }, k.id);
423
+ }) })
424
+ ] })
425
+ ] });
426
+ }
427
+ var api_keys_default = ApiKeys;
428
+
429
+ export {
430
+ ApiKeys,
431
+ api_keys_default
432
+ };