import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
    connect() {
        try {
            const ua = navigator.userAgent || "";
            const platform = navigator.platform || "";
            const isMac = /Mac|iPhone|iPad|iPod/.test(platform) || /Macintosh|Mac OS X/.test(ua);
            if (isMac) {
                this.element.classList.add('macos');
            } else {
                this.element.classList.remove('macos');
            }
        } catch (_) {
            // no-op: in non-browser environments
        }
    }
}
