/** * Phone and tablet helpers (25 Oct 2026 phone check). * * Mouse-or-touch wording is done in CSS (.on-mouse / .on-touch in * styles.scss), so the prerendered page needs no swap after loading; these * are for what CSS cannot reach. */ /** * An iPhone, iPod or iPad, including iPadOS, which reports a Mac's desktop * user agent but has a touch screen (no Mac does). False while prerendering. */ export function isIOS(): boolean { if (typeof navigator === 'undefined') return false; const ua = navigator.userAgent || ''; return /iPhone|iPad|iPod/.test(ua) || (/Macintosh/.test(ua) && (navigator.maxTouchPoints ?? 0) > 1); } /** * The accept list for a file input. On iOS the Files picker greys out every * file whose extension the system does not know (.3mf, .skp, .tgs, .insv, * .rsv, .mts...), even when it is on the list, so there the input gets no * list at all and the tool says plainly when a chosen file is not one it * reads. Bind it as [attr.accept]="pickerAccept('...')": null removes the * attribute. Prerendered pages keep the list. */ export function pickerAccept(list: string): string | null { return isIOS() ? null : list; } /** A touch screen is the main pointer (a phone or tablet), after loading; false while prerendering. */ export function isTouch(): boolean { return typeof matchMedia !== 'undefined' && matchMedia('(pointer: coarse)').matches; } /** * A file that is plainly not a video or sound recording (a photo, PDF or * text): with no accept list on iOS the picker offers these too, and video * tools turn them away with a plain message instead of a "damaged video" one. */ export function plainlyNotVideo(file: File): boolean { // Some systems type MPEG-TS (.ts) as Qt translation text. if (/\.(ts|mts|m2ts|m2t|tod|mod)$/i.test(file.name)) return false; return /^(image|text)\//.test(file.type) || file.type === 'application/pdf' || /\.(jpe?g|png|heic|heif|gif|webp|pdf|txt|docx?|xlsx?|zip)$/i.test(file.name); }