@sentry/junior-dashboard 0.290.0 → 0.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/app.js +3 -3
  2. package/dist/client-manifest.json +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/public/chunks/{AdminPage-htjffg0n.js → AdminPage-fdz3hucf.js} +1 -1
  5. package/dist/public/chunks/{Area-hr2tz6ad.js → Area-f1nin66q.js} +1 -1
  6. package/dist/public/chunks/{AutomationPage-eihr9acm.js → AutomationPage-d5mdkrn9.js} +3 -3
  7. package/dist/public/chunks/{AutomationRunDetails-op6rfaji.js → AutomationRunDetails-hyjcewq8.js} +1 -1
  8. package/dist/public/chunks/AutomationRunsPage-fcez9yb2.js +1 -0
  9. package/dist/public/chunks/AutomationsPage-in07jyvb.js +15 -0
  10. package/dist/public/chunks/{BarChart-cg02osy4.js → BarChart-hdlbq093.js} +1 -1
  11. package/dist/public/chunks/{BoardPage-mbypholh.js → BoardPage-jmv26j4s.js} +1 -1
  12. package/dist/public/chunks/{CodeChangeRow-oyge0uo2.js → CodeChangeRow-enn40527.js} +2 -2
  13. package/dist/public/chunks/CodePage-ous0utk0.js +1 -0
  14. package/dist/public/chunks/{CodeSummaryCards-gikkczl6.js → CodeSummaryCards-d2oxdoq1.js} +1 -1
  15. package/dist/public/chunks/{ConnectionsPage-l2d6sesm.js → ConnectionsPage-lilwyiau.js} +2 -2
  16. package/dist/public/chunks/{DrawerContent-jt25bpic.js → DrawerContent-jg0soa2u.js} +1 -1
  17. package/dist/public/chunks/{FilterBar-h4ab22b1.js → FilterBar-lsllb7tj.js} +1 -1
  18. package/dist/public/chunks/{FormNotice-oukmcfaj.js → FormNotice-mmzuj60h.js} +1 -1
  19. package/dist/public/chunks/{LocationDetailPage-gldsmom2.js → LocationDetailPage-cf82jjul.js} +1 -1
  20. package/dist/public/chunks/{LocationsPage-glec25wm.js → LocationsPage-g9b4zhrs.js} +1 -1
  21. package/dist/public/chunks/{McpSettingsPage-nfv7qia1.js → McpSettingsPage-gibci7qd.js} +1 -1
  22. package/dist/public/chunks/{PeoplePage-kd1ad63d.js → PeoplePage-cphdlfgf.js} +1 -1
  23. package/dist/public/chunks/{PersonProfilePage-diqz6hmw.js → PersonProfilePage-mf6i9tif.js} +1 -1
  24. package/dist/public/chunks/{PersonalTokensPage-mwkwnlc7.js → PersonalTokensPage-iodbv05e.js} +1 -1
  25. package/dist/public/chunks/PluginReportRecordSet-fossppyd.js +1 -0
  26. package/dist/public/chunks/{PluginUserPage-l7q0ylyz.js → PluginUserPage-ismd883z.js} +2 -2
  27. package/dist/public/chunks/RepositoryPage-dwvax7uv.js +1 -0
  28. package/dist/public/chunks/SettingsPage-f9kssan6.js +1 -0
  29. package/dist/public/chunks/{SystemPage-mpp6dtwm.js → SystemPage-a5t28k3w.js} +1 -1
  30. package/dist/public/chunks/{WorkspaceFormPage-o74u0sno.js → WorkspaceFormPage-h21lnuo4.js} +2 -2
  31. package/dist/public/chunks/WorkspacesPage-h0lwq044.js +1 -0
  32. package/dist/public/chunks/{automationFormat-bhjz2hx6.js → automationFormat-nmiq4qj2.js} +1 -1
  33. package/dist/public/chunks/{chart-mxqu3c8e.js → chart-dbzd0ka8.js} +1 -1
  34. package/dist/public/chunks/{code-highlighter-dd09ntlw.js → code-highlighter-lmx9nqyd.js} +1 -1
  35. package/dist/public/chunks/{format-eev8is9c.js → format-c4b0iyrx.js} +2 -2
  36. package/dist/public/chunks/{junior-btnqqkq5.js → junior-gfsokzu9.js} +2 -2
  37. package/dist/public/chunks/{workspaceQueries-i5xdl0za.js → workspaceQueries-l3p6sri7.js} +1 -1
  38. package/dist/public/client-mgf2bxi7.js +165 -0
  39. package/dist/public/styles-6XAAC7O5.css +2 -0
  40. package/dist/tailwind.css +1 -1
  41. package/package.json +4 -4
  42. package/src/client/conversations/ConversationMeta.tsx +127 -34
  43. package/src/client/conversations/ConversationWorkspace.tsx +45 -30
  44. package/src/client/conversations/conversationSections.ts +3 -2
  45. package/src/client/format.ts +1 -0
  46. package/src/client/types.ts +2 -0
  47. package/dist/public/chunks/AutomationRunsPage-sx9tdkxv.js +0 -1
  48. package/dist/public/chunks/AutomationsPage-mnstyn9j.js +0 -15
  49. package/dist/public/chunks/CodePage-ojiokuht.js +0 -1
  50. package/dist/public/chunks/PluginReportRecordSet-ea6phh3k.js +0 -1
  51. package/dist/public/chunks/RepositoryPage-f61pzf0s.js +0 -1
  52. package/dist/public/chunks/SettingsPage-oqgh66n1.js +0 -1
  53. package/dist/public/chunks/WorkspacesPage-kfphmgpt.js +0 -1
  54. package/dist/public/client-ll3qwj84.js +0 -165
  55. package/dist/public/styles-GFFU7LPU.css +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-dashboard",
3
- "version": "0.290.0",
3
+ "version": "0.292.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -45,10 +45,10 @@
45
45
  "remark-gfm": "^4.0.1",
46
46
  "shiki": "4.1.0",
47
47
  "zod": "^4.5.4",
48
- "@sentry/junior-plugin-api": "0.290.0"
48
+ "@sentry/junior-plugin-api": "0.292.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@sentry/junior": "0.290.0"
51
+ "@sentry/junior": "0.292.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@fontsource-variable/inter": "^5.3.0",
@@ -72,7 +72,7 @@
72
72
  "typescript": "^7.0.2",
73
73
  "unrun": "^0.3.1",
74
74
  "vitest": "^4.1.12",
75
- "@sentry/junior": "0.290.0"
75
+ "@sentry/junior": "0.292.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "pnpm --filter @sentry/junior-plugin-api build && pnpm --filter @sentry/junior build && pnpm run build:css && pnpm run build:client && pnpm run build:server",
@@ -9,7 +9,13 @@ import {
9
9
  LockKeyhole,
10
10
  TriangleAlert,
11
11
  } from "lucide-react";
12
- import { useSyncExternalStore, type ReactNode } from "react";
12
+ import {
13
+ useLayoutEffect,
14
+ useRef,
15
+ useState,
16
+ useSyncExternalStore,
17
+ type ReactNode,
18
+ } from "react";
13
19
  import { Link } from "react-router";
14
20
  import type { ConversationDetailReport } from "@sentry/junior/api/schema";
15
21
 
@@ -184,50 +190,137 @@ function SidebarAnnotationIconFacepile(props: {
184
190
  <span
185
191
  className={cn(
186
192
  // Isolate stacking context so z-index only orders chips inside the pile.
187
- // Extra right pad keeps the last chip's cutout ring from clipping.
188
- "relative isolate inline-flex h-[18px] items-center pr-0.5",
193
+ "relative isolate inline-flex h-[18px] min-w-0 items-center",
189
194
  props.className,
190
195
  )}
191
196
  >
192
- {props.annotations.map((annotation, index) => (
193
- <SidebarAnnotationStatusChip
194
- annotation={annotation}
195
- cutoutColor={props.cutoutColor}
196
- key={annotation.key}
197
- // Each chip to the right layers above the chip before it.
198
- stacked={index > 0}
199
- zIndex={index + 1}
200
- />
201
- ))}
197
+ <FittingIcons
198
+ // The padding keeps the cutout rings inside the clipped row.
199
+ className="-m-0.5 h-[22px] min-w-[22px] p-0.5"
200
+ icons={props.annotations.map((annotation, index) => (
201
+ <SidebarAnnotationStatusChip
202
+ annotation={annotation}
203
+ cutoutColor={props.cutoutColor}
204
+ key={annotation.key}
205
+ // Each chip to the right layers above the chip before it.
206
+ stacked={index > 0}
207
+ zIndex={index + 1}
208
+ />
209
+ ))}
210
+ overflow={(count) => (
211
+ <span
212
+ aria-hidden="true"
213
+ className="relative -ml-0.5 box-border inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full border border-dashboard-border-strong bg-dashboard-control px-1 font-sans text-2xs tabular-nums leading-none text-dashboard-text-muted"
214
+ style={{
215
+ boxShadow: `0 0 0 2px ${props.cutoutColor}`,
216
+ zIndex: props.annotations.length + 1,
217
+ }}
218
+ >
219
+ +{count}
220
+ </span>
221
+ )}
222
+ />
202
223
  </span>
203
224
  );
204
225
  }
205
226
 
