(function () {
var e = new URL(window.location.href),
t = e.searchParams.get("results") === "submitted",
s =
e.searchParams.get("skip_intro") === "true" ||
e.searchParams.get("start") === "quiz",
a = document.createElement("style");
a.id = "sits-fouc-prevention";
var n = t
? "Loading your personalized quiz results..."
: "Loading your quiz...";
a.textContent =
"#quiz-section{opacity:0!important;visibility:hidden!important;pointer-events:none!important}#results-section{opacity:0!important;visibility:hidden!important;pointer-events:none!important}.sits-loader-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:#f7f7f7;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:9999}.sits-loader-spinner{width:48px;height:48px;animation:sits-spin 1s linear infinite}.sits-loader-text{margin-top:16px;font-family:system-ui,-apple-system,sans-serif;font-size:16px;color:#3f4d49;text-align:center}.sits-loader-text.pulse{animation:sits-pulse 1.5s ease-in-out infinite}@keyframes sits-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes sits-pulse{0%,100%{opacity:0.4}50%{opacity:0.8}}";
(document.head || document.documentElement).appendChild(a);
document.addEventListener("DOMContentLoaded", function () {
var e = document.createElement("div");
e.id = "sits-loader-overlay";
e.className = "sits-loader-overlay";
e.innerHTML =
'
' +
n +
"
";
document.body.appendChild(e);
});
window.__SITS_FLAGS = { isResultsPage: t, shouldSkipIntro: s };
})();
(function () {
function e() {
var e = document.createElement("script");
e.src =
"https://cdn.jsdelivr.net/gh/videsigns/webflow-tools@latest/multi-step.js";
document.head.appendChild(e);
}
function t() {
typeof window.jQuery !== "undefined" ? e() : setTimeout(t, 50);
}
document.readyState === "loading"
? document.addEventListener("DOMContentLoaded", t)
: t();
})();
(function () {
var e = {
config: {
successCheckTimeout: 30000,
successTriggerDelay: 6000,
animationDuration: 500,
skipIntroParams: ["skip_intro", "start"],
libraryCheckAttempts: 100,
libraryCheckDelay: 100,
},
elements: {},
flags: window.__SITS_FLAGS || {
isResultsPage: false,
shouldSkipIntro: false,
},
init: function () {
var t = this;
t.cacheElements();
t.flags.isResultsPage ? t.waitForResultsReady() : t.waitForLibraryReady();
t.initRadioControls();
t.initCheckboxHandler();
t.initFormSubmission();
t.updatePageURL();
},
cacheElements: function () {
this.elements = {
quizSection: document.getElementById("quiz-section"),
resultsSection: document.getElementById("results-section"),
childFitOptions: document.getElementById(
"child-fit-convertible-options",
),
radioYes: document.getElementById("radio-yes-hide-animation"),
radioNo: document.getElementById("radio-no-do-nothing"),
tosCheckbox: document.getElementById(
"Read-Terms-of-Service-and-Agree-to-Emails",
),
pageUrlInput: document.getElementById("pageURL"),
shortenedUrlInput: document.getElementById("shortenedURL"),
seatResultsInput: document.getElementById("seat-results"),
quantityResultsInput: document.getElementById("quantity-results"),
resultsTriggerBlock: document.querySelector(".results-trigger-block"),
};
},
hideLoader: function () {
var e = document.getElementById("sits-loader-overlay"),
t = document.getElementById("sits-fouc-prevention"),
s = this.elements.quizSection,
a = this.elements.resultsSection;
t && t.remove();
if (this.flags.isResultsPage) {
s &&
((s.style.display = "none"),
(s.style.height = "0"),
(s.style.overflow = "hidden"),
(s.style.opacity = "0"),
(s.style.visibility = "hidden"));
a &&
((a.style.display = "block"),
(a.style.opacity = "1"),
(a.style.visibility = "visible"),
(a.style.pointerEvents = ""));
} else {
s &&
((s.style.opacity = "1"),
(s.style.visibility = "visible"),
(s.style.pointerEvents = ""));
}
e && e.remove();
},
waitForResultsReady: function () {
var e = this,
t = 0;
function s() {
t++;
var a = document.getElementById("results-section");
var n =
a &&
a.querySelector(
".product-list-scroll, .jetboost-list-item, [class*='result']",
);
if (a && (a.children.length > 0 || n)) {
e.hideLoader();
} else if (t < 50) {
setTimeout(s, 100);
} else {
e.hideLoader();
}
}
setTimeout(s, 200);
},
waitForLibraryReady: function () {
var e = this,
t = 0;
function s() {
t++;
var a = document.querySelectorAll('[data-form="step"]');
if (a.length < 2) {
t < e.config.libraryCheckAttempts
? setTimeout(s, e.config.libraryCheckDelay)
: e.hideLoader();
return;
}
var n = window.getComputedStyle(a[1]).display === "none";
n
? e.flags.shouldSkipIntro
? e.skipToNextStep()
: e.hideLoader()
: t < e.config.libraryCheckAttempts
? setTimeout(s, e.config.libraryCheckDelay)
: e.hideLoader();
}
setTimeout(s, 200);
},
skipToNextStep: function () {
var e = this,
t =
document.querySelector('[data-card="true"][data-form="step"]') ||
document.querySelector(".form1_step.cover-screen");
if (!t) {
e.hideLoader();
return;
}
var s = t.querySelector('[data-form="next-btn"]');
if (!s) {
e.hideLoader();
return;
}
s.classList.remove("disabled");
s.style.pointerEvents = "auto";
s.style.opacity = "1";
typeof jQuery !== "undefined" ? jQuery(s).trigger("click") : s.click();
e.cleanSkipIntroFromURL();
setTimeout(function () {
e.hideLoader();
}, 100);
},
cleanSkipIntroFromURL: function () {
var e = new URL(window.location.href),
t = false;
for (var s = 0; s < this.config.skipIntroParams.length; s++) {
var a = this.config.skipIntroParams[s];
if (e.searchParams.has(a)) {
e.searchParams.delete(a);
t = true;
}
}
t &&
window.history &&
window.history.replaceState &&
window.history.replaceState({}, "", e.toString());
},
initRadioControls: function () {
var e = this,
t = this.elements.childFitOptions,
s = this.elements.radioYes,
a = this.elements.radioNo;
if (!t) return;
this.syncRadioState();
s &&
s.addEventListener("change", function () {
s.checked && e.toggleChildFitOptions(false);
});
a &&
a.addEventListener("change", function () {
a.checked && e.toggleChildFitOptions(true);
});
},
syncRadioState: function () {
var e = this.elements.radioYes,
t = this.elements.radioNo;
e && e.checked
? this.toggleChildFitOptions(false, false)
: t && t.checked && this.toggleChildFitOptions(true, false);
},
toggleChildFitOptions: function (e, t) {
var s = this.elements.childFitOptions;
if (!s) return;
t === undefined && (t = true);
if (typeof gsap !== "undefined" && t) {
gsap.to(s, {
autoAlpha: e ? 1 : 0,
height: e ? "auto" : 0,
duration: 0.5,
ease: "power2.inOut",
});
} else {
s.style.display = e ? "block" : "none";
s.style.opacity = e ? "1" : "0";
s.style.height = e ? "auto" : "0";
s.style.visibility = e ? "visible" : "hidden";
}
},
getURLParameters: function () {
var e = {},
t = new URL(window.location.href),
s = this;
t.searchParams.forEach(function (t, a) {
s.config.skipIntroParams.indexOf(a) === -1 && (e[a] = t);
});
return e;
},
updatePageURL: function () {
var e = this.getURLParameters(),
t = window.location.pathname.split("/").filter(function (e) {
return e;
}),
s = t[t.length - 1] || "convertible",
a = "https://www.safeintheseat.com/stage/" + s + "?results=submitted&",
n = a + new URLSearchParams(e).toString();
this.elements.pageUrlInput && (this.elements.pageUrlInput.value = n);
return n;
},
initCheckboxHandler: function () {
var e = this,
t = this.elements.tosCheckbox;
t &&
t.addEventListener("change", function () {
t.checked && e.handleCheckboxChange();
});
},
handleCheckboxChange: function () {
var e = this.updatePageURL();
this.elements.shortenedUrlInput &&
(this.elements.shortenedUrlInput.value = e);
var t = document.querySelectorAll(
'input[data-ms-member="last-quiz-result"]',
);
for (var s = 0; s < t.length; s++) {
t[s].value = e;
}
this.updateProductResults();
},
updateProductResults: function () {
var e = document.querySelectorAll(
".product-list-scroll .jetboost-list-item",
),
t = [];
for (var s = 0; s < e.length; s++) {
e[s].value && t.push(e[s].value);
}
var a = t.join(",");
this.elements.seatResultsInput &&
(this.elements.seatResultsInput.value = a);
this.elements.quantityResultsInput &&
(this.elements.quantityResultsInput.value = e.length);
},
initFormSubmission: function () {
var e = this,
t = document.querySelectorAll("form");
for (var s = 0; s < t.length; s++) {
t[s].addEventListener("submit", function () {
e.watchForSuccess();
});
}
},
watchForSuccess: function () {
var e = this,
t = new MutationObserver(function (s, a) {
document.querySelector(".results-submitted") &&
(a.disconnect(),
setTimeout(function () {
e.triggerResultsBlock();
}, e.config.successTriggerDelay));
});
t.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ["class", "style"],
});
setTimeout(function () {
t.disconnect();
}, this.config.successCheckTimeout);
},
triggerResultsBlock: function () {
var e =
this.elements.resultsTriggerBlock ||
document.querySelector(".results-trigger-block");
e && e.click();
},
};
document.readyState === "loading"
? document.addEventListener("DOMContentLoaded", function () {
e.init();
})
: e.init();
window.SITSQuiz = e;
})();