import * as React from 'react'; import '@fontsource/roboto/300.css'; import '@fontsource/roboto/400.css'; import '@fontsource/roboto/500.css'; import '@fontsource/roboto/700.css'; import ReactMarkdown from 'react-markdown'; import { MathJax } from "better-react-mathjax"; import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; import { Paper, Box, Typography, Alert } from '@mui/material'; const errorRegex = /:1:(?[^:]*): (?.*)/; // TODO: Dead variables (x✝) are not displayed correctly. function Goal({ goal }) { const hasObject = typeof goal.objects === "object" && goal.objects.length > 0 const hasAssumption = typeof goal.assumptions === "object" && goal.assumptions.length > 0 return ( {hasObject && Objects {goal.objects.map((item) => {item.userName} : {item.type} )} } {hasAssumption && Assumptions {goal.assumptions.map((item) => {item.userName} : {item.type})} } Prove: {goal.goal} {goal.messages.map((message) => {message})} {goal.hints.map((message) => {message})} ) } function TacticState({ goals, errors, completed }) { const hasError = typeof errors === "object" && errors.length > 0 const hasGoal = goals !== null && goals.length > 0 const hasManyGoal = hasGoal && goals.length > 1 var col = "" var msg = "" if (hasError) { const m = errors[0].match(errorRegex) if (m) { col = `Column ${m.groups.col}: ` msg = m.groups.msg } else { msg = errors[0] if (msg === "Unrecognized tactic") { msg = "Unknown spell!" } } } return ( {goals === null && No goals at cursor position} {hasGoal && Main goal at cursor } {completed && Level completed ! 🎉} {hasError && Spell invocation failed {col}{msg} Use the undo button to go back to a sane state. } {hasManyGoal && Other goals {goals.slice(1).map((goal, index) => )} } ) } export default TacticState