/* Atlas Mission Control POC — all telemetry and operators are fictional. */
const groups = [
{ id: 'alpha', name: 'ALPHA', count: 12, task: 'Area Search', operator: 'Alex', progress: 82, health: 'nominal', color: 'cyan', icon: 'A', current: 'Search area north', next: 'Return', lease: 'Alex' },
{ id: 'bravo', name: 'BRAVO', count: 10, task: 'Route Recon', operator: 'Sara', progress: 71, health: 'nominal', color: 'blue', icon: 'B', current: 'Coastal route', next: 'Survey pass', lease: 'Sara' },
{ id: 'charlie', name: 'CHARLIE', count: 8, task: 'Relay', operator: 'David', progress: 64, health: 'nominal', color: 'violet', icon: 'C', current: 'Relay station', next: 'Hold', lease: 'David' },
{ id: 'delta', name: 'DELTA', count: 12, task: 'Reserve', operator: 'Maria', progress: 35, health: 'attention', color: 'amber', icon: 'D', current: 'Ready reserve', next: 'Awaiting task', lease: 'Maria' },
{ id: 'reserve', name: 'RESERVE', count: 8, task: 'Available', operator: 'Ken', progress: 100, health: 'nominal', color: 'violet', icon: 'R', current: 'Base service', next: 'Available', lease: 'Ken' }
];
const operators = [
{ id: 'alex', name: 'Alex', role: 'Commanding Alpha', color: 'cyan', activity: 'selected Alpha' },
{ id: 'sara', name: 'Sara', role: 'Commanding Bravo', color: 'green', activity: 'updated Bravo search area' },
{ id: 'david', name: 'David', role: 'Planning', color: 'amber', activity: 'drafted Task-144' },
{ id: 'maria', name: 'Maria', role: 'Monitoring', color: 'violet', activity: 'added monitoring note' },
{ id: 'ken', name: 'Ken', role: 'Engineering', color: 'yellow', activity: 'updated comms plan' }
];
const alphaVehicles = [
['UAV-01', 18, 32, 92], ['UAV-02', 25, 39, 86], ['UAV-03', 33, 28, 43],
['UAV-04', 39, 44, 80], ['UAV-05', 45, 35, 74], ['UAV-06', 53, 45, 88],
['UAV-07', 60, 30, 74], ['UAV-08', 66, 42, 83], ['UAV-09', 72, 35, 79],
['UAV-10', 76, 51, 90], ['UAV-11', 55, 57, 82], ['UAV-12', 34, 57, 76]
].map((item, index) => ({ id: item[0], x: item[1], y: item[2], energy: item[3], heading: 20 + index * 16, status: item[0] === 'UAV-03' ? 'critical' : 'nominal' }));
const availableVehicles = [
['ALP-01', 18, 50, 92], ['ALP-02', 31, 47, 71], ['ALP-03', 17, 35, 82], ['ALP-04', 72, 42, 65],
['ALP-05', 71, 55, 80], ['ALP-06', 64, 69, 74], ['ALP-07', 35, 18, 78], ['ALP-08', 38, 72, 61]
].map(item => ({ id: item[0], x: item[1], y: item[2], energy: item[3], heading: 30, status: 'nominal' }));
const requestedView = new URLSearchParams(window.location.search).get('view');
const validViews = ['overview', 'zoom', 'selection', 'collaboration', 'recovery', 'queue', 'system'];
let state = {
view: validViews.includes(requestedView) ? requestedView : 'overview',
selectedGroup: 'alpha',
selectedVehicle: 'UAV-07',
selectedCandidate: 'UAV-19',
modal: null,
toast: '',
layersOpen: false,
reassigned: false,
queueDraft: false,
queue: [
{ title: 'Transit', detail: 'to Northern Sector', duration: '8 min', status: 'completed' },
{ title: 'Search Area A', detail: 'coverage pattern', duration: '18 min', status: 'current' },
{ title: 'Loiter', detail: '6 min', duration: '6 min', status: 'queued' },
{ title: 'Return', detail: 'staging point', duration: '12 min', status: 'queued' },
{ title: 'Recharge', detail: 'base service', duration: '35 min', status: 'queued' },
{ title: 'Search Area B', detail: 'coverage pattern', duration: '20 min', status: 'queued' }
]
};
const icons = {
menu: ' ',
map: ' ',
layers: ' ',
plane: ' ',
people: ' ',
task: ' ',
alert: ' ',
shield: ' ',
chevron: ' ',
plus: ' ',
close: ' ',
target: ' ',
transfer: ' ',
hold: ' ',
move: ' ',
clock: ' ',
check: ' ',
search: ' ',
info: ' ',
bolt: ' ',
route: ' ',
settings: ' '
};
function icon(name, extra = '') {
return '';
}
function groupById(id) {
return groups.find(group => group.id === id) || groups[0];
}
function statusTag(status, label) {
const text = label || ({ nominal: 'Nominal', attention: 'Attention', critical: 'Critical', planned: 'Planned' }[status] || status);
return ' ' + text + ' ';
}
function button(label, action, options = {}) {
const cls = 'button ' + (options.kind || 'secondary') + (options.iconOnly ? ' icon-button' : '') + (options.className ? ' ' + options.className : '');
const attrs = (options.disabled ? ' disabled' : '') + (options.label ? ' aria-label="' + options.label + '"' : '') + (options.value ? ' data-value="' + options.value + '"' : '');
return '' + (options.icon ? icon(options.icon) : '') + (options.iconOnly ? '' : '' + label + ' ') + ' ';
}
function navItem(id, label, iconName) {
return '' + icon(iconName) + '' + label + ' ';
}
function topBar() {
return '';
}
function mapBase() {
return '' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'North Point Cliffside Seabridge West Cove ' +
'
2 km
';
}
function mapControls() {
return '' + button('', 'toggle-layers', { icon: 'layers', iconOnly: true, label: 'Toggle map layers' }) + button('', 'map-zoom-in', { icon: 'plus', iconOnly: true, label: 'Zoom map in' }) + button('−', 'map-zoom-out', { iconOnly: true, label: 'Zoom map out' }) + '
' +
(state.layersOpen ? 'Map layers Search areas Planned routes Constraints Map labels
' : '');
}
function taskArea(label = 'ALPHA\nSEARCH AREA', classes = '') {
return '
' + label.replace('\n', ' ') + ' ';
}
function groupMarker(group, x, y, active = false) {
return '' +
'' + group.icon + ' ' + group.name + ' ' + group.count + ' UAV · ' + group.task + ' · ' + group.progress + '% ';
}
function vehicleMarker(vehicle, selected = false, label = false) {
const critical = vehicle.status === 'critical';
return '' +
icon('plane') + (label ? '' + vehicle.id + ' ' : '') + ' ';
}
function routeLine(className = '') {
return ' ';
}
function overviewMap() {
const g = groupById(state.selectedGroup);
return '' + mapBase() + mapControls() + routeLine() + taskArea(g.name + '\nAREA ' + (g.task === 'Area Search' ? 'SEARCH' : g.task.toUpperCase()), 'alpha-area') +
'
' +
alphaVehicles.map(vehicle => vehicleMarker(vehicle, false, vehicle.id === 'UAV-03')).join('') +
groupMarker(groups[1], 65, 27) + groupMarker(groups[2], 69, 50) + groupMarker(groups[3], 73, 68) + groupMarker(groups[4], 57, 82) +
'
' +
'
Exceptions (3) ' + icon('alert') + ' UAV-27 · Navigation degraded
' + icon('info') + ' Alpha task behind schedule
Review recovery ' +
'
';
}
function groupRail(compact = false) {
return 'Groups ' + button('', 'new-group', { icon: 'plus', iconOnly: true, label: 'Create a new group' }) + '
' +
'' + groups.map(group => {
const selected = state.selectedGroup === group.id;
return '' +
'' + group.icon + ' ' + group.name + ' ' + group.count + ' UAV ' + group.task + ' ' + group.operator + ' ' +
'' + statusTag(group.health, '') + '' + group.progress + '% ' + Array(9).fill(' ').join('') + ' ';
}).join('') + '
' + button('New group', 'new-group', { icon: 'plus', className: 'full-width' }) + ' ';
}
function attentionRail() {
return 'Attention ' + button('', 'view-alerts', { icon: 'alert', iconOnly: true, label: 'View all alerts' }) + '
' +
'' + icon('alert') + 'UAV-27 Navigation degraded Since 01:32:11 ALPHA ' +
'' + icon('clock') + 'Alpha task behind schedule ETA impact +00:08:45 ALPHA ' +
'' + icon('alert') + 'Bravo approaching constraint R-210B coastal limit BRAVO ' +
'' + icon('check') + '
47 vehicles nominal No action required
' +
' ';
}
function contextBar() {
const group = groupById(state.selectedGroup);
return '' + group.icon + '
' + group.name + ' ' + group.count + ' vehicles
Task ' + group.task + '
Progress ' + group.progress + '% complete
Operator ' + group.operator + '
Status ' + statusTag(group.health) + '
Current ' + group.current + '
Next ' + group.next + ' ' +
'' + button('Task', 'open-preview', { icon: 'task' }) + button('Move', 'move-group', { icon: 'move' }) + button('Hold', 'hold-group', { icon: 'hold' }) + button('Group', 'group-vehicles', { icon: 'people' }) + button('Split', 'split-group', { icon: 'route' }) + button('Transfer', 'open-transfer', { icon: 'transfer' }) + button('Details', 'open-vehicle-detail', { icon: 'info' }) + '
';
}
function overviewView() {
return '' + groupRail() + '' + attentionRail() + contextBar() + ' ';
}
function zoomSmallMap(kind) {
if (kind === 'strategic') {
return '' + mapBase() + taskArea('TASK 143', 'small-task violet') + groupMarker(groups[0], 35, 33, true) + groupMarker(groups[1], 20, 57) + groupMarker(groups[2], 38, 75) + groupMarker(groups[3], 68, 61) + '
' + groups.map(g => '' + g.name + ' ').join('') + '
';
}
if (kind === 'operational') {
return '' + mapBase() + taskArea('AREA SEARCH\n82%', 'wide alpha-area') + routeLine() + alphaVehicles.map(v => vehicleMarker(v)).join('') + '
Area search 82% Alex
';
}
return '' + mapBase() + taskArea('', 'wide alpha-area muted') + routeLine() + alphaVehicles.map(v => vehicleMarker(v, v.id === 'UAV-07')).join('') + '
UAV-07 ' + button('', 'close-inspector', { icon: 'close', iconOnly: true, label: 'Close vehicle inspector' }) + '
ALPHA GROUP
Position 34.72245° N 18.28512° W
Heading 128°
Energy 74%
Navigation Nominal
Communication Good
Payload Imaging Current task Search Area North
Next action Sweep 4
';
}
function zoomFooter(kind) {
const content = kind === 'strategic' ? 'Groups and task intent High-level view of mission groups and task areas.
' : kind === 'operational' ? 'Group composition and coverage Coordinated group view with coverage progress.
' : 'Vehicle details on request Progressive disclosure for a selected vehicle.
';
return '';
}
function zoomView() {
return 'Semantic zoom — shared multi-UAV mission planner Seamless transition from strategic intent to operational control to individual vehicle detail.
' + statusTag('blue', 'Active') + statusTag('cyan', 'Selected') + statusTag('nominal', 'Nominal') + statusTag('attention', 'Attention') + statusTag('planned', 'Planned') + '
' +
'A Strategic ' + button('', 'zoom-strategic', { icon: 'target', iconOnly: true, label: 'View strategic detail' }) + ' ' + zoomSmallMap('strategic') + zoomFooter('strategic') + ' ' +
'B Operational — Alpha ' + button('', 'zoom-operational', { icon: 'target', iconOnly: true, label: 'View operational detail' }) + ' ' + zoomSmallMap('operational') + zoomFooter('operational') + ' ' +
'C Vehicle — UAV-07 ' + button('', 'zoom-vehicle', { icon: 'target', iconOnly: true, label: 'View vehicle detail' }) + ' ' + zoomSmallMap('vehicle') + zoomFooter('vehicle') + ' ' +
' ';
}
function filterChip(label, value) {
return '' + label + ' ' + value + ' ' + icon('close') + '
';
}
function selectionMap() {
return '' + mapBase() + '
' + taskArea('TASK-143\nAREA SEARCH', 'violet') + '
' + routeLine('selection-routes') + availableVehicles.map(v => vehicleMarker(v, true, true)).join('') + '
TASK-143 Area search
Priority High
Assigned Alpha / 4
Area Northern sector
Progress 63%
Required 4 UAV
Health Green ' + icon('clock') + ' Estimated completion 18 min ' + mapControls() + '
';
}
function smartSelectionView() {
return 'Smart selection ' + button('', 'show-filter-help', { icon: 'info', iconOnly: true, label: 'Selection help' }) + 'Natural language query ' + icon('search') + '
Available ISR aircraft within 20 km of Task Bravo with more than 60% energy.
Structured filters Clear all
' + filterChip('Type', 'ISR') + filterChip('Availability', 'Available') + filterChip('Distance', '< 20 km') + filterChip('Energy', '> 60%') + filterChip('Task', 'None') + '
Results 8 vehicles selected Filter distribution
Type (ISR) 32
Availability 12
Distance 9
Energy 8 ' + button('Assign task', 'open-preview', { icon: 'task', kind: 'primary', className: 'full-width' }) + 'Last updated: 14:32:10 UTC ' + assignPanel() + ' ';
}
function validationRow(label, value, stateName = 'ok') {
return '' + icon(stateName === 'warning' ? 'alert' : stateName === 'info' ? 'info' : 'check') + '' + label + ' ' + value + ' ' + (stateName === 'ok' ? '' + icon('check') + ' ' : '') + '
';
}
function assignPanel() {
return 'Assign task 6 vehicles selected
' + button('', 'close-assign', { icon: 'close', iconOnly: true, label: 'Close assignment panel' }) + '
Task TASK-143 / AREA SEARCH
Area Northern sector Validation summary ' + validationRow('Estimated completion', '18 min') + validationRow('Energy reserve', 'All above minimum') + validationRow('Route conflicts', 'None detected') + validationRow('Constraint conflicts', 'None detected') + validationRow('Vehicle compatibility', '6 / 6 compatible') + validationRow('Communication link', 'All links good') + validationRow('Assignment considerations', '1 aircraft may require reassignment.', 'warning') + '
' + icon('info') + '
Review the preview to confirm routing, timing, and resource allocation before assigning.
' + button('Cancel', 'cancel-modal') + button('Preview', 'open-preview', { kind: 'secondary' }) + button('Confirm', 'confirm-assignment', { icon: 'check', kind: 'primary' }) + ' ';
}
function collabMap() {
return '' + mapBase() + '
' + taskArea('ALPHA\n3 UAV · 1 USV', 'alpha-area') + alphaVehicles.slice(0, 3).map(v => vehicleMarker(v)).join('') + '
' +
groupMarker(groups[1], 32, 23) + groupMarker(groups[2], 73, 23) + groupMarker(groups[3], 73, 53) + groupMarker(groups[4], 60, 75) +
operators.map((op, i) => '
◢ ' + op.name + ' ').join('') +
'
Command authority Alex lease expires 02:34
Observers ' + statusTag('nominal', 'Sara') + statusTag('amber', 'David') + '
' +
'
';
}
function collaborationView() {
return '' + groupRail(true) + '' + operators.map(op => '' + op.name + ' ' + op.role + ' ⌄ ').join('') + '
Collaboration stream View all ' + operators.slice().reverse().map((op, i) => '
' + op.activity + ' ' + (i * 2 + 2) + 'm ago
').join('') + '
Mission events 14:30:41Z Alex selected Alpha 14:28:15Z David drafted Task-144 14:26:32Z Sara updated Bravo search area 14:24:10Z Maria added monitoring note
Shared awareness · authority changes are explicit and auditable.
';
}
function recoveryMap() {
return '' + mapBase() + taskArea('ALPHA\nSEARCH AREA', 'alpha-area') + routeLine() + alphaVehicles.slice(0, 4).map(v => vehicleMarker(v, false, true)).join('') + '
! UAV-03 Unavailable ' + icon('people') + 'Alpha Search Search and locate pattern
' + (state.reassigned ? '4 / 4' : '3 / 4') + 'assigned ';
}
function candidateCard(id, energy, distance, compatibility, selected) {
return '' + icon('people') + '' + id + ' ' + statusTag('nominal', 'Ready') + ' ' + (selected ? '' + icon('check') + ' ' : '') + '
Energy ' + energy + '% ' + statusTag('nominal', '') + '
Distance to task ' + distance + ' km
Task compatibility ' + compatibility + '
Communication Strong ' + (selected ? '' : '') + ' ';
}
function recoveryView() {
const active = state.selectedCandidate;
return '' + icon('shield') + ' Keep TASK-143 on plan Current state
Task Alpha Search
Required 4 vehicles
Current ' + (state.reassigned ? '4 / 4' : '3 / 4') + 'assigned
Completion impact ' + (state.reassigned ? 'None' : '+11 minutes') + ' Recommended replacements ' + icon('info') + ' Select a vehicle to review. This is a system recommendation for operator approval.
' + candidateCard('UAV-19', 78, 6.2, 'High', active === 'UAV-19') + candidateCard('UAV-27', 64, 9.8, 'High', active === 'UAV-27') + candidateCard('UAV-31', 82, 12.4, 'Medium', active === 'UAV-31') + '
' + icon('info') + ' Recommended because it can join before coverage gap exceeds threshold.
Local preview of reassignment ' + icon('plane') + ' ' + active + ' ALPHA SEARCH AREA
' + button('Cancel', 'cancel-modal') + button('Compare candidates', 'compare-candidates') + button(state.reassigned ? 'Recommendation accepted' : 'Accept recommendation', 'accept-replacement', { icon: 'shield', kind: 'primary', disabled: state.reassigned }) + ' ' + icon('alert') + ' 14:33:02 system detected UAV-03 unavailable ' + icon('shield') + ' 14:33:04 system evaluated replacement options ' + icon('info') + ' 14:33:17 operator reviewing recommendation ';
}
function queueMap() {
return '' + mapBase() + routeLine() + '
⌾Base Service
' + taskArea('Search Area A', 'queue-search') + taskArea('Search Area B', 'queue-search future') + '
A ALPHA 12
A Alpha ' + icon('people') + '12 vehicles
' + icon('search') + 'Search
' + icon('people') + 'Operator Alex
' + statusTag('nominal') + ' ';
}
function queueStep(step, index) {
return '⠿ ' + (index + 1) + ' ' + step.title + ' ' + step.detail + '
' + (step.status === 'current' ? '
82% complete ' : '') + '
Alex ' + step.duration + ' ' + statusTag(step.status === 'completed' ? 'nominal' : step.status === 'current' ? 'blue' : 'planned', step.status) + '' + button('', 'queue-up', { icon: 'chevron', iconOnly: true, label: 'Move step up', value: index }) + button('', 'queue-down', { icon: 'chevron', iconOnly: true, label: 'Move step down', value: index }) + '
';
}
function queueView() {
const current = state.queue[1];
return 'Alpha · Intent queue' + statusTag('planned', 'Draft changes') + button('', 'queue-menu', { icon: 'settings', iconOnly: true, label: 'Queue options' }) + '
' + state.queue.map(queueStep).join('') + '
⠿ Drop step here to reorder
Step 2 of 6 ' + button('', 'close-inspector', { icon: 'close', iconOnly: true, label: 'Close step inspector' }) + 'Goal Search Area A with coverage pattern to identify objects of interest.
Owner ' + icon('people') + ' Alex
Resources ' + icon('people') + ' 12 vehicles
Est. duration ' + icon('clock') + ' 18 min
Expected finish ⚑ 14:53 (local)
Linked task ⛓ TASK-143
Local plan status ' + statusTag('nominal', 'Plan valid') + '' + button('Add step', 'add-step', { icon: 'plus' }) + button('Reorder', 'reorder-queue', { icon: 'transfer' }) + button('Simulate timeline', 'simulate-queue', { icon: 'clock' }) + button('Review changes', 'review-queue', { kind: 'primary' }) + ' Activity timeline 14:32 Alex reordered Return after Search Area A 14:33 System recomputed completion estimate ';
}
function systemView() {
const color = (name, code, cls) => '' + name + ' ' + code + '
';
return '1. Color and status Surface (Graphite / Navy)
' + color('Surface 0', '#0B0F14', 's0') + color('Surface 1', '#111724', 's1') + color('Surface 2', '#171D2B', 's2') + color('Surface 3', '#1D2536', 's3') + color('Border', '#2A3447', 'border') + '
Semantic status (meaning over decoration)
' + color('Blue', 'Active / Primary', 'blue') + color('Cyan', 'Selected', 'cyan') + color('Green', 'Nominal', 'green') + color('Amber', 'Attention', 'amber') + color('Red', 'Critical', 'red') + color('Violet', 'Planned', 'violet') + '
Color communicates state and priority, not category. Do not rely on color alone—use icon, text, and shape. Maintain WCAG AA contrast for all text. 2. Typography H1 Mission / Group Heading H2 Task Heading Body / UI Text Readable action and mission information
Metadata / Secondary UAV-3F7A2C 08:43:21Z ALT 3250 ft 3. Components Buttons (44px height)
' + button('Create group', 'new-group', { icon: 'plus', kind: 'primary' }) + button('Assign task', 'open-preview', { icon: 'task' }) + button('Remove', 'remove', { icon: 'close', kind: 'danger' }) + 'Status chips
' + statusTag('nominal') + statusTag('attention') + statusTag('critical') + statusTag('cyan', 'Selected') + statusTag('planned') + '
Authority
' + icon('shield') + 'AuthorityOperator
▣ Read-only observer
ISR Sweep North ' + statusTag('nominal') + 'Type ISR
Area Sector 12
Assets 14 UAV
27 Group Alpha ' + statusTag('cyan', 'Selected') + 'Members 27 UAVs
Lead UAV-3F7A2C
' + icon('alert') + '' + statusTag('critical') + 'Link degraded on UAV-7B1C 4. Interaction states ' + alphaVehicles.slice(0, 9).map(v => vehicleMarker(v, v.id !== 'UAV-03')).join('') + '
' + icon('check') + '27 vehicles selected ISR 14 Relay 7 Transport 6 ' + button('Create group', 'new-group', { icon: 'plus', kind: 'primary' }) + button('Assign task', 'open-preview') + button('Add to group', 'group-vehicles') + '
Selection state cards 27 Group Alpha ' + statusTag('cyan', 'Selected') + 'Members · 27 UAVs
◈ ISR Sweep North ' + statusTag('nominal') + 'Start · 09:00Z · Assets 14 UAVs
✈ UAV-3F7A2C ' + statusTag('cyan', 'Selected') + 'Type · ISR · Alt 3,250 ft
□ No selection Use selection tools to choose vehicles or groups.
5. Responsive composition Map-first layouts adapt by collapsing / expanding secondary panels.
Laptop
27-inch
Ultrawide
4K wall
6. Density and accessibility 44px minimum tap / click target
Assign task Tab
Aa high-contrast UI text
' + icon('info') + ' Semantic label and tooltip
';
}
function modal() {
if (!state.modal) return '';
let content = '';
if (state.modal === 'preview') {
content = '6 selected vehicles will be assigned to Area Search — Northern Sector .
Current assignment
' + icon('route') + ' Proposed task
' + validationRow('Estimated completion', '18 min') + validationRow('Energy reserve', 'All above minimum') + validationRow('Route conflicts', 'None detected') + validationRow('Geofence conflicts', 'None detected') + validationRow('Vehicle compatibility', '6 / 6') + validationRow('Potential issue', '1 aircraft may require reassignment', 'warning') + '
' + button('Cancel', 'cancel-modal') + button('Confirm assignment', 'confirm-assignment', { icon: 'check', kind: 'primary' }) + ' ';
} else if (state.modal === 'transfer') {
content = 'A Alpha · command authority Held by Alex · lease expires 02:34
Reason ' + icon('info') + ' This action will transfer command authority from Alex to Sara . The change is logged for all operators.
' + button('Deny', 'deny-transfer') + button('Transfer control', 'confirm-transfer', { icon: 'transfer', kind: 'danger' }) + ' ';
} else if (state.modal === 'help') {
content = 'Smart selection ' + button('', 'cancel-modal', { icon: 'close', iconOnly: true, label: 'Close help' }) + 'Use a natural-language request or structured filters to select a resource-ready group of aircraft. The POC derives the result from fictional vehicles and always validates the task before confirmation.
' + button('Got it', 'cancel-modal', { kind: 'primary' }) + ' ';
}
return '';
}
function toast() {
return state.toast ? '' + icon('check') + '' + state.toast + ' ' + icon('close') + '
' : '';
}
function app() {
const views = { overview: overviewView, zoom: zoomView, selection: smartSelectionView, collaboration: collaborationView, recovery: recoveryView, queue: queueView, system: systemView };
document.getElementById('app').innerHTML = topBar() + views[state.view]() + modal() + toast();
}
function setToast(message) {
state.toast = message;
window.clearTimeout(window.__atlasToast);
window.__atlasToast = window.setTimeout(() => { state.toast = ''; app(); }, 3600);
}
function clickAction(action, value) {
if (action === 'set-view') { state.view = value; state.modal = null; }
if (action === 'select-group') { state.selectedGroup = value; state.view = state.view === 'collaboration' ? 'collaboration' : 'overview'; setToast(groupById(value).name + ' selected — contextual controls updated.'); }
if (action === 'select-vehicle') { state.selectedVehicle = value; state.view = 'zoom'; setToast(value + ' selected — vehicle detail is shown on request.'); }
if (action === 'toggle-layers') state.layersOpen = !state.layersOpen;
if (action === 'open-preview') state.modal = 'preview';
if (action === 'open-transfer') state.modal = 'transfer';
if (action === 'cancel-modal' || action === 'close-assign' || action === 'close-inspector') state.modal = null;
if (action === 'show-filter-help') state.modal = 'help';
if (action === 'confirm-assignment') { state.modal = null; setToast('TASK-143 assigned after route, energy, and constraint validation.'); }
if (action === 'confirm-transfer') { state.modal = null; groups[0].lease = 'Sara'; groups[0].operator = 'Sara'; setToast('Command lease transferred to Sara. The audit event is visible to all operators.'); }
if (action === 'deny-transfer') { state.modal = null; setToast('Command request denied. Alex retains the Alpha command lease.'); }
if (action === 'move-group') setToast('Move intent opened. A route preview would be required before confirmation.');
if (action === 'hold-group') setToast('Hold intent queued for ' + groupById(state.selectedGroup).name + '.');
if (action === 'group-vehicles') setToast('Create / add to group workflow opened for the current selection.');
if (action === 'split-group') setToast('Split group is available after selecting a destination task.');
if (action === 'open-vehicle-detail') { state.view = 'zoom'; state.selectedVehicle = 'UAV-07'; }
if (action === 'select-candidate') state.selectedCandidate = value;
if (action === 'accept-replacement') { state.reassigned = true; setToast(state.selectedCandidate + ' assigned to Alpha Search. Task coverage returned to 4 / 4.'); }
if (action === 'show-failure') setToast('UAV-03 is unavailable. A replacement recommendation needs operator approval.');
if (action === 'queue-up' || action === 'queue-down') {
const index = Number(value); const direction = action === 'queue-up' ? -1 : 1; const next = index + direction;
if (next >= 0 && next < state.queue.length) { const copy = state.queue.slice(); [copy[index], copy[next]] = [copy[next], copy[index]]; state.queue = copy; state.queueDraft = true; setToast('Intent queue reordered locally. Review changes to commit.'); }
}
if (action === 'review-queue') { state.queueDraft = false; setToast('Queue review recorded. The plan remains valid.'); }
if (action === 'reorder-queue') { state.queueDraft = true; setToast('Reorder mode active — use the arrows on each intent step.'); }
if (action === 'simulate-queue') setToast('Simulation complete: no constraints conflict with the proposed intent queue.');
if (action === 'add-step') { state.queue.push({ title: 'New intent', detail: 'Configure task', duration: '—', status: 'queued' }); state.queueDraft = true; setToast('New draft intent added to the queue.'); }
if (action === 'new-group') setToast('New group creation starts with a multi-vehicle selection.');
if (action === 'remove-filter') setToast('Filter removed. The fictional result set has been recalculated.');
if (action === 'clear-filters') setToast('Structured filters cleared. Use a query to build a new selection.');
if (action === 'map-zoom-in') setToast('Map zoomed in — semantic detail increases as you select groups and vehicles.');
if (action === 'map-zoom-out') setToast('Map zoomed out — groups aggregate to protect situational awareness.');
if (action === 'view-alerts' || action === 'view-fleet' || action === 'view-history') setToast('This POC surfaces exceptions first; the nominal fleet stays intentionally quiet.');
if (action === 'compare-candidates') setToast('Candidate comparison keeps energy, task compatibility, and link quality visible.');
if (action === 'clear-toast') state.toast = '';
app();
}
document.addEventListener('click', event => {
const el = event.target.closest('[data-action]');
if (el) {
event.preventDefault();
clickAction(el.dataset.action, el.dataset.value);
return;
}
if (event.target.closest('[data-stop-propagation]')) event.stopPropagation();
});
document.addEventListener('keydown', event => {
if (event.key === 'Escape' && state.modal) { state.modal = null; app(); }
});
app();