(function () {
"use strict";
var fill = document.querySelector(".sb-fill");
var track = document.querySelector(".sb-track");
var elapsed = document.querySelector(".sb-elapsed");
if (!fill || !track || !elapsed) return;
var TOTAL = 237; var sections = Array.prototype.slice.call(document.querySelectorAll("[data-section]"));
function clock(seconds) {
var s = Math.round(seconds);
return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
}
function update() {
var scrollable = document.documentElement.scrollHeight - window.innerHeight;
var progress = scrollable > 0 ? Math.min(1, Math.max(0, window.scrollY / scrollable)) : 0;
fill.style.width = (progress * 100).toFixed(2) + "%";
elapsed.textContent = clock(progress * TOTAL);
var middle = window.innerHeight / 2;
var current = "ommp";
for (var i = 0; i < sections.length; i++) {
if (sections[i].getBoundingClientRect().top <= middle) {
current = sections[i].getAttribute("data-section");
}
}
if (track.textContent !== current) track.textContent = current;
}
var queued = false;
function onScroll() {
if (queued) return;
queued = true;
requestAnimationFrame(function () { queued = false; update(); });
}
addEventListener("scroll", onScroll, { passive: true });
addEventListener("resize", onScroll);
update();
document.querySelectorAll(".cmd-copy").forEach(function (btn) {
var cmd = btn.parentNode.querySelector(".cmd");
if (!cmd) return;
btn.addEventListener("click", function () {
if (!navigator.clipboard) return;
navigator.clipboard.writeText(cmd.textContent.trim()).then(function () {
btn.classList.add("is-copied");
setTimeout(function () { btn.classList.remove("is-copied"); }, 1600);
});
});
});
var setup = document.querySelector(".setup-skipped");
if (setup && "IntersectionObserver" in window) {
var lines = Array.prototype.slice.call(setup.children);
setup.parentNode.classList.add("setup-armed");
var still = matchMedia("(prefers-reduced-motion: reduce)").matches;
var strike = new IntersectionObserver(function (entries) {
entries.forEach(function (e) {
if (!e.isIntersecting) return;
strike.unobserve(e.target);
lines.forEach(function (li, i) {
setTimeout(function () { li.classList.add("is-struck"); }, still ? 0 : i * 260);
});
});
}, { threshold: 0.6 });
strike.observe(setup);
}
})();