Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DesktopWindow.test.ts

582 lines22.1 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, describe, it } from "@effect/vitest";
3import * as Effect from "effect/Effect";
4import * as Layer from "effect/Layer";
5import * as Option from "effect/Option";
6import * as Ref from "effect/Ref";
7import * as TestClock from "effect/testing/TestClock";
8​
9import type * as Electron from "electron";
10import { vi } from "vite-plus/test";
11​
12vi.mock("electron", async (importOriginal) => ({
13 ...(await importOriginal<typeof import("electron")>()),
14 session: {
15 fromPartition: vi.fn(() => ({
16 getUserAgent: vi.fn(() => "Mozilla/5.0 Electron/41.5.0 v12/1.2.3"),
17 setPermissionRequestHandler: vi.fn(),
18 setUserAgent: vi.fn(),
19 })),
20 },
21}));
22​
23import * as DesktopAssets from "../app/DesktopAssets.ts";
24import * as DesktopConfig from "../app/DesktopConfig.ts";
25import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
26import * as DesktopState from "../app/DesktopState.ts";
27import * as ElectronMenu from "../electron/ElectronMenu.ts";
28import * as ElectronShell from "../electron/ElectronShell.ts";
29import * as ElectronTheme from "../electron/ElectronTheme.ts";
30import * as ElectronWindow from "../electron/ElectronWindow.ts";
31import { MENU_ACTION_CHANNEL, WINDOW_FULLSCREEN_STATE_CHANNEL } from "../ipc/channels.ts";
32import * as DesktopServerExposure from "../backend/DesktopServerExposure.ts";
33import * as DesktopWindow from "./DesktopWindow.ts";
34import * as PreviewManager from "../preview/Manager.ts";
35​
36const environmentInput = {
37 dirname: "/repo/apps/desktop/dist-electron",
38 homeDirectory: "/Users/alice",
39 platform: "darwin",
40 processArch: "arm64",
41 appVersion: "1.2.3",
42 appPath: "/repo",
43 isPackaged: false,
44 resourcesPath: "/repo/resources",
45 runningUnderArm64Translation: false,
46} satisfies DesktopEnvironment.MakeDesktopEnvironmentInput;
47​
48function makeFakeBrowserWindow() {
49 const windowListeners = new Map<string, (...args: readonly unknown[]) => void>();
50 const webContentsListeners = new Map<string, (...args: readonly unknown[]) => void>();
51 const webContents = {
52 copyImageAt: vi.fn(),
53 getURL: vi.fn(() => "v12-dev://app/"),
54 isLoadingMainFrame: vi.fn(() => false),
55 on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
56 webContentsListeners.set(eventName, listener);
57 }),
58 once: vi.fn(),
59 openDevTools: vi.fn(),
60 reload: vi.fn(),
61 replaceMisspelling: vi.fn(),
62 send: vi.fn(),
63 setWindowOpenHandler: vi.fn(),
64 };
65​
66 const window = {
67 close: vi.fn(),
68 focus: vi.fn(),
69 isDestroyed: vi.fn(() => false),
70 isFullScreen: vi.fn(() => false),
71 isMinimized: vi.fn(() => false),
72 isVisible: vi.fn(() => true),
73 loadURL: vi.fn(() => Promise.resolve()),
74 on: vi.fn((eventName: string, listener: (...args: readonly unknown[]) => void) => {
75 windowListeners.set(eventName, listener);
76 }),
77 once: vi.fn(),
78 restore: vi.fn(),
79 setBackgroundColor: vi.fn(),
80 setAutoHideCursor: vi.fn(),
81 setTitle: vi.fn(),
82 setTitleBarOverlay: vi.fn(),
83 show: vi.fn(),
84 webContents,
85 };
86​
87 return {
88 window: window as unknown as Electron.BrowserWindow,
89 loadURL: window.loadURL,
90 openDevTools: webContents.openDevTools,
91 reload: webContents.reload,
92 send: webContents.send,
93 setAutoHideCursor: window.setAutoHideCursor,
94 webContentsListeners,
95 windowListeners,
96 };
98​
99const desktopAssetsLayer = Layer.succeed(DesktopAssets.DesktopAssets, {
100 iconPaths: Effect.succeed({
101 ico: Option.none<string>(),
102 icns: Option.none<string>(),
103 png: Option.none<string>(),
104 }),
105 resolveResourcePath: () => Effect.succeed(Option.none<string>()),
106} satisfies DesktopAssets.DesktopAssets["Service"]);
107​
108const desktopServerExposureLayer = Layer.succeed(DesktopServerExposure.DesktopServerExposure, {
109 getState: Effect.die("unexpected getState"),
110 backendConfig: Effect.succeed({
111 port: 3773,
112 bindHost: "127.0.0.1",
113 httpBaseUrl: new URL("http://127.0.0.1:3773"),
114 tailscaleServeEnabled: false,
115 tailscaleServePort: 443,
116 }),
117 configureFromSettings: () => Effect.die("unexpected configureFromSettings"),
118 setMode: () => Effect.die("unexpected setMode"),
119 setTailscaleServeEnabled: () => Effect.die("unexpected setTailscaleServeEnabled"),
120 getAdvertisedEndpoints: Effect.die("unexpected getAdvertisedEndpoints"),
121} satisfies DesktopServerExposure.DesktopServerExposure["Service"]);
122​
123const electronMenuLayer = Layer.succeed(ElectronMenu.ElectronMenu, {
124 setApplicationMenu: () => Effect.void,
125 popupTemplate: () => Effect.void,
126 showContextMenu: () => Effect.succeed(Option.none()),
127} satisfies ElectronMenu.ElectronMenu["Service"]);
128​
129const electronThemeLayer = Layer.succeed(ElectronTheme.ElectronTheme, {
130 shouldUseDarkColors: Effect.succeed(false),
131 setSource: () => Effect.void,
132 onUpdated: () => Effect.void,
133} satisfies ElectronTheme.ElectronTheme["Service"]);
134​
135const desktopEnvironmentLayer = DesktopEnvironment.layer(environmentInput).pipe(
136 Layer.provide(
137 Layer.mergeAll(
138 NodeServices.layer,
139 DesktopConfig.layerTest({
140 V12_PORT: "3773",
141 VITE_DEV_SERVER_URL: "http://127.0.0.1:5733",
142 }),
143 ),
144 ),
145);
146​
147function makeTestLayer(input: {
148 readonly window: Electron.BrowserWindow;
149 readonly createCount: Ref.Ref<number>;
150 readonly mainWindow: Ref.Ref<Option.Option<Electron.BrowserWindow>>;
151 readonly createdWindowOptions?: Electron.BrowserWindowConstructorOptions[];
152 readonly openedExternalUrls?: unknown[];
153}) {
154 const electronWindowLayer = Layer.succeed(ElectronWindow.ElectronWindow, {
155 create: (options) =>
156 Effect.sync(() => {
157 input.createdWindowOptions?.push(options);
158 }).pipe(
159 Effect.andThen(Ref.update(input.createCount, (count) => count + 1)),
160 Effect.as(input.window),
161 ),
162 main: Ref.get(input.mainWindow),
163 currentMainOrFirst: Ref.get(input.mainWindow),
164 focusedMainOrFirst: Ref.get(input.mainWindow),
165 setMain: (window) => Ref.set(input.mainWindow, Option.some(window)),
166 clearMain: () => Ref.set(input.mainWindow, Option.none()),
167 reveal: () => Effect.void,
168 sendAll: () => Effect.void,
169 destroyAll: Effect.void,
170 syncAllAppearance: (sync) => sync(input.window),
171 } satisfies ElectronWindow.ElectronWindow["Service"]);
172​
173 return DesktopWindow.layer.pipe(
174 Layer.provide(
175 Layer.mergeAll(
176 desktopAssetsLayer,
177 desktopEnvironmentLayer,
178 desktopServerExposureLayer,
179 DesktopState.layer,
180 electronMenuLayer,
181 Layer.succeed(ElectronShell.ElectronShell, {
182 openExternal: (url) =>
183 Effect.sync(() => {
184 input.openedExternalUrls?.push(url);
185 return true;
186 }),
187 copyText: () => Effect.void,
188 } satisfies ElectronShell.ElectronShell["Service"]),
189 electronThemeLayer,
190 electronWindowLayer,
191 Layer.mock(PreviewManager.PreviewManager)({
192 getBrowserSession: () => Effect.succeed({} as Electron.Session),
193 setMainWindow: () => Effect.void,
194 isBrowserPartition: (partition) => partition.startsWith("persist:v12-preview-"),
195 getBrowserPartition: () => Effect.succeed("persist:v12-preview-test"),
196 }),
197 ),
198 ),
199 );
201​
202// Builds a DesktopWindow over a fake ElectronWindow whose `create` returns the
203// given outcomes in order (null => simulated open failure), and whose
204// currentMainOrFirst mirrors the real fallback to the first live window (the
205// splash, before any main is registered). Reveal targets are recorded so tests
206// can assert what activation actually surfaced.
207const makeSplashScenario = (createOutcomes: readonly (Electron.BrowserWindow | null)[]) =>
208 Effect.gen(function* () {
209 const createdWindows = yield* Ref.make<Electron.BrowserWindow[]>([]);
210 const createCalls = yield* Ref.make(0);
211 const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
212 const revealedWindows = yield* Ref.make<Electron.BrowserWindow[]>([]);
213 const fallbackWindow = createOutcomes.find(
214 (window): window is Electron.BrowserWindow => window !== null,
215 );
216​
217 const currentMainOrFirst = Effect.gen(function* () {
218 const registered = yield* Ref.get(mainWindow);
219 if (Option.isSome(registered)) {
220 return registered;
221 }
222 const created = yield* Ref.get(createdWindows);
223 return Option.fromNullishOr(created[0] ?? null);
224 });
225​
226 const electronWindowShape = {
227 create: () =>
228 Effect.gen(function* () {
229 const index = yield* Ref.getAndUpdate(createCalls, (count) => count + 1);
230 const outcome = createOutcomes[index] ?? null;
231 if (outcome === null) {
232 return yield* new ElectronWindow.ElectronWindowCreateError({
233 options: {
234 title: null,
235 width: null,
236 height: null,
237 minWidth: null,
238 minHeight: null,
239 show: null,
240 modal: null,
241 frame: null,
242 transparent: null,
243 backgroundColor: null,
244 webPreferences: {
245 preload: null,
246 partition: null,
247 sandbox: null,
248 contextIsolation: null,
249 nodeIntegration: null,
250 webviewTag: null,
251 },
252 },
253 cause: new Error("simulated window-open failure"),
254 });
255 }
256 yield* Ref.update(createdWindows, (windows) => [...windows, outcome]);
257 return outcome;
258 }),
259 main: Ref.get(mainWindow),
260 currentMainOrFirst,
261 focusedMainOrFirst: currentMainOrFirst,
262 setMain: (window) => Ref.set(mainWindow, Option.some(window)),
263 clearMain: () => Ref.set(mainWindow, Option.none()),
264 reveal: (window) => Ref.update(revealedWindows, (windows) => [...windows, window]),
265 sendAll: () => Effect.void,
266 destroyAll: Effect.void,
267 syncAllAppearance: (sync) => (fallbackWindow ? sync(fallbackWindow) : Effect.void),
268 } satisfies ElectronWindow.ElectronWindow["Service"];
269​
270 const layer = DesktopWindow.layer.pipe(
271 Layer.provide(
272 Layer.mergeAll(
273 desktopAssetsLayer,
274 desktopEnvironmentLayer,
275 desktopServerExposureLayer,
276 electronMenuLayer,
277 Layer.succeed(ElectronShell.ElectronShell, {
278 openExternal: () => Effect.succeed(true),
279 copyText: () => Effect.void,
280 } satisfies ElectronShell.ElectronShell["Service"]),
281 electronThemeLayer,
282 Layer.succeed(ElectronWindow.ElectronWindow, electronWindowShape),
283 Layer.mock(PreviewManager.PreviewManager)({
284 getBrowserSession: () => Effect.succeed({} as Electron.Session),
285 setMainWindow: () => Effect.void,
286 isBrowserPartition: (partition) => partition.startsWith("persist:v12-preview-"),
287 getBrowserPartition: () => Effect.succeed("persist:v12-preview-test"),
288 }),
289 ),
290 ),
291 );
292​
293 return { layer, createCalls, mainWindow, revealedWindows } as const;
294 });
295​
296describe("DesktopWindow", () => {
297 it("recognizes only same-origin renderer navigations", () => {
298 assert.isTrue(
299 DesktopWindow.isSameOriginRendererNavigation({
300 applicationUrl: "v12://app/",
301 navigationUrl: "v12://app/settings/connections",
302 }),
303 );
304 assert.isFalse(
305 DesktopWindow.isSameOriginRendererNavigation({
306 applicationUrl: "v12://app/",
307 navigationUrl: "https://accounts.microsoft.com/oauth",
308 }),
309 );
310 assert.isFalse(
311 DesktopWindow.isSameOriginRendererNavigation({
312 applicationUrl: "v12://app/",
313 navigationUrl: "not a url",
314 }),
315 );
316 });
317​
318 it.effect("does not open a development window until the backend is ready", () =>
319 Effect.gen(function* () {
320 const fakeWindow = makeFakeBrowserWindow();
321 const createCount = yield* Ref.make(0);
322 const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
323 const createdWindowOptions: Electron.BrowserWindowConstructorOptions[] = [];
324 const layer = makeTestLayer({
325 window: fakeWindow.window,
326 createCount,
327 mainWindow,
328 createdWindowOptions,
329 });
330​
331 yield* Effect.gen(function* () {
332 const desktopWindow = yield* DesktopWindow.DesktopWindow;
333 yield* desktopWindow.activate;
334 assert.equal(yield* Ref.get(createCount), 0);
335​
336 yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
337 assert.equal(yield* Ref.get(createCount), 1);
338 assert.isTrue(createdWindowOptions[0]?.disableAutoHideCursor);
339 assert.deepEqual(fakeWindow.setAutoHideCursor.mock.calls, [[false]]);
340 assert.deepEqual(fakeWindow.loadURL.mock.calls[0], ["v12-dev://app/"]);
341 assert.equal(fakeWindow.openDevTools.mock.calls.length, 1);
342 }).pipe(Effect.provide(layer));
343 }),
344 );
345​
346 it.effect("publishes native macOS fullscreen changes to the renderer", () =>
347 Effect.gen(function* () {
348 const fakeWindow = makeFakeBrowserWindow();
349 const createCount = yield* Ref.make(0);
350 const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
351 const layer = makeTestLayer({
352 window: fakeWindow.window,
353 createCount,
354 mainWindow,
355 });
356​
357 yield* Effect.gen(function* () {
358 const desktopWindow = yield* DesktopWindow.DesktopWindow;
359 yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
360​
361 const enterFullscreen = fakeWindow.windowListeners.get("enter-full-screen");
362 const leaveFullscreen = fakeWindow.windowListeners.get("leave-full-screen");
363 if (!enterFullscreen || !leaveFullscreen) {
364 return yield* Effect.die("fullscreen listeners were not registered");
365 }
366​
367 enterFullscreen();
368 leaveFullscreen();
369 assert.deepEqual(fakeWindow.send.mock.calls, [
370 [WINDOW_FULLSCREEN_STATE_CHANNEL, true],
371 [WINDOW_FULLSCREEN_STATE_CHANNEL, false],
372 ]);
373 }).pipe(Effect.provide(layer));
374 }),
375 );
376​
377 it.effect("recovers when the development renderer is temporarily unreachable", () =>
378 Effect.gen(function* () {
379 const fakeWindow = makeFakeBrowserWindow();
380 const createCount = yield* Ref.make(0);
381 const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
382 const layer = makeTestLayer({
383 window: fakeWindow.window,
384 createCount,
385 mainWindow,
386 });
387​
388 yield* Effect.gen(function* () {
389 const desktopWindow = yield* DesktopWindow.DesktopWindow;
390 yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
391​
392 const didFailLoad = fakeWindow.webContentsListeners.get("did-fail-load");
393 const didFinishLoad = fakeWindow.webContentsListeners.get("did-finish-load");
394 if (!didFailLoad || !didFinishLoad) {
395 return yield* Effect.die("renderer load listeners were not registered");
396 }
397​
398 didFailLoad({}, -9, "ERR_UNEXPECTED", "v12-dev://app/", true);
399 assert.equal(fakeWindow.loadURL.mock.calls.length, 1);
400​
401 yield* TestClock.adjust(100);
402 assert.deepEqual(fakeWindow.loadURL.mock.calls, [["v12-dev://app/"], ["v12-dev://app/"]]);
403 assert.equal(fakeWindow.reload.mock.calls.length, 0);
404​
405 didFailLoad({}, -9, "ERR_UNEXPECTED", "v12-dev://app/", true);
406 didFinishLoad();
407 yield* TestClock.adjust(250);
408 assert.equal(fakeWindow.loadURL.mock.calls.length, 2);
409 assert.equal(fakeWindow.reload.mock.calls.length, 0);
410 }).pipe(Effect.provide(layer));
411 }),
412 );
413​
414 it("retries only transient failures for the development renderer", () => {
415 assert.isTrue(
416 DesktopWindow.isRetryableDevelopmentRendererLoadFailure({
417 applicationUrl: "v12-dev://app/",
418 errorCode: -102,
419 isMainFrame: true,
420 validatedUrl: "v12-dev://app/",
421 }),
422 );
423 assert.isFalse(
424 DesktopWindow.isRetryableDevelopmentRendererLoadFailure({
425 applicationUrl: "v12-dev://app/",
426 errorCode: -3,
427 isMainFrame: true,
428 validatedUrl: "v12-dev://app/",
429 }),
430 );
431 assert.isFalse(
432 DesktopWindow.isRetryableDevelopmentRendererLoadFailure({
433 applicationUrl: "v12-dev://app/",
434 errorCode: -102,
435 isMainFrame: true,
436 validatedUrl: "https://example.com/",
437 }),
438 );
439 });
440​
441 it.effect("opens safe off-origin renderer navigations in the system browser", () =>
442 Effect.gen(function* () {
443 const fakeWindow = makeFakeBrowserWindow();
444 const createCount = yield* Ref.make(0);
445 const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
446 const openedExternalUrls: unknown[] = [];
447 const layer = makeTestLayer({
448 window: fakeWindow.window,
449 createCount,
450 mainWindow,
451 openedExternalUrls,
452 });
453​
454 yield* Effect.gen(function* () {
455 const desktopWindow = yield* DesktopWindow.DesktopWindow;
456 yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
457​
458 const willNavigate = fakeWindow.webContentsListeners.get("will-navigate");
459 if (!willNavigate) {
460 return yield* Effect.die("will-navigate listener was not registered");
461 }
462 let prevented = false;
463 willNavigate(
464 {
465 preventDefault: () => {
466 prevented = true;
467 },
468 },
469 "https://accounts.microsoft.com/oauth",
470 );
471 yield* Effect.promise(() => Promise.resolve());
472​
473 assert.isTrue(prevented);
474 assert.deepEqual(openedExternalUrls, ["https://accounts.microsoft.com/oauth"]);
475 }).pipe(Effect.provide(layer));
476 }),
477 );
478​
479 it.effect(
480 "retries opening the real main on activate when a failed post-readiness open left only the splash",
481 () =>
482 Effect.gen(function* () {
483 const splash = makeFakeBrowserWindow();
484 const main = makeFakeBrowserWindow();
485 // create #1 -> splash, #2 -> fails (the pool swallows this post-readiness
486 // window-open error), #3 -> the real main on activate's retry.
487 const scenario = yield* makeSplashScenario([splash.window, null, main.window]);
488​
489 yield* Effect.gen(function* () {
490 const desktopWindow = yield* DesktopWindow.DesktopWindow;
491​
492 // 1. WSL-only boot shows the connecting splash.
493 yield* desktopWindow.showConnectingSplash;
494 assert.equal(yield* Ref.get(scenario.createCalls), 1);
495​
496 // 2. Backend reports ready, but opening the real main fails. The pool
497 // swallows that error in production, so handleBackendReady fails
498 // here without a registered main window -- only the splash is open.
499 const readyExit = yield* Effect.exit(
500 desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773")),
501 );
502 assert.equal(readyExit._tag, "Failure");
503 assert.equal(yield* Ref.get(scenario.createCalls), 2);
504 assert.isTrue(Option.isNone(yield* Ref.get(scenario.mainWindow)));
505​
506 // 3. Activating must not mistake the splash for the main window: it
507 // retries the open and brings up the real main instead of leaving
508 // the user stranded on "Connecting to WSL".
509 yield* desktopWindow.activate;
510 assert.equal(yield* Ref.get(scenario.createCalls), 3);
511 const registeredMain = yield* Ref.get(scenario.mainWindow);
512 assert.isTrue(Option.isSome(registeredMain));
513 assert.equal(Option.getOrThrow(registeredMain), main.window);
514 }).pipe(Effect.provide(scenario.layer));
515 }),
516 );
517​
518 it.effect(
519 "re-reveals the connecting splash on activate while the backend is still cold-booting",
520 () =>
521 Effect.gen(function* () {
522 const splash = makeFakeBrowserWindow();
523 // Only the splash is ever created; the backend never reports ready.
524 const scenario = yield* makeSplashScenario([splash.window]);
525​
526 yield* Effect.gen(function* () {
527 const desktopWindow = yield* DesktopWindow.DesktopWindow;
528​
529 yield* desktopWindow.showConnectingSplash;
530 assert.equal(yield* Ref.get(scenario.createCalls), 1);
531​
532 // Taskbar/dock activation during cold boot must bring the splash back
533 // rather than no-op and leave it hidden until the backend finishes.
534 yield* desktopWindow.activate;
535 assert.equal(yield* Ref.get(scenario.createCalls), 1);
536 assert.deepEqual(yield* Ref.get(scenario.revealedWindows), [splash.window]);
537 }).pipe(Effect.provide(scenario.layer));
538 }),
539 );
540​
541 it.effect("does not dispatch menu actions to the splash before the backend is ready", () =>
542 Effect.gen(function* () {
543 const splash = makeFakeBrowserWindow();
544 const main = makeFakeBrowserWindow();
545 const scenario = yield* makeSplashScenario([splash.window, main.window]);
546​
547 yield* Effect.gen(function* () {
548 const desktopWindow = yield* DesktopWindow.DesktopWindow;
549​
550 yield* desktopWindow.showConnectingSplash;
551 yield* desktopWindow.dispatchMenuAction("open-settings");
552​
553 assert.equal(yield* Ref.get(scenario.createCalls), 1);
554 assert.equal(splash.send.mock.calls.length, 0);
555 assert.equal(main.send.mock.calls.length, 0);
556 }).pipe(Effect.provide(scenario.layer));
557 }),
558 );
559​
560 it.effect("dispatches menu actions after backend readiness when no main window exists", () =>
561 Effect.gen(function* () {
562 const splash = makeFakeBrowserWindow();
563 const main = makeFakeBrowserWindow();
564 const scenario = yield* makeSplashScenario([splash.window, null, main.window]);
565​
566 yield* Effect.gen(function* () {
567 const desktopWindow = yield* DesktopWindow.DesktopWindow;
568​
569 yield* desktopWindow.showConnectingSplash;
570 const readyExit = yield* Effect.exit(
571 desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773")),
572 );
573 assert.equal(readyExit._tag, "Failure");
574​
575 yield* desktopWindow.dispatchMenuAction("open-settings");
576​
577 assert.equal(yield* Ref.get(scenario.createCalls), 3);
578 assert.deepEqual(main.send.mock.calls, [[MENU_ACTION_CHANNEL, "open-settings"]]);
579 }).pipe(Effect.provide(scenario.layer));
580 }),
581 );
582});