import {
  Box,
  Button,
  Chip,
  IconButton,
  Paper,
  Table,
  TableBody,
  TableCell,
  TableContainer,
  TableHead,
  TableRow,
  Tooltip,
  Typography,
  LinearProgress,
  Grid,
  Card,
  CardContent,
} from '@mui/material';
import dayjs from 'dayjs';
import DeleteIcon from '@mui/icons-material/Delete';
import EditIcon from '@mui/icons-material/Edit';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import QuizIcon from '@mui/icons-material/Quiz';
import SlideshowIcon from '@mui/icons-material/Slideshow';
import TrendingUpIcon from '@mui/icons-material/TrendingUp';
import TrendingDownIcon from '@mui/icons-material/TrendingDown';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import ViewModuleIcon from '@mui/icons-material/ViewModule';
import SpeedIcon from '@mui/icons-material/Speed';
import { useMemo } from 'react';

interface CoverageEntry {
  id: string;
  timestamp_ms: number;
  sectionName: string;
  sectionUri: string;
  targetSectionName: string;
  targetSectionUri: string;
  clipId: string;
  isQuizScheduled: boolean;
  slideUri: string;
  slideNumber?: number;
}

interface CoverageTableProps {
  entries: CoverageEntry[];
  onEdit: (index: number) => void;
  onDelete: (index: number) => void;
  sectionOrder?: string[];
  courseStartDate?: string;
  sectionList?: Array<{ id: string; title: string; uri: string }>;
}

function calculatePreorderFlatProgress(
  entries: CoverageEntry[] = [],
  sectionOrder: string[] = [],
  courseStartDate: string = ''
) {
  const normalize = (s: string) => s.trim().toLowerCase();
  const today = dayjs().endOf('day');
  const start = dayjs(courseStartDate);

  if (!start.isValid() || sectionOrder.length === 0) {
    return {
      status: 'on-track',
      difference: 0,
      message: 'Invalid configuration',
      overallProgress: 0,
      totalSections: sectionOrder.length,
      overallPercentage: 0,
      completedSections: [],
    };
  }

  const normalizedOrder = sectionOrder.map(normalize);

  let maxSeenIndex = -1;
  let maxTargetIndex = -1;

  for (const entry of entries) {
    const entryDate = dayjs(entry.timestamp_ms);
    if (entryDate.isAfter(today)) continue;

    const sectionNameIndex = normalizedOrder.indexOf(normalize(entry.sectionName ?? ''));
    const targetSectionIndex = normalizedOrder.indexOf(normalize(entry.targetSectionName ?? ''));

    if (sectionNameIndex !== -1) {
      maxSeenIndex = Math.max(maxSeenIndex, sectionNameIndex);
    }

    if (targetSectionIndex !== -1) {
      maxTargetIndex = Math.max(maxTargetIndex, targetSectionIndex);
    }
  }

  const difference = maxSeenIndex - maxTargetIndex;

  const status = difference > 0 ? 'ahead' : difference < 0 ? 'behind' : 'on-track';
  const message =
    difference === 0
      ? "You're on track with today's plan."
      : `You're ${Math.abs(difference)} section${Math.abs(difference) !== 1 ? 's' : ''} ${status}.`;

  return {
    status,
    difference,
    message,
    overallProgress: maxSeenIndex + 1,
    totalSections: sectionOrder.length,
    overallPercentage:
      sectionOrder.length > 0 ? ((maxSeenIndex + 1) / sectionOrder.length) * 100 : 0,
    completedSections: normalizedOrder.slice(0, maxSeenIndex + 1),
  };
}

