- End ============================ */ (function () { function initLabHospaOnly() { const root = document.getElementById("labHospaOnly"); if (!root) return;// prevent double-init (Elementor can render multiple times) if (root.dataset.lhsInit === "1") return; root.dataset.lhsInit = "1";const track = root.querySelector(".lhs-track"); const viewport = root.querySelector(".lhs-viewport"); const prevBtn = root.querySelector(".lhs-prev"); const nextBtn = root.querySelector(".lhs-next"); const progressFill = root.querySelector(".lhs-progressFill"); const progressBar = root.querySelector(".lhs-progress");if (!track || !viewport || !prevBtn || !nextBtn) return;const isRTL = (getComputedStyle(root).direction || "").toLowerCase() === "rtl" || (document.documentElement.getAttribute("dir") || "").toLowerCase() === "rtl";const cards = () => Array.from(root.querySelectorAll(".lhs-card"));let index = 0; let autoTimer = null; const AUTO_MS = 3000;function gapPx() { const style = window.getComputedStyle(track); const g = parseFloat(style.columnGap || style.gap || "0"); return Number.isFinite(g) ? g : 0; }function stepPx() { const cs = cards(); if (!cs.length) return 0; return cs[0].offsetWidth + gapPx(); }function visibleCount() { const step = stepPx(); if (!step) return 1; return Math.max(1, Math.floor(viewport.clientWidth / step)); }function maxIndex() { const total = cards().length; const vis = visibleCount(); return Math.max(0, total - vis); }function clampLoop() { const mi = maxIndex(); if (index < 0) index = mi; if (index > mi) index = 0; }function render() { clampLoop(); const step = stepPx();// IMPORTANT: RTL moves opposite direction const tx = isRTL ? index * step : -index * step; track.style.transform = "translateX(" + tx + "px)";// progress bar if (progressFill && progressBar) { const mi = maxIndex(); const maxMove = progressBar.clientWidth - progressFill.clientWidth;if (mi <= 0 || maxMove <= 0) { progressFill.style.transform = "translateX(0px)"; return; }// RTL should fill in opposite direction too const pct = index / mi; const px = maxMove * pct; progressFill.style.transform = "translateX(" + px + "px)"; } }// In RTL, "next" should reveal cards on the LEFT visually (so index changes opposite) function next() { index += isRTL ? -1 : 1; render(); } function prev() { index += isRTL ? 1 : -1; render(); }function stopAuto() { if (autoTimer) { clearInterval(autoTimer); autoTimer = null; } }function startAuto() { stopAuto(); autoTimer = setInterval(next, AUTO_MS); }nextBtn.addEventListener("click", function () { stopAuto(); next(); startAuto(); });prevBtn.addEventListener("click", function () { stopAuto(); prev(); startAuto(); });root.addEventListener("mouseenter", stopAuto); root.addEventListener("mouseleave", startAuto); viewport.addEventListener("focusin", stopAuto); viewport.addEventListener("focusout", startAuto);viewport.addEventListener("keydown", function (e) { // keep arrows natural for RTL too if (e.key === "ArrowRight") { e.preventDefault(); stopAuto(); prev(); startAuto(); } if (e.key === "ArrowLeft") { e.preventDefault(); stopAuto(); next(); startAuto(); } });window.addEventListener("resize", function () { // when resizing, keep correct start side in RTL if (isRTL) index = Math.min(index, maxIndex()); render(); });// Start position: // RTL: start from "right side" (so you can scroll to see the other cards) // LTR: start from left requestAnimationFrame(function () { if (isRTL) index = maxIndex(); render(); startAuto(); }); }// normal load if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", initLabHospaOnly); } else { initLabHospaOnly(); }// Elementor hook (frontend/editor) document.addEventListener("elementor/frontend/init", function () { try { if (window.elementorFrontend && elementorFrontend.hooks) { elementorFrontend.hooks.addAction("frontend/element_ready/global", function () { // allow re-init after Elementor rerender const root = document.getElementById("labHospaOnly"); if (root) root.dataset.lhsInit = "0"; initLabHospaOnly(); }); } } catch (e) {} }); })();