import { render } from 'preact'; import { readBootstrap } from './bootstrap'; import { App } from './App'; import { createT } from './i18n'; import { WidgetApi, buildCapabilities } from './widget-api'; import './styles.css'; // Input-mode detector — see apps/widget-telegram/src/main.tsx for the // full rationale. Default to 'mouse'; the capture-phase pointerdown // listener flips to 'touch' on the first non-mouse pointerType. // matchMedia guessing was dropped — every variant // (`any-pointer: coarse|fine`, `hover: hover`, `pointer: fine|coarse`) // is mis-reported on at least one shipping device. const setInputMode = (mode: 'touch' | 'mouse'): void => { document.documentElement.dataset.input = mode; }; setInputMode('mouse'); window.addEventListener( 'pointerdown', (event) => { setInputMode(event.pointerType === 'mouse' ? 'mouse' : 'touch'); }, { passive: true, capture: true } ); const root = document.getElementById('app'); if (!root) { throw new Error('#app root element missing — index.html out of sync'); } const result = readBootstrap(window.location.search); if (!result.ok) { // Either someone opened the widget URL directly (no host params), or a // host bug failed to provide them. Render a self-contained diagnostic // instead of going silent. Bootstrap failed before we could read // clientLanguage, so let createT fall back to navigator.language. const t = createT(); render(