206
- /** One shared label with every status icon for that label. */
227
+ /**
228
+ * Show the icons that fit in the row and a +N count for the rest. Icons that
229
+ * do not fit wrap onto lines that the row clips, so the count follows the
230
+ * real width.
231
+ */
232
+ function FittingIcons(props: {
233
+ className: string;
234
+ icons: ReactNode[];
235
+ overflow(count: number): ReactNode;
236
+ }) {
237
+ const rowRef = useRef<HTMLSpanElement>(null);
238
+ const overflowRef = useRef<HTMLSpanElement>(null);
239
+ const total = props.icons.length;
240
+ const [shown, setShown] = useState(total);
241
+
242
+ useLayoutEffect(() => {
243
+ const row = rowRef.current;
244
+ if (!row) return;
245
+ const countFirstLine = () => {
246
+ const items = Array.from(row.children);
247
+ const bottom = items[0]?.getBoundingClientRect().bottom ?? 0;
248
+ return items.filter((item) => item.getBoundingClientRect().top < bottom)
249
+ .length;
250
+ };
251
+ const measure = () => {
252
+ // Measure without the +N first. Otherwise its own width keeps the
253
+ // last icons hidden after the row grows wide enough for all of them.
254
+ const overflow = overflowRef.current;
255
+ if (overflow) overflow.style.display = "none";
256
+ const fitting = countFirstLine();
257
+ if (overflow) overflow.style.display = "";
258
+ setShown(fitting === total || !overflow ? fitting : countFirstLine());
259
+ };
260
+ measure();
261
+ const observer = new ResizeObserver(measure);
262
+ observer.observe(row);
263
+ return () => observer.disconnect();
264
+ // Run again when `shown` changes: the +N that mounts takes width, and
265
+ // this pass counts it before paint. The observer would run after paint.
266
+ }, [shown, total]);
267
+
268
+ return (
269
+ <>
270
+ <span
271
+ className={cn(
272
+ // The row gap pushes wrapped lines fully outside the clip.
273
+ "flex flex-wrap items-center gap-y-6 overflow-hidden",
274
+ props.className,
275
+ )}
276
+ ref={rowRef}
277
+ >
278
+ {props.icons}
279
+ </span>
280
+ {shown < total ? (
281
+ <span className="contents" ref={overflowRef}>
282
+ {props.overflow(total - shown)}
283
+ </span>
284
+ ) : null}
285
+ </>
286
+ );
287
+ }
288
+
289
+ /** One shared label with the status icons that fit and a count of the rest. */
207
290
  function SidebarAnnotationGroupChip(props: {
208
291
  group: SidebarAnnotationBadgeGroup;
209
292
  }) {
210
293
  return (
211
- <span className="inline-flex h-5 min-w-0 max-w-60 shrink-0 items-center gap-1 truncate rounded-full border border-dashboard-border-strong bg-dashboard-control px-1.5 font-sans text-2xs leading-none text-dashboard-text-muted">
212
- {props.group.annotations.map((annotation) =>
213
- annotation.objectType ? (
214
- <ObjectIcon
215
- {...annotation}
216
- objectType={annotation.objectType}
217
- key={annotation.key}
218
- decorative
219
- size={14}
220
- />
221
- ) : annotation.icon ? (
222
- <SidebarAnnotationIcon
223
- decorative
224
- icon={annotation.icon}
225
- key={annotation.key}
226
- size={11}
227
- />
228
- ) : null,
229
- )}
230
- <span className="min-w-0 truncate whitespace-nowrap">
294
+ // No min-w-0: a chip shrinks only to one icon and its label, so the
295
+ // longest group gives up icons before a shorter one loses its label.
296
+ <span className="inline-flex h-5 items-center gap-1 rounded-full border border-dashboard-border-strong bg-dashboard-control px-1.5 font-sans text-2xs leading-none text-dashboard-text-muted">
297
+ <FittingIcons
298
+ className="h-3.5 min-w-3.5 gap-x-1"
299
+ icons={props.group.annotations.flatMap((annotation) =>
300
+ annotation.objectType ? (
301
+ <ObjectIcon
302
+ {...annotation}
303
+ objectType={annotation.objectType}
304
+ key={annotation.key}
305
+ decorative
306
+ size={14}
307
+ />
308
+ ) : annotation.icon ? (
309
+ <SidebarAnnotationIcon
310
+ decorative
311
+ icon={annotation.icon}
312
+ key={annotation.key}
313
+ size={11}
314
+ />
315
+ ) : (
316
+ []
317
+ ),
318
+ )}
319
+ overflow={(count) => (
320
+ <span className="shrink-0 tabular-nums">+{count}</span>
321
+ )}
322
+ />
323
+ <span className="max-w-40 shrink-0 truncate whitespace-nowrap">
231
324
  {props.group.label}
232
325
  </span>
233
326
  </span>
@@ -20,7 +20,6 @@ import {
20
20
  ResizablePanelGroup,
21
21
  } from "../components/ui/resizable";
22
22
  import { ToggleGroup, ToggleGroupItem } from "../components/ui/toggle-group";
23
- import { pageCount, pageItems, PagePagination } from "../components/Pagination";
24
23
  import { composerDockClass } from "./ComposerDock";
25
24
  import { ConversationHomeList } from "./ConversationHomeList";
26
25
  import { useConversationActionToasts } from "./conversationActionToasts";
@@ -62,6 +61,7 @@ import { usePushNotificationsTip } from "../notifications/pushNotificationsTip";
62
61
  import { cn } from "../styles";
63
62
  import type { Conversation } from "../types";
64
63
  import { ConversationPage } from "./ConversationPage";
64
+ import { useAutoLoadHistoryPage } from "./transcriptBottomPinning";
65
65
  import { FeedThreads, feedThreadsById } from "./feedThreads";
66
66
  import {
67
67
  useWaitingConversationIds,
@@ -88,7 +88,7 @@ export function ConversationWorkspace(props: {
88
88
  /** The selected Conversation's data, from the shell. */
89
89
  detail: ConversationData;
90
90
  }) {
91
- const [page, setPage] = useState(1);
91
+ const [visibleCount, setVisibleCount] = useState(CONVERSATION_PAGE_SIZE);
92
92
  const [query, setQuery] = useState("");
93
93
  const [sidebarOpen, setSidebarOpen] = useConversationSidebarOpen();
94
94
  // Home reports an archive that started on a conversation page. Do it here,
@@ -148,25 +148,34 @@ export function ConversationWorkspace(props: {
148
148
  const waitingConversations = useWaitingConversations();
149
149
  const waitingConversationIds = useWaitingConversationIds();
150
150
 
151
- const totalPages = pageCount(conversations.length, CONVERSATION_PAGE_SIZE);
152
- const pagedConversations = useMemo(
151
+ // The feed holds every row. The home list shows them a batch at a time
152
+ // and shows the next batch when the reader scrolls near its end.
153
+ const orderedConversations = useMemo(
153
154
  () =>
154
- pageItems(
155
- pinnedAndAttentionFirst(
156
- conversations,
157
- attentionConversationIds(conversations, waitingConversationIds),
158
- ),
159
- page,
160
- CONVERSATION_PAGE_SIZE,
155
+ pinnedAndAttentionFirst(
156
+ conversations,
157
+ attentionConversationIds(conversations, waitingConversationIds),
161
158
  ),
162
- [conversations, page, waitingConversationIds],
159
+ [conversations, waitingConversationIds],
163
160
  );
161
+ const visibleConversations = useMemo(
162
+ () => orderedConversations.slice(0, visibleCount),
163
+ [orderedConversations, visibleCount],
164
+ );
165
+ const hiddenCount = orderedConversations.length - visibleConversations.length;
166
+ const homeList = useRef<HTMLDivElement>(null);
167
+ // A new search starts at the top. Otherwise the shorter list leaves the
168
+ // loader row in view, and it loads more before the results arrive.
164
169
  useEffect(() => {
165
- setPage(1);
170
+ setVisibleCount(CONVERSATION_PAGE_SIZE);
171
+ homeList.current?.scrollTo({ top: 0 });
166
172
  }, [search]);
167
- useEffect(() => {
168
- if (page > totalPages) setPage(totalPages);
169
- }, [page, totalPages]);
173
+ const loadMoreRef = useAutoLoadHistoryPage({
174
+ edge: "bottom",
175
+ enabled: hiddenCount > 0,
176
+ historyVersion: String(visibleCount),
177
+ onLoad: () => setVisibleCount((count) => count + CONVERSATION_PAGE_SIZE),
178
+ });
170
179
 
171
180
  // Aborts when the reader leaves home, so a late create does not pull them
172
181
  // back from the page they went to.
@@ -291,8 +300,13 @@ export function ConversationWorkspace(props: {
291
300
  {sidebarFits ? (
292
301
  <div className="flex h-13 items-center px-1">{sidebarToggle}</div>
293
302
  ) : (
294
- <div className="min-h-0 overflow-y-auto overscroll-contain px-4 pb-3 pt-4 sm:px-6">
295
- <section aria-label="Conversations" className="grid gap-3">
303
+ // The top space is inside the content, not the scroller's padding,
304
+ // so the sticky section labels meet the page header.
305
+ <div
306
+ className="min-h-0 overflow-y-auto overscroll-contain px-4 pb-3 sm:px-6"
307
+ ref={homeList}
308
+ >
309
+ <section aria-label="Conversations" className="grid gap-3 pt-4">
296
310
  <SearchInput
297
311
  className="w-full sm:ml-auto sm:w-72"
298
312
  label="Search your conversations"
@@ -301,29 +315,30 @@ export function ConversationWorkspace(props: {
301
315
  value={query}
302
316
  />
303
317
  <ConversationHomeList
304
- conversations={pagedConversations}
318
+ conversations={visibleConversations}
305
319
  emptyLabel={feed.error?.message}
306
320
  loading={feed.isPending}
307
- // Search, or more pins than one page holds, shows only some
308
- // pins, so a drop could not place the rest.
321
+ // Search, or more pins than the list shows yet, shows only
322
+ // some pins, so a drop could not place the rest.
309
323
  onReorderPins={
310
324
  search ||
311
325
  conversations.filter((conversation) => conversation.pinnedAt)
312
- .length > CONVERSATION_PAGE_SIZE
326
+ .length > visibleCount
313
327
  ? undefined
314
328
  : reorderPins
315
329
  }
316
330
  timeZone={getDashboardTimeZone()}
317
331
  waitingConversationIds={waitingConversationIds}
318
332
  />
319
- <PagePagination
320
- className="pt-1"
321
- onPageChange={setPage}
322
- page={page}
323
- pageCount={totalPages}
324
- pageSize={CONVERSATION_PAGE_SIZE}
325
- total={conversations.length}
326
- />
333
+ {hiddenCount > 0 ? (
334
+ <div
335
+ className="py-2 text-center font-sans text-xs text-dashboard-text-muted"
336
+ ref={loadMoreRef}
337
+ role="status"
338
+ >
339
+ Loading {Math.min(hiddenCount, CONVERSATION_PAGE_SIZE)} more…
340
+ </div>
341
+ ) : null}
327
342
  </section>
328
343
  </div>
329
344
  )}
@@ -65,8 +65,8 @@ export function buildConversationSections(
65
65
 
66
66
  /**
67
67
  * True when the conversation waits on a person: its id is in `attentionIds`,
68
- * or it has unfinished work, such as an open pull request, while Junior is
69
- * not running in it.
68
+ * a Turn waits on a person to finish an authorization, or it has unfinished
69
+ * work, such as an open pull request, while Junior is not running in it.
70
70
  */
71
71
  function needsAttention(
72
72
  conversation: Conversation,
@@ -74,6 +74,7 @@ function needsAttention(
74
74
  ): boolean {
75
75
  return (
76
76
  attentionIds.has(conversation.id) ||
77
+ conversation.awaitingAuthorization === true ||
77
78
  (conversation.unfinishedWork === true && conversation.status !== "active")
78
79
  );
79
80
  }
@@ -910,6 +910,7 @@ export function buildConversations(
910
910
  parentConversationId: summary.parentConversationId,
911
911
  threads: summary.threads && buildConversations(summary.threads),
912
912
  unfinishedWork: summary.unfinishedWork,
913
+ awaitingAuthorization: summary.awaitingAuthorization,
913
914
  visibility: summary.visibility,
914
915
  }))
915
916
  .sort((a, b) => compareTimeDesc(a.lastSeenAt, b.lastSeenAt));
@@ -199,6 +199,8 @@ export type Conversation = {
199
199
  /** Visible Threads under this row, newest first. */
200
200
  threads?: Conversation[];
201
201
  unfinishedWork?: boolean;
202
+ /** A Turn waits on a person to finish an authorization. Server-owned. */
203
+ awaitingAuthorization?: boolean;
202
204
  visibility?: ConversationSummaryReport["visibility"];
203
205
  };
204
206
 
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n}from"./vendor-react-ggbyvons.js";import{t as r}from"./vendor-icons-mxz7yi04.js";import{a as i,i as a,n as o,t as s}from"./automationFormat-bhjz2hx6.js";import{t as c}from"./styles-j0007fov.js";import{t as l}from"./Card-hy4bfgq7.js";import{t as u}from"./PageContentSkeleton-b7dkba0l.js";import{d,t as f,u as p}from"./PageHeader-kvp1fo95.js";import{b as m,l as h,p as g}from"./format-eev8is9c.js";import{n as _,r as v}from"./searchParams-moqjgi65.js";import{F as y,U as b,Wt as x,dt as S,lt as C,ut as w}from"../client-ll3qwj84.js";import{i as T,n as E,r as D,t as O}from"./AutomationRunDetails-op6rfaji.js";import{n as k,t as A}from"./FilterBar-h4ab22b1.js";import{t as j}from"./SelectableRow-j8fwjsjz.js";var M=/* @__PURE__ */ e(t(),1),N=n();const P=[`all`,`scheduled`,`event`],F=[`all`,`completed`,`failed`,`blocked`],I=[],L=`grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_5.5rem_5.5rem_5.5rem_2rem]`;function R(e){let t=x(e.enabled),[n,r]=v(`type`,`all`,P),[i,a]=v(`status`,`all`,F),[o,s,m]=_(),[h,g]=(0,M.useState)(1),y=m.toLowerCase(),D=t.data?.runs??I,j=(0,M.useMemo)(()=>D.filter(e=>n!==`all`&&e.kind!==n||i!==`all`&&e.status!==i?!1:!y||[e.kind,e.status,e.automationTitle,e.title,e.conversationId].filter(Boolean).join(` `).toLowerCase().includes(y)),[n,D,y,i]),R=w(j.length,25),V=(0,M.useMemo)(()=>S(j,h,25),[h,j]);(0,M.useEffect)(()=>{g(1)},[n,m,i]),(0,M.useEffect)(()=>{h>R&&g(R)},[h,R]);let H=!t.data&&!t.error,U=T(V.map(e=>e.executionId)),W=U.runId?D.find(e=>e.executionId===U.runId):void 0;return/* @__PURE__ */ (0,N.jsxs)(E,{details:U.runId?/* @__PURE__ */ (0,N.jsx)(O,{loading:H,onClose:U.close,run:W,showAutomation:!0},U.runId):null,label:`Runs list`,listRef:U.listRef,children:[/* @__PURE__ */ (0,N.jsx)(f,{description:`Newest runs across your automations and automations in public destinations.`,title:`Runs`}),H?/* @__PURE__ */ (0,N.jsx)(u,{label:`Loading automation runs`,variant:`list`}):/* @__PURE__ */ (0,N.jsxs)(N.Fragment,{children:[/* @__PURE__ */ (0,N.jsxs)(A,{search:{label:`Search runs`,onChange:s,placeholder:`Automation, conversation, or status`,value:o},children:[/* @__PURE__ */ (0,N.jsx)(k,{label:`Type`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&r(e)},value:[n],children:P.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})}),/* @__PURE__ */ (0,N.jsx)(k,{label:`Status`,children:/* @__PURE__ */ (0,N.jsx)(p,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&a(e)},value:[i],children:F.map(e=>/* @__PURE__ */ (0,N.jsx)(d,{value:e,variant:`pill`,children:e},e))})})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-5 gap-y-1 border-b border-dashboard-border-subtle pb-3`,children:/* @__PURE__ */ (0,N.jsxs)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:[j.length,` `,j.length===1?`run`:`runs`,/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`text-dashboard-text-muted/70`,children:[` `,`· newest first`]})]})}),t.error?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(b,{children:`Automation runs could not be loaded. Try again.`})}):j.length===0?/* @__PURE__ */ (0,N.jsx)(l,{padding:`md`,children:/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:z({kind:n,search:y,status:i})})}):/* @__PURE__ */ (0,N.jsx)(l,{children:/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-[44rem]`,children:[/* @__PURE__ */ (0,N.jsxs)(`div`,{"aria-hidden":`true`,className:c(`sticky top-0 z-[1] hidden items-center gap-4 border-b border-dashboard-border-subtle bg-dashboard-overlay-soft px-4 py-2.5 font-sans font-medium text-xs text-dashboard-text-muted md:grid`,L),children:[/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Run`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Automation`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Duration`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Tokens`}),/* @__PURE__ */ (0,N.jsx)(`div`,{children:`Cost`})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`min-w-0`,onKeyDown:U.onRowsKeyDown,role:`list`,children:V.map(e=>/* @__PURE__ */ (0,N.jsx)(B,{onSelect:()=>U.toggle(e.executionId),run:e,selected:U.runId===e.executionId},`${e.kind}:${e.executionId}`))})]})})}),/* @__PURE__ */ (0,N.jsx)(C,{onPageChange:g,page:h,pageCount:R,pageSize:25,total:j.length}),t.data?.truncated?/* @__PURE__ */ (0,N.jsx)(`p`,{className:`m-0 text-center text-xs text-dashboard-text-muted`,children:`Showing the 100 most recent runs.`}):null]})]})}function z(e){return e.search||e.kind!==`all`||e.status!==`all`?`No runs matched these filters.`:`No visible automations have run yet.`}function B(e){let{run:t}=e,n=g(t.costUsd===void 0?void 0:{total:t.costUsd})||`—`,r=m(t.durationMs)||`—`,i=t.totalTokens===void 0?`—`:h(t.totalTokens);return/* @__PURE__ */ (0,N.jsx)(`div`,{className:`border-b border-dashboard-border-subtle last:border-b-0`,"data-run-id":t.executionId,role:`listitem`,children:/* @__PURE__ */ (0,N.jsxs)(j,{className:c(`grid min-w-0 items-center gap-4 overflow-hidden px-4 py-3 max-md:grid-cols-1 max-md:gap-y-2 max-md:py-3.5`,L),onSelect:e.onSelect,selected:e.selected,children:[/* @__PURE__ */ (0,N.jsxs)(`button`,{"aria-expanded":e.selected,className:`block min-w-0 cursor-pointer rounded-md border-0 bg-transparent p-0 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,N.jsx)(`span`,{className:`block truncate text-sm font-medium leading-snug text-dashboard-text`,children:o(t,t.automationTitle)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mt-1 block truncate text-xs text-dashboard-text-muted`,children:a(t.executedAt)})]}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,N.jsx)(`div`,{className:`truncate text-sm text-dashboard-text`,children:t.automationTitle}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,N.jsx)(H,{kind:t.kind}),/* @__PURE__ */ (0,N.jsx)(y,{label:t.status,tone:s(t.status)}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`truncate text-xs text-dashboard-text-muted`,children:t.status})]})]}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Duration`,value:r}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Tokens`,value:i}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Cost`,value:n}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`max-md:hidden`,children:/* @__PURE__ */ (0,N.jsx)(D,{conversationId:t.conversationId})})]})})}function V(e){return/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`min-w-0 max-md:flex max-md:items-center max-md:gap-2`,children:[/* @__PURE__ */ (0,N.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 hidden font-sans font-medium text-2xs text-dashboard-text-muted max-md:mb-0 max-md:block`,children:e.label}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`truncate whitespace-nowrap font-mono text-xs text-dashboard-text-muted md:text-sm md:text-dashboard-text`,children:[/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`sr-only`,children:[e.label,`: `]}),e.value]})]})}function H(e){let t=e.kind===`scheduled`?i:r,n=e.kind===`scheduled`?`Scheduled automation`:`Event automation`;return/* @__PURE__ */ (0,N.jsx)(`span`,{"aria-label":n,className:`inline-flex size-3.5 shrink-0 items-center justify-center text-dashboard-accent/80`,role:`img`,title:n,children:/* @__PURE__ */ (0,N.jsx)(t,{"aria-hidden":`true`,className:`size-3.5`,strokeWidth:1.8})})}export{R as AutomationRunsPage};
@@ -1,15 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,h as r,p as i,r as a,y as o}from"./vendor-react-ggbyvons.js";import{t as s}from"./button-loz3etho.js";import{J as c,Qt as l,mt as u,n as d,o as ee,t as f}from"./vendor-icons-mxz7yi04.js";import{a as p,i as m,r as h}from"./automationFormat-bhjz2hx6.js";import{It as te,tt as g}from"./junior-btnqqkq5.js";import{t as _}from"./Card-hy4bfgq7.js";import{t as ne}from"./PageContentSkeleton-b7dkba0l.js";import{a as v,d as y,l as re,r as ie,s as b,t as ae,u as x}from"./PageHeader-kvp1fo95.js";import{c as S,k as oe,n as C,p as w,y as T}from"./format-eev8is9c.js";import{t as E}from"./AnchorHeading-cp3vx8qa.js";import{n as se,r as ce,t as le}from"./searchParams-moqjgi65.js";import{Kt as ue,Mt as D,Ot as O,St as k,U as de,ft as A,ht as j,jt as M,kt as N,lt as fe,st as P,ut as pe,z as me}from"../client-ll3qwj84.js";import{t as he}from"./native-select-jfknh8t4.js";import{n as F}from"./FilterBar-h4ab22b1.js";import{t as ge}from"./SelectableRow-j8fwjsjz.js";import{C as I,a as L,d as R,n as z,o as B,r as V,s as H,t as U,u as W}from"./chart-mxqu3c8e.js";import{n as G,t as K}from"./BarChart-cg02osy4.js";import{t as _e}from"./DirectorySortSelect-1dv0yqxi.js";import{t as q}from"./StatCard-i2klkqqp.js"
2
- /**
3
- * @license lucide-react v1.17.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */
8
- ;const ve=l(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),ye=l(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]])
9
- /**
10
- * @license lucide-react v1.17.0 - ISC
11
- *
12
- * This source code is licensed under the ISC license.
13
- * See the LICENSE file in the root directory of this source tree.
14
- */
15
- ;var J=/* @__PURE__ */ e(t(),1),Y=n();const X=[{value:`active`,label:`Active`},{value:`blocked`,label:`Blocked`},{value:`paused`,label:`Paused`},{value:`unavailable`,label:`Trigger unavailable`},{value:`completed`,label:`Completed`}];function be(e){let t=window.matchMedia(k);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function xe(){return window.matchMedia(k).matches}function Se(e){let{filters:t,data:n,onChange:r}=e,[i,a]=(0,J.useState)(!1),o=(0,J.useSyncExternalStore)(be,xe,()=>!1),c=[{key:`type`,label:`Type`,value:t.type===`all`?``:t.type,valueLabel:t.type===`scheduled`?`Scheduled`:`Event`},{key:`creator`,label:`Creator`,value:t.creator,valueLabel:n?.creators.find(e=>e.value===t.creator)?.label??t.creator},{key:`destination`,label:`Destination`,value:t.destination,valueLabel:n?.destinations.find(e=>e.value===t.destination)?.label??t.destination},{key:`state`,label:`State`,value:t.state===`all`?``:t.state,valueLabel:X.find(e=>e.value===t.state)?.label}].filter(e=>e.value),l=/* @__PURE__ */ (0,Y.jsxs)(s,{className:`h-11 shrink-0`,"aria-expanded":i,"aria-haspopup":`dialog`,onClick:o?void 0:()=>a(!0),children:[/* @__PURE__ */ (0,Y.jsx)(ye,{"aria-hidden":`true`,size:14}),` Filters`,c.length?` (${c.length})`:``]}),u=/* @__PURE__ */ (0,Y.jsx)(Ce,{filters:t,data:n,onChange:r});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-2 lg:grid-cols-[auto_minmax(16rem,1fr)] lg:items-center lg:gap-4`,children:[/* @__PURE__ */ (0,Y.jsx)(x,{"aria-label":`Scope`,className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&r(`scope`,e)},value:[t.scope],children:[[`all`,`All`],[`mine`,`Mine`],[`public`,`Public`],[`attention`,`Needs attention`]].map(([e,t])=>/* @__PURE__ */ (0,Y.jsxs)(y,{className:`min-h-11 lg:min-h-9`,value:e,variant:`pill`,children:[t,n&&e!==`attention`?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`ml-1.5 opacity-65`,children:n.counts[e]}):null]},e))}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(A,{className:`flex-1`,size:`default`,label:`Search automations`,placeholder:`Search automations`,value:e.searchText,onChange:e.onSearch}),o?/* @__PURE__ */ (0,Y.jsxs)(O,{open:i,onOpenChange:a,children:[/* @__PURE__ */ (0,Y.jsx)(D,{render:l}),/* @__PURE__ */ (0,Y.jsxs)(N,{align:`end`,className:`w-80`,children:[/* @__PURE__ */ (0,Y.jsx)(M,{children:`Filters`}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-4`,children:u})]})]}):l]})]}),c.length>0?/* @__PURE__ */ (0,Y.jsx)(`div`,{"aria-label":`Active filters`,role:`group`,className:`flex min-w-0 flex-wrap gap-2`,children:c.map(e=>/* @__PURE__ */ (0,Y.jsxs)(s,{"aria-label":`Remove ${e.key} filter`,className:`min-h-9 max-w-full text-xs`,title:`${e.label}: ${e.valueLabel}`,onClick:()=>r(e.key,``),children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`truncate`,children:[e.label,`: `,e.valueLabel]}),/* @__PURE__ */ (0,Y.jsx)(d,{"aria-hidden":`true`,className:`shrink-0`,size:12})]},e.key))}):null,!o&&i?/* @__PURE__ */ (0,Y.jsx)(me,{label:`Filters`,size:`content`,onClose:()=>a(!1),children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-4 pb-[max(1rem,env(safe-area-inset-bottom))]`,children:u})}):null]})}function Ce({filters:e,data:t,onChange:n}){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[/* @__PURE__ */ (0,Y.jsx)(F,{label:`Type`,children:/* @__PURE__ */ (0,Y.jsx)(x,{className:`flex-wrap gap-2`,onValueChange:([e])=>{e&&n(`type`,e)},value:[e.type],children:[`all`,`scheduled`,`event`].map(e=>/* @__PURE__ */ (0,Y.jsx)(y,{className:`min-h-9`,value:e,variant:`pill`,children:e},e))})}),/* @__PURE__ */ (0,Y.jsx)(Z,{label:`Creator`,emptyLabel:`All`,value:e.creator??``,options:t?.creators??[],onChange:e=>n(`creator`,e)}),/* @__PURE__ */ (0,Y.jsx)(Z,{label:`Destination`,emptyLabel:`All`,value:e.destination??``,options:t?.destinations??[],onChange:e=>n(`destination`,e)}),/* @__PURE__ */ (0,Y.jsx)(Z,{label:`State`,emptyLabel:`All`,value:e.state===`all`?``:e.state,options:X,onChange:e=>n(`state`,e)})]})}function we(e){return/* @__PURE__ */ (0,Y.jsx)(_e,{ariaLabel:`Sort automations`,onChange:e.onChange,options:[{value:`newest`,label:`Recently created`},{value:`oldest`,label:`Oldest created`},{value:`title`,label:`Title A–Z`}],value:e.value})}function Z(e){return/* @__PURE__ */ (0,Y.jsx)(F,{label:e.label,children:/* @__PURE__ */ (0,Y.jsxs)(he,{"aria-label":e.ariaLabel??`Filter by ${e.label.toLowerCase()}`,variant:`filter`,value:e.value,onChange:t=>e.onChange(t.currentTarget.value),children:[e.emptyLabel?/* @__PURE__ */ (0,Y.jsx)(`option`,{value:``,children:e.emptyLabel}):null,e.value&&!e.options.some(t=>t.value===e.value)?/* @__PURE__ */ (0,Y.jsx)(`option`,{value:e.value,children:e.value}):null,e.options.map(e=>/* @__PURE__ */ (0,Y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})}function Te(e){let{automation:t}=e,n=Ee(t),r=/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(P,{imageUrl:t.createdByAvatarUrl,name:t.createdBy,size:`list`}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate`,children:t.createdBy})]});return/* @__PURE__ */ (0,Y.jsx)(`article`,{className:`min-w-0 rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-faint`,"data-automation-id":t.id,role:`listitem`,children:/* @__PURE__ */ (0,Y.jsx)(ge,{className:`flex items-start gap-3 rounded-lg px-4 py-3.5`,onSelect:e.onSelect,selected:!1,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(a,{"aria-label":`Open automation: ${t.title}`,className:`block w-full min-w-0 rounded-md text-left no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,to:e.to,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`truncate font-display text-base font-medium text-dashboard-text`,title:t.title,children:t.title}),n?/* @__PURE__ */ (0,Y.jsx)(j,{className:`shrink-0`,size:`compact`,tone:n===`completed`||n===`paused`?`neutral`:`warning`,children:n}):null]}),/* @__PURE__ */ (0,Y.jsx)(De,{automation:t})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`mt-2.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-dashboard-text-muted`,children:[t.createdByEmail?/* @__PURE__ */ (0,Y.jsx)(a,{className:`inline-flex min-w-0 max-w-full items-center gap-2 rounded-md text-dashboard-text no-underline hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus`,title:t.createdBy,to:oe(t.createdByEmail),children:r}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-2 text-dashboard-text`,title:t.createdBy,children:r}),/* @__PURE__ */ (0,Y.jsx)(Oe,{automation:t})]})]})})})}function Ee(e){return e.kind===`scheduled`?e.status===`active`?void 0:e.status:e.status===`active`?e.trigger.problems.length===0?void 0:`Trigger unavailable`:e.status}function De({automation:e}){let t=e.kind===`scheduled`,n=t?p:f,r=e.kind===`scheduled`?e.schedule:te(e.resource,e.trigger),i=e.kind===`scheduled`?h(e):r;return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Y.jsx)(n,{"aria-label":t?`Scheduled automation`:`${e.source} event automation`,className:`shrink-0`,role:`img`,size:13}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 truncate`,title:i,children:r}),/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-45`,children:`·`}),e.destination.visibility===`private`?/* @__PURE__ */ (0,Y.jsx)(c,{"aria-label":`Private destination`,className:`shrink-0`,role:`img`,size:12}):null,/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`min-w-0 max-w-[45%] truncate`,title:e.destination.label,children:e.destination.label})]})}function Oe({automation:e}){let t=e.kind===`scheduled`&&e.status===`active`?e.nextRunAt:void 0,n=e.lastRunAt?m(e.lastRunAt):void 0,r=e.lastRunStatus===`failed`||e.lastRunStatus===`blocked`;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[t?/* @__PURE__ */ (0,Y.jsxs)(Q,{title:m(t),children:[`Next run `,T(t)]}):null,/* @__PURE__ */ (0,Y.jsx)(Q,{title:n,children:r?/* @__PURE__ */ (0,Y.jsxs)(a,{className:`text-amber-300 underline`,to:C(e.id,`runs`),children:[`Last run `,e.lastRunStatus,e.lastRunAt?` ${T(e.lastRunAt)}`:null]}):e.lastRunAt?`Last run ${T(e.lastRunAt)}`:`Never run`})]})}function Q(e){return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`whitespace-nowrap`,title:e.title,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mr-2 opacity-45`,children:`·`}),e.children]})}const ke={costUsd:{color:`var(--color-cyan-300)`,label:`Spend`}};function $(e){return w({total:e})}function Ae(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.costUsd),i=r.reduce((e,t)=>e+t,0),a=Math.max(.01,...r),o=W(r),s=r.some(e=>e>0);return/* @__PURE__ */ (0,Y.jsxs)(_,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(E,{anchor:`cost`,label:`cost`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:w({total:i})||`$0.00`}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Spend from conversations linked to completed automation executions.`})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative mt-5 overflow-hidden`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{className:`aspect-auto h-50 w-full`,config:ke,children:/* @__PURE__ */ (0,Y.jsxs)(K,{"aria-label":`Automation execution spend during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:R,role:`img`,children:[/* @__PURE__ */ (0,Y.jsx)(I,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Y.jsx)(H,{format:$,maximum:a}),/* @__PURE__ */ (0,Y.jsx)(B,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,Y.jsx)(z,{content:/* @__PURE__ */ (0,Y.jsx)(L,{rows:e=>[[`spend`,$(e.costUsd)]]})}),/* @__PURE__ */ (0,Y.jsx)(G,{dataKey:`costUsd`,fill:`var(--color-costUsd)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,radius:1}),/* @__PURE__ */ (0,Y.jsx)(V,{unit:v(t),average:o,format:$,stroke:`var(--color-slate-200)`})]})}),s?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No linked spend in this period.`})]})]})}const je={total:{color:`var(--color-amber-400)`,label:`Executions`}};function Me(e){let t=e.bucketUnit??`day`,n=e.days.map(e=>({date:e.date,total:e.scheduled+e.event})),r=n.map(e=>e.total),i=Math.max(1,...r),a=W(r),o=r.some(e=>e>0);return/* @__PURE__ */ (0,Y.jsxs)(_,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Y.jsx)(E,{anchor:`runs`,label:`runs`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`${r.reduce((e,t)=>e+t,0).toLocaleString()} runs`}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Completed automation executions over time.`})]}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative mt-5 overflow-hidden`,children:[/* @__PURE__ */ (0,Y.jsx)(U,{className:`aspect-auto h-50 w-full`,config:je,children:/* @__PURE__ */ (0,Y.jsxs)(K,{"aria-label":`Automation executions during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:R,role:`img`,children:[/* @__PURE__ */ (0,Y.jsx)(I,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Y.jsx)(H,{maximum:i}),/* @__PURE__ */ (0,Y.jsx)(B,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,Y.jsx)(z,{content:/* @__PURE__ */ (0,Y.jsx)(L,{rows:e=>[[`executions`,e.total]]})}),/* @__PURE__ */ (0,Y.jsx)(G,{dataKey:`total`,fill:`var(--color-total)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,radius:1}),/* @__PURE__ */ (0,Y.jsx)(V,{unit:v(t),average:a,format:S,stroke:`var(--color-slate-200)`})]})}),o?null:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted`,children:`No automation executions in this period.`})]})]})}const Ne=[`1`,`7`,`30`,`90`];function Pe(e){let t=Number(e);return t===1||t===7||t===30||t===90?t:30}const Fe=[];function Ie(e){let t=r(),n=i(),[a,l]=ce(`range`,`30`,Ne),d=Pe(a),f=e=>l(String(e)),[p,m]=o(),[h,te]=se(`q`,{resetPage:!0}),v=g.parse(Object.fromEntries(Object.entries(g.shape).flatMap(([e,t])=>{let n=t.safeParse(p.get(e)??void 0);return n.success&&n.data!==void 0?[[e,n.data]]:[]}))),y=new URLSearchParams(Object.entries(v).map(([e,t])=>[e,String(t)])),x=ue(e.enabled,e.view===`list`?y.toString():``),S=(e,t)=>{let n=new URLSearchParams(window.location.search);n.delete(`page`),t?n.set(e,t):n.delete(e),m(n,{replace:!0})},oe=e=>m(t=>{let n=new URLSearchParams(t);return e===1?n.delete(`page`):n.set(`page`,String(e)),n}),w=e=>le(C(e),n.search),T=x.data?.automations??Fe,E=x.data?.counts.mine??0,D=x.data?.counts.public??0,O=x.data?.counts.private??0,k=x.data?.total??0,A=pe(k,v.pageSize),j=x.data?.page??v.page;re(e.view===`list`?`All automations`:void 0),(0,J.useEffect)(()=>{e.view!==`list`||!x.data||x.isPlaceholderData||x.isFetching||x.data.page===v.page||m(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(x.data.page)),t},{replace:!0})},[v.page,e.view,x.data,x.isFetching,x.isPlaceholderData,m]);let M=!x.data&&!x.error,N=x.data?.executionDays?.length?ie({days:x.data.executionDays,hours:x.data.executionHours,sixHours:x.data.executionSixHours,range:d,emptySixHour:e=>({costUsd:0,date:e,event:0,scheduled:0})}):[],P=N.length>0;return/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[e.view===`overview`?/* @__PURE__ */ (0,Y.jsx)(ae,{description:`Scheduled and event-driven work created by users.`,onRangeChange:f,range:d,title:`Automations`}):/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 font-display text-2xl font-light tracking-tight text-dashboard-text sm:text-3xl`,children:`All automations`}),e.view===`list`?/* @__PURE__ */ (0,Y.jsx)(Se,{filters:v,data:x.data,onChange:S,searchText:h,onSearch:te}):null,M?/* @__PURE__ */ (0,Y.jsx)(ne,{label:`Loading automations`,variant:e.view===`overview`?`stats`:`list`}):null,x.error?/* @__PURE__ */ (0,Y.jsxs)(de,{children:[`Automations could not be loaded.`,` `,/* @__PURE__ */ (0,Y.jsx)(s,{onClick:()=>void x.refetch(),children:`Try again`})]}):null,x.data&&e.view===`overview`?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,Y.jsx)(q,{detail:`All automations you can access`,icon:ve,label:`Total automations`,value:x.data?.counts.all??0}),/* @__PURE__ */ (0,Y.jsx)(q,{detail:`Created by you`,icon:ee,label:`Your automations`,value:E}),/* @__PURE__ */ (0,Y.jsx)(q,{detail:`In shared destinations`,icon:u,label:`Public automations`,value:D}),/* @__PURE__ */ (0,Y.jsx)(q,{detail:`Visible only to you`,icon:c,label:`Private automations`,value:O})]}),P?/* @__PURE__ */ (0,Y.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[/* @__PURE__ */ (0,Y.jsx)(Me,{bucketUnit:b(d),days:N,range:d}),/* @__PURE__ */ (0,Y.jsx)(Ae,{bucketUnit:b(d),days:N,range:d})]}):null]}):null,x.data&&e.view===`list`?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-5 gap-y-2`,children:[/* @__PURE__ */ (0,Y.jsxs)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:[k,` `,k===1?`automation`:`automations`,x.isFetching?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`ml-3`,role:`status`,children:`Updating results…`}):null]}),/* @__PURE__ */ (0,Y.jsx)(we,{value:v.sort,onChange:e=>S(`sort`,e)})]}),!x.error&&k===0?/* @__PURE__ */ (0,Y.jsx)(_,{padding:`md`,children:/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:`No automations matched these filters.`})}):/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-2`,role:`list`,children:T.map(e=>{let n=`${e.kind}:${e.id}`;return/* @__PURE__ */ (0,Y.jsx)(Te,{onSelect:()=>t(w(e.id)),automation:e,to:w(e.id)},n)})}),/* @__PURE__ */ (0,Y.jsx)(fe,{onPageChange:oe,page:j,pageCount:A,pageSize:v.pageSize,total:k})]}):null]})}export{Ie as AutomationsPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,r}from"./vendor-react-ggbyvons.js";import{n as i,t as a}from"./CodeChangeRow-oyge0uo2.js";import{t as o}from"./Card-hy4bfgq7.js";import{r as s,s as c,t as l}from"./PageHeader-kvp1fo95.js";import{t as u}from"./PageLayout-l6dhbimv.js";import{$ as d,J as f,Jt as p,Q as m,X as h,Y as g,Z as _,p as v,pt as y,u as b}from"../client-ll3qwj84.js";import{n as x,r as S,t as C}from"./CodeSummaryCards-gikkczl6.js";var w=/* @__PURE__ */ e(t(),1),T=n();function E(){let[e,t]=(0,w.useState)(30),n=p();return!n.data&&!n.error?/* @__PURE__ */ (0,T.jsx)(b,{description:`Repositories and code changes created by Junior.`,label:`Loading code activity`,title:`Code`,variant:`stats`}):/* @__PURE__ */ (0,T.jsxs)(u,{children:[/* @__PURE__ */ (0,T.jsx)(l,{description:`Repositories and code changes created by Junior.`,onRangeChange:t,range:e,title:`Code`}),n.error?/* @__PURE__ */ (0,T.jsx)(y,{children:`Code activity is unavailable. Try refreshing the dashboard.`}):null,n.data?/* @__PURE__ */ (0,T.jsx)(D,{data:n.data,range:e}):null]})}function D(e){let t=e.data;return/* @__PURE__ */ (0,T.jsxs)(T.Fragment,{children:[/* @__PURE__ */ (0,T.jsx)(C,{summary:t.summary}),/* @__PURE__ */ (0,T.jsx)(i,{bucketUnit:c(e.range),days:s({days:t.activityDays,hours:t.activityHours,sixHours:t.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),/* @__PURE__ */ (0,T.jsxs)(o,{as:`section`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text`,children:`Repositories`}),t.repositories.length===0?/* @__PURE__ */ (0,T.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,T.jsx)(y,{children:`No code activity has been recorded yet.`})}):/* @__PURE__ */ (0,T.jsxs)(f,{className:`min-w-[36rem] table-fixed`,children:[/* @__PURE__ */ (0,T.jsxs)(`colgroup`,{children:[/* @__PURE__ */ (0,T.jsx)(`col`,{}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`}),/* @__PURE__ */ (0,T.jsx)(`col`,{className:`w-28`})]}),/* @__PURE__ */ (0,T.jsx)(m,{children:/* @__PURE__ */ (0,T.jsxs)(d,{children:[/* @__PURE__ */ (0,T.jsx)(_,{className:`px-4`,children:`Repository`}),/* @__PURE__ */ (0,T.jsx)(_,{className:`px-4 text-right`,children:`Created`}),/* @__PURE__ */ (0,T.jsx)(_,{className:`px-4 text-right`,children:`Merge rate`}),/* @__PURE__ */ (0,T.jsx)(_,{className:`px-4 text-right`,children:`Median cost`})]})}),/* @__PURE__ */ (0,T.jsx)(g,{children:t.repositories.map(e=>/* @__PURE__ */ (0,T.jsxs)(d,{children:[/* @__PURE__ */ (0,T.jsxs)(h,{className:`min-w-0 px-4 py-3`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`truncate font-display text-sm text-dashboard-text`,children:/* @__PURE__ */ (0,T.jsx)(r,{className:`text-inherit no-underline hover:text-dashboard-accent-text`,to:v(e.id),children:e.name})}),/* @__PURE__ */ (0,T.jsx)(`div`,{className:`mt-1 truncate font-mono text-xs text-dashboard-text-muted`,children:e.provider})]}),/* @__PURE__ */ (0,T.jsx)(h,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:e.created}),/* @__PURE__ */ (0,T.jsx)(h,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:S(e.mergeRate)}),/* @__PURE__ */ (0,T.jsx)(h,{className:`px-4 py-3 text-right font-sans tabular-nums`,children:x(e.medianCostUsd)})]},e.id))})]})]}),t.changes.length>0?/* @__PURE__ */ (0,T.jsxs)(o,{as:`section`,children:[/* @__PURE__ */ (0,T.jsx)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3 font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,T.jsx)(`div`,{children:t.changes.map(e=>/* @__PURE__ */ (0,T.jsx)(a,{change:e},e.id))})]}):null]})}export{E as CodePage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{nt as t}from"./vendor-lthmb2su.js";import{C as n,S as r}from"./vendor-react-ggbyvons.js";import{Pt as i}from"./vendor-icons-mxz7yi04.js";import{i as a,t as o}from"./styles-j0007fov.js";import{t as s}from"./Card-hy4bfgq7.js";import{a as c,d as l,o as u,u as d}from"./PageHeader-kvp1fo95.js";import{c as f,l as p,p as m,q as h}from"./format-eev8is9c.js";import{$ as g,J as _,Q as v,X as y,Y as b,Z as x,it as S,nt as C,rt as ee}from"../client-ll3qwj84.js";import{$t as te,A as ne,At as w,C as T,Ct as E,D as re,E as ie,Et as D,F as ae,Ft as oe,H as se,It as ce,J as le,K as ue,Lt as de,M as fe,Mt as pe,N as me,Nt as he,O as ge,P as _e,Qt as ve,R as ye,S as be,Tt as O,U as k,Vt as A,Yt as j,Z as M,_ as xe,a as N,ct as Se,d as P,dt as Ce,f as we,g as Te,gt as F,h as Ee,ht as De,it as Oe,k as ke,n as I,o as L,p as Ae,q as je,r as Me,s as R,st as Ne,t as z,u as Pe,ut as Fe,v as Ie,x as Le,yt as Re,zt as B}from"./chart-mxqu3c8e.js";import{a as ze,c as Be,i as Ve,l as He,n as V,o as Ue,r as We,s as Ge,t as H}from"./BarChart-cg02osy4.js";import{t as Ke}from"./Area-hr2tz6ad.js";import{t as qe}from"./ChartLegend-c3e9l1vl.js";import{t as Je}from"./ChartHeader-c1zg4xt5.js";var U=/* @__PURE__ */ e(n()),Ye=[`option`,`isActive`];function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}function Xe(e,t){if(e==null)return{};var n,r,i=Ze(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ze(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Qe(e){var{option:t,isActive:n}=e,r=Xe(e,Ye);return typeof t==`string`?/*#__PURE__*/ U.createElement(Ge,W({option:/*#__PURE__*/ U.createElement(He,W({type:t},r)),isActive:n,shapeType:`symbols`},r)):/*#__PURE__*/ U.createElement(Ge,W({option:t,isActive:n,shapeType:`symbols`},r))}var $e=(e,t,n,r,i,a,o)=>k(e,`xAxis`,t,o),et=(e,t,n,r,i,a,o)=>ue(e,`xAxis`,t,o),tt=(e,t,n,r,i,a,o)=>k(e,`yAxis`,n,o),nt=(e,t,n,r,i,a,o)=>ue(e,`yAxis`,n,o),rt=(e,t,n,r)=>le(e,`zAxis`,r,!1),it=(e,t,n,r,i)=>i,at=(e,t,n,r,i,a)=>a,ot=(e,t,n,r,i,a,o)=>Oe(e,void 0,void 0,o),st=w([je,it],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),ct=w([ot,$e,et,tt,nt,rt,st,at],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(d!=null&&t!=null&&r!=null&&n!=null&&i!=null&&n?.length!==0&&i?.length!==0)return Ct({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),lt=[`id`],ut=[`onMouseEnter`,`onClick`,`onMouseLeave`],dt=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function G(e,t){if(e==null)return{};var n,r,i=ft(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ft(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?pt(Object(n),!0).forEach(function(t){mt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mt(e,t,n){return(t=ht(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ht(e){var t=gt(e,`string`);return typeof t==`symbol`?t:t+``}function gt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _t=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:O(n,t),payload:e}]},vt=/*#__PURE__*/ U.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:O(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return/*#__PURE__*/ U.createElement(ke,{tooltipEntrySettings:u})});function yt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=ve(n),s=te(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=de(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=q(q(q({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=/*#__PURE__*/ U.isValidElement(r)?/*#__PURE__*/ U.cloneElement(r,h):typeof r==`function`?r(h):/*#__PURE__*/ U.createElement(Fe,K({},h,{type:a})),/*#__PURE__*/ U.createElement(j,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function bt(e){var{showLabels:t,points:n,children:r}=e,i=De(),a=(0,U.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return q(q({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return/*#__PURE__*/ U.createElement(fe,{value:t?a:void 0},r)}function xt(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=G(n,lt),c=pe(ye),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=G(n,ut),p=ze(l,a,o),m=Ue(d),h=Ve(u,a,o);if(!ce(t))return null;var g=ve(s);return/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(yt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=q(q(q({},g),e),{},{index:t,[Re]:String(o)});return/*#__PURE__*/ U.createElement(ae,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?M.activeDot:void 0},/*#__PURE__*/ U.createElement(j,K({className:`recharts-scatter-symbol`},oe(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),/*#__PURE__*/ U.createElement(Qe,K({option:s,isActive:a},l))))}))}function St(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Ne(n,`recharts-scatter-`),[u,d]=(0,U.useState)(!1),f=(0,U.useCallback)(()=>{d(!1)},[]),p=(0,U.useCallback)(()=>{d(!0)},[]),m=!u;return/*#__PURE__*/ U.createElement(bt,{showLabels:m,points:r},n.children,/*#__PURE__*/ U.createElement(Se,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?q(q({},t),{},{cx:t.cx==null?void 0:B(r.cx,t.cx,e),cy:t.cy==null?void 0:B(r.cy,t.cy,e),size:B(r.size,t.size,e)}):q(q({},t),{},{size:B(0,t.size,e)})});return e>0&&(t.current=i),/*#__PURE__*/ U.createElement(j,null,/*#__PURE__*/ U.createElement(xt,{points:i,allOtherScatterProps:n,showLabels:m}))}),/*#__PURE__*/ U.createElement(me,{label:n.label}))}function Ct(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=A(n.dataKey)?a.dataKey:n.dataKey,u=A(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:se.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=D(e,l),g=D(e,u),_=!A(d)&&D(e,d)||`-`,v=[{name:A(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:A(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=E({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=E({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return q(q({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var wt=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:D(e,t)});function Tt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,U.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return/*#__PURE__*/ U.createElement(ae,{zIndex:e.zIndex},/*#__PURE__*/ U.createElement(j,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&/*#__PURE__*/ U.createElement(`defs`,null,/*#__PURE__*/ U.createElement(Le,{clipPathId:d,xAxisId:o,yAxisId:s})),/*#__PURE__*/ U.createElement(We,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:wt,errorBarOffset:0},/*#__PURE__*/ U.createElement(j,{key:`recharts-scatter-symbols`},/*#__PURE__*/ U.createElement(St,{props:e,previousPointsRef:l})))))}var Et={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:M.scatter};function Dt(e){var t=he(e,Et),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=G(t,dt),{needClip:h}=be(d,f),g=(0,U.useMemo)(()=>ne(e.children,Be),[e.children]),_=F(),v=pe(t=>ct(t,d,f,p,e.id,g,_));return h==null||v==null?null:/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(vt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),/*#__PURE__*/ U.createElement(Tt,K({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function Ot(e){var t=he(e,Et),n=F();return/*#__PURE__*/ U.createElement(re,{id:t.id,type:`scatter`},e=>/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(ge,{legendPayload:_t(t)}),/*#__PURE__*/ U.createElement(ie,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),/*#__PURE__*/ U.createElement(Dt,K({},t,{id:e}))))}var kt=/*#__PURE__*/ U.memo(Ot,Ce);kt.displayName=`Scatter`;var At=[`axis`],jt=/*#__PURE__*/ (0,U.forwardRef)((e,t)=>/*#__PURE__*/ U.createElement(xe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:_e,categoricalChartProps:e,ref:t}));const J=[{key:`cachedInputTokens`,label:`From cache`,color:`var(--color-cyan-400)`},{key:`cacheCreationTokens`,label:`Written to cache`,color:`var(--color-amber-400)`},{key:`inputTokens`,label:`Uncached`,color:`var(--color-violet-400)`}];function Y(e){if(!J.some(({key:t})=>e[t]===void 0))return J.reduce((t,{key:n})=>t+e[n],0)}function X(e,t){if(e===void 0||t===void 0||t===0)return`—`;let n=e/t*100;return n<100&&n>=99.95?`<100%`:n>0&&n<.05?`<0.1%`:`${n.toFixed(1)}%`}function Mt(e){return J.some(({key:t})=>e[t]!==void 0)||(e.tokens??0)>0||e.durationMs>0||e.conversations>0}function Nt(e){let t=e.filter(Mt),n={};for(let{key:e}of J)t.length&&t.every(t=>t[e]!==void 0)&&(n[e]=t.reduce((t,n)=>t+n[e],0));return{input:n,total:Y(n),activePeriods:t.length,incompletePeriods:t.filter(e=>Y(e)===void 0).length}}var Z=r();function Pt(e){let t=e.days.filter(e=>(e.cacheCreationTokens??0)>0).sort((e,t)=>t.cacheCreationTokens-e.cacheCreationTokens||t.date.localeCompare(e.date)).slice(0,3);if(!t.length)return null;let n=e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit;return/* @__PURE__ */ (0,Z.jsxs)(C,{className:`border-t border-dashboard-border-subtle px-4 py-3 sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(S,{className:`group flex cursor-pointer items-center gap-1 font-sans tabular-nums text-xs text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`Largest cache writes`]}),/* @__PURE__ */ (0,Z.jsxs)(ee,{hiddenUntilFound:!0,children:[/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`mb-2 mt-3 font-sans tabular-nums text-xs leading-relaxed text-dashboard-text-muted`,children:[`Top three by tokens written per `,n,`, within the selected time window. Large writes alone do not mean a cache problem.`]}),/* @__PURE__ */ (0,Z.jsxs)(_,{"aria-label":`Largest cache writes`,className:`min-w-80 table-fixed font-sans text-xs tabular-nums`,children:[/* @__PURE__ */ (0,Z.jsx)(v,{children:/* @__PURE__ */ (0,Z.jsxs)(g,{children:[/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`px-0 py-2 font-normal`,children:e.bucketUnit===`day`?`Day`:`Starting at`}),/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`Written`}),/* @__PURE__ */ (0,Z.jsx)(x,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`From cache`})]})}),/* @__PURE__ */ (0,Z.jsx)(b,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsxs)(g,{children:[/* @__PURE__ */ (0,Z.jsx)(x,{scope:`row`,className:`px-0 py-2 font-normal whitespace-normal`,children:Ee(e.date)}),/* @__PURE__ */ (0,Z.jsx)(y,{className:`px-0 py-2 text-right whitespace-normal`,children:p(e.cacheCreationTokens)}),/* @__PURE__ */ (0,Z.jsx)(y,{className:`px-0 py-2 text-right whitespace-normal`,children:X(e.cachedInputTokens,Y(e))})]},e.date))})]})]})]})}const Ft={...Object.fromEntries(J.map(({color:e,key:t,label:n})=>[t,{color:e,label:n}])),missing:{color:`var(--color-slate-400)`,label:`Missing data`}};function It(e){let[t,n]=(0,U.useState)(`share`),r=Nt(e.days),o=e.days.map(e=>{let n=Y(e);return{...Object.fromEntries(J.map(({key:r})=>{let i=e[r]??0;return[r,t===`share`?n?i/n*100:0:i]})),date:e.date,day:e,missing:n===void 0&&Mt(e)?0:void 0}}),c=t===`share`?100:Math.max(1,...e.days.map(e=>J.reduce((t,{key:n})=>t+(e[n]??0),0)));return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:`Input cache`,trailing:/* @__PURE__ */ (0,Z.jsxs)(d,{"aria-label":`Cache chart display`,onValueChange:([e])=>{e&&n(e)},value:[t],children:[/* @__PURE__ */ (0,Z.jsx)(l,{value:`share`,children:`Percent`}),/* @__PURE__ */ (0,Z.jsx)(l,{value:`tokens`,children:`Tokens`})]})}),/* @__PURE__ */ (0,Z.jsx)(`dl`,{className:`m-0 flex flex-wrap gap-x-5 gap-y-2 px-4 py-3 font-sans tabular-nums text-xs sm:px-5`,children:J.map(({key:e,label:t,color:n})=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,Z.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:n}}),t]}),/* @__PURE__ */ (0,Z.jsx)(`dd`,{className:`m-0 tabular-nums text-dashboard-text`,children:X(r.input[e],r.total)})]},e))}),r.activePeriods===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:`No input data in this time window.`}):r.incompletePeriods>0?/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[`Missing data in `,r.incompletePeriods,` of `,r.activePeriods,` `,`active time intervals. Percentages are unavailable; Tokens shows the reported values.`]}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-40 w-full`,config:Ft,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":`Input cache ${t} per ${u(e.bucketUnit)}`,data:o,margin:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t===`share`?e=>`${e}%`:p,maximum:c}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:o.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(Ie,{dataKey:`date`,hide:!0,xAxisId:`missing`}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(N,{rows:({day:e})=>{let t=Y(e);return J.map(({key:n,label:r})=>[r,e[n]===void 0?`Not reported`:`${p(e[n])} · ${X(e[n],t)}`])}})}),J.map(({key:e})=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:e,fill:`var(--color-${e})`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:32,stackId:`input`},e)),/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`missing`,fill:`var(--color-missing)`,isAnimationActive:!1,maxBarSize:32,minPointSize:3,xAxisId:`missing`})]})})}),/* @__PURE__ */ (0,Z.jsx)(Pt,{days:e.days,bucketUnit:e.bucketUnit}),/* @__PURE__ */ (0,Z.jsxs)(C,{className:`border-t border-dashboard-border-subtle px-4 py-3 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(S,{className:`group flex cursor-pointer items-center gap-1 text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`How to read this`]}),/* @__PURE__ */ (0,Z.jsx)(ee,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 leading-relaxed`,children:[/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`From cache is input reused. Written to cache is input saved for reuse. Uncached is the remaining input.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`Percentages use total input tokens, not call counts. Gray marks and — mean missing data; zero means a reported zero. The latest interval may be incomplete.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`These totals can show when reuse changes, but not why. They do not show individual calls or prove that every call reported cache use.`})]})})]})]})}function Lt(e){return e<1?`$${e.toFixed(2)}`:`$${p(e)}`}function Rt(e){let t=e/36e5;return t>=24?`${p(t/24)}d`:t>=1?`${p(t)}h`:h(e)}function zt(){return{axisFormat:p,color:`var(--color-cyan-400)`,format:p,metric:`tokens`,title:`Token usage`,type:`bar`}}function Bt(){return[{axisFormat:Lt,color:`var(--color-amber-400)`,format:e=>m({total:e}),metric:`costUsd`,title:`Model spend`,type:`area`},{axisFormat:Rt,color:`var(--color-violet-400)`,format:h,metric:`durationMs`,title:`Runtime`,type:`scatter`}]}function Vt(e,t){return e[t]??0}function Ht(e){let t=e.bucketUnit??`day`,n=e.cacheBreakdown?Bt():[zt(),...Bt()];return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[e.cacheBreakdown?/* @__PURE__ */ (0,Z.jsx)(It,{bucketUnit:t,days:e.days}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:e.cacheBreakdown?`grid gap-4 lg:grid-cols-2`:`grid gap-4 lg:grid-cols-3`,children:n.map(n=>/* @__PURE__ */ (0,Z.jsx)(Ut,{bucketUnit:t,chart:n,days:e.days},n.metric))})]})}function Ut(e){let{chart:t,days:n}=e,r=n.map(e=>Vt(e,t.metric)),i=n.map((e,t)=>({date:e.date,value:r[t]})),a=Math.max(2**-52,...r),o=r.reduce((e,t)=>e+t,0),l=Pe(r),u={dataKey:`value`,fill:`var(--color-value)`,isAnimationActive:!1};return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:t.title,total:t.format(o)}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 py-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-38 w-full`,config:{value:{color:t.color,label:t.title}},children:/* @__PURE__ */ (0,Z.jsxs)(jt,{"aria-label":`${t.title} per ${e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit}`,data:i,margin:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t.axisFormat,maximum:a}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:i.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(N,{rows:e=>[[t.title,t.format(e.value)]]})}),t.type===`bar`?/* @__PURE__ */ (0,Z.jsx)(V,{...u,fillOpacity:.8,maxBarSize:8,minPointSize:e=>e?2:0,radius:1.5}):t.type===`area`?/* @__PURE__ */ (0,Z.jsx)(Ke,{...u,dot:{fillOpacity:.45,r:2.5,stroke:`none`},fillOpacity:.08,stroke:`var(--color-value)`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,type:`linear`}):/* @__PURE__ */ (0,Z.jsx)(kt,{...u,fillOpacity:.75}),/* @__PURE__ */ (0,Z.jsx)(Me,{average:l,format:t.metric===`tokens`?f:t.format,stroke:t.color,unit:c(e.bucketUnit)})]})})})]})}const Q=[`var(--color-cyan-300)`,`var(--color-emerald-300)`,`var(--color-amber-400)`,`var(--color-rose-400)`,`var(--color-violet-400)`],Wt={danger:`var(--color-rose-400)`,good:`var(--color-emerald-300)`,neutral:`var(--color-cyan-300)`,warning:`var(--color-amber-400)`};function Gt(e,t){return e.tone?Wt[e.tone]:Q[t%Q.length]??Q[0]}function Kt(e,t){let n=e.timeRangeDays?e.categories.slice(-Jt(e,t)):e.categories,r=n.flatMap(t=>e.series.map(e=>t.values[e.key]??0)),i=Math.min(0,...r),a=Math.max(0,...r);return{categories:n,maximum:a===i?i+1:a,minimum:i}}function qt(e){let{widget:t}=e,{categories:n,maximum:r,minimum:i}=Kt(t,e.range),a=Xt(t),o=n.map(e=>({category:e,id:e.id,...Object.fromEntries(t.series.map((t,n)=>[`series-${n}`,e.values[t.key]??0]))})),s=new Map(n.map(e=>[e.id,e.label])),c=Object.fromEntries(t.series.map((e,t)=>[`series-${t}`,{color:Gt(e,t),label:e.label}]));return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:/* @__PURE__ */ (0,Z.jsx)(`h4`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:t.title})}),t.description?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`mt-1 mb-0 font-mono text-xs text-dashboard-text-muted`,children:t.description}):null,t.series.length>1?/* @__PURE__ */ (0,Z.jsx)(qe,{ariaLabel:`Chart legend`,items:t.series.map((e,t)=>({color:Gt(e,t),key:e.key,label:e.label}))}):null]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 p-4 font-sans text-xs text-dashboard-text-muted`,children:t.emptyText??`No chart data.`}):/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-60 w-full`,config:c,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":t.title,data:o,margin:P,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(T,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:e=>Zt(e,a),maximum:r,minimum:i}),/* @__PURE__ */ (0,Z.jsx)(L,{centered:!0,dataKey:`id`,formatLabel:e=>we(s.get(e)??e),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(N,{formatLabel:e=>Ae(s.get(e)??e),rows:({category:e})=>t.series.map(t=>[t.label,Zt(e.values[t.key]??0,t.format)])})}),t.series.map((e,n)=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`series-${n}`,fill:`var(--color-series-${n})`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:54/t.series.length,minPointSize:e=>e?2:0,radius:1.5},e.key))]})})]})}function Jt(e,t){let n=e.timeRangeDays??[],r=e.categories[0],i=r?.id||r?.label||``,a=Te(i);return t===1?a&&n.includes(1)?24:n.includes(7)?7:n.includes(30)?30:n[0]??30:t&&n.includes(t)?t:n.includes(30)?30:n[0]??30}function Yt(e){return String(Number(e.toPrecision(12)))}function Xt(e){return new Set(e.series.map(e=>e.format)).size===1?e.series[0]?.format:void 0}function Zt(e,t){return t===`usd`?m({total:e}):Yt(e)}function Qt(e){let t=e.recordSet.fields??[],n=e.recordSet.records??[],r=e.embedded===!0;return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:o(r?`border-t border-dashboard-border-subtle`:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`),children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.recordSet.title}),/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`hidden font-mono text-xs text-dashboard-text-muted sm:block`,children:[n.length,` records`]})]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.recordSet.emptyText??`No records.`}):t.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Report records are unavailable because no fields were declared.`}):/* @__PURE__ */ (0,Z.jsxs)(Z.Fragment,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`grid gap-2 border-t border-dashboard-border-subtle p-3 sm:hidden`,children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(`div`,{className:o(`grid gap-3 rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft p-3`,$(e.tone)),children:t.map(t=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:t.label}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`mt-1 break-words font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.values[t.key]??``})]},t.key))},e.id))}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`hidden border-t border-dashboard-border-subtle sm:block`,children:/* @__PURE__ */ (0,Z.jsxs)(_,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,Z.jsx)(v,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,Z.jsx)(g,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsx)(x,{className:`px-5`,scope:`col`,children:e.label},e.key))})}),/* @__PURE__ */ (0,Z.jsx)(b,{children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(g,{className:$(e.tone),children:t.map(t=>/* @__PURE__ */ (0,Z.jsx)(y,{className:`max-w-72 truncate px-5 py-3 font-mono text-xs text-dashboard-text-muted`,children:e.values[t.key]??``},t.key))},e.id))})]})})]})]})}function $(e){return e===`danger`?`bg-rose-500/[0.07]`:e===`warning`?`bg-amber-300/[0.045]`:e===`good`?`bg-emerald-400/[0.055]`:``}export{qt as n,Ht as r,Qt as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{n as a}from"./button-loz3etho.js";import{qt as o}from"./vendor-icons-mxz7yi04.js";import{n as s,t as c}from"./CodeChangeRow-oyge0uo2.js";import{a as l,t as u}from"./styles-j0007fov.js";import{t as d}from"./Card-hy4bfgq7.js";import{n as f,r as p,s as m,t as h}from"./PageHeader-kvp1fo95.js";import{H as g,T as _,U as ee,a as v,j as y,r as b,y as x}from"./format-eev8is9c.js";import{t as S}from"./SecondaryNavigation-m358iuko.js";import{t as C}from"./PageLayout-l6dhbimv.js";import{B as w,Dt as T,Et as E,G as D,Tt as O,W as k,Xt as te,Yt as A,dt as j,ft as M,lt as N,p as P,pt as F,q as I,u as L,ut as R,wt as z,xt as B}from"../client-ll3qwj84.js";import{r as V}from"./FilterBar-h4ab22b1.js";import{t as H}from"./CodeSummaryCards-gikkczl6.js";import{n as U,t as W}from"./SectionTitle-drw3mqtl.js";var G=/* @__PURE__ */ e(t(),1),K=n();function q(e){return/* @__PURE__ */ (0,K.jsxs)(d,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,K.jsx)(U,{actions:e.viewAllTo?/* @__PURE__ */ (0,K.jsx)(i,{className:`text-sm text-dashboard-text underline underline-offset-2`,to:e.viewAllTo,children:`View all`}):void 0,children:/* @__PURE__ */ (0,K.jsx)(W,{children:e.title})}),e.children]})}function J(e){let t=e.conversation,n=v(t),r=y(t,{includeId:!1}),a=!!t.sidebarAnnotations?.length;return/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`relative min-w-0 border-b border-dashboard-border-subtle px-4 py-3 transition-colors last:border-b-0 hover:bg-dashboard-fill-soft`,children:[/* @__PURE__ */ (0,K.jsx)(i,{"aria-label":`Open ${n}`,className:`absolute inset-0 z-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,to:O(t.id)}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`pointer-events-none relative z-[1] grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2`,children:[/* @__PURE__ */ (0,K.jsx)(`span`,{className:`mt-1.5 grid size-3 shrink-0 place-items-center`,children:/* @__PURE__ */ (0,K.jsx)(D,{unread:!1,isPrivate:t.visibility===`private`,status:g(t),waitingOnViewer:!1})}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`min-w-0 truncate font-display text-sm text-dashboard-text`,children:n}),/* @__PURE__ */ (0,K.jsx)(`span`,{className:`whitespace-nowrap font-mono text-xs text-dashboard-text-muted`,children:x(t.lastSeenAt)}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`col-start-2 col-end-4 mt-1 flex h-4 min-w-0 items-center gap-1.5 font-mono text-xs text-dashboard-text-muted`,children:a?/* @__PURE__ */ (0,K.jsx)(w,{annotations:t.sidebarAnnotations}):r?/* @__PURE__ */ (0,K.jsx)(`span`,{className:`truncate`,children:r}):null})]})]})}function Y(e,t){return p({days:e.activityDays,hours:e.activityHours,sixHours:e.activitySixHours,range:t,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})})}function X(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(1),a=z(t.trim()),o=A(e.repositoryId,a),s=b(o.data?.conversations??[]),c=B();return(0,G.useEffect)(()=>{i(1)},[a]),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3`,children:[/* @__PURE__ */ (0,K.jsx)(M,{className:`w-full sm:ml-auto sm:w-72`,label:`Search conversations in this repository`,onChange:n,placeholder:`Search conversations…`,value:t}),o.error?/* @__PURE__ */ (0,K.jsx)(F,{children:`Conversations are unavailable. Try refreshing the dashboard.`}):/* @__PURE__ */ (0,K.jsx)(k,{conversations:j(T(s,E(s,c)),r,25),emptyLabel:a?`No conversations match this search.`:`No conversations are linked to this repository yet.`,loading:!o.data,timeZone:_(),waitingConversationIds:c}),/* @__PURE__ */ (0,K.jsx)(N,{className:`pt-1`,onPageChange:i,page:r,pageCount:R(s.length,25),pageSize:25,total:s.length})]})}function Z(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(1),l=e.data.changes,u=r.trim().toLowerCase(),f=l.filter(e=>(!t||e.state===t)&&(!u||e.title?.toLowerCase().includes(u)||`#${e.number}`.includes(u))),p=e=>l.filter(t=>t.state===e).length;return(0,G.useEffect)(()=>{o(1)},[t,u]),/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(e.data,e.range),range:e.range}),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Changes`,className:`grid gap-4`,children:[/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,K.jsx)(V,{ariaLabel:`Change state`,items:[{count:l.length,label:`All`,value:``},{count:p(`open`),label:`Open`,value:`open`},{count:p(`merged`),label:`Merged`,value:`merged`},{count:p(`closed`),label:`Closed`,value:`closed`}],onChange:n,value:t}),/* @__PURE__ */ (0,K.jsx)(M,{className:`w-full max-w-md sm:w-auto`,label:`Search changes`,onChange:i,placeholder:`Title or number`,value:r})]}),/* @__PURE__ */ (0,K.jsx)(d,{children:f.length===0?/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(F,{children:`No changes match these filters.`})}):j(f,a,25).map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id))}),/* @__PURE__ */ (0,K.jsx)(N,{onPageChange:o,page:a,pageCount:R(f.length,25),pageSize:25,total:f.length})]})]})}const Q=`Conversations and code changes from Junior.`,ne=u(`font-semibold`,l);function re(e){let t=r().repositoryId,[n,i]=(0,G.useState)(30),o=te(t);if(!o.data&&!o.error)return/* @__PURE__ */ (0,K.jsx)(L,{description:Q,label:`Loading repository`,title:`Repository`,variant:`stats`});let s=o.data;if(!s)return/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(F,{children:`This repository is unavailable. It may not have any code changes from Junior.`})]});let c=s.repository;return/* @__PURE__ */ (0,K.jsx)(S,{ariaLabel:`Repository navigation`,items:[{end:!0,label:`Overview`,to:P(c.id)},{label:`Conversations`,to:P(c.id,`conversations`)},{label:`Changes`,to:P(c.id,`changes`)}],children:/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(h,{actions:/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,K.jsx)(f,{onChange:i,value:n}),c.url?/* @__PURE__ */ (0,K.jsx)(I,{className:a(),href:c.url,children:`Open repository`}):null]}),description:/* @__PURE__ */ (0,K.jsx)(ie,{data:s}),documentTitle:e.tab===`overview`?c.name:`${c.name} · ${e.tab===`changes`?`Changes`:`Conversations`}`,title:c.name}),e.tab===`overview`?/* @__PURE__ */ (0,K.jsx)(ae,{data:s,range:n}):null,e.tab===`conversations`?/* @__PURE__ */ (0,K.jsx)(X,{repositoryId:c.id}):null,e.tab===`changes`?/* @__PURE__ */ (0,K.jsx)(Z,{data:s,range:n}):null]})})}function $(){return/* @__PURE__ */ (0,K.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/code`,children:[/* @__PURE__ */ (0,K.jsx)(o,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to code`]})}function ie(e){let t=e.data.workspaces;return t.length===0?Q:/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[Q,` / Workspaces`,` `,t.map((e,t)=>/* @__PURE__ */ (0,K.jsxs)(`span`,{children:[t>0?`, `:null,/* @__PURE__ */ (0,K.jsx)(i,{className:ne,to:ee(e.id),children:e.name})]},e.id))]})}function ae(e){let t=e.data,n=A(t.repository.id),r=b(n.data?.conversations??[]).slice(0,5),i=t.changes.slice(0,5);return/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(H,{summary:t.summary}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent conversations`,viewAllTo:P(t.repository.id,`conversations`),children:r.length>0?r.map(e=>/* @__PURE__ */ (0,K.jsx)(J,{conversation:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(F,{children:n.error?`Conversations are unavailable. Try refreshing the dashboard.`:n.data?`No conversations are linked to this repository yet.`:`Loading conversations…`})})}),/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent changes`,viewAllTo:P(t.repository.id,`changes`),children:i.length>0?i.map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(F,{children:`No code changes are recorded yet.`})})})]}),/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(t,e.range),range:e.range})]})}export{re as RepositoryPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-loz3etho.js";import{E as s,Ot as c,lt as l,mt as u}from"./junior-btnqqkq5.js";import{r as d}from"./schema-m4v0mjyv.js";import{a as f,i as p,n as m,s as h,t as g}from"./http-cdq677qt.js";import{t as _}from"./Card-hy4bfgq7.js";import{t as v}from"./skeleton-h6p83ux1.js";import{d as y,u as b}from"./PageHeader-kvp1fo95.js";import{t as x}from"./AnchorHeading-cp3vx8qa.js";import{C as ee,H as S,M as C,N as w,Nt as te,P as T,Pt as ne,S as E,U as D,V as O,_ as k,_t as A,b as j,bt as M,d as re,g as ie,gt as N,h as P,m as F,mt as I,v as L,w as R,x as z,y as B,yt as V}from"../client-ll3qwj84.js";import{t as H}from"./native-select-jfknh8t4.js";var U=/* @__PURE__ */ e(i(),1),W=a();const G=k.queryKey,K=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]],q={default:`Junior default`,saved:`from your profile`,slack:`from Slack`};function J(){try{return Intl.supportedValuesOf(`timeZone`)}catch{return[]}}function Y(){let e=r(k);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:ie,className:`m-0 text-lg font-bold`,title:`Push notifications`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:`Get a notification when Junior replies to a conversation you started here. Slack threads keep using Slack notifications.`}),e.isPending?/* @__PURE__ */ (0,W.jsx)(ae,{}):e.isError?/* @__PURE__ */ (0,W.jsx)(D,{className:`mt-5`,children:`Could not load notification settings. Reload the page to try again.`}):/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(oe,{settings:e.data}),/* @__PURE__ */ (0,W.jsx)(se,{settings:e.data})]})]})}function ae(){return/* @__PURE__ */ (0,W.jsxs)(`div`,{"aria-label":`Loading notification settings`,className:`mt-5 grid gap-3`,role:`status`,children:[/* @__PURE__ */ (0,W.jsx)(v,{className:`h-10 w-48`}),/* @__PURE__ */ (0,W.jsx)(v,{className:`h-24 w-full`})]})}function oe({settings:e}){let i=n(),a=(0,U.useMemo)(()=>E(),[]),c=r({enabled:a===`supported`,queryKey:L,queryFn:async()=>(await z())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,U.useEffect)(()=>{l&&ee()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(G,e),d=t({mutationFn:e=>j(i,e)}),f=t({mutationFn:async()=>{let e=await R();return e?await m(s,`${P}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:L})}}),p=t({mutationFn:B});if(!e.publicKey)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`Push notifications are not set up for this Junior install. Ask a Junior admin to add Web Push keys.`});if(a===`needs-install`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`On iPhone and iPad, add Junior to your Home Screen first. Tap Share, then Add to Home Screen. Open Junior from the Home Screen and come back to this page.`});if(a===`unsupported`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`This browser cannot receive notifications.`});let h=typeof Notification<`u`&&Notification.permission===`denied`,g=!!c.data,_=e.publicKey;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:g?/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:f.isPending,onClick:()=>f.mutate(),type:`button`,children:f.isPending?`Turning off…`:`Turn off on this device`}),/* @__PURE__ */ (0,W.jsx)(o,{disabled:p.isPending,onClick:()=>p.mutate(),type:`button`,children:p.isPending?`Sending…`:`Send a test`})]}):/* @__PURE__ */ (0,W.jsx)(o,{disabled:d.isPending||c.isPending||h,onClick:()=>d.mutate(_),type:`button`,variant:`primary`,children:d.isPending?`Turning on…`:`Turn on for this device`})}),/* @__PURE__ */ (0,W.jsxs)(`p`,{className:`mt-3 mb-0 text-sm text-dashboard-text-muted`,children:[e.deviceCount===1?`1 device gets your notifications.`:`${e.deviceCount} devices get your notifications.`,h?` This browser blocks notifications from Junior. Allow them in the browser settings.`:``]}),p.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-emerald-300`,children:p.data.delivered>0?`Test sent.`:`No device got the test. Turn notifications off and on again.`}):null,d.isError||f.isError||p.isError?/* @__PURE__ */ (0,W.jsx)(D,{className:`mt-2`,children:`Could not change notifications on this device. Try again.`}):null]})}function se({settings:e}){let r=n(),[i,a]=(0,U.useState)(e.schedule);(0,U.useEffect)(()=>a(e.schedule),[e.schedule]);let l=(0,U.useMemo)(()=>J(),[]),u=t({mutationFn:e=>h(s,`${P}/schedule`,e),onSuccess:e=>r.setQueryData(G,e)}),d=e=>{a(t=>({...t,...e})),(u.isSuccess||u.isError)&&u.reset()},f=JSON.stringify(i)!==JSON.stringify(e.schedule),p=i.start!==i.end&&(!i.workingHoursOnly||i.days.length>0),m=i.timezone??e.timezone,g=i.followSlack!==!1,_=g&&e.slackPausedNow!==void 0?!e.slackPausedNow:c(i,m,Date.now());function v(e){e.preventDefault(),f&&p&&u.mutate(i)}return/* @__PURE__ */ (0,W.jsxs)(`form`,{className:`mt-6 border-t border-dashboard-border pt-5`,onSubmit:v,children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 text-base font-bold`,children:`Working hours`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(T,{checked:g,onCheckedChange:e=>d({followSlack:e===!0})}),`Follow my Slack notification schedule`]}),g?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.slackPausedNow===void 0?`Junior cannot read your Slack notification schedule, so it uses the hours below.`:`Junior pauses notifications when Slack does. It uses the hours below only when it cannot read Slack.`}):null,/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(T,{checked:i.workingHoursOnly,onCheckedChange:e=>d({workingHoursOnly:e===!0})}),`Only notify me during working hours`]}),/* @__PURE__ */ (0,W.jsxs)(`fieldset`,{className:`m-0 mt-4 border-0 p-0 disabled:opacity-60`,disabled:!i.workingHoursOnly,children:[/* @__PURE__ */ (0,W.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-medium`,children:`Days`}),/* @__PURE__ */ (0,W.jsx)(b,{"aria-label":`Working days`,className:`flex-wrap gap-2`,multiple:!0,onValueChange:e=>d({days:e.map(Number).sort((e,t)=>e-t)}),value:i.days.map(String),children:K.map(([e,t])=>/* @__PURE__ */ (0,W.jsx)(y,{className:`min-h-11 min-w-12 lg:min-h-9`,value:String(e),variant:`pill`,children:t},e))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsxs)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,W.jsxs)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-4 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,W.jsxs)(H,{id:`notification-timezone`,onChange:e=>d({timezone:e.target.value||void 0}),value:i.timezone??``,children:[/* @__PURE__ */ (0,W.jsx)(`option`,{value:``,children:e.timezoneSource===`manual`?`Automatic`:`Automatic: ${e.timezone} (${q[e.timezoneSource]})`}),l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:e},e))]}),/* @__PURE__ */ (0,W.jsx)(A,{children:`Automatic uses your Slack timezone when Junior can read it.`})]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:_?`Notifications are on right now.`:`Notifications are paused right now. Replies still show here.`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f||!p||u.isPending,type:`submit`,children:u.isPending?`Saving…`:`Save hours`}),u.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Hours saved.`}):null,u.isError?/* @__PURE__ */ (0,W.jsx)(D,{children:`Could not save your hours. Try again.`}):null]})]})}const ce=[`dashboard`,`core`],X=[1,6,24,72,168];function le(e){return e===0?`No done conversations to archive.`:e===1?`Archived 1 conversation.`:`Archived ${e} conversations.`}function ue(e){if(e%24!=0)return e===1?`1 hour`:`${e} hours`;let t=e/24;return t===7?`1 week`:t===1?`1 day`:`${t} days`}function de({identity:e}){let r=n(),i=t({mutationFn:e=>f(d,`/api/me`,e),onSuccess:e=>{r.setQueryData(ce,t=>t&&{...t,me:e})}}),a=F(),s=e.autoArchiveDefault??!1,c=e.autoArchiveGraceHours??24,l=X.includes(c)?X:[...X,c].sort((e,t)=>e-t);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`conversations`,className:`m-0 text-lg font-bold`,title:`Conversations`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(T,{checked:s,className:`mt-0.5`,disabled:i.isPending,onCheckedChange:e=>i.mutate({autoArchiveDefault:e})}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-archive conversations when done`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Archive a conversation for everyone when all of its linked work, such as pull requests, is merged or closed and nobody replies during the wait time. You can change this for each conversation in its details.`})]})]}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5 max-w-xs`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`auto-archive-grace`,children:`Wait time`}),/* @__PURE__ */ (0,W.jsx)(H,{"aria-describedby":`auto-archive-grace-help`,disabled:i.isPending,id:`auto-archive-grace`,onChange:e=>i.mutate({autoArchiveGraceHours:Number(e.target.value)}),value:c,children:l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:ue(e)},e))}),/* @__PURE__ */ (0,W.jsx)(A,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,W.jsx)(D,{className:`mt-3`,children:`Could not save this setting. Try again.`}):null,/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 grid gap-1.5`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:a.isPending,onClick:()=>a.mutate(),type:`button`,children:a.isPending?`Archiving…`:`Archive done now`}),a.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,role:`status`,children:le(a.data.archived)}):null,a.isError?/* @__PURE__ */ (0,W.jsx)(D,{children:`Could not archive conversations. Try again.`}):null]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:`Archive every done conversation once, after the same wait time. Skips conversations where you turned auto-archive off.`})]})]})}const fe=[`dashboard`,`core`],Z=[`dashboard`,`user-customization`],Q=`/api/user-customization`;function pe({identity:e}){let r=n(),[i,a]=(0,U.useState)(e.user.name??``);(0,U.useEffect)(()=>{a(e.user.name??``)},[e.user.name]);let s=t({mutationFn:e=>f(d,`/api/me`,{displayName:e}),onSuccess:e=>{r.setQueryData(fe,t=>t&&{...t,me:e}),a(e.user.name??``)}}),c=e.user.name?.trim()??``,l=i.trim(),u=l.length>0&&l.length<=80&&l!==c&&!s.isPending;function p(e){e.preventDefault(),u&&s.mutate(l)}return/* @__PURE__ */ (0,W.jsxs)(re,{description:`Manage your profile and preferences.`,title:`General`,children:[/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:p,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,W.jsx)(M,{autoComplete:`name`,id:`display-name`,maxLength:80,onChange:e=>{a(e.target.value),(s.isError||s.isSuccess)&&s.reset()},value:i}),/* @__PURE__ */ (0,W.jsx)(A,{id:`display-name-help`,children:`Your display name is shown with your conversations and activity.`})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!u,type:`submit`,children:s.isPending?`Saving…`:`Save changes`}),s.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,s.isError?/* @__PURE__ */ (0,W.jsx)(D,{children:`Could not save your display name. Try again.`}):null]})]})}),/* @__PURE__ */ (0,W.jsx)($,{}),/* @__PURE__ */ (0,W.jsx)(he,{}),/* @__PURE__ */ (0,W.jsx)(ge,{}),/* @__PURE__ */ (0,W.jsx)(de,{identity:e}),/* @__PURE__ */ (0,W.jsx)(Y,{}),/* @__PURE__ */ (0,W.jsx)(_e,{})]})}function $(){let[e,t]=ne();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`navigation`,className:`m-0 text-lg font-bold`,title:`Navigation`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(C,{"aria-label":`Navigation`,className:`grid gap-3`,onValueChange:t,value:e,children:te.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(w,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}const me=[{description:`Open at the first new message, below a “New” line.`,label:`Where I left off`,value:`unread`},{description:`Always open at the newest message.`,label:`Latest message`,value:`latest`}];function he(){let[e,t]=I();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`open-conversations-at`,className:`m-0 text-lg font-bold`,title:`Open conversations at`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`Junior keeps your place in each conversation on all your devices. This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(C,{"aria-label":`Open conversations at`,className:`grid gap-3`,onValueChange:t,value:e,children:me.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(w,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}function ge(){let[e,t]=O();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`message-box`,className:`m-0 text-lg font-bold`,title:`Message box`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(T,{checked:e,className:`mt-0.5`,onCheckedChange:t}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Autocorrect`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Let your keyboard correct spelling and capitalize sentences as you type. This can change ids, paths, and code. This choice applies to this browser.`})]})]})]})}function _e(){let e=n(),[i,a]=(0,U.useState)(``),s=r({queryKey:Z,queryFn:({signal:e})=>p(u,Q,e),retry:!1}),c=s.data?.customization;(0,U.useEffect)(()=>{c!==void 0&&a(c)},[c]);let d=t({mutationFn:e=>h(u,Q,{customization:e}),onSuccess:t=>{e.setQueryData(Z,t)}});if(s.error instanceof g&&s.error.status===404)return null;if(c===void 0)return s.isError?/* @__PURE__ */ (0,W.jsx)(D,{children:`Could not load your customization.`}):null;let f=i.trim()!==c&&i.trim().length<=1e3&&!d.isPending;function m(e){e.preventDefault(),f&&d.mutate(i.trim())}return/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:m,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,W.jsx)(S,{id:`user-customization`,maxLength:l,onChange:e=>{a(e.target.value),(d.isError||d.isSuccess)&&d.reset()},placeholder:`Keep replies short and simple.`,value:i}),/* @__PURE__ */ (0,W.jsxs)(A,{children:[`Added to each message you send. Do not put secrets here. (`,i.trim().length,`/`,l,`)`]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f,type:`submit`,children:d.isPending?`Saving…`:`Save customization`}),d.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,d.isError?/* @__PURE__ */ (0,W.jsx)(D,{children:`Could not save your customization. Try again.`}):null]})]})})}export{pe as SettingsPage};