func visualizeForMermaidAsFlowChart(fsm *FSM) string {
	var buf bytes.Buffer
	sortedTransitionKeys := getSortedTransitionKeys(fsm.transitions)
	sortedStates, statesToIDMap := getSortedStates(fsm.transitions)
	writeFlowChartGraphType(&buf)
	writeFlowChartStates(&buf, sortedStates, statesToIDMap)
	writeFlowChartTransitions(&buf, fsm.transitions, sortedTransitionKeys, statesToIDMap)
	writeFlowChartHighlightCurrent(&buf, fsm.current, statesToIDMap)
	return buf.String()
}
visualizeForMermaidAsFlowChart outputs a visualization of a FSM in Mermaid format (including highlighting of current state).
package fsm
import (
	"bytes"
	"fmt"
)
const highlightingColor = "#00AA00"
type MermaidDiagramType string
const (
	FlowChart MermaidDiagramType = "flowChart"
	StateDiagram MermaidDiagramType = "stateDiagram"
)
func VisualizeForMermaidWithGraphType(fsm *FSM, graphType MermaidDiagramType) (string, error) {
	switch graphType {
	case FlowChart:
		return visualizeForMermaidAsFlowChart(fsm), nil
	case StateDiagram:
		return visualizeForMermaidAsStateDiagram(fsm), nil
	default:
		return "", fmt.Errorf("unknown MermaidDiagramType: %s", graphType)
	}
}
func visualizeForMermaidAsStateDiagram(fsm *FSM) string {
	var buf bytes.Buffer
	sortedTransitionKeys := getSortedTransitionKeys(fsm.transitions)
	buf.WriteString("stateDiagram-v2\n")
	buf.WriteString(fmt.Sprintln(`    [*] -->`, fsm.current))
	for _, k := range sortedTransitionKeys {
		v := fsm.transitions[k]
		buf.WriteString(fmt.Sprintf(`    %s --> %s: %s`, k.src, v, k.event))
		buf.WriteString("\n")
	}
	return buf.String()
}