{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "questionnaire",
  "type": "registry:ui",
  "title": "Questionnaire",
  "description": "Questionnaire provides its canonical documented behavior.",
  "dependencies": [
    "lucide-react@0.561.0"
  ],
  "registryDependencies": [
    "https://ghost-ui.com/r/ghost-tokens.json",
    "https://ghost-ui.com/r/button.json",
    "https://ghost-ui.com/r/button-group.json",
    "https://ghost-ui.com/r/checkbox.json",
    "https://ghost-ui.com/r/checkbox-group.json",
    "https://ghost-ui.com/r/field.json",
    "https://ghost-ui.com/r/fieldset.json",
    "https://ghost-ui.com/r/input.json",
    "https://ghost-ui.com/r/progress.json",
    "https://ghost-ui.com/r/radio-group.json",
    "https://ghost-ui.com/r/textarea.json",
    "https://ghost-ui.com/r/chat-model.json",
    "https://ghost-ui.com/r/foundation.json",
    "https://ghost-ui.com/r/layer-card.json",
    "https://ghost-ui.com/r/composer.json"
  ],
  "files": [
    {
      "path": "src/components/ui/questionnaire.tsx",
      "type": "registry:component",
      "target": "@ui/questionnaire.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { ArrowLeft, ArrowRight, OctagonAlert, X } from \"lucide-react\";\n\nimport { Button } from \"./button\";\nimport { IconButton } from \"./button\";\nimport { Checkbox } from \"./checkbox\";\nimport { CheckboxGroup } from \"./checkbox-group\";\nimport { Field } from \"./field\";\nimport { Fieldset } from \"./fieldset\";\nimport { Input } from \"./input\";\nimport { Kbd } from \"./kbd\";\nimport { RadioGroup } from \"./radio-group\";\nimport { Textarea } from \"./textarea\";\nimport { LayerCard } from \"./layer-card\";\nimport type {\n  QuestionCustomAnswer,\n  QuestionDefinition,\n  QuestionOption,\n  QuestionnaireAnswer,\n  QuestionnaireAnswers,\n  QuestionnaireResponse,\n} from \"./chat-model\";\n\nexport type { QuestionCustomAnswer, QuestionCustomDefinition, QuestionDefinition, QuestionOption, QuestionnaireAnswer, QuestionnaireAnswers, QuestionnaireCustomAnswer, QuestionnaireResponse } from \"./chat-model\";\nimport \"./questionnaire.css\";\nimport \"./composer.css\";\n\nexport type QuestionnaireStatus = \"editing\" | \"submitting\" | \"submitted\" | \"cancelled\" | \"expired\";\n\nexport interface QuestionnaireProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, \"onSubmit\" | \"defaultValue\" | \"onChange\"> {\n  appearance?: \"standalone\" | \"composer\";\n  questions: readonly QuestionDefinition[];\n  value?: QuestionnaireAnswers;\n  defaultValue?: QuestionnaireAnswers;\n  onValueChange?: (value: QuestionnaireAnswers) => void;\n  onSubmit: (response: QuestionnaireResponse) => void | Promise<void>;\n  onCancel?: () => void;\n  status?: QuestionnaireStatus;\n  response?: QuestionnaireResponse;\n  error?: string;\n  label?: string;\n  disabled?: boolean;\n  children?: React.ReactNode;\n}\n\ntype ValidationErrors = Readonly<Record<string, string>>;\n\ninterface SchemaResult {\n  error?: string;\n}\n\ninterface QuestionnaireContextValue {\n  questions: readonly QuestionDefinition[];\n  currentQuestion?: QuestionDefinition;\n  currentIndex: number;\n  total: number;\n  completed: number;\n  answers: QuestionnaireAnswers;\n  skipped: ReadonlySet<string>;\n  errors: ValidationErrors;\n  busy: boolean;\n  terminal: boolean;\n  waiting: boolean;\n  updateAnswer: (id: string, value: QuestionnaireAnswer | readonly QuestionnaireAnswer[]) => void;\n  toggleSkip: () => void;\n  goBack: () => void;\n  goNext: () => void;\n  submit: (answerOverride?: QuestionnaireAnswers, skippedOverride?: ReadonlySet<string>) => void;\n  onCancel?: () => void;\n  renderQuestion: (question: QuestionDefinition, region?: \"all\" | \"prompt\" | \"response\") => React.ReactNode;\n  firstQuestionRef: (id: string, node: HTMLElement | null) => void;\n}\n\nconst QuestionnaireContext = React.createContext<QuestionnaireContextValue | null>(null);\n\nfunction useQuestionnaire() {\n  const context = React.useContext(QuestionnaireContext);\n  if (!context) throw new Error(\"Questionnaire parts must be used inside Questionnaire.\");\n  return context;\n}\n\nfunction asAnswerArray(value: QuestionnaireAnswer | readonly QuestionnaireAnswer[] | undefined): readonly QuestionnaireAnswer[] {\n  return Array.isArray(value) ? [...value] : value === undefined ? [] : [value as QuestionnaireAnswer];\n}\n\nconst hasOwn = (value: object, key: string) => Object.prototype.hasOwnProperty.call(value, key);\n\nfunction ownValue<T>(value: object | undefined, key: string): T | undefined {\n  return value && hasOwn(value, key) ? (value as Record<string, T>)[key] : undefined;\n}\n\nfunction setOwn<T extends object>(target: T, key: string, value: unknown) {\n  Object.defineProperty(target, key, { configurable: true, enumerable: true, writable: true, value });\n  return target;\n}\n\nfunction customEnabled(question: QuestionDefinition) {\n  return Boolean(question.custom);\n}\n\nfunction customDefinition(question: QuestionDefinition) {\n  return typeof question.custom === \"object\" ? question.custom : undefined;\n}\n\nfunction customAnswerId(question: QuestionDefinition) {\n  return `custom:${question.id}`;\n}\n\nfunction isCustomAnswer(value: unknown): value is QuestionCustomAnswer {\n  return Boolean(value && typeof value === \"object\" && (value as Partial<QuestionCustomAnswer>).type === \"custom\" && typeof (value as Partial<QuestionCustomAnswer>).value === \"string\");\n}\n\nfunction createCustomAnswer(question: QuestionDefinition, value: string): QuestionCustomAnswer {\n  return { type: \"custom\", id: customAnswerId(question), value };\n}\n\nfunction canonicalAnswer(question: QuestionDefinition, value: unknown): QuestionnaireAnswer | undefined {\n  if (typeof value === \"string\") {\n    if (question.kind === \"text\" || question.options?.some((option) => option.value === value)) return value;\n    return undefined;\n  }\n  if (customEnabled(question) && isCustomAnswer(value)) {\n    if (!value.value) return undefined;\n    return createCustomAnswer(question, value.value);\n  }\n  return undefined;\n}\n\nfunction normalizeAnswers(questions: readonly QuestionDefinition[], answers: QuestionnaireAnswers | undefined): QuestionnaireAnswers {\n  if (!answers) return {};\n  const known = new Map(questions.map((question) => [question.id, question]));\n  const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = {};\n  for (const id of Object.keys(answers)) {\n    const raw = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, id);\n    const question = known.get(id);\n    if (!question) continue;\n    if (question.kind === \"multiple\") {\n      if (Array.isArray(raw)) {\n        const values = raw.map((value) => canonicalAnswer(question, value)).filter((value): value is QuestionnaireAnswer => value !== undefined);\n        if (values.length) setOwn(next, id, values);\n      }\n      continue;\n    }\n    const value = canonicalAnswer(question, raw);\n    if (value !== undefined) setOwn(next, id, value);\n  }\n  return next;\n}\n\nfunction reconcileAnswers(\n  questions: readonly QuestionDefinition[],\n  answers: QuestionnaireAnswers | undefined,\n  previousQuestions: readonly QuestionDefinition[] | undefined,\n  droppedKinds: ReadonlySet<string>,\n) {\n  const previousKinds = new Map((previousQuestions ?? []).map((question) => [question.id, question.kind]));\n  const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = {};\n  for (const question of questions) {\n    if (droppedKinds.has(question.id) || previousKinds.get(question.id) !== undefined && previousKinds.get(question.id) !== question.kind) continue;\n    const raw = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n    if (question.kind === \"multiple\" && Array.isArray(raw)) {\n      const values = raw.map((value) => canonicalAnswer(question, value)).filter((value): value is QuestionnaireAnswer => value !== undefined);\n      if (values.length) setOwn(next, question.id, values);\n    }\n    if (question.kind !== \"multiple\") {\n      const value = canonicalAnswer(question, raw);\n      if (value !== undefined) setOwn(next, question.id, value);\n    }\n  }\n  return next;\n}\n\nfunction answerEqual(left: QuestionnaireAnswer | readonly QuestionnaireAnswer[] | undefined, right: QuestionnaireAnswer | readonly QuestionnaireAnswer[] | undefined): boolean {\n  if (Array.isArray(left) || Array.isArray(right)) {\n    if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n    return left.every((value, index) => answerEqual(value, right[index]));\n  }\n  const leftAnswer = left as QuestionnaireAnswer | undefined;\n  const rightAnswer = right as QuestionnaireAnswer | undefined;\n  if (isCustomAnswer(leftAnswer) || isCustomAnswer(rightAnswer)) {\n    return isCustomAnswer(leftAnswer) && isCustomAnswer(rightAnswer) && leftAnswer.id === rightAnswer.id && leftAnswer.value === rightAnswer.value;\n  }\n  return left === right;\n}\n\nfunction answersEqual(questions: readonly QuestionDefinition[], left: QuestionnaireAnswers, right: QuestionnaireAnswers) {\n  return questions.every((question) => hasOwn(left, question.id) === hasOwn(right, question.id)\n    && answerEqual(ownValue(left, question.id), ownValue(right, question.id)));\n}\n\nfunction questionsSignature(questions: readonly QuestionDefinition[]) {\n  return JSON.stringify(questions.map((question) => ({\n    id: question.id,\n    title: question.title,\n    description: question.description,\n    required: question.required,\n    kind: question.kind,\n    options: question.options?.map((option) => ({ value: option.value, label: option.label, description: option.description, disabled: option.disabled })),\n    placeholder: question.placeholder,\n    maxLength: question.maxLength,\n    minSelections: question.minSelections,\n    maxSelections: question.maxSelections,\n    custom: question.custom,\n  })));\n}\n\nfunction schemaError(questions: readonly QuestionDefinition[]): SchemaResult {\n  const ids = new Set<string>();\n  for (const question of questions) {\n    if (!question.id || ids.has(question.id)) return { error: \"Question ids must be unique.\" };\n    ids.add(question.id);\n    if (!question.title || !question.kind) return { error: \"Each question needs a title and kind.\" };\n    if (question.kind !== \"single\" && question.kind !== \"multiple\" && question.kind !== \"text\") return { error: `Question “${question.title}” has an unsupported kind.` };\n    if (question.kind === \"text\") {\n      if (question.options?.length) return { error: `Text question “${question.title}” cannot define options.` };\n      if (question.custom) return { error: `Custom choice answers belong only to single- and multiple-choice questions.` };\n      if (question.minSelections !== undefined || question.maxSelections !== undefined) {\n        return { error: `Selection limits belong only to multiple-choice questions.` };\n      }\n      if (question.maxLength !== undefined && (!Number.isInteger(question.maxLength) || question.maxLength < 0 || question.required && question.maxLength === 0)) {\n        return { error: `The maximum length for “${question.title}” is invalid.` };\n      }\n      continue;\n    }\n    const customMaxLength = customDefinition(question)?.maxLength;\n    if (customMaxLength !== undefined && (!Number.isInteger(customMaxLength) || customMaxLength < 0)) {\n      return { error: `The custom answer length for “${question.title}” is invalid.` };\n    }\n    if (!question.options?.length) return { error: `Question “${question.title}” needs at least one option.` };\n    const optionValues = new Set<string>();\n    for (const option of question.options) {\n      if (!option.value || optionValues.has(option.value)) return { error: `Option values for “${question.title}” must be unique.` };\n      optionValues.add(option.value);\n    }\n    if (question.required && question.options.every((option) => option.disabled)) return { error: `Question “${question.title}” has no selectable options.` };\n    if (question.kind === \"single\" && (question.minSelections !== undefined || question.maxSelections !== undefined)) {\n      return { error: `Selection limits belong only to multiple-choice questions.` };\n    }\n    const enabledCount = question.options.filter((option) => !option.disabled).length;\n    if (question.maxSelections === 0 || question.minSelections !== undefined && question.minSelections > enabledCount) {\n      return { error: `Selection limits for “${question.title}” are impossible.` };\n    }\n    const min = question.minSelections ?? 0;\n    const max = question.maxSelections ?? question.options.length;\n    if (!Number.isInteger(min) || !Number.isInteger(max) || min < 0 || max < 0 || min > max || max > question.options.length) {\n      return { error: `Selection limits for “${question.title}” are impossible.` };\n    }\n  }\n  return {};\n}\n\nfunction optionValues(question: QuestionDefinition) {\n  return new Set((question.options ?? []).map((option) => option.value));\n}\n\nfunction questionError(question: QuestionDefinition, raw: QuestionnaireAnswer | readonly QuestionnaireAnswer[] | undefined, skipped: boolean) {\n  if (skipped && !question.required) return undefined;\n  const validOptions = optionValues(question);\n  if (question.kind === \"text\") {\n    const value = typeof raw === \"string\" ? raw : \"\";\n    if (question.required && !value.trim()) return \"Enter an answer.\";\n    if (question.maxLength !== undefined && value.length > question.maxLength) return `Use ${question.maxLength} characters or fewer.`;\n    return undefined;\n  }\n  if (question.kind === \"single\") {\n    if (isCustomAnswer(raw)) {\n      if (!customEnabled(question)) return \"Choose a valid option.\";\n      const maxLength = customDefinition(question)?.maxLength;\n      if (question.required && !raw.value.trim()) return \"Enter an answer.\";\n      if (maxLength !== undefined && raw.value.length > maxLength) return `Use ${maxLength} characters or fewer.`;\n      return undefined;\n    }\n    if (typeof raw !== \"string\" || !raw) return question.required ? \"Choose an option.\" : undefined;\n    if (!validOptions.has(raw)) return \"Choose a valid option.\";\n    if (question.options?.some((option) => option.value === raw && option.disabled)) return \"Choose an available option.\";\n    return undefined;\n  }\n  const values = Array.isArray(raw) ? raw : [];\n  const customValues = values.filter(isCustomAnswer);\n  if (customValues.length > 1) return \"Choose each option once.\";\n  if (customValues.length && !customEnabled(question)) return \"Choose valid options.\";\n  const maxLength = customDefinition(question)?.maxLength;\n  if (customValues.some((value) => question.required && !value.value.trim())) return \"Enter an answer.\";\n  if (maxLength !== undefined && customValues.some((value) => value.value.length > maxLength)) return `Use ${maxLength} characters or fewer.`;\n  const knownValues = values.filter((value): value is string => typeof value === \"string\");\n  if (knownValues.some((value) => !validOptions.has(value))) return \"Choose valid options.\";\n  if (new Set(knownValues).size !== knownValues.length) return \"Choose each option once.\";\n  if (knownValues.some((value) => question.options?.some((option) => option.value === value && option.disabled))) return \"Choose available options.\";\n  const min = Math.max(question.minSelections ?? 0, question.required ? 1 : 0);\n  const max = question.maxSelections ?? question.options?.length ?? 0;\n  if (values.length < min) return `Choose at least ${min} option${min === 1 ? \"\" : \"s\"}.`;\n  if (values.length > max) return `Choose no more than ${max} option${max === 1 ? \"\" : \"s\"}.`;\n  return undefined;\n}\n\nfunction validationFor(questions: readonly QuestionDefinition[], answers: QuestionnaireAnswers, skipped: ReadonlySet<string>, only?: QuestionDefinition) {\n  const result: Record<string, string> = {};\n  for (const question of only ? [only] : questions) {\n    const message = questionError(question, ownValue(answers, question.id), skipped.has(question.id));\n    if (message) setOwn(result, question.id, message);\n  }\n  return result;\n}\n\nfunction displayAnswer(question: QuestionDefinition, value: QuestionnaireAnswer | readonly QuestionnaireAnswer[] | undefined) {\n  if (question.kind === \"text\") return typeof value === \"string\" && value ? value : \"No answer\";\n  const values = asAnswerArray(value);\n  const labels = new Map((question.options ?? []).map((option) => [option.value, option.label]));\n  const result = values.map((item) => isCustomAnswer(item) ? item.value : labels.get(item) ?? item);\n  return result.length ? result.join(\", \") : \"No answer\";\n}\n\nfunction progressCount(\n  questions: readonly QuestionDefinition[],\n  answers: QuestionnaireAnswers,\n  skipped: ReadonlySet<string>,\n  acknowledged = false,\n) {\n  return questions.reduce((count, question) => {\n    if (skipped.has(question.id)) return question.required ? count : count + 1;\n    if (!hasOwn(answers, question.id)) return count;\n    const value = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n    if (questionError(question, value, false)) return count;\n    if (question.kind === \"text\" && typeof value === \"string\" && !acknowledged && !value.trim()) return count;\n    if (question.kind === \"multiple\" && Array.isArray(value) && !acknowledged && value.length === 0) return count;\n    return count + 1;\n  }, 0);\n}\n\nexport const QuestionnaireProgress = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n  function QuestionnaireProgress({ className, ...props }, ref) {\n    const context = useQuestionnaire();\n    return (\n      <div {...props} ref={ref} className={[\"ui-questionnaire__progress\", className].filter(Boolean).join(\" \")} aria-label={`Question ${Math.min(context.currentIndex + 1, context.total)} of ${context.total}`}>\n        {context.total ? `${Math.min(context.currentIndex + 1, context.total)}/${context.total}` : \"0/0\"}\n      </div>\n    );\n  },\n);\n\nexport interface QuestionnaireItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  id: string;\n  children?: React.ReactNode | ((question: QuestionDefinition) => React.ReactNode);\n}\n\nexport const QuestionnaireItem = React.forwardRef<HTMLDivElement, QuestionnaireItemProps>(function QuestionnaireItem(\n  { id, children, className, ...props },\n  ref,\n) {\n  const context = useQuestionnaire();\n  const question = context.currentQuestion?.id === id ? context.currentQuestion : undefined;\n  if (!question) return null;\n  return (\n    <div {...props} ref={ref} className={[\"ui-questionnaire__item\", className].filter(Boolean).join(\" \")}>\n      {typeof children === \"function\" ? children(question) : children ?? context.renderQuestion(question)}\n    </div>\n  );\n});\n\nexport const QuestionnaireActions = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(function QuestionnaireActions(\n  { className, ...props },\n  ref,\n) {\n  const context = useQuestionnaire();\n  const current = context.currentQuestion;\n  if (!current || context.terminal) return null;\n  const last = context.currentIndex === context.total - 1;\n  return (\n    <div aria-label=\"Question navigation\" {...props} ref={ref} className={[\"ui-questionnaire__actions\", className].filter(Boolean).join(\" \")}>\n      <div className=\"ui-questionnaire__back\">\n        {context.onCancel ? <IconButton type=\"button\" variant=\"ghost\" shape=\"circle\" size=\"icon\" aria-label=\"Close questionnaire\" icon={<X aria-hidden=\"true\" />} onClick={context.onCancel} /> : null}\n        <IconButton type=\"button\" variant=\"ghost\" shape=\"circle\" size=\"icon\" aria-label=\"Go back\" icon={<ArrowLeft aria-hidden=\"true\" />} onClick={context.goBack} disabled={context.currentIndex === 0 || context.busy} />\n        <QuestionnaireProgress />\n        {!current.required ? <Button type=\"button\" variant=\"ghost\" onClick={context.toggleSkip} disabled={context.busy}>Skip</Button> : null}\n      </div>\n      {last ? (\n        <IconButton key=\"submit\" type=\"submit\" variant=\"solid\" shape=\"circle\" size=\"icon\" aria-label=\"Submit answers\" icon={<ArrowRight aria-hidden=\"true\" />} disabled={context.busy} loading={context.busy} />\n      ) : (\n        <IconButton key=\"next\" type=\"button\" variant=\"solid\" shape=\"circle\" size=\"icon\" aria-label=\"Next question\" icon={<ArrowRight aria-hidden=\"true\" />} onClick={(event) => { event.preventDefault(); context.goNext(); }} disabled={context.busy} />\n      )}\n    </div>\n  );\n});\n\nexport const Questionnaire = React.forwardRef<HTMLFormElement, QuestionnaireProps>(function Questionnaire(\n  {\n    appearance = \"standalone\",\n    questions,\n    value,\n    defaultValue,\n    onValueChange,\n    onSubmit,\n    onCancel,\n    status,\n    response,\n    error,\n    label = \"Questionnaire\",\n    disabled = false,\n    children,\n    className,\n    onReset,\n    ...props\n  },\n  ref,\n) {\n  const schema = React.useMemo(() => schemaError(questions), [questions]);\n  const controlled = value !== undefined;\n  const [uncontrolledAnswers, setUncontrolledAnswers] = React.useState<QuestionnaireAnswers>(() => normalizeAnswers(questions, defaultValue));\n  const [customDrafts, setCustomDrafts] = React.useState<Record<string, string>>(() => {\n    const seed = normalizeAnswers(questions, defaultValue ?? value);\n    const init: Record<string, string> = {};\n    for (const question of questions) {\n      const raw = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(seed, question.id);\n      const custom = question.kind === \"multiple\" && Array.isArray(raw) ? raw.find(isCustomAnswer) : isCustomAnswer(raw) ? raw : undefined;\n      if (custom) init[question.id] = custom.value;\n    }\n    return init;\n  });\n  const [skipped, setSkipped] = React.useState<ReadonlySet<string>>(new Set());\n  const [currentIndex, setCurrentIndex] = React.useState(0);\n  const [validation, setValidation] = React.useState<ValidationErrors>({});\n  const [formError, setFormError] = React.useState<string | undefined>();\n  const [submitting, setSubmitting] = React.useState(false);\n  const [localStatus, setLocalStatus] = React.useState<QuestionnaireStatus>(\"editing\");\n  const [localResponse, setLocalResponse] = React.useState<QuestionnaireResponse | undefined>();\n  const [waiting, setWaiting] = React.useState(false);\n  const token = React.useRef(0);\n  const submissionLock = React.useRef(false);\n  const mounted = React.useRef(true);\n  const activeQuestionId = React.useRef<string | undefined>(questions[0]?.id);\n  const instanceId = React.useId().replace(/:/g, \"\");\n  const questionRefs = React.useRef<Record<string, HTMLElement | null>>(Object.create(null));\n  const previousQuestions = React.useRef(questions);\n  const previousQuestionSignature = React.useRef(questionsSignature(questions));\n  const droppedKinds = React.useRef<Set<string>>(new Set());\n  const previousControlled = React.useRef(controlled);\n  const previousControlledAnswers = React.useRef(normalizeAnswers(questions, value));\n  const currentQuestionSignature = questionsSignature(questions);\n  const previousControlledQuestionSignature = React.useRef(currentQuestionSignature);\n  const answerInput = controlled ? value : uncontrolledAnswers;\n  const answers = reconcileAnswers(questions, answerInput, previousQuestions.current, droppedKinds.current);\n  const controlledStatus = status !== undefined;\n  const currentQuestion = questions[currentIndex];\n  const formStatus = controlledStatus ? status! : localStatus;\n  const terminalStatus = formStatus === \"submitted\" || formStatus === \"cancelled\" || formStatus === \"expired\";\n  const externallySubmitting = status === \"submitting\";\n  const busy = disabled || submitting || externallySubmitting || waiting;\n  const terminal = disabled || terminalStatus;\n  const effectiveResponse = response ?? (!controlledStatus && formStatus === \"submitted\" ? localResponse : undefined);\n  const isSubmitted = formStatus === \"submitted\";\n  const readOnlyResponse = isSubmitted ? effectiveResponse : undefined;\n\n  React.useEffect(() => {\n    mounted.current = true;\n    return () => {\n      mounted.current = false;\n      token.current += 1;\n      submissionLock.current = false;\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (previousQuestionSignature.current === currentQuestionSignature) return;\n    const prior = previousQuestions.current;\n    const changedKinds = new Set<string>();\n    for (const question of questions) {\n      if (prior.find((candidate) => candidate.id === question.id)?.kind !== undefined\n        && prior.find((candidate) => candidate.id === question.id)?.kind !== question.kind) changedKinds.add(question.id);\n    }\n    droppedKinds.current = changedKinds;\n    token.current += 1;\n    submissionLock.current = false;\n    setSubmitting(false);\n    setWaiting(false);\n    setFormError(undefined);\n    const next = reconcileAnswers(questions, controlled ? value : uncontrolledAnswers, prior, droppedKinds.current);\n    if (!controlled) setUncontrolledAnswers(next);\n    setSkipped((current) => new Set([...current].filter((id) => questions.some((question) => question.id === id))));\n    setCurrentIndex((index) => {\n      const stableIndex = activeQuestionId.current ? questions.findIndex((question) => question.id === activeQuestionId.current) : -1;\n      const nextIndex = stableIndex >= 0 ? stableIndex : Math.min(Math.max(index, 0), Math.max(questions.length - 1, 0));\n      activeQuestionId.current = questions[nextIndex]?.id;\n      return nextIndex;\n    });\n    setValidation({});\n    previousQuestions.current = questions;\n    previousQuestionSignature.current = currentQuestionSignature;\n  }, [controlled, currentQuestionSignature, questions, uncontrolledAnswers, value]);\n\n  React.useEffect(() => {\n    const nextAnswers = normalizeAnswers(questions, value);\n    const questionChanged = previousControlledQuestionSignature.current !== currentQuestionSignature;\n    const changed = previousControlled.current !== controlled\n      || previousControlled.current && !answersEqual(questions, previousControlledAnswers.current, nextAnswers);\n    if (changed) {\n      token.current += 1;\n      submissionLock.current = false;\n      setSubmitting(false);\n      setWaiting(false);\n      setFormError(undefined);\n      setValidation({});\n      if (!questionChanged) droppedKinds.current.clear();\n    }\n    previousControlled.current = controlled;\n    previousControlledAnswers.current = nextAnswers;\n    previousControlledQuestionSignature.current = currentQuestionSignature;\n  }, [controlled, currentQuestionSignature, questions, value]);\n\n  React.useEffect(() => {\n    if (error) {\n      token.current += 1;\n      submissionLock.current = false;\n      setSubmitting(false);\n      setWaiting(false);\n      setFormError(undefined);\n      if (controlledStatus) setLocalStatus(\"editing\");\n    }\n  }, [controlledStatus, error]);\n\n  React.useEffect(() => {\n    if (status === \"submitted\" || status === \"cancelled\" || status === \"expired\" || disabled) {\n      token.current += 1;\n      submissionLock.current = false;\n      setSubmitting(false);\n      setWaiting(false);\n    }\n    if (status === \"editing\") {\n      token.current += 1;\n      submissionLock.current = false;\n      setWaiting(false);\n      setSubmitting(false);\n      setLocalStatus(\"editing\");\n    }\n  }, [disabled, status]);\n\n  const emitAnswers = React.useCallback((next: QuestionnaireAnswers) => {\n    if (!controlled) setUncontrolledAnswers(next);\n    onValueChange?.(next);\n  }, [controlled, onValueChange]);\n\n  const updateAnswer = React.useCallback((id: string, nextValue: QuestionnaireAnswer | readonly QuestionnaireAnswer[]) => {\n    if (busy || terminal) return;\n    droppedKinds.current.delete(id);\n    const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = { ...answers };\n    setOwn(next, id, Array.isArray(nextValue) ? [...nextValue] : nextValue);\n    const nextSkipped = new Set(skipped);\n    nextSkipped.delete(id);\n    setSkipped(nextSkipped);\n    setValidation((current) => {\n      const copy: Record<string, string> = { ...current };\n      delete copy[id];\n      return copy;\n    });\n    setFormError(undefined);\n    emitAnswers(next);\n  }, [answers, busy, emitAnswers, skipped, terminal]);\n\n  const updateCustomAnswer = React.useCallback((question: QuestionDefinition, value: string) => {\n    if (busy || terminal) return;\n    if (value) {\n      setCustomDrafts((current) => (current[question.id] === value ? current : { ...current, [question.id]: value }));\n    } else {\n      setCustomDrafts((current) => {\n        if (!(question.id in current)) return current;\n        const next = { ...current };\n        delete next[question.id];\n        return next;\n      });\n    }\n    const current = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n    if (question.kind === \"multiple\") {\n      const known = asAnswerArray(current).filter((item) => !isCustomAnswer(item));\n      updateAnswer(question.id, value ? [...known, createCustomAnswer(question, value)] : known);\n      return;\n    }\n    if (value) updateAnswer(question.id, createCustomAnswer(question, value));\n    else {\n      const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = { ...answers };\n      delete next[question.id];\n      emitAnswers(next);\n      setValidation((currentErrors) => { const copy = { ...currentErrors }; delete copy[question.id]; return copy; });\n    }\n  }, [answers, busy, emitAnswers, terminal, updateAnswer]);\n\n  const clearCustomAnswer = React.useCallback((question: QuestionDefinition) => {\n    if (busy || terminal) return;\n    setCustomDrafts((current) => {\n      if (!(question.id in current)) return current;\n      const next = { ...current };\n      delete next[question.id];\n      return next;\n    });\n    const current = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n    if (question.kind === \"multiple\") {\n      const known = asAnswerArray(current).filter((item) => !isCustomAnswer(item));\n      updateAnswer(question.id, known);\n    } else if (isCustomAnswer(current)) {\n      const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = { ...answers };\n      delete next[question.id];\n      emitAnswers(next);\n      setValidation((currentErrors) => { const copy = { ...currentErrors }; delete copy[question.id]; return copy; });\n    }\n    window.requestAnimationFrame(() => {\n      questionRefs.current[question.id]?.querySelector<HTMLInputElement>(\"[data-question-custom]\")?.focus();\n    });\n  }, [answers, busy, emitAnswers, terminal, updateAnswer]);\n\n  const focusCustomInput = React.useCallback((id: string) => {\n    window.requestAnimationFrame(() => {\n      questionRefs.current[id]?.querySelector<HTMLInputElement | HTMLTextAreaElement>(\"[data-question-custom]\")?.focus();\n    });\n  }, []);\n\n  const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLFormElement>) => {\n    if (busy || terminal || event.defaultPrevented || event.nativeEvent.isComposing || event.repeat || event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) return;\n    if (!/^[1-9]$/.test(event.key) || !currentQuestion?.options?.length) return;\n    const target = event.target as HTMLElement | null;\n    if (target?.closest(\"input, textarea, select, [contenteditable='true']\")) return;\n    const optionIndex = Number(event.key) - 1;\n    const option = currentQuestion.options[optionIndex];\n    if (!option && customEnabled(currentQuestion) && optionIndex === currentQuestion.options.length) {\n      const customInput = questionRefs.current[currentQuestion.id]?.querySelector<HTMLInputElement | HTMLTextAreaElement>(\"[data-question-custom]\");\n      customInput?.focus();\n      event.preventDefault();\n      return;\n    }\n    if (!option || option.disabled) return;\n    event.preventDefault();\n    if (currentQuestion.kind === \"multiple\") {\n      const selected = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, currentQuestion.id);\n      const values = Array.isArray(selected) ? [...selected] : [];\n      const index = values.findIndex((value) => value === option.value);\n      if (index >= 0) values.splice(index, 1);\n      else values.push(option.value);\n      updateAnswer(currentQuestion.id, values);\n    } else if (currentQuestion.kind === \"single\") {\n      updateAnswer(currentQuestion.id, option.value);\n    }\n  }, [answers, busy, currentQuestion, terminal, updateAnswer]);\n\n  const focusQuestion = React.useCallback((id: string, heading = false) => {\n    window.requestAnimationFrame(() => {\n      const node = questionRefs.current[id];\n      const control = node?.querySelector<HTMLElement>(\"[role='radio'], [role='checkbox'], textarea, input\");\n      const title = node?.querySelector<HTMLElement>(\"[data-question-heading]\");\n      const target = heading ? title ?? control : control ?? title;\n      target?.focus();\n    });\n  }, []);\n\n  const setValidationAndFocus = React.useCallback((next: ValidationErrors) => {\n    setValidation(next);\n    const first = Object.keys(next)[0];\n    if (first) focusQuestion(first);\n  }, [focusQuestion]);\n\n  const goBack = React.useCallback(() => {\n    if (busy || currentIndex <= 0) return;\n    activeQuestionId.current = questions[currentIndex - 1]?.id;\n    setCurrentIndex((index) => index - 1);\n    setValidation({});\n    focusQuestion(questions[currentIndex - 1]?.id, true);\n  }, [busy, currentIndex, focusQuestion, questions]);\n\n  const goNext = React.useCallback(() => {\n    if (busy || !currentQuestion) return;\n    const nextErrors = validationFor(questions, answers, skipped, currentQuestion);\n    if (Object.keys(nextErrors).length) {\n      setValidationAndFocus(nextErrors);\n      return;\n    }\n    if (currentIndex < questions.length - 1) {\n      activeQuestionId.current = questions[currentIndex + 1]?.id;\n      setCurrentIndex((index) => index + 1);\n      setValidation({});\n      focusQuestion(questions[currentIndex + 1]?.id, true);\n    }\n  }, [answers, busy, currentIndex, currentQuestion, focusQuestion, questions, setValidationAndFocus, skipped]);\n\n  const submit = React.useCallback((answerOverride?: QuestionnaireAnswers, skippedOverride?: ReadonlySet<string>) => {\n    if (busy || submissionLock.current || terminal || schema.error || !questions.length) return;\n    const submitAnswers = answerOverride ?? answers;\n    const submitSkipped = skippedOverride ?? skipped;\n    const nextErrors = validationFor(questions, submitAnswers, submitSkipped);\n    if (Object.keys(nextErrors).length) {\n      const firstIndex = questions.findIndex((question) => ownValue<string>(nextErrors, question.id));\n      if (firstIndex >= 0) {\n        activeQuestionId.current = questions[firstIndex]?.id;\n        setCurrentIndex(firstIndex);\n      }\n      setValidationAndFocus(nextErrors);\n      return;\n    }\n    const nextResponse: QuestionnaireResponse = {\n      answers: normalizeAnswers(questions, submitAnswers),\n      skipped: questions.map((question) => question.id).filter((id) => submitSkipped.has(id)),\n    };\n    const requestToken = ++token.current;\n    submissionLock.current = true;\n    setSubmitting(true);\n    setValidation({});\n    setFormError(undefined);\n    let result: void | Promise<void>;\n    try {\n      result = onSubmit(nextResponse);\n    } catch (reason) {\n      result = Promise.reject(reason);\n    }\n    Promise.resolve(result).then(() => {\n      if (!mounted.current || requestToken !== token.current) return;\n      setSubmitting(false);\n      if (controlledStatus) {\n        setWaiting(true);\n      } else {\n        setLocalResponse(nextResponse);\n        setLocalStatus(\"submitted\");\n      }\n    }, (reason: unknown) => {\n      if (!mounted.current || requestToken !== token.current) return;\n      submissionLock.current = false;\n      setSubmitting(false);\n      setFormError(reason instanceof Error ? reason.message : \"The response could not be sent.\");\n    });\n  }, [answers, busy, controlledStatus, onSubmit, questions, schema.error, setValidationAndFocus, skipped, terminal]);\n\n  const toggleSkip = React.useCallback(() => {\n    if (busy || terminal || !currentQuestion || currentQuestion.required) return;\n    const nextSkipped = new Set(skipped);\n    nextSkipped.add(currentQuestion.id);\n    setSkipped(nextSkipped);\n    const next: Record<string, QuestionnaireAnswer | readonly QuestionnaireAnswer[]> = { ...answers };\n    delete next[currentQuestion.id];\n    emitAnswers(next);\n    setValidation({});\n    setFormError(undefined);\n    if (currentIndex < questions.length - 1) {\n      activeQuestionId.current = questions[currentIndex + 1]?.id;\n      setCurrentIndex((index) => index + 1);\n      focusQuestion(questions[currentIndex + 1]?.id, true);\n    } else {\n      submit(next, nextSkipped);\n    }\n  }, [answers, busy, currentIndex, currentQuestion, emitAnswers, focusQuestion, questions, skipped, submit, terminal]);\n\n  const handleReset = React.useCallback((event: React.FormEvent<HTMLFormElement>) => {\n    onReset?.(event);\n    if (event.defaultPrevented) return;\n    event.preventDefault();\n    token.current += 1;\n    submissionLock.current = false;\n    setSubmitting(false);\n    setWaiting(false);\n    setValidation({});\n    setFormError(undefined);\n    setLocalResponse(undefined);\n    droppedKinds.current.clear();\n    setCustomDrafts(() => {\n      const seed = normalizeAnswers(questions, defaultValue);\n      const init: Record<string, string> = {};\n      for (const question of questions) {\n        const raw = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(seed, question.id);\n        const custom = question.kind === \"multiple\" && Array.isArray(raw) ? raw.find(isCustomAnswer) : isCustomAnswer(raw) ? raw : undefined;\n        if (custom) init[question.id] = custom.value;\n      }\n      return init;\n    });\n    if (!controlled) setUncontrolledAnswers(normalizeAnswers(questions, defaultValue));\n    else onValueChange?.(normalizeAnswers(questions, defaultValue));\n    setSkipped(new Set());\n    activeQuestionId.current = questions[0]?.id;\n    setCurrentIndex(0);\n    if (!controlledStatus) setLocalStatus(\"editing\");\n  }, [controlled, controlledStatus, defaultValue, onReset, onValueChange, questions]);\n\n  const renderQuestion = React.useCallback((question: QuestionDefinition, region: \"all\" | \"prompt\" | \"response\" = \"all\") => {\n    const errorMessage = ownValue<string>(validation, question.id);\n    const questionDomId = `${instanceId}-${encodeURIComponent(question.id)}`;\n    const describedBy = [question.description ? `${questionDomId}-description` : \"\", errorMessage ? `${questionDomId}-error` : \"\"].filter(Boolean).join(\" \") || undefined;\n    const questionProps = {\n      \"data-question-id\": question.id,\n      ref: region === \"all\" ? (node: HTMLElement | null) => { questionRefs.current[question.id] = node; } : undefined,\n    };\n    if (question.kind === \"single\" || question.kind === \"multiple\") {\n      const legend = <><Fieldset.Legend data-question-heading tabIndex={-1}>{question.title}</Fieldset.Legend>{question.description ? <p id={`${questionDomId}-description`} className=\"ui-questionnaire__description\">{question.description}</p> : null}</>;\n      const selectedValue = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n      const selectedList = Array.isArray(selectedValue) ? selectedValue : [];\n      const answerCustomValue = question.kind === \"single\"\n        ? (isCustomAnswer(selectedValue) ? selectedValue.value : undefined)\n        : selectedList.find(isCustomAnswer)?.value;\n      const customDraft = customDrafts[question.id];\n      const displayCustom = answerCustomValue ?? customDraft ?? \"\";\n      const customId = customAnswerId(question);\n      const customIndex = question.options?.length ?? 0;\n      const customDisabled = busy || terminal;\n      const selectSingle = (next: string) => {\n        if (next === customId) {\n          if (displayCustom) updateAnswer(question.id, createCustomAnswer(question, displayCustom));\n          else focusCustomInput(question.id);\n          return;\n        }\n        updateAnswer(question.id, next);\n      };\n      const selectMultiple = (next: string[]) => {\n        const customChecked = next.includes(customId);\n        const knownNext = next.filter((item) => item !== customId);\n        const draftValue = customDrafts[question.id] ?? answerCustomValue ?? \"\";\n        if (customChecked) {\n          if (draftValue) updateAnswer(question.id, [...knownNext, createCustomAnswer(question, draftValue)]);\n          else {\n            updateAnswer(question.id, knownNext);\n            focusCustomInput(question.id);\n          }\n          return;\n        }\n        updateAnswer(question.id, knownNext);\n      };\n      const choices = question.kind === \"single\" ? (\n        <RadioGroup\n            aria-label={question.title}\n            aria-describedby={describedBy}\n            aria-required={question.required || undefined}\n            aria-invalid={errorMessage ? true : undefined}\n            data-question-control=\"true\"\n            disabled={busy || terminal}\n            value={typeof selectedValue === \"string\" ? selectedValue : isCustomAnswer(selectedValue) ? customId : \"\"}\n            onValueChange={selectSingle}\n          >\n            <RadioGroup.Rows inset={0}>{question.options?.map((option, index) => <ChoiceRadio key={option.value} option={option} index={index} />)}{region === \"all\" && customEnabled(question) ? <CustomSingleOption question={question} value={displayCustom} index={customIndex} disabled={customDisabled} onChange={(next) => updateCustomAnswer(question, next)} onClear={() => clearCustomAnswer(question)} /> : null}</RadioGroup.Rows>\n          </RadioGroup>\n      ) : null;\n      const selected = selectedList;\n      const knownStrings = selected.filter((item): item is string => typeof item === \"string\");\n      const hasCustomSelected = selected.some(isCustomAnswer);\n      const multipleChoices = (\n        <CheckboxGroup\n            aria-label={question.title}\n            aria-describedby={describedBy}\n            aria-required={question.required || undefined}\n            aria-invalid={errorMessage ? true : undefined}\n            data-question-control=\"true\"\n            disabled={busy || terminal}\n            value={[...knownStrings, ...(hasCustomSelected ? [customId] : [])]}\n            onValueChange={(next) => selectMultiple(next as string[])}\n          >\n            <CheckboxGroup.Rows inset={0}>{question.options?.map((option, index) => <ChoiceCheckbox key={option.value} option={option} index={index} />)}{region === \"all\" && customEnabled(question) ? <CustomMultipleOption question={question} value={displayCustom} index={customIndex} disabled={customDisabled} onChange={(next) => updateCustomAnswer(question, next)} onClear={() => clearCustomAnswer(question)} /> : null}</CheckboxGroup.Rows>\n          </CheckboxGroup>\n      );\n      const optionControls = question.kind === \"single\" ? choices : multipleChoices;\n      if (region === \"response\") return <>{customEnabled(question) ? <CustomChoiceRow question={question} value={displayCustom} index={customIndex} disabled={customDisabled} onChange={(next) => updateCustomAnswer(question, next)} onClear={() => clearCustomAnswer(question)} /> : null}{errorMessage ? <Field.Error match id={`${questionDomId}-error`}>{errorMessage}</Field.Error> : null}</>;\n      const content = (\n        <Fieldset.Root {...questionProps} className=\"ui-questionnaire__fieldset\" disabled={busy || terminal}>\n          {legend}\n          {optionControls}\n          {region === \"all\" && errorMessage ? <Field.Error match id={`${questionDomId}-error`}>{errorMessage}</Field.Error> : null}\n        </Fieldset.Root>\n      );\n      return region === \"all\" ? <Field.Root invalid={Boolean(errorMessage)} disabled={busy || terminal}>{content}</Field.Root> : content;\n    }\n    const answerValue = ownValue<QuestionnaireAnswer | readonly QuestionnaireAnswer[]>(answers, question.id);\n    const value = typeof answerValue === \"string\" ? answerValue : \"\";\n    const useTextarea = (question.maxLength ?? 0) > 160;\n    const controlId = `${questionDomId}-control`;\n    if (region === \"prompt\") return <div data-question-id={question.id}><Field.Label htmlFor={controlId} data-question-heading tabIndex={-1}>{question.title}</Field.Label>{question.description ? <Field.Description id={`${questionDomId}-description`}>{question.description}</Field.Description> : null}</div>;\n    if (region === \"response\") return <>{useTextarea ? <Field.Control render={<Textarea id={controlId} variant=\"ghost\" data-question-control=\"true\" disabled={busy || terminal} aria-required={question.required || undefined} aria-describedby={describedBy} aria-invalid={errorMessage ? true : undefined} value={value} onChange={(event) => updateAnswer(question.id, event.target.value)} placeholder={question.placeholder} maxLength={question.maxLength} />} /> : <Field.Control render={<Input id={controlId} variant=\"ghost\" data-question-control=\"true\" disabled={busy || terminal} aria-required={question.required || undefined} aria-describedby={describedBy} aria-invalid={errorMessage ? true : undefined} value={value} onChange={(event) => updateAnswer(question.id, event.target.value)} placeholder={question.placeholder} maxLength={question.maxLength} />} />}{errorMessage ? <Field.Error match id={`${questionDomId}-error`}>{errorMessage}</Field.Error> : null}</>;\n    return (\n      <Field.Root {...questionProps} className=\"ui-questionnaire__field\" invalid={Boolean(errorMessage)} disabled={busy || terminal}>\n        <Field.Label data-question-heading tabIndex={-1}>{question.title}</Field.Label>\n        {question.description ? <Field.Description id={`${questionDomId}-description`}>{question.description}</Field.Description> : null}\n        {useTextarea ? <Field.Control render={<Textarea id={controlId} variant=\"ghost\" data-question-control=\"true\" disabled={busy || terminal} aria-required={question.required || undefined} aria-describedby={describedBy} aria-invalid={errorMessage ? true : undefined} value={value} onChange={(event) => updateAnswer(question.id, event.target.value)} placeholder={question.placeholder} maxLength={question.maxLength} />} /> : <Field.Control render={<Input id={controlId} variant=\"ghost\" data-question-control=\"true\" disabled={busy || terminal} aria-required={question.required || undefined} aria-describedby={describedBy} aria-invalid={errorMessage ? true : undefined} value={value} onChange={(event) => updateAnswer(question.id, event.target.value)} placeholder={question.placeholder} maxLength={question.maxLength} />} />}\n        {errorMessage ? <Field.Error match id={`${questionDomId}-error`}>{errorMessage}</Field.Error> : null}\n      </Field.Root>\n    );\n  }, [answers, busy, clearCustomAnswer, customDrafts, focusCustomInput, instanceId, terminal, updateAnswer, updateCustomAnswer, validation]);\n\n  const context = React.useMemo<QuestionnaireContextValue>(() => ({\n    questions,\n    currentQuestion,\n    currentIndex,\n    total: questions.length,\n    completed: isSubmitted && effectiveResponse\n      ? progressCount(questions, normalizeAnswers(questions, effectiveResponse.answers), new Set(effectiveResponse.skipped), true)\n      : progressCount(questions, answers, skipped),\n    answers,\n    skipped,\n    errors: validation,\n    busy,\n    terminal,\n    waiting,\n    updateAnswer,\n    toggleSkip,\n    goBack,\n    goNext,\n    submit,\n    onCancel,\n    renderQuestion,\n    firstQuestionRef: (id, node) => { questionRefs.current[id] = node; },\n  }), [answers, busy, currentIndex, currentQuestion, effectiveResponse, goBack, goNext, isSubmitted, onCancel, questions, renderQuestion, skipped, submit, terminal, toggleSkip, updateAnswer, validation, waiting]);\n\n  const currentError = currentQuestion ? ownValue<string>(validation, currentQuestion.id) : undefined;\n\n  return (\n    <QuestionnaireContext.Provider value={context}>\n      <form\n        {...props}\n        ref={ref}\n        aria-label={label}\n        aria-busy={busy || undefined}\n        className={[\"ui-questionnaire\", className].filter(Boolean).join(\" \")}\n        data-appearance={appearance}\n        data-status={formStatus}\n        onSubmit={(event) => { event.preventDefault(); submit(); }}\n        onKeyDown={handleKeyDown}\n        onReset={handleReset}\n      >\n        {schema.error ? <div className=\"ui-questionnaire__configuration\" role=\"alert\">{schema.error}</div> : null}\n        {!schema.error && !questions.length ? <p className=\"ui-questionnaire__empty\">No questions. <QuestionnaireProgress /></p> : null}\n        {!schema.error && appearance === \"composer\" && (terminalStatus || currentQuestion || children) ? (\n          <div className=\"ui-questionnaire__composer-card\" ref={(node) => { if (currentQuestion) questionRefs.current[currentQuestion.id] = node; }}>\n            {children !== undefined ? (\n              <LayerCard variant=\"basic\" secondaryVisible={false} className=\"ui-questionnaire__composer-layer\">\n                <LayerCard.Primary className=\"ui-questionnaire__composer-primary ui-composer-surface\">{children}</LayerCard.Primary>\n              </LayerCard>\n            ) : currentQuestion && !terminalStatus ? (\n              <Field.Root className=\"ui-questionnaire__composer-field-root\" invalid={Boolean(currentError)} disabled={busy || terminal}>\n                <LayerCard variant=\"basic\" className=\"ui-questionnaire__composer-layer\">\n                  <LayerCard.Secondary className=\"ui-questionnaire__composer-secondary\">{renderQuestion(currentQuestion, \"prompt\")}</LayerCard.Secondary>\n                  <LayerCard.Primary className=\"ui-questionnaire__composer-primary ui-composer-surface\" data-invalid={currentError ? \"true\" : undefined}>\n                    {renderQuestion(currentQuestion, \"response\")}\n                    <QuestionnaireActions />\n                  </LayerCard.Primary>\n                </LayerCard>\n              </Field.Root>\n            ) : (\n              <LayerCard variant=\"basic\" secondaryVisible={false} className=\"ui-questionnaire__composer-layer\">\n                <LayerCard.Primary className=\"ui-questionnaire__composer-primary ui-composer-surface\">\n                  <QuestionnaireRecord\n                    questions={questions}\n                    response={response ?? readOnlyResponse ?? (formStatus === \"submitted\" ? undefined : { answers, skipped: [...skipped] })}\n                    status={formStatus === \"submitted\" || formStatus === \"cancelled\" || formStatus === \"expired\" ? formStatus : \"unavailable\"}\n                  />\n                </LayerCard.Primary>\n              </LayerCard>\n            )}\n          </div>\n        ) : null}\n        {!schema.error && appearance === \"standalone\" && (terminalStatus || currentQuestion || children) ? <div className=\"ui-questionnaire__card\">\n          {terminalStatus ? (\n            <QuestionnaireRecord\n              questions={questions}\n              response={response ?? readOnlyResponse ?? (formStatus === \"submitted\" ? undefined : { answers, skipped: [...skipped] })}\n              status={formStatus}\n            />\n          ) : children ?? (currentQuestion ? <QuestionnaireItem id={currentQuestion.id} /> : null)}\n          {children === undefined && !terminalStatus && currentQuestion ? <QuestionnaireActions /> : null}\n        </div> : null}\n        {waiting ? <p className=\"ui-questionnaire__status\" role=\"status\">Waiting for confirmation.</p> : null}\n        {status === \"submitting\" || submitting ? <p className=\"ui-questionnaire__status\" role=\"status\">Submitting…</p> : null}\n        {error ? <p className=\"ui-questionnaire__error\" role=\"alert\">{error}</p> : null}\n        {formError ? <p className=\"ui-questionnaire__error\" role=\"alert\">{formError}</p> : null}\n      </form>\n    </QuestionnaireContext.Provider>\n  );\n});\n\nfunction ChoiceRadio({ option, index }: { option: QuestionOption; index: number }) {\n  const labelId = React.useId();\n  return (\n    <Field.Item render={<RadioGroup.Row data-align=\"start\" className=\"ui-questionnaire__choice-row\" />}>\n      <RadioGroup.Item aria-labelledby={labelId} aria-describedby={option.description ? `${labelId}-description` : undefined} value={option.value} disabled={option.disabled}>\n        <RadioGroup.Indicator />\n      </RadioGroup.Item>\n      <span className=\"ui-questionnaire__choice-copy\"><span className=\"ui-questionnaire__choice-label\"><span id={labelId}>{option.label}</span>{option.description ? <small id={`${labelId}-description`}>{option.description}</small> : null}</span>{!option.disabled && index < 9 ? <Kbd aria-hidden=\"true\">{index + 1}</Kbd> : null}</span>\n    </Field.Item>\n  );\n}\n\nfunction ChoiceCheckbox({ option, index }: { option: QuestionOption; index: number }) {\n  const labelId = React.useId();\n  return (\n    <Field.Item render={<Checkbox.Row data-align=\"start\" className=\"ui-questionnaire__choice-row\" />}>\n      <Checkbox.Root aria-labelledby={labelId} aria-describedby={option.description ? `${labelId}-description` : undefined} value={option.value} disabled={option.disabled}>\n        <Checkbox.Indicator />\n      </Checkbox.Root>\n      <span className=\"ui-questionnaire__choice-copy\"><span className=\"ui-questionnaire__choice-label\"><span id={labelId}>{option.label}</span>{option.description ? <small id={`${labelId}-description`}>{option.description}</small> : null}</span>{!option.disabled && index < 9 ? <Kbd aria-hidden=\"true\">{index + 1}</Kbd> : null}</span>\n    </Field.Item>\n  );\n}\n\nfunction CustomClearButton({ label, disabled, onClear }: { label: string; disabled: boolean; onClear: () => void }) {\n  return (\n    <IconButton\n      type=\"button\"\n      variant=\"ghost\"\n      shape=\"square\"\n      size=\"icon-xs\"\n      aria-label={label}\n      disabled={disabled}\n      onClick={(event) => { event.preventDefault(); event.stopPropagation(); onClear(); }}\n      onPointerDown={(event) => event.stopPropagation()}\n      onMouseDown={(event) => event.stopPropagation()}\n      icon={<X aria-hidden=\"true\" />}\n      className=\"ui-questionnaire__custom-clear\"\n    />\n  );\n}\n\nfunction CustomSingleOption({\n  question,\n  value,\n  index,\n  disabled,\n  onChange,\n  onClear,\n}: {\n  question: QuestionDefinition;\n  value: string;\n  index: number;\n  disabled: boolean;\n  onChange: (value: string) => void;\n  onClear: () => void;\n}) {\n  const custom = customDefinition(question);\n  return (\n    <Field.Item render={<RadioGroup.Row className=\"ui-questionnaire__choice-row ui-questionnaire__custom-row\" data-filled={value ? \"true\" : undefined} />}>\n      {value ? (\n        <RadioGroup.Item value={customAnswerId(question)} disabled={disabled} aria-label={`${question.title} custom option`}>\n          <RadioGroup.Indicator />\n        </RadioGroup.Item>\n      ) : (\n        <span className=\"ui-questionnaire__custom-marker\" aria-hidden=\"true\" />\n      )}\n      <span className=\"ui-questionnaire__choice-copy\"><span className=\"ui-questionnaire__choice-label ui-questionnaire__custom-input-wrap\"><Input\n        variant=\"ghost\"\n        data-question-custom=\"true\"\n        aria-label={`${question.title} custom answer`}\n        value={value}\n        onChange={(event) => onChange(event.target.value)}\n        placeholder={custom?.placeholder ?? \"Type your answer…\"}\n        maxLength={custom?.maxLength}\n        disabled={disabled}\n      /></span>{value ? <CustomClearButton label={`Clear custom answer for ${question.title}`} disabled={disabled} onClear={onClear} /> : null}{index < 9 ? <Kbd aria-hidden=\"true\">{index + 1}</Kbd> : null}</span>\n    </Field.Item>\n  );\n}\n\nfunction CustomMultipleOption({\n  question,\n  value,\n  index,\n  disabled,\n  onChange,\n  onClear,\n}: {\n  question: QuestionDefinition;\n  value: string;\n  index: number;\n  disabled: boolean;\n  onChange: (value: string) => void;\n  onClear: () => void;\n}) {\n  const custom = customDefinition(question);\n  return (\n    <Field.Item render={<Checkbox.Row className=\"ui-questionnaire__choice-row ui-questionnaire__custom-row\" data-filled={value ? \"true\" : undefined} />}>\n      {value ? (\n        <Checkbox.Root value={customAnswerId(question)} disabled={disabled} aria-label={`${question.title} custom option`}>\n          <Checkbox.Indicator />\n        </Checkbox.Root>\n      ) : (\n        <span className=\"ui-questionnaire__custom-marker ui-questionnaire__custom-marker--multiple\" aria-hidden=\"true\" />\n      )}\n      <span className=\"ui-questionnaire__choice-copy\"><span className=\"ui-questionnaire__choice-label ui-questionnaire__custom-input-wrap\"><Input\n        variant=\"ghost\"\n        data-question-custom=\"true\"\n        aria-label={`${question.title} custom answer`}\n        value={value}\n        onChange={(event) => onChange(event.target.value)}\n        placeholder={custom?.placeholder ?? \"Type your answer…\"}\n        maxLength={custom?.maxLength}\n        disabled={disabled}\n      /></span>{value ? <CustomClearButton label={`Clear custom answer for ${question.title}`} disabled={disabled} onClear={onClear} /> : null}{index < 9 ? <Kbd aria-hidden=\"true\">{index + 1}</Kbd> : null}</span>\n    </Field.Item>\n  );\n}\n\nfunction CustomChoiceRow({\n  question,\n  value,\n  index,\n  disabled,\n  onChange,\n  onClear,\n}: {\n  question: QuestionDefinition;\n  value: string;\n  index: number;\n  disabled: boolean;\n  onChange: (value: string) => void;\n  onClear?: () => void;\n}) {\n  const custom = customDefinition(question);\n  return (\n    <div className=\"ui-questionnaire__custom-row ui-questionnaire__custom-row--plain\" data-filled={value ? \"true\" : undefined}>\n      <label className=\"ui-questionnaire__custom-label\">\n        <span className={`ui-questionnaire__custom-marker${question.kind === \"multiple\" ? \" ui-questionnaire__custom-marker--multiple\" : \"\"}`} aria-hidden=\"true\" />\n        <Input\n        variant=\"ghost\"\n        data-question-custom=\"true\"\n        aria-label={`${question.title} custom answer`}\n        value={value}\n        onChange={(event) => onChange(event.target.value)}\n        placeholder={custom?.placeholder ?? \"Type your answer…\"}\n        maxLength={custom?.maxLength}\n        disabled={disabled}\n      />\n      </label>\n      {value && onClear ? <CustomClearButton label={`Clear custom answer for ${question.title}`} disabled={disabled} onClear={onClear} /> : null}\n      {index < 9 ? <Kbd aria-hidden=\"true\">{index + 1}</Kbd> : null}\n    </div>\n  );\n}\n\nexport interface QuestionnaireRecordProps extends React.HTMLAttributes<HTMLFieldSetElement> {\n  questions: readonly QuestionDefinition[];\n  response?: QuestionnaireResponse;\n  status: \"submitted\" | \"cancelled\" | \"expired\" | \"unavailable\";\n}\n\nexport const QuestionnaireRecord = React.forwardRef<HTMLFieldSetElement, QuestionnaireRecordProps>(function QuestionnaireRecord({ questions, response, status, className, ...props }, ref) {\n  const title = status === \"submitted\" ? \"Submitted answers\" : status === \"cancelled\" ? \"Cancelled answers\" : status === \"expired\" ? \"Expired answers\" : \"Questions\";\n  const notes: { text: string; role?: \"status\" }[] = [\n    status === \"cancelled\" ? { text: \"This request was cancelled.\" } : null,\n    status === \"expired\" ? { text: \"This request expired.\" } : null,\n    !response && status === \"unavailable\" ? { text: \"Responses are unavailable for this request.\", role: \"status\" } : null,\n    !response && status !== \"unavailable\" ? { text: \"Submitted response unavailable.\" } : null,\n  ].filter((note): note is { text: string; role?: \"status\" } => note !== null);\n  return (\n    <Fieldset.Root {...props} ref={ref} className={[\"ui-questionnaire__record\", className].filter(Boolean).join(\" \")} data-status={status} aria-label={props[\"aria-label\"] ?? title}>\n      <Fieldset.Legend className=\"ui-questionnaire__record-title\">{title}</Fieldset.Legend>\n      {response || status === \"unavailable\" ? <dl>{questions.map((question) => <div key={question.id} className=\"ui-questionnaire__record-field\"><dt>{question.title}</dt><dd>{response?.skipped.includes(question.id) ? \"Skipped\" : response ? displayAnswer(question, ownValue(response.answers, question.id)) : \"No answer recorded.\"}</dd></div>)}</dl> : null}\n      {notes.map((note) => <p key={note.text} role={note.role} className=\"ui-error ui-questionnaire__record-note\"><OctagonAlert aria-hidden=\"true\" />{note.text}</p>)}\n    </Fieldset.Root>\n  );\n});\nQuestionnaireRecord.displayName = \"QuestionnaireRecord\";\n\nQuestionnaire.displayName = \"Questionnaire\";\nQuestionnaireProgress.displayName = \"QuestionnaireProgress\";\nQuestionnaireItem.displayName = \"QuestionnaireItem\";\nQuestionnaireActions.displayName = \"QuestionnaireActions\";\n"
    },
    {
      "path": "src/components/ui/questionnaire.css",
      "type": "registry:file",
      "target": "@ui/questionnaire.css",
      "content": ".ui-questionnaire {\n  display: grid;\n  width: 100%;\n  max-width: 100%;\n  min-width: 0;\n  gap: var(--gap-section);\n  color: var(--foreground);\n  font-family: var(--font-sans, \"IBM Plex Sans\", sans-serif);\n  font-size: var(--font-size-base);\n  line-height: var(--leading-copy);\n}\n\n.ui-questionnaire__progress {\n  display: inline-flex;\n  min-block-size: var(--space-6);\n  align-items: center;\n  color: var(--muted-foreground);\n  font-size: var(--font-size-caption);\n  font-weight: var(--font-weight-regular);\n  line-height: var(--leading-tight);\n}\n\n.ui-questionnaire__card {\n  min-width: 0;\n  overflow: hidden;\n  border: 1px solid var(--border);\n  border-radius: var(--radius-lg);\n  background: var(--card);\n}\n\n.ui-questionnaire__item,\n.ui-questionnaire__fieldset,\n.ui-questionnaire__field {\n  min-width: 0;\n}\n\n.ui-questionnaire__item {\n  padding: var(--space-3);\n}\n\n.ui-questionnaire__fieldset {\n  gap: var(--gap-heading-desc);\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__fieldset > .ui-legend,\n.ui-questionnaire__field > .ui-label {\n  color: var(--muted-foreground);\n  font-size: var(--font-size-sm);\n  font-weight: var(--font-weight-regular);\n  line-height: var(--leading-copy);\n}\n\n.ui-questionnaire__description,\n.ui-questionnaire__status {\n  margin: 0;\n  color: var(--muted-foreground);\n  font-size: var(--font-size-caption);\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__choice-copy {\n  display: flex;\n  min-width: 0;\n  flex: 1;\n  align-items: flex-start;\n  justify-content: space-between;\n  gap: var(--gap-list);\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__choice-label {\n  display: grid;\n  min-width: 0;\n  gap: var(--gap-heading-helper);\n}\n\n.ui-questionnaire__choice-copy small {\n  color: var(--muted-foreground);\n  font-size: var(--font-size-caption);\n}\n\n.ui-questionnaire__custom-row {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  gap: var(--gap-list);\n  padding: var(--space-1) 0;\n}\n\n.ui-questionnaire__custom-row.ui-radio-row,\n.ui-questionnaire__custom-row.ui-check-row {\n  padding: var(--space-1) var(--ui-choice-row-inset, 0px);\n}\n\n.ui-questionnaire__custom-row .ui-questionnaire__choice-copy {\n  align-items: center;\n}\n\n.ui-questionnaire__custom-input-wrap {\n  min-width: 0;\n  flex: 1;\n}\n\n.ui-questionnaire__custom-input-wrap > .ui-input {\n  width: 100%;\n}\n\n.ui-questionnaire__custom-row .ui-questionnaire__custom-clear {\n  flex: 0 0 auto;\n  align-self: center;\n  width: var(--space-5);\n  min-width: var(--space-5);\n  height: var(--space-5);\n  min-height: var(--space-5);\n}\n\n.ui-questionnaire__custom-label {\n  display: flex;\n  min-width: 0;\n  flex: 1;\n  align-items: center;\n  gap: var(--space-2);\n}\n\n.ui-questionnaire__custom-label > input {\n  min-width: 0;\n  flex: 1;\n}\n\n.ui-questionnaire__custom-row > .ui-kbd {\n  flex: 0 0 auto;\n}\n\n.ui-questionnaire__configuration,\n.ui-questionnaire__error {\n  margin: 0;\n  color: var(--destructive);\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__empty {\n  margin: 0;\n  color: var(--muted-foreground);\n}\n\n.ui-questionnaire__actions {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: var(--gap-list);\n  padding: var(--space-2) var(--space-3);\n  border-block-start: 1px solid var(--border);\n  background: var(--secondary);\n}\n\n.ui-questionnaire__back {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  gap: var(--gap-list);\n}\n\n@media (hover: hover) {\n  .ui-questionnaire__actions .ui-button--ghost:not(:disabled):not([data-disabled]):hover {\n    background: var(--quiet-active);\n  }\n}\n\n.ui-questionnaire__record {\n  display: grid;\n  min-width: 0;\n  gap: var(--gap-list);\n  padding: var(--space-card-y) var(--space-card-x);\n  font-family: var(--font-sans);\n  font-size: var(--font-size-base);\n  line-height: var(--leading-copy);\n}\n\n.ui-questionnaire__record > .ui-legend.ui-questionnaire__record-title {\n  margin: 0;\n  font-weight: var(--font-weight-regular);\n}\n\n.ui-questionnaire__record dl {\n  display: grid;\n  min-width: 0;\n  grid-template-columns: minmax(0, 1fr);\n  gap: var(--gap-list);\n  margin: 0;\n}\n\n.ui-questionnaire__record-field {\n  display: grid;\n  min-width: 0;\n  gap: var(--gap-heading-helper);\n}\n\n.ui-questionnaire__record dt {\n  color: var(--muted-foreground);\n  font-size: var(--font-size-caption);\n}\n\n.ui-questionnaire__record dd {\n  min-width: 0;\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__record-note.ui-error {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  gap: var(--space-2);\n  overflow-wrap: anywhere;\n}\n\n.ui-questionnaire__record-note > svg {\n  flex: 0 0 auto;\n  width: 14px;\n  height: 14px;\n  stroke-width: var(--icon-stroke);\n}\n\n.ui-questionnaire[data-appearance=\"composer\"] {\n  gap: var(--gap-list);\n}\n\n.ui-questionnaire__composer-card,\n.ui-questionnaire__composer-layer {\n  min-width: 0;\n  width: 100%;\n}\n\n.ui-questionnaire__composer-field-root {\n  display: contents;\n}\n\n.ui-questionnaire__composer-secondary {\n  display: block;\n  padding: var(--space-3);\n  border-radius: 0;\n  background: var(--secondary);\n  color: var(--foreground);\n}\n\n.ui-questionnaire__composer-secondary > .ui-questionnaire__fieldset {\n  gap: var(--gap-heading-desc);\n}\n\n.ui-questionnaire__composer-primary.ui-composer-surface {\n  gap: var(--gap-list);\n  overflow: visible;\n}\n\n.ui-questionnaire__composer-primary > .ui-questionnaire__actions {\n  padding: var(--space-2) 0 0;\n  border: 0;\n  background: transparent;\n}\n\n.ui-questionnaire__custom-marker {\n  box-sizing: border-box;\n  flex: 0 0 18px;\n  width: 18px;\n  height: 18px;\n  border: 1px dashed var(--input);\n  border-radius: 50%;\n  background: transparent;\n}\n\n.ui-questionnaire__custom-marker--multiple {\n  border-radius: var(--radius-sm);\n}\n\n@media (hover: hover) {\n  .ui-questionnaire__custom-row--plain:hover .ui-questionnaire__custom-marker {\n    border-color: var(--input-focus-border-color);\n  }\n}\n\n.ui-questionnaire__custom-row:focus-within .ui-questionnaire__custom-marker,\n.ui-questionnaire__custom-row:focus-within .ui-check:not([data-checked]):not([data-disabled]),\n.ui-questionnaire__custom-row:focus-within .ui-radio:not([data-checked]):not([data-disabled]) {\n  border-color: var(--input-focus-border-color);\n}\n\n@media (max-width: 40rem) {\n  .ui-questionnaire__item {\n    padding-inline: var(--space-3);\n  }\n\n  .ui-questionnaire__actions {\n    padding-inline: var(--space-3);\n  }\n}\n"
    },
    {
      "path": "src/components/ui/kbd.tsx",
      "type": "registry:component",
      "target": "@ui/kbd.tsx",
      "content": "import \"./foundation.css\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowRightToLine, ArrowUp, ChevronUp, Command, CornerDownLeft, Delete, Option } from \"lucide-react\";\nimport \"./kbd.css\";\n\nconst keyIcons = {\n  Enter: CornerDownLeft,\n  Command,\n  Shift: ArrowBigUp,\n  Option,\n  Control: ChevronUp,\n  Tab: ArrowRightToLine,\n  Backspace: Delete,\n  ArrowUp,\n  ArrowDown,\n  ArrowLeft,\n  ArrowRight,\n};\n\nexport type KbdKey = keyof typeof keyIcons | \"Escape\";\n\nconst keyLabels: Record<KbdKey, string> = {\n  Enter: \"Enter\", Command: \"Command\", Shift: \"Shift\", Option: \"Option\", Control: \"Control\",\n  Tab: \"Tab\", Backspace: \"Backspace\", Escape: \"Escape\",\n  ArrowUp: \"Up arrow\", ArrowDown: \"Down arrow\", ArrowLeft: \"Left arrow\", ArrowRight: \"Right arrow\",\n};\n\nexport type KbdProps = Omit<ComponentProps<\"kbd\">, \"children\"> & {\n  variant?: \"outline\" | \"subtle\" | \"plain\";\n  size?: \"base\" | \"sm\";\n} & ({ keyName: KbdKey; keyLabel?: string; children?: never } | { keyName?: never; keyLabel?: never; children?: ReactNode });\n\n/** Displays a key; the caller owns its binding and platform-specific wording. */\nexport function Kbd({ className, variant = \"outline\", size = \"base\", keyName, keyLabel, children, ...props }: KbdProps) {\n  const Icon = keyName && keyName !== \"Escape\" ? keyIcons[keyName] : undefined;\n  return <kbd {...props} data-variant={variant} data-size={size} className={[\"ui-kbd\", className].filter(Boolean).join(\" \")}>\n    {keyName ? <><span className=\"ui-kbd-label\">{keyLabel ?? keyLabels[keyName]}</span>{Icon ? <Icon aria-hidden=\"true\" /> : <span aria-hidden=\"true\">Esc</span>}</> : children}\n  </kbd>;\n}\n\nexport function KbdGroup({ className, ...props }: ComponentProps<\"div\">) {\n  return <div role=\"group\" {...props} className={[\"ui-kbd-group\", className].filter(Boolean).join(\" \")} />;\n}\n"
    },
    {
      "path": "src/components/ui/kbd.css",
      "type": "registry:file",
      "target": "@ui/kbd.css",
      "content": "@import \"./tokens.css\";\n\n.ui-kbd {\n  box-sizing: border-box;\n  display: inline-flex;\n  flex-shrink: 0;\n  align-items: center;\n  justify-content: center;\n  min-inline-size: var(--space-5);\n  min-block-size: var(--space-5);\n  max-inline-size: 100%;\n  gap: var(--space-1);\n  padding-inline: var(--space-1);\n  border: 1px solid var(--border);\n  border-radius: var(--radius-control-keycap);\n  background: var(--ui-kbd-background, var(--secondary));\n  color: var(--muted-foreground);\n  font-family: var(--font-sans);\n  font-size: var(--font-size-caption);\n  font-weight: var(--font-weight-regular);\n  line-height: var(--leading-tight);\n  white-space: normal;\n  text-align: center;\n  overflow-wrap: anywhere;\n  user-select: none;\n}\n\n.ui-kbd[data-variant=\"subtle\"] {\n  border-color: transparent;\n}\n\n.ui-kbd[data-size=\"sm\"] {\n  min-inline-size: 18px;\n  min-block-size: 18px;\n  padding-inline: 3px;\n  font-size: 10px;\n  line-height: 12px;\n}\n\n.ui-kbd[data-variant=\"plain\"] {\n  min-inline-size: 0;\n  padding-inline: 0;\n  border: 0;\n  border-radius: 0;\n  background: transparent;\n}\n\n.ui-kbd[data-size] svg {\n  display: block;\n  inline-size: calc(var(--font-size-caption) - var(--space-1) / 2);\n  block-size: calc(var(--font-size-caption) - var(--space-1) / 2);\n  flex: none;\n  stroke-width: var(--icon-stroke);\n}\n\n.ui-kbd[data-size=\"sm\"] svg {\n  inline-size: 10px;\n  block-size: 10px;\n}\n\n.ui-kbd-group {\n  display: inline-flex;\n  align-items: center;\n  gap: var(--space-1);\n  max-inline-size: 100%;\n  flex-wrap: wrap;\n  direction: ltr;\n}\n\n.ui-kbd-label {\n  position: absolute;\n  inline-size: 1px;\n  block-size: 1px;\n  padding: 0;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n"
    }
  ]
}
