// Generated, do not edit. sha256:93e679e11f5329a380a996f2d99d603c26410a0b331dfefcb1da78dc2058cc17 import { appSetting, setAppSetting } from '../app-settings.js'; import { t } from '../i18n/index.js'; import { EYE, EYE_OFF } from './icons.js'; import { CONFIG } from '../../shared/config.js'; let idleTimer = null; let btn = null; function isOn() { return appSetting('blur') === 1; } export const isBlurred = () => isOn(); export const unblur = () => setOn(false); function apply(on) { document.documentElement.dataset.blur = on ? 'on' : 'off'; if (btn) { btn.innerHTML = on ? EYE_OFF : EYE; btn.classList.toggle('is-on', on); } document.dispatchEvent(new CustomEvent('blur-changed', { detail: { on } })); } function armIdle() { clearTimeout(idleTimer); const min = appSetting('auto_blur_min'); if (min >= CONFIG.AUTO_BLUR.NEVER_MIN) return; idleTimer = setTimeout(() => { setOn(true); }, min * 60 * 1000); } async function setOn(on) { apply(on); try { await setAppSetting('blur', on ? 1 : 0); } catch { } if (on) clearTimeout(idleTimer); else armIdle(); } function onActivity() { if (!isOn()) armIdle(); } function onSpace(e) { if (e.key !== ' ' || e.repeat || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return; if (e.target !== document.body && e.target !== document.documentElement) return; if (document.querySelector('.nav-edit-toggle.is-on')) return; e.preventDefault(); setOn(!isOn()); } export function initPrivacyBlur(hostEl) { btn = document.createElement('button'); btn.type = 'button'; btn.className = 'statusbar-eye'; btn.title = t('blur.toggle'); btn.setAttribute('aria-label', t('blur.toggle')); btn.onclick = () => { setOn(!isOn()); }; hostEl.appendChild(btn); apply(isOn()); armIdle(); for (const ev of ['pointerdown', 'keydown', 'wheel', 'touchstart']) { document.addEventListener(ev, onActivity, { passive: true }); } document.addEventListener('keydown', onSpace); document.addEventListener('settings-changed', () => { if (!isOn()) armIdle(); }); }