export function CoverageTable({
  entries,
  onEdit,
  onDelete,
  sectionOrder = [],
  courseStartDate = '',
}: CoverageTableProps) {
  const now = dayjs();
  const sortedEntries = [...entries].sort((a, b) => {
    const dateA = dayjs(a.timestamp_ms).startOf('day').valueOf();
    const dateB = dayjs(b.timestamp_ms).startOf('day').valueOf();
    return dateA - dateB;
  });
  const progressData = useMemo(
    () => calculatePreorderFlatProgress(entries, sectionOrder, courseStartDate),
    [entries, sectionOrder, courseStartDate]
  );
  
  const getStatusIcon = (status: string) => {
    switch (status) {
      case 'ahead':
        return <TrendingUpIcon />;
      case 'behind':
        return <TrendingDownIcon />;
      case 'on-track':
        return <CheckCircleIcon />;
      default:
        return null;
    }
  };

  const getStatusColor = (status: string) => {
    switch (status) {
      case 'ahead':
        return 'success';
      case 'behind':
        return 'error';
      case 'on-track':
        return 'info';
      default:
        return 'warning';
    }
  };

  const getProgressColor = (percentage: number) => {
    if (percentage >= 80) return '#4caf50';
    if (percentage >= 60) return '#2196f3';
    if (percentage >= 40) return '#ff9800';
    return '#f44336';
  };

  const formatSectionWithSlide = (sectionName: string, slideNumber?: number, slideUri?: string) => {
    if (!sectionName) return <i>-</i>;
    
    if (slideNumber && slideUri) {
      return (
        <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
          <SlideshowIcon sx={{ fontSize: 16, color: 'success.main' }} />
          <Typography variant="body2">
            <strong>Slide {slideNumber}</strong> of {sectionName}
          </Typography>
        </Box>
      );
    } else {
      return (
        <Typography variant="body2">
          {sectionName}
        </Typography>
      );
    }
  };

  return (
    <Box>
      <Paper
        elevation={3}
        sx={{
          mb: 3,
          borderRadius: 3,
          overflow: 'hidden',
          background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
        }}
      >
        <Box sx={{ p: 2.5, color: 'white' }}>
          <Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}>
            <SpeedIcon sx={{ fontSize: 28 }} />
            <Typography variant="h6" fontWeight="600">
              Lecture Progress
            </Typography>
          </Box>

          <Grid container spacing={3} sx={{ mb: 2 }}>
            <Grid item xs={12} md={6}>
              <Card
                sx={{
                  bgcolor: 'rgba(255,255,255,0.95)',
                  borderRadius: 2,
                  height: 160,
                  display: 'flex',
                  flexDirection: 'column',
                  justifyContent: 'center',
                }}
              >
                <CardContent
                  sx={{
                    p: 2.5,
                    '&:last-child': { pb: 2.5 },
                    height: '100%',
                    display: 'flex',
                    flexDirection: 'column',
                    justifyContent: 'center',
                  }}
                >
                  <Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}>
                    <ViewModuleIcon sx={{ color: '#764ba2', fontSize: 24 }} />
                    <Typography variant="h6" fontWeight="600" color="text.primary">
                      Lecture Progress
                    </Typography>
                  </Box>

                  <Box sx={{ display: 'flex', alignItems: 'center', gap: 3 }}>
                    <Typography variant="h2" fontWeight="bold" sx={{ color: '#764ba2' }}>
                      {Math.round(progressData.overallPercentage)}%
                    </Typography>

                    <Box sx={{ flex: 1 }}>
                      <LinearProgress
                        variant="determinate"
                        value={progressData.overallPercentage}
                        sx={{
                          height: 12,
                          borderRadius: 6,
                          bgcolor: 'rgba(0,0,0,0.1)',
                          '& .MuiLinearProgress-bar': {
                            borderRadius: 6,
                            bgcolor: getProgressColor(progressData.overallPercentage),
                          },
                        }}
                      />
                      <Typography variant="body2" color="text.secondary" sx={{ mt: 0.5 }}>
                        {progressData.overallProgress} of {progressData.totalSections} lectures
                        completed
                      </Typography>
                    </Box>
                  </Box>
                </CardContent>
              </Card>
            </Grid>

            <Grid item xs={12} md={6}>
              <Card
                sx={{
                  bgcolor: 'rgba(255,255,255,0.95)',
                  borderRadius: 2,
                  height: 160,
                  display: 'flex',
                  flexDirection: 'column',
                  justifyContent: 'center',
                }}
              >
                <CardContent
                  sx={{
                    p: 2.5,
                    '&:last-child': { pb: 2.5 },
                    height: '100%',
                    display: 'flex',
                    flexDirection: 'column',
                    justifyContent: 'center',
                  }}
                >
                  <Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mb: 2 }}>
                    {getStatusIcon(progressData.status)}
                    <Typography variant="h6" fontWeight="600" color="text.primary">
                      Schedule Status
                    </Typography>
                  </Box>

                  <Typography variant="h6" fontWeight="600" color="text.primary" sx={{ mb: 1.5 }}>
                    {Math.abs(progressData.difference) < 1
                      ? `Running slightly ${
                          progressData.difference > 0
                            ? 'ahead-of'
                            : progressData.difference < 0
                            ? 'behind'
                            : 'on'
                        } schedule`
                      : `Running over ${Math.abs(progressData.difference)} lecture${
                          Math.abs(progressData.difference) !== 1 ? 's' : ''
                        } ${progressData.difference > 0 ? 'ahead-of' : 'behind'} schedule`}
                  </Typography>

                  <Chip
                    label={
                      progressData.status.charAt(0).toUpperCase() + progressData.status.slice(1)
                    }
                    color={getStatusColor(progressData.status) as any}
                    sx={{ fontWeight: 600 }}
                  />
                </CardContent>
              </Card>
            </Grid>
          </Grid>
        </Box>
      </Paper>

      <TableContainer component={Paper} elevation={2} sx={{ borderRadius: 2, mb: 3 }}>
        <Table sx={{ minWidth: 650 }} size="medium">
          <TableHead>
            <TableRow sx={{ bgcolor: 'primary.light' }}>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Date</TableCell>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Section Completed</TableCell>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Target Section</TableCell>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Clip</TableCell>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Quiz</TableCell>
              <TableCell sx={{ fontWeight: 'bold', color: 'white' }}>Actions</TableCell>
            </TableRow>
          </TableHead>
          <TableBody>
            {sortedEntries.map((item, idx) => {
              const itemDate = dayjs(item.timestamp_ms);
              const isPast = itemDate.isBefore(now, 'day');
              const isFuture = itemDate.isAfter(now, 'day');

              const originalIndex = entries.findIndex((entry) => entry.id === item.id);

              return (
                <TableRow
                  key={`${item.timestamp_ms}-${idx}`}
                  sx={{
                    backgroundColor: isPast
                      ? 'rgba(237, 247, 237, 0.5)'
                      : isFuture
                      ? 'rgba(255, 243, 224, 0.5)'
                      : 'inherit',
                    '&:hover': {
                      backgroundColor: isPast
                        ? 'rgba(237, 247, 237, 0.7)'
                        : isFuture
                        ? 'rgba(255, 243, 224, 0.7)'
                        : 'action.hover',
                    },
                  }}
                >
                  <TableCell>
                    <Typography
                      variant="body2"
                      fontWeight="medium"
                      sx={{
                        color: isPast ? 'success.main' : isFuture ? 'warning.main' : 'text.primary',
                        fontWeight: 'bold',
                      }}
                    >
                      {itemDate.format('YYYY-MM-DD')}
                    </Typography>
                  </TableCell>
                  <TableCell
                    sx={{
                      maxWidth: '300px',
                      overflow: 'hidden',
                      textOverflow: 'ellipsis',
                      whiteSpace: 'nowrap',
                    }}
                  >
                    <Tooltip title={item.sectionName || 'No Section'}>
                      <Box>
                        {formatSectionWithSlide(item.sectionName, item.slideNumber, item.slideUri)}
                      </Box>
                    </Tooltip>
                  </TableCell>
                  <TableCell
                    sx={{
                      maxWidth: '200px',
                      overflow: 'hidden',
                      textOverflow: 'ellipsis',
                      whiteSpace: 'nowrap',
                    }}
                  >
                    <Tooltip title={item.targetSectionName || 'No Target'}>
                      <Typography variant="body2">
                        {item.targetSectionName || <i>-</i>}
                      </Typography>
                    </Tooltip>
                  </TableCell>
                  <TableCell>
                    {item.clipId?.length ? (
                      <Button
                        variant="outlined"
                        size="small"
                        href={`https://fau.tv/clip/id/${item.clipId}`}
                        target="_blank"
                        rel="noreferrer"
                        startIcon={<OpenInNewIcon />}
                        sx={{ textTransform: 'none' }}
                      >
                        {item.clipId}
                      </Button>
                    ) : (
                      <Typography variant="body2" color="text.secondary">
                        <i>-</i>
                      </Typography>
                    )}
                  </TableCell>
                  <TableCell>
                    {item.isQuizScheduled ? (
                      <Chip icon={<QuizIcon />} label="Scheduled" size="small" color="warning" />
                    ) : (
                      <Typography variant="body2" color="text.secondary">
                        <i>No Quiz</i>
                      </Typography>
                    )}
                  </TableCell>
                  <TableCell>
                    <Box sx={{ display: 'flex', gap: 1 }}>
                      <IconButton
                        size="small"
                        color="primary"
                        onClick={() => onEdit(originalIndex)}
                        sx={{
                          boxShadow: '0 2px 5px rgba(0,0,0,0.1)',
                          '&:hover': {
                            transform: 'translateY(-2px)',
                            boxShadow: '0 4px 8px rgba(0,0,0,0.15)',
                          },
                          transition: 'all 0.2s',
                        }}
                      >
                        <EditIcon fontSize="small" />
                      </IconButton>
                      <IconButton
                        size="small"
                        color="error"
                        onClick={() => onDelete(originalIndex)}
                        sx={{
                          boxShadow: '0 2px 5px rgba(0,0,0,0.1)',
                          '&:hover': {
                            transform: 'translateY(-2px)',
                            boxShadow: '0 4px 8px rgba(0,0,0,0.15)',
                          },
                          transition: 'all 0.2s',
                        }}
                      >
                        <DeleteIcon fontSize="small" />
                      </IconButton>
                    </Box>
                  </TableCell>
                </TableRow>
              );
            })}
          </TableBody>
        </Table>
      </TableContainer>
    </Box>
  );
}

