window.sptb = { downloadFile: function(fileName, contentType, base64) { var link = document.createElement('a'); link.download = fileName; link.href = 'data:' + contentType + ';base64,' + base64; document.body.appendChild(link); link.click(); document.body.removeChild(link); }, setTheme: function(theme) { var t = (theme || 'System').toLowerCase(); if (t === 'system') { t = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } document.documentElement.setAttribute('data-theme', t); }, scrollToBottom: function(el) { if (el) el.scrollTop = el.scrollHeight; } };