{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "education102",
  "title": "Lesson Check Quiz",
  "description": "An end-of-lesson knowledge check: a two-column header, a three-figure strip for questions, pass mark, and attempts, a graded quiz that swaps itself for a score and a per-question review, and a list of readings for whatever went wrong.",
  "dependencies": [
    "clsx",
    "tailwind-merge",
    "lucide-react"
  ],
  "registryDependencies": [
    "questionnaire",
    "button"
  ],
  "files": [
    {
      "path": "registry/education102/education102.tsx",
      "content": "\"use client\";\n\nimport { ArrowUpRight, Check, RotateCcw, X } from \"lucide-react\";\nimport Link from \"next/link\";\nimport { type FormEvent, useState } from \"react\";\nimport { Badge23 } from \"@/components/beste/component/badge23\";\nimport { Button21 } from \"@/components/beste/component/button21\";\nimport {\n  Questionnaire,\n  QuestionnaireActions,\n  QuestionnaireChoice,\n  QuestionnaireChoiceDescription,\n  QuestionnaireChoices,\n  QuestionnaireDescription,\n  QuestionnaireError,\n  QuestionnaireItem,\n  QuestionnaireNext,\n  QuestionnairePrevious,\n  QuestionnaireProgress,\n  QuestionnaireSubmit,\n  QuestionnaireTitle,\n} from \"@/components/ui/questionnaire\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Badge {\n  label: string;\n}\n\ninterface StatItem {\n  title: string;\n  value: string;\n}\n\ninterface ResourceLink {\n  title: string;\n  description: string;\n  href: string;\n}\n\ninterface QuizChoice {\n  value: string;\n  label: string;\n  description?: string;\n}\n\ninterface QuizQuestion {\n  /** Form field name. Must be unique across the quiz. */\n  name: string;\n  title: string;\n  description?: string;\n  choices?: QuizChoice[];\n  /**\n   * The answer key. A string is a single-answer question; an array turns the\n   * question into a checkbox set that only counts as correct when the whole\n   * set matches.\n   */\n  answer: string | string[];\n  /** Shown under the question in the review, once the quiz is graded */\n  explanation?: string;\n}\n\ninterface QuizLabels {\n  previous?: string;\n  next?: string;\n  submit?: string;\n  retry?: string;\n  scoreTitle?: string;\n  passed?: string;\n  failed?: string;\n  yourAnswer?: string;\n  correctAnswer?: string;\n  noAnswer?: string;\n}\n\ninterface Education102Props {\n  badge?: Badge;\n  heading?: string;\n  description?: string;\n  stats?: StatItem[];\n  quizHeading?: string;\n  quizDescription?: string;\n  questions?: QuizQuestion[];\n  /** Prints a scoped shortcut on every choice and binds it while the question is active */\n  shortcuts?: \"letters\" | \"numbers\";\n  /** Percent needed to pass. Omit to grade without a pass or fail line. */\n  passingScore?: number;\n  /** Prints the right answer and the explanation in the review */\n  showAnswerKey?: boolean;\n  labels?: QuizLabels;\n  resourcesTitle?: string;\n  resources?: ResourceLink[];\n  className?: string;\n}\n\n/** Order-insensitive comparison key for a set of answer values. */\nfunction answerKey(values: string[]) {\n  return JSON.stringify([...values].sort());\n}\n\nfunction expected(question: QuizQuestion) {\n  return Array.isArray(question.answer) ? question.answer : [question.answer];\n}\n\nexport const education102Demo: Education102Props = {\n  badge: { label: \"Module 3\" },\n  heading: \"Check what stuck before you move on\",\n  description:\n    \"Five questions on accessible forms. You see the right answer and the reason for it as soon as you finish, and you can retake it as often as you like.\",\n  stats: [\n    { title: \"Questions\", value: \"5\" },\n    { title: \"To pass\", value: \"60%\" },\n    { title: \"Attempts\", value: \"No limit\" },\n  ],\n  quizHeading: \"Lesson 3 check\",\n  quizDescription: \"Press a letter key to answer without reaching for the mouse.\",\n  shortcuts: \"letters\",\n  passingScore: 60,\n  showAnswerKey: true,\n  labels: {\n    submit: \"Finish quiz\",\n    retry: \"Try again\",\n    scoreTitle: \"Your score\",\n    passed: \"Passed. Lesson 4 is unlocked.\",\n    failed: \"Not quite. Read the notes below and take it again.\",\n  },\n  questions: [\n    {\n      name: \"label\",\n      title: \"What gives a text input its accessible name?\",\n      answer: \"label\",\n      explanation:\n        \"A label element with a matching for attribute is the only one of these the browser exposes as the field's name to every assistive technology.\",\n      choices: [\n        { value: \"label\", label: \"A label pointing at the input's id\" },\n        { value: \"placeholder\", label: \"The placeholder attribute\" },\n        { value: \"title\", label: \"The title attribute\" },\n        { value: \"nearby\", label: \"Text sitting next to the field\" },\n      ],\n    },\n    {\n      name: \"error\",\n      title: \"An error message appears under a field. What has to be true?\",\n      answer: \"described\",\n      explanation:\n        \"aria-describedby ties the message to the field, so it is read out with the field rather than stranded in the page.\",\n      choices: [\n        { value: \"described\", label: \"The field references it with aria-describedby\" },\n        { value: \"red\", label: \"It is red\" },\n        { value: \"icon\", label: \"It has a warning icon\" },\n        { value: \"top\", label: \"It is repeated at the top of the form\" },\n      ],\n    },\n    {\n      name: \"grouping\",\n      title: \"Which of these belong around a set of radio buttons?\",\n      description: \"Two answers are right.\",\n      answer: [\"fieldset\", \"legend\"],\n      explanation:\n        \"A fieldset groups the controls and its legend names the group, which is what turns four loose radios into one question.\",\n      choices: [\n        { value: \"fieldset\", label: \"A fieldset element\" },\n        { value: \"legend\", label: \"A legend element\" },\n        { value: \"table\", label: \"A table element\" },\n        { value: \"role-list\", label: \"A list role on the wrapper\" },\n      ],\n    },\n    {\n      name: \"focus\",\n      title: \"Where should focus go after a failed submit?\",\n      answer: \"first-invalid\",\n      explanation:\n        \"Moving focus to the first invalid field puts the person at the thing they have to fix, instead of at the top of a page they have to re-read.\",\n      choices: [\n        { value: \"first-invalid\", label: \"The first invalid field\" },\n        { value: \"submit\", label: \"Back on the submit button\" },\n        { value: \"body\", label: \"Nowhere in particular\" },\n        { value: \"top\", label: \"The page heading\" },\n      ],\n    },\n    {\n      name: \"target\",\n      title: \"What is the minimum target size a control should meet?\",\n      answer: \"24\",\n      explanation:\n        \"WCAG 2.2 sets 24 by 24 CSS pixels as the floor, and 44 by 44 as the comfortable size most touch guidelines land on.\",\n      choices: [\n        { value: \"16\", label: \"16 by 16 pixels\" },\n        { value: \"24\", label: \"24 by 24 pixels\" },\n        { value: \"40\", label: \"40 by 40 pixels\" },\n        { value: \"none\", label: \"There is no minimum\" },\n      ],\n    },\n  ],\n  resourcesTitle: \"If a question caught you out\",\n  resources: [\n    {\n      title: \"Naming form controls\",\n      description: \"Labels, legends, and the three things that are not a name.\",\n      href: \"https://beste.co\",\n    },\n    {\n      title: \"Errors people can act on\",\n      description: \"Wording, placement, and where focus belongs after a failed submit.\",\n      href: \"https://beste.co\",\n    },\n    {\n      title: \"Target sizes in WCAG 2.2\",\n      description: \"The 24 pixel floor, the exceptions, and how to measure it.\",\n      href: \"https://beste.co\",\n    },\n  ],\n};\n\nexport function Education102({\n  badge,\n  heading,\n  description,\n  stats = [],\n  quizHeading,\n  quizDescription,\n  questions = [],\n  shortcuts,\n  passingScore,\n  showAnswerKey = true,\n  labels = {},\n  resourcesTitle,\n  resources = [],\n  className,\n}: Education102Props) {\n  const {\n    previous: previousLabel,\n    next: nextLabel,\n    submit: submitLabel,\n    retry: retryLabel,\n    scoreTitle,\n    passed: passedLabel,\n    failed: failedLabel,\n    yourAnswer: yourAnswerLabel,\n    correctAnswer: correctAnswerLabel,\n    noAnswer: noAnswerLabel,\n  } = labels;\n\n  const [graded, setGraded] = useState<{\n    score: number;\n    total: number;\n    percent: number;\n    passed: boolean;\n    answers: Record<string, string[]>;\n    correct: Record<string, boolean>;\n  } | null>(null);\n  /**\n   * Only observed, never enforced: the quiz stays uncontrolled so the primitive\n   * keeps owning navigation, and this is here purely to draw the bar.\n   */\n  const [activeName, setActiveName] = useState(questions[0]?.name);\n\n  const activeIndex = Math.max(\n    0,\n    questions.findIndex((question) => question.name === activeName)\n  );\n  const percentThrough = questions.length > 0 ? ((activeIndex + 1) / questions.length) * 100 : 0;\n\n  const handleSubmit = (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault();\n    const data = new FormData(event.currentTarget);\n    const answers: Record<string, string[]> = {};\n    const correct: Record<string, boolean> = {};\n\n    for (const question of questions) {\n      const given = data\n        .getAll(question.name)\n        .map((entry) => String(entry))\n        .filter((entry) => entry.length > 0);\n      answers[question.name] = given;\n      correct[question.name] = answerKey(given) === answerKey(expected(question));\n    }\n\n    const score = questions.filter((question) => correct[question.name]).length;\n    const total = questions.length;\n    const percent = total > 0 ? Math.round((score / total) * 100) : 0;\n\n    setGraded({\n      score,\n      total,\n      percent,\n      passed: passingScore === undefined || percent >= passingScore,\n      answers,\n      correct,\n    });\n  };\n\n  const retry = () => {\n    setGraded(null);\n    setActiveName(questions[0]?.name);\n  };\n\n  const readable = (question: QuizQuestion, value: string) =>\n    question.choices?.find((choice) => choice.value === value)?.label ?? value;\n\n  return (\n    <section className={cn(\"w-full bg-background py-16 md:py-24\", className)}>\n      <div className=\"mx-auto max-w-5xl px-4 md:px-6\">\n        {badge && <Badge23 label={badge.label} />}\n\n        <div className=\"mt-6 border-t border-border pt-8 md:pt-10\">\n          <div className=\"grid gap-6 md:grid-cols-2 md:gap-12\">\n            {heading && (\n              <h2 className=\"text-3xl font-light leading-[1.1] tracking-tight text-foreground md:text-5xl\">\n                {heading}\n              </h2>\n            )}\n            {description && (\n              <div className=\"flex md:justify-end\">\n                <p className=\"max-w-md text-base leading-relaxed text-muted-foreground\">\n                  {description}\n                </p>\n              </div>\n            )}\n          </div>\n        </div>\n\n        {stats.length > 0 && (\n          <dl className=\"mt-12 grid gap-8 sm:grid-cols-3 md:mt-16\">\n            {stats.map((stat, index) => (\n              <div key={index} className=\"border-t border-border pt-5\">\n                <dt className=\"text-sm text-muted-foreground\">{stat.title}</dt>\n                <dd className=\"mt-3 text-4xl font-light tracking-tight text-foreground\">\n                  {stat.value}\n                </dd>\n              </div>\n            ))}\n          </dl>\n        )}\n\n        <div className=\"mt-12 md:mt-16\">\n          {graded ? (\n            <>\n              <p className=\"text-sm text-muted-foreground\">{scoreTitle ?? \"Your score\"}</p>\n              <p className=\"mt-3 text-4xl font-light tracking-tight text-foreground md:text-6xl\">\n                {graded.score}\n                <span className=\"text-muted-foreground\"> of {graded.total}</span>\n              </p>\n\n              <div className=\"mt-6 h-1 w-full overflow-hidden rounded-full bg-border\">\n                <div\n                  className=\"h-full rounded-full bg-primary transition-all duration-300\"\n                  style={{ width: `${graded.percent}%` }}\n                />\n              </div>\n\n              {passingScore !== undefined && (\n                <p\n                  className={cn(\n                    \"mt-5 text-base\",\n                    graded.passed ? \"text-primary\" : \"text-muted-foreground\"\n                  )}\n                >\n                  {graded.passed ? (passedLabel ?? \"Passed\") : (failedLabel ?? \"Not passed\")}\n                </p>\n              )}\n\n              <ul className=\"mt-10\">\n                {questions.map((question, index) => {\n                  const isCorrect = graded.correct[question.name] ?? false;\n                  const given = graded.answers[question.name] ?? [];\n                  return (\n                    <li\n                      key={index}\n                      className=\"flex gap-4 border-b border-border py-5 first:border-t\"\n                    >\n                      <span\n                        aria-hidden=\"true\"\n                        className={cn(\n                          \"mt-0.5 flex size-6 shrink-0 items-center justify-center rounded-full border\",\n                          isCorrect\n                            ? \"border-primary bg-primary text-primary-foreground\"\n                            : \"border-border text-muted-foreground\"\n                        )}\n                      >\n                        {isCorrect ? <Check className=\"size-3.5\" /> : <X className=\"size-3.5\" />}\n                      </span>\n                      <div className=\"min-w-0 flex-1\">\n                        <p className=\"text-lg font-medium text-foreground\">{question.title}</p>\n                        <p className=\"mt-2 text-sm leading-relaxed text-muted-foreground\">\n                          {yourAnswerLabel ?? \"Your answer\"}\n                          {\": \"}\n                          {given.length > 0\n                            ? given.map((value) => readable(question, value)).join(\", \")\n                            : (noAnswerLabel ?? \"Not answered\")}\n                        </p>\n                        {showAnswerKey && !isCorrect && (\n                          <p className=\"mt-1 text-sm leading-relaxed text-muted-foreground\">\n                            {correctAnswerLabel ?? \"Correct answer\"}\n                            {\": \"}\n                            {expected(question)\n                              .map((value) => readable(question, value))\n                              .join(\", \")}\n                          </p>\n                        )}\n                        {showAnswerKey && question.explanation && (\n                          <p className=\"mt-3 text-base leading-relaxed text-muted-foreground\">\n                            {question.explanation}\n                          </p>\n                        )}\n                      </div>\n                    </li>\n                  );\n                })}\n              </ul>\n\n              <div className=\"mt-8\">\n                <Button21\n                  label={retryLabel ?? \"Try again\"}\n                  tone=\"outline\"\n                  icon={RotateCcw}\n                  onClick={retry}\n                />\n              </div>\n            </>\n          ) : (\n            <>\n              {(quizHeading || quizDescription) && (\n                <div className=\"mb-8\">\n                  {quizHeading && (\n                    <p className=\"text-xl font-medium text-foreground\">{quizHeading}</p>\n                  )}\n                  {quizDescription && (\n                    <p className=\"mt-2 text-base leading-relaxed text-muted-foreground\">\n                      {quizDescription}\n                    </p>\n                  )}\n                </div>\n              )}\n\n              <Questionnaire\n                defaultItem={questions[0]?.name}\n                onItemChange={setActiveName}\n                shortcuts={shortcuts}\n                onSubmit={handleSubmit}\n                className=\"gap-6\"\n              >\n                {questions.length > 0 && (\n                  <div className=\"flex flex-col gap-3\">\n                    <QuestionnaireProgress className=\"text-sm font-normal tracking-normal\" />\n                    <div className=\"h-1 w-full overflow-hidden rounded-full bg-border\">\n                      <div\n                        className=\"h-full rounded-full bg-primary transition-all duration-300\"\n                        style={{ width: `${percentThrough}%` }}\n                      />\n                    </div>\n                  </div>\n                )}\n\n                {questions.map((question, index) => (\n                  <QuestionnaireItem\n                    key={index}\n                    name={question.name}\n                    required\n                    multiple={Array.isArray(question.answer)}\n                  >\n                    <QuestionnaireTitle className=\"text-xl font-medium text-foreground\">\n                      {question.title}\n                    </QuestionnaireTitle>\n                    {question.description && (\n                      <QuestionnaireDescription className=\"text-base leading-relaxed\">\n                        {question.description}\n                      </QuestionnaireDescription>\n                    )}\n                    <QuestionnaireChoices>\n                      {question.choices?.map((choice, choiceIndex) => (\n                        <QuestionnaireChoice\n                          key={choiceIndex}\n                          value={choice.value}\n                          className=\"rounded-md border-border p-4 text-base\"\n                        >\n                          <span className=\"font-medium text-foreground\">{choice.label}</span>\n                          {choice.description && (\n                            <QuestionnaireChoiceDescription className=\"text-sm\">\n                              {choice.description}\n                            </QuestionnaireChoiceDescription>\n                          )}\n                        </QuestionnaireChoice>\n                      ))}\n                    </QuestionnaireChoices>\n                    <QuestionnaireError className=\"text-sm\" />\n                  </QuestionnaireItem>\n                ))}\n\n                <QuestionnaireActions>\n                  <QuestionnairePrevious className=\"cursor-pointer rounded-md border-border text-sm font-medium\">\n                    {previousLabel}\n                  </QuestionnairePrevious>\n                  <QuestionnaireNext className=\"cursor-pointer rounded-md bg-primary text-sm font-medium text-primary-foreground hover:bg-primary/90\">\n                    {nextLabel}\n                  </QuestionnaireNext>\n                  <QuestionnaireSubmit className=\"cursor-pointer rounded-md bg-primary text-sm font-medium text-primary-foreground hover:bg-primary/90\">\n                    {submitLabel}\n                  </QuestionnaireSubmit>\n                </QuestionnaireActions>\n              </Questionnaire>\n            </>\n          )}\n        </div>\n\n        {resources.length > 0 && (\n          <div className=\"mt-12 md:mt-16\">\n            {resourcesTitle && (\n              <p className=\"text-xl font-medium text-foreground\">{resourcesTitle}</p>\n            )}\n            <div className=\"mt-6\">\n              {resources.map((resource, index) => (\n                <Link\n                  key={index}\n                  href={resource.href}\n                  className=\"group/education102 flex items-start justify-between gap-6 border-b border-border py-5 first:border-t\"\n                >\n                  <div className=\"min-w-0\">\n                    <p className=\"text-lg font-medium text-foreground\">{resource.title}</p>\n                    <p className=\"mt-1 text-sm leading-relaxed text-muted-foreground\">\n                      {resource.description}\n                    </p>\n                  </div>\n                  <ArrowUpRight\n                    className=\"mt-1 size-4 shrink-0 text-muted-foreground transition-transform motion-safe:group-hover/education102:-translate-y-0.5 motion-safe:group-hover/education102:translate-x-0.5\"\n                    aria-hidden=\"true\"\n                  />\n                </Link>\n              ))}\n            </div>\n          </div>\n        )}\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/beste/block/education102.tsx"
    },
    {
      "path": "registry-components/badge23/badge23.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\n\ntype Tone = \"muted\" | \"foreground\" | \"primary\";\n\ninterface Badge23Props {\n  /** Eyebrow label */\n  label: string;\n  /** Text/border tone */\n  tone?: Tone;\n  /** Additional classes merged onto the root */\n  className?: string;\n}\n\nconst toneStyles: Record<Tone, string> = {\n  muted: \"border-border text-muted-foreground\",\n  foreground: \"border-foreground/30 text-foreground\",\n  primary: \"border-primary/40 text-primary\",\n};\n\nexport const badge23Demo: Badge23Props = {\n  label: \"Product\",\n};\n\nexport function Badge23({ label, tone = \"muted\", className }: Badge23Props) {\n  return (\n    <span\n      className={cn(\n        \"inline-flex items-center rounded-md border bg-transparent px-2.5 py-1 text-sm font-medium leading-none\",\n        toneStyles[tone],\n        className\n      )}\n    >\n      {label}\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/beste/component/badge23.tsx"
    },
    {
      "path": "registry-components/button21/button21.tsx",
      "content": "\"use client\";\n\nimport type { LucideIcon } from \"lucide-react\";\nimport * as React from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\n\ntype Tone = \"primary\" | \"neutral\" | \"outline\";\n\ninterface Button21Props {\n  /** Button label */\n  label: string;\n  /**\n   * Compose the rendered element shadcn-style (radix asChild): your element\n   * (e.g. a router Link) becomes the root and the button content is injected\n   * as its children. Pass the element without children of its own.\n   */\n  asChild?: boolean;\n  /** The element to render when `asChild` is set (e.g. your framework's Link) */\n  children?: React.ReactElement;\n  /**\n   * Fallback link: renders a plain `<a>`. Prefer `asChild` with your\n   * framework's Link component for client-side navigation.\n   */\n  href?: string;\n  /** Optional trailing icon */\n  icon?: LucideIcon;\n  /** Surface tone: solid accent (default), soft neutral pill, or hairline outline */\n  tone?: Tone;\n  /** Click handler (used when there is no href and no asChild) */\n  onClick?: React.MouseEventHandler<HTMLButtonElement>;\n  /** Additional classes merged onto the button */\n  className?: string;\n}\n\nconst toneStyles: Record<Tone, string> = {\n  primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n  neutral: \"bg-muted text-foreground hover:bg-muted/70\",\n  outline: \"border border-border bg-transparent text-foreground hover:bg-muted\",\n};\n\nexport const button21Demo: Button21Props = {\n  label: \"Book a demo\",\n};\n\nexport function Button21({\n  label,\n  asChild = false,\n  children,\n  href,\n  icon: Icon,\n  tone = \"primary\",\n  onClick,\n  className,\n}: Button21Props) {\n  const classes = cn(\n    \"group/button21 h-auto w-fit gap-2 rounded-md px-5 py-2.5 text-sm font-medium tracking-tight transition-colors\",\n    toneStyles[tone],\n    className\n  );\n\n  const inner = (\n    <>\n      {label}\n      {Icon && (\n        <Icon className=\"size-4 transition-transform motion-safe:group-hover/button21:translate-x-0.5\" />\n      )}\n    </>\n  );\n\n  if (asChild && React.isValidElement(children)) {\n    return (\n      <Button asChild className={classes}>\n        {React.cloneElement(children, undefined, inner)}\n      </Button>\n    );\n  }\n\n  if (href) {\n    return (\n      <Button asChild className={classes}>\n        <a href={href}>{inner}</a>\n      </Button>\n    );\n  }\n\n  return (\n    <Button type=\"button\" className={classes} onClick={onClick}>\n      {inner}\n    </Button>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/beste/component/button21.tsx"
    }
  ],
  "type": "registry:block"
}