@alfadocs/ui-kit-debug 1.4.17 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/_chunks/{care-plan-card-C83Hb9EE.js → care-plan-card-CehAU7F_.js} +2 -2
  2. package/dist/_chunks/{care-plan-card-C83Hb9EE.js.map → care-plan-card-CehAU7F_.js.map} +1 -1
  3. package/dist/_chunks/{care-plan-entry-card-CHMPSTCz.js → care-plan-entry-card-ChWRMfMw.js} +2 -2
  4. package/dist/_chunks/{care-plan-entry-card-CHMPSTCz.js.map → care-plan-entry-card-ChWRMfMw.js.map} +1 -1
  5. package/dist/_chunks/{periodontal-chart-brakjj0s.js → periodontal-chart-C0nNQKKK.js} +121 -121
  6. package/dist/_chunks/{periodontal-chart-brakjj0s.js.map → periodontal-chart-C0nNQKKK.js.map} +1 -1
  7. package/dist/_chunks/tooth-data-DR8Kdnup.js +903 -0
  8. package/dist/_chunks/tooth-data-DR8Kdnup.js.map +1 -0
  9. package/dist/_chunks/tooth-finding-palette-vqC-D2Ye.js +708 -0
  10. package/dist/_chunks/tooth-finding-palette-vqC-D2Ye.js.map +1 -0
  11. package/dist/_chunks/tooth-scheme-BPXE1_3N.js +2051 -0
  12. package/dist/_chunks/tooth-scheme-BPXE1_3N.js.map +1 -0
  13. package/dist/agent-catalog.json +465 -21
  14. package/dist/agent-i18n/en.json +23 -6
  15. package/dist/components/care-plan-card/index.js +1 -1
  16. package/dist/components/care-plan-entry-card/index.js +1 -1
  17. package/dist/components/index.d.ts +1 -0
  18. package/dist/components/index.d.ts.map +1 -1
  19. package/dist/components/periodontal-chart/index.js +1 -1
  20. package/dist/components/tooth-finding-palette/index.d.ts +4 -0
  21. package/dist/components/tooth-finding-palette/index.d.ts.map +1 -0
  22. package/dist/components/tooth-finding-palette/index.js +9 -0
  23. package/dist/components/tooth-finding-palette/index.js.map +1 -0
  24. package/dist/components/tooth-finding-palette/tooth-finding-palette.agent.d.ts +4 -0
  25. package/dist/components/tooth-finding-palette/tooth-finding-palette.agent.d.ts.map +1 -0
  26. package/dist/components/tooth-finding-palette/tooth-finding-palette.d.ts +89 -0
  27. package/dist/components/tooth-finding-palette/tooth-finding-palette.d.ts.map +1 -0
  28. package/dist/components/tooth-scheme/index.d.ts +2 -2
  29. package/dist/components/tooth-scheme/index.d.ts.map +1 -1
  30. package/dist/components/tooth-scheme/index.js +57 -30
  31. package/dist/components/tooth-scheme/tooth-data.d.ts +279 -10
  32. package/dist/components/tooth-scheme/tooth-data.d.ts.map +1 -1
  33. package/dist/components/tooth-scheme/tooth-scheme.agent.d.ts +2 -2
  34. package/dist/components/tooth-scheme/tooth-scheme.agent.d.ts.map +1 -1
  35. package/dist/components/tooth-scheme/tooth-scheme.d.ts +30 -3
  36. package/dist/components/tooth-scheme/tooth-scheme.d.ts.map +1 -1
  37. package/dist/i18n/locales/ar.d.ts +40 -1
  38. package/dist/i18n/locales/ar.d.ts.map +1 -1
  39. package/dist/i18n/locales/ar.js +41 -2
  40. package/dist/i18n/locales/ar.js.map +1 -1
  41. package/dist/i18n/locales/de.d.ts +40 -1
  42. package/dist/i18n/locales/de.d.ts.map +1 -1
  43. package/dist/i18n/locales/de.js +41 -2
  44. package/dist/i18n/locales/de.js.map +1 -1
  45. package/dist/i18n/locales/el.d.ts +40 -1
  46. package/dist/i18n/locales/el.d.ts.map +1 -1
  47. package/dist/i18n/locales/el.js +41 -2
  48. package/dist/i18n/locales/el.js.map +1 -1
  49. package/dist/i18n/locales/en.d.ts +40 -1
  50. package/dist/i18n/locales/en.d.ts.map +1 -1
  51. package/dist/i18n/locales/en.js +41 -2
  52. package/dist/i18n/locales/en.js.map +1 -1
  53. package/dist/i18n/locales/es.d.ts +40 -1
  54. package/dist/i18n/locales/es.d.ts.map +1 -1
  55. package/dist/i18n/locales/es.js +41 -2
  56. package/dist/i18n/locales/es.js.map +1 -1
  57. package/dist/i18n/locales/fr.d.ts +40 -1
  58. package/dist/i18n/locales/fr.d.ts.map +1 -1
  59. package/dist/i18n/locales/fr.js +41 -2
  60. package/dist/i18n/locales/fr.js.map +1 -1
  61. package/dist/i18n/locales/hi.d.ts +40 -1
  62. package/dist/i18n/locales/hi.d.ts.map +1 -1
  63. package/dist/i18n/locales/hi.js +41 -2
  64. package/dist/i18n/locales/hi.js.map +1 -1
  65. package/dist/i18n/locales/it.d.ts +40 -1
  66. package/dist/i18n/locales/it.d.ts.map +1 -1
  67. package/dist/i18n/locales/it.js +41 -2
  68. package/dist/i18n/locales/it.js.map +1 -1
  69. package/dist/i18n/locales/ja.d.ts +40 -1
  70. package/dist/i18n/locales/ja.d.ts.map +1 -1
  71. package/dist/i18n/locales/ja.js +41 -2
  72. package/dist/i18n/locales/ja.js.map +1 -1
  73. package/dist/i18n/locales/nl.d.ts +40 -1
  74. package/dist/i18n/locales/nl.d.ts.map +1 -1
  75. package/dist/i18n/locales/nl.js +41 -2
  76. package/dist/i18n/locales/nl.js.map +1 -1
  77. package/dist/i18n/locales/pl.d.ts +40 -1
  78. package/dist/i18n/locales/pl.d.ts.map +1 -1
  79. package/dist/i18n/locales/pl.js +41 -2
  80. package/dist/i18n/locales/pl.js.map +1 -1
  81. package/dist/i18n/locales/pt.d.ts +40 -1
  82. package/dist/i18n/locales/pt.d.ts.map +1 -1
  83. package/dist/i18n/locales/pt.js +41 -2
  84. package/dist/i18n/locales/pt.js.map +1 -1
  85. package/dist/i18n/locales/ro.d.ts +40 -1
  86. package/dist/i18n/locales/ro.d.ts.map +1 -1
  87. package/dist/i18n/locales/ro.js +41 -2
  88. package/dist/i18n/locales/ro.js.map +1 -1
  89. package/dist/i18n/locales/ru.d.ts +40 -1
  90. package/dist/i18n/locales/ru.d.ts.map +1 -1
  91. package/dist/i18n/locales/ru.js +41 -2
  92. package/dist/i18n/locales/ru.js.map +1 -1
  93. package/dist/i18n/locales/sq.d.ts +40 -1
  94. package/dist/i18n/locales/sq.d.ts.map +1 -1
  95. package/dist/i18n/locales/sq.js +41 -2
  96. package/dist/i18n/locales/sq.js.map +1 -1
  97. package/dist/i18n/locales/sv.d.ts +40 -1
  98. package/dist/i18n/locales/sv.d.ts.map +1 -1
  99. package/dist/i18n/locales/sv.js +41 -2
  100. package/dist/i18n/locales/sv.js.map +1 -1
  101. package/dist/i18n/locales/tr.d.ts +40 -1
  102. package/dist/i18n/locales/tr.d.ts.map +1 -1
  103. package/dist/i18n/locales/tr.js +41 -2
  104. package/dist/i18n/locales/tr.js.map +1 -1
  105. package/dist/i18n/locales/zh.d.ts +40 -1
  106. package/dist/i18n/locales/zh.d.ts.map +1 -1
  107. package/dist/i18n/locales/zh.js +41 -2
  108. package/dist/i18n/locales/zh.js.map +1 -1
  109. package/dist/index.js +448 -415
  110. package/dist/index.js.map +1 -1
  111. package/dist/locales/ar.json +41 -2
  112. package/dist/locales/de.json +41 -2
  113. package/dist/locales/el.json +41 -2
  114. package/dist/locales/en.json +41 -2
  115. package/dist/locales/es.json +41 -2
  116. package/dist/locales/fr.json +41 -2
  117. package/dist/locales/hi.json +41 -2
  118. package/dist/locales/it.json +41 -2
  119. package/dist/locales/ja.json +41 -2
  120. package/dist/locales/nl.json +41 -2
  121. package/dist/locales/pl.json +41 -2
  122. package/dist/locales/pt.json +41 -2
  123. package/dist/locales/ro.json +41 -2
  124. package/dist/locales/ru.json +41 -2
  125. package/dist/locales/sq.json +41 -2
  126. package/dist/locales/sv.json +41 -2
  127. package/dist/locales/tr.json +41 -2
  128. package/dist/locales/zh.json +41 -2
  129. package/dist/tokens.css +1 -1
  130. package/package.json +5 -1
  131. package/dist/_chunks/tooth-data-BwuoKFf4.js +0 -660
  132. package/dist/_chunks/tooth-data-BwuoKFf4.js.map +0 -1
  133. package/dist/_chunks/tooth-scheme-s0ipC0-Z.js +0 -1483
  134. package/dist/_chunks/tooth-scheme-s0ipC0-Z.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"tooth-scheme-s0ipC0-Z.js","sources":["../../src/components/tooth-scheme/tooth-scheme.agent.ts","../../src/components/tooth-scheme/tooth-scheme.tsx"],"sourcesContent":["import type { AgentAdapter } from '../../agent/types';\nimport type { ToothSchemeHandle } from './tooth-scheme';\nimport type { Radiograph, Surface, ToothCondition } from './tooth-data';\n\ntype FdiId = Parameters<ToothSchemeHandle['focusTooth']>[0];\n\n// JSON-Schema fragments derived from the tooth-data type unions. Kept inline so\n// the adapter stays a pure module with no runtime import of the unions.\nconst FDI_SCHEMA = {\n type: 'string',\n description:\n \"FDI tooth id ('11'–'48' permanent, '51'–'85' primary) or a special-element id ('Q1'–'Q4' quadrants, 'S1'–'S6' sextants, 'AS'/'AI' arches, 'general'; primary mirrors with an 'm' prefix).\",\n} as const;\nconst CONDITION_SCHEMA = {\n enum: [\n 'caries',\n 'filled',\n 'crowned',\n 'temporaryCrown',\n 'bridge',\n 'missing',\n 'implant',\n 'implantExtraction',\n 'stub',\n 'destroyed',\n 'rootCanal',\n ],\n} as const;\nconst SURFACE_SCHEMA = {\n enum: ['mesial', 'distal', 'occlusal', 'buccal', 'lingual'],\n} as const;\nconst RADIOGRAPH_SCHEMA = {\n type: 'object',\n properties: {\n id: { type: 'string' },\n url: { type: 'string' },\n thumbnailUrl: { type: 'string' },\n date: { type: 'string', description: 'ISO acquisition date (YYYY-MM-DD).' },\n note: { type: 'string' },\n kind: { enum: ['periapical', 'bitewing', 'panoramic', 'other'] },\n alt: { type: 'string' },\n },\n required: ['id', 'url'],\n} as const;\n\nexport const toothSchemeAgent: AgentAdapter<ToothSchemeHandle> = {\n id: 'tooth-scheme',\n // pick — focus/select a tooth (`focus_tooth`, transient, not persisted);\n // set_value / edit_inline — `set_finding` records a finding and marks the\n // affected surfaces (set-surface), `remove_finding` clears one;\n // view_change — the side/plan projection + dentition are view props.\n capabilities: ['pick', 'set_value', 'edit_inline', 'view_change'],\n state: {\n chart: {\n type: 'object',\n descriptionKey: 'ui.agent.toothScheme.state.chart',\n description:\n 'Current dental chart — findings (and marked surfaces) keyed by FDI id, or by a special-element id (quadrant / sextant / arch / general) for region-spanning findings.',\n read: (handle) => handle.getChart(),\n },\n chartedTeeth: {\n type: 'string[]',\n descriptionKey: 'ui.agent.toothScheme.state.chartedTeeth',\n description:\n 'Ids carrying at least one finding — FDI tooth ids and/or special-element ids (quadrant / sextant / arch / general).',\n read: (handle) => Object.keys(handle.getChart()),\n },\n radiographs: {\n // A9: the always-on state snapshot carries identifiers + enums only —\n // never PHI free-text (the radiograph `note`), service dates, or the\n // consumer-hosted image URLs. Those are fetched deliberately, per tooth,\n // via the audited `get_radiographs` action.\n type: 'Record<string, { id: string; kind?: string }[]>',\n descriptionKey: 'ui.agent.toothScheme.state.radiographs',\n description:\n 'Structural references (id + kind) to the radiographs on each tooth, keyed by FDI id. Notes, dates and image URLs are not exposed here — fetch them on demand via get_radiographs.',\n read: (handle) =>\n Object.fromEntries(\n handle\n .teethWithRadiographs()\n .map((fdi) => [\n fdi,\n handle\n .getRadiographs(fdi)\n .map((r) => ({ id: r.id, kind: r.kind ?? 'periapical' })),\n ]),\n ),\n },\n teethWithRadiographs: {\n type: 'string[]',\n descriptionKey: 'ui.agent.toothScheme.state.teethWithRadiographs',\n description: 'FDI ids of every tooth carrying at least one radiograph.',\n read: (handle) => handle.teethWithRadiographs(),\n },\n },\n actions: {\n focus_tooth: {\n safety: 'read',\n argsType: '{ id: FdiId }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.focusTooth',\n description: 'Move focus to a specific tooth by FDI id.',\n invoke: (handle, args: { id: FdiId }) => {\n handle.focusTooth(args.id);\n },\n },\n get_tooth: {\n safety: 'read',\n argsType: '{ id: FdiId }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA },\n required: ['id'],\n },\n returns: 'ToothCondition[]',\n returnsSchema: { type: 'array', items: CONDITION_SCHEMA },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.getTooth',\n description: 'Read the findings recorded on one tooth (FDI id).',\n invoke: (handle, args: { id: FdiId }) => handle.getTooth(args.id),\n },\n teeth_with: {\n safety: 'read',\n argsType: '{ condition: ToothCondition }',\n argsSchema: {\n type: 'object',\n properties: { condition: CONDITION_SCHEMA },\n required: ['condition'],\n },\n returns: 'FdiId[]',\n returnsSchema: { type: 'array', items: FDI_SCHEMA },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.teethWith',\n description:\n 'List the ids carrying a given finding — FDI tooth ids and/or special-element ids (e.g. all teeth with caries).',\n invoke: (handle, args: { condition: ToothCondition }) =>\n handle.teethWith(args.condition),\n },\n get_radiographs: {\n safety: 'read',\n argsType: '{ id: FdiId }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA },\n required: ['id'],\n },\n returns: 'Radiograph[]',\n returnsSchema: { type: 'array', items: RADIOGRAPH_SCHEMA },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.getRadiographs',\n description: 'Read the radiographs (x-rays) attached to one tooth.',\n invoke: (handle, args: { id: FdiId }) => handle.getRadiographs(args.id),\n },\n open_radiographs: {\n safety: 'read',\n argsType: '{ id: FdiId }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.openRadiographs',\n description:\n \"Focus a tooth and open its radiograph archive (fires the host's onOpenRadiographs).\",\n invoke: (handle, args: { id: FdiId }) => {\n handle.openRadiographs(args.id);\n },\n },\n set_finding: {\n safety: 'write',\n argsType:\n '{ id: FdiId; condition: ToothCondition; surfaces?: Surface[] }',\n argsSchema: {\n type: 'object',\n properties: {\n id: FDI_SCHEMA,\n condition: CONDITION_SCHEMA,\n surfaces: { type: 'array', items: SURFACE_SCHEMA },\n },\n required: ['id', 'condition'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.setFinding',\n description:\n 'Record a finding on a tooth or region element (crown, implant, root canal, caries, …). Optionally mark the affected surfaces for a surface finding.',\n invoke: (\n handle,\n args: { id: FdiId; condition: ToothCondition; surfaces?: Surface[] },\n ) => {\n handle.setFinding(args.id, args.condition, args.surfaces);\n },\n },\n remove_finding: {\n safety: 'write',\n argsType: '{ id: FdiId; condition: ToothCondition }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA, condition: CONDITION_SCHEMA },\n required: ['id', 'condition'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.removeFinding',\n description: 'Remove a single finding from a tooth.',\n invoke: (handle, args: { id: FdiId; condition: ToothCondition }) => {\n handle.removeFinding(args.id, args.condition);\n },\n },\n clear_tooth: {\n safety: 'destructive',\n argsType: '{ id: FdiId }',\n argsSchema: {\n type: 'object',\n properties: { id: FDI_SCHEMA },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.toothScheme.actions.clearTooth',\n description: 'Clear every finding from a tooth.',\n invoke: (handle, args: { id: FdiId }) => {\n handle.clearTooth(args.id);\n },\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'tooth-scheme' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n item: {\n attr: 'data-fdi',\n description:\n 'Each rendered tooth `<g>` carries its FDI id as `data-fdi`; selectable special-element slots carry their id there too (plus `data-special` naming the kind). The `data-projection` / `data-view-mode` attributes on the root expose the side/plan/both view.',\n },\n },\n};\n\n// Re-exported for callers building typed args against the adapter.\nexport type { Radiograph, Surface, ToothCondition };\n","/* ------------------------------------------------------------------ */\n/* ToothScheme — the consolidated AlfaDocs odontogram. */\n/* */\n/* - Image-base + SVG overlay: each tooth is a photoreal CGI render */\n/* (`<image>`, served from `assetBaseUrl`); the SVG layer on top */\n/* carries findings, selection, keyboard nav and a11y. No third-party */\n/* engine — `src/docs/08-third-party.mdx §Dental chart` rejected the */\n/* candidates (jQuery, abandoned, poor a11y). */\n/* */\n/* - Colour-not-alone: whole-tooth findings render a DISTINCT symbol */\n/* glyph image (the shape is the channel) + the tooth's accessible */\n/* name + tooltip; surface findings (caries / filled) render a */\n/* per-surface fill in the plan view, or a distinguished ring (solid */\n/* = caries, dashed = filled) + legend + tooltip in the side view. */\n/* */\n/* - Two projections: `side` (facial — whole-tooth findings) and */\n/* `plan` (occlusal — per-surface caries / fillings, the \"Stato */\n/* dentale\" marking). `both` lays the two facial (side) rows on the */\n/* outside with the two occlusal (plan) rows between them — upper */\n/* side, upper occlusal, lower occlusal, lower side — and brackets */\n/* the chart with tooth numbers above and below (matching the */\n/* platform odontogram). */\n/* */\n/* - Special elements: selectable quadrant / sextant / arch / whole- */\n/* mouth slots appended to the inline-end of each arch row, so a */\n/* finding can span a region (e.g. a denture on the upper arch). See */\n/* `tooth-data.ts` § Special elements. */\n/* */\n/* - Chart orientation is FIXED to clinical convention: the patient's */\n/* right sits on the viewer's left in both arches regardless of */\n/* `dir`. A mirrored chart would invert every recorded diagnosis. */\n/* ------------------------------------------------------------------ */\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type KeyboardEvent,\n type ReactElement,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport * as RadixTooltip from '@radix-ui/react-tooltip';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Settings } from 'lucide-react';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { IconButton } from '../button';\nimport { Popover } from '../popover';\nimport { Select } from '../select';\nimport { Switch } from '../switch';\nimport { toothSchemeAgent } from './tooth-scheme.agent';\n\nimport {\n CONDITION_COLORS,\n CONDITION_SIDE_SYMBOL,\n CONDITION_PLAN_FOLDER,\n conditionSymbolUrl,\n surfaceSymbolUrl,\n zonesForTooth,\n zoneSurface,\n zonePath,\n FDI_TO_META,\n PERMANENT_TEETH,\n PRIMARY_TEETH,\n SPECIAL_BY_ID,\n SPECIAL_SLOT_WIDTH,\n TOOTH_HIT_PAD,\n TOOTH_ROW_GAP,\n TOOTH_SLOT_WIDTH,\n TOOTH_SLOT_HEIGHT,\n PRIMARY_TOOTH_SCALE,\n chartFromConditions,\n isSpecialElement,\n labelFor,\n layoutSpecials,\n layoutTeeth,\n specialIconUrl,\n specialsForRow,\n toothImageUrl,\n type Arch,\n type Projection,\n type PositionedSpecial,\n type SpecialElement,\n type ViewMode,\n type Dentition,\n type FdiId,\n type Numbering,\n type Radiograph,\n type Surface,\n type SurfaceZone,\n type ToothChart,\n type ToothCondition,\n type ToothMode,\n type ToothState,\n} from './tooth-data';\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport interface ToothSchemeProps {\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /** Which teeth to render. Default `'permanent'`. */\n dentition?: Dentition;\n /** Numbering system shown on each tooth label. Default `'fdi'`. */\n numbering?: Numbering;\n /** `'interactive'` enables selection + keyboard nav; `'display'` is read-only. Default `'interactive'`. */\n mode?: ToothMode;\n /**\n * `'side'` shows the facial view (whole-tooth findings); `'plan'` shows the\n * occlusal view (per-surface caries / fillings); `'both'` lays the two facial\n * rows on the outside with the two occlusal rows between them (upper side →\n * upper occlusal → lower occlusal → lower side), bracketed by tooth numbers\n * above and below. Default `'side'`.\n */\n projection?: ViewMode;\n /**\n * Show the selectable special-element slots (quadrants, sextants, arches,\n * whole-mouth) to the inline-end of each arch row. When unset, they show in\n * `both` view and hide in the single side / plan views; pass `true` / `false`\n * to force it. They share the chart data and emit `onSelect` like a tooth.\n */\n specialElements?: boolean;\n /** Controlled chart state — the full `Record<FdiId, ToothState>`. */\n value?: ToothChart;\n /** Uncontrolled initial chart state. */\n defaultValue?: ToothChart;\n /** Fired whenever the chart changes — always emits FDI ids. */\n onChange?: (next: ToothChart) => void;\n /**\n * Fired when a tooth OR special element is focused / clicked. Special\n * elements emit their id (`Q1`, `S3`, `AS`, `general`, …).\n */\n onSelect?: (toothId: FdiId) => void;\n /** Shortcut for pre-populating conditions: `{ '16': ['caries'], '36': ['filled'] }`. */\n conditions?: Partial<Record<FdiId, ToothCondition[]>>;\n /**\n * Per-tooth radiographs (x-rays / *endorali*), keyed by FDI id — mirrors the\n * `conditions` shape. Teeth carrying at least one radiograph get a corner\n * count badge; in `radiographDisplay=\"thumbnail\"` the most-recent film also\n * fills the slot. Image urls are opaque / consumer-hosted — never bundle real\n * scans (PHI).\n */\n radiographs?: Partial<Record<FdiId, Radiograph[]>>;\n /**\n * How a tooth carrying radiographs is marked. `'badge'` (default) keeps the\n * photoreal tooth render and adds a corner count badge; `'thumbnail'` shows\n * the most-recent radiograph inset in the slot (still badged).\n */\n radiographDisplay?: 'badge' | 'thumbnail';\n /**\n * Fired when a tooth's radiograph archive is opened — i.e. a tooth is\n * activated (click / Enter / Space) in `mode=\"display\"`. Wire this to a\n * Sheet/Dialog that manages the tooth's films. Setting this makes display-mode\n * teeth focusable buttons; it is mutually exclusive with interactive\n * findings-editing (`mode=\"interactive\"` / `activeCondition`).\n *\n * EVERY tooth becomes an open-archive button — including unfilmed teeth, so the\n * user can add the first film to an empty tooth (matching a real imaging hub).\n * Filmed teeth are distinguished by the radiograph count folded into their\n * accessible name and tooltip.\n */\n onOpenRadiographs?: (toothId: FdiId) => void;\n /**\n * The finding a tooth-click applies in interactive mode (the selected\n * tool in a Findings / \"Stato dentale\" panel). Clicking a tooth toggles\n * this condition. When unset, clicking cycles caries on/off.\n */\n activeCondition?: ToothCondition;\n /**\n * Base URL the photoreal tooth renders are served from. Resolves to\n * `${assetBaseUrl}/{side|plan}/{symbol}/{top|bottom}/{fdi}.webp`. Defaults\n * to the kit's bundled static path; host the `toothscheme/teeth` set\n * elsewhere (CDN) by overriding this. Trusted developer-controlled value —\n * interpolated into an SVG `<image href>` (which cannot execute scripts),\n * not user input; intentionally not runtime-validated.\n */\n assetBaseUrl?: string;\n /**\n * Show the finding-colour legend below the chart. Default `false` — findings\n * render as distinct symbol glyphs (self-describing) + tooltips, so the\n * colour key is opt-in; a consuming \"Stato dentale\" surface uses a\n * finding-type panel as its key instead.\n */\n legend?: boolean;\n /**\n * Render a built-in options affordance: a gear button that opens a popover\n * letting the END USER toggle the legend + special elements and switch\n * dentition / numbering / projection. Opt-in — when on, those become\n * user-overridable (seeded from the props); when off, the props drive the\n * chart directly. Default `false`.\n */\n controls?: boolean;\n /**\n * Where to render the `controls` gear. `undefined` (default) renders it\n * inline at the top-end of the chart. Pass a DOM element (e.g. a ref'd slot in\n * your card header) to portal the gear + its popover into that slot instead,\n * so the chart options can sit on the title line. While the slot is mounting\n * the prop will be `null`; the gear renders nothing until the element exists,\n * so it never flashes inline first. No effect unless `controls` is on.\n */\n controlsContainer?: HTMLElement | null;\n /** Accessible label override for the chart region. */\n ariaLabel?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/** Number-label placement for a sub-chart. */\ntype NumbersPosition = 'between' | 'above' | 'below' | 'none';\n\n/**\n * Internal-only props (prefixed `_`) used when the component composes itself\n * into the four-row `both` view — never part of the public API.\n */\ninterface ToothSchemeInternalProps {\n /** Render a single arch (the `both` view stacks one arch per sub-chart). */\n _arch?: Arch;\n /** Number-label placement for this sub-chart. */\n _numbersPosition?: NumbersPosition;\n /** Render only the `<svg>` (no region wrapper, controls, legend, or chrome). */\n _inner?: boolean;\n /**\n * Force the SVG content width (the `both` view shares one width across all\n * four sub-charts so they scale identically and stay column-aligned —\n * otherwise rows with fewer special-element columns would scale up larger).\n */\n _contentWidth?: number;\n}\n\nexport interface ToothSchemeHandle {\n /** Programmatically focus a tooth by FDI id. */\n focusTooth: (id: FdiId) => void;\n /** Read the current chart state. */\n getChart: () => ToothChart;\n /** Read the findings recorded on one tooth (empty array if none). */\n getTooth: (id: FdiId) => ToothCondition[];\n /** Read the FDI ids of every tooth carrying a given finding. */\n teethWith: (condition: ToothCondition) => FdiId[];\n /** Add a finding to a tooth (no-op if already present). Optionally mark surfaces. */\n setFinding: (\n id: FdiId,\n condition: ToothCondition,\n surfaces?: Surface[],\n ) => void;\n /** Remove a finding from a tooth (no-op if absent). */\n removeFinding: (id: FdiId, condition: ToothCondition) => void;\n /** Clear every finding from a tooth. */\n clearTooth: (id: FdiId) => void;\n /** Read the radiographs attached to one tooth (empty array if none). */\n getRadiographs: (id: FdiId) => Radiograph[];\n /** Read the FDI ids of every tooth carrying at least one radiograph. */\n teethWithRadiographs: () => FdiId[];\n /** Focus a tooth and open its radiograph archive (fires `onOpenRadiographs`). */\n openRadiographs: (id: FdiId) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva(\n [\n 'ds:tooth-scheme-alfadocs',\n 'ds:flex ds:flex-col',\n 'ds:gap-[var(--spacing-sm)]',\n 'ds:bg-[var(--background)] ds:text-[var(--foreground)]',\n // Block-level flex column so the SVG's w-full can grow to fill the frame.\n // min-w-fit on the SVG floors it at natural size, so narrow frames scroll\n // here rather than shrinking the per-tooth hit target below the 44px floor.\n 'ds:max-w-full ds:overflow-x-auto',\n // When the scroll container itself is the tab stop (display mode, see\n // scrollTabIndex) it needs a focus ring. Use an outline (not box-shadow):\n // forced-colors / high-contrast mode zeroes box-shadow, which would leave\n // HCM keyboard users with no visible focus. outline survives, and the\n // CanvasText fallback repaints it in the system palette.\n 'ds:outline-none',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n ].join(' '),\n);\n\n// The four `both`-view sub-charts stack in a tight column (no inter-row gap),\n// so the facial → occlusal → occlusal → facial rows read as one chart.\nconst bothStackVariants = cva(['ds:flex ds:flex-col ds:gap-0'].join(' '));\n\n// Responsive width: w-full lets the SVG grow to FILL a wider frame and h-auto\n// keeps the viewBox aspect. min-w-fit floors it at the viewBox's natural width\n// so it never scales the per-tooth tap target below the ≥44px AAA floor (WCAG\n// 2.5.5) — narrower frames scroll on the root rather than shrinking the teeth.\nconst svgVariants = cva(\n [\n 'ds:block',\n 'ds:w-full ds:min-w-fit ds:h-auto',\n 'ds:text-[var(--foreground)]',\n ].join(' '),\n);\n\n// `group` here is load-bearing — the focus-ring <rect> below uses\n// `group-focus-visible:opacity-100` to appear when the parent <g> takes\n// focus. Without this class the selector never fires and keyboard users\n// see no focus indicator (a11y-critical-fixes.mdx).\nconst toothGroupVariants = cva(\n [\n 'ds:group ds:cursor-pointer',\n 'ds:focus:outline-none',\n 'ds:transition-[fill,stroke,opacity] ds:duration-[var(--animation-duration)]',\n 'ds:motion-reduce:transition-none',\n ].join(' '),\n);\n\nconst legendVariants = cva(\n [\n 'ds:flex ds:flex-wrap ds:items-center',\n 'ds:gap-[var(--spacing-sm)]',\n 'type-meta ds:text-[var(--muted-foreground)]',\n ].join(' '),\n);\n\nconst legendItemVariants = cva(\n ['ds:inline-flex ds:items-center', 'ds:gap-[var(--spacing-xs)]'].join(' '),\n);\n\nconst liveRegionVariants = cva(['ds:sr-only'].join(' '));\n\n// Surface-zone affordance (plan view, interactive surface-picking). Invisible\n// until hovered (pointer) or focused (keyboard, drilled-in) — the marked\n// surface itself is shown by the photoreal per-surface overlay underneath.\nconst zoneVariants = cva(\n [\n 'ds:cursor-pointer ds:outline-none',\n 'ds:fill-transparent ds:stroke-transparent',\n 'ds:transition-[fill] ds:duration-[var(--animation-duration)]',\n 'ds:motion-reduce:transition-none',\n 'ds:hover:fill-[color-mix(in_srgb,var(--accent)_18%,transparent)]',\n 'ds:focus-visible:fill-[color-mix(in_srgb,var(--accent)_22%,transparent)]',\n 'ds:focus-visible:stroke-[var(--ring)]',\n 'ds:forced-colors:focus-visible:stroke-[CanvasText]',\n ].join(' '),\n);\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\nfunction isControlled(props: Pick<ToothSchemeProps, 'value'>): boolean {\n return props.value !== undefined;\n}\n\nfunction emptyState(): ToothState {\n return { conditions: [], surfaces: [] };\n}\n\nfunction cycleCondition(\n current: ToothCondition[] | undefined,\n active?: ToothCondition,\n): ToothCondition[] {\n const list = current ?? [];\n // No tool selected → cycle caries on/off (legacy demo behaviour).\n if (!active) return list.length === 0 ? ['caries'] : [];\n // A finding tool is selected → toggle it on this tooth.\n return list.includes(active)\n ? list.filter((condition) => condition !== active)\n : [...list, active];\n}\n\n/** Translate a special element to its accessible name. */\nfunction elementName(\n element: SpecialElement,\n t: (key: string, opts?: Record<string, unknown>) => string,\n): string {\n switch (element.labelKey) {\n case 'quadrant':\n return t('toothScheme.special.quadrant', { n: element.labelIndex });\n case 'sextant':\n return t('toothScheme.special.sextant', { n: element.labelIndex });\n case 'archUpper':\n return t('toothScheme.special.archUpper');\n case 'archLower':\n return t('toothScheme.special.archLower');\n default:\n return t('toothScheme.special.general');\n }\n}\n\n/**\n * Drill-in arrow navigation between a tooth's surface zones. 4-zone teeth map\n * each arrow straight to its zone; 5-zone teeth pivot through the occlusal\n * centre (every edge connects only to the centre, the centre to all edges).\n */\nfunction nextZone(\n zone: SurfaceZone,\n key: string,\n hasCenter: boolean,\n): SurfaceZone {\n if (!hasCenter) {\n if (key === 'ArrowUp') return 'top';\n if (key === 'ArrowDown') return 'bottom';\n if (key === 'ArrowLeft') return 'left';\n if (key === 'ArrowRight') return 'right';\n return zone;\n }\n const hub: Record<SurfaceZone, Partial<Record<string, SurfaceZone>>> = {\n top: { ArrowDown: 'center' },\n bottom: { ArrowUp: 'center' },\n left: { ArrowRight: 'center' },\n right: { ArrowLeft: 'center' },\n center: {\n ArrowUp: 'top',\n ArrowDown: 'bottom',\n ArrowLeft: 'left',\n ArrowRight: 'right',\n },\n };\n return hub[zone]?.[key] ?? zone;\n}\n\n/* ------------------------------------------------------------------ */\n/* Legend */\n/* */\n/* Each entry shows the finding EXACTLY as it renders on the chart — a */\n/* mini tooth (the upper-right molar) carrying that finding's symbol */\n/* glyph, surface ring, or missing-X — so the key actually maps to the */\n/* scheme rather than to an abstract colour swatch. */\n/* ------------------------------------------------------------------ */\n\nconst ALL_CONDITIONS: ToothCondition[] = [\n 'caries',\n 'filled',\n 'crowned',\n 'temporaryCrown',\n 'bridge',\n 'rootCanal',\n 'implant',\n 'implantExtraction',\n 'stub',\n 'destroyed',\n 'missing',\n];\n\n/** A 36×62 mini tooth rendering one finding, mirroring the chart's visuals. */\nfunction LegendSymbol({\n condition,\n assetBaseUrl,\n}: {\n condition: ToothCondition;\n assetBaseUrl: string;\n}): ReactElement {\n const meta = FDI_TO_META['16'];\n const spec = CONDITION_SIDE_SYMBOL[condition];\n const isMissing = condition === 'missing';\n const isSurface = condition === 'caries' || condition === 'filled';\n // Match the chart: the render is inset (scaled 0.9) so the surface ring and\n // missing-X never touch the tooth — the same fix applied to the live teeth.\n const w = 36 * 0.9;\n const h = 62 * 0.9;\n const x = (36 - w) / 2;\n const y = (62 - h) / 2;\n return (\n <svg\n width=\"22\"\n height=\"38\"\n viewBox=\"0 0 36 62\"\n aria-hidden=\"true\"\n className=\"ds:block ds:shrink-0\"\n >\n <image\n href={toothImageUrl(meta, assetBaseUrl)}\n x={x}\n y={y}\n width={w}\n height={h}\n preserveAspectRatio=\"xMidYMid meet\"\n opacity={isMissing ? 0.25 : 1}\n />\n {spec ? (\n <image\n href={conditionSymbolUrl(meta, assetBaseUrl, spec)}\n x={x}\n y={y}\n width={w}\n height={h}\n preserveAspectRatio=\"xMidYMid meet\"\n />\n ) : null}\n {isSurface ? (\n <rect\n x={3}\n y={2}\n width={30}\n height={58}\n fill=\"none\"\n stroke={CONDITION_COLORS[condition]}\n strokeWidth={2}\n strokeDasharray={condition === 'filled' ? '4 2' : undefined}\n rx={6}\n />\n ) : null}\n {isMissing ? (\n <path\n d=\"M7 9 L29 53 M29 9 L7 53\"\n stroke={CONDITION_COLORS.missing}\n strokeWidth={2}\n fill=\"none\"\n />\n ) : null}\n </svg>\n );\n}\n\nfunction Legend({ assetBaseUrl }: { assetBaseUrl: string }): ReactElement {\n const { t } = useTranslation();\n return (\n <section\n aria-label={t('toothScheme.legendLabel')}\n data-testid=\"tooth-scheme-legend\"\n // Matches the Card `elevated` variant exactly: --card surface, a subtle\n // --card-border, --shadow-card, and the thicker border in the accessible\n // theme. --muted-foreground on --card stays a validated pair.\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:rounded-[var(--radius-md)] ds:bg-[var(--card)] ds:border ds:border-[color:var(--card-border)] ds:p-[var(--spacing-sm)] ds:shadow-[var(--shadow-card)] ds:[.theme-accessible_&]:border-2\"\n >\n <span className=\"type-eyebrow ds:text-[color:var(--muted-foreground)]\">\n {t('toothScheme.legendLabel')}\n </span>\n <ul className={legendVariants()}>\n {ALL_CONDITIONS.map((condition) => (\n <li\n key={condition}\n className={legendItemVariants()}\n data-condition={condition}\n data-testid={`tooth-scheme-legend-item-${condition}`}\n >\n <LegendSymbol condition={condition} assetBaseUrl={assetBaseUrl} />\n <span>{t(`toothScheme.condition.${condition}`)}</span>\n </li>\n ))}\n </ul>\n </section>\n );\n}\n\n// One labelled Select row inside the options popover. The label stacks ABOVE a\n// full-width Select so long option values (e.g. \"Permanent dentition\") fit on\n// one line. The visible label is `aria-hidden` (sighted-only) and duplicated as\n// the Select's `aria-label`, so screen-reader users get the name once.\nfunction OptionRow({\n label,\n value,\n options,\n onValueChange,\n container,\n}: {\n label: string;\n value: string;\n options: { value: string; label: string }[];\n onValueChange: (value: string) => void;\n container?: HTMLElement | null;\n}): ReactElement {\n return (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]\">\n <span\n aria-hidden=\"true\"\n className=\"type-label ds:text-[color:var(--muted-foreground)]\"\n >\n {label}\n </span>\n <Select\n size=\"md\"\n aria-label={label}\n value={value}\n options={options}\n onValueChange={onValueChange}\n // Keeps the listbox inside the popover's scroll container. Not needed\n // for stacking — dropdown and popover share a layer, so the listbox\n // already paints on top by portal order.\n container={container}\n />\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\n/** Sort radiographs newest-first; undated films sink to the end. */\nfunction sortByDateDesc(a: Radiograph, b: Radiograph): number {\n if (a.date === b.date) return 0;\n if (!a.date) return 1;\n if (!b.date) return -1;\n return a.date < b.date ? 1 : -1;\n}\n\nexport const ToothScheme = forwardRef<\n ToothSchemeHandle,\n ToothSchemeProps & ToothSchemeInternalProps\n>(\n (\n {\n id,\n dentition: dentitionProp = 'permanent',\n numbering: numberingProp = 'fdi',\n mode = 'interactive',\n projection: projectionProp = 'side',\n specialElements: specialElementsProp,\n value,\n defaultValue,\n onChange,\n onSelect,\n conditions,\n radiographs,\n radiographDisplay = 'badge',\n onOpenRadiographs,\n activeCondition,\n assetBaseUrl = '/toothscheme/teeth',\n legend: legendProp = false,\n controls = false,\n controlsContainer,\n ariaLabel,\n className,\n _arch,\n _numbersPosition = 'between',\n _inner = false,\n _contentWidth,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n // User-facing options (the gear popover). When `controls` is on, the\n // chart's dentition / numbering / projection / legend / special elements\n // become user-overridable: internal state is seeded from the props and the\n // popover updates it. When `controls` is off, the props drive the chart\n // directly (the component stays fully controlled for consumers who don't\n // want it).\n const [uiDentition, setUiDentition] = useState<Dentition>(dentitionProp);\n const [uiNumbering, setUiNumbering] = useState<Numbering>(numberingProp);\n const [uiProjection, setUiProjection] = useState<ViewMode>(projectionProp);\n const [uiLegend, setUiLegend] = useState<boolean>(legendProp);\n const [uiSpecial, setUiSpecial] = useState<boolean | undefined>(\n specialElementsProp,\n );\n\n // Portal target for the option selects, captured from the popover content\n // so their listboxes render above the popover (not behind it).\n const [optionsPopoverEl, setOptionsPopoverEl] =\n useState<HTMLElement | null>(null);\n\n const dentition = controls ? uiDentition : dentitionProp;\n const numbering = controls ? uiNumbering : numberingProp;\n const legend = controls ? uiLegend : legendProp;\n // The View select can pick a single projection or 'both'. The single\n // projections render one chart; 'both' lays four arch-scoped sub-charts so\n // the occlusal rows sit between the facial rows.\n const viewMode: ViewMode = controls ? uiProjection : projectionProp;\n const projection: Projection = viewMode === 'plan' ? 'plan' : 'side';\n const showBoth = viewMode === 'both' && !_inner;\n // Special elements default to visible in the `both` view and hidden in the\n // single side / plan views; an explicit prop (or the gear toggle) overrides.\n const specialAuto = viewMode === 'both';\n const showSpecials = controls\n ? (uiSpecial ?? specialAuto)\n : (specialElementsProp ?? specialAuto);\n\n // The `ui*` seeds above only run once (at mount). If `controls` flips on\n // later, re-seed from the current props so the popover opens from the\n // consumer's latest values rather than the stale mount-time snapshot.\n const controlsWasOn = useRef(controls);\n useEffect(() => {\n if (controls && !controlsWasOn.current) {\n setUiDentition(dentitionProp);\n setUiNumbering(numberingProp);\n setUiProjection(projectionProp);\n setUiLegend(legendProp);\n setUiSpecial(specialElementsProp);\n }\n controlsWasOn.current = controls;\n }, [\n controls,\n dentitionProp,\n numberingProp,\n projectionProp,\n legendProp,\n specialElementsProp,\n ]);\n\n // Chart state — controlled / uncontrolled.\n const [internalChart, setInternalChart] = useState<ToothChart>(() => {\n if (value !== undefined) return value;\n if (defaultValue !== undefined) return defaultValue;\n if (conditions) return chartFromConditions(conditions);\n return {};\n });\n\n const chart: ToothChart = isControlled({ value })\n ? (value as ToothChart)\n : internalChart;\n\n // Keep uncontrolled chart in sync when `conditions` shortcut updates.\n useEffect(() => {\n if (isControlled({ value })) return;\n if (conditions === undefined) return;\n setInternalChart(chartFromConditions(conditions));\n // Intentionally depend on a stable key — swapping the entire prop\n // snapshot is the consumer's signal to reset.\n }, [conditions, value]);\n\n // Plan (occlusal) teeth are square; facial teeth are tall (crown + root).\n const slotHeight = projection === 'plan' ? 44 : TOOTH_SLOT_HEIGHT;\n\n // Layout — single-arch (a `both`-view sub-chart) or both arches.\n const layout = useMemo(\n () => layoutTeeth(dentition, slotHeight, _arch ? { arch: _arch } : {}),\n [dentition, slotHeight, _arch],\n );\n\n // Special-element slots positioned to the inline-end of each arch row.\n const specials = useMemo<PositionedSpecial[]>(() => {\n if (!showSpecials) return [];\n if (_arch) {\n // A `both`-view sub-chart: one arch row, specials at y = 0.\n return layoutSpecials(\n specialsForRow(dentition, _arch, projection),\n layout.width,\n ).specials;\n }\n // Single-projection chart: specials attach to both arch rows.\n const upper = layoutSpecials(\n specialsForRow(dentition, 'upper', projection),\n layout.width,\n ).specials;\n const lowerRowY = slotHeight + TOOTH_ROW_GAP;\n const lower = layoutSpecials(\n specialsForRow(dentition, 'lower', projection),\n layout.width,\n ).specials.map((s) => ({ ...s, y: lowerRowY }));\n return [...upper, ...lower];\n }, [showSpecials, _arch, dentition, projection, layout.width, slotHeight]);\n\n // The `both` view pins every sub-chart to the widest row's width (upper\n // facial carries the most columns: Q1, Q2, AS, Gen.) so all four scale\n // identically and stay column-aligned.\n const bothContentWidth = useMemo(() => {\n if (!showBoth) return undefined;\n if (!showSpecials) return layout.width;\n let max = layout.width;\n for (const arch of ['upper', 'lower'] as Arch[]) {\n for (const proj of ['side', 'plan'] as Projection[]) {\n const w = layoutSpecials(\n specialsForRow(dentition, arch, proj),\n layout.width,\n ).width;\n if (w > max) max = w;\n }\n }\n return max;\n }, [showBoth, showSpecials, dentition, layout.width]);\n\n const visibleIds = useMemo(\n () => [\n ...layout.teeth.map((tooth) => tooth.fdi),\n // Special slots join keyboard nav only when interactive — in display /\n // radiograph-open mode they are decorative (role=\"img\"), so the\n // radiograph-open keyboard path never reaches a region id.\n ...(mode === 'interactive' ? specials.map((s) => s.element.id) : []),\n ],\n [layout, specials, mode],\n );\n\n // Roving tabindex: which slot (tooth or special) owns `tabindex=\"0\"`.\n const firstId: FdiId | undefined = visibleIds[0];\n const [focusedId, setFocusedId] = useState<FdiId | undefined>(firstId);\n useEffect(() => {\n if (!focusedId || !visibleIds.includes(focusedId)) {\n setFocusedId(firstId);\n }\n }, [firstId, focusedId, visibleIds]);\n\n // Live-region announcement text.\n const [announcement, setAnnouncement] = useState<string>('');\n\n const svgRef = useRef<SVGSVGElement>(null);\n\n const commitChart = useCallback(\n (next: ToothChart) => {\n if (!isControlled({ value })) {\n setInternalChart(next);\n }\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const focusToothById = useCallback((id: FdiId) => {\n const svg = svgRef.current;\n if (!svg) return;\n const node = svg.querySelector<SVGGElement>(`g[data-fdi=\"${id}\"]`);\n if (node) {\n node.focus();\n setFocusedId(id);\n }\n }, []);\n\n // The announcement string for selecting / deselecting a tooth or element.\n const buildAnnouncement = useCallback(\n (id: FdiId, conditions: ToothCondition[]): string => {\n const conditionText = conditions\n .map((c) => t(`toothScheme.condition.${c}`))\n .join(', ');\n if (isSpecialElement(id)) {\n const name = elementName(SPECIAL_BY_ID[id], t);\n return conditions.length > 0\n ? t('toothScheme.elementSelected', {\n name,\n conditions: conditionText,\n })\n : t('toothScheme.elementDeselected', { name });\n }\n return conditions.length > 0\n ? t('toothScheme.selected', { id, conditions: conditionText })\n : t('toothScheme.deselected', { id });\n },\n [t],\n );\n\n /* ------------------------------------------------------------- */\n /* Per-surface picking (plan view, caries / filling) */\n /* ------------------------------------------------------------- */\n\n // Live only in the occlusal (plan) view while a surface finding\n // (caries / filling) is the active tool.\n const surfacePicking =\n projection === 'plan' &&\n mode === 'interactive' &&\n (activeCondition === 'caries' || activeCondition === 'filled');\n\n // Drill-in state: the tooth + zone the keyboard is currently inside\n // (null = tooth-level navigation, the default).\n const [drilled, setDrilled] = useState<{\n fdi: FdiId;\n zone: SurfaceZone;\n } | null>(null);\n\n // End the drill if surface-picking turns off (tool / view change) OR the\n // drilled tooth leaves the layout (e.g. the dentition changes mid-drill) —\n // a stale drill would leave every tooth tabIndex=-1 and lock out keyboard.\n useEffect(() => {\n if (!surfacePicking || (drilled && !visibleIds.includes(drilled.fdi))) {\n setDrilled(null);\n }\n }, [surfacePicking, drilled, visibleIds]);\n\n const focusZone = useCallback((fdi: FdiId, zone: SurfaceZone) => {\n const node = svgRef.current?.querySelector<SVGPathElement>(\n `path[data-fdi=\"${fdi}\"][data-zone=\"${zone}\"]`,\n );\n node?.focus();\n }, []);\n\n // Move DOM focus onto the drilled zone when it changes; restore focus to\n // the tooth when the drill ends (Escape).\n const prevDrilled = useRef<{ fdi: FdiId; zone: SurfaceZone } | null>(null);\n useEffect(() => {\n if (drilled) {\n focusZone(drilled.fdi, drilled.zone);\n } else if (prevDrilled.current) {\n focusToothById(prevDrilled.current.fdi);\n }\n prevDrilled.current = drilled;\n }, [drilled, focusZone, focusToothById]);\n\n const isSurfaceMarked = useCallback(\n (fdi: FdiId, surface: Surface): boolean => {\n const state = chart[fdi];\n return Boolean(\n state &&\n state.surfaces.includes(surface) &&\n state.conditions.includes(activeCondition as ToothCondition),\n );\n },\n [chart, activeCondition],\n );\n\n const announceTooth = useCallback(\n (fdi: FdiId, state: ToothState | undefined) => {\n if (state && state.conditions.length > 0) {\n setAnnouncement(\n t('toothScheme.selected', {\n id: fdi,\n conditions: state.conditions\n .map((c) => t(`toothScheme.condition.${c}`))\n .join(', '),\n }),\n );\n } else {\n setAnnouncement(t('toothScheme.deselected', { id: fdi }));\n }\n },\n [t],\n );\n\n const toggleSurface = useCallback(\n (fdi: FdiId, surface: Surface) => {\n if (!surfacePicking) return;\n const cond = activeCondition as ToothCondition;\n const prev = chart[fdi] ?? emptyState();\n const hadSurface = prev.surfaces.includes(surface);\n const hadCond = prev.conditions.includes(cond);\n let surfaces: Surface[];\n let conditions: ToothCondition[];\n if (hadSurface && hadCond) {\n surfaces = prev.surfaces.filter((s) => s !== surface);\n conditions =\n surfaces.length === 0\n ? prev.conditions.filter((c) => c !== cond)\n : prev.conditions;\n } else {\n surfaces = hadSurface ? prev.surfaces : [...prev.surfaces, surface];\n conditions = hadCond ? prev.conditions : [...prev.conditions, cond];\n }\n const next: ToothChart = { ...chart };\n if (conditions.length === 0 && surfaces.length === 0) {\n delete next[fdi];\n } else {\n next[fdi] = { ...prev, conditions, surfaces };\n }\n commitChart(next);\n announceTooth(fdi, next[fdi]);\n onSelect?.(fdi);\n },\n [\n surfacePicking,\n activeCondition,\n chart,\n commitChart,\n announceTooth,\n onSelect,\n ],\n );\n\n const drillInto = useCallback((fdi: FdiId) => {\n const meta = FDI_TO_META[fdi];\n if (!meta) return;\n setFocusedId(fdi);\n setDrilled({ fdi, zone: zonesForTooth(meta)[0] });\n }, []);\n\n const handleSurfaceKeyDown = useCallback(\n (event: KeyboardEvent<SVGPathElement>, fdi: FdiId, zone: SurfaceZone) => {\n const meta = FDI_TO_META[fdi];\n if (!meta) return;\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n case 'ArrowLeft':\n case 'ArrowRight': {\n event.preventDefault();\n event.stopPropagation();\n const hasCenter = zonesForTooth(meta).includes('center');\n const nz = nextZone(zone, event.key, hasCenter);\n if (nz !== zone) setDrilled({ fdi, zone: nz });\n return;\n }\n case ' ':\n case 'Enter': {\n event.preventDefault();\n event.stopPropagation();\n toggleSurface(fdi, zoneSurface(meta, zone));\n return;\n }\n case 'Escape': {\n event.preventDefault();\n event.stopPropagation();\n setDrilled(null);\n return;\n }\n default:\n return;\n }\n },\n [toggleSurface],\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n // Radiograph \"open archive\" affordance. In display mode, when an open\n // handler is provided, each tooth becomes a button that opens its film\n // archive — reusing the roving-tabindex + button wiring (no nested\n // interactivity), mutually exclusive with interactive findings-editing.\n const radiographOpenable =\n mode === 'display' && typeof onOpenRadiographs === 'function';\n // Teeth are keyboard-focusable in interactive mode OR radiograph-open mode.\n const teethFocusable = mode === 'interactive' || radiographOpenable;\n\n const handleOpenRadiographs = useCallback(\n (id: FdiId) => {\n setFocusedId(id);\n onSelect?.(id);\n onOpenRadiographs?.(id);\n },\n [onSelect, onOpenRadiographs],\n );\n\n const agentHandle = useMemo<ToothSchemeHandle>(\n () => ({\n focusTooth: (id: FdiId) => {\n focusToothById(id);\n },\n getChart: () => chart,\n getTooth: (id: FdiId) => chart[id]?.conditions ?? [],\n teethWith: (condition: ToothCondition) =>\n Object.entries(chart)\n .filter(([, state]) => state.conditions.includes(condition))\n .map(([fdi]) => fdi),\n setFinding: (\n id: FdiId,\n condition: ToothCondition,\n surfaces?: Surface[],\n ) => {\n const prev = chart[id] ?? emptyState();\n if (prev.conditions.includes(condition) && !surfaces) return;\n const next: ToothChart = {\n ...chart,\n [id]: {\n ...prev,\n conditions: prev.conditions.includes(condition)\n ? prev.conditions\n : [...prev.conditions, condition],\n surfaces: surfaces ?? prev.surfaces,\n },\n };\n commitChart(next);\n },\n removeFinding: (id: FdiId, condition: ToothCondition) => {\n const prev = chart[id];\n if (!prev || !prev.conditions.includes(condition)) return;\n const conditions = prev.conditions.filter((c) => c !== condition);\n const next: ToothChart = { ...chart };\n if (conditions.length === 0) {\n delete next[id];\n } else {\n next[id] = { ...prev, conditions };\n }\n commitChart(next);\n },\n clearTooth: (id: FdiId) => {\n if (!chart[id]) return;\n const next: ToothChart = { ...chart };\n delete next[id];\n commitChart(next);\n },\n getRadiographs: (id: FdiId) => radiographs?.[id] ?? [],\n teethWithRadiographs: () =>\n Object.keys(radiographs ?? {}).filter(\n (fdi) => (radiographs?.[fdi]?.length ?? 0) > 0,\n ),\n openRadiographs: (id: FdiId) => {\n focusToothById(id);\n handleOpenRadiographs(id);\n },\n }),\n [chart, commitChart, focusToothById, radiographs, handleOpenRadiographs],\n );\n useImperativeHandle(ref, () => agentHandle, [agentHandle]);\n // Only the outer chart registers with the agent registry; the inner\n // `both`-view sub-charts share its chart data and pass no id, so the\n // registration is a no-op for them (guarded on a truthy instanceId).\n useAgentRegistration(\n toothSchemeAgent,\n agentHandle,\n _inner ? undefined : id,\n );\n\n /* ------------------------------------------------------------- */\n /* Keyboard navigation */\n /* ------------------------------------------------------------- */\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<SVGGElement>, id: FdiId) => {\n if (!teethFocusable) return;\n // `meta` is undefined for a special-element slot — those skip the\n // tooth-only vertical / quadrant navigation but keep linear nav + activation.\n const meta = FDI_TO_META[id];\n\n // Resolve the ordered list of visible ids for Left/Right.\n const order = visibleIds;\n const currentIndex = order.indexOf(id);\n\n switch (event.key) {\n case 'ArrowRight': {\n event.preventDefault();\n const nextIndex = Math.min(order.length - 1, currentIndex + 1);\n focusToothById(order[nextIndex]);\n return;\n }\n case 'ArrowLeft': {\n event.preventDefault();\n const nextIndex = Math.max(0, currentIndex - 1);\n focusToothById(order[nextIndex]);\n return;\n }\n case 'ArrowUp':\n case 'ArrowDown': {\n event.preventDefault();\n if (!meta) return;\n // Map to the opposing arch, same FDI position where possible.\n // Permanent: 1 ↔ 4, 2 ↔ 3. Primary: 5 ↔ 8, 6 ↔ 7.\n const quadrantMap: Record<number, number> = {\n 1: 4,\n 4: 1,\n 2: 3,\n 3: 2,\n 5: 8,\n 8: 5,\n 6: 7,\n 7: 6,\n };\n const targetQuadrant = quadrantMap[meta.quadrant];\n if (!targetQuadrant) return;\n const candidate = `${targetQuadrant}${meta.positionInQuadrant}`;\n if (order.includes(candidate)) {\n focusToothById(candidate);\n }\n return;\n }\n case 'Home': {\n event.preventDefault();\n if (!meta) return;\n // First tooth in the same quadrant (visible).\n const inQuadrant = order.filter(\n (other) => FDI_TO_META[other]?.quadrant === meta.quadrant,\n );\n if (inQuadrant.length > 0) {\n focusToothById(inQuadrant[0]);\n }\n return;\n }\n case 'End': {\n event.preventDefault();\n if (!meta) return;\n const inQuadrant = order.filter(\n (other) => FDI_TO_META[other]?.quadrant === meta.quadrant,\n );\n if (inQuadrant.length > 0) {\n focusToothById(inQuadrant[inQuadrant.length - 1]);\n }\n return;\n }\n case ' ':\n case 'Enter': {\n event.preventDefault();\n // Radiograph-open mode: Enter/Space opens the tooth's film archive\n // rather than editing findings.\n if (radiographOpenable) {\n handleOpenRadiographs(id);\n return;\n }\n // In surface-picking mode, Enter drills into the tooth's surfaces\n // rather than toggling the whole tooth (teeth only).\n if (surfacePicking && meta) {\n drillInto(id);\n return;\n }\n const prev = chart[id]?.conditions;\n const nextConditions = cycleCondition(prev, activeCondition);\n const next: ToothChart = { ...chart };\n if (nextConditions.length === 0) {\n delete next[id];\n } else {\n next[id] = {\n ...(chart[id] ?? emptyState()),\n conditions: nextConditions,\n };\n }\n setAnnouncement(buildAnnouncement(id, nextConditions));\n commitChart(next);\n onSelect?.(id);\n return;\n }\n default:\n return;\n }\n },\n [\n activeCondition,\n buildAnnouncement,\n chart,\n commitChart,\n drillInto,\n focusToothById,\n handleOpenRadiographs,\n onSelect,\n radiographOpenable,\n surfacePicking,\n teethFocusable,\n visibleIds,\n ],\n );\n\n const handleClick = useCallback(\n (id: FdiId) => {\n if (mode !== 'interactive') return;\n setFocusedId(id);\n const prev = chart[id]?.conditions;\n const nextConditions = cycleCondition(prev, activeCondition);\n const next: ToothChart = { ...chart };\n if (nextConditions.length === 0) {\n delete next[id];\n } else {\n next[id] = {\n ...(chart[id] ?? emptyState()),\n conditions: nextConditions,\n };\n }\n setAnnouncement(buildAnnouncement(id, nextConditions));\n commitChart(next);\n onSelect?.(id);\n },\n [activeCondition, buildAnnouncement, chart, commitChart, mode, onSelect],\n );\n\n // The whole-mouth `general` element is a switch beneath the chart (not a\n // column). It carries the active finding (or caries by default) across the\n // whole mouth — on records it, off clears it.\n const generalId: FdiId = dentition === 'primary' ? 'mGeneral' : 'general';\n const generalChecked = (chart[generalId]?.conditions.length ?? 0) > 0;\n const toggleGeneral = useCallback(\n (checked: boolean) => {\n const next: ToothChart = { ...chart };\n if (checked) {\n next[generalId] = {\n conditions: [activeCondition ?? 'caries'],\n surfaces: [],\n };\n } else {\n delete next[generalId];\n }\n setAnnouncement(\n buildAnnouncement(generalId, next[generalId]?.conditions ?? []),\n );\n commitChart(next);\n onSelect?.(generalId);\n },\n [\n activeCondition,\n buildAnnouncement,\n chart,\n commitChart,\n generalId,\n onSelect,\n ],\n );\n\n /* ------------------------------------------------------------- */\n /* Rendering */\n /* ------------------------------------------------------------- */\n\n // Number-label headroom: `above` lifts numbers over the crowns (negative y),\n // `below` drops them under (past the slot); the single-view `between`\n // placement keeps numbers in the inter-arch gap, so it needs no extra pad.\n const topPad = _numbersPosition === 'above' ? 16 : 2;\n const bottomPad = _numbersPosition === 'below' ? 16 : 2;\n const specialsWidth =\n specials.length > 0\n ? Math.max(...specials.map((s) => s.x)) + SPECIAL_SLOT_WIDTH\n : 0;\n // `_contentWidth` (set on the four `both`-view sub-charts) pins every row to\n // one width so they scale identically; otherwise each row sizes to its own\n // content and a row with fewer special columns would render larger.\n const contentWidth = Math.max(\n _contentWidth ?? 0,\n layout.width,\n specialsWidth,\n );\n const viewBoxWidth = contentWidth + 4;\n const viewBoxHeight = layout.height + topPad + bottomPad;\n\n const baseLabel = ariaLabel ?? t('toothScheme.ariaLabel');\n\n // The root is horizontally scrollable (`overflow-x-auto`), so it needs\n // keyboard access. In interactive mode the roving-tabindex teeth supply\n // it; in display mode nothing inside is focusable, so the scroll\n // container itself becomes the tab stop (WCAG 2.1.1 / axe\n // scrollable-region-focusable).\n const scrollTabIndex = teethFocusable ? undefined : 0;\n\n // The chart `<svg>` — reused for the single-projection view (this instance)\n // and each `both`-view sub-chart (an `_inner` instance). Built only when\n // this instance renders its own teeth (i.e. NOT the `both`-view outer host).\n const chartSvg = showBoth ? null : (\n <svg\n ref={svgRef}\n viewBox={`0 ${-topPad} ${viewBoxWidth} ${viewBoxHeight}`}\n width={viewBoxWidth}\n height={viewBoxHeight}\n className={svgVariants()}\n role=\"group\"\n aria-label={baseLabel}\n // Never a tab stop itself — keyboard focus lives on the teeth\n // (interactive) or the scroll container (display). Legacy engines\n // make a labelled SVG focusable without this.\n focusable=\"false\"\n data-testid=\"tooth-scheme-svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {layout.teeth.map((tooth) => {\n const state = chart[tooth.fdi];\n const primaryCondition: ToothCondition | undefined =\n state?.conditions?.[0];\n\n const anatomyLabel = t(`toothScheme.anatomy.${tooth.meta.anatomy}`);\n const conditionSuffix = primaryCondition\n ? `, ${t(`toothScheme.condition.${primaryCondition}`)}`\n : '';\n const toothRadiographs = radiographs?.[tooth.fdi] ?? [];\n const radiographCount = toothRadiographs.length;\n const hasRadiographs = radiographCount > 0;\n // Most-recent film (newest date first; undated sink last) drives\n // the thumbnail + tooltip.\n const latestRadiograph = hasRadiographs\n ? [...toothRadiographs].sort(sortByDateDesc)[0]\n : undefined;\n const showThumbnail =\n radiographDisplay === 'thumbnail' && latestRadiograph !== undefined;\n // Surface the radiograph count to AT via the accessible name so\n // it is announced, not signalled by the corner badge alone.\n const radiographSuffix = hasRadiographs\n ? `, ${t('toothScheme.radiographBadge', { count: radiographCount })}`\n : '';\n // In the `both` view the same tooth renders in a facial AND an\n // occlusal sub-chart — fold the projection into the name so a screen\n // reader can tell the two apart (a `role=\"group\"` name is not reliably\n // announced on a focused SVG descendant).\n const projectionSuffix = _inner\n ? `, ${\n projection === 'plan'\n ? t('toothScheme.view.occlusal')\n : t('toothScheme.view.side')\n }`\n : '';\n const label =\n t('toothScheme.toothLabel', {\n id: labelFor(tooth.fdi, numbering),\n anatomy: anatomyLabel,\n conditionSuffix,\n }) +\n radiographSuffix +\n projectionSuffix;\n\n const tabIndex = teethFocusable\n ? drilled\n ? -1\n : tooth.fdi === focusedId\n ? 0\n : -1\n : undefined;\n\n const conditions = state?.conditions ?? [];\n const isMissing = conditions.includes('missing');\n // Whole-tooth findings (crown, implant, RCT…) overlay a photoreal\n // symbol render on the facial tooth.\n const symbolOverlays = conditions\n .map((condition) => ({\n condition,\n spec: CONDITION_SIDE_SYMBOL[condition],\n }))\n .filter(\n (\n entry,\n ): entry is {\n condition: ToothCondition;\n spec: NonNullable<typeof entry.spec>;\n } => Boolean(entry.spec),\n );\n // Surface findings (caries / filled) have no side symbol — flag\n // them with a token-coloured ring until the plan view lands.\n const surfaceCondition = conditions.find(\n (condition) =>\n condition !== 'missing' && !CONDITION_SIDE_SYMBOL[condition],\n );\n const ringColour = surfaceCondition\n ? CONDITION_COLORS[surfaceCondition]\n : undefined;\n\n const tooltipContent =\n (primaryCondition\n ? `${anatomyLabel} · ${t(`toothScheme.condition.${primaryCondition}`)}`\n : anatomyLabel) +\n (hasRadiographs\n ? ` · ${t('toothScheme.radiographBadge', { count: radiographCount })}`\n : '');\n\n const labelText = labelFor(tooth.fdi, numbering);\n const imageUrl = toothImageUrl(\n tooth.meta,\n assetBaseUrl,\n 'default',\n projection,\n );\n // In thumbnail display the most-recent film fills the slot\n // (cropped via `slice`) in place of the photoreal render.\n const slotImageHref =\n showThumbnail && latestRadiograph\n ? (latestRadiograph.thumbnailUrl ?? latestRadiograph.url)\n : imageUrl;\n // Plan (occlusal) view: per-surface caries / filling overlays —\n // the \"Stato dentale\" surface marking.\n const surfaceOverlays =\n projection === 'plan'\n ? conditions.flatMap((condition) => {\n const folder = CONDITION_PLAN_FOLDER[condition];\n if (!folder) return [];\n return (state?.surfaces ?? []).map((surface) => ({\n key: `${condition}-${surface}`,\n url: surfaceSymbolUrl(\n tooth.meta,\n assetBaseUrl,\n folder,\n surface,\n ),\n }));\n })\n : [];\n\n // Primary teeth reuse the permanent render scaled down. A small\n // inset on every tooth keeps the render off the slot edges so\n // the focus ring + labels never crowd or touch it.\n const imgScale =\n (tooth.meta.dentition === 'primary' ? PRIMARY_TOOTH_SCALE : 1) *\n 0.9;\n const imgW = TOOTH_SLOT_WIDTH * imgScale;\n const imgH = slotHeight * imgScale;\n const imgX = (TOOTH_SLOT_WIDTH - imgW) / 2;\n const imgY = (slotHeight - imgH) / 2;\n\n // Surface-picking zones (plan view). When drilled into THIS\n // tooth, its zones become the focusable buttons and the tooth\n // group steps back to a plain container (no nested interactive).\n const isDrilled = surfacePicking && drilled?.fdi === tooth.fdi;\n const toothZones = surfacePicking ? zonesForTooth(tooth.meta) : [];\n const hasCenter = toothZones.includes('center');\n\n // Number-label y per the sub-chart's number placement.\n const numberY =\n _numbersPosition === 'above'\n ? -4\n : _numbersPosition === 'below'\n ? slotHeight + 12\n : _numbersPosition === 'none'\n ? null\n : tooth.meta.arch === 'upper'\n ? slotHeight + 12\n : -4;\n\n return (\n <RadixTooltip.Root key={tooth.fdi}>\n <RadixTooltip.Trigger asChild>\n <g\n data-fdi={tooth.fdi}\n data-anatomy={tooth.meta.anatomy}\n data-arch={tooth.meta.arch}\n data-side={tooth.meta.side}\n data-quadrant={tooth.meta.quadrant}\n data-condition={primaryCondition ?? 'none'}\n data-testid={`tooth-${tooth.fdi}`}\n transform={`translate(${tooth.x}, ${tooth.y})`}\n tabIndex={tabIndex}\n // SVG `<g>` has no implicit role, so `aria-label`\n // would be rejected by axe's `aria-prohibited-attr`\n // rule. Give it an explicit role: `button` in\n // interactive mode, `img` in display mode. When drilled\n // into for surface picking it becomes a `group` so its\n // focusable surface zones aren't nested in a button.\n role={isDrilled ? 'group' : teethFocusable ? 'button' : 'img'}\n aria-label={label}\n aria-pressed={\n isDrilled\n ? undefined\n : mode === 'interactive'\n ? primaryCondition !== undefined\n : undefined\n }\n className={toothGroupVariants()}\n onClick={\n isDrilled\n ? undefined\n : mode === 'interactive'\n ? surfacePicking\n ? () => drillInto(tooth.fdi)\n : () => handleClick(tooth.fdi)\n : radiographOpenable\n ? () => handleOpenRadiographs(tooth.fdi)\n : undefined\n }\n onFocus={() => setFocusedId(tooth.fdi)}\n onKeyDown={\n isDrilled\n ? undefined\n : (event) => handleKeyDown(event, tooth.fdi)\n }\n >\n {/* Invisible ≥44px hit target (WCAG 2.5.5). */}\n <rect\n x={-TOOTH_HIT_PAD}\n y={-TOOTH_HIT_PAD}\n width={TOOTH_SLOT_WIDTH + TOOTH_HIT_PAD * 2}\n height={slotHeight + TOOTH_HIT_PAD * 2}\n fill=\"transparent\"\n />\n {/* Photoreal tooth render (side = facial, plan =\n occlusal). The upper/lower view folders are\n pre-oriented, so no mirroring is needed. Decorative —\n the parent <g> carries the accessible name. */}\n <image\n href={slotImageHref}\n x={imgX}\n y={imgY}\n width={imgW}\n height={imgH}\n preserveAspectRatio={\n showThumbnail ? 'xMidYMid slice' : 'xMidYMid meet'\n }\n opacity={isMissing && !showThumbnail ? 0.25 : 1}\n aria-hidden=\"true\"\n />\n {/* Side view: whole-tooth symbol overlays (crown,\n implant, RCT, bridge…) composited on the facial\n tooth. The distinct glyph is the colour-independent\n channel; the group's accessible name names it. */}\n {projection === 'side'\n ? symbolOverlays.map(({ condition, spec }) => (\n <image\n key={condition}\n href={conditionSymbolUrl(\n tooth.meta,\n assetBaseUrl,\n spec,\n )}\n x={imgX}\n y={imgY}\n width={imgW}\n height={imgH}\n preserveAspectRatio=\"xMidYMid meet\"\n aria-hidden=\"true\"\n pointerEvents=\"none\"\n />\n ))\n : null}\n {/* Plan view: per-surface caries / filling overlays —\n the \"Stato dentale\" surface marking. */}\n {projection === 'plan'\n ? surfaceOverlays.map(({ key, url }) => (\n <image\n key={key}\n href={url}\n x={imgX}\n y={imgY}\n width={imgW}\n height={imgH}\n preserveAspectRatio=\"xMidYMid meet\"\n aria-hidden=\"true\"\n pointerEvents=\"none\"\n />\n ))\n : null}\n {/* Plan view: interactive surface-picking zones. Pointer\n clicks mark a surface directly; keyboard users drill\n in (Enter) then pick a zone (arrows), so the zones are\n focusable buttons only while THIS tooth is drilled. */}\n {surfacePicking\n ? toothZones.map((zone) => {\n const surface = zoneSurface(tooth.meta, zone);\n const marked = isSurfaceMarked(tooth.fdi, surface);\n return (\n <path\n key={zone}\n d={zonePath(\n zone,\n { x: imgX, y: imgY, w: imgW, h: imgH },\n hasCenter,\n )}\n data-fdi={tooth.fdi}\n data-zone={zone}\n data-surface={surface}\n data-testid={`tooth-${tooth.fdi}-zone-${zone}`}\n role={isDrilled ? 'button' : undefined}\n tabIndex={\n isDrilled\n ? drilled?.zone === zone\n ? 0\n : -1\n : undefined\n }\n aria-label={\n isDrilled\n ? t('toothScheme.toothLabel', {\n id: labelText,\n anatomy: t(\n `toothScheme.surface.${surface}`,\n ),\n conditionSuffix: '',\n })\n : undefined\n }\n aria-pressed={isDrilled ? marked : undefined}\n strokeWidth=\"var(--focus-ring-width)\"\n className={zoneVariants()}\n onClick={(event) => {\n event.stopPropagation();\n if (!isDrilled) setFocusedId(tooth.fdi);\n toggleSurface(tooth.fdi, surface);\n }}\n onKeyDown={\n isDrilled\n ? (event) =>\n handleSurfaceKeyDown(event, tooth.fdi, zone)\n : undefined\n }\n onFocus={\n isDrilled\n ? () =>\n setDrilled((d) =>\n d &&\n d.fdi === tooth.fdi &&\n d.zone === zone\n ? d\n : { fdi: tooth.fdi, zone },\n )\n : undefined\n }\n />\n );\n })\n : null}\n {/* Side view: surface-finding ring (caries / filled)\n stands in until the plan view marks the surface. */}\n {projection === 'side' && ringColour ? (\n <rect\n x={3}\n y={2}\n width={TOOTH_SLOT_WIDTH - 6}\n height={slotHeight - 4}\n fill=\"none\"\n stroke={ringColour}\n strokeWidth=\"2\"\n // Distinguish caries (solid) from filled (dashed) by\n // line style, not colour alone (WCAG 1.4.1).\n strokeDasharray={\n surfaceCondition === 'filled' ? '4 2' : undefined\n }\n rx=\"6\"\n pointerEvents=\"none\"\n />\n ) : null}\n {/* Missing-tooth X glyph over the faded render. */}\n {isMissing ? (\n <path\n d={`M7 9 L${TOOTH_SLOT_WIDTH - 7} ${slotHeight - 9} M${TOOTH_SLOT_WIDTH - 7} 9 L7 ${slotHeight - 9}`}\n stroke={CONDITION_COLORS.missing}\n strokeWidth=\"2\"\n fill=\"none\"\n pointerEvents=\"none\"\n />\n ) : null}\n {/* Thumbnail-mode frame — a token border so the x-ray\n reads as a framed film rather than a tooth render. */}\n {showThumbnail ? (\n <rect\n x={imgX}\n y={imgY}\n width={imgW}\n height={imgH}\n fill=\"none\"\n stroke=\"var(--border)\"\n strokeWidth=\"1\"\n rx=\"3\"\n pointerEvents=\"none\"\n />\n ) : null}\n {/* Radiograph count badge — bottom-inline-end corner.\n Decorative (aria-hidden); the count is announced via\n the tooth's accessible name. An opaque --card chip\n keeps the count legible over the photoreal render. */}\n {hasRadiographs ? (\n <g\n data-testid={`tooth-${tooth.fdi}-radiograph-badge`}\n data-radiograph-count={radiographCount}\n transform={`translate(${TOOTH_SLOT_WIDTH - (radiographCount >= 10 ? 19 : 15)}, ${slotHeight - 13})`}\n pointerEvents=\"none\"\n aria-hidden=\"true\"\n >\n <rect\n width={radiographCount >= 10 ? 17 : 13}\n height={12}\n rx=\"3.5\"\n fill=\"var(--card)\"\n stroke=\"var(--info-foreground)\"\n strokeWidth=\"0.75\"\n />\n <text\n x={(radiographCount >= 10 ? 17 : 13) / 2}\n y={9}\n textAnchor=\"middle\"\n fontSize=\"9\"\n fontWeight=\"600\"\n fill=\"var(--info-foreground)\"\n className=\"ds:select-none\"\n >\n {radiographCount}\n </text>\n </g>\n ) : null}\n {/* Focus ring — drawn as a rect so it tracks the hit\n area. `group` on the parent <g> makes this\n group-focus-visible selector fire when a keyboard\n user focuses the tooth. In forced-colors mode the\n ring falls back to `CanvasText` so it stays visible\n when `var(--ring)` is remapped. */}\n <rect\n x={-TOOTH_HIT_PAD}\n y={-TOOTH_HIT_PAD}\n width={TOOTH_SLOT_WIDTH + TOOTH_HIT_PAD * 2}\n height={slotHeight + TOOTH_HIT_PAD * 2}\n fill=\"none\"\n stroke=\"var(--ring)\"\n strokeWidth=\"var(--focus-ring-width)\"\n className={[\n 'ds:opacity-0',\n 'ds:group-focus-visible:opacity-100',\n 'ds:forced-colors:stroke-[CanvasText]',\n ].join(' ')}\n data-testid={`tooth-${tooth.fdi}-focus-ring`}\n pointerEvents=\"none\"\n rx=\"4\"\n />\n {/* Tooth number label — placement follows the sub-chart's\n number position (`above` / `below` / between arches). */}\n {numberY !== null ? (\n <text\n x={TOOTH_SLOT_WIDTH / 2}\n y={numberY}\n textAnchor=\"middle\"\n fontSize=\"10\"\n fill=\"var(--muted-foreground)\"\n className=\"ds:select-none\"\n aria-hidden=\"true\"\n >\n {labelText}\n </text>\n ) : null}\n </g>\n </RadixTooltip.Trigger>\n <RadixTooltip.Portal>\n <RadixTooltip.Content\n side=\"top\"\n sideOffset={6}\n className=\"ds:z-[var(--z-tooltip)] ds:rounded-[var(--radius-sm)] ds:bg-[var(--foreground)] ds:text-[var(--background)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:pt-[calc(var(--spacing-xs)/2)] ds:pb-[calc(var(--spacing-xs)/2)] ds:text-[length:var(--font-size-xs)]\"\n >\n {tooltipContent}\n <RadixTooltip.Arrow className=\"ds:fill-[var(--foreground)]\" />\n </RadixTooltip.Content>\n </RadixTooltip.Portal>\n </RadixTooltip.Root>\n );\n })}\n\n {/* Special elements — selectable quadrant / sextant / arch / whole-mouth\n slots. A label block: outline when empty, accent-tinted with a\n condition-coloured border when a finding is recorded (fill state is\n the colour-independent channel; the finding is also in the name). */}\n {specials.map(({ element, x, y }) => {\n const state = chart[element.id];\n const cond = state?.conditions?.[0];\n const selected = cond !== undefined;\n const name = elementName(element, t);\n const conditionSuffix = cond\n ? `, ${t(`toothScheme.condition.${cond}`)}`\n : '';\n const label = t('toothScheme.elementLabel', {\n name,\n conditionSuffix,\n });\n const condColour = cond ? CONDITION_COLORS[cond] : undefined;\n // Quadrants / arches / general render a photoreal icon (matching the\n // platform); sextants are label-only.\n const iconUrl = specialIconUrl(element, assetBaseUrl);\n // Region slots are selectable only in interactive mode — never\n // filmable, so they stay decorative in display / radiograph-open mode.\n const elementInteractive = mode === 'interactive';\n const tabIndex = elementInteractive\n ? element.id === focusedId\n ? 0\n : -1\n : undefined;\n\n return (\n <RadixTooltip.Root key={element.id}>\n <RadixTooltip.Trigger asChild>\n <g\n data-fdi={element.id}\n data-special={element.kind}\n data-arch={element.arch}\n data-condition={cond ?? 'none'}\n data-testid={`element-${element.id}`}\n transform={`translate(${x}, ${y})`}\n tabIndex={tabIndex}\n role={elementInteractive ? 'button' : 'img'}\n aria-label={label}\n aria-pressed={elementInteractive ? selected : undefined}\n className={toothGroupVariants()}\n onClick={\n elementInteractive\n ? () => handleClick(element.id)\n : undefined\n }\n onFocus={\n elementInteractive\n ? () => setFocusedId(element.id)\n : undefined\n }\n onKeyDown={\n elementInteractive\n ? (event) => handleKeyDown(event, element.id)\n : undefined\n }\n >\n {/* Invisible ≥44px hit target. */}\n <rect\n x={-TOOTH_HIT_PAD}\n y={-TOOTH_HIT_PAD}\n width={SPECIAL_SLOT_WIDTH + TOOTH_HIT_PAD * 2}\n height={slotHeight + TOOTH_HIT_PAD * 2}\n fill=\"transparent\"\n />\n <rect\n x={0}\n y={0}\n width={SPECIAL_SLOT_WIDTH}\n height={slotHeight}\n rx={6}\n fill={selected ? 'var(--accent)' : 'var(--card)'}\n fillOpacity={selected ? 0.16 : 1}\n stroke={condColour ?? 'var(--border)'}\n strokeWidth={selected ? 2 : 1}\n />\n {iconUrl ? (\n <>\n {/* Photoreal region icon (quadrant / arch / general). */}\n <image\n href={iconUrl}\n x={3}\n y={3}\n width={SPECIAL_SLOT_WIDTH - 6}\n height={slotHeight - 16}\n preserveAspectRatio=\"xMidYMid meet\"\n aria-hidden=\"true\"\n pointerEvents=\"none\"\n />\n <text\n x={SPECIAL_SLOT_WIDTH / 2}\n y={slotHeight - 4}\n textAnchor=\"middle\"\n fontSize=\"9\"\n fontWeight=\"600\"\n fill=\"var(--muted-foreground)\"\n className=\"ds:select-none\"\n aria-hidden=\"true\"\n >\n {element.code}\n </text>\n </>\n ) : (\n <text\n x={SPECIAL_SLOT_WIDTH / 2}\n y={slotHeight / 2}\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n fontSize=\"11\"\n fontWeight=\"600\"\n fill=\"var(--foreground)\"\n className=\"ds:select-none\"\n aria-hidden=\"true\"\n >\n {element.code}\n </text>\n )}\n {/* Focus ring. */}\n <rect\n x={-TOOTH_HIT_PAD}\n y={-TOOTH_HIT_PAD}\n width={SPECIAL_SLOT_WIDTH + TOOTH_HIT_PAD * 2}\n height={slotHeight + TOOTH_HIT_PAD * 2}\n fill=\"none\"\n stroke=\"var(--ring)\"\n strokeWidth=\"var(--focus-ring-width)\"\n className={[\n 'ds:opacity-0',\n 'ds:group-focus-visible:opacity-100',\n 'ds:forced-colors:stroke-[CanvasText]',\n ].join(' ')}\n data-testid={`element-${element.id}-focus-ring`}\n pointerEvents=\"none\"\n rx=\"6\"\n />\n </g>\n </RadixTooltip.Trigger>\n <RadixTooltip.Portal>\n <RadixTooltip.Content\n side=\"top\"\n sideOffset={6}\n className=\"ds:z-[var(--z-tooltip)] ds:rounded-[var(--radius-sm)] ds:bg-[var(--foreground)] ds:text-[var(--background)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:pt-[calc(var(--spacing-xs)/2)] ds:pb-[calc(var(--spacing-xs)/2)] ds:text-[length:var(--font-size-xs)]\"\n >\n {cond\n ? `${name} · ${t(`toothScheme.condition.${cond}`)}`\n : name}\n <RadixTooltip.Arrow className=\"ds:fill-[var(--foreground)]\" />\n </RadixTooltip.Content>\n </RadixTooltip.Portal>\n </RadixTooltip.Root>\n );\n })}\n </svg>\n );\n\n // The sr-only live region announcing selection changes. Each chart (single\n // view or `both`-view sub-chart) owns one, so announcements stay local to\n // the row the user is editing.\n const liveRegion = (\n <div\n className={liveRegionVariants()}\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-testid=\"tooth-scheme-live\"\n >\n {announcement}\n </div>\n );\n\n // `_inner` sub-chart: render only the svg + its live region (no region\n // wrapper / controls / legend — the outer host supplies those).\n if (_inner) {\n return (\n <RadixTooltip.Provider delayDuration={200}>\n {chartSvg}\n {liveRegion}\n </RadixTooltip.Provider>\n );\n }\n\n // The `both` view: four arch-scoped sub-charts in clinical reading order —\n // upper facial, upper occlusal, lower occlusal, lower facial — so the two\n // occlusal rows sit between the two facial rows, numbers bracketing top and\n // bottom. Each shares this chart's data (value / onChange), so an edit in\n // any row propagates everywhere.\n const archLabel = (arch: Arch) =>\n arch === 'upper'\n ? t('toothScheme.arch.upper')\n : t('toothScheme.arch.lower');\n const rowLabel = (arch: Arch, view: Projection) =>\n `${baseLabel} — ${archLabel(arch)}, ${\n view === 'plan'\n ? t('toothScheme.view.occlusal')\n : t('toothScheme.view.side')\n }`;\n const sharedSubChartProps = {\n dentition,\n numbering,\n mode,\n value: chart,\n onChange: commitChart,\n onSelect,\n activeCondition,\n assetBaseUrl,\n radiographs,\n radiographDisplay,\n onOpenRadiographs,\n specialElements: showSpecials,\n _inner: true as const,\n _contentWidth: bothContentWidth,\n };\n const bothView = (\n <div className={bothStackVariants()} data-testid=\"tooth-scheme-both\">\n <ToothScheme\n {...sharedSubChartProps}\n projection=\"side\"\n _arch=\"upper\"\n _numbersPosition=\"above\"\n ariaLabel={rowLabel('upper', 'side')}\n />\n <ToothScheme\n {...sharedSubChartProps}\n projection=\"plan\"\n _arch=\"upper\"\n _numbersPosition=\"none\"\n ariaLabel={rowLabel('upper', 'plan')}\n />\n <ToothScheme\n {...sharedSubChartProps}\n projection=\"plan\"\n _arch=\"lower\"\n _numbersPosition=\"none\"\n ariaLabel={rowLabel('lower', 'plan')}\n />\n <ToothScheme\n {...sharedSubChartProps}\n projection=\"side\"\n _arch=\"lower\"\n _numbersPosition=\"below\"\n ariaLabel={rowLabel('lower', 'side')}\n />\n </div>\n );\n\n // The options gear, built once so the inline and portaled placements share\n // the same popover + state wiring. Rendered inline by default; portaled into\n // `controlsContainer` (e.g. a card header) when the consumer provides one.\n const controlsNode = controls ? (\n <div\n className={\n controlsContainer != null\n ? 'ds:flex ds:justify-end'\n : 'ds:flex ds:w-full ds:justify-end'\n }\n data-testid=\"tooth-scheme-controls\"\n >\n <Popover.Root>\n <Popover.Trigger asChild>\n <IconButton\n size=\"sm\"\n intent=\"outline\"\n icon={<Settings aria-hidden=\"true\" />}\n aria-label={t('toothScheme.options.label')}\n tooltip={t('toothScheme.options.label')}\n />\n </Popover.Trigger>\n <Popover.Content\n ref={setOptionsPopoverEl}\n align=\"end\"\n size=\"md\"\n aria-label={t('toothScheme.options.label')}\n >\n <div className=\"ds:flex ds:w-[var(--popover-size-sm)] ds:max-w-full ds:flex-col ds:gap-[var(--spacing-md)]\">\n {/* Stretch the toggle rows full-width so each control\n aligns to the inline-end edge like the selects below. */}\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:border-b ds:border-[color:var(--border)] ds:pb-[var(--spacing-sm)] ds:[&>*]:w-full ds:[&>*]:justify-between\">\n <Switch\n label={t('toothScheme.options.legend')}\n labelSide=\"start\"\n checked={legend}\n onCheckedChange={setUiLegend}\n />\n <Switch\n label={t('toothScheme.options.specialElements')}\n labelSide=\"start\"\n checked={showSpecials}\n onCheckedChange={setUiSpecial}\n />\n </div>\n <OptionRow\n container={optionsPopoverEl}\n label={t('toothScheme.options.dentition')}\n value={dentition}\n onValueChange={(v) => setUiDentition(v as Dentition)}\n options={[\n {\n value: 'permanent',\n label: t('toothScheme.dentition.permanent'),\n },\n {\n value: 'primary',\n label: t('toothScheme.dentition.primary'),\n },\n {\n value: 'mixed',\n label: t('toothScheme.dentition.mixed'),\n },\n ]}\n />\n <OptionRow\n container={optionsPopoverEl}\n label={t('toothScheme.options.numbering')}\n value={numbering}\n onValueChange={(v) => setUiNumbering(v as Numbering)}\n options={[\n {\n value: 'fdi',\n label: t('toothScheme.numbering.fdi'),\n },\n {\n value: 'universal',\n label: t('toothScheme.numbering.universal'),\n },\n {\n value: 'palmer',\n label: t('toothScheme.numbering.palmer'),\n },\n ]}\n />\n <OptionRow\n container={optionsPopoverEl}\n label={t('toothScheme.options.view')}\n value={viewMode}\n onValueChange={(v) => setUiProjection(v as ViewMode)}\n options={[\n {\n value: 'side',\n label: t('toothScheme.view.side'),\n },\n {\n value: 'plan',\n label: t('toothScheme.view.occlusal'),\n },\n {\n value: 'both',\n label: t('toothScheme.view.both'),\n },\n ]}\n />\n </div>\n </Popover.Content>\n </Popover.Root>\n </div>\n ) : null;\n\n return (\n <RadixTooltip.Provider delayDuration={200}>\n <div\n ref={rootRef}\n role=\"region\"\n aria-label={baseLabel}\n tabIndex={scrollTabIndex}\n className={[rootVariants(), className].filter(Boolean).join(' ')}\n data-component=\"tooth-scheme\"\n data-component-id={id}\n data-testid=\"tooth-scheme-root\"\n data-dentition={dentition}\n data-numbering={numbering}\n data-mode={mode}\n data-projection={projection}\n data-view-mode={viewMode}\n data-special-elements={showSpecials ? 'true' : 'false'}\n >\n {/* Options gear — inline by default; portaled into the consumer's\n `controlsContainer` slot (e.g. a card header) when one is passed.\n While that slot mounts the prop is `null`, so nothing renders here\n and the gear never flashes inline first. */}\n {controlsContainer === undefined\n ? controlsNode\n : controlsContainer\n ? createPortal(controlsNode, controlsContainer)\n : null}\n\n {showBoth ? bothView : chartSvg}\n\n {/* Whole-mouth `general` element — a switch beneath the chart, not a\n cramped icon column. Interactive-only; in display mode it shows\n only when a finding is set, as a read-only indicator. */}\n {showSpecials && (mode === 'interactive' || generalChecked) ? (\n <div\n className=\"ds:flex ds:w-full ds:items-center ds:pt-[var(--spacing-2xs)]\"\n data-testid=\"tooth-scheme-general\"\n >\n <Switch\n label={t('toothScheme.special.general')}\n labelSide=\"end\"\n checked={generalChecked}\n disabled={mode !== 'interactive'}\n onCheckedChange={toggleGeneral}\n />\n </div>\n ) : null}\n\n {legend ? <Legend assetBaseUrl={assetBaseUrl} /> : null}\n\n {liveRegion}\n </div>\n </RadixTooltip.Provider>\n );\n },\n);\n\nToothScheme.displayName = 'ToothScheme';\n\n/* ------------------------------------------------------------------ */\n/* Re-exports */\n/* ------------------------------------------------------------------ */\n\nexport { rootVariants as toothSchemeVariants, PERMANENT_TEETH, PRIMARY_TEETH };\nexport type {\n Dentition,\n FdiId,\n Numbering,\n SpecialElement,\n ToothChart,\n ToothCondition,\n ToothMode,\n ToothState,\n} from './tooth-data';\n"],"names":["FDI_SCHEMA","CONDITION_SCHEMA","SURFACE_SCHEMA","RADIOGRAPH_SCHEMA","toothSchemeAgent","handle","fdi","r","args","rootVariants","cva","bothStackVariants","svgVariants","toothGroupVariants","legendVariants","legendItemVariants","liveRegionVariants","zoneVariants","isControlled","props","emptyState","cycleCondition","current","active","list","condition","elementName","element","t","nextZone","zone","key","hasCenter","_a","ALL_CONDITIONS","LegendSymbol","assetBaseUrl","meta","FDI_TO_META","spec","CONDITION_SIDE_SYMBOL","isMissing","isSurface","w","h","x","y","jsxs","jsx","toothImageUrl","conditionSymbolUrl","CONDITION_COLORS","Legend","useTranslation","OptionRow","label","value","options","onValueChange","container","Select","sortByDateDesc","a","b","ToothScheme","forwardRef","id","dentitionProp","numberingProp","mode","projectionProp","specialElementsProp","defaultValue","onChange","onSelect","conditions","radiographs","radiographDisplay","onOpenRadiographs","activeCondition","legendProp","controls","controlsContainer","ariaLabel","className","_arch","_numbersPosition","_inner","_contentWidth","ref","uiDentition","setUiDentition","useState","uiNumbering","setUiNumbering","uiProjection","setUiProjection","uiLegend","setUiLegend","uiSpecial","setUiSpecial","optionsPopoverEl","setOptionsPopoverEl","dentition","numbering","legend","viewMode","projection","showBoth","specialAuto","showSpecials","controlsWasOn","useRef","useEffect","internalChart","setInternalChart","chartFromConditions","chart","slotHeight","TOOTH_SLOT_HEIGHT","layout","useMemo","layoutTeeth","specials","layoutSpecials","specialsForRow","upper","lowerRowY","TOOTH_ROW_GAP","lower","s","bothContentWidth","max","arch","proj","visibleIds","tooth","firstId","focusedId","setFocusedId","announcement","setAnnouncement","svgRef","commitChart","useCallback","next","focusToothById","svg","node","buildAnnouncement","conditionText","c","isSpecialElement","name","SPECIAL_BY_ID","surfacePicking","drilled","setDrilled","focusZone","prevDrilled","isSurfaceMarked","surface","state","announceTooth","toggleSurface","cond","prev","hadSurface","hadCond","surfaces","drillInto","zonesForTooth","handleSurfaceKeyDown","event","nz","zoneSurface","rootRef","radiographOpenable","teethFocusable","handleOpenRadiographs","agentHandle","useImperativeHandle","useAgentRegistration","handleKeyDown","order","currentIndex","nextIndex","targetQuadrant","candidate","inQuadrant","other","nextConditions","handleClick","generalId","generalChecked","toggleGeneral","checked","topPad","bottomPad","specialsWidth","SPECIAL_SLOT_WIDTH","viewBoxWidth","viewBoxHeight","baseLabel","scrollTabIndex","chartSvg","primaryCondition","anatomyLabel","conditionSuffix","toothRadiographs","radiographCount","hasRadiographs","latestRadiograph","showThumbnail","radiographSuffix","projectionSuffix","labelFor","tabIndex","symbolOverlays","entry","surfaceCondition","ringColour","tooltipContent","labelText","imageUrl","slotImageHref","surfaceOverlays","folder","CONDITION_PLAN_FOLDER","surfaceSymbolUrl","imgScale","PRIMARY_TOOTH_SCALE","imgW","TOOTH_SLOT_WIDTH","imgH","imgX","imgY","isDrilled","toothZones","numberY","RadixTooltip","TOOTH_HIT_PAD","url","marked","zonePath","d","selected","condColour","iconUrl","specialIconUrl","elementInteractive","Fragment","liveRegion","archLabel","rowLabel","view","sharedSubChartProps","bothView","controlsNode","Popover","IconButton","Settings","Switch","v","createPortal"],"mappings":";;;;;;;;;;;;;AAQA,MAAMA,IAAa;AAAA,EACjB,MAAM;AAAA,EACN,aACE;AACJ,GACMC,KAAmB;AAAA,EACvB,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ,GACMC,KAAiB;AAAA,EACrB,MAAM,CAAC,UAAU,UAAU,YAAY,UAAU,SAAS;AAC5D,GACMC,KAAoB;AAAA,EACxB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,IAAI,EAAE,MAAM,SAAA;AAAA,IACZ,KAAK,EAAE,MAAM,SAAA;AAAA,IACb,cAAc,EAAE,MAAM,SAAA;AAAA,IACtB,MAAM,EAAE,MAAM,UAAU,aAAa,qCAAA;AAAA,IACrC,MAAM,EAAE,MAAM,SAAA;AAAA,IACd,MAAM,EAAE,MAAM,CAAC,cAAc,YAAY,aAAa,OAAO,EAAA;AAAA,IAC7D,KAAK,EAAE,MAAM,SAAA;AAAA,EAAS;AAAA,EAExB,UAAU,CAAC,MAAM,KAAK;AACxB,GAEaC,KAAoD;AAAA,EAC/D,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,EAKJ,cAAc,CAAC,QAAQ,aAAa,eAAe,aAAa;AAAA,EAChE,OAAO;AAAA,IACL,OAAO;AAAA,MACL,MA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