"use client"; import * as React from "react"; import { MaximizeIcon } from "lucide-react"; import { STATEMENT_LOCALES, isStatementLocale, type StatementLocale, } from "@accessibit/types"; import { Button } from "../ui/button"; import { Card } from "../ui/card"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../ui/dialog"; import { SegmentedControl } from "../ui/segmented-control"; import { useMessages } from "../context"; import { STATEMENT_TOUR_ANCHORS } from "../tour"; import { cn } from "../lib/cn"; /** * Each language under its own name: the switch chooses a document, and a * document is named in the language it is written in. Not from the * dictionary: these are the same three words in every language of the * dashboard. */ const ENDONYMS: Record = { it: "Italiano", en: "English", es: "EspaƱol", }; /** * The language of the document on show. The page has ONE document language: * this switch, the tabs of the free text and the select of the embed card all * move the same state, so the preview and the text being written can never * be in two languages. */ export function StatementLanguageSwitch({ value, onChange, className, }: { value: StatementLocale; onChange: (locale: StatementLocale) => void; className?: string; }) { const messages = useMessages(); return ( ({ value: locale, label: ENDONYMS[locale], lang: locale, }))} value={value} onChange={(next) => { if (isStatementLocale(next)) onChange(next); }} className={cn("flex", className)} /> ); } /** * The real document, from the same function that writes the published * artifact: not a React re-implementation of it, which is how a preview comes * to show fields the statement never contained. * * `allow-scripts` is deliberately absent from `sandbox`: the document is * static HTML and must stay that way, and `srcDoc` keeps it a pure render * with no network round trip. */ function StatementDocument({ html, title, className, }: { html: string; title: string; className?: string; }) { return (