(function (root, factory) { if (typeof module === 'object' && module.exports) module.exports = factory; else root.createMobileTaskDock = factory; })(typeof self !== 'undefined' ? self : this, function createMobileTaskDock(options) { const nav = options.nav; const buttons = options.buttons; const overlays = options.overlays || []; let launcher = null; let wasHidden = false; function select(name) { Object.entries(buttons).forEach(([key, button]) => { if (key === name) button.setAttribute('aria-current', 'page'); else button.removeAttribute('aria-current'); }); } function refreshVisibility() { const hidden = overlays.some(overlay => overlay.classList.contains('open')); nav.hidden = hidden; if (wasHidden && !hidden && launcher) launcher.focus(); wasHidden = hidden; } function start() { Object.entries(buttons).forEach(([name, button]) => { button.addEventListener('click', event => { launcher = event.currentTarget; select(name); options.actions[name](); }); }); options.observe(refreshVisibility, overlays); refreshVisibility(); } function updateAttention(count) { const total = Math.max(0, Number(count) || 0); const badge = options.attentionBadge; if (badge) { badge.textContent = String(total); badge.hidden = total === 0; } if (buttons.work) { buttons.work.setAttribute( 'aria-label', total ? 'Work, ' + total + ' items need attention' : 'Work' ); } } return {start, refreshVisibility, updateAttention}; });