export default CoverageTable;// I want to track the parent child hierarchy in this 

0
: 
id
: 
"pre2/preface/section"
title
: 
"        Preface"
uri
: 
"https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preface&l=en&e=section"
[[Prototype]]
: 
Object
1
: 
id
: 
"pre2/preface/section/concept/section"
title
: 
"            Course Concept"
uri
: 
"https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=concept&l=en&e=section"
[[Prototype]]
: 
Object
2
: 
{id: 'pre2/preface/section/contents/section', title: '            Course Contents', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=contents&l=en&e=section'}
3
: 
{id: 'pre2/preface/section/thisdoc/section', title: '            This Document', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=thisdoc&l=en&e=section'}
4
: 
{id: 'pre2/preface/section/acknowledgements/section', title: '            Acknowledgments', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=acknowledgements&l=en&e=section'}
5
: 
{id: 'pre2/preface/section/section_1', title: '            Recorded Syllabus', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preface&l=en&e=section/section_1'}
6
: 
{id: 'pre2/preliminaries2/section', title: '    Preliminaries', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preliminaries2&l=en&e=section'}
7
: 
{id: 'pre2/preliminaries2/section/admin2/section', title: '        Administrative Ground Rules', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=admin2&l=en&e=section'}
8
: 
{id: 'pre2/preliminaries2/section/getting-most/section', title: '        Getting Most out of AI-2', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=getting-most&l=en&e=section'}
9
: 
{id: 'pre2/preliminaries2/section/resources/section', title: '        Learning Resources for AI-2', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=resources&l=en&e=section'}
10
: 
{id: 'pre2/preliminaries2/section_1', title: '    Excursions', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=preliminaries2&l=en&e=section_1'}
11
: 
{id: 'pre2/preliminaries2/section_1/alea/section', title: '        ALeA – AI-Supported Learning', uri: 'https://mathhub.info?a=courses/FAU/meta-inf&p=ALeA/sec&d=alea&l=en&e=section'}
12
: 
{id: 'pre2/overview2/section', title: '    Overview over AI and Topics of AI-II', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=overview2&l=en&e=section'}
13
: 
{id: 'pre2/overview2/section/whatisai/section', title: '        What is Artificial Intelligence?', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=intro/sec&d=whatisai&l=en&e=section'}
14
: 
{id: 'pre2/overview2/section/aiexists/section', title: '        Artificial Intelligence is here today!', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=intro/sec&d=aiexists&l=en&e=section'}
15
: 
{id: 'pre2/overview2/section/two-attacks/section', title: '        Ways to Attack the AI Problem', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=two-attacks&l=en&e=section'}
16
: 
{id: 'pre2/overview2/section/kwarc-ai/section', title: '        AI in the KWARC Group', uri: 'https://mathhub.info?a=mkohlhase/talks&p=kwarc/sec&d=kwarc-ai&l=en&e=section'}
17
: 
{id: 'pre2/overview2/section/agents2/section', title: '        Agents and Environments in AI2', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=agents2&l=en&e=section'}
18
: 
{id: 'pre2/overview2/section/agents2/section/agents-recap/section', title: '            Recap: Rational Agents as a Conceptual Framework', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rational-agents/sec&d=agents-recap&l=en&e=section'}
19
: 
{id: 'pre2/overview2/section/agents2/section/uncert-sources/section', title: '            Sources of Uncertainty', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…tic-reasoning/sec&d=uncert-sources&l=en&e=section'}
20
: 
{id: 'pre2/overview2/section/agents2/section/bsa-recap/section', title: '            Agent Architectures based on Belief States', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rational-agents/sec&d=bsa-recap&l=en&e=section'}
21
: 
{id: 'uncert/section', title: 'Reasoning with Uncertain Knowledge', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=course/sec&d=uncert&l=en&e=section'}
22
: 
{id: 'uncert/section/probabilities/section', title: '    Quantifying Uncertainty', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…stic-reasoning/sec&d=probabilities&l=en&e=section'}
23
: 
{id: 'uncert/section/probabilities/section/probability-theory/section', title: '        Probability Theory', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…reasoning/sec&d=probability-theory&l=en&e=section'}
24
: 
{id: 'uncert/section/probabilities/section/probability-theory/section/section_1', title: '            Prior and Posterior Probabilities', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…sec&d=probability-theory&l=en&e=section/section_1'}
25
: 
{id: 'uncert/section/probabilities/section/probability-theory/section/section_2', title: '            Independence', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…sec&d=probability-theory&l=en&e=section/section_2'}
26
: 
{id: 'uncert/section/probabilities/section/probability-theory/section/section_3', title: '            Conclusion', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…sec&d=probability-theory&l=en&e=section/section_3'}
27
: 
{id: 'uncert/section/probabilities/section/techniques/section', title: '        Probabilistic Reasoning Techniques', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…ilistic-reasoning/sec&d=techniques&l=en&e=section'}
28
: 
{id: 'uncert/section/probabilities/section/techniques/section/section_1', title: '            Probability Distributions', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…asoning/sec&d=techniques&l=en&e=section/section_1'}
29
: 
{id: 'uncert/section/probabilities/section/techniques/section/section_2', title: '            Naive Bayes', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…asoning/sec&d=techniques&l=en&e=section/section_2'}
30
: 
{id: 'uncert/section/probabilities/section/techniques/section/section_3', title: '            Inference by Enumeration', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…asoning/sec&d=techniques&l=en&e=section/section_3'}
31
: 
{id: 'uncert/section/probabilities/section/techniques/section/section_4', title: '            Example – The Wumpus is Back', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…asoning/sec&d=techniques&l=en&e=section/section_4'}
32
: 
{id: 'uncert/section/bayesian-networks2/section', title: '    Probabilistic Reasoning: Bayesian Networks', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…reasoning/sec&d=bayesian-networks2&l=en&e=section'}
33
: 
{id: 'uncert/section/bayesian-networks2/section/BN-intro2/section', title: '        Introduction', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…bilistic-reasoning/sec&d=BN-intro2&l=en&e=section'}
34
: 
{id: 'uncert/section/bayesian-networks2/section/BN-construct2/section', title: '        Constructing Bayesian Networks', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…stic-reasoning/sec&d=BN-construct2&l=en&e=section'}
35
: 
{id: 'uncert/section/bayesian-networks2/section/BN-inference2/section', title: '        Inference in Bayesian Networks', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…stic-reasoning/sec&d=BN-inference2&l=en&e=section'}
36
: 
{id: 'uncert/section/bayesian-networks2/section/BN-concl/section', title: '        Conclusion', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=probabilistic-reasoning/sec&d=BN-concl&l=en&e=section'}
37
: 
{id: 'uncert/section/simple-decisions/section', title: '    Making Simple Decisions Rationally', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rat…l-decisions/sec&d=simple-decisions&l=en&e=section'}
38
: 
{id: 'uncert/section/simple-decisions/section/simple-decisions-intro2/section', title: '        Introduction', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rat…ions/sec&d=simple-decisions-intro2&l=en&e=section'}
39
: 
{id: 'uncert/section/simple-decisions/section/decision-networks/section', title: '        Decision Networks', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rat…-decisions/sec&d=decision-networks&l=en&e=section'}
40
: 
{id: 'uncert/section/simple-decisions/section/rational-preferences2/section', title: '        Preferences and Utilities', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rat…isions/sec&d=rational-preferences2&l=en&e=section'}
41
: 
{id: 'uncert/section/simple-decisions/section/utilities/section', title: '        Utilities', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rational-decisions/sec&d=utilities&l=en&e=section'}
42
: 
{id: 'uncert/section/simple-decisions/section/multi-attribute-utility/section', title: '        Multi-Attribute Utility', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rat…ions/sec&d=multi-attribute-utility&l=en&e=section'}
43
: 
{id: 'uncert/section/simple-decisions/section/vpi/section', title: '        The Value of Information', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=rational-decisions/sec&d=vpi&l=en&e=section'}
44
: 
{id: 'uncert/section/temporal-models/section', title: '    Temporal Probability Models', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…ic-reasoning/sec&d=temporal-models&l=en&e=section'}
45
: 
{id: 'uncert/section/temporal-models/section/time-uncertainty/section', title: '        Modeling Time and Uncertainty', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…c-reasoning/sec&d=time-uncertainty&l=en&e=section'}
46
: 
{id: 'uncert/section/temporal-models/section/temporal-inference/section', title: '        Inference: Filtering, Prediction, and Smoothing', uri: 'https://mathhub.info?a=courses/FAU/AI/course&p=pro…reasoning/sec&d=temporal-inference&l=en&e=section'}
47
: 
{id: 'uncert/section/temporal-models/section/HMM-ex/section', title: '   //this is an example how the data is