{"version":3,"sources":["../../src/vue/BoardViewer.ts","../../src/utils/grid3Images.ts","../../src/utils/pageBackground.ts"],"sourcesContent":["import {\n  defineComponent,\n  ref,\n  computed,\n  watch,\n  onMounted,\n  onBeforeUnmount,\n  nextTick,\n  h,\n  type PropType,\n  type VNode,\n  type VNodeRef,\n} from 'vue';\nimport type { AACPage, AACButton } from '@willwade/aac-processors';\nimport type { BoardViewerProps, ButtonMetric } from '../types';\nimport {\n  deriveCellPresentation,\n  isAutoGeneratedCellLabel,\n  isDefaultWorkspaceLabel,\n} from '../utils/grid3Images';\nimport { derivePageBackgroundColor } from '../utils/pageBackground';\n\ninterface PredictionsTooltipProps {\n  predictions: string[];\n  label: string;\n  position: { x: number; y: number };\n  buttonMetricsLookup: { [buttonId: string]: ButtonMetric };\n  onClose: () => void;\n  onWordClick?: (word: string, effort: number) => void;\n  pos?: string;\n}\n\nconst PredictionsTooltip = defineComponent({\n  name: 'PredictionsTooltip',\n  props: {\n    predictions: { type: Array as PropType<string[]>, required: true },\n    label: { type: String, required: true },\n    position: {\n      type: Object as PropType<{ x: number; y: number }>,\n      required: true,\n    },\n    buttonMetricsLookup: {\n      type: Object as PropType<{ [buttonId: string]: ButtonMetric }>,\n      required: true,\n    },\n    onClose: { type: Function as PropType<() => void>, required: true },\n    onWordClick: {\n      type: Function as PropType<(word: string, effort: number) => void>,\n      required: false,\n    },\n    pos: { type: String, default: undefined },\n  },\n  setup(props: Readonly<PredictionsTooltipProps>) {\n    const handleClickOutside = (e: MouseEvent) => {\n      if (e.target instanceof HTMLElement && !e.target.closest('.predictions-tooltip')) {\n        props.onClose();\n      }\n    };\n\n    onMounted(() => {\n      document.addEventListener('mousedown', handleClickOutside);\n    });\n\n    onBeforeUnmount(() => {\n      document.removeEventListener('mousedown', handleClickOutside);\n    });\n\n    const getPosition = () => {\n      const maxX = typeof window !== 'undefined' ? window.innerWidth - 200 : props.position.x;\n      const maxY = typeof window !== 'undefined' ? window.innerHeight - 150 : props.position.y;\n      return {\n        left: `${Math.min(props.position.x, maxX)}px`,\n        top: `${Math.min(props.position.y, maxY)}px`,\n      };\n    };\n\n    return () => {\n      const positionStyle = getPosition();\n\n      return h(\n        'div',\n        {\n          class:\n            'predictions-tooltip fixed z-50 bg-white dark:bg-gray-800 rounded-lg shadow-xl border-2 border-purple-500 p-3 max-w-xs',\n          style: positionStyle,\n          onClick: (e: MouseEvent) => e.stopPropagation(),\n        },\n        [\n          h('div', { class: 'flex items-center justify-between mb-2' }, [\n            h(\n              'h4',\n              { class: 'text-sm font-semibold text-gray-900 dark:text-white flex items-center gap-1.5' },\n              [\n                `Word forms for \"${props.label}\"`,\n                props.pos && props.pos !== 'Unknown' && props.pos !== 'Ignore'\n                  ? h(\n                      'span',\n                      {\n                        class: `px-1.5 py-0 text-[10px] font-semibold rounded text-white ${\n                          props.pos === 'Verb' ? 'bg-orange-500' :\n                          props.pos === 'Noun' ? 'bg-teal-500' :\n                          props.pos === 'Pronoun' ? 'bg-pink-500' :\n                          props.pos === 'Adjective' ? 'bg-yellow-500' :\n                          'bg-gray-500'\n                        }`,\n                      },\n                      props.pos\n                    )\n                  : null,\n              ]\n            ),\n            h(\n              'button',\n              {\n                onClick: props.onClose,\n                class: 'p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded',\n                'aria-label': 'Close',\n              },\n              [\n                h(\n                  'svg',\n                  {\n                    class: 'h-4 w-4 text-gray-600 dark:text-gray-400',\n                    fill: 'none',\n                    stroke: 'currentColor',\n                    viewBox: '0 0 24 24',\n                  },\n                  [\n                    h('path', {\n                      'stroke-linecap': 'round',\n                      'stroke-linejoin': 'round',\n                      'stroke-width': 2,\n                      d: 'M6 18L18 6M6 6l12 12',\n                    }),\n                  ]\n                ),\n              ]\n            ),\n          ]),\n          h(\n            'div',\n            { class: 'flex flex-wrap gap-1' },\n            props.predictions.map((word: string, idx: number) => {\n              const metricForWord = Object.values(props.buttonMetricsLookup).find(\n                (m: ButtonMetric) => m.label === word\n              );\n              const effort = metricForWord?.effort;\n\n              return h(\n                'span',\n                {\n                  key: `${word}-${idx}`,\n                  class:\n                    'px-2 py-1 bg-purple-100 dark:bg-purple-900 text-purple-800 dark:text-purple-200 rounded text-xs font-medium relative cursor-pointer hover:bg-purple-200 dark:hover:bg-purple-800 transition',\n                  title: `Click to add \"${word}\" to message`,\n                  onClick: (e: MouseEvent) => {\n                    e.stopPropagation();\n                    if (props.onWordClick) {\n                      props.onWordClick(word, effort || 1.0);\n                      props.onClose();\n                    }\n                  },\n                },\n                [\n                  effort !== undefined\n                    ? h(\n                        'span',\n                        {\n                          class:\n                            'absolute -top-1 -right-1 px-1 py-0 text-[8px] font-semibold rounded bg-blue-600 text-white shadow-xs',\n                        },\n                        effort.toFixed(1)\n                      )\n                    : null,\n                  word,\n                ]\n              );\n            })\n          ),\n        ]\n      );\n    };\n  },\n});\n\nexport const BoardViewer = defineComponent({\n  name: 'BoardViewer',\n  props: {\n    tree: { type: Object as PropType<BoardViewerProps['tree']>, required: true },\n    buttonMetrics: { type: Array as PropType<ButtonMetric[] | null>, default: null },\n    showMessageBar: { type: Boolean, default: true },\n    showBoardInfo: { type: Boolean, default: true },\n    derivePageBackground: { type: Boolean, default: true },\n    showEffortBadges: { type: Boolean, default: true },\n    showLinkIndicators: { type: Boolean, default: true },\n    initialPageId: { type: String, default: undefined },\n    navigateToPageId: { type: String, default: undefined },\n    highlight: { type: Object as PropType<BoardViewerProps['highlight']>, default: undefined },\n    onButtonClick: {\n      type: Function as PropType<(button: AACButton) => void>,\n      default: undefined,\n    },\n    onPageChange: {\n      type: Function as PropType<(pageId: string) => void>,\n      default: undefined,\n    },\n    className: { type: String, default: '' },\n    loadId: { type: String, default: undefined },\n  },\n  setup(props: Readonly<BoardViewerProps>) {\n    const resolveInitialPageId = () => {\n      if (props.initialPageId && props.tree.pages[props.initialPageId]) {\n        return props.initialPageId;\n      }\n      if (props.tree.toolbarId && props.tree.rootId && props.tree.rootId !== props.tree.toolbarId) {\n        return props.tree.rootId;\n      }\n      if (props.tree.rootId && props.tree.pages[props.tree.rootId]) {\n        const rootPage = props.tree.pages[props.tree.rootId];\n        const isToolbar =\n          rootPage.name.toLowerCase().includes('toolbar') ||\n          rootPage.name.toLowerCase().includes('tool bar');\n        if (!isToolbar) {\n          return props.tree.rootId;\n        }\n      }\n      const startPage = Object.values(props.tree.pages).find(\n        (p) => p.name.toLowerCase() === 'start'\n      );\n      if (startPage) {\n        return startPage.id;\n      }\n      const nonToolbarPage = Object.values(props.tree.pages).find(\n        (p) => !p.name.toLowerCase().includes('toolbar') && !p.name.toLowerCase().includes('tool bar')\n      );\n      if (nonToolbarPage) {\n        return nonToolbarPage.id;\n      }\n      const pageIds = Object.keys(props.tree.pages);\n      return pageIds.length > 0 ? pageIds[0] : null;\n    };\n\n    const currentPageId = ref<string | null>(resolveInitialPageId());\n    const highlightedButtonRef = ref<HTMLButtonElement | null>(null);\n\n    // Image srcs that failed to load — reactive so cells can swap the <img>\n    // for their glyph fallback on the next render (React parity).\n    const failedImageSrcs = ref<Set<string>>(new Set());\n    const pageHistory = ref<AACPage[]>([]);\n    const message = ref('');\n    const currentWordCount = ref(0);\n    const currentEffort = ref(0);\n\n    const predictionsTooltip = ref<PredictionsTooltipProps | null>(null);\n\n    const buttonMetricsLookup = computed(() => {\n      if (!props.buttonMetrics) return {};\n      const lookup: { [buttonId: string]: ButtonMetric } = {};\n      props.buttonMetrics.forEach((metric: ButtonMetric) => {\n        lookup[metric.id] = metric;\n      });\n      return lookup;\n    });\n\n    const currentPage = computed(() =>\n      currentPageId.value ? props.tree.pages[currentPageId.value] : null\n    );\n\n    const goToPage = (targetPageId: string | undefined | null) => {\n      if (!targetPageId || !props.tree.pages[targetPageId]) return false;\n      if (currentPage.value) {\n        pageHistory.value = [...pageHistory.value, currentPage.value];\n      }\n      currentPageId.value = targetPageId;\n      if (props.onPageChange) {\n        props.onPageChange(targetPageId);\n      }\n      return true;\n    };\n\n    watch([() => props.tree, () => props.initialPageId], () => {\n      currentPageId.value = resolveInitialPageId();\n      pageHistory.value = [];\n      // New board: transient image failures from the previous board must\n      // not suppress images in this one.\n      failedImageSrcs.value = new Set();\n    });\n\n    watch(\n      () => props.navigateToPageId,\n      (pageId: string | undefined) => {\n        if (!pageId) return;\n        if (!props.tree.pages[pageId]) return;\n        currentPageId.value = pageId;\n        pageHistory.value = [];\n        if (props.onPageChange) {\n          props.onPageChange(pageId);\n        }\n      }\n    );\n\n    watch(\n      [\n        currentPageId,\n        () => props.highlight?.pageId,\n        () => props.highlight?.x,\n        () => props.highlight?.y,\n        () => props.highlight?.label,\n      ],\n      () => {\n        nextTick(() => {\n          if (highlightedButtonRef.value) {\n            highlightedButtonRef.value.scrollIntoView({\n              behavior: 'smooth',\n              block: 'center',\n              inline: 'center',\n            });\n          }\n        });\n      }\n    );\n\n    const updateStats = (word: string, effort: number) => {\n      currentWordCount.value += 1;\n      currentEffort.value += effort;\n    };\n\n    const clearMessage = () => {\n      message.value = '';\n      currentWordCount.value = 0;\n      currentEffort.value = 0;\n    };\n\n    const handleBack = () => {\n      if (pageHistory.value.length > 0) {\n        const previousPage = pageHistory.value[pageHistory.value.length - 1];\n        pageHistory.value = pageHistory.value.slice(0, -1);\n        currentPageId.value = previousPage.id;\n        if (props.onPageChange) {\n          props.onPageChange(previousPage.id);\n        }\n      }\n    };\n\n    const handleButtonClick = (button: AACButton) => {\n      if (props.onButtonClick) {\n        props.onButtonClick(button);\n      }\n\n      const intent = button.semanticAction?.intent\n        ? String(button.semanticAction.intent)\n        : undefined;\n      const targetPageId = button.targetPageId || button.semanticAction?.targetId;\n      const effort = buttonMetricsLookup.value[button.id]?.effort || 1;\n      const textValue =\n        button.semanticAction?.text || button.message || button.label || '';\n\n      const deleteLastWord = () => {\n        message.value = message.value\n          .trim()\n          .split(/\\s+/)\n          .slice(0, -1)\n          .join(' ');\n      };\n\n      const deleteLastCharacter = () => {\n        message.value = message.value.slice(0, -1);\n      };\n\n      const appendText = (word: string) => {\n        const trimmed = word || button.label || '';\n        message.value = trimmed\n          ? `${message.value}${message.value ? ' ' : ''}${trimmed}`\n          : message.value;\n        if (trimmed) {\n          updateStats(trimmed, effort);\n        }\n      };\n\n      if (intent === 'NAVIGATE_TO' && goToPage(targetPageId)) {\n        return;\n      }\n\n      switch (intent) {\n        case 'GO_BACK':\n          handleBack();\n          return;\n        case 'GO_HOME':\n          if (props.tree.rootId && goToPage(props.tree.rootId)) return;\n          break;\n        case 'DELETE_WORD':\n          deleteLastWord();\n          return;\n        case 'DELETE_CHARACTER':\n          deleteLastCharacter();\n          return;\n        case 'CLEAR_TEXT':\n          clearMessage();\n          return;\n        case 'SPEAK_IMMEDIATE':\n        case 'SPEAK_TEXT':\n        case 'INSERT_TEXT':\n          appendText(textValue);\n          return;\n        default:\n          break;\n      }\n\n      if (targetPageId && goToPage(targetPageId)) {\n        return;\n      }\n\n      appendText(textValue);\n    };\n\n    const handleShowPredictions = (button: AACButton, event: MouseEvent) => {\n      event.stopPropagation();\n      const predictions =\n        button.predictions || (button.parameters as { predictions?: string[] })?.predictions;\n      const buttonMetric = buttonMetricsLookup.value[button.id];\n      if (predictions && predictions.length > 0) {\n        predictionsTooltip.value = {\n          predictions,\n          label: button.label,\n          position: { x: event.clientX, y: event.clientY },\n          buttonMetricsLookup: buttonMetricsLookup.value,\n          pos: buttonMetric?.pos || button.pos,\n          onWordClick: (word: string, effort: number) => {\n            const trimmed = word || '';\n            if (trimmed) {\n              message.value = `${message.value}${message.value ? ' ' : ''}${trimmed}`;\n              updateStats(trimmed, effort);\n            }\n          },\n          onClose: () => {\n            predictionsTooltip.value = null;\n          },\n        };\n      }\n    };\n\n    const getTextColor = (backgroundColor?: string) => {\n      if (!backgroundColor) return '#111827';\n\n      const hex = backgroundColor.replace('#', '');\n      if (hex.length === 6) {\n        const r = parseInt(hex.substring(0, 2), 16);\n        const g = parseInt(hex.substring(2, 4), 16);\n        const b = parseInt(hex.substring(4, 6), 16);\n        const brightness = (r * 299 + g * 587 + b * 114) / 1000;\n        return brightness >= 128 ? '#111827' : '#f9fafb';\n      }\n\n      return '#111827';\n    };\n\n    const renderToolbar = (toolbarPage: AACPage | null): VNode | null => {\n      if (!toolbarPage) return null;\n\n      return h('div', {\n        class:\n          'w-16 sm:w-20 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50',\n      }, [\n        h('div', { class: 'p-2' }, [\n          h(\n            'p',\n            {\n              class:\n                'text-[10px] text-gray-500 dark:text-gray-400 text-center mb-2 font-semibold',\n            },\n            'TOOLBAR'\n          ),\n          h(\n            'div',\n            { class: 'grid gap-1' },\n            toolbarPage.grid.flatMap((row: (AACButton | null)[]) =>\n              row.map((button: AACButton | null) => {\n                if (!button) return null;\n\n                const buttonMetric = buttonMetricsLookup.value[button.id];\n                const effort = buttonMetric?.effort || 0;\n\n                // Toolbar cells never render images; apply the same\n                // synthetic-label/glyph derivation as the main grid\n                // (resolvedImageEntry first, like the grid path).\n                const toolbarImageRef =\n                  (typeof button.resolvedImageEntry === 'string' && button.resolvedImageEntry) ||\n                  (typeof button.image === 'string' ? button.image : null);\n                const { glyph: toolbarGlyph, displayLabel: toolbarLabel } =\n                  deriveCellPresentation(button, toolbarImageRef, false);\n                const toolbarMessage = isAutoGeneratedCellLabel(button.message) ? '' : button.message || '';\n\n                return h(\n                  'button',\n                  {\n                    key: button.id,\n                    onClick: () => handleButtonClick(button),\n                    class:\n                      'aspect-square p-1 rounded border border-gray-200 dark:border-gray-700 transition flex flex-col items-center justify-center gap-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 relative',\n                    style: {\n                      backgroundColor: button.style?.backgroundColor || '#f3f4f6',\n                      borderColor: button.style?.borderColor || '#e5e7eb',\n                      color:\n                        button.style?.fontColor || getTextColor(button.style?.backgroundColor),\n                    },\n                    title: `${toolbarLabel}\\n${toolbarMessage}`,\n                  },\n                  [\n                    buttonMetric && props.showEffortBadges && effort > 0\n                      ? h(\n                          'div',\n                          {\n                            class:\n                              'absolute top-0 right-0 px-0.5 py-0 text-[8px] font-semibold rounded bg-blue-600 text-white',\n                          },\n                          effort.toFixed(1)\n                        )\n                      : null,\n                    toolbarGlyph\n                      ? h(\n                          'span',\n                          {\n                            role: 'img',\n                            'aria-hidden': true,\n                            style: { fontSize: '20px', lineHeight: 1, opacity: '0.85' },\n                          },\n                          toolbarGlyph\n                        )\n                      : null,\n                    h(\n                      'span',\n                      {\n                        class:\n                          'text-[8px] sm:text-[9px] text-center font-medium leading-tight line-clamp-2',\n                      },\n                      toolbarLabel\n                    ),\n                  ]\n                );\n              })\n            )\n          ),\n        ]),\n      ]);\n    };\n\n    const renderGridCells = (): (VNode | null)[] => {\n      if (!currentPage.value) return [];\n      const rendered = new Set<string>();\n      const cells: (VNode | null)[] = [];\n\n      currentPage.value.grid.forEach((row: (AACButton | null)[], rowIndex: number) => {\n        row.forEach((button: AACButton | null, colIndex: number) => {\n          if (!button) {\n            cells.push(\n              h('div', {\n                key: `empty-${rowIndex}-${colIndex}`,\n                class: 'aspect-square',\n              })\n            );\n            return;\n          }\n\n          if (rendered.has(button.id)) {\n            cells.push(null);\n            return;\n          }\n          rendered.add(button.id);\n\n          const buttonMetric = buttonMetricsLookup.value[button.id];\n          const effort = buttonMetric?.effort || 0;\n          const targetPageId = button.targetPageId || button.semanticAction?.targetId;\n          const hasLink = targetPageId && props.tree.pages[targetPageId];\n          const colSpan = button.columnSpan || 1;\n          const rowSpan = button.rowSpan || 1;\n          const predictions =\n            button.predictions || (button.parameters as { predictions?: string[] })?.predictions;\n          const hasPredictions = predictions && predictions.length > 0;\n          const isPredictionCell =\n            button.contentType === 'AutoContent' &&\n            (button.contentSubType || '').toLowerCase() === 'prediction';\n          const isWorkspace = button.contentType === 'Workspace';\n\n          const isHighlighted =\n            props.highlight &&\n            props.highlight.pageId === currentPageId.value &&\n            (props.highlight.buttonId === button.id ||\n              (props.highlight.x !== undefined && props.highlight.y !== undefined\n                ? button.x === props.highlight.x && button.y === props.highlight.y\n                : false) ||\n              (props.highlight.label && button.label === props.highlight.label));\n\n          const params = button.parameters as {\n            image_id?: string;\n            gridPageName?: string;\n            imageData?: Buffer;\n          };\n\n          let imageSrc: string | null = null;\n          let apiUrl: string | undefined = undefined;\n\n          const resolvedEntry = button.resolvedImageEntry;\n          const buttonImage = button.image;\n\n          if (\n            resolvedEntry &&\n            typeof resolvedEntry === 'string' &&\n            resolvedEntry.startsWith('data:image/')\n          ) {\n            imageSrc = resolvedEntry;\n          } else if (\n            buttonImage &&\n            typeof buttonImage === 'string' &&\n            buttonImage.startsWith('data:image/')\n          ) {\n            imageSrc = buttonImage;\n          } else if (\n            resolvedEntry &&\n            typeof resolvedEntry === 'string' &&\n            !resolvedEntry.startsWith('[') &&\n            !resolvedEntry.startsWith('data:image/')\n          ) {\n            if (props.loadId) {\n              const entryPath = resolvedEntry;\n              const pathMatch = entryPath.match(/^(?:Grids\\/)?(.+)$/);\n              if (pathMatch) {\n                apiUrl = `/api/image/${props.loadId}/${encodeURIComponent(pathMatch[1])}`;\n              }\n            } else {\n              imageSrc = resolvedEntry;\n            }\n          } else if (\n            buttonImage &&\n            typeof buttonImage === 'string' &&\n            !buttonImage.startsWith('[')\n          ) {\n            imageSrc = buttonImage;\n          }\n\n          if (\n            props.loadId &&\n            !imageSrc &&\n            !apiUrl &&\n            params &&\n            params.image_id &&\n            typeof params.image_id === 'string'\n          ) {\n            apiUrl = `/api/image/${props.loadId}/${encodeURIComponent(params.image_id)}`;\n          }\n\n          // Fallbacks for caption-less / browser-unrenderable images\n          // (Grid 3 [GRID3X] WMF symbols, image-only cells labelled Cell_N)\n          const imageRefForFallback =\n            (typeof resolvedEntry === 'string' && resolvedEntry) ||\n            (typeof buttonImage === 'string' ? buttonImage : null);\n          const {\n            glyph: fallbackGlyph,\n            displayLabel,\n            hideLabel,\n            alt: cellAlt,\n          } = deriveCellPresentation(button, imageRefForFallback, !!(imageSrc || apiUrl));\n          const imgSrc = imageSrc || apiUrl || null;\n          const imgFailed = !!imgSrc && failedImageSrcs.value.has(imgSrc);\n\n          if (isWorkspace) {\n            cells.push(\n              h(\n                'div',\n                {\n                  key: button.id,\n                  class:\n                    'relative p-3 rounded-lg border-2 bg-gray-50 text-gray-800 flex items-center gap-2',\n                  style: {\n                    borderColor: button.style?.borderColor || '#e5e7eb',\n                    gridColumn: `${colIndex + 1} / span ${colSpan}`,\n                    gridRow: `${rowIndex + 1} / span ${rowSpan}`,\n                  },\n                },\n                [\n                  !isDefaultWorkspaceLabel(button.label) && button.label\n                    ? h('div', { class: 'font-semibold text-sm' }, button.label)\n                    : null,\n                  h('div', { class: 'text-xs text-gray-500 truncate' }, message.value || 'Chat writing area'),\n                ]\n              )\n            );\n            return;\n          }\n\n          cells.push(\n            h(\n              'button',\n              {\n                key: button.id,\n                onClick: () => handleButtonClick(button),\n                ref: isHighlighted\n                  ? ((el: Element | null) => {\n                      highlightedButtonRef.value = el as HTMLButtonElement | null;\n                    }) as VNodeRef\n                  : undefined,\n                class: `relative ${colSpan === 1 && rowSpan === 1 ? 'aspect-square ' : ''}p-2 rounded-lg border-2 transition flex flex-col items-center justify-center gap-1 hover:opacity-80 hover:scale-105 active:scale-95 ${\n                    isHighlighted ? 'ring-4 ring-amber-400 ring-offset-2 ring-offset-white' : ''\n                  }`,\n                style: {\n                  backgroundColor: button.style?.backgroundColor || '#f3f4f6',\n                  borderColor: button.style?.borderColor || '#e5e7eb',\n                  color:\n                    button.style?.fontColor || getTextColor(button.style?.backgroundColor),\n                  gridColumn: `${colIndex + 1} / span ${colSpan}`,\n                  gridRow: `${rowIndex + 1} / span ${rowSpan}`,\n                },\n              },\n              [\n                buttonMetric && props.showEffortBadges\n                  ? h(\n                      'div',\n                      {\n                        class:\n                          'absolute top-1 right-1 px-1.5 py-0.5 text-xs font-semibold rounded bg-blue-600 text-white shadow-sm',\n                      },\n                      effort.toFixed(1)\n                    )\n                  : null,\n                hasLink && props.showLinkIndicators\n                  ? h('div', {\n                      class:\n                        'absolute top-1 left-1 w-2 h-2 bg-green-500 rounded-full shadow-sm',\n                    })\n                  : null,\n                buttonMetric?.pos && buttonMetric.pos !== 'Unknown' && buttonMetric.pos !== 'Ignore'\n                  ? h('div', {\n                      class: `absolute top-1 ${hasLink && props.showLinkIndicators ? 'left-4' : 'left-1'} px-1 py-0 text-[8px] font-semibold rounded shadow-sm text-white ${\n                        buttonMetric.pos === 'Verb' ? 'bg-orange-500' :\n                        buttonMetric.pos === 'Noun' ? 'bg-teal-500' :\n                        buttonMetric.pos === 'Pronoun' ? 'bg-pink-500' :\n                        buttonMetric.pos === 'Adjective' ? 'bg-yellow-500' :\n                        'bg-gray-500'\n                      }`,\n                      title: `Part of speech: ${buttonMetric.pos}`,\n                    }, buttonMetric.pos.charAt(0))\n                  : null,\n                hasPredictions\n                  ? h(\n                      'div',\n                      {\n                        onClick: (event: MouseEvent) => handleShowPredictions(button, event),\n                        class:\n                          'absolute bottom-1 right-1 px-1.5 py-0.5 text-xs font-semibold rounded bg-purple-600 text-white shadow-sm cursor-pointer hover:bg-purple-700 transition',\n                        title: `Has ${predictions?.length} word form${\n                          predictions && predictions.length > 1 ? 's' : ''\n                        }`,\n                      },\n                      predictions?.length\n                    )\n                  : null,\n          imageSrc || apiUrl\n            ? imgFailed\n              ? null // failed: fall through to the glyph below by rendering no img\n              : h('img', {\n                  src: imgSrc || undefined,\n                  alt: cellAlt,\n                  class: 'max-h-12 object-contain',\n                  onError: (e: Event) => {\n                    const target = e.target as HTMLImageElement;\n                    console.warn('Image failed to load:', button.label, 'src:', target.src);\n                    failedImageSrcs.value = new Set([...failedImageSrcs.value, imgSrc || '']);\n                  },\n                })\n            : null,\n          !imgSrc || imgFailed\n            ? fallbackGlyph\n              ? h(\n                  'span',\n                  {\n                    role: 'img',\n                    'aria-label': cellAlt || undefined,\n                    'aria-hidden': !cellAlt,\n                    style: { fontSize: '30px', lineHeight: 1, opacity: '0.85', flexShrink: 0 },\n                  },\n                  fallbackGlyph\n                )\n              : null\n            : null,\n                hideLabel\n                  ? null\n                  : h('div', { class: 'flex flex-col items-center justify-center' }, [\n                      h(\n                        'span',\n                        {\n                          class: 'text-xs sm:text-sm text-center font-medium leading-tight line-clamp-3',\n                        },\n                        displayLabel\n                      ),\n                      isPredictionCell && predictions && predictions.length > 0\n                        ? h(\n                            'div',\n                            {\n                              class:\n                                'mt-1 text-[10px] sm:text-xs text-center opacity-80 space-y-0.5',\n                            },\n                            [\n                              ...predictions.slice(0, 3).map((prediction: string, idx: number) =>\n                                h('div', { key: `${button.id}-pred-${idx}` }, prediction)\n                              ),\n                              predictions.length > 3 ? h('div', '…') : null,\n                            ]\n                          )\n                        : null,\n                    ]),\n                !isAutoGeneratedCellLabel(button.message) &&\n                button.message &&\n                button.message !== displayLabel &&\n                !hideLabel &&\n                !isPredictionCell\n                  ? h(\n                      'span',\n                      { class: 'text-[10px] sm:text-xs text-center opacity-75 line-clamp-2' },\n                      button.message\n                    )\n                  : null,\n              ]\n            )\n          );\n        });\n      });\n\n      return cells;\n    };\n\n    return () => {\n      if (!currentPage.value) {\n        return h(\n          'div',\n          {\n            class: `flex items-center justify-center h-96 bg-gray-100 dark:bg-gray-800 rounded-lg ${\n              props.className\n            }`,\n          },\n          [\n            h('div', { class: 'text-center' }, [\n              h('p', { class: 'text-gray-600 dark:text-gray-400' }, 'No pages available'),\n            ]),\n          ]\n        );\n      }\n\n      const toolbarPage = props.tree.toolbarId ? props.tree.pages[props.tree.toolbarId] : null;\n      const gridRows = currentPage.value.grid.length;\n      const gridCols = gridRows > 0 ? currentPage.value.grid[0].length : 0;\n      const pageBackground = derivePageBackgroundColor(\n        currentPage.value,\n        props.derivePageBackground !== false\n      );\n\n      return h('div', {\n        class: `bg-white dark:bg-gray-800 rounded-lg shadow-xl overflow-hidden ${props.className}`,\n      }, [\n        props.showMessageBar\n          ? h(\n              'div',\n              {\n                class:\n                  'p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50',\n              },\n              [\n                h('div', { class: 'flex items-start justify-between gap-4' }, [\n                  h('div', { class: 'flex-1 min-w-0' }, [\n                    message.value\n                      ? h('div', { class: 'space-y-2' }, [\n                          h(\n                            'p',\n                            { class: 'text-lg text-gray-900 dark:text-white break-words' },\n                            message.value\n                          ),\n                          h('div', { class: 'flex gap-4 text-sm' }, [\n                            h(\n                              'div',\n                              { class: 'text-gray-600 dark:text-gray-400' },\n                              `${currentWordCount.value} ${\n                                currentWordCount.value === 1 ? 'word' : 'words'\n                              }`\n                            ),\n                            props.buttonMetrics\n                              ? [\n                                  h(\n                                    'div',\n                                    { class: 'text-gray-600 dark:text-gray-400' },\n                                    [\n                                      'Effort: ',\n                                      h(\n                                        'span',\n                                        { class: 'font-medium' },\n                                        currentEffort.value.toFixed(2)\n                                      ),\n                                    ]\n                                  ),\n                                  h(\n                                    'div',\n                                    { class: 'text-gray-600 dark:text-gray-400' },\n                                    [\n                                      'Avg: ',\n                                      h(\n                                        'span',\n                                        { class: 'font-medium' },\n                                        currentWordCount.value > 0\n                                          ? (currentEffort.value / currentWordCount.value).toFixed(2)\n                                          : '0.00'\n                                      ),\n                                    ]\n                                  ),\n                                ]\n                              : null,\n                          ]),\n                        ])\n                      : h(\n                          'p',\n                          { class: 'text-gray-500 dark:text-gray-400 italic' },\n                          'Tap buttons to build a sentence...'\n                        ),\n                  ]),\n                  message.value\n                    ? h(\n                        'button',\n                        {\n                          onClick: clearMessage,\n                          class:\n                            'p-2 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition',\n                          'aria-label': 'Clear message',\n                        },\n                        [\n                          h(\n                            'svg',\n                            {\n                              class: 'h-5 w-5 text-gray-600 dark:text-gray-400',\n                              fill: 'none',\n                              stroke: 'currentColor',\n                              viewBox: '0 0 24 24',\n                            },\n                            [\n                              h('path', {\n                                'stroke-linecap': 'round',\n                                'stroke-linejoin': 'round',\n                                'stroke-width': 2,\n                                d: 'M6 18L18 6M6 6l12 12',\n                              }),\n                            ]\n                          ),\n                        ]\n                      )\n                    : null,\n                ]),\n              ]\n            )\n          : null,\n        h('div', { class: 'flex' }, [\n          renderToolbar(toolbarPage),\n          h('div', { class: 'flex-1' }, [\n            props.showBoardInfo || pageHistory.value.length > 0\n              ? h('div', {\n                  class: 'flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700',\n                }, [\n                  h('div', { class: 'flex items-center gap-2' }, [\n                    pageHistory.value.length > 0\n                      ? h(\n                          'button',\n                          {\n                            onClick: handleBack,\n                            class: 'p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition',\n                            'aria-label': 'Go back',\n                          },\n                          [\n                            h(\n                              'svg',\n                              {\n                                class: 'h-5 w-5 text-gray-600 dark:text-gray-400',\n                                fill: 'none',\n                                stroke: 'currentColor',\n                                viewBox: '0 0 24 24',\n                              },\n                              [\n                                h('path', {\n                                  'stroke-linecap': 'round',\n                                  'stroke-linejoin': 'round',\n                                  'stroke-width': 2,\n                                  d: 'M15 19l-7-7 7-7',\n                                }),\n                              ]\n                            ),\n                          ]\n                        )\n                      : null,\n                    props.showBoardInfo\n                      ? h(\n                          'h3',\n                          { class: 'text-lg font-semibold text-gray-900 dark:text-white' },\n                          currentPage.value.name\n                        )\n                      : null,\n                  ]),\n                  props.showBoardInfo\n                    ? h(\n                        'div',\n                        { class: 'text-sm text-gray-500 dark:text-gray-400' },\n                        `${gridRows}×${gridCols} grid`\n                      )\n                    : null,\n                ])\n              : null,\n            h(\n              'div',\n              {\n                class: 'p-4 gap-2 overflow-auto max-h-[600px]',\n                style: {\n                  display: 'grid',\n                  gridTemplateColumns: `repeat(${gridCols}, minmax(0, 1fr))`,\n                  ...(pageBackground ? { backgroundColor: pageBackground } : {}),\n                },\n              },\n              renderGridCells()\n            ),\n            props.showBoardInfo && Object.keys(props.tree.pages).length > 1\n              ? h('div', { class: 'p-4 border-t border-gray-200 dark:border-gray-700' }, [\n                  h(\n                    'p',\n                    { class: 'text-sm text-gray-600 dark:text-gray-400 mb-2' },\n                    `${Object.keys(props.tree.pages).length} pages in this vocabulary`\n                  ),\n                ])\n              : null,\n          ]),\n        ]),\n        predictionsTooltip.value\n          ? h(PredictionsTooltip, {\n              predictions: predictionsTooltip.value.predictions,\n              label: predictionsTooltip.value.label,\n              position: predictionsTooltip.value.position,\n              buttonMetricsLookup: predictionsTooltip.value.buttonMetricsLookup,\n              onClose: predictionsTooltip.value.onClose,\n              onWordClick: predictionsTooltip.value.onWordClick,\n              pos: predictionsTooltip.value.pos,\n            })\n          : null,\n      ]);\n    };\n  },\n});\n\nexport default BoardViewer;\n","/**\n * Helpers for Grid 3 image references and auto-generated cell labels.\n *\n * Grid 3 keyboard gridsets commonly have image-only action cells: the cell\n * carries an image reference (e.g. `[GRID3X]delete_letter.wmf`) and no\n * caption. Two things fall out of that:\n *\n * 1. Browsers cannot render WMF, so built-in [GRID3X] symbols need a glyph\n *    fallback (the built-in set is small and predictable).\n * 2. The aac-processors loader gives caption-less cells synthetic labels\n *    (`Cell_43`, `AutoContent_7`, `\"Chat Workspace\"`), which should not be\n *    shown to users when we can derive something better from the image\n *    reference.\n */\n\n/**\n * Fallback glyphs for Grid 3 built-in [GRID3X] symbols, keyed by the symbol\n * name parsed from the reference (`[GRID3X]delete_letter.wmf` →\n * `delete_letter`).\n */\nexport const GRID3X_GLYPHS: Record<string, string> = {\n  delete_letter: '⌫',\n  delete_word: '⌦',\n  backspace: '⌫',\n  clear: '🧹',\n  enter: '↵',\n  shift: '⇧',\n  undo: '↶',\n  redo: '↷',\n  speak: '🔊',\n  speak_all: '🔊',\n  speak_nothing: '🔇',\n  space: '␣',\n  tab: '⇥',\n  keyboard: '⌨',\n  keyboard_hide: '⌨',\n  hide_keyboard: '⌨',\n  globe: '🌐',\n  left: '←',\n  right: '→',\n  up: '↑',\n  down: '↓',\n  home: '⌂',\n};\n\n/**\n * Grid 3 dynamic image files are coordinate-named (`{x}-{y}-0-text-0.png`\n * under `Grids/<page>/`). A name like that carries no meaning for users, so\n * label derivation treats it as underivable.\n */\nconst COORDINATE_IMAGE_NAME = /^\\d+-\\d+-/;\n\n/**\n * Extract a normalised symbol name from a Grid 3 image reference.\n *\n * Handles bracketed library references — `[GRID3X]name.wmf`,\n * `[Widgit]computer/keyboard.png` (the last path segment is used) — and\n * plain filenames/paths.\n */\nexport function grid3ImageName(imageRef?: string | null): string | null {\n  if (!imageRef || typeof imageRef !== 'string') return null;\n  const bracketMatch = imageRef.match(/^\\[[^\\]]+\\](?:([^/\\]]*\\/)*([^/]+?))(?:\\.[^.]*)?$/);\n  const fromBracket = bracketMatch ? bracketMatch[2] : null;\n  const base = fromBracket || imageRef.split('/').pop() || imageRef;\n  const noExt = base.replace(/\\.[^.]+$/, '');\n  return noExt ? noExt.toLowerCase() : null;\n}\n\n/**\n * Best-effort glyph for an image reference. Exact [GRID3X] names first,\n * then fuzzy rules for spelling variants. Fuzzy stems are matched only\n * when followed by a separator or end-of-name, so `tablet`, `tabby_cat`\n * or `spaceship` never match the `tab`/`space` rules.\n */\nconst startsWithStem = (name: string, stem: string) =>\n  name.startsWith(stem) && (name.length === stem.length || /^[_-]/.test(name.slice(stem.length)));\n\nexport function glyphForGrid3Image(imageRef?: string | null): string | null {\n  const name = grid3ImageName(imageRef);\n  if (!name) return null;\n  if (GRID3X_GLYPHS[name]) return GRID3X_GLYPHS[name];\n  if (startsWithStem(name, 'delete') && /letter/.test(name)) return '⌫';\n  if (startsWithStem(name, 'delete') && /word/.test(name)) return '⌦';\n  if (startsWithStem(name, 'delete')) return '⌫';\n  if (startsWithStem(name, 'backspace')) return '⌫';\n  if (startsWithStem(name, 'enter')) return '↵';\n  if (startsWithStem(name, 'shift')) return '⇧';\n  if (startsWithStem(name, 'undo')) return '↶';\n  if (startsWithStem(name, 'redo')) return '↷';\n  if (startsWithStem(name, 'speak')) return '🔊';\n  if (startsWithStem(name, 'space')) return '␣';\n  if (startsWithStem(name, 'tab')) return '⇥';\n  if (startsWithStem(name, 'keyboard')) return '⌨';\n  return null;\n}\n\n/**\n * True for the synthetic labels the aac-processors loader assigns to\n * caption-less cells (`Cell_43`, `AutoContent_7`).\n */\nexport function isAutoGeneratedCellLabel(label?: string | null): boolean {\n  return !!label && /^(Cell|AutoContent)_\\d+$/.test(label);\n}\n\n/**\n * Derive a friendly label for a caption-less cell from its image reference\n * (`Cell_43` + `[GRID3X]delete_letter.wmf` → `delete letter`). Returns null\n * when nothing better than the raw label can be derived — including\n * coordinate-named images (`2-3-0-text-0`), which would otherwise produce\n * meaningless number soup.\n */\nexport function friendlyCellLabel(\n  label?: string | null,\n  imageRef?: string | null\n): string | null {\n  if (!isAutoGeneratedCellLabel(label)) return null;\n  const name = grid3ImageName(imageRef);\n  if (!name || COORDINATE_IMAGE_NAME.test(name)) return null;\n  return name.replace(/[_-]+/g, ' ');\n}\n\n/**\n * True when `label` looks like the loader's default display name for a\n * Workspace cell — the bare `Workspace` or the subtyped `Chat Workspace` /\n * `Keyboard Workspace` forms. Note the check is shape-based: any label\n * *ending* in \"workspace\" (e.g. a genuine \"Writing workspace\" caption)\n * matches too, which is accepted as the cost of a simple default filter.\n */\nexport function isDefaultWorkspaceLabel(label?: string | null): boolean {\n  if (!label) return false;\n  const trimmed = label.trim();\n  return /(?:^|\\s)workspace$/i.test(trimmed);\n}\n\n/**\n * One-stop presentation derivation for a cell, shared by the React and Vue\n * renderers (main grid and toolbar):\n *\n * - `glyph`: fallback glyph when the image cannot be rendered\n * - `displayLabel`: the label to show (derived when possible, raw otherwise)\n * - `hideLabel`: the label should not be shown at all (synthetic label with\n *   a glyph or image doing the talking)\n * - `alt`: accessible name for the image/glyph (empty when the raw label is\n *   synthetic and nothing better was derived)\n */\nexport function deriveCellPresentation(\n  button: { label?: string | null | undefined; message?: string | null | undefined },\n  imageRef: string | null | undefined,\n  hasRenderableImage: boolean\n): { glyph: string | null; displayLabel: string; hideLabel: boolean; alt: string } {\n  // The glyph is always derived: it is used when there is no renderable\n  // image *and* as the fallback when a load fails (WMF-backed URLs etc.).\n  const glyph = glyphForGrid3Image(imageRef);\n  const derivedLabel = friendlyCellLabel(button.label, imageRef);\n  const synthetic = isAutoGeneratedCellLabel(button.label);\n  const hasVisual = !!(glyph || hasRenderableImage);\n  const hideLabel = !derivedLabel && synthetic && hasVisual;\n  const displayLabel = derivedLabel ?? (button.label ?? '');\n  const alt = derivedLabel ?? (synthetic ? '' : (button.label ?? ''));\n  return { glyph, displayLabel, hideLabel, alt };\n}\n","/**\n * Derive a board/page background colour for rendering.\n *\n * Explicit `page.style.backgroundColor` always wins. Otherwise, Grid 3\n * gridsets communicate the page surround through the styles referenced by\n * their cells (`BackColour`): when a strong majority of buttons share the\n * same opaque background colour, that colour is the surround the board\n * should render behind its keys. Boards with varied or mostly-transparent\n * button backgrounds (OBZ, Snap, generated layouts with sparse styling)\n * derive nothing and keep the viewer default.\n */\n\nconst RGBA_RE = /rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*([\\d.]+)\\s*)?\\)/;\n\nfunction toHexPair(n: number): string {\n  return Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, '0').toUpperCase();\n}\n\n/**\n * Normalise any CSS colour the loaders produce to `#RRGGBB` (alpha dropped).\n * Returns null for transparent colours (alpha 0) and unparseable input.\n */\nexport function normalizeOpaqueHex(color?: string | null): string | null {\n  if (!color || typeof color !== 'string') return null;\n  const rgb = color.match(RGBA_RE);\n  if (rgb) {\n    if (rgb[4] !== undefined && parseFloat(rgb[4]) === 0) return null;\n    return `#${toHexPair(parseInt(rgb[1], 10))}${toHexPair(parseInt(rgb[2], 10))}${toHexPair(parseInt(rgb[3], 10))}`;\n  }\n  const hex = color.replace('#', '').trim();\n  if (/^[0-9A-Fa-f]{6}$/.test(hex)) return `#${hex.toUpperCase()}`;\n  if (/^[0-9A-Fa-f]{8}$/.test(hex)) {\n    if (hex.slice(6) === '00') return null; // fully transparent\n    return `#${hex.slice(0, 6).toUpperCase()}`;\n  }\n  if (/^[0-9A-Fa-f]{3}$/.test(hex)) {\n    return `#${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`.toUpperCase();\n  }\n  return null;\n}\n\nexport interface PageBackgroundSource {\n  style?: { backgroundColor?: string | null } | null;\n  buttons?: Array<{ style?: { backgroundColor?: string | null } | null }> | null;\n}\n\n/** Minimum buttons before derivation is trusted */\nconst MIN_BUTTONS = 4;\n/** Fraction of buttons that must share one opaque colour */\nconst MAJORITY = 0.6;\n\n/**\n * Page background for rendering: explicit page style first, then the\n * majority button surround colour, else undefined (viewer default).\n */\nexport function derivePageBackgroundColor(\n  page: PageBackgroundSource | null | undefined,\n  enabled: boolean\n): string | undefined {\n  const explicit = normalizeOpaqueHex(page?.style?.backgroundColor);\n  if (explicit) return explicit;\n  if (!enabled || !page?.buttons) return undefined;\n\n  const counts = new Map<string, number>();\n  let total = 0;\n  for (const button of page.buttons) {\n    if (!button?.style?.backgroundColor) continue;\n    total++;\n    const hex = normalizeOpaqueHex(button.style.backgroundColor);\n    if (!hex) continue;\n    counts.set(hex, (counts.get(hex) || 0) + 1);\n  }\n  if (total < MIN_BUTTONS) return undefined;\n  for (const [hex, count] of counts) {\n    if (count / total >= MAJORITY) return hex;\n  }\n  return undefined;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;;;ACQA,IAAM,gBAAwC;AAAA,EACnD,eAAe;AAAA,EACf,aAAa;AAAA,EACb,WAAW;AAAA,EACX,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AAAA,EACV,eAAe;AAAA,EACf,eAAe;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AACR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