"use client"; import React from "react"; import { Mermaid } from "./Mermaid"; interface StateTransition { from: string; to: string; label?: string; } interface DiagramStateProps { states: string[]; transitions: StateTransition[]; initialState?: string; finalStates?: string[]; title?: string; caption?: string; id?: string; showShare?: boolean; fontSize?: string; } export const DiagramState: React.FC = ({ states, transitions, initialState, finalStates = [], title, caption, id, showShare = true, fontSize = "16px", }) => { const stateGraph = `stateDiagram-v2 ${initialState ? ` [*] --> ${initialState}` : ""} ${(transitions || []) .map((t) => { const label = t.label ? ` : ${t.label}` : ""; return ` ${t.from} --> ${t.to}${label}`; }) .join("\n")} ${(finalStates || []).map((s) => ` ${s} --> [*]`).join("\n")}`; return (
{caption && (
{caption}
)}
); };