File size: 43,432 Bytes
d705bb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
# Component Documentation โ€” World Monitor

> Auto-generated reference for all UI components in `src/components/`.
> Last updated: 2026-02-19

---

## Table of Contents

1. [Overview](#overview)
2. [Panel Base Class](#panel-base-class)
3. [Map System](#map-system)
   - [DeckGLMap (WebGL / 3D)](#deckglmap)
   - [MapComponent (D3 / SVG)](#mapcomponent)
   - [MapContainer (Adapter)](#mapcontainer)
   - [MapPopup (Popup Builder)](#mappopup)
4. [Virtual Scrolling](#virtual-scrolling)
   - [VirtualList](#virtuallist)
   - [WindowedList\<T\>](#windowedlistt)
5. [Search](#search)
   - [SearchModal](#searchmodal)
6. [Domain Panels](#domain-panels)
   - [Intelligence & Analysis](#intelligence--analysis-panels)
   - [News & Content](#news--content-panels)
   - [Markets & Finance](#markets--finance-panels)
   - [Military & Security](#military--security-panels)
   - [Natural Events & Humanitarian](#natural-events--humanitarian-panels)
   - [Infrastructure & Tech](#infrastructure--tech-panels)
   - [Platform](#platform-panels)
7. [Modals & Widgets](#modals--widgets)
8. [Variant Visibility Matrix](#variant-visibility-matrix)
9. [Component Interaction Diagram](#component-interaction-diagram)

---

## Overview

World Monitor's UI is built entirely with **vanilla TypeScript** โ€” no React, Vue, or
Angular. Every component is a plain ES class that owns its own DOM subtree and
communicates through method calls, callbacks, and a handful of
`document`/`window`-level custom events.

### Design principles

| Principle | Detail |
|---|---|
| **No framework** | Components create and manage DOM imperatively. |
| **Class-based** | Each component is a standalone class (or, rarely, a set of exported functions). |
| **Panel inheritance** | Most dashboard tiles extend the shared `Panel` base class. |
| **Variant-aware** | Components check `SITE_VARIANT` (`world` / `tech` / `finance`) to show/hide themselves or swap data sources. |
| **Theme-aware** | Components listen for `theme-changed` events and adapt colours accordingly. |
| **Desktop-aware** | Tauri bridge detection via `isDesktopRuntime()` unlocks native features. |

### Component count

| Category | Count |
|---|---|
| Panel subclasses | ~35 |
| Map components | 4 (DeckGLMap, MapComponent, MapContainer, MapPopup) |
| Virtual scrolling | 2 (VirtualList, WindowedList) |
| Search | 1 (SearchModal) |
| Modals & widgets | ~9 |
| **Total** | **~51** |

All public exports are re-exported from `src/components/index.ts` (barrel file,
40+ symbols).

---

## Panel Base Class

**File:** `src/components/Panel.ts` (420 lines)

`Panel` is the shared superclass for every dashboard tile. It owns the chrome โ€”
header, collapse/expand, resize handle, loading/error states, count badge,
"NEW" badge, data-quality badge, and tooltip โ€” so that subclasses only need to
fill in `panel-content`.

### Constructor

```ts
interface PanelOptions {
  id: string;           // unique DOM id, also used as localStorage key
  title: string;        // human-readable header text
  showCount?: boolean;  // if true, renders a count badge in the header
  className?: string;   // extra CSS class on the root element
  trackActivity?: boolean; // enable activity tracking
  infoTooltip?: string; // markdown/HTML shown on hover of the โ„น icon
}

const panel = new Panel(options);
```

### Lifecycle & Methods

#### Public

| Method | Signature | Description |
|---|---|---|
| `getElement()` | `(): HTMLElement` | Returns the root `div.panel`. |
| `showLoading()` | `(): void` | Replaces content with a spinner. |
| `showError()` | `(msg: string): void` | Shows a red error banner inside content. |
| `showConfigError()` | `(): void` | Shows a config-missing message (desktop). |
| `setCount()` | `(n: number): void` | Updates the header count badge. |
| `setErrorState()` | `(isError: boolean): void` | Toggles `.panel-error` class. |
| `setContent()` | `(html: string \| HTMLElement): void` | Replaces panel-content innerHTML or child. |
| `show()` | `(): void` | Removes `display:none`. |
| `hide()` | `(): void` | Sets `display:none`. |
| `toggle()` | `(): void` | Toggles between show/hide. |
| `setNewBadge()` | `(): void` | Adds the "NEW" pill next to the title. |
| `clearNewBadge()` | `(): void` | Removes the "NEW" pill. |
| `getId()` | `(): string` | Returns the panel id. |
| `resetHeight()` | `(): void` | Clears any user-set height override. |
| `destroy()` | `(): void` | Removes element, cleans up listeners. |

#### Protected

| Method | Signature | Description |
|---|---|---|
| `setDataBadge(state, detail?)` | `(state: 'live'\|'cached'\|'unavailable', detail?: string): void` | Shows a coloured dot in the header indicating data freshness. |
| `clearDataBadge()` | `(): void` | Hides the data badge. |

### DOM Structure

```
div.panel#${id}                       โ† root
 โ”œโ”€ div.panel-header
 โ”‚   โ”œโ”€ div.panel-header-left
 โ”‚   โ”‚   โ”œโ”€ span.panel-title          โ† title text
 โ”‚   โ”‚   โ”œโ”€ span.panel-info-wrapper   โ† โ„น icon + tooltip
 โ”‚   โ”‚   โ””โ”€ span.panel-new-badge      โ† "NEW" pill (conditional)
 โ”‚   โ”œโ”€ span.panel-data-badge         โ† live/cached/unavailable dot
 โ”‚   โ””โ”€ span.panel-count              โ† count number (conditional)
 โ”œโ”€ div.panel-content                 โ† subclass fills this
 โ””โ”€ div.panel-resize-handle           โ† drag handle for vertical resize
```

### CSS Classes

| Class | Applied to | Meaning |
|---|---|---|
| `.panel` | root | Base panel styling. |
| `.panel-collapsed` | root | Content hidden, header only. |
| `.panel-error` | root | Red border / error state. |
| `.panel-resizing` | root | While user drags resize handle. |
| `.panel-header` | header wrapper | Flex row. |
| `.panel-content` | content area | Overflow auto, flex-grow 1. |
| `.panel-resize-handle` | resize bar | Cursor `ns-resize`. |

### Events

| Event / Listener | Target | Direction |
|---|---|---|
| `click` (document) | tooltip close | Consumed |
| `mousemove` / `mouseup` | resize drag | Consumed |
| `touchstart` / `touchmove` / `touchend` | mobile resize | Consumed |
| `dragstart` | blocked during resize | Consumed |

### Persistence

Panel **span sizes** (user-resized heights) are stored in
`localStorage['worldmonitor-panel-spans']` as a JSON map of `{ [id]: height }`.

### Services

- `escapeHtml` from `sanitize` โ€” XSS-safe title rendering.
- `isDesktopRuntime()` / `invokeTauri()` โ€” Tauri bridge for settings sync.
- `t()` โ€” i18n translation of UI strings.

### Variant Logic

None โ€” `Panel` is a pure base class and renders identically in all variants.

---

## Map System

World Monitor ships two independent map renderers and an adapter that picks the
right one at runtime.

### DeckGLMap

**File:** `src/components/DeckGLMap.ts` (3 853 lines)

The primary, high-performance map used on desktop and WebGL-capable browsers.

#### Constructor

```ts
interface DeckMapState {
  zoom: number;
  pan: [number, number];
  view: DeckMapView;
  layers: MapLayers;
  timeRange: TimeRange;
}

type DeckMapView =
  | 'global' | 'america' | 'mena' | 'eu'
  | 'asia'   | 'latam'   | 'africa' | 'oceania';

const map = new DeckGLMap(container, initialState);
```

#### Exported Types

| Type | Description |
|---|---|
| `TimeRange` | `{ start: number; end: number }` epoch-ms window. |
| `DeckMapView` | 8 named camera presets. |
| `CountryClickPayload` | `{ iso: string; name: string; lngLat: [number, number] }` |
| `MapInteractionMode` | `'flat' \| '3d'` โ€” controlled by `MAP_INTERACTION_MODE` env. |

#### Rendering Stack

Built on **MapLibre GL JS** (`maplibregl.Map`) with a **deck.gl** overlay
(`MapboxOverlay` from `@deck.gl/mapbox`). The following deck.gl layer types
are used:

- `GeoJsonLayer` โ€” country polygons, cables, pipelines, waterways
- `ScatterplotLayer` โ€” point events (earthquakes, fires, outages, bases)
- `PathLayer` โ€” flight tracks, vessel tracks
- `IconLayer` โ€” infrastructure icons, cluster markers
- `TextLayer` โ€” labels
- `ArcLayer` โ€” origin/destination arcs (trade, displacement)
- `HeatmapLayer` โ€” density surfaces (protests, fires)
- `Supercluster` โ€” client-side clustering of dense point data

#### Static Infrastructure Data

The map embeds or lazily loads over 20 static datasets:

| Dataset | Constant / Source |
|---|---|
| Intelligence hotspots | `INTEL_HOTSPOTS` |
| Conflict zones | `CONFLICT_ZONES` |
| Military bases | `MILITARY_BASES` |
| Undersea cables | `UNDERSEA_CABLES` |
| Nuclear facilities | `NUCLEAR_FACILITIES` |
| Gamma irradiators | `GAMMA_IRRADIATORS` |
| Pipelines | `PIPELINES` |
| Strategic waterways | `STRATEGIC_WATERWAYS` |
| Economic centers | `ECONOMIC_CENTERS` |
| AI data centers | `AI_DATA_CENTERS` |
| Startup hubs | `STARTUP_HUBS` |
| Accelerators | `ACCELERATORS` |
| Tech HQs | `TECH_HQS` |
| Cloud regions | `CLOUD_REGIONS` |
| Ports | `PORTS` |
| Spaceports | `SPACEPORTS` |
| APT groups | `APT_GROUPS` |
| Critical minerals | `CRITICAL_MINERALS` |
| Stock exchanges | `STOCK_EXCHANGES` |
| Financial centers | `FINANCIAL_CENTERS` |
| Central banks | `CENTRAL_BANKS` |
| Commodity hubs | `COMMODITY_HUBS` |
| Gulf investments | `GULF_INVESTMENTS` |

#### Services

| Service | Purpose |
|---|---|
| `hotspot-escalation` | Escalation scoring for hotspot markers. |
| `country-instability` | CII heat overlay. |
| `geo-convergence` | Convergence ring rendering. |
| `country-geometry` | GeoJSON boundaries. |
| `MapPopup` | Generates popup HTML for clicked features. |

#### Variant & Theme Logic

- **`SITE_VARIANT`** determines which static infrastructure layers are
  loaded (e.g. `tech` loads `AI_DATA_CENTERS`, `STARTUP_HUBS`,
  `CLOUD_REGIONS`; `finance` loads `STOCK_EXCHANGES`, `FINANCIAL_CENTERS`).
- **`MAP_INTERACTION_MODE`** env var toggles flat (2-D pitch-locked) vs 3-D
  (free pitch/bearing).
- **Theme**: basemap switches between CARTO Dark Matter and CARTO Positron
  via `getOverlayColors()` which provides a colour palette per theme.

---

### MapComponent

**File:** `src/components/Map.ts` (3 500 lines)

Fallback **D3 + SVG** map used on mobile and devices without WebGL.

#### Constructor

```ts
interface MapState {
  zoom: number;
  pan: [number, number];
  view: MapView;
  layers: MapLayers;
  timeRange: TimeRange;
}

const map = new MapComponent(container, initialState);
```

#### DOM Structure

```
div.map-wrapper#mapWrapper
 โ”œโ”€ svg.map-svg#mapSvg            โ† D3 projected countries & overlays
 โ”œโ”€ canvas.map-cluster-canvas#mapClusterCanvas  โ† Canvas 2-D for clusters
 โ””โ”€ div#mapOverlays                โ† Popup container
```

#### Key Data Overlays

| Overlay | Source |
|---|---|
| Hotspots | `hotspot-escalation` |
| Earthquakes | USGS feed |
| Weather alerts | `weather` service |
| Outages | Cloudflare / service-status |
| AIS disruptions | AIS feed |
| Cable advisories | Undersea cable advisories |
| Protests | ACLED |
| Military flights | OpenSky |
| Military vessels | AIS snapshot |
| Natural events | EONET |
| FIRMS fires | NASA FIRMS |
| Tech events | Tech events API |
| Tech activities | GitHub trending, HackerNews |
| Geo activities | Geo-convergence |
| News | Geolocated news clusters |

#### Events Consumed

| Event | Source | Effect |
|---|---|---|
| `theme-changed` | `window` | Re-renders all layers with new colour palette. |

#### Variant Logic

Imports `SITE_VARIANT` and adjusts loaded data layers accordingly. Runs a
health-check interval every **30 seconds**.

---

### MapContainer

**File:** `src/components/MapContainer.ts` (553 lines)

Adapter / faรงade that selects the appropriate map renderer at startup.

#### Constructor

```ts
const mapContainer = new MapContainer(container, initialState);
```

#### Selection Logic

```
if (isMobileDevice() || !hasWebGLSupport())
  โ†’ MapComponent (D3/SVG)
else
  โ†’ DeckGLMap (WebGL/deck.gl)
```

The container element receives the CSS class `deckgl-mode` or `svg-mode`
accordingly.

#### Delegated API

All calls are forwarded transparently to the underlying renderer:

| Method | Description |
|---|---|
| `render()` | Full re-render. |
| `setView(view)` | Switch named camera preset. |
| `setZoom(z)` | Set zoom level. |
| `setCenter(lng, lat)` | Pan to coordinates. |
| `setTimeRange(range)` | Filter displayed events by time. |
| `setLayers(layers)` | Toggle layer visibility. |
| `getState()` | Return current map state. |
| `setEarthquakes(data)` | Push earthquake data. |
| `setWeatherAlerts(data)` | Push weather alerts. |
| `setOutages(data)` | Push outage data. |
| โ€ฆ | (and many more domain-specific setters) |

---

### MapPopup

**File:** `src/components/MapPopup.ts` (2 400+ lines)

**Not a class** โ€” a collection of builder functions that generate popup HTML
for every feature type the map can display.

#### PopupType Union

Over 40 discriminated popup types grouped into categories:

| Category | Types (examples) |
|---|---|
| Conflict | `conflict-event`, `protest`, `acled-event`, `hotspot`, `conflict-zone` |
| Military | `military-base`, `military-flight`, `military-vessel`, `spaceport` |
| Natural | `earthquake`, `weather-alert`, `natural-event`, `firms-fire` |
| Infrastructure | `cable`, `pipeline`, `nuclear`, `port`, `waterway`, `gamma-irradiator` |
| Tech | `datacenter`, `tech-hq`, `cloud-region`, `startup-hub`, `accelerator`, `tech-event` |
| Finance | `stock-exchange`, `financial-center`, `central-bank`, `commodity-hub`, `gulf-investment` |
| Intelligence | `apt-group`, `critical-mineral`, `news-cluster`, `convergence` |

Each popup type has a dedicated data interface and a builder function that
returns sanitized HTML.

---

## Virtual Scrolling

**File:** `src/components/VirtualList.ts`

Two complementary strategies for rendering large lists without creating
thousands of DOM nodes.

### VirtualList

Fixed-height, DOM-recycling virtual scroller.

#### Constructor

```ts
interface VirtualListOptions {
  itemHeight: number;          // px height per row
  overscan?: number;           // extra rows above/below viewport (default 3)
  container: HTMLElement;      // parent element
  renderItem: (index: number, el: HTMLElement) => void;
  onRecycle?: (el: HTMLElement) => void;
}

const vl = new VirtualList(options);
```

#### Methods

| Method | Signature | Description |
|---|---|---|
| `setItemCount()` | `(n: number): void` | Total number of items. |
| `refresh()` | `(): void` | Re-render visible items from current scroll position. |
| `scrollToIndex()` | `(i: number): void` | Programmatic scroll. |
| `getViewport()` | `(): { start: number; end: number }` | Currently visible range. |
| `destroy()` | `(): void` | Cleanup. |

#### DOM Structure

```
div.virtual-viewport
 โ””โ”€ div.virtual-content           โ† total height = itemHeight ร— itemCount
     โ”œโ”€ (spacer top)
     โ”œโ”€ div.virtual-item          โ† pooled, reused via renderItem()
     โ”œโ”€ div.virtual-item
     โ”œโ”€ ...
     โ””โ”€ (spacer bottom)
```

---

### WindowedList\<T\>

Variable-height, chunk-based windowed scroller. Used by `NewsPanel`.

#### Constructor

```ts
interface WindowedListOptions {
  container: HTMLElement;
  chunkSize?: number;       // items per chunk (default 10)
  bufferChunks?: number;    // chunks to keep rendered above/below viewport
}

const wl = new WindowedList<MyItem>(options, renderItem, onRendered?);
```

#### Methods

| Method | Description |
|---|---|
| `setItems(items: T[])` | Replace item array, re-chunk, re-render. |
| `refresh()` | Force re-render of visible chunks. |
| `destroy()` | Cleanup, remove intersection observers. |

#### DOM Structure

```
div.windowed-list
 โ”œโ”€ div.windowed-chunk             โ† IntersectionObserver placeholder
 โ”œโ”€ div.windowed-chunk
 โ””โ”€ ...
```

---

## Search

### SearchModal

**File:** `src/components/SearchModal.ts` (377 lines)

Global search overlay accessible via `Ctrl+K` / `Cmd+K`.

#### Constructor

```ts
const search = new SearchModal(container, {
  placeholder?: string,   // input placeholder text
  hint?: string,          // footer hint text
});
```

#### Methods

| Method | Signature | Description |
|---|---|---|
| `registerSource(type, items)` | `(type: SearchResultType, items: SearchItem[]): void` | Add or replace a searchable dataset. |
| `setOnSelect(callback)` | `(cb: (result: SearchResult) => void): void` | Selection handler. |
| `open()` | `(): void` | Show modal, focus input. |
| `close()` | `(): void` | Hide modal. |
| `isOpen()` | `(): boolean` | Visibility check. |

#### Search Result Types

20+ discriminated types:

```
country | news | hotspot | market | prediction | conflict | base |
pipeline | cable | datacenter | earthquake | outage | nuclear |
techhq | exchange | financial-center | central-bank | commodity-hub |
gulf-investment | apt-group | critical-mineral | ...
```

#### Scoring

| Match kind | Score |
|---|---|
| Prefix match | 2 |
| Substring match | 1 |

Results are further sorted by a **priority tier**:

```
news > prediction > market > earthquake > outage >
conflict > hotspot > country > infrastructure > tech
```

#### Persistence

Recent selections stored in `localStorage['worldmonitor_recent_searches']`
(most recent 10).

#### DOM Structure

```
div.search-overlay
 โ””โ”€ div.search-modal
     โ”œโ”€ div.search-header
     โ”‚   โ”œโ”€ svg (search icon)
     โ”‚   โ”œโ”€ input[type=text]
     โ”‚   โ””โ”€ kbd (Esc)
     โ”œโ”€ div.search-results           โ† rendered matches
     โ””โ”€ div.search-footer            โ† hint text
```

---

## Domain Panels

All domain panels extend `Panel` (ยง2) and fill `.panel-content` with
domain-specific markup.

### Intelligence & Analysis Panels

#### InsightsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/InsightsPanel.ts` |
| **Panel ID** | `insights` |
| **Purpose** | AI-generated analytical insights aggregated from multiple ML pipelines. |
| **Constructor** | `new InsightsPanel()` โ€” no extra args. |
| **Key methods** | `setMilitaryFlights(flights)` |
| **Services** | `mlWorker`, `generateSummary`, `parallelAnalysis`, `signalAggregator`, `focalPointDetector`, `ingestNewsForCII`, `getTheaterPostureSummaries` |
| **Variant** | All |
| **Notes** | Hidden on mobile via CSS media query. |

#### CIIPanel (Country Instability Index)

| Field | Detail |
|---|---|
| **File** | `src/components/CIIPanel.ts` |
| **Panel ID** | `cii` |
| **Purpose** | Renders server-authoritative CII v8 scores for 31 Tier-1 countries from cached risk-score ingestion, with local fallback scoring when forced or no cached data is available. |
| **Key methods** | `setShareStoryHandler()`, `setCountryClickHandler()`, `refresh(forceLocal?)`, `renderFromCached(cached)`, `getScores()` |
| **DOM** | `.cii-list` โ†’ `.cii-country` each with header (emoji flag, name, score, trend arrow, share button), colour bar, sub-score row (U/C/S/I). |
| **Services** | `toCountryScore()`, `calculateCII()` fallback path, `getCSSColor` |
| **Variant** | `full` only |

#### GdeltIntelPanel

| Field | Detail |
|---|---|
| **File** | `src/components/GdeltIntelPanel.ts` |
| **Panel ID** | `gdelt-intel` |
| **Purpose** | Multi-topic intelligence digest from GDELT data. |
| **Key methods** | `refresh()`, `refreshAll()` |
| **Services** | `getIntelTopics`, `fetchTopicIntelligence` |
| **Variant** | `full` only |
| **Notes** | Tab-based UI, per-topic 5-minute cache. |

#### StrategicRiskPanel

| Field | Detail |
|---|---|
| **File** | `src/components/StrategicRiskPanel.ts` |
| **Panel ID** | `strategic-risk` |
| **Purpose** | Composite strategic risk overview with convergence detection. |
| **Key methods** | `refresh()` |
| **Services** | `calculateStrategicRiskOverview`, `getRecentAlerts`, `detectConvergence`, `dataFreshness`, `getLearningProgress`, `fetchCachedRiskScores` |
| **Data badge** | `live` / `cached` / `unavailable` |
| **Variant** | `full` only |

#### StrategicPosturePanel

| Field | Detail |
|---|---|
| **File** | `src/components/StrategicPosturePanel.ts` |
| **Panel ID** | `strategic-posture` |
| **Purpose** | Theater-level military posture assessment. |
| **Services** | `fetchCachedTheaterPosture`, `fetchMilitaryVessels`, `recalcPostureWithVessels` |
| **Variant** | `full` only |
| **Notes** | Multi-stage loading, 5-minute refresh interval. |

#### CascadePanel

| Field | Detail |
|---|---|
| **File** | `src/components/CascadePanel.ts` |
| **Panel ID** | `cascade` |
| **Purpose** | Infrastructure cascade / dependency-graph analysis. |
| **Services** | `buildDependencyGraph`, `calculateCascade`, `getGraphStats`, `clearGraphCache` (from `infrastructure-cascade` service) |
| **Variant** | `full` only |

#### MonitorPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MonitorPanel.ts` (172 lines) |
| **Panel ID** | `monitors` |
| **Purpose** | User-defined keyword monitors that match against news. |
| **Key methods** | `removeMonitor(id)`, `renderResults(news)` |
| **DOM** | Input + add button, `#monitorsList` (`.monitor-tag` pills), `#monitorsResults` |
| **Matching** | Word-boundary regex, max 10 results per keyword. |
| **Variant** | All |

---

### News & Content Panels

#### NewsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/NewsPanel.ts` (593 lines) |
| **Constructor** | `new NewsPanel(id: string, title: string)` |
| **Purpose** | Clustered news feed with velocity scoring and AI summaries. |
| **Scrolling** | `WindowedList<PreparedCluster>` with `chunkSize: 8`. |
| **Services** | `analysisWorker`, `enrichWithVelocityML`, `getClusterAssetContext`, `activityTracker`, `generateSummary`, `translateText`, `getSourcePropagandaRisk` / `getSourceTier` / `getSourceType` |
| **DOM extras** | Deviation indicator, summary container, summarize button. |
| **Variant** | `SITE_VARIANT` used in summary cache key. |

#### LiveNewsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/LiveNewsPanel.ts` (703 lines) |
| **Panel ID** | `live-news` |
| **Purpose** | Embedded YouTube live-stream player with channel switching. |
| **DOM** | YouTube IFrame player, channel switcher bar, mute/live buttons. |
| **Services** | `fetchLiveVideoId`, `isDesktopRuntime`, `getRemoteApiBaseUrl` |
| **Variant channels** | `tech` โ†’ `TECH_LIVE_CHANNELS` (Bloomberg, Yahoo Finance, CNBC, NASA TV). `world` / `full` โ†’ `FULL_LIVE_CHANNELS` (Bloomberg, Sky, Euronews, DW, CNBC, France24, Al Arabiya, Al Jazeera). |
| **Notes** | Idle pause after 5 minutes of inactivity. |

#### PredictionPanel

| Field | Detail |
|---|---|
| **File** | `src/components/PredictionPanel.ts` (62 lines) |
| **Panel ID** | `polymarket` |
| **Purpose** | Polymarket prediction market odds display. |
| **Key methods** | `renderPredictions(data)` |
| **DOM** | `.prediction-item` with question text, volume, yes/no percentage bars. |
| **Variant** | All |

#### LiveWebcamsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/LiveWebcamsPanel.ts` |
| **Panel ID** | `live-webcams` |
| **Purpose** | Grid of live YouTube webcam feeds from global locations. |
| **Data** | Hardcoded `WEBCAM_FEEDS` (YouTube channels). |
| **Variant** | All |
| **Notes** | Region filters, grid/single view toggle, idle pause. |

---

### Markets & Finance Panels

#### MarketPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MarketPanel.ts` (152 lines, shared file) |
| **Panel ID** | `markets` |
| **Purpose** | Stock index overview with sparkline charts. |
| **DOM** | `.market-item` with inline sparkline `<svg>`. |
| **Helper** | `miniSparkline()` โ€” generates a tiny inline SVG polyline. |

#### HeatmapPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MarketPanel.ts` (shared file) |
| **Panel ID** | `heatmap` |
| **Purpose** | Market heatmap grid (sector / index performance). |
| **DOM** | `.heatmap` grid of colour-coded cells. |

#### CommoditiesPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MarketPanel.ts` (shared file) |
| **Panel ID** | `commodities` |
| **Purpose** | Commodity price overview. |
| **DOM** | `.commodities-grid` of price cells. |

#### CryptoPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MarketPanel.ts` (shared file) |
| **Panel ID** | `crypto` |
| **Purpose** | Top crypto assets with sparklines. |
| **DOM** | `.market-item` with inline sparkline `<svg>`. |

#### ETFFlowsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/ETFFlowsPanel.ts` |
| **Panel ID** | `etf-flows` |
| **Purpose** | ETF fund flow data. |
| **Services** | `fetch('/api/etf-flows')` |
| **Refresh** | Auto, every 3 minutes. |
| **Variant** | `finance` / `full` / `tech` |

#### MacroSignalsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/MacroSignalsPanel.ts` |
| **Panel ID** | `macro-signals` |
| **Purpose** | Macro economic signal aggregator with BUY/CASH verdict. |
| **Services** | `fetch('/api/macro-signals')` |
| **DOM** | Sparklines, donut gauge, verdict label. |
| **Refresh** | Auto, every 3 minutes. |
| **Variant** | `finance` / `full` / `tech` |

#### StablecoinPanel

| Field | Detail |
|---|---|
| **File** | `src/components/StablecoinPanel.ts` |
| **Panel ID** | `stablecoins` |
| **Purpose** | Stablecoin peg deviation monitor. |
| **Services** | `fetch('/api/stablecoin-markets')` |
| **DOM** | Peg status badges (pegged / depegging / depegged). |
| **Refresh** | Auto, every 3 minutes. |
| **Variant** | `finance` / `full` / `tech` |

#### InvestmentsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/InvestmentsPanel.ts` |
| **Panel ID** | `gcc-investments` |
| **Constructor** | `new InvestmentsPanel(onInvestmentClick?)` |
| **Purpose** | GCC / Gulf sovereign investment tracker. |
| **Services** | `GULF_INVESTMENTS` config data. |
| **Variant** | `finance` |
| **Notes** | Multi-filter, sortable columns. |

#### EconomicPanel

| Field | Detail |
|---|---|
| **File** | `src/components/EconomicPanel.ts` |
| **Panel ID** | `economic` |
| **Purpose** | Three-tab economic dashboard: indicators (FRED), oil (EIA), spending (USASpending). |
| **Key methods** | `update(data)`, `updateOil(data)`, `updateSpending(data)` |
| **Variant** | All |

---

### Military & Security Panels

#### UcdpEventsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/UcdpEventsPanel.ts` |
| **Panel ID** | `ucdp-events` |
| **Purpose** | Uppsala Conflict Data Program โ€” armed conflict event log. |
| **Key methods** | `setEventClickHandler()`, `setEvents()`, `getEvents()` |
| **DOM** | Three tabs: state-based / non-state / one-sided. Max 50 rows per tab. |
| **Variant** | `full` only |

#### PlaybackControl

| Field | Detail |
|---|---|
| **File** | `src/components/PlaybackControl.ts` (178 lines) |
| **Purpose** | Time-travel slider for historical snapshot playback. |
| **DOM** | `div.playback-control` with toggle, range slider, action buttons (โฎ โ—€ LIVE โ–ถ โญ). |
| **Key methods** | `getElement()`, `onSnapshotChange` callback. |
| **Services** | `getSnapshotTimestamps()`, `getSnapshotAt()` |
| **Notes** | Adds `.playback-mode` class to `<body>` when active. |

---

### Natural Events & Humanitarian Panels

#### ClimateAnomalyPanel

| Field | Detail |
|---|---|
| **File** | `src/components/ClimateAnomalyPanel.ts` |
| **Panel ID** | `climate` |
| **Purpose** | Climate anomaly zones with severity indicators. |
| **Key methods** | `setZoneClickHandler(handler)`, `setAnomalies(anomalies)` |
| **Services** | `getSeverityIcon`, `formatDelta` from climate service. |

#### SatelliteFiresPanel

| Field | Detail |
|---|---|
| **File** | `src/components/SatelliteFiresPanel.ts` |
| **Panel ID** | `satellite-fires` |
| **Purpose** | NASA FIRMS satellite fire detection statistics. |
| **Key methods** | `update(stats, totalCount)` |
| **Variant** | `full` only |

#### PopulationExposurePanel

| Field | Detail |
|---|---|
| **File** | `src/components/PopulationExposurePanel.ts` |
| **Panel ID** | `population-exposure` |
| **Purpose** | Population within impact radius of active events. |
| **Key methods** | `setExposures()` |
| **DOM** | Event type icons (conflict / earthquake / flood / fire). Highlighted row at 1 M+. |

#### DisplacementPanel

| Field | Detail |
|---|---|
| **File** | `src/components/DisplacementPanel.ts` |
| **Panel ID** | `displacement` |
| **Purpose** | UNHCR displacement data โ€” refugee origin / hosting. |
| **Key methods** | `setCountryClickHandler()`, `setData(data)` |
| **Services** | `formatPopulation` from UNHCR service. |
| **DOM** | Two tabs: origins / hosts. |

---

### Infrastructure & Tech Panels

#### TechEventsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/TechEventsPanel.ts` |
| **Constructor** | `new TechEventsPanel(id)` |
| **Purpose** | Tech conferences, earnings calls, product launches. |
| **Services** | `fetch('/api/tech-events')` |
| **DOM** | View mode switcher: upcoming / conferences / earnings / all. |
| **Variant** | `tech` |

#### TechHubsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/TechHubsPanel.ts` |
| **Panel ID** | `tech-hubs` |
| **Purpose** | Top-10 tech hub activity ranking. |
| **Key methods** | `setOnHubClick()`, `setActivities()` |
| **Variant** | `tech` |

#### TechReadinessPanel

| Field | Detail |
|---|---|
| **File** | `src/components/TechReadinessPanel.ts` |
| **Panel ID** | `tech-readiness` |
| **Purpose** | Country technology readiness rankings (World Bank data). |
| **Key methods** | `refresh()` |
| **Services** | `getTechReadinessRankings` from `worldbank` service. |
| **Refresh** | Every 6 hours. Top 25 countries. |
| **Variant** | `tech` |

#### GeoHubsPanel

| Field | Detail |
|---|---|
| **File** | `src/components/GeoHubsPanel.ts` |
| **Panel ID** | `geo-hubs` |
| **Purpose** | Geopolitical hub activity monitor. |
| **Key methods** | `setOnHubClick()`, `setActivities()` |
| **Services** | `GeoHubActivity` type. |
| **Variant** | `full` only |

#### RegulationPanel

| Field | Detail |
|---|---|
| **File** | `src/components/RegulationPanel.ts` |
| **Panel ID** | `regulation` |
| **Purpose** | AI / tech regulation tracker by country and timeline. |
| **DOM** | Four view modes: timeline / deadlines / regulations / countries. |
| **Services** | `AI_REGULATIONS`, `COUNTRY_REGULATION_PROFILES` |
| **Variant** | `tech` |

#### ServiceStatusPanel

| Field | Detail |
|---|---|
| **File** | `src/components/ServiceStatusPanel.ts` |
| **Panel ID** | `service-status` |
| **Purpose** | External service health / availability monitor. |
| **Refresh** | Auto, every 60 seconds. |
| **DOM** | Category filter chips, status rows. |
| **Variant** | `tech` primarily |
| **Notes** | Desktop readiness checks via Tauri bridge. |

---

### Platform Panels

#### StatusPanel

| Field | Detail |
|---|---|
| **File** | `src/components/StatusPanel.ts` (251 lines) |
| **Panel ID** | `status` |
| **Purpose** | Internal feed & API health status dashboard. |
| **Key methods** | `updateFeed(name, status)`, `updateApi(name, status)`, `setFeedDisabled(name)` |
| **DOM** | `div.status-panel-container` with toggle button, sections: `feeds-list`, `apis-list`, `storage-info`. |
| **Variant data** | `tech` โ†’ `TECH_FEEDS` / `TECH_APIS`. `world` / `full` โ†’ `WORLD_FEEDS` / `WORLD_APIS`. |

#### RuntimeConfigPanel

| Field | Detail |
|---|---|
| **File** | `src/components/RuntimeConfigPanel.ts` |
| **Panel ID** | `runtime-config` |
| **Purpose** | Runtime configuration / API-key management panel. |
| **Key methods** | `commitPendingSecrets()`, `hasPendingChanges()`, `verifyPendingSecrets()` |
| **Variant** | All |
| **Notes** | Desktop vs web mode adapts form fields. Tauri bridge for secure secrets storage. |

#### LanguageSelector

| Field | Detail |
|---|---|
| **File** | `src/components/LanguageSelector.ts` |
| **Purpose** | UI language switcher dropdown. |
| **Constructor** | `new LanguageSelector()` |
| **Key methods** | `getElement()` |
| **Services** | `ENABLED_LANGUAGES`, `changeLanguage`, `getCurrentLanguage` |
| **Variant** | All |

---

## Modals & Widgets

Standalone components that are not panels โ€” overlays, banners, badges, and
small UI affordances.

### SignalModal

| Field | Detail |
|---|---|
| **File** | `src/components/SignalModal.ts` (326 lines) |
| **Purpose** | Full-screen modal for correlation signals and unified alerts. |
| **DOM** | `div.signal-modal-overlay` โ†’ header, scrollable content, footer (audio toggle + dismiss). |
| **Methods** | `show(signals)`, `showSignal(signal)`, `showAlert(alert)`, `setLocationClickHandler()`, `hide()` |
| **Audio** | Inline base64-encoded WAV notification sound. |
| **Types** | `CorrelationSignal`, `UnifiedAlert` |

### CountryBriefPage

| Field | Detail |
|---|---|
| **File** | `src/components/CountryBriefPage.ts` |
| **Purpose** | Full-page overlay showing a comprehensive country intelligence brief with nearby infrastructure analysis. |
| **Services** | `getNearbyInfrastructure`, `haversineDistanceKm`, `exportCountryBriefJSON`, `exportCountryBriefCSV` |

### CountryTimeline

| Field | Detail |
|---|---|
| **File** | `src/components/CountryTimeline.ts` |
| **Constructor** | `new CountryTimeline(container)` |
| **Purpose** | D3 SVG timeline of country events across conflict / protest / natural / military lanes. |
| **Methods** | `render(events)` |

### StoryModal

| Field | Detail |
|---|---|
| **File** | `src/components/StoryModal.ts` |
| **Purpose** | Shareable story card generator and viewer. |
| **Exported functions** | `openStoryModal(data)`, `closeStoryModal()` |
| **Share targets** | WhatsApp, X (Twitter), LinkedIn, clipboard copy. |
| **Notes** | Generates PNG image for sharing via canvas rendering. |

### MobileWarningModal

| Field | Detail |
|---|---|
| **File** | `src/components/MobileWarningModal.ts` |
| **Purpose** | First-visit warning on mobile devices about limited functionality. |
| **Static** | `MobileWarningModal.shouldShow()` |
| **Notes** | Dismissible, remembers via `localStorage`. |

### DownloadBanner

| Field | Detail |
|---|---|
| **File** | `src/components/DownloadBanner.ts` |
| **Purpose** | Prompts web users to download the desktop app. |
| **Exported** | `maybeShowDownloadBanner()` |
| **Platform detection** | `macos-arm64`, `macos-x64`, `windows`, `linux` |

### CommunityWidget

| Field | Detail |
|---|---|
| **File** | `src/components/CommunityWidget.ts` |
| **Purpose** | Small floating widget linking to GitHub Discussions. |
| **Exported** | `mountCommunityWidget()` |
| **Notes** | Dismissible via `localStorage`. |

### PizzIntIndicator

| Field | Detail |
|---|---|
| **File** | `src/components/PizzIntIndicator.ts` |
| **Purpose** | DEFCON-style 1โ€“5 threat indicator with expandable detail panel. |
| **DOM** | Toggle button + expandable panel. |
| **Notes** | Links to `pizzint.watch`. |

### IntelligenceGapBadge (IntelligenceFindingsBadge)

| Field | Detail |
|---|---|
| **File** | `src/components/IntelligenceGapBadge.ts` |
| **Purpose** | Header badge + dropdown showing intelligence findings and gaps. |
| **Key methods** | `setOnSignalClick()`, `setOnAlertClick()` |
| **Notes** | Audio notification for new findings. `full` variant only. |

### VerificationChecklist

| Field | Detail |
|---|---|
| **File** | `src/components/VerificationChecklist.ts` |
| **Purpose** | Bellingcat-style open-source verification checklist (8 checks). |
| **Framework** | **Preact** component (`extends Component`) โ€” the only Preact component in the codebase. |
| **Notes** | Verdict scoring based on completed checks. |

---

## Variant Visibility Matrix

| Component | `world` / `full` | `tech` | `finance` |
|---|:---:|:---:|:---:|
| Panel (base) | โœ… | โœ… | โœ… |
| DeckGLMap | โœ… | โœ… | โœ… |
| MapComponent | โœ… | โœ… | โœ… |
| MapContainer | โœ… | โœ… | โœ… |
| MapPopup | โœ… | โœ… | โœ… |
| VirtualList / WindowedList | โœ… | โœ… | โœ… |
| SearchModal | โœ… | โœ… | โœ… |
| NewsPanel | โœ… | โœ… | โœ… |
| LiveNewsPanel | โœ… | โœ… | โ€” |
| PredictionPanel | โœ… | โœ… | โœ… |
| LiveWebcamsPanel | โœ… | โœ… | โœ… |
| MarketPanel | โœ… | โœ… | โœ… |
| HeatmapPanel | โœ… | โœ… | โœ… |
| CommoditiesPanel | โœ… | โœ… | โœ… |
| CryptoPanel | โœ… | โœ… | โœ… |
| ETFFlowsPanel | โœ… | โœ… | โœ… |
| MacroSignalsPanel | โœ… | โœ… | โœ… |
| StablecoinPanel | โœ… | โœ… | โœ… |
| InvestmentsPanel | โ€” | โ€” | โœ… |
| EconomicPanel | โœ… | โœ… | โœ… |
| InsightsPanel | โœ… | โœ… | โœ… |
| CIIPanel | โœ… | โ€” | โ€” |
| GdeltIntelPanel | โœ… | โ€” | โ€” |
| StrategicRiskPanel | โœ… | โ€” | โ€” |
| StrategicPosturePanel | โœ… | โ€” | โ€” |
| CascadePanel | โœ… | โ€” | โ€” |
| MonitorPanel | โœ… | โœ… | โœ… |
| UcdpEventsPanel | โœ… | โ€” | โ€” |
| ClimateAnomalyPanel | โœ… | โœ… | โ€” |
| SatelliteFiresPanel | โœ… | โ€” | โ€” |
| PopulationExposurePanel | โœ… | โœ… | โ€” |
| DisplacementPanel | โœ… | โ€” | โ€” |
| TechEventsPanel | โ€” | โœ… | โ€” |
| TechHubsPanel | โ€” | โœ… | โ€” |
| TechReadinessPanel | โ€” | โœ… | โ€” |
| GeoHubsPanel | โœ… | โ€” | โ€” |
| RegulationPanel | โ€” | โœ… | โ€” |
| ServiceStatusPanel | โ€” | โœ… | โ€” |
| StatusPanel | โœ… | โœ… | โœ… |
| RuntimeConfigPanel | โœ… | โœ… | โœ… |
| LanguageSelector | โœ… | โœ… | โœ… |
| PlaybackControl | โœ… | โœ… | โœ… |
| SignalModal | โœ… | โœ… | โœ… |
| CountryBriefPage | โœ… | โœ… | โ€” |
| CountryTimeline | โœ… | โœ… | โ€” |
| StoryModal | โœ… | โœ… | โœ… |
| MobileWarningModal | โœ… | โœ… | โœ… |
| DownloadBanner | โœ… | โœ… | โœ… |
| CommunityWidget | โœ… | โœ… | โœ… |
| PizzIntIndicator | โœ… | โ€” | โ€” |
| IntelligenceFindingsBadge | โœ… | โ€” | โ€” |
| VerificationChecklist | โœ… | โœ… | โ€” |

---

## Component Interaction Diagram

```mermaid
graph TD
    subgraph App["App.ts (Orchestrator)"]
        APP[App]
    end

    subgraph Maps["Map System"]
        MC[MapContainer]
        DGL[DeckGLMap]
        SVG[MapComponent]
        MP[MapPopup]
        MC -->|desktop/WebGL| DGL
        MC -->|mobile/fallback| SVG
        DGL --> MP
        SVG --> MP
    end

    subgraph Intelligence["Intelligence & Analysis"]
        INS[InsightsPanel]
        CII[CIIPanel]
        GDL[GdeltIntelPanel]
        SRP[StrategicRiskPanel]
        SPP[StrategicPosturePanel]
        CSC[CascadePanel]
        MON[MonitorPanel]
    end

    subgraph News["News & Content"]
        NP[NewsPanel]
        LNP[LiveNewsPanel]
        PP[PredictionPanel]
        LWP[LiveWebcamsPanel]
    end

    subgraph Markets["Markets & Finance"]
        MKT[MarketPanel]
        HMP[HeatmapPanel]
        CMD[CommoditiesPanel]
        CRY[CryptoPanel]
        ETF[ETFFlowsPanel]
        MAC[MacroSignalsPanel]
        STB[StablecoinPanel]
        INV[InvestmentsPanel]
        ECO[EconomicPanel]
    end

    subgraph Military["Military & Security"]
        UCDP[UcdpEventsPanel]
        PBC[PlaybackControl]
    end

    subgraph NatHum["Natural & Humanitarian"]
        CLP[ClimateAnomalyPanel]
        SFP[SatelliteFiresPanel]
        PEP[PopulationExposurePanel]
        DSP[DisplacementPanel]
    end

    subgraph Tech["Infrastructure & Tech"]
        TEP[TechEventsPanel]
        THP[TechHubsPanel]
        TRP[TechReadinessPanel]
        GHP[GeoHubsPanel]
        REG[RegulationPanel]
        SSP[ServiceStatusPanel]
    end

    subgraph Platform["Platform"]
        STP[StatusPanel]
        RCP[RuntimeConfigPanel]
        LNG[LanguageSelector]
    end

    subgraph Modals["Modals & Widgets"]
        SIG[SignalModal]
        CBP[CountryBriefPage]
        CTL[CountryTimeline]
        STM[StoryModal]
        IGB[IntelligenceFindingsBadge]
        PIZ[PizzIntIndicator]
    end

    subgraph Services["Service Layer"]
        HES[hotspot-escalation]
        CIS[country-instability]
        GCS[geo-convergence]
        MLW[mlWorker]
        ACT[activityTracker]
        SAS[signalAggregator]
    end

    subgraph Search["Search"]
        SM[SearchModal]
    end

    APP --> MC
    APP --> SM
    APP --> Intelligence
    APP --> News
    APP --> Markets
    APP --> Military
    APP --> NatHum
    APP --> Tech
    APP --> Platform
    APP --> Modals

    DGL --> HES
    DGL --> CIS
    DGL --> GCS
    SVG --> HES
    SVG --> CIS
    SVG --> GCS

    INS --> MLW
    INS --> SAS
    CII --> CIS
    SRP --> GCS

    NP --> MLW
    NP --> ACT

    SM -.->|registers sources| APP
    SIG -.->|triggered by| SAS
    IGB -.->|triggered by| SAS
```

### Reading the Diagram

- **Solid arrows** (`โ†’`) represent ownership or direct method calls.
- **Dashed arrows** (`-.->`) represent event-driven or callback-based
  connections.
- `App.ts` is the top-level orchestrator that instantiates all panels,
  wires callbacks, and drives the refresh cycle.
- The **Service Layer** is shared โ€” multiple panels and map components call
  the same services.
- `MapContainer` is the single map entry point; it delegates to
  `DeckGLMap` or `MapComponent` based on runtime capability detection.

---

## Appendix: Barrel Exports

`src/components/index.ts` re-exports 40+ symbols:

```ts
// Panels
export { Panel } from './Panel';
export { NewsPanel } from './NewsPanel';
export { LiveNewsPanel } from './LiveNewsPanel';
export { MarketPanel, HeatmapPanel, CommoditiesPanel, CryptoPanel } from './MarketPanel';
export { CIIPanel } from './CIIPanel';
export { MonitorPanel } from './MonitorPanel';
export { PredictionPanel } from './PredictionPanel';
export { StatusPanel } from './StatusPanel';
export { InsightsPanel } from './InsightsPanel';
export { CascadePanel } from './CascadePanel';
export { ClimateAnomalyPanel } from './ClimateAnomalyPanel';
export { EconomicPanel } from './EconomicPanel';
export { ETFFlowsPanel } from './ETFFlowsPanel';
export { GdeltIntelPanel } from './GdeltIntelPanel';
export { GeoHubsPanel } from './GeoHubsPanel';
export { MacroSignalsPanel } from './MacroSignalsPanel';
export { StablecoinPanel } from './StablecoinPanel';
export { InvestmentsPanel } from './InvestmentsPanel';
export { TechEventsPanel } from './TechEventsPanel';
export { TechHubsPanel } from './TechHubsPanel';
export { TechReadinessPanel } from './TechReadinessPanel';
export { UcdpEventsPanel } from './UcdpEventsPanel';
export { DisplacementPanel } from './DisplacementPanel';
export { SatelliteFiresPanel } from './SatelliteFiresPanel';
export { PopulationExposurePanel } from './PopulationExposurePanel';
export { StrategicPosturePanel } from './StrategicPosturePanel';
export { StrategicRiskPanel } from './StrategicRiskPanel';
export { RegulationPanel } from './RegulationPanel';
export { ServiceStatusPanel } from './ServiceStatusPanel';
export { RuntimeConfigPanel } from './RuntimeConfigPanel';
export { LiveWebcamsPanel } from './LiveWebcamsPanel';

// Map system
export { DeckGLMap } from './DeckGLMap';
export { MapComponent } from './Map';
export { MapContainer } from './MapContainer';

// Scrolling
export { VirtualList, WindowedList } from './VirtualList';

// Search
export { SearchModal } from './SearchModal';

// Modals & widgets
export { SignalModal } from './SignalModal';
export { CountryBriefPage } from './CountryBriefPage';
export { CountryTimeline } from './CountryTimeline';
export { PlaybackControl } from './PlaybackControl';
export { LanguageSelector } from './LanguageSelector';
export { VerificationChecklist } from './VerificationChecklist';
// ... and standalone functions
```

> **Note:** The barrel file is the canonical list. If a component is not
> exported here it is either internal or mounted directly by `App.ts`.