Skip to content
543 linesCodeBlameRaw
1import { useEffect, useMemo, useRef, useState } from "react";
2import {
3 isRouteErrorResponse,
4 Link,
5 Links,
6 Meta,
7 Outlet,
8 Scripts,
9 ScrollRestoration,
10 type ShouldRevalidateFunctionArgs,
11 useLocation,
12 useMatches,
13 useRouteError,
14 useRouteLoaderData,
15} from "react-router";
16
17import { type User, awaitsConfirmation, hasAccessIn, sharedWorkspaces } from "@g1t/contracts";
18
19import type { Route } from "./+types/root";
20import appCss from "./app.css?url";
21import displayFont from "@g1t/theme/fonts/bricolage-grotesque-latin.woff2?url";
22import sansFont from "@g1t/theme/fonts/hanken-grotesk-latin.woff2?url";
23import { ButtonLink } from "./components/ui";
24import { AppShell, Progress, type ShellData, useLeaving } from "./components/shell";
25import { SiteFooter } from "./components/footer";
26import { PublicHeader } from "./components/public-header";
27import { SpikeBanner } from "./components/spike-banner";
28import { PolicyNotice } from "./components/policy-notice";
29import { identify } from "./lib/analytics.client";
30import { visitorAsksFirst } from "./lib/analytics-consent";
31import { AnalyticsConsent } from "./components/analytics-consent";
32import { readCookie } from "./lib/mission";
33import { WORKSPACE_COOKIE, workspaceFor } from "./lib/workspace-choice";
34import { PageMain } from "./components/landmark";
35import { NotFound } from "./components/not-found";
36import { frameOf } from "./lib/chrome";
37import { DOCK_COOKIE, SIDEBAR_COOKIE, pinsToShow, sidebarClosed } from "./lib/apps";
38import { savedPins } from "./lib/dock.server";
39import { StandaloneFrame } from "./components/standalone";
40import { billing, chat, identity, inbox, projects, workspaceAgents } from "./lib/services.server";
41import { teamsByAgent } from "./lib/people";
42import { unreadTotals } from "./lib/chat";
43import { countsFor, readableRepos } from "./lib/access.server";
44import { shortCache } from "./lib/cache.server";
45import { getViewer, viewerMiddleware } from "./lib/session.server";
46import { shortcutOf, workspaceProjects } from "./lib/workspace-projects.server";
47import { registrationMode } from "./lib/registration.server";
48import { addresses } from "./lib/addresses.server";
49import { RELOADED_KEY, RELOAD_GIVE_UP_MS, clientNavigated, reloadFixes, reloadedBefore } from "./lib/stale-build";
50import { useNonce } from "./lib/nonce";
51import { isNeedsSignIn } from "./lib/website-token";
52import { setLiveViaToken } from "./lib/live-socket";
53import { LiveNotifications } from "./components/notifications/live-notifications";
54import { THEME_COLOR, THEME_COOKIE, readTheme, themeAttribute, useThemeChoice } from "./lib/theme";
55
56
57export const links: Route.LinksFunction = () => [
58 { rel: "icon", href: "/favicon.ico", sizes: "32x32" },
59 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
60 { rel: "icon", type: "image/png", sizes: "192x192", href: "/icon-192.png" },
61 { rel: "icon", type: "image/png", sizes: "512x512", href: "/icon-512.png" },
62 // Home screens and password managers look for a square, opaque 180px tile;
63 // the "-precomposed" name is served too, for the ones that ask for it.
64 { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
65 // Installable: name, icons and colours for "Add to Home Screen" (public/site.webmanifest;
66 // manifest.webmanifest is the same file, kept for installs that already point at it).
67 { rel: "manifest", href: "/site.webmanifest" },
68 // The text and headline faces are wanted on every page, so they start
69 // loading with the stylesheet; mono waits until something uses it.
70 { rel: "preload", href: sansFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
71 { rel: "preload", href: displayFont, as: "font", type: "font/woff2", crossOrigin: "anonymous" },
72];
73
74export const middleware: Route.MiddlewareFunction[] = [viewerMiddleware];
75
76export async function loader({ context, params, request }: Route.LoaderArgs) {
77 const user = getViewer(context);
78 const cookies = request.headers.get("cookie");
79 const chosen = readCookie(cookies, WORKSPACE_COOKIE);
80 const dock = readCookie(cookies, DOCK_COOKIE);
81 // Whether sign-up takes an invite: the sign-up page says so, and
82 // Settings → Invites offers invites to g1t only then. Cached per isolate.
83 const [shell, mode] = await Promise.all([
84 // An account still confirming its address sees only the pages that
85 // allows (lib/confirm-gate.ts), in the visitor's frame.
86 user && !awaitsConfirmation(user)
87 ? shellFor(user, params, chosen, context).catch((error: unknown) => {
88 // A sidebar that could not be read is no reason to lose the page,
89 // or to draw it as if they were signed out.
90 console.error("root: the sidebar could not be read", error);
91 return bareShell(user, params, chosen);
92 })
93 : visitorShell(params, context),
94 registrationMode(),
95 ]);
96 // The apps this person pinned to their dock here: as their account keeps
97 // them (read with the rest of the shell), else as this device's cookie
98 // remembers them (lib/apps.ts).
99 if (shell.workspace) shell.pins = pinsToShow(shell.pins, dock, shell.workspace.slug);
100 // Where this g1t lives, for clone lines, agent setup and link previews.
101 return {
102 user,
103 shell,
104 // Whether they folded the sidebar away, so the page is drawn that way from the start.
105 sidebarClosed: sidebarClosed(readCookie(cookies, SIDEBAR_COOKIE)),
106 // Their Appearance, so the page is drawn in it from the first byte (lib/theme.ts).
107 theme: readTheme(readCookie(cookies, THEME_COOKIE)),
108 inviteOnly: mode !== "open",
109 addresses: addresses(),
110 // Visitors from where the law asks first are asked before analytics runs.
111 analyticsConsent: visitorAsksFirst(request),
112 };
113}
114
115/**
116 * The sidebar for someone not signed in: nothing of their own, only the
117 * open counts of the project being looked at. One call, and only in a
118 * project; it answers the same for a private project as a missing one.
119 */
120async function visitorShell(params: { owner?: string; repo?: string }, context: Route.LoaderArgs["context"]): Promise<ShellData> {
121 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
122 const counts = path ? await countsFor(context, params) : null;
123 return {
124 workspace: null,
125 repos: [],
126 repo: path && counts?.ok ? { ...path, member: false, issues: counts.value.issues, pulls: counts.value.pulls } : null,
127 limit: null,
128 monthUsageMicros: null,
129 };
130}
131
132/** The sidebar from what the session already says, with no service asked. */
133function bareShell(user: User, params: { owner?: string; repo?: string }, chosen: string | null): ShellData {
134 return {
135 workspace: workspaceFor(user.workspaces ?? [], chosen, params),
136 repos: [],
137 repo: null,
138 limit: null,
139 monthUsageMicros: null,
140 };
141}
142
143/**
144 * The sidebar only changes with the workspace or repository being looked
145 * at, or after something was submitted: not on every page within them.
146 */
147export function shouldRevalidate({
148 currentParams,
149 nextParams,
150 formMethod,
151 defaultShouldRevalidate,
152}: ShouldRevalidateFunctionArgs) {
153 if (formMethod && formMethod !== "GET") return defaultShouldRevalidate;
154 return currentParams.owner !== nextParams.owner || currentParams.repo !== nextParams.repo;
155}
156
157/**
158 * The sidebar: the workspace whose pages or project these are when it is
159 * one of yours, else the one you chose (lib/workspace-choice.ts); its
160 * projects; and the repository being looked at.
161 */
162async function shellFor(
163 user: User,
164 params: { owner?: string; repo?: string },
165 chosen: string | null,
166 context: Route.LoaderArgs["context"],
167): Promise<ShellData> {
168 const memberships = user.workspaces ?? [];
169 const workspace = workspaceFor(memberships, chosen, params);
170 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
171 const now = new Date();
172 const monthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
173 // What the sidebar shows of the workspace changes rarely: kept for a few
174 // seconds per person and workspace, except just after they changed
175 // something (lib/cache.server.ts).
176 const kept = <T,>(what: string, load: () => Promise<T>) =>
177 workspace ? shortCache(`shell:${what}:${user.id}:${workspace.slug}`, SHELL_TTL_MS, load) : Promise.resolve(null);
178 const [listed, counts, status, usage, limit, entitlements, shared, unread, shortcuts, chatUnread, teamAgents, dockPins] = await Promise.all([
179 // Every project, for the palette and the count; the sidebar lists only
180 // the person's pinned and recent ones (lib/pins.ts).
181 workspace ? workspaceProjects(workspace.slug, user) : Promise.resolve(null),
182 path ? countsFor(context, params) : Promise.resolve(null),
183 // Whether billing is on, without reading the account: that asks the
184 // card processor about the workspace's cards, too slow for every page.
185 kept("status", () => billing.status()).catch(() => null),
186 kept(`usage:${monthStart}`, () => billing.usage(workspace!.slug, user, monthStart)).catch(() => null),
187 kept("limit", () => billing.limit(workspace!.slug, user)).catch(() => null),
188 kept("entitlements", () => billing.entitlements(workspace!.slug)).catch(() => null),
189 sharedRepos(user),
190 // The bell's count: one query, never kept, so marking an item shows at once.
191 inbox.counts(user.username).catch(() => null),
192 // Never kept: opening a project moves it up Recent.
193 workspace ? projects.shortcuts(workspace.slug, user).catch(() => null) : Promise.resolve(null),
194 // The rail's Chat badge: never kept, and never waited on for long.
195 workspace ? chatUnreadFor(workspace.slug, user) : Promise.resolve(null),
196 // Home's Recent and the Agents sidebar, on every page: never waited on for long.
197 workspace ? agentsFor(workspace.slug, user) : Promise.resolve(null),
198 // The dock's pins, kept with the account so every device shows the same
199 // dock; never kept here, so a pin shows the moment it is made. Null
200 // falls back to the cookie (lib/dock.server.ts).
201 workspace ? savedPins(user, workspace.slug) : Promise.resolve(null),
202 ]);
203 return {
204 workspace,
205 // Projects are what the sidebar lists: what the workspace builds and runs.
206 repos: listed?.ok ? listed.value.map(shortcutOf) : [],
207 pinned: (shortcuts?.pinned ?? []).map(shortcutOf),
208 recent: (shortcuts?.recent ?? []).map(shortcutOf),
209 repo:
210 path && counts?.ok
211 ? {
212 ...path,
213 // Until the repository's own page says what their role is.
214 member: hasAccessIn(user, path.namespace),
215 issues: counts.value.issues,
216 pulls: counts.value.pulls,
217 }
218 : null,
219 // Where the workspace stands against its usage limit, once billing is on.
220 limit:
221 status?.enabled && limit?.ok
222 ? {
223 exposureMicros: limit.value.exposureMicros,
224 ceilingMicros: limit.value.ceilingMicros,
225 state: limit.value.state,
226 comped: limit.value.trust === "internal",
227 }
228 : null,
229 free: Boolean(status?.free),
230 // A spend spike or a hold pauses new compute: the shell says so on every page.
231 compute:
232 workspace && entitlements && (entitlements.paused || entitlements.spike?.status === "open")
233 ? { paused: entitlements.paused, spike: entitlements.spike ?? null, owner: workspace.role === "owner" }
234 : null,
235 shared,
236 inbox: unread,
237 chat: chatUnread,
238 agents: teamAgents,
239 pins: dockPins ?? undefined,
240 // While g1t is free every charge is zero, so usage is shown at cost.
241 // Usage at price, the one figure every page shows.
242 monthUsageMicros: usage?.ok ? (usage.value.free ? usage.value.usedMicros : (usage.value.priceMicros ?? usage.value.spentMicros)) : null,
243 };
244}
245
246/** Starred and recent conversations Home's sidebar lists. */
247const SHELL_CONVERSATIONS = 8;
248
249/**
250 * What is unread in chat, for the rail, and the starred and latest
251 * conversations, for Home's sidebar; null when chat is slow to answer or
252 * does not.
253 */
254async function chatUnreadFor(slug: string, user: User): Promise<ShellData["chat"]> {
255 const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), CHAT_BADGE_WAIT_MS));
256 const read = chat
257 .sidebar(slug, user)
258 .then((result) => {
259 if (!result.ok) return null;
260 const entries = result.value.entries;
261 const latest = [...entries].sort((a, b) => (b.channel.last_message_at ?? "").localeCompare(a.channel.last_message_at ?? ""));
262 return {
263 ...unreadTotals(entries),
264 starred: entries.filter((e) => e.starred).slice(0, SHELL_CONVERSATIONS),
265 recent: latest.slice(0, SHELL_CONVERSATIONS),
266 };
267 })
268 .catch(() => null);
269 return Promise.race([read, timeout]);
270}
271
272/** The workspace's agents, as the shell lists them; null when the agents service is slow or down. */
273async function agentsFor(slug: string, user: User): Promise<ShellData["agents"]> {
274 const timeout = new Promise<null>((resolve) => setTimeout(() => resolve(null), CHAT_BADGE_WAIT_MS));
275 // The workspace's agents and the person's own personal ones, for "Yours",
276 // with the teams each is on, for the Agents sidebar's groups.
277 const read = Promise.all([workspaceAgents.list(slug, user, { personal: "mine" }), identity.teamAgentIndex(slug).catch(() => null)])
278 .then(([result, index]) => {
279 if (!result.ok) return null;
280 const teams = index ? teamsByAgent(index) : null;
281 return result.value
282 .filter((agent) => !agent.archived_at)
283 .map((agent) => ({
284 id: agent.id,
285 handle: agent.handle,
286 display_name: agent.display_name,
287 avatar: agent.avatar,
288 avatar_seed: agent.avatar_seed,
289 role: agent.role,
290 title: agent.title,
291 status: agent.status,
292 builtin: agent.builtin === true,
293 scope: agent.scope,
294 ...(teams ? { teams: teams[agent.id] ?? [] } : {}),
295 }));
296 })
297 .catch(() => null);
298 return Promise.race([read, timeout]);
299}
300
301/** The longest the rail's Chat badge holds up a page. */
302const CHAT_BADGE_WAIT_MS = 300;
303
304/**
305 * How long the sidebar's workspace answers are kept: as long as someone's
306 * own changes read fresh anyway (lib/perf.ts `PRIMARY_WINDOW_SECONDS`).
307 */
308const SHELL_TTL_MS = 30_000;
309
310/** Most repositories listed under Shared with you. */
311const MAX_SHARED = 20;
312
313/**
314 * Repositories shared with the user in workspaces they do not belong to,
315 * by their grants: only those, never the workspace's other repositories.
316 */
317async function sharedRepos(user: User): Promise<ShellData["shared"]> {
318 const outside = new Set(sharedWorkspaces(user));
319 if (outside.size === 0) return [];
320 const ids = (user.grants ?? []).filter((grant) => outside.has(grant.workspace)).map((grant) => grant.repo_id).slice(0, MAX_SHARED);
321 const found = await readableRepos(ids, user);
322 return found
323 .map((repo) => ({ namespace: repo.namespace, name: repo.name, isPrivate: repo.isPrivate }))
324 .sort((a, b) => `${a.namespace}/${a.name}`.localeCompare(`${b.namespace}/${b.name}`));
325}
326
327/**
328 * The root's data as the browser last had it. When a navigation fails in a
329 * way that takes the root's data with it, the error is still drawn in the
330 * person's own frame, signed in, not the visitor's. Never kept on the
331 * server, where one module serves everyone.
332 */
333let lastRoot: Awaited<ReturnType<typeof loader>> | undefined;
334
335export function Layout({ children }: { children: React.ReactNode }) {
336 const nonce = useNonce();
337 // Undefined when the root loader itself failed.
338 const loaded = useRouteLoaderData<typeof loader>("root");
339 const inBrowser = typeof document !== "undefined";
340 if (loaded && inBrowser) lastRoot = loaded;
341 const root = loaded ?? (inBrowser ? lastRoot : undefined);
342 const user = root?.user;
343 // A page opened with an access token signs its live sockets in with tickets (lib/live-socket.ts).
344 if (inBrowser) setLiveViaToken(Boolean(user?.token?.website));
345 const { pathname, search } = useLocation();
346 // Drawn around the error page too: a 404 keeps the sidebar out of a
347 // project or workspace the viewer cannot see.
348 const error = useRouteError();
349 const missing = isRouteErrorResponse(error) && error.status === 404;
350 // The billing page shows the full banner itself.
351 const paused = root?.shell?.compute && root.shell.workspace && !pathname.endsWith("/-/billing") && (
352 <SpikeBanner
353 compact
354 slug={root.shell.workspace.slug}
355 entitlements={{ paused: root.shell.compute.paused, spike: root.shell.compute.spike }}
356 owner={root.shell.compute.owner}
357 />
358 );
359 // On the few pages an account still confirming its address can open
360 // besides /confirm-email (policies, support, signing in): the way back.
361 const verify = user && awaitsConfirmation(user) && pathname !== "/confirm-email" && (
362 <p
363 role="status"
364 className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-b border-warn/30 bg-warn/10 px-4 py-2 text-sm"
365 >
366 <span>Confirm your email address to start using g1t.</span>
367 <Link to="/confirm-email" className="font-medium underline underline-offset-4">
368 Enter your code
369 </Link>
370 </p>
371 );
372 // A workspace that requires two-factor authentication of someone who
373 // has not turned it on: they keep their place, and cannot use it yet.
374 const held = user?.held && user.held.length > 0 && pathname !== "/settings/two-factor" && <PolicyNotice held={user.held} />;
375 const leaving = useLeaving();
376 // Auto, Light or Dark: as the cookie said when the page was drawn, or as just switched.
377 const theme = useThemeChoice(root?.theme);
378 // Which frame the page is drawn in (lib/chrome.ts): on its own, the app's, or the public one.
379 const frame = frameOf(pathname, {
380 signedIn: user != null && !awaitsConfirmation(user),
381 workspace: (user?.workspaces ?? []).length > 0,
382 });
383 const banner =
384 paused || verify || held ? (
385 <>
386 {paused}
387 {verify}
388 {held}
389 </>
390 ) : null;
391 return (
392 <html lang="en" data-theme={themeAttribute(theme)}>
393 <head>
394 <meta charSet="utf-8" />
395 <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
396 {/* The browser bar matches the page: one colour for a chosen theme, the system's for Auto. */}
397 {theme === "auto" ? (
398 <>
399 <meta name="theme-color" media="(prefers-color-scheme: light)" content={THEME_COLOR.light} />
400 <meta name="theme-color" media="(prefers-color-scheme: dark)" content={THEME_COLOR.dark} />
401 </>
402 ) : (
403 <meta name="theme-color" content={THEME_COLOR[theme]} />
404 )}
405 <meta name="mobile-web-app-capable" content="yes" />
406 <meta name="apple-mobile-web-app-capable" content="yes" />
407 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
408 {/* The stylesheet before everything React Router preloads, so a slow
409 connection paints sooner. */}
410 <link rel="stylesheet" href={appCss} precedence="default" />
411 {root?.analyticsConsent && <meta name="g1t-analytics" content="consent" />}
412 <Meta />
413 <Links nonce={nonce} />
414 </head>
415 <body className="flex min-h-screen flex-col" data-frame={frame === "app" && user && root?.shell ? "app" : frame}>
416 {/* The first stop for the keyboard: past the menus, to the page. */}
417 <a
418 href="#content"
419 className="sr-only rounded-md bg-fg px-3 py-2 text-sm font-medium text-bg focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[70]"
420 >
421 Skip to content
422 </a>
423 {frame === "standalone" ? (
424 <StandaloneFrame>{children}</StandaloneFrame>
425 ) : frame === "app" && user && root?.shell ? (
426 <AppShell user={user} shell={root.shell} missing={missing} banner={banner} sidebarClosed={root.sidebarClosed}>
427 {children}
428 </AppShell>
429 ) : (
430 <>
431 <Progress />
432 <PublicHeader user={user} />
433 {banner}
434 <div id="content" tabIndex={-1} {...leaving} className={`grow outline-none ${leaving.className}`}>
435 {children}
436 </div>
437 <SiteFooter user={user} />
438 </>
439 )}
440 {/* Live notifications for the signed-in: the feed socket, toasts, the tab's count (components/notifications). */}
441 {user && !awaitsConfirmation(user) && (
442 <LiveNotifications workspace={root?.shell?.workspace?.slug ?? null} inbox={root?.shell?.inbox?.unread ?? null} />
443 )}
444 <AnalyticsConsent />
445 <ScrollRestoration nonce={nonce} />
446 <Scripts nonce={nonce} />
447 </body>
448 </html>
449 );
450}
451
452export default function App() {
453 const userId = useRouteLoaderData<typeof loader>("root")?.user?.id ?? null;
454 // Tell analytics who is signed in, once per change; signing out forgets them.
455 const lastUserId = useRef<string | null>(null);
456 useEffect(() => {
457 identify(userId, lastUserId.current);
458 lastUserId.current = userId;
459 }, [userId]);
460 return <Outlet />;
461}
462
463export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
464 const location = useLocation();
465 const matches = useMatches();
466 const href = location.pathname + location.search + location.hash;
467 // A tab left open across a deploy: load the address again as a whole
468 // page, once, rather than show an error the reload fixes. A document load
469 // never reloads, so the server and the hydrating client render the same.
470 const reloadable = reloadFixes({
471 error,
472 status: isRouteErrorResponse(error) ? error.status : undefined,
473 clientNavigation: clientNavigated(location.key),
474 caughtByCatchAll: matches.at(-1)?.id === "routes/not-found",
475 });
476 // Already loaded again once, or the reload never started: show the page.
477 const tried = useMemo(() => reloadable && reloadedBefore(href), [reloadable, href]);
478 const [gaveUp, setGaveUp] = useState<string | null>(null);
479 const reload = reloadable && !tried && gaveUp !== href;
480 useEffect(() => {
481 if (!reload) return;
482 try {
483 sessionStorage.setItem(RELOADED_KEY, href);
484 } catch {
485 // No session storage: reload anyway; a document load never asks again.
486 }
487 window.location.assign(href);
488 const timer = window.setTimeout(() => setGaveUp(href), RELOAD_GIVE_UP_MS);
489 return () => window.clearTimeout(timer);
490 }, [reload, href]);
491 if (reload) {
492 return (
493 <PageMain className="mx-auto max-w-xl px-4 py-32 text-center text-sm text-muted" aria-busy="true">
494 <title>Loading · g1t</title>
495 Loading the latest version of g1t…
496 </PageMain>
497 );
498 }
499
500 let title = "Something went wrong";
501 let details = "An unexpected error occurred. Try again in a moment.";
502 let stack: string | undefined;
503
504 if (isRouteErrorResponse(error)) {
505 // The same page for something private and something missing.
506 if (error.status === 404) {
507 return (
508 <>
509 <title>Not found · g1t</title>
510 <NotFound data={error.data} />
511 </>
512 );
513 }
514 if (typeof error.data === "string" && error.data) {
515 details = error.data;
516 }
517 // A token asked for what needs a real sign-in (lib/website-token.ts).
518 if (isNeedsSignIn(error.data)) {
519 title = "This needs you to sign in";
520 details = error.data.message;
521 }
522 } else if (import.meta.env.DEV && error instanceof Error) {
523 details = error.message;
524 stack = error.stack;
525 }
526
527 return (
528 <PageMain className="mx-auto max-w-xl px-4 py-32 text-center">
529 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
530 <p className="mt-3 text-muted">{details}</p>
531 <div className="mt-8">
532 <ButtonLink to="/" variant="quiet">
533 Back to home
534 </ButtonLink>
535 </div>
536 {stack && (
537 <pre className="mt-8 overflow-x-auto rounded-lg border border-line p-4 text-left text-xs">
538 <code>{stack}</code>
539 </pre>
540 )}
541 </PageMain>
542 );
543}