/* UTIL — small shared helpers. No dependencies. */ (function () { 'use strict'; function escapeHtml(value) { return String(value == null ? '' : value) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function getParam(name) { return new URLSearchParams(location.search).get(name); } // 95 -> "1:35", 3675 -> "1:01:15" function formatSeconds(sec) { sec = Math.max(0, Math.floor(sec || 0)); const h = Math.floor(sec / 3600); const m = Math.floor((sec % 3600) / 60); const s = sec % 60; const mm = h ? String(m).padStart(2, '0') : String(m); const ss = String(s).padStart(2, '0'); return h ? `${h}:${mm}:${ss}` : `${mm}:${ss}`; } // 141 -> "2h 21m" function runtimeLabel(mins) { if (!mins || mins <= 0) return ''; const h = Math.floor(mins / 60); const m = mins % 60; return h ? (m ? `${h}h ${m}m` : `${h}h`) : `${m}m`; } function debounce(fn, wait) { let timer = null; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), wait); }; } // resize a full TMDB image URL (…/t/p//path) to another size function tmdbResize(url, size) { if (!url) return ''; return url.replace(/\/t\/p\/[A-Za-z0-9._-]+/, `/t/p/${size}`); } window.SR = window.SR || {}; SR.util = { escapeHtml, getParam, formatSeconds, runtimeLabel, debounce, tmdbResize }; })();