All files / window.ts

100.00% Branches 9/9
100.00% Lines 663/663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
x1
 
x2
x2
 
x2
x2
x2
 
x2
x2
x9
x9
 
x2
x4
x4
 
x528
 
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x789
 
x263
x789
 
x263
x789
 
x263
x789
 
x263
x789
 
x263
x789
 
x263
 
x263
x263
x265
x265
 
x263
x266
x266
 
x263
 
x263
x263
x264
x264
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x788
x788
 
x263
x265
x265
 
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x264
x264
 
x263
 
x263
 
x263
x263
x263
 
x263
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x265
x266
x266
x266
x265
 
x263
x263
x263
x265
x266
x266
x266
x265
 
x263
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
 
x263
x263
 
x263
x263
 
x263
x263
 
x263
x263
x263
x265
x266
x266
x266
x265
 
x263
x263
x263
x265
x266
x266
x266
x265
 
x263
 
x263
x263
 
x263
x263
 
x263
x263
 
x263
x263
 
x263
x263
 
x263
x263
 
 
 
 
 
x263
x264
x264
 
 
 
 
 
x263
x264
x264
 
 
 
 
 
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
 
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x263
 
x263
 
x263
x263
 
x263
x263
x266
x268
x268
x268
x266
x266
x266
x266
 
x263
x263
x264
x264
x264
x264
x264
 
x263
x263
 
x263
x263
x266
x282
x282
x266
x266
x266
x266
 
x263
x263
x264
x264
x264
x264
x264
 
x263
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x263
 
x263
x263
x263
x263
 
x263
x263
x263
x263
 
x263
 
x263
x263
x263
x264
x264
 
 
 
 
 
 
 
x263
x263
x264
x264
 
x263
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
 
x263
 
x263
x263
 
x263
x263
x263
x264
x264
 
x263
x263
 
x263
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x264
x264
 
x263
x263
x264
x264
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x269
x269
x269
x269
x269
x269
x269
 
x265
x267
x267
 
x263
 
x263
x263
x267
x267
 
x263
x265
x265
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x526
x263
x263
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
 
x263
 
x263
x263
x263
x263
x265
x265
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x265
x265
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
 
x263
x263
x263
 
x263
 
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
x263
x263
x263
 
x263
x263
x263
 
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
 
x263
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
x263
x263
x263
x263
x263
 
x263
x263
 
x263
 
x263
x263
x263
x266
x266
 
x263
x265
x265
 
x263
 
x263
x263
x263
x264
x264
 
x263
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
x263
x264
x264
 
x263
x263
 
 
 
 
 
x263
 
x263
 
x263
 
x263
 
x2
x2
 
x2
x2
x2
x1572
x1572
 
x2
x2
x2
x5
x5
 
x2
x4
x4
x2































































































































































































































































































































































































































































































































































































































































































































































































































































































// Imports
import type { callback, Nullable, Optional } from "@libs/typing"
import { type _BarProp, type _Window, illegal, internal, unimplemented } from "./_.ts"
import { Navigator } from "./navigator.ts"

/** https://developer.mozilla.org/en-US/docs/Web/API/Window */
export class Window extends EventTarget implements _Window {
  // Client =============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator
  get navigator(): Navigator {
    return this.#navigator
  }

  set navigator(_: Navigator) {
    return
  }

  readonly #navigator = new Navigator({ [internal]: true })

