window.DigitalFeedback['https://cdn.us2.hxplatform.com/loader/prod/scenario?programKey=T3xr60&scenarioId=94&programVersion=96'] = function (api) {
console.log('8.10.26')

// ----------------------------------------
// SPA Initialization Guard
// ----------------------------------------

if (window.showPercentAndSurveyHandlersInitialized) {
    return;
}

window.showPercentAndSurveyHandlersInitialized = true;


// ----------------------------------------
// Show to .5%
// ----------------------------------------

if (!sessionStorage.showPercent) {
    sessionStorage.showPercent =
        Math.floor(Math.random() * 200) + 1;
}

//console.log(
//    "Show percent:",
//    sessionStorage.showPercent
//);


// ----------------------------------------
// Close Button / Shim Handler
// ----------------------------------------

let shimHandlerAttached = false;

const observer = new MutationObserver(() => {

    const shim =
        document.querySelector(
            '.cf-container-shim'
        );

    const closeBtn =
        document.querySelector(
            '.cf-container__close'
        );


    if (
        shim &&
        closeBtn &&
        !shimHandlerAttached
    ) {

        shim.addEventListener(
            'click',
            () => closeBtn.click()
        );

        shimHandlerAttached = true;

        observer.disconnect();

        //console.log(
        //    "Survey shim close handler attached"
        //);
    }
});


if (document.body) {

    observer.observe(
        document.body,
        {
            childList: true,
            subtree: true
        }
    );

}


// ----------------------------------------
// Survey Complete Handler
// ----------------------------------------

window.addEventListener(
    "message",
    function (e) {

        if (
            e.data &&
            e.data.type ===
            "cf-survey-complete"
        ) {

            const closeBtn =
                document.querySelector(
                    ".cf-container__close"
                );

            if (closeBtn) {

                setTimeout(() => {

                    // Re-check the DOM in case the
                    // SPA recreated the survey container.
                    const currentCloseBtn =
                        document.querySelector(
                            ".cf-container__close"
                        );

                    if (currentCloseBtn) {
                        currentCloseBtn.click();
                    }

                }, 3000);
            }
        }
    }
);

};