/* One action control for the Downloads page and Settings download manager. */
(function(root) {
'use strict';
// One SVG definition per media concept; every instance inherits its control colour.
const mediaPaths = {
download: '',
offline: '',
progress: ''
};
const variants = {
'classic': mediaPaths,
'f7-swipe': {
download: '',
offline: '',
progress: ''
},
'glass-stage': {
download: '',
offline: '',
progress: ''
},
'bento-hub': {
download: '',
offline: '',
progress: ''
}
};
const use = kind => ``;
const svg = (kind, extra = '') => ``;
const media = { paths: mediaPaths, use, svg };
if (root.document) {
const defs = root.document.createElementNS('http://www.w3.org/2000/svg', 'svg');
defs.setAttribute('aria-hidden', 'true'); defs.setAttribute('width', '0'); defs.setAttribute('height', '0');
defs.style.position = 'absolute'; defs.style.pointerEvents = 'none';
defs.innerHTML = '' + Object.keys(mediaPaths).map(kind => `${Object.entries(variants).map(([layout, paths]) => `${paths[kind]}`).join('')}`).join('') + '';
root.document.body.appendChild(defs);
root.MediaIcons = media;
}
const paths = {
retry: '',
cancel: '',
pause: '',
resume: '',
};
function create(doc, action, title) {
if (!paths[action]) throw new Error('Unknown download action');
const label = action[0].toUpperCase() + action.slice(1);
const button = doc.createElement('button'); button.type = 'button';
button.className = `dl-act download-action${action === 'cancel' ? ' danger' : ''}`;
button.setAttribute('aria-label', `${label} ${title}`);
const icon = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
icon.setAttribute('viewBox', '0 0 24 24'); icon.setAttribute('aria-hidden', 'true'); icon.setAttribute('focusable', 'false');
icon.classList.add('download-action-icon'); icon.innerHTML = paths[action];
const text = doc.createElement('span'); text.textContent = label;
button.append(icon, text); return button;
}
const api = { create, media };
if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.DownloadActions = api;
})(globalThis);