  onlanguagechange = null as _Window["onlanguagechange"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/clientInformation
  // Note: alias of navigator
  get clientInformation(): Navigator {
    return this.navigator
  }

  set clientInformation(_: Navigator) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/locationbar
  readonly locationbar = new BarProp({ [internal]: true })

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/menubar
  readonly menubar = new BarProp({ [internal]: true })

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/personalbar
  readonly personalbar = new BarProp({ [internal]: true })

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollbars
  readonly scrollbars = new BarProp({ [internal]: true })

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/statusbar
  readonly statusbar = new BarProp({ [internal]: true })

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/toolbar
  readonly toolbar = new BarProp({ [internal]: true })

  // Document ============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/name
  set name(name: string) {
    this.#name = `${name}`
  }

  get name(): string {
    return this.#name
  }

  #name = ""

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/document
  get document(): Document {
    return unimplemented.getter<"immutable">()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/frameElement
  // Note: forced as multiple windows are not supported
  get frameElement(): Nullable<Element> {
    return null
  }

  set frameElement(_: Nullable<Element>) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/window
  get window(): WindowProxy & typeof globalThis {
    return this as unknown as WindowProxy & typeof globalThis
  }

  set window(_: WindowProxy & typeof globalThis) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/self
  // Note: alias of window
  readonly self = this.window

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/frames
  // Note: alias of window
  readonly frames = this.window

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/parent
  // Note: forced as multiple windows are not supported
  readonly opener = null as Nullable<WindowProxy>

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/length
  // Note: forced as multiple windows are not supported
  readonly length = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/top
  // Note: forced as multiple windows are not supported
  get top(): WindowProxy {
    return this as unknown as WindowProxy
  }

  set top(_: WindowProxy) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/parent
  // Note: forced as multiple windows are not supported
  get parent(): WindowProxy {
    return this as unknown as WindowProxy
  }

  set parent(_: WindowProxy) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements
  // Depends: CustomElementRegistry implementation
  get customElements(): CustomElementRegistry {
    return unimplemented.getter<"immutable">()
  }

  // Focus ==============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/focus
  // Note: N/A as no UI
  focus(): void {
    return
  }

  onfocus = null as _Window["onfocus"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/blur
  // Note: noop
  blur(): void {
    return
  }

  onblur = null as _Window["onblur"] // unimplemented

  // Sizing ==============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight
  // Note: forced as no UI
  readonly innerHeight = 0

  // Note: forced as no UI
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth
  // Note: forced as no UI
  readonly innerWidth = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/outerHeight
  // Note: forced as no UI
  readonly outerHeight = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/outerWidth
  // Note: forced as no UI
  readonly outerWidth = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/mozInnerScreenX
  // Note: forced as no UI
  get mozInnerScreenX(): number {
    return 0
  }

  set mozInnerScreenX(_: number) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/mozInnerScreenY
  // Note: forced as no UI
  get mozInnerScreenY(): number {
    return 0
  }

  set mozInnerScreenY(_: number) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/setResizable
  // Note: noop
  setRezizable() {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/resizeBy
  // Note: N/A as no UI
  resizeBy(_dx: number, _dy: number): void {
    if (arguments.length < 2) {
      throw new TypeError(`At least 2 arguments required, but only ${arguments.length} passed`)
    }
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/resizeTo
  // Note: N/A as no UI
  resizeTo(_x: number, _y: number): void {
    if (arguments.length < 2) {
      throw new TypeError(`At least 2 arguments required, but only ${arguments.length} passed`)
    }
    return
  }

  onresize = null as _Window["onresize"] // unimplemented

  // Positioning ========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/screen
  // Depends: Screen implementation
  get screen(): Screen {
    return unimplemented.getter()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/screenX
  readonly screenX = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/screenY
  readonly screenY = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/screenLeft
  readonly screenLeft = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/screenTop
  readonly screenTop = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/moveBy
  // Note: N/A as no UI
  moveBy(_dx: number, _dy: number): void {
    if (arguments.length < 2) {
      throw new TypeError(`At least 2 arguments required, but only ${arguments.length} passed`)
    }
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/moveTo
  // Note: N/A as no UI
  moveTo(_x: number, _y: number): void {
    if (arguments.length < 2) {
      throw new TypeError(`At least 2 arguments required, but only ${arguments.length} passed`)
    }
    return
  }

  // Scrolling ==========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX
  readonly scrollX = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY
  readonly scrollY = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/pageXOffset
  readonly pageXOffset = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/pageYOffset
  readonly pageYOffset = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollMaxX
  readonly scrollMaxX = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollMaxY
  readonly scrollMaxY = 0

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll
  // Depends: none
  scroll(_options: ScrollToOptions): void
  scroll(_x: number, _y: number): void
  scroll(_xOrOptions: number | ScrollToOptions, _y?: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo
  // Depends: none
  scrollTo(_options: ScrollToOptions): void
  scrollTo(_x: number, _y: number): void
  scrollTo(_xOrOptions: number | ScrollToOptions, _y?: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy
  // Depends: none
  scrollBy(_options: ScrollToOptions): void
  scrollBy(_x: number, _y: number): void
  scrollBy(_xOrOptions: number | ScrollToOptions, _y?: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollByLines
  // Depends: none
  scrollByLines(_lines: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollByPages
  // Depends: none
  scrollByPages(_pages: number): void {
    return unimplemented()
  }

  onscroll = null as _Window["onscroll"] // unimplemented
  onscrollend = null as _Window["onscrollend"] // unimplemented

  // Orientation ========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/orientation
  // Note: forced as no UI
  get orientation(): number {
    return 0
  }

  set orientation(_: number) {
    return
  }

  ondevicemotion = null as _Window["ondevicemotion"] // unimplemented
  ondeviceorientation = null as _Window["ondeviceorientation"] // unimplemented
  onorientationchange = null as _Window["onorientationchange"] // unimplemented
  ondeviceorientationabsolute = null as _Window["ondeviceorientationabsolute"] // unimplemented

  // Scheduling =========================================================================================================

  /** Internal `setTimeout` handle used to keep track on spawned timeouts. */
  #timeouts = new Set<number>()

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout
  setTimeout(handler: TimerHandler, timeout?: number, ...args: unknown[]): number {
    const id = setTimeout(() => {
      const func = typeof handler === "string" ? new Function(handler) : handler
      this.#timeouts.delete(id)
      func(...args)
    }, timeout)
    this.#timeouts.add(id)
    return id
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/clearTimeout
  clearTimeout(id?: number): void {
    if (id) {
      this.#timeouts.delete(id)
    }
    return clearTimeout(id)
  }

  /** Internal `setInterval` handle used to keep track on spawned intervals. */
  #intervals = new Set<number>()

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval
  setInterval(handler: TimerHandler, timeout?: number, ...args: unknown[]): number {
    const id = setInterval(() => {
      const func = typeof handler === "string" ? new Function(handler) : handler
      func(...args)
    }, timeout)
    this.#intervals.add(id)
    return id
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/clearInterval
  clearInterval(id?: number): void {
    if (id) {
      this.#intervals.delete(id)
    }
    return clearInterval(id)
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/queueMicrotask
  // Depends: none
  queueMicrotask(_callback: VoidFunction): void {
    return unimplemented()
  }

  // Rendering ==========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/visualViewport
  // Depends: VisualViewport implementation
  get visualViewport(): VisualViewport {
    return unimplemented.getter()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  // Note: arbitrary set
  readonly devicePixelRatio = 1

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/fullScreen
  // Note: arbitrary set
  get fullScreen(): boolean {
    return false
  }

  set fullScreen(_: boolean) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/fullscreen
  // Depends: none
  requestAnimationFrame(_callback: FrameRequestCallback): number {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame
  // Depends: none
  cancelAnimationFrame(_handle: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame
  // Depends: none
  requestIdleCallback(_callback: callback, _options?: IdleRequestOptions): number {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelIdleCallback
  // Depends: none
  cancelIdleCallback(_handle: number): void {
    return unimplemented()
  }

  // Styling and animations =============================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
  // Depends: CSSStyleDeclaration implementation
  getComputedStyle(_element: Element, _pseudo?: Nullable<string>): CSSStyleDeclaration {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/getMatchedCSSRules
  // Depends: CSSStyleDeclaration implementation
  getDefaultComputedStyle(_element: Element, _pseudo?: Nullable<string>): CSSStyleDeclaration {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
  // Depends: MediaQueryList implementation
  matchMedia(_query: string): MediaQueryList {
    return unimplemented()
  }

  onanimationstart = null as _Window["onanimationstart"] // unimplemented
  onanimationiteration = null as _Window["onanimationiteration"] // unimplemented
  onanimationend = null as _Window["onanimationend"] // unimplemented
  onanimationcancel = null as _Window["onanimationcancel"] // unimplemented

  ontransitionstart = null as _Window["ontransitionstart"] // unimplemented
  ontransitionrun = null as _Window["ontransitionrun"] // unimplemented
  ontransitionend = null as _Window["ontransitionend"] // unimplemented
  ontransitioncancel = null as _Window["ontransitioncancel"] // unimplemented

  onwebkitanimationstart = null as _Window["onwebkitanimationstart"] // unimplemented
  onwebkitanimationiteration = null as _Window["onwebkitanimationiteration"] // unimplemented
  onwebkitanimationend = null as _Window["onwebkitanimationend"] // unimplemented
  onwebkittransitionend = null as _Window["onwebkittransitionend"] // unimplemented

  // Messaging ==========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone
  // deno-lint-ignore no-explicit-any
  structuredClone<T = any>(value: T, options?: StructuredSerializeOptions): T {
    return structuredClone(value, options)
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
  // Depends: none
  // deno-lint-ignore no-explicit-any
  postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void
  // deno-lint-ignore no-explicit-any
  postMessage(message: any, options?: WindowPostMessageOptions): void
  // deno-lint-ignore no-explicit-any
  postMessage(_message: any, _optionsOrTargetOrigin?: string | WindowPostMessageOptions, _transfer?: Transferable[]): void {
    return unimplemented()
  }

  onmessage = null as _Window["onmessage"] // unimplemented
  onmessageerror = null as _Window["onmessageerror"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/reportError
  // deno-lint-ignore no-explicit-any
  reportError(_throwable: any): void {
    return unimplemented()
  }

  onerror = null as _Window["onerror"] // unimplemented
  onrejectionhandled = null as _Window["onrejectionhandled"] // unimplemented
  onunhandledrejection = null as _Window["onunhandledrejection"] // unimplemented

  // Printing ==========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/console
  readonly console = console

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/print
  // Note: N/A as no printer
  print(): void {
    return
  }

  onbeforeprint = null as _Window["onbeforeprint"] // unimplemented
  onafterprint = null as _Window["onafterprint"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/dump
  // Depends: none, should be designed to send data to stdout
  dump(_message?: unknown): void {
    return unimplemented()
  }

  // Crypto utilities =================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext
  // Note: arbitrary set
  get isSecureContext(): boolean {
    return true
  }

  set isSecureContext(_: boolean) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto
  get crypto(): Crypto {
    return crypto
  }

  set crypto(_: Crypto) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/atob
  atob(base64: string): string {
    return atob(base64)
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa
  btoa(string: string): string {
    return btoa(string)
  }

  // Navigation =========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/location
  // Depends: Location implementation (deno implementation cannot be used, and globalThis.location may be undefined)
  get location(): Location {
    return unimplemented.getter()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/origin
  get origin(): string {
    return unimplemented.getter()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/history
  // Depends: History implementation
  get history(): History {
    return unimplemented.getter<"immutable">()
  }

  onpageshow = null as _Window["onpageshow"] // unimplemented
  onpagehide = null as _Window["onpagehide"] // unimplemented
  onpopstate = null as _Window["onpopstate"] // unimplemented
  onhashchange = null as _Window["onhashchange"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
  // Depends: none
  open(_url?: string | URL, _target?: string, _windowFeatures?: string): Nullable<WindowProxy> {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/close
  // Note: this is also used for cleanup
  close(): void {
    this.#timeouts.forEach(clearTimeout)
    this.#intervals.forEach(clearInterval)
    this.#timeouts.clear()
    this.#intervals.clear()
    this.#closed = true
    return
  }

  [Symbol.dispose]() {
    this.close()
  }

  onclose = null as _Window["onclose"] // unimplemented

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/closed
  get closed(): boolean {
    return this.#closed
  }

  set closed(_: boolean) {
    return
  }

  #closed = false

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/stop
  // Depends: none
  stop(): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/crossOriginIsolated
  // Note: arbitrary set
  get crossOriginIsolated(): boolean {
    return false
  }

  set crossOriginIsolated(_: boolean) {
    return
  }

  // deno-lint-ignore no-explicit-any
  onload = null as Nullable<((event: Event) => any)> // unimplemented
  onbeforeunload = null as _Window["onbeforeunload"] // unimplemented
  onunload = null as _Window["onunload"] // unimplemented

  // Storage ============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/caches
  // Depends: CacheStorage implementation
  get caches(): CacheStorage {
    return unimplemented.getter<"immutable">()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/indexedDB
  // Depends: IDBFactory implementation
  get indexedDB(): IDBFactory {
    return unimplemented.getter<"immutable">()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
  // Note: inherited from Deno
  get localStorage(): Storage {
    return localStorage
  }

  set localStorage(_: Storage) {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
  // Note: inherited from Deno
  get sessionStorage(): Storage {
    return sessionStorage
  }

  set sessionStorage(_: Storage) {
    return
  }

  onstorage = null as _Window["onstorage"] // unimplemented

  // Diagogs ============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/alert
  // Note: N/A as no UI
  // deno-lint-ignore no-explicit-any
  alert(_message?: any): void {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm
  // Note: N/A as no UI
  confirm(_message?: string): boolean {
    return false
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
  // Note: N/A as no UI, always returns defaults value
  prompt(_message?: string, defaults?: string): Nullable<string> {
    return defaults ?? null
  }

  // Clipboard ==========================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/clipboard
  // Depends: Selection implementation
  getSelection(): Nullable<Selection> {
    return unimplemented()
  }

  oncopy = null as _Window["oncopy"] // unimplemented
  onpaste = null as _Window["onpaste"] // unimplemented
  oncut = null as _Window["oncut"] // unimplemented

  onselect = null as _Window["onselect"] // unimplemented
  onselectionchange = null as _Window["onselectionchange"] // unimplemented
  onselectstart = null as _Window["onselectstart"] // unimplemented

  // Events =============================================================================================================

  onmousedown = null as _Window["onmousedown"] // unimplemented
  onmouseup = null as _Window["onmouseup"] // unimplemented
  onmousemove = null as _Window["onmousemove"] // unimplemented
  onmouseenter = null as _Window["onmouseenter"] // unimplemented
  onmouseleave = null as _Window["onmouseleave"] // unimplemented
  onmouseover = null as _Window["onmouseover"] // unimplemented
  onmouseout = null as _Window["onmouseout"] // unimplemented

  onpointerdown = null as _Window["onpointerdown"] // unimplemented
  onpointerup = null as _Window["onpointerup"] // unimplemented
  onpointermove = null as _Window["onpointermove"] // unimplemented
  onpointerenter = null as _Window["onpointerenter"] // unimplemented
  onpointerleave = null as _Window["onpointerleave"] // unimplemented
  onpointerover = null as _Window["onpointerover"] // unimplemented
  onpointerout = null as _Window["onpointerout"] // unimplemented
  onpointercancel = null as _Window["onpointercancel"] // unimplemented
  ongotpointercapture = null as _Window["ongotpointercapture"] // unimplemented
  onlostpointercapture = null as _Window["onlostpointercapture"] // unimplemented

  onclick = null as _Window["onclick"] // unimplemented
  ondblclick = null as _Window["ondblclick"] // unimplemented
  onauxclick = null as _Window["onauxclick"] // unimplemented
  oncontextmenu = null as _Window["oncontextmenu"] // unimplemented
  onwheel = null as _Window["onwheel"] // unimplemented

  onkeydown = null as _Window["onkeydown"] // unimplemented
  onkeyup = null as _Window["onkeyup"] // unimplemented
  onkeypress = null as _Window["onkeypress"] // unimplemented

  ondrag = null as _Window["ondrag"] // unimplemented
  ondragstart = null as _Window["ondragstart"] // unimplemented
  ondragend = null as _Window["ondragend"] // unimplemented
  ondragenter = null as _Window["ondragenter"] // unimplemented
  ondragleave = null as _Window["ondragleave"] // unimplemented
  ondragover = null as _Window["ondragover"] // unimplemented
  ondrop = null as _Window["ondrop"] // unimplemented

  oncontextlost = null as _Window["oncontextlost"] // unimplemented
  oncontextrestored = null as _Window["oncontextrestored"] // unimplemented

  onbeforeinput = null as _Window["onbeforeinput"] // unimplemented
  oninput = null as _Window["oninput"] // unimplemented
  onchange = null as _Window["onchange"] // unimplemented
  oninvalid = null as _Window["oninvalid"] // unimplemented
  oncancel = null as _Window["oncancel"] // unimplemented
  onreset = null as _Window["onreset"] // unimplemented
  onsubmit = null as _Window["onsubmit"] // unimplemented
  onformdata = null as _Window["onformdata"] // unimplemented

  onloadeddata = null as _Window["onloadeddata"] // unimplemented
  onloadedmetadata = null as _Window["onloadedmetadata"] // unimplemented
  onloadstart = null as _Window["onloadstart"] // unimplemented
  oncanplay = null as _Window["oncanplay"] // unimplemented
  oncanplaythrough = null as _Window["oncanplaythrough"] // unimplemented
  onplay = null as _Window["onplay"] // unimplemented
  onplaying = null as _Window["onplaying"] // unimplemented
  onseeked = null as _Window["onseeked"] // unimplemented
  onseeking = null as _Window["onseeking"] // unimplemented
  onstalled = null as _Window["onstalled"] // unimplemented
  onwaiting = null as _Window["onwaiting"] // unimplemented
  onsuspend = null as _Window["onsuspend"] // unimplemented
  onpause = null as _Window["onpause"] // unimplemented
  ontimeupdate = null as _Window["ontimeupdate"] // unimplemented
  ondurationchange = null as _Window["ondurationchange"] // unimplemented
  onratechange = null as _Window["onratechange"] // unimplemented
  onvolumechange = null as _Window["onvolumechange"] // unimplemented
  onemptied = null as _Window["onemptied"] // unimplemented
  onended = null as _Window["onended"] // unimplemented

  onprogress = null as _Window["onprogress"] // unimplemented
  onabort = null as _Window["onabort"] // unimplemented
  onbeforetoggle = null as _Window["onbeforetoggle"] // unimplemented
  ontoggle = null as _Window["ontoggle"] // unimplemented
  onslotchange = null as _Window["onslotchange"] // unimplemented
  oncuechange = null as _Window["oncuechange"] // unimplemented
  onsecuritypolicyviolation = null as _Window["onsecuritypolicyviolation"] // unimplemented

  ongamepadconnected = null as _Window["ongamepadconnected"] // unimplemented
  ongamepaddisconnected = null as _Window["ongamepaddisconnected"] // unimplemented

  // Other ==============================================================================================================

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/status
  // Note: string-only
  get status(): string {
    return this.#status
  }

  set status(status: string) {
    this.#status = `${status}`
  }

  #status = ""

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/speechSynthesis
  // Depends: SpeechSynthesis implementation
  get speechSynthesis(): SpeechSynthesis {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/performance
  readonly performance = performance

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/external
  // Depends: External implementation
  get external(): External {
    return unimplemented.getter()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/event
  // Note: forced as undefined as not executed in event context
  readonly event = undefined as Optional<Event>

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/captureEvents
  // Note: noop
  captureEvents(): void {
    return
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/releaseEvents
  // Depends: none
  releaseEvents(_events?: number): void {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/find
  // Depends: none
  find(_string?: string, _caseSensitive?: boolean, _backwards?: boolean, _wrapAround?: boolean, _wholeWord?: boolean, _searchInFrames?: boolean, _showDialog?: boolean): boolean {
    return unimplemented()
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/Window/updateCommands
  // Note: N/A in Deno
  updateCommands() {
    return
  }

  ononline = null as _Window["ononline"] // unimplemented
  onoffline = null as _Window["onoffline"]; // unimplemented

  // Globals ============================================================================================================

  [index: number]: WindowProxy

  readonly fetch = fetch

  readonly createImageBitmap = createImageBitmap

  readonly Deno = Deno

  readonly Location = Location

  readonly Navigator = Navigator
}

/** https://developer.mozilla.org/en-US/docs/Web/API/BarProp */
export class BarProp implements _BarProp {
  constructor(_ = {} as { [internal]?: boolean }) {
    illegal(arguments)
  }

  // https://developer.mozilla.org/en-US/docs/Web/API/BarProp/visible
  // Note: forced as no ui
  get visible(): boolean {
    return false
  }

  set visible(_: boolean) {
    return
  }
}