<!doctype html>
<html lang="en">
<head prefix="og: http://ogp.me/ns# cms: http://ogp.me/ns/cms#">
    <meta charset="utf-8"/>
<meta name="title" content="Knowledge Quest"/>
<meta name="description" content="Academically effective Christian homeschool curriculum with a bible-based approach in all subjects, grades K-12."/>
<meta name="robots" content="INDEX,FOLLOW"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Knowledge Quest</title>
        <link rel="stylesheet" type="text/css" media="all" href="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/css/styles.css" />
<link rel="stylesheet" type="text/css" media="all" href="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Ecommerce121_DynamicVideoEmbed/css/styles.css" />
<link rel="stylesheet" type="text/css" rel="stylesheet" type="text/css" href="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/ChrisMallory_FreeShippingProgressBar/css/custom.css" />
<link rel="stylesheet" type="text/css" defer="defer" href="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Hyva_PayPalBraintree/css/apple-pay.css" />
<link rel="stylesheet" type="text/css" defer="defer" href="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Hyva_PayPalBraintree/css/google-pay.css" />
<link rel="icon" type="image/x-icon" href="https://cdn.masterbooks.com/media/favicon/websites/2/mb-favicon.png" />
<link rel="shortcut icon" type="image/x-icon" href="https://cdn.masterbooks.com/media/favicon/websites/2/mb-favicon.png" />
<meta name="p:domain_verify" content="3c2b7b779c79cf0e0c5d00dab22d860b"/>
<meta name="google-site-verification" content="mmfjEiKzKkwJhE0q9kVSU21poab0VA6-DWLa-QnGfTo" />

<link rel="preconnect" href="https://www.google.com">
<link rel="preconnect" href="https://www.gstatic.com" crossorigin>

<script async src="https://cdn.noibu.com/collect.js"></script>

<style><!--

/* Hide Google ReCaptcha text box in footer temporarily */
.page-footer #newsletter-validate-detail + div.w-full { display: none; }

/* Temporary fix for affiliate program ugly formatting - Should be resolved now */
 .affiliate-account_current .bg-secondary { background-color: transparent; } 
 .affiliate__widget-programs tr.bg-secondary { background-color: transparent; } 

/* Don't show instant checkout options in minicart dropdown */
	.actions .primary .minicart { display: none; }

/* Hide nav toggle and minicart on checkout */
	.checkout-index-index .header.content .nav-toggle { display: none !important; }
	.checkout-index-index .header.content .minicart-wrapper { display: none !important; }

/* File Download Description CSS for Lesson Planners */
	table.lesson-planner-detail {border:none; border-collapse:collapse; margin-top:1em; margin-bottom:2em;}
	table.lesson-planner-detail td {padding:5px 15px; vertical-align:middle; text-align:center; border: solid 1px;}

/* Adjust Amasty Promo Banners, hide second sidebar banner on phones */
	.sidebar-main .ambanners > div { margin: 1rem 0; }

	@media (max-width: 768px) {
		div[data-banner-id="5"] { display: none; }
	}

/* Handle possibility for empty widget blocks on checkout without breaking layout (shipping notices, login banner) */
	@media (max-width: 768px) {
		.checkout-index-index .widget { margin-bottom: 0; }
	}

/* Color on category header for specials page */
    body[class*="categorypath-specials"] h1#page-title {
	/* color: red; */
    }

--></style>

<style><!--
/* Update to decrease billing address confusion on checkout */

.checkout-payment-method .checkout-billing-address .primary .action-update {
    background-color: #f37021;
    color: #fff;
    margin-bottom: 20px;
    margin-right: 0;
    font-size: 3rem;
    line-height: normal;
    width: 100%;
}

@media (min-width: 768px) {
    .checkout-payment-method .actions-toolbar .primary {
        float: none;
        display: block;
        max-width: 500px;
    }
}
--></style>

<style><!--
/* Hide the blog post title under the main header image (non-H1) */
.amblog-index-post .amblog-post-title {
    display: none;
}
--></style>

<style><!--
/* Drastically reduce CLS from top strip popin */
body > .widget.block.block-banners {
    min-height: 2.6rem;
}
--></style>
<style><!--
@property --tw-rotate {syntax:"*";inherits:false;initial-value: 0deg;}
@property --tw-rotate-x {syntax:"*";inherits:false;initial-value: 0deg;}
@property --tw-rotate-y {syntax:"*";inherits:false;initial-value: 0deg;}
@property --tw-rotate-z {syntax:"*";inherits:false;initial-value: 0deg;}
@property --tw-skew-x {syntax:"*";inherits:false;initial-value: 0deg;}
@property --tw-skew-y {syntax:"*";inherits:false;initial-value: 0deg;}
--></style>

<style><!--
.mb-basic4 { color:rgba(0, 0, 0, 1); }
.mb-basic4-background { background-color:rgba(159, 162, 168, .20); }
.mb-math { color:rgba(218, 178, 40, 1); }
.mb-math-background { background-color:rgba(218, 178, 40, .20); }
.mb-languagearts { color:rgba(243, 112, 33, 1); }
.mb-languagearts-background { background-color:rgba(243, 112, 33, .20); }
.mb-history { color:rgba(0, 166, 81, 1); }
.mb-history-background { background-color:rgba(0, 166, 81, .20); }
.mb-science { color:rgba(38, 59, 151, 1); }
.mb-science-background { background-color:rgba(38, 59, 151, .20); }
.mb-electives { color:rgba(0, 161, 228, 1); }
.mb-electives-background { background-color:rgba(0, 161, 228, .20); }
--></style>    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,600" rel="stylesheet" type="text/css"><style type="text/css"><!--
						h1.page-title {display: none !important;}
						.page-layout-1column .column.main { padding-top: 0 !important; }

						#nlpg-landing-page-container { width: 100%; font-size: 18px; font-family:"Montserrat"; line-height: normal; padding: 1em; box-sizing: border-box;}
#nlpg-landing-page-container * {box-sizing: border-box;}
						#nlpg-landing-page-container .argento-grid > div { flex: 0 0 auto; display: flex; flex-direction: row; flex-wrap: wrap; box-sizing: border-box; }

						#nlpg-landing-page-container div.product-endcap ul { display: none; }
						#nlpg-landing-page-container div.product-endcap h4 { text-align: center; }
						#nlpg-landing-page-container div.product-endcap > div { padding: 1em; }
						#nlpg-landing-page-container .features { padding: 0 2em; }
						#nlpg-landing-page-container .text ul { font-size: 16px; }

						#nlpg-landing-page-container div.nlpg-videoCenterer { display: block; margin: 0 auto; max-width: 90%; }
						#nlpg-landing-page-container div.nlpg-videoWrapper {position:relative;padding-bottom:97.25%; /* 16:9 = 56.25%; */padding-top:25px;height:0;}
						#nlpg-landing-page-container div.nlpg-videoWrapper iframe {position:absolute;top:0;left:0;width:100%;height:100%;max-height:80vh;}

						#nlpg-landing-page-container .nlpglpc-button span {width: 100%;padding: 15px;cursor: pointer;box-shadow: 1px 1px 1px #999;font-weight: bold;background: #d3b21c;color: #FFFFFF;border-radius: 10px;border: 1px solid #999;font-size: 1em;display: block;box-sizing: border-box;text-align:center; font-family:"Montserrat";margin:3em 0;}
						#nlpg-landing-page-container .nlpglpc-button:hover span {box-shadow: inset 1px 1px 2px rgba(0,0,0,.5);}
						#nlpg-landing-page-container h4 { font-size: 1.2em; margin:.25em 0; font-weight: 600; }
						#nlpg-landing-page-container .nlpglpc-tagline {font-size: 1em; font-weight: normal; text-align:left; display:block; margin: 3em 0; line-height: 1.2;border:3px solid #d3b21c; padding: 0 2em 10px; }

						#nlpg-landing-page-container .argento-grid .product-endcap div { /*margin: 1em 0; */}
						#nlpg-landing-page-container .argento-grid img { margin: 0 auto; display: flex; }

						#nlpg-landing-page-container .block.widget .products-grid .product-item, #nlpg-landing-page-container .block.widget .products-grid .product-item .prolabels-wrapper { height: auto !important; }

						.main ul.check {margin:.5em 0 .5em 0;}
						.main ul.check li { display: block; }
						.main ul.check li:before { content: "\f00c"; margin-left: -1.5em; margin-right: 0.25em; font: bold normal normal 16px/1 "Font Awesome 5 Free"; position: relative; top: -1px; }

						@media (min-width: 768px) {
							#nlpg-landing-page-container div.nlpg-videoCenterer { max-width: 80%; }
						}
						@media (min-width: 970px) {
							#nlpg-landing-page-container .nlpglpc-button span {padding: 30px; font-size: 1.3em;}
							#nlpg-landing-page-container h4 { margin:.5em 0;}
							#nlpg-landing-page-container .nlpglpc-tagline {font-size: 1.3em; }
							#nlpg-landing-page-container div.product-endcap ul { display: block; }	
							#nlpg-landing-page-container div.product-endcap > div { padding: 1em; }
							#nlpg-landing-page-container div.product-endcap img { padding: 0 1em; box-sizing: border-box; }

							#nlpg-landing-page-container div.nlpg-videoWrapper {position:relative;padding-bottom:56.25%; /* 16:9 = 56.25%; */padding-top:25px;height:0;}

							#nlpg-landing-page-container .features { padding: 0 3em; }
							#nlpg-landing-page-container .text ul { font-size: 18px; }
						}

						@media (min-width: 768px) and (max-width: 991px){
							.col-sm-4 { width: 33.33333333%; }
						}
					--></style><script src="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Ecommerce121_JajumaImageOptimizerUltimate/js/jajuma-custom.js" ></script>

<script type="text&#x2F;javascript">window.loadModernizr();</script>
<style>
    .swatch-option-loading-webp {
        content: url(https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/images/loader-2.gif);
    }
    @keyframes imgpulse {
        50% {
            opacity: 0.5;
        }
    }
</style>

<script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    window.YIREO_GOOGLETAGMANAGER2_ENABLED = true;
    (function (events) {
        const initYireoGoogleTagManager2 = function () {
            events.forEach(function (eventType) {
                window.removeEventListener(eventType, initYireoGoogleTagManager2);
            });

                        (function (w, d, s, l, i) {
                w[l] = w[l] || [];
                w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
                var f = d.getElementsByTagName(s)[0],
                    j = d.createElement(s),
                    dl = l != 'dataLayer' ? '&l=' + l : '';
                j.async = true;
                j.src = 'https\u003A\u002F\u002Fwww.googletagmanager.com' + '/gtm.js?id=' + i + dl;
                f.parentNode.insertBefore(j, f);
            })(window, document, 'script', 'dataLayer', 'GTM\u002DW4SHH4P');
                    };

        events.forEach(function (eventType) {
            window.addEventListener(eventType, initYireoGoogleTagManager2, {once: true, passive: true})
        });
    })(['load', 'keydown', 'mouseover', 'scroll', 'touchstart', 'wheel']);

    </script>
<script>
    var BASE_URL = 'https://www.masterbooks.com/';
    var THEME_PATH = 'https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US';
    var COOKIE_CONFIG = {
        "expires": null,
        "path": "\u002F",
        "domain": ".www.masterbooks.com",
        "secure": true,
        "lifetime": "28800",
        "cookie_restriction_enabled": false    };
    var CURRENT_STORE_CODE = 'masterbooks';
    var CURRENT_WEBSITE_ID = '2';

    window.hyva = window.hyva || {}

    window.cookie_consent_groups = window.cookie_consent_groups || {}
    window.cookie_consent_groups['necessary'] = true;

    window.cookie_consent_config = window.cookie_consent_config || {};
    window.cookie_consent_config['necessary'] = [].concat(
        window.cookie_consent_config['necessary'] || [],
        [
            'user_allowed_save_cookie',
            'form_key',
            'mage-messages',
            'private_content_version',
            'mage-cache-sessid',
            'last_visited_store',
            'section_data_ids'
        ]
    );
    //# sourceURL=hyva-variables.js
</script>
<script>
    (function( hyva, undefined ) {

        function lifetimeToExpires(options, defaults) {

            const lifetime = options.lifetime || defaults.lifetime;

            if (lifetime) {
                const date = new Date;
                date.setTime(date.getTime() + lifetime * 1000);
                return date;
            }

            return null;
        }

        function generateRandomString() {

            const allowedCharacters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
                length = 16;

            let formKey = '',
                charactersLength = allowedCharacters.length;

            for (let i = 0; i < length; i++) {
                formKey += allowedCharacters[Math.round(Math.random() * (charactersLength - 1))]
            }

            return formKey;
        }

        const sessionCookieMarker = {noLifetime: true}

        const cookieTempStorage = {};

        const internalCookie = {
            get(name) {
                const v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
                return v ? v[2] : null;
            },
            set(name, value, days, skipSetDomain) {
                let expires,
                    path,
                    domain,
                    secure,
                    samesite;

                const defaultCookieConfig = {
                    expires: null,
                    path: '/',
                    domain: null,
                    secure: false,
                    lifetime: null,
                    samesite: 'lax'
                };

                const cookieConfig = window.COOKIE_CONFIG || {};

                expires = days && days !== sessionCookieMarker
                    ? lifetimeToExpires({lifetime: 24 * 60 * 60 * days, expires: null}, defaultCookieConfig)
                    : lifetimeToExpires(window.COOKIE_CONFIG, defaultCookieConfig) || defaultCookieConfig.expires;

                path = cookieConfig.path || defaultCookieConfig.path;
                domain = !skipSetDomain && (cookieConfig.domain || defaultCookieConfig.domain);
                secure = cookieConfig.secure || defaultCookieConfig.secure;
                samesite = cookieConfig.samesite || defaultCookieConfig.samesite;

                document.cookie = name + "=" + encodeURIComponent(value) +
                    (expires && days !== sessionCookieMarker ? '; expires=' + expires.toGMTString() : '') +
                    (path ? '; path=' + path : '') +
                    (domain ? '; domain=' + domain : '') +
                    (secure ? '; secure' : '') +
                    (samesite ? '; samesite=' + samesite : 'lax');
            },
            isWebsiteAllowedToSaveCookie() {
                const allowedCookies = this.get('user_allowed_save_cookie');
                if (allowedCookies) {
                    const allowedWebsites = JSON.parse(unescape(allowedCookies));

                    return allowedWebsites[CURRENT_WEBSITE_ID] === 1;
                }
                return false;
            },
            getGroupByCookieName(name) {
                const cookieConsentConfig = window.cookie_consent_config || {};
                let group = null;
                for (let prop in cookieConsentConfig) {
                    if (!cookieConsentConfig.hasOwnProperty(prop)) continue;
                    if (cookieConsentConfig[prop].includes(name)) {
                        group = prop;
                        break;
                    }
                }
                return group;
            },
            isCookieAllowed(name) {
                const cookieGroup = this.getGroupByCookieName(name);
                return cookieGroup
                    ? window.cookie_consent_groups[cookieGroup]
                    : this.isWebsiteAllowedToSaveCookie();
            },
            saveTempStorageCookies() {
                for (const [name, data] of Object.entries(cookieTempStorage)) {
                    if (this.isCookieAllowed(name)) {
                        this.set(name, data['value'], data['days'], data['skipSetDomain']);
                        delete cookieTempStorage[name];
                    }
                }
            }
        };

        hyva.getCookie = (name) => {
            const cookieConfig = window.COOKIE_CONFIG || {};

            if (cookieConfig.cookie_restriction_enabled && ! internalCookie.isCookieAllowed(name)) {
                return cookieTempStorage[name] ? cookieTempStorage[name]['value'] : null;
            }

            return internalCookie.get(name);
        }

        hyva.setCookie = (name, value, days, skipSetDomain) => {
            const cookieConfig = window.COOKIE_CONFIG || {};

            if (cookieConfig.cookie_restriction_enabled && ! internalCookie.isCookieAllowed(name)) {
                cookieTempStorage[name] = {value, days, skipSetDomain};
                return;
            }
            return internalCookie.set(name, value, days, skipSetDomain);
        }


        hyva.setSessionCookie = (name, value, skipSetDomain) => {
            return hyva.setCookie(name, value, sessionCookieMarker, skipSetDomain)
        }

        hyva.getBrowserStorage = () => {
            const browserStorage = window.localStorage || window.sessionStorage;
            if (!browserStorage) {
                console.warn('Browser Storage is unavailable');
                return false;
            }
            try {
                browserStorage.setItem('storage_test', '1');
                browserStorage.removeItem('storage_test');
            } catch (error) {
                console.warn('Browser Storage is not accessible', error);
                return false;
            }
            return browserStorage;
        }

        hyva.postForm = (postParams) => {
            const form = document.createElement("form");

            let data = postParams.data;

            if (! postParams.skipUenc && ! data.uenc) {
                data.uenc = btoa(window.location.href);
            }
            form.method = "POST";
            form.action = postParams.action;

            Object.keys(postParams.data).map(key => {
                const field = document.createElement("input");
                field.type = 'hidden'
                field.value = postParams.data[key];
                field.name = key;
                form.appendChild(field);
            });

            const form_key = document.createElement("input");
            form_key.type = 'hidden';
            form_key.value = hyva.getFormKey();
            form_key.name="form_key";
            form.appendChild(form_key);

            document.body.appendChild(form);

            form.submit();
        }

        hyva.getFormKey = function () {
            let formKey = hyva.getCookie('form_key');

            if (!formKey) {
                formKey = generateRandomString();
                hyva.setCookie('form_key', formKey);
            }

            return formKey;
        }

        hyva.formatPrice = (value, showSign, options = {}) => {
            const groupSeparator = options.groupSeparator;
            const decimalSeparator = options.decimalSeparator
            delete options.groupSeparator;
            delete options.decimalSeparator;
            const formatter = new Intl.NumberFormat(
                'en\u002DUS',
                Object.assign({
                    style: 'currency',
                    currency: 'USD',
                    signDisplay: showSign ? 'always' : 'auto'
                }, options)
            );
            return (typeof Intl.NumberFormat.prototype.formatToParts === 'function') ?
                formatter.formatToParts(value).map(({type, value}) => {
                    switch (type) {
                        case 'currency':
                            return '\u0024' || value;
                        case 'minusSign':
                            return '- ';
                        case 'plusSign':
                            return '+ ';
                        case 'group':
                            return groupSeparator !== undefined ? groupSeparator : value;
                        case 'decimal':
                            return decimalSeparator !== undefined ? decimalSeparator : value;
                        default :
                            return value;
                    }
                }).reduce((string, part) => string + part) :
                formatter.format(value);
        }

        const formatStr = function (str, nStart) {
            const args = Array.from(arguments).slice(2);

            return str.replace(/(%+)([0-9]+)/g, (m, p, n) => {
                const idx = parseInt(n) - nStart;

                if (args[idx] === null || args[idx] === void 0) {
                    return m;
                }
                return p.length % 2
                    ? p.slice(0, -1).replace('%%', '%') + args[idx]
                    : p.replace('%%', '%') + n;
            })
        }

        hyva.str = function (string) {
            const args = Array.from(arguments);
            args.splice(1, 0, 1);

            return formatStr.apply(undefined, args);
        }

        hyva.strf = function () {
            const args = Array.from(arguments);
            args.splice(1, 0, 0);

            return formatStr.apply(undefined, args);
        }

        /**
         * Take a html string as `content` parameter and
         * extract an element from the DOM to replace in
         * the current page under the same selector,
         * defined by `targetSelector`
         */
        hyva.replaceDomElement = (targetSelector, content) => {
            // Parse the content and extract the DOM node using the `targetSelector`
            const parser = new DOMParser();
            const doc = parser.parseFromString(content, 'text/html');
            const contentNode = doc.querySelector(targetSelector);

            // Bail if content or target can't be found
            if (!contentNode || !document.querySelector(targetSelector)) {
                return;
            }

                        hyva.activateScripts(contentNode);
            
            // Replace the old DOM node with the new content
            document.querySelector(targetSelector).replaceWith(contentNode);

            // Reload customerSectionData and display cookie-messages if present
            window.dispatchEvent(new CustomEvent("reload-customer-section-data"));
            hyva.initMessages();
        }

        hyva.removeScripts = (contentNode) => {
            const scripts = contentNode.getElementsByTagName('script');
            for (let i = 0; i < scripts.length; i++) {
                scripts[i].parentNode.removeChild(scripts[i]);
            }
            const templates = contentNode.getElementsByTagName('template');
            for (let i = 0; i < templates.length; i++) {
                const container = document.createElement('div');
                container.innerHTML = templates[i].innerHTML;
                hyva.removeScripts(container);
                templates[i].innerHTML = container.innerHTML;
            }
        }

        hyva.activateScripts = (contentNode) => {
            // Create new array from HTMLCollection to avoid mutation of collection while manipulating the DOM.
            const scripts = Array.from(contentNode.getElementsByTagName('script'));

            // Iterate over all script tags to duplicate+inject each into the head
            for (const original of scripts) {
                const script = document.createElement('script');
                original.type && (script.type = original.type);
                script.innerHTML = original.innerHTML;

                // Remove the original (non-executing) script from the contentNode
                original.parentNode.removeChild(original)

                // Add script to head
                document.head.appendChild(script);
            }

            return contentNode;
        }

        const replace = {['+']: '-', ['/']: '_', ['=']: ','};
        hyva.getUenc = () => btoa(window.location.href).replace(/[+/=]/g, match => replace[match]);

        let currentTrap;

        const focusableElements = (rootElement) => {
            const selector = 'button, [href], input, select, textarea, details, [tabindex]:not([tabindex="-1"]';
            return Array.from(rootElement.querySelectorAll(selector))
                .filter(el => {
                    return el.style.display !== 'none'
                        && !el.disabled
                        && el.tabIndex !== -1
                        && (el.offsetWidth || el.offsetHeight || el.getClientRects().length)
                })
        }

        const focusTrap = (e) => {
            const isTabPressed = e.key === 'Tab' || e.keyCode === 9;
            if (!isTabPressed) return;

            const focusable = focusableElements(currentTrap)
            const firstFocusableElement = focusable[0]
            const lastFocusableElement = focusable[focusable.length - 1]

            e.shiftKey
                ? document.activeElement === firstFocusableElement && (lastFocusableElement.focus(), e.preventDefault())
                : document.activeElement === lastFocusableElement && (firstFocusableElement.focus(), e.preventDefault())
        };

        hyva.releaseFocus = (rootElement) => {
            if (currentTrap && (!rootElement || rootElement === currentTrap)) {
                currentTrap.removeEventListener('keydown', focusTrap)
                currentTrap = null
            }
        }
        hyva.trapFocus = (rootElement) => {
            if (!rootElement) return;
            hyva.releaseFocus()
            currentTrap = rootElement
            rootElement.addEventListener('keydown', focusTrap)
            const firstElement = focusableElements(rootElement)[0]
            firstElement && firstElement.focus()
        }

        hyva.safeParseNumber = (rawValue) => {
            const number = rawValue ? parseFloat(rawValue) : null;

            return Array.isArray(number) || isNaN(number) ? rawValue : number;
        }

        const toCamelCase = s => s.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
        hyva.createBooleanObject = (name, value = false, additionalMethods = {}) => {

            const camelCase = toCamelCase(name);
            const key = '__hyva_bool_' + name

            return new Proxy(Object.assign(
                additionalMethods,
                {
                    [key]: !!value,
                    [name]() {return !!this[key]},
                    ['!' + name]() {return !this[key]}, // @deprecated This does not work with non-CSP Alpine
                    ['not' + camelCase]() {return !this[key]},
                    ['toggle' + camelCase]() {this[key] = !this[key]},
                    [`set${camelCase}True`]() {this[key] = true},
                    [`set${camelCase}False`]() {this[key] = false},
                }
            ), {
                set(target, prop, value) {
                    return prop === name
                        ? (target[key] = !!value)
                        : Reflect.set(...arguments);
                }
            })
        }

                hyva.alpineInitialized = (fn) => window.addEventListener('alpine:initialized', fn, {once: true})
        window.addEventListener('alpine:init', () => Alpine.data('{}', () => ({})), {once: true});
                window.addEventListener('user-allowed-save-cookie', () => internalCookie.saveTempStorageCookies())

    }( window.hyva = window.hyva || {} ));
    //# sourceURL=hyva.js
</script>
<script>
    'use strict';
    (() => {
        const origFormatPrice = hyva.formatPrice
        hyva.formatPrice = (value, showSign) => {
            if (value == 0) {
                return 'FREE';
            }
            const formatter = new Intl.NumberFormat(
                'en\u002DUS',
                {
                    style: 'currency',
                    currency: 'USD',
                    signDisplay: showSign ? "always" : "auto"
                }
            );
            return (typeof Intl.NumberFormat.prototype.formatToParts === 'function') ?
                formatter.formatToParts(value).map(({type, value}) => {
                    switch (type) {
                        case 'currency':
                            return '$' || value;
                        case 'minusSign':
                            return '- ';
                        case 'plusSign':
                            return '+ ';
                        default :
                            return value;
                    }
                }).reduce((string, part) => string + part) :
                formatter.format(value);
        }
    })()
</script>
<script type="speculationrules">
{
    "tag": "Hyva Theme",
    "prefetch": [{
        "source": "document",
        "where": {
            "and": [
                { "href_matches": "/*" },
                { "not": {
                    "href_matches": ["/customer/*","/search/*","/sales/*","/wishlist/*","/checkout/*","/paypal/*","/newsletter/*","/stores/store/redirect/*"]                }},
                { "not": {
                    "selector_matches": [".no-preload", ".do-not-prerender", "[download]", "[rel~=nofollow]", "[target]"]
                }}
            ]
        },
        "eagerness": "moderate"
    }]
}
</script>
<script>
    'use strict';

    (function () {
        window.initAmAppendLabels = {
            selectors: {
                labelWrapper: '.amlabel-position-wrapper'
            },
            /**
             * We use approach from hyva.replaceDomElement method to replace labels and init components
             *
             * @param {HTMLElement} labelContainer
             * @param {string} labelHtml
             * @return {void}
             */
            appendLabels: function (labelContainer, labelHtml) {
                const parser = new DOMParser();
                const doc = parser.parseFromString(labelHtml, 'text/html');
                const nodes = doc.querySelectorAll(this.selectors.labelWrapper);

                if (!nodes) {
                    return;
                }

                labelContainer.append(...nodes);
            }
        };
    })();
</script>
<script>
    (function () {
        let amSplideProcessed = false;

        window.addEventListener('load-amsplide', () => {
            if (amSplideProcessed) {
                window?.Splide && window.dispatchEvent(new CustomEvent('amsplide-loaded', {}));
                return;
            }

            const script = document.createElement('script');
            script.src = 'https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Amasty_LibSplideJs/4.1.3/js/splide/splide.min.js';
            script.async = true;
            document.body.appendChild(script);

            amSplideProcessed = true;

            script.onload = () => {
                window.dispatchEvent(new CustomEvent('amsplide-loaded', {}));
            }

            const stylesHref = 'https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Amasty_LibSplideJs/4.1.3/css/splide/splide.min.css';

            if (document.querySelector(`link[href="${stylesHref}"]`)) {
                return;
            }

            const styles = document.createElement('link');
            styles.rel = 'stylesheet';
            styles.type = 'text/css';
            styles.href = stylesHref;

            document.head.appendChild(styles);
        });
    }());
</script>

<script>
    window.addEventListener('init-external-scripts', () => {
        if (window._amPurifyLoaded) {
            return;
        }

        // Load Purify script asynchronously
        const script = document.createElement('script');
        script.src = 'https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Amasty_XsearchHyvaCompatibility/js/purify.min.js';
        script.async = true;
        document.body.appendChild(script);

        window._amPurifyLoaded = true;

        script.onload = () => {
            // Dispatch custom event when Swiper is loaded
            window.dispatchEvent(new CustomEvent('amPurifyLoaded', {}));
        }
    }, { once: true, passive: true });
</script>
    <script>
        function initWishlist() {
            return {
                addToWishlist(productId) {
                    this.$dispatch('open-amasty-wishlist-popup', {productId: productId})
                }
            }
        }
    </script>

    <meta property="og:type" content="cms"/>

    
    
    <meta property="og:url" content="https://www.masterbooks.com/knowledge-quest"/>
    <meta property="og:site_name" content="masterbooks.com"/>
</head>
<body id="html-body" class="cms-knowledge-quest page-layout-1column cms-page-view page-layout-cms-full-width">

<div
            class="ambanners ambanner-10"
        data-position="10"
        data-bannerid=""
        data-role="amasty-banner-container"
></div>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W4SHH4P" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<input name="form_key" type="hidden" value="zoOV9lBFMarBAz0K" />
    <noscript>
        <section
            class="message global noscript border-b-2 border-blue-500 bg-blue-50 shadow-none m-0 px-0 rounded-none font-normal"
            aria-labelledby="messageGlobalNoScriptMessage"
        >
            <div class="container text-center">
                <p id="messageGlobalNoScriptMessage">
                    <strong>JavaScript seems to be disabled in your browser.</strong>
                    <span>
                        For the best experience on our site, be sure to turn on Javascript in your browser.                    </span>
                </p>
            </div>
        </section>
    </noscript>


<script>
    document.body.addEventListener('touchstart', () => {}, {passive: true})
</script>


    <script>
        /**
         * Capture customer email address for DotDigital service.
         *
         * @param type
         * @param url
         */
        const dotDigitalEmailCapture = (type, url) => {
            /**
             * Validate email address for DotDigital service.
             *
             * Ported directly from the original module.
             *
             * @see Dotdigitalgroup\Email\view\frontend\web\js\emailCapture.js
             * @param email
             */
            const dotDigitalEmailValidate = (email) => {
                const regex = new RegExp([
                    '^([+\\w-\\.]+)@',
                    '((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|',
                    '(([\\w-]+\\.)+))',
                    '([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$'
                ].join(''));

                return regex.test(email);
            };

            /**
             * @param email
             */
            const captureEmail = (email) => {
                if (!email || !dotDigitalEmailValidate(email)) {
                    return;
                }

                if (typeof window.dmPt !== 'undefined') {
                    window.dmPt('identify', email);
                }
            };

            /**
             * POST to connector/ajax/emailcapture (to update the quote).
             *
             * @param email
             */
            const postToConnectorAjaxRoute = (email) => {
                if (url.length === 0) {
                    return;
                }

                fetch(url, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        'X-Requested-With': 'XMLHttpRequest'
                    },
                    body: "email=" + encodeURIComponent(email)
                });
            }

            let selectors = [];

            switch (type) {
                case 'newsletter' :
                    selectors.push('input[id="newsletter-subscribe"]');
                    break;

                case 'login' :
                    selectors.push('input[id="email"]');
                    break;

                case 'checkout' :
                    selectors.push('input[id="guest_details-email_address"]');
                    break;
            }

            selectors.forEach((selector) => {
                let element = document.querySelector(selector);
                if (!element)
                    return;

                element.addEventListener('blur', () => {
                    captureEmail(element.value);

                    if (type === 'checkout') {
                        postToConnectorAjaxRoute(element.value);
                    }
                });
            });
        };
    </script>
    <script>
    'use strict';

    (() => {
        window.addEventListener(
            'ga-initialized',
            () => {
                window.addEventListener('cart-item-added', (event) => {
                    let products = [];

                    event.detail.forEach((item) => {
                        products.push({
                            id: item['product_sku'],
                            name: item['product_name'],
                            price: item['product_price_value'],
                            quantity: item['qty'],
                        });
                    });

                    dataLayer.push({
                        event: 'addToCart',
                        ecommerce: {
                            currencyCode: 'USD',
                            add: {
                                products: products,
                            },
                        },
                    });
                });
            },
            { once: true }
        );
    })();
</script>
<script>
    'use strict';

    (() => {
        window.addEventListener(
            'ga-initialized',
            () => {
                window.addEventListener('cart-item-removed', (event) => {
                    let products = [];

                    event.detail.forEach((item) => {
                        products.push({
                            id: item['product_sku'],
                            name: item['product_name'],
                            price: item['product_price_value'],
                            quantity: item['qty'],
                        });
                    });

                    dataLayer.push({
                        event: 'removeFromCart',
                        ecommerce: {
                            currencyCode: 'USD',
                            remove: {
                                products: products,
                            },
                        },
                    });
                });
            },
            { once: true }
        );
    })();
</script>
<script>
    'use strict';

    (() => {
        window.addEventListener(
            'ga-initialized',
            () => {
                const banners = document.querySelectorAll('\u005Bdata\u002Dbanner\u002Did\u005D');
                let promotions = [];

                banners.forEach((banner) => {
                    banner.addEventListener('click', () => {
                        window.dataLayer.push({
                            event: 'promotionClick',
                            ecommerce: {
                                promoClick: {
                                    promotions: [{
                                        id: banner.dataset.bannerId,
                                        name: banner.dataset.bannerName,
                                        creative: '',
                                        position: 'cms_page_view',
                                    }],
                                },
                            },
                        });
                    });

                    promotions.push({
                        id: banner.dataset.bannerId,
                        name: banner.dataset.bannerName,
                        creative: '',
                        position: 'cms_page_view',
                    });
                });

                if (promotions.length) {
                    window.dataLayer.push({
                        event: 'promotionView',
                        ecommerce: {
                            promoView: {
                                promotions: promotions,
                            },
                        },
                    });
                }
            },
            { once: true }
        );
    })();
</script>
<script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    function yireoGoogleTagManager2Pusher(eventData, message, callback) {
        window.YIREO_GOOGLETAGMANAGER2_PAST_EVENTS = window.YIREO_GOOGLETAGMANAGER2_PAST_EVENTS || [];

        function doCallback(cb) {
            if (undefined === cb) {
                return;
            }

            cb();
        }


        const copyEventData = Object.assign({}, eventData);
        let metaData = {};
        if (copyEventData.meta) {
            metaData = copyEventData.meta;
            delete copyEventData.meta;
        }

        const eventHash = btoa(encodeURIComponent(JSON.stringify(copyEventData)));
        if (window.YIREO_GOOGLETAGMANAGER2_PAST_EVENTS.includes(eventHash)) {
            yireoGoogleTagManager2Logger('Warning: Event already triggered', eventData);
            doCallback(callback);
            return;
        }

        if (metaData && metaData.allowed_pages && metaData.allowed_pages.length > 0
            && false === metaData.allowed_pages.some(page => window.location.pathname.includes(page))) {
            yireoGoogleTagManager2Logger('Warning: Skipping event, not in allowed pages', window.location.pathname, eventData);
            doCallback(callback);
            return;
        }

        if (metaData && metaData.allowed_events && metaData.allowed_events.length > 0) {
            for (const [allowedEventKey, allowedEvent] of Object.entries(metaData.allowed_events)) {
                window.addEventListener(allowedEvent, function () {
                    const eventDataCopy = Object.assign({}, eventData);
                    eventDataCopy.meta.allowed_events = false;
                    yireoGoogleTagManager2Pusher(eventDataCopy, 'push (allowed event "' + eventData.event + '") [script-pusher]');
                });
            }

            yireoGoogleTagManager2Logger('Warning: Skipping event, not in allowed events', window.location.pathname, eventData);
            doCallback(callback);
            return;
        }

        if (!message) {
            message = 'push (unknown) [unknown]';
        }

        yireoGoogleTagManager2Logger(message, eventData);
        window.dataLayer = window.dataLayer || [];

        if (eventData.ecommerce) {
            window.dataLayer.push({ecommerce: null});
        }

        try {
            window.dataLayer.push(eventData);
            window.YIREO_GOOGLETAGMANAGER2_PAST_EVENTS.push(eventHash);
        } catch(error) {
            doCallback(callback);
        }

        doCallback(callback);
    }
</script>
<script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    function yireoGoogleTagManager2Logger(...args) {
        const debug = window.YIREO_GOOGLETAGMANAGER2_DEBUG || false;
        if (false === debug) {
            return;
        }

        var color = 'gray';
        if (args[0].toLowerCase().startsWith('push')) {
            color = 'green';
        }

        if (args[0].toLowerCase().startsWith('warning')) {
            color = 'orange';
        }

        var css = 'color:white; background-color:' + color + '; padding:1px;'
        console.log('%cYireo_GoogleTagManager2', css, ...args);
    }
</script>
<div class="widget block block-banners" data-banner-id="871d555d25e390f6163ceae9077755bb84ca1b0756d632d0b555407eea259825" data-types="" data-display-mode="fixed" data-ids="20" data-rotate="random" data-store-id="2" data-banner-name="top-promo-america-250" data-banner-status="Enabled"></div>
<div class="page-wrapper min-h-screen flex flex-col"><header id="header-container" class="page-header top-0 z-50"><a class="action skip sr-only focus:not-sr-only focus:absolute focus:z-40 focus:bg-white
   contentarea"
   href="#contentarea">
    <span>
        Skip to Content    </span>
</a>
<script>
    function initHeader () {
        return {
            searchOpen: false,
            cart: {},
            isCartOpen: false,
            isMobile: true,
            init() {
                const matchMedia = window.matchMedia("(max-width: 1023px)");
                this.onChangeMedia(matchMedia);

                if(typeof matchMedia.onchange !== 'object') {
                    //prevent an old iOS Safari bug where addEventListener does not accept an event type parameter
                    matchMedia.addListener((event) => this.onChangeMedia(event));
                } else {
                    matchMedia.addEventListener(
                        "change",
                        (event) => this.onChangeMedia(event)
                    )
                }
            },
            getData(data) {
                if (data.cart) { this.cart = data.cart }
            },
            isCartEmpty() {
                return !this.cart.summary_count
            },
            toggleCart(event) {
                if (event.detail && event.detail.isOpen !== undefined) {
                    this.isCartOpen = event.detail.isOpen
                    if (!this.isCartOpen && this.$refs && this.$refs.cartButton) {
                        this.$refs.cartButton.focus()
                    }
                } else {
                                        this.isCartOpen = true
                }
            },
            onChangeMedia(mediaQuery) {
                if(this.isMobile !== mediaQuery.matches && this.$refs.searchContainerMobile){
                    this.isMobile = mediaQuery.matches;
                    if(this.isMobile){
                        this.$refs.searchContainerMobile.appendChild(this.$refs.searchForm);
                    }else{
                        this.$refs.searchContainerDesktop.appendChild(this.$refs.searchForm);
                    }
                }
            }
        }
    }
    function initCompareHeader() {
        return {
            compareProducts: null,
            itemCount: 0,
            receiveCompareData(data) {
                if (data['compare-products']) {
                    this.compareProducts = data['compare-products'];
                    this.itemCount = this.compareProducts.count;
                }
            }
        }
    }
</script>
<div id="header"
     class="relative z-30 shadow-md w-full bg-white pb-6 lg:pb-0"
     x-data="initHeader()"
     @private-content-loaded.window="getData(event.detail.data)"
>
    
    <div class="bg-white relative py-3">
        <div class="container flex gap-6 justify-between items-center">

            <nav
    x-data="initMenuMobile_6a2810c732c95()"
    @load.window="setActiveMenu($root)"
    @keydown.window.escape="closeMenu()"
    class="z-30 navigation lg:hidden w-1/5"
    aria-label="Site&#x20;navigation"
    role="navigation"
>
    <!-- mobile -->
    <button
        x-ref="mobileMenuTrigger"
        @click="openMenu()"
        class="block text-headerFooter"
        :class="{ 'overflow-x-hidden overflow-y-auto fixed top-0 left-0 w-full': open }"
        type="button"
        aria-label="Open&#x20;menu"
        aria-haspopup="menu"
        :aria-expanded="open"
        :hidden="open"
    >
        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="40" height="40" :class="{ 'hidden' : open, 'block': !open }" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16"/>
</svg>
    </button>
    <div
        x-ref="mobileMenuNavLinks"
        class="
            fixed top-0 right-0 w-full h-full p-1 hidden
            flex-col border-t border-container bg-white
            overflow-y-auto overflow-x-hidden text-headerFooter
        "
        :class="{ 'flex': open, 'hidden': !open }"
        :aria-hidden="open ? 'false' : 'true'"
        role="dialog"
        aria-modal="true"
    >
        <ul
            class="border-t border-container flex flex-col gap-y-1 mt-16"
            aria-label="Site&#x20;navigation&#x20;links"
        >
            <template x-for="(menuItem, index) in currentSelectedMenuItem" :key="index">
                <li :data-child-id="index + '-main'"
                    class="level-0 border-b border-container">
                    <div class="flex items-center transition-transform duration-150 ease-in-out transform"
                         :class="{
                            '-translate-x-full' : mobilePanelActiveId,
                            'translate-x-0' : !mobilePanelActiveId
                        }"
                    >
                        <template x-if="index === 'currentMenuItemClone'">
                            <button
                                type="button"
                                class="flex items-center pl-8 py-4 cursor-pointer bg-container w-14"
                                @click="backToPreviousCategory()"
                                aria-label="Back&#x20;to&#x20;previous&#x20;category"
                            >
                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="24" height="24" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"/>
</svg>
                            </button>
                        </template>
                        <a class="flex items-center w-full px-8 py-4 cursor-pointer
                                 border-container level-0"
                           :class="{
                               'pl-4 bg-container': index === 'currentMenuItemClone',
                               'ml-10': index !== 'currentMenuItemClone',
                               'underline': index === 'viewAllMenuItem'
                           }"
                           :href="menuItem.url"
                           :title="menuItem.name"
                           x-text="menuItem.name">
                        </a>
                        <template x-if="Object.entries(menuItem.childData).length">
                            <button
                                @click="openSubcategory(index)"
                                class="absolute right-0 flex items-center justify-center w-11 h-11 mr-8 cursor-pointer"
                                :aria-label="hyva.str('Open %1 subcategories', menuItem.name)"
                                aria-haspopup="true"
                                :aria-expanded="mobilePanelActiveId === index">
                                <div class="w-8 h-8 border rounded border-container">
                                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-full h-full p-1" width="24" height="24" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"/>
</svg>
                                </div>
                            </button>
                        </template>
                    </div>
                </li>
            </template>
        </ul>
        <button
            @click="closeMenu()"
            class="absolute flex justify-end w-16 self-end mb-1"
            aria-label="Close&#x20;menu"
            type="button"
        >
            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="hidden p-4" width="64" height="64" :class="{ 'hidden' : !open, 'block': open }" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
</svg>
        </button>
    </div>
</nav>
<script>
    'use strict';

    const initMenuMobile_6a2810c732c95 = () => {
        return {
            mobilePanelActiveId: null,
            open: false,
            currentSelectedMenuItem: null,
            fullMenuList: null,
            visitedMenuLevels: [],
            init() {
                this.fullMenuList = JSON.parse('\u007B\u0022category\u002Dnode\u002D139\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Apologetics\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D139\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u0022,\u0022childData\u0022\u003A\u007B\u0022category\u002Dnode\u002D145\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Astronomy\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D145\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fastronomy\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F145\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D146\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Biology\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D146\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fbiology\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F146\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D147\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Chemistry\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D147\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fchemistry\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F147\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D148\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Dinosaurs\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D148\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fdinosaurs\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F148\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D149\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Evolution\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D149\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fevolution\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F149\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D150\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Geology\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D150\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fgeology\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F150\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D151\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Noah\u0027s\u0020Ark\u005C\u002FFlood\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D151\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fnoah\u002Ds\u002Dark\u002Dflood\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F151\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D152\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Physics\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D152\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fphysics\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F152\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D183\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Reference\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D183\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Freference\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F183\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D141\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Theology\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D141\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Ftheology\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F141\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D153\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Young\u0020Earth\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D153\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fapologetics\u005C\u002Fyoung\u002Dearth\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F139\u005C\u002F153\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D\u007D\u007D,\u0022category\u002Dnode\u002D275\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Books\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D275\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u0022,\u0022childData\u0022\u003A\u007B\u0022category\u002Dnode\u002D70\u0022\u003A\u007B\u0022name\u0022\u003A\u0022New\u0020Releases\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D70\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fnew\u002Dreleases\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F70\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D276\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Activity\u0020Books\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D276\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Factivity\u002Dbooks\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F276\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D277\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Audiobooks\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D277\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Faudiobooks\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F277\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D278\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Bibles\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D278\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fbibles\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F278\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D280\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Christian\u0020Living\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D280\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fchristian\u002Dliving\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F280\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D281\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Devotionals\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D281\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fdevotionals\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F281\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D289\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Digital\u0020Books\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D289\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fdigital\u002Dbooks\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F289\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D282\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Fiction\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D282\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Ffiction\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F282\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D283\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Morning\u0020Baskets\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D283\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fmorning\u002Dbaskets\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F283\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D258\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Parenting\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D258\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fparenting\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F258\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D287\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Readers\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D287\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Freaders\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F287\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D284\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Timelines\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D284\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Ftimelines\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F284\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D279\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Bundle\u0020\u0026\u0020Save\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D279\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fbooks\u005C\u002Fbundle\u002Dand\u002Dsave\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F275\u005C\u002F279\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D\u007D\u007D,\u0022category\u002Dnode\u002D143\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Homeschool\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D143\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u0022,\u0022childData\u0022\u003A\u007B\u0022category\u002Dnode\u002D157\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Grade\u0020Level\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D157\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fgrade\u002Dlevel\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F157\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D158\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Subject\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D158\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fsubject\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F158\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D288\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Practice\u0020Workbooks\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D288\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fpractice\u002Dworkbooks\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F288\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D270\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Printables\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D270\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fprintables\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F270\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D260\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Master\u0020Books\u0020Academy\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D260\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fmaster\u002Dbooks\u002Dacademy\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F260\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D259\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Master\u0020Books\u0020Merch\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D259\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Fmasterbooksmerch\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F259\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D290\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Homeschool\u0020Reset\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D290\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fhomeschool\u002Dcurriculum\u005C\u002Freset\u002Dhomeschool\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F143\u005C\u002F290\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D\u007D\u007D,\u0022category\u002Dnode\u002D179\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Kids\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D179\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u0022,\u0022childData\u0022\u003A\u007B\u0022category\u002Dnode\u002D263\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u00203\u002D5\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D263\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D3\u002D5\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F263\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D264\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u00205\u002D7\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D264\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D5\u002D7\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F264\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D265\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u00208\u002D10\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D265\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D8\u002D10\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F265\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D266\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u002011\u002D13\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D266\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D11\u002D13\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F266\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D267\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u002014\u002D16\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D267\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D14\u002D16\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F267\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D,\u0022category\u002Dnode\u002D268\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Ages\u002017\u002D18\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D268\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fkids\u005C\u002Fages\u002D17\u002D18\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F179\u005C\u002F268\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D\u007D\u007D,\u0022category\u002Dnode\u002D71\u0022\u003A\u007B\u0022name\u0022\u003A\u0022Clearance\u0022,\u0022id\u0022\u003A\u0022category\u002Dnode\u002D71\u0022,\u0022url\u0022\u003A\u0022https\u003A\u005C\u002F\u005C\u002Fwww.masterbooks.com\u005C\u002Fspecials\u0022,\u0022image\u0022\u003Afalse,\u0022has_active\u0022\u003Afalse,\u0022is_active\u0022\u003Afalse,\u0022is_category\u0022\u003Atrue,\u0022is_parent_active\u0022\u003Atrue,\u0022position\u0022\u003Anull,\u0022path\u0022\u003A\u00221\u005C\u002F64\u005C\u002F71\u0022,\u0022childData\u0022\u003A\u005B\u005D\u007D\u007D');
                this.fullMenuList['communitynode'] = {
                        childData:{
                            support: {
                                childData: {},
                                has_active:false,
                                id:"support",
                                image:false,
                                is_active:true,
                                is_category:false,
                                is_parent_active:true,
                                name:"Support",
                                path:null,
                                position:null,
                                url: "/contact"
                            },
                            blog: {
                                childData: {},
                                has_active:false,
                                id:"blog",
                                image:false,
                                is_active:true,
                                is_category:false,
                                is_parent_active:true,
                                name:"Blog",
                                path:null,
                                position:null,
                                url: "/blog"
                            },
                            app: {
                                childData: {},
                                has_active:false,
                                id:"app",
                                image:false,
                                is_active:true,
                                is_category:false,
                                is_parent_active:true,
                                name:"App",
                                path:null,
                                position:null,
                                url: "/master-books-app"
                            },
                            events: {
                                childData: {},
                                has_active:false,
                                id:"events",
                                image:false,
                                is_active:true,
                                is_category:false,
                                is_parent_active:true,
                                name:"Events",
                                path:null,
                                position:null,
                                url: "/homeschooling-conferences"
                            },
                            faq: {
                                childData: {},
                                has_active:false,
                                id:"faq",
                                image:false,
                                is_active:true,
                                is_category:false,
                                is_parent_active:true,
                                name:"FAQ",
                                path:null,
                                position:null,
                                url: "/knowledge-base"
                            }
                        },
                        has_active:false,
                        id:"connect",
                        image:false,
                        is_active:true,
                        is_category:false,
                        is_parent_active:true,
                        name:"Connect",
                        path:null,
                        position:null,
                        url: "/contact"
                };
                this.currentSelectedMenuItem = this.fullMenuList;
            },
            setActiveMenu(menuNode) {
                Array.from(menuNode.querySelectorAll('a')).filter(link => {
                    return link.href === window.location.href.split('?')[0];
                }).map(item => {
                    item.classList.add('underline');
                    item.closest('li.level-0') &&
                    item.closest('li.level-0').querySelector('a.level-0').classList.add('underline');
                });
            },
            openMenu() {
                const formWrapper = document.querySelector('#form-wrapper');
                formWrapper.style.zIndex = '0';
                this.open = true
                this.$nextTick(() => hyva.trapFocus(this.$refs['mobileMenuNavLinks']));
                // Prevent from body scrolling while mobile menu opened
                document.body.style.position = 'fixed';
            },
            closeMenu() {
                const formWrapper = document.querySelector('#form-wrapper');
                formWrapper.style.zIndex = '20';
                document.body.style.position = '';

                if (this.open) {
                    this.$nextTick(() => this.$refs['mobileMenuTrigger'].focus() || hyva.releaseFocus());
                }

                this.open = false
                this.mobilePanelActiveId = null
            },
            openSubcategory(index) {
                if (!this.visitedMenuLevels.length) {
                    this.visitedMenuLevels.push('main');
                    this.visitedMenuLevels.push(index);
                } else {
                    this.visitedMenuLevels.push(index);
                }
                this.currentSelectedMenuItem = this.getCurrentMenuList(index);
            },
            getCurrentMenuList(index) {
                let selectedMenuItem = this.findNestedValueByKeyName(this.fullMenuList, index),
                    currentMenuItemClone,
                    viewAllMenuItem;
                currentMenuItemClone = Object.assign({}, selectedMenuItem);
                currentMenuItemClone.currentCategory = true;
                currentMenuItemClone.childData = {};
                viewAllMenuItem = Object.assign({}, currentMenuItemClone);
                viewAllMenuItem.name = 'View All';
                if (selectedMenuItem.is_category) {
                    return {currentMenuItemClone, viewAllMenuItem, ...selectedMenuItem.childData};
                } else {
                    return {currentMenuItemClone, ...selectedMenuItem.childData};
                }
            },
            findNestedValueByKeyName(obj, key) {
                let result = null;

                function searchNested(currentObj) {
                    _.forEach(currentObj, function(value, currentKey) {
                        if (currentKey === key) {
                            result = value;
                        } else if (_.isObject(value)) {
                            searchNested(value);
                        }
                    });
                }

                searchNested(obj);
                return result;
            },
            backToPreviousCategory() {
                this.visitedMenuLevels.pop();
                const previousMenuLevel = this.visitedMenuLevels.at(-1);
                if (previousMenuLevel === 'main') {
                    this.currentSelectedMenuItem = this.fullMenuList;
                } else {
                    this.currentSelectedMenuItem = this.getCurrentMenuList(previousMenuLevel);
                }
            }
        }
    }
</script>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        const header = document.getElementById('header-container');
        header.setAttribute('x-data', 'initStickyHeader()')
        header.setAttribute('x-on:scroll.window.throttle.debounce.passive', `handleMobileStickyHeader()`);
        header.setAttribute(':class', `{'w-full sticky': true}`);
        header.style.transition = 'top .3s ease-in-out';
    });

    function initStickyHeader() {
        return {
            header: document.getElementById('header-container'),
            lastScrollTop: window.scrollY || document.documentElement.scrollTop,
            handleMobileStickyHeader() {
                const st = window.scrollY || document.documentElement.scrollTop;
                if (st < this.lastScrollTop) {
                    this.header.style.top = '0';
                } else if (window.scrollY > 2 * this.header.offsetHeight) {
                    this.header.style.top = '-' + this.header.offsetHeight + 'px';
                }
                this.lastScrollTop = (st <= 0 ? 0 : st);
            }
        }
    }
</script>

            <!--Logo-->
            <div class="flex-1 lg:ml-0 lg:flex-none lg:flex lg:justify-center">
                <a
    class="flex justify-center items-center text-xl font-medium tracking-wide text-gray-800 no-underline hover:no-underline font-title"
    href="https://www.masterbooks.com/"
    aria-label="Go&#x20;to&#x20;Home&#x20;page"
>
    <img
        src="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/images/logo-mb@2x.png"
        alt="Master&#x20;Books&#x20;Christian&#x20;Homeschool&#x20;Curriculum"
        width="189"        height="64"    />
    </a>
            </div>

            <!--Search desktop-->
            <div x-ref="searchContainerDesktop" class="hidden lg:block lg:flex-1">
            </div>

            <div class="flex md:gap-4 items-center justify-end w-1/5 lg:w-auto">

                <!--Compare Icon
                <a id="compare-link"
                   class="relative invisible hidden lg:inline-block no-underline outline-hidden hover:text-black focus:ring-blue-700 focus:ring-1"
                   :class="{ 'invisible': !(itemCount > 0) }"
                   href="https://www.masterbooks.com/catalog/product_compare/index/"
                   title="Compare Products"
                   x-data="initCompareHeader()"
                   @private-content-loaded.window="receiveCompareData($event.detail.data)"

                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="text-slate-800 hover:text-black" width="24" height="24" role="img">
  <path stroke-linecap="round" stroke-linejoin="round" d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"/>
<title>scale</title></svg>

                    <span class="sr-only label">
                        Compare Products                    </span>

                    <span class="absolute top-0 right-0 px-3 py-1 -mt-5 -mr-4 text-xs font-semibold
                        leading-none text-center text-gray-700 uppercase transform
                        translate-y-1/2 rounded-full bg-green-200"
                    >
                        <span x-text="itemCount"></span>
                        <span x-show="itemCount === 1" class="sr-only">
                            item                        </span>
                        <span x-show="itemCount > 1" class="sr-only">
                            items                        </span>
                    </span>
                </a>
                -->
                
                <!--Customer Icon & Dropdown-->
                <!-- BLOCK header.customer -->
<div class="relative inline-block ml-1 sm:ml-3"
     x-data="{ open: false }"
     @keyup.escape="open = false"
>
    <button
        type="button"
        id="customer-menu"
        class="block hover:text-black text-gray-800"
        @click="open = !open"
        @click.outside="open = false"
        :aria-expanded="open ? 'true' : 'false'"
        aria-label="My&#x20;Account"
        aria-haspopup="true"
    >
        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="md:h-6 md:w-6 text-headerFooter" width="24" height="24" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
</svg>
    </button>
    <nav
        class="text-gray-800 absolute right-0 z-30 w-40 py-2 mt-2 -mr-4 px-1 overflow-auto origin-top-right rounded-xs
            shadow-lg sm:w-48 lg:mt-3 bg-container-lighter text-base"
        x-cloak
        x-show="open"
        aria-labelledby="customer-menu"
        @click.outside="open = false"
    >
                    
<a id="customer.header.sign.in.link"
   class="block px-4 py-2 lg:px-5 lg:py-2 hover:underline"
   onclick="hyva.setCookie && hyva.setCookie(
       'login_redirect',
       window.location.href,
       1
       )"
   href="https://www.masterbooks.com/customer/account/index/"
   title="Sign&#x20;In"
>
    Sign In</a>

    <a id="customer.header.register.link"
       class="block px-4 py-2 lg:px-5 lg:py-2 hover:underline"
       onclick="hyva.setCookie && hyva.setCookie(
           'login_redirect',
           window.location.href,
           1
           )"
       href="https://www.masterbooks.com/customer/account/create/"
       title="Create&#x20;an&#x20;Account"
    >
        Create an Account    </a>
            </nav>
</div>
<!-- /BLOCK header.customer -->
                <!--Cart Icon-->
                                    <button
                                    id="menu-cart-icon"
                    class="text-gray-800 relative outline-hidden focus:ring-blue-700 ml-2"
                    x-ref="cartButton"
                    :aria-disabled="isCartEmpty()"
                    title="Cart"
                                            @click.prevent.stop="() => {
                            isCartOpen = !isCartOpen;
                            $dispatch('toggle-cart', { isOpen: isCartOpen })
                        }"
                        @toggle-cart.window="toggleCart($event)"
                        :aria-expanded="isCartOpen"
                        aria-haspopup="dialog"
                                    >
                    <span
                        class="sr-only label"
                        x-text="`
                            Toggle minicart,
                            ${isCartEmpty() ?
                            'Cart is empty' :
                            hyva.str(
                                'You have %1 product%2 in your cart.',
                                cart.summary_count,
                                cart.summary_count === 1 ? '' : 's'
                            )}`
                        "
                    >
                    </span>

                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="md:h-6 md:w-6 text-headerFooter hover:text-black" width="24" height="24" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg>

                    <span
                        x-text="cart.summary_count"
                        x-show="!isCartEmpty()"
                        x-cloak
                        class="
                            absolute top-1 right-2.5 py-1 -mt-5 -mr-4 text-[10px] font-semibold
                            leading-[11px] text-center uppercase transform w-[18px] h-[18px]
                            translate-y-1/2 rounded-full bg-primary-darker text-white
                        "
                        aria-hidden="true"
                    ></span>
                                            </button>
                                </div>
        </div>
    </div>

    <div class="bg-white">
        <div class="container">
            <div x-data="initMenuDesktop_6a2810c73e930()"
     class="z-20 order-2 sm:order-1 lg:order-2 navigation hidden lg:flex justify-center header-nav"
>
    <!-- desktop -->
    <div x-ref="nav-desktop"
         @load.window="setActiveMenu($root)"
         class="hidden lg:block lg:relative lg:min-h-0 lg:w-auto lg:pt-0">
        <nav
            class="duration-150 ease-in-out transform w-auto relative min-h-0 transition-display"
            aria-label="Main&#x20;menu"
        >
            <ul class="flex justify-start">
                                    <li class="relative mr-8 "
                        @mouseenter="hoverPanelActiveId = 'category-node-139'"
                        @mouseleave="hoverPanelActiveId = 0"
                        @keyup.escape="hoverPanelActiveId = 0"
                    >
                        <span class="flex items-center gap-1 text-md group">
                            <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-primary level-0 font-semibold uppercase"
                               href="https://www.masterbooks.com/apologetics"
                               title="Apologetics"
                               @focus="hoverPanelActiveId = 0"
                            >
                                Apologetics                            </a>
                                                            <button
                                    type="button"
                                    data-sr-button-id="category-node-139"
                                    :aria-expanded="hoverPanelActiveId === 'category-node-139' ? 'true' : 'false'"
                                    @click="openMenuOnClick('category-node-139')"
                                    @touchend.prevent="openMenuOnClick('category-node-139')"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex self-center h-5 w-5 group-hover:text-highlighted text-primary" width="25" height="25" aria-hidden="true">
  <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
                                    <span class="sr-only">
                                        Show submenu for Apologetics category                                    </span>
                                </button>
                                                    </span>
                                                    <ul
                                class="absolute z-10 hidden py-4 -ml-6 shadow-lg bg-white"
                                :class="{
                                    'hidden' : hoverPanelActiveId !== 'category-node-139',
                                    'block' : hoverPanelActiveId === 'category-node-139'
                                }"
                            >
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-145'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/astronomy"
                                           title="Astronomy"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Astronomy                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-146'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/biology"
                                           title="Biology"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Biology                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-147'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/chemistry"
                                           title="Chemistry"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Chemistry                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-148'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/dinosaurs"
                                           title="Dinosaurs"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Dinosaurs                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-149'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/evolution"
                                           title="Evolution"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Evolution                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-150'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/geology"
                                           title="Geology"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Geology                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-151'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/noah-s-ark-flood"
                                           title="Noah&#x27;s&#x20;Ark&#x2F;Flood"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Noah&#039;s Ark/Flood                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-152'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/physics"
                                           title="Physics"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Physics                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-183'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/reference"
                                           title="Reference"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Reference                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-141'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/theology"
                                           title="Theology"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Theology                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-153'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/apologetics/young-earth"
                                           title="Young&#x20;Earth"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D139]').focus())"
                                        >
                                            <span class="text-base">
                                                Young Earth                                            </span>
                                        </a>
                                                                            </li>
                                                            </ul>
                                            </li>
                                    <li class="relative mr-8 "
                        @mouseenter="hoverPanelActiveId = 'category-node-275'"
                        @mouseleave="hoverPanelActiveId = 0"
                        @keyup.escape="hoverPanelActiveId = 0"
                    >
                        <span class="flex items-center gap-1 text-md group">
                            <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-primary level-0 font-semibold uppercase"
                               href="https://www.masterbooks.com/books"
                               title="Books"
                               @focus="hoverPanelActiveId = 0"
                            >
                                Books                            </a>
                                                            <button
                                    type="button"
                                    data-sr-button-id="category-node-275"
                                    :aria-expanded="hoverPanelActiveId === 'category-node-275' ? 'true' : 'false'"
                                    @click="openMenuOnClick('category-node-275')"
                                    @touchend.prevent="openMenuOnClick('category-node-275')"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex self-center h-5 w-5 group-hover:text-highlighted text-primary" width="25" height="25" aria-hidden="true">
  <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
                                    <span class="sr-only">
                                        Show submenu for Books category                                    </span>
                                </button>
                                                    </span>
                                                    <ul
                                class="absolute z-10 hidden py-4 -ml-6 shadow-lg bg-white"
                                :class="{
                                    'hidden' : hoverPanelActiveId !== 'category-node-275',
                                    'block' : hoverPanelActiveId === 'category-node-275'
                                }"
                            >
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-70'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/new-releases"
                                           title="New&#x20;Releases"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                New Releases                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-276'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/activity-books"
                                           title="Activity&#x20;Books"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Activity Books                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-277'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/audiobooks"
                                           title="Audiobooks"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Audiobooks                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-278'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/bibles"
                                           title="Bibles"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Bibles                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-280'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/christian-living"
                                           title="Christian&#x20;Living"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Christian Living                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-281'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/devotionals"
                                           title="Devotionals"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Devotionals                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-289'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/digital-books"
                                           title="Digital&#x20;Books"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Digital Books                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-282'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/fiction"
                                           title="Fiction"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Fiction                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-283'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/morning-baskets"
                                           title="Morning&#x20;Baskets"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Morning Baskets                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-258'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/parenting"
                                           title="Parenting"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Parenting                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-287'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/readers"
                                           title="Readers"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Readers                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-284'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/timelines"
                                           title="Timelines"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Timelines                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-279'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/books/bundle-and-save"
                                           title="Bundle&#x20;&amp;&#x20;Save"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D275]').focus())"
                                        >
                                            <span class="text-base">
                                                Bundle &amp; Save                                            </span>
                                        </a>
                                                                            </li>
                                                            </ul>
                                            </li>
                                    <li class="relative mr-8 "
                        @mouseenter="hoverPanelActiveId = 'category-node-143'"
                        @mouseleave="hoverPanelActiveId = 0"
                        @keyup.escape="hoverPanelActiveId = 0"
                    >
                        <span class="flex items-center gap-1 text-md group">
                            <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-primary level-0 font-semibold uppercase"
                               href="https://www.masterbooks.com/homeschool-curriculum"
                               title="Homeschool"
                               @focus="hoverPanelActiveId = 0"
                            >
                                Homeschool                            </a>
                                                            <button
                                    type="button"
                                    data-sr-button-id="category-node-143"
                                    :aria-expanded="hoverPanelActiveId === 'category-node-143' ? 'true' : 'false'"
                                    @click="openMenuOnClick('category-node-143')"
                                    @touchend.prevent="openMenuOnClick('category-node-143')"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex self-center h-5 w-5 group-hover:text-highlighted text-primary" width="25" height="25" aria-hidden="true">
  <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
                                    <span class="sr-only">
                                        Show submenu for Homeschool category                                    </span>
                                </button>
                                                    </span>
                                                    <ul
                                class="absolute z-10 hidden py-4 -ml-6 shadow-lg bg-white"
                                :class="{
                                    'hidden' : hoverPanelActiveId !== 'category-node-143',
                                    'block' : hoverPanelActiveId === 'category-node-143'
                                }"
                            >
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-157'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/grade-level"
                                           title="Grade&#x20;Level"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Grade Level                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-158'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/subject"
                                           title="Subject"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Subject                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-288'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/practice-workbooks"
                                           title="Practice&#x20;Workbooks"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Practice Workbooks                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-270'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/printables"
                                           title="Printables"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Printables                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-260'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/master-books-academy"
                                           title="Master&#x20;Books&#x20;Academy"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Master Books Academy                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-259'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/masterbooksmerch"
                                           title="Master&#x20;Books&#x20;Merch"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Master Books Merch                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-290'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/homeschool-curriculum/reset-homeschool"
                                           title="Homeschool&#x20;Reset"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D143]').focus())"
                                        >
                                            <span class="text-base">
                                                Homeschool Reset                                            </span>
                                        </a>
                                                                            </li>
                                                            </ul>
                                            </li>
                                    <li class="relative mr-8 "
                        @mouseenter="hoverPanelActiveId = 'category-node-179'"
                        @mouseleave="hoverPanelActiveId = 0"
                        @keyup.escape="hoverPanelActiveId = 0"
                    >
                        <span class="flex items-center gap-1 text-md group">
                            <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-primary level-0 font-semibold uppercase"
                               href="https://www.masterbooks.com/kids"
                               title="Kids"
                               @focus="hoverPanelActiveId = 0"
                            >
                                Kids                            </a>
                                                            <button
                                    type="button"
                                    data-sr-button-id="category-node-179"
                                    :aria-expanded="hoverPanelActiveId === 'category-node-179' ? 'true' : 'false'"
                                    @click="openMenuOnClick('category-node-179')"
                                    @touchend.prevent="openMenuOnClick('category-node-179')"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex self-center h-5 w-5 group-hover:text-highlighted text-primary" width="25" height="25" aria-hidden="true">
  <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
                                    <span class="sr-only">
                                        Show submenu for Kids category                                    </span>
                                </button>
                                                    </span>
                                                    <ul
                                class="absolute z-10 hidden py-4 -ml-6 shadow-lg bg-white"
                                :class="{
                                    'hidden' : hoverPanelActiveId !== 'category-node-179',
                                    'block' : hoverPanelActiveId === 'category-node-179'
                                }"
                            >
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-263'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-3-5"
                                           title="Ages&#x20;3-5"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 3-5                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-264'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-5-7"
                                           title="Ages&#x20;5-7"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 5-7                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-265'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-8-10"
                                           title="Ages&#x20;8-10"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 8-10                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-266'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-11-13"
                                           title="Ages&#x20;11-13"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 11-13                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-267'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-14-16"
                                           title="Ages&#x20;14-16"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 14-16                                            </span>
                                        </a>
                                                                            </li>
                                                                    <li class="relative flex flex-row my-1 group"
                                        @mouseenter="hoverSubPanelActiveId = 'category-node-268'"
                                        @mouseleave="hoverSubPanelActiveId = 0"
                                        @keyup.escape="hoverSubPanelActiveId = 0"
                                    >
                                        <a href="https://www.masterbooks.com/kids/ages-17-18"
                                           title="Ages&#x20;17-18"
                                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                                           @keyup.escape="$nextTick(() => document.querySelector('[data-sr-button-id=category\u002Dnode\u002D179]').focus())"
                                        >
                                            <span class="text-base">
                                                Ages 17-18                                            </span>
                                        </a>
                                                                            </li>
                                                            </ul>
                                            </li>
                                    <li class="relative mr-8 "
                        @mouseenter="hoverPanelActiveId = 'category-node-71'"
                        @mouseleave="hoverPanelActiveId = 0"
                        @keyup.escape="hoverPanelActiveId = 0"
                    >
                        <span class="flex items-center gap-1 text-md group">
                            <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-primary level-0 font-semibold uppercase"
                               href="https://www.masterbooks.com/specials"
                               title="Clearance"
                               @focus="hoverPanelActiveId = 0"
                            >
                                Clearance                            </a>
                                                    </span>
                                            </li>
                            </ul>
        </nav>
    </div>
    
<div class="hidden lg:block lg:relative lg:min-h-0 lg:w-auto lg:pt-0">
    <nav class="duration-150 ease-in-out transform w-auto relative min-h-0 transition-display">
        <ul class="flex justify-start">
            <li class="relative"
                @mouseenter="hoverPanelActiveId = 'community'"
                @mouseleave="hoverPanelActiveId = 0"
                @keyup.escape="hoverPanelActiveId = 0"
            >
                    <span class="flex items-center gap-1 text-md group">
                        <a class="w-full py-2.5 text-lg group-hover:text-highlighted text-gray-800 level-0 font-semibold uppercase"
                           href="/contact"
                           title="Connect"
                        >
                            Connect                        </a>
                            <button
                                type="button"
                                data-sr-button-id="community"
                                :aria-expanded="hoverPanelActiveId === 'community' ? 'true' : 'false'"
                                @click="openMenuOnClick('community')"
                                @touchend.prevent="openMenuOnClick('community')"
                            >
                                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="flex self-center h-5 w-5 group-hover:text-highlighted text-gray-800" width="25" height="25" aria-hidden="true">
  <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
                            </button>
                    </span>
                <ul
                    class="absolute z-10 w-full hidden py-4 right-0 shadow-lg bg-white"
                    :class="{
                                    'hidden' : hoverPanelActiveId !== 'community',
                                    'block' : hoverPanelActiveId === 'community'
                                }"
                >
                    <!--<li class="relative flex flex-row my-1 group">
                        <a href=""
                           title=""
                           class="block w-full px-6 py-1 whitespace-nowrap first:mt-0 group-hover:text-highlighted text-primary"
                        >
                            <span class="text-base">
                                                            </span>
                        </a>
                    </li>-->
                    <style>.cmsb245-relative {
position: relative
}
.cmsb245-my-1 {
margin-top: 0.25rem;
margin-bottom: 0.25rem
}
.cmsb245-block {
display: block
}
.cmsb245-flex {
display: flex
}
.cmsb245-w-full {
width: 100%
}
.cmsb245-flex-row {
flex-direction: row
}
.cmsb245-whitespace-nowrap {
white-space: nowrap
}
.cmsb245-px-6 {
padding-left: 1.5rem;
padding-right: 1.5rem
}
.cmsb245-py-1 {
padding-top: 0.25rem;
padding-bottom: 0.25rem
}
.cmsb245-text-base {
font-size: 1rem;
line-height: 1.5rem
}
.cmsb245-first\:mt-0:first-child {
margin-top: 0px
}</style>
<div data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><li class="cmsb245-relative cmsb245-flex cmsb245-flex-row cmsb245-my-1 group">
	<a href="/contact"
	   title="Support"
	   class="cmsb245-block cmsb245-w-full cmsb245-px-6 cmsb245-py-1 cmsb245-whitespace-nowrap cmsb245-first:mt-0 group-hover:text-highlighted text-primary"
	>
	<span class="cmsb245-text-base">Support</span>
	</a>
</li>
<li class="cmsb245-relative cmsb245-flex cmsb245-flex-row cmsb245-my-1 group">
	<a href="/blog"
	   title="Blog"
	   class="cmsb245-block cmsb245-w-full cmsb245-px-6 cmsb245-py-1 cmsb245-whitespace-nowrap cmsb245-first:mt-0 group-hover:text-highlighted text-primary"
	>
	<span class="cmsb245-text-base">Blog</span>
	</a>
</li>
<li class="cmsb245-relative cmsb245-flex cmsb245-flex-row cmsb245-my-1 group">
	<a href="/master-books-app"
	   title="App"
	   class="cmsb245-block cmsb245-w-full cmsb245-px-6 cmsb245-py-1 cmsb245-whitespace-nowrap cmsb245-first:mt-0 group-hover:text-highlighted text-primary"
	>
	<span class="cmsb245-text-base">App</span>
	</a>
</li>
<li class="cmsb245-relative cmsb245-flex cmsb245-flex-row cmsb245-my-1 group">
	<a href="/homeschooling-conferences"
	   title="Events"
	   class="cmsb245-block cmsb245-w-full cmsb245-px-6 cmsb245-py-1 cmsb245-whitespace-nowrap cmsb245-first:mt-0 group-hover:text-highlighted text-primary"
	>
	<span class="cmsb245-text-base">Events</span>
	</a>
</li>
<li class="cmsb245-relative cmsb245-flex cmsb245-flex-row cmsb245-my-1 group">
	<a href="/knowledge-base"
	   title="FAQ"
	   class="cmsb245-block cmsb245-w-full cmsb245-px-6 cmsb245-py-1 cmsb245-whitespace-nowrap cmsb245-first:mt-0 group-hover:text-highlighted text-primary"
	>
	<span class="cmsb245-text-base">FAQ</span>
	</a>
</li></div>                </ul>
            </li>
        </ul>
    </nav>
</div>
</div>
<script>
    'use strict';

    const initMenuDesktop_6a2810c73e930 = () => {
        return {
            hoverPanelActiveId: null,
            hoverSubPanelActiveId: null,
            setActiveMenu(menuNode) {
                Array.from(menuNode.querySelectorAll('a')).filter(link => {
                    return link.href === window.location.href.split('?')[0];
                }).map(item => {
                    item.classList.add('underline');
                    item.closest('div.level-0') &&
                    item.closest('div.level-0').querySelector('a.level-0').classList.add('underline');
                });
            },
            openMenuOnClick(menuNode) {
                if (menuNode === this.hoverPanelActiveId) {
                    this.hoverPanelActiveId = 0;
                } else {
                    this.hoverPanelActiveId = menuNode
                }
            },
            openSubMenuOnClick(subMenuNode) {
                if (subMenuNode === this.hoverSubPanelActiveId) {
                    this.hoverSubPanelActiveId = 0;
                } else {
                    this.hoverSubPanelActiveId = subMenuNode
                }
            }
        }
    }
</script>
        </div>
    </div>

    <!--Search mobile-->
    <div x-ref="searchContainerMobile" class="lg:hidden">
        <div x-ref="searchForm" class="container">
            
<script>
    'use strict';

    function amXsearchProductsComponent() {
        const postFormRequest = (postUrl, id) => {
            const req = fetch(BASE_URL + postUrl, {
                "headers": {
                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                },
                "body": "form_key=" + hyva.getFormKey() + "&product=" + id + "&uenc=" + hyva.getUenc(),
                "method": "POST",
                "mode": "cors",
                "credentials": "include"
            });

            req.finally(() => this.isLoading = false);

            return req;
        }

        return {
            mutationAddToCartQuery: "mutation addProductsToCart($cartId: String!, $cartItems: [CartItemInput!]!) {addProductsToCart(\n                cartId: $cartId,\n                cartItems: $cartItems\n                ) {\n                    cart {\n                        items {\n                            product {\n                                name\n                            }\n                        }\n                        total_quantity\n                    }\n                    user_errors {\n                        code\n                        message\n                    }\n                }}",
            mutationAddToWishlistQuery: "mutation addProductsToWishlist($wishlistId: ID!, $wishlistItems: [WishlistItemInput!]!) {addProductsToWishlist(\n                wishlistId: $wishlistId,\n                wishlistItems: $wishlistItems\n                ) {\n                    wishlist {\n                        items {\n                            id\n                            product {\n                                name\n                            }\n                        }\n                        items_count\n                    }\n                    user_errors {\n                        code\n                        message\n                    }\n                }}",
            mutationAddToCompareListQuery: "mutation addProductsToCompareList($uid: ID!, $products: [ID!]!) {addProductsToCompareList(input: {\n                uid: $uid,\n                products: $products\n            }) {\n                items {\n                    product {\n                        name\n                    }\n                }\n                item_count\n            }}",

            sliderInitialization(event) {
                this[event.detail.key] = event.detail.value;
            },

            getResultProductsCount() {
                const suggestions = this.sections.products;
                const totalCount = suggestions?.total_count ?? 0;
                const itemsCount = suggestions?.items?.length ?? 0;

                return totalCount > 0 ? totalCount - itemsCount : 0;
            },

            processProductName(value) {
                if (value.items) {
                    value.items = value.items.map(item => {
                        item.name = this.addHighlight(item, 'name');
                        item.sku = this.addHighlight(item, 'sku');
                        item.name = this.truncateWithDots(item.name, this.productNameMaxLength, true);

                        return item;
                    });
                }
                return value;
            },

            addHighlight(product, key = 'name') {
                const name = product[key];
                const { latestQuery } = this;
                const queries = latestQuery.toLowerCase().split(" ");

                let highlightedName = name;

                for (const query of queries) {
                    const regex = new RegExp(`(?!<[^>]*)(${query})(?![^<]*>)`, "gi");
                    highlightedName = highlightedName.replace(regex, match => `<span class="amsearch-highlight">${match}</span>`);
                }

                return highlightedName;
            },

            truncateWithDots(str, maxLength, returnOriginal = false) {
                if (maxLength === '' || maxLength < 1) {
                    return returnOriginal ? str : "";
                }

                let output = [];
                let tagBuffer = [];
                let count = 0;
                let inTag = false;

                for (const char of str) {
                    if (char === "<") {
                        inTag = true;
                    }

                    if (inTag) {
                        tagBuffer.push(char);
                    } else {
                        count++;
                    }

                    if (char === ">") {
                        inTag = false;
                        output.push(tagBuffer.join(""));
                        tagBuffer = [];
                    } else if (!inTag) {
                        output.push(char);
                    }

                    if (count >= maxLength) {
                        break;
                    }
                }

                if (count >= maxLength) {
                    output.push("...");
                }

                // Close any unclosed tags
                while (tagBuffer.length > 0) {
                    const closingTagPos = str.indexOf(">", str.indexOf(tagBuffer.join("")) + tagBuffer.length);
                    if (closingTagPos !== -1) {
                        output.push(str.slice(str.indexOf(tagBuffer.join("")) + tagBuffer.length, closingTagPos + 1));
                        tagBuffer = [];
                    } else {
                        break;
                    }
                }

                return output.join("");
            },

            getProductUrl(product) {
                return window.BASE_URL + product.url_key + (product.url_suffix || '');
            },

            getProductImageUrl(product) {
                const imageUrl = product.small_image.url;
                let mediaURL = this.config.customMediaUrl || imageUrl;

                if (mediaURL.includes('/media') && imageUrl.startsWith('media/')) {
                    mediaURL = mediaURL.replace('/media', '');
                }

                return (imageUrl.includes('://') ? '' : mediaURL) + imageUrl;
            },

            /**
             * @param Product {id: string}
             */
            addToWishlist({id}) {
                postFormRequest('wishlist/index/add/', id).then(response => {
                    if (response.redirected) {
                        window.location.href = response.url;
                    } else if (response.ok) {
                        return response.json();
                    } else {
                        typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                            [{
                                type: "warning",
                                text: "Could not add item to wishlist."
                            }], 5000
                        );
                    }
                }).then(response => {
                    if (!response) { return }
                    typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                        [{
                            type: response.success ? "success" : "error",
                            text: response.success
                                ? "Product has been added to your Wish List." : response.error_message
                        }], 5000
                    );
                    window.dispatchEvent(new CustomEvent("reload-customer-section-data"));
                }).catch(function (error) {
                    typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                        [{
                            type: "error",
                            text: error
                        }], 5000
                    );
                });
            },

            /**
             * @param Product {id: string}
             */
            addToCompare({id}) {
                postFormRequest('catalog/product_compare/add', id)
                    .then(response => {
                        if (response.redirected) {
                            window.location.href = response.url;
                        }
                        this.isLoading = false;
                    }).catch(error => {
                        this.isLoading = false;
                        typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                            [{
                                type: "error",
                                text: error
                            }], 5000
                        );
                    });
            },

            /**
             *
             * @param product
             */
            getRating(product) {
                const { rating_summary } = product;
                product.ratingData = {
                    ratingSteps: 5,
                    starsFilled: Math.floor(+rating_summary / 100 * 5),
                    starFragment: rating_summary / 100 * 5 % 1,
                    starsEmpty: Math.floor(5 - (+rating_summary / 100 * 5)),
                    yellowHex: '#fbbf24',
                    greyHex: '#9ca3af'
                };
                return product;
            },

                        /**
             * @param Product {id: string}
             */
            addToCart({id}, $event) {
                this.isLoading = true;

                const action = 'https://www.masterbooks.com/checkout/cart/add/';
                const data = { product: id, qty: 1 };

                hyva.postForm({ action, data });
            },
                    }
    }
</script>
<script>
    'use strict';

    window._amXSearchConfigFetcher = null;

    function amXsearchAutocompleteComponent() {
        const browserCache = {
            set(key, value, ttl = 5 * 60 * 1000) {
                const expiry = Date.now() + ttl;
                localStorage.setItem(key, JSON.stringify({value, expiry}));
            },

            get(key) {
                const item = JSON.parse(localStorage.getItem(key) || "null");
                if (!item || Date.now() > item.expiry) {
                    localStorage.removeItem(key);
                    return null;
                }
                return item.value;
            }
        };

        const INITIAL_QUERY_CACHE_KEY = 'x.InitialQuery';
        const CONFIG_QUERY_CACHE_KEY = 'x.ConfigQuery';
        const PREV_QUERY_CACHE_KEY = 'x.PrevQuery';
        // TODO: Possible it will needs to change after the configurations are added to Admin
        const HEADER_TYPE = 'b';

        const cache = {};
        const dataSections = {
            products: false,
            category: false,
            page: false,
            faq: false,
            landingPage: false,
            browsingHistory: false,
            popularSearches: false,
            bestsellers: false,
            recentSearches: false,
            recentlyViewed: false,
            brand: false,
            blog: false
        };

        return {
            isLoading: false,
            searchInitialized: false,
            latestQuery: '',
            productNameMaxLength: 50,
            resultPageUrl: 'https://www.masterbooks.com/catalogsearch/result/?q=',
            minSearchLength: 3,
            maxSearchLength: 128,
            isDefaultSearchInput: false,
            isFullWidthSearch: false,
            searchPopupWidth: 1536,
            showOverlay: false,
            config: {},
            slider: {
                bestsellers: false,
                recentlyViewed: false
            },
            isHorizontalView: true,
            noResultsFound: false,
            errorMessage: null,
            // sections
            sections: Object.create(dataSections),
            searchQuery: '',

            isHyvaUiHeader() {
                return HEADER_TYPE.length && HEADER_TYPE !== 'default';
            },

            checkHyvaUiHeaderVariant(needle) {
                return this.isHyvaUiHeader() && needle === HEADER_TYPE;
            },

            dynamicLayout($el) {
                const matchMedia = window.matchMedia('(max-width: 768px)');
                const isHorizontalViewPopupWidth = this.searchPopupWidth < 700 && !this.isDefaultSearchInput && !this.isFullWidthSearch;
                // Fix cms preview
                this.normalizeBaseUrl();

                this.isHorizontalView = !matchMedia.matches ? isHorizontalViewPopupWidth : true;
                matchMedia.addEventListener('change', event => {
                    this.isHorizontalView = !matchMedia.matches ? isHorizontalViewPopupWidth : true;
                })

                if (!window._amXSearchConfigFetcher) {
                    window._amXSearchConfigFetcher = new Promise(async resolve => {
                        const cachedData = browserCache.get(CONFIG_QUERY_CACHE_KEY);

                        if (cachedData) {
                            return resolve(cachedData);
                        }

                        const query = `query {config: storeConfig {
            amasty_xsearch_product_reviews
            amasty_xsearch_product_add_to_cart
            amasty_xsearch_product_redirect_single_product
            amasty_xsearch_general_full_screen
            amasty_xsearch_product_popup_display
            amasty_xsearch_product_show_sku
            amasty_xsearch_product_desc_length

            secure_base_media_url

            amasty_xsearch_product_title
            amasty_xsearch_popular_searches_title
            amasty_xsearch_browsing_history_title
            amasty_xsearch_recent_searches_title
            amasty_xsearch_recently_viewed_title
            amasty_xsearch_landing_page_title
            amasty_xsearch_bestsellers_position

            amasty_xsearch_faq_title
            amasty_xsearch_brand_title
            amasty_xsearch_blog_title
            amasty_xsearch_category_title
            amasty_xsearch_bestsellers_title
            amasty_xsearch_page_title

            amasty_xsearch_popular_searches_first_click
            amasty_xsearch_browsing_history_first_click
            amasty_xsearch_recent_searches_first_click

            amasty_xsearch_layout_enabled
            amasty_xsearch_layout_border
            amasty_xsearch_layout_hover
            amasty_xsearch_layout_highlight
            amasty_xsearch_layout_background
            amasty_xsearch_layout_text
            amasty_xsearch_layout_hover_text
            amasty_xsearch_layout_search_button
            amasty_xsearch_layout_search_button_text
        }}`;
                        const response = await this.fetch(query, {}, CONFIG_QUERY_CACHE_KEY, false);
                        if (response.errors && response.errors.length > 0) {
                            console.error(response.errors);
                        }

                        response.data.config = this.mapGraphAliases(response.data.config)

                        browserCache.set(CONFIG_QUERY_CACHE_KEY, response);
                        resolve(response);
                    });
                }

                _amXSearchConfigFetcher.then(response => {
                    if (!response?.data?.config) {
                        return;
                    }

                    this.config = response.data.config;
                    this.processCustomLayoutStyles($el);
                });

                if (typeof this.searchOpen !== "undefined") {
                    this.$watch('searchOpen', val => {
                        if (!val) {
                            return;
                        }

                        requestAnimationFrame(() => {
                            const searchInput = document.querySelector('#search');
                            searchInput && searchInput.focus();
                        });
                    });
                }

                if (typeof this.showOverlay !== "undefined") {
                    this.$watch('showOverlay', val => {
                        if (!val) {
                            return;
                        }

                        this.applyHyvaUiHeaderConfig()
                    });
                }

                                this.applyHeaderTypeToContainers();
                            },

            isSidebarSectionsDisabled() {
                if (!this.isHorizontalView) {
                    return !Object.entries(this.sections).some(([key, value]) =>
                        key !== 'products' && key !== 'bestsellers' && key !== 'recentlyViewed' && value.total_count > 0
                    );
                }
            },

            showSideBar() {
                const recentlyViewed = this.sections?.recentlyViewed;
                return this.latestQuery.length >= 3
                    || (recentlyViewed && recentlyViewed?.items?.length);
            },


            showOnFirstClick(blockName) {
                const sectionsToCheck = [
                    'popularSearches',
                    'browsingHistory',
                    'recentSearches'
                ];

                if (!sectionsToCheck.includes(blockName)) {
                    return false;
                }

                return this.latestQuery.length < this.minSearchLength
                    && this.config[`amasty_xsearch_${blockName}_first_click`]
                    && this.sections[blockName]?.items?.length;
            },

            processCustomLayoutStyles() {
                const conf = key => this.config[`amasty_xsearch_layout_${key}`];

                if (!conf("enabled")) {
                    return "";
                }

                const styles = [
                    "border",
                    "hover",
                    "highlight",
                    "background",
                    "text",
                    "hover_text",
                    'search_button',
                    'search_button_text'
                ];

                const cachedConf = styles.reduce((acc, key) => {
                    acc[key] = conf(key);
                    return acc;
                }, {});

                const getDarken = (color, amount) => {
                    const hex = parseInt(color.slice(1), 16);
                    const r = Math.min(255, Math.max(0, ((hex >> 16) & 0xff) + amount));
                    const g = Math.min(255, Math.max(0, ((hex >> 8) & 0xff) + amount));
                    const b = Math.min(255, Math.max(0, (hex & 0xff) + amount));

                    return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, "0")}`;
                };

                const prefix = "--amsearch-color-";
                styles.forEach((key) => {
                    const color = cachedConf[key];

                    document.body.style.setProperty(prefix + key, `#${color}`);
                    document.body.style.setProperty(`${prefix + key}-focus`, getDarken(`#${color}`, -12));
                    document.body.style.setProperty(`${prefix + key}-hover`, getDarken(`#${color}`, -16));
                });
            },

            canShowSection(sectionData) {
                return sectionData && sectionData.items && sectionData.items.length > 0;
            },

            initialSectionLoad() {
                const req = this.fetch(`query xSearchQuery {
recentlyViewed: xsearchRecentlyViewed {
            items {
                small_image {
                    label
                    url
                }
                id
                is_salable
                short_description {
                    html
                }
                name
                options_container
                rating_summary
                reviews_count
                sku
                url_key
                url_suffix
                url_rewrites {
                  url
                }
                price_range {
                    minimum_price {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                    maximum_price {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                    minimum_price_excl_tax {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                    maximum_price_excl_tax {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                 }
            }
        }




}`, {}, INITIAL_QUERY_CACHE_KEY);
                req.then(response => {
                    if (response.errors && response.errors.length > 0) {
                        console.error(response.errors);
                    }

                    this.searchInitialized = true;
                    this.processResponse(response);
                });
            },

            encodeHtml(html) {
                const txt = document.createElement('textarea');
                txt.textContent = html;
                return txt.innerHTML;
            },

            sanitize(value) {
                if (typeof DOMPurify === 'function') {
                    return DOMPurify.sanitize(value)
                } else {
                    return this.encodeHtml(value)
                }
            },

            doSearch() {
                this.sections = Object.create(dataSections);

                const {searchInput} = this.$refs;
                const {latestQuery, minSearchLength} = this;
                const inputText = this.sanitize(searchInput.value);

                this.searchQuery = inputText;

                if (inputText !== latestQuery && cache[PREV_QUERY_CACHE_KEY]) {
                    delete cache[PREV_QUERY_CACHE_KEY];
                }

                this.latestQuery = this.sanitize(searchInput.value);

                if (inputText.length < minSearchLength) {
                    this.initialSectionLoad();
                    return;
                }

                this.noResultsFound = null;
                this.errorMessage = null;

                const query = `query xSearchQuery($inputText: String!) {products: xsearchProducts(search: $inputText) {
                code
                items {
                  __typename
                  small_image {
                    label
                    url
                  }

                  id
                  is_salable
                  short_description {
                    html
                  }
                  name
                  rating_summary
                  reviews_count
                  sku
                  url_key
                  url_suffix
                  url_path
                  canonical_url
                  url_rewrites {
                    url
                  }
                  grouped_final_price {
                    final_price  {
                            value
                            currency
                        }
                    regular_price  {
                            value
                            currency
                        }
                    has_discount
                  }
                  price_range {
                    minimum_price {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                    maximum_price {
                        regular_price {
                            value
                            currency
                        }
                        final_price {
                            value
                            currency
                        }
                    }
                 }
                }
                total_count
              }
page: xsearchPages(search: $inputText) {
                   items {
                      description
                      name
                      title
                      url
                    },
                    total_count
                }




brand: xsearchBrands(search: $inputText) {
                code
                items {
                  name
                  title
                  url
                }
                total_count
              }
blog: xsearchBlogs(search: $inputText) {
                code
                items {
                  description
                  name
                  title
                  url
                }
                total_count
              }
terms: xsearchRelatedTerms(search: $inputText) {
                    items {
                      count
                      name
                    }
                  }

faq: xsearchFaqs(search: $inputText) {
                code
                items {
                  name
                  title
                  url
                }
                total_count
              }}`;
                const req = this.fetch(query, {inputText}, PREV_QUERY_CACHE_KEY);

                req.then(response => {
                    if (response.errors && response.errors.length > 0) {
                        this.errorMessage = response.errors[0].message;
                        console.error(this.errorMessage);

                        response.data.popularSearches = null;
                    }

                    this.searchInitialized = true;
                    this.processResponse(response);
                });
            },

            fetch(query, variables = {}, cacheKey = null, useLoading = true) {
                if (cacheKey && cache[cacheKey]) {
                    return Promise.resolve(cache[cacheKey]);
                }

                if (useLoading) {
                    this.isLoading = true;
                }

                const req = fetch(`${BASE_URL}graphql`, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Store': 'masterbooks'
                    },
                    credentials: 'include',
                    body: JSON.stringify({query, variables}),
                });

                return req.then(response => {
                    if (!response.ok) {
                        throw new Error(`HTTP error: ${response.status}`);
                    }

                    const body = response.json();
                    if (cacheKey) {
                        cache[cacheKey] = body;
                    }

                    return body;
                })
                    .catch(reason => {
                        console.error(reason);
                    })
                    .finally(() => {
                        this.isLoading = false;
                    });
            },

            checkSearchInput() {
                if (this.$refs.searchInput.value === '') {
                    this.clear();
                }
            },

            redirect() {
                this.isLoading = true;
                const {searchInput} = this.$refs;
                const inputText = this.sanitize(searchInput.value);

                const products = this.sections.products;
                if (products && products.items.length === 1 && this.config.isRedirectToSingleProductEnabled) {
                    location.href = this.getProductUrl(products.items[0]);
                    return;
                }

                const url = 'https://www.masterbooks.com/catalogsearch/result/?q=';
                location.href = url + encodeURI(inputText);
            },

            focusElement(element) {
                if (element && element.nodeName === "DIV") {
                    element.focus();
                    return true;
                }
                return false;
            },

            processResponse(response) {
                this.updateSections(response.data);
            },

            clear() {
                const initialQueryCache = cache[INITIAL_QUERY_CACHE_KEY];
                if (!initialQueryCache) {
                    return;
                }

                initialQueryCache.then(result => {
                    this.updateSections(result.data ?? {});
                });
            },

            clearSearchQuery() {
                this.searchQuery = '';
                this.$refs.searchInput.value = '';
                this.$refs.searchInput.focus();
            },

            closeSearch() {
                if (this.searchOpen) {
                    this.searchOpen = false;
                }

                this.$nextTick(() => {
                    this.showOverlay = false;
                    this.searchInitialized = false;
                })

                if (this.checkHyvaUiHeaderVariant('c')) {
                    this.$refs.searchContainerDesktop.classList.remove(HEADER_TYPE + '-header-type');
                }
            },

            processItemsWithRating(value) {
                if (value?.items) {
                    value.items = value.items.map(this.getRating);
                }
                return value;
            },

            processSection(key, value) {
                if (!value) return value;

                let processedValue = {...value};

                switch (key) {
                    case 'recentlyViewed':
                    case 'bestsellers':
                        processedValue = this.processItemsWithRating(processedValue);
                        processedValue.items = (processedValue.items || []).map(item => ({
                            ...item,
                            isSliderItem: true,
                        }));
                        break;
                    case 'products':
                        processedValue = this.processItemsWithRating(processedValue);
                        processedValue = this.processProductName(processedValue);
                        break;
                    default:
                        break;
                }

                processedValue.title = this.config[`amasty_xsearch_${key}_title`] || 'Default Title';
                return processedValue;
            },

            updateSections(rows) {
                if (!this.showOverlay) this.showOverlay = true;

                this.isLoading = false;

                this.noResultsFound = !rows.products?.total_count && this.latestQuery.length >= this.minSearchLength;
                if (!this.noResultsFound) this.errorMessage = null;

                Object.keys(rows).forEach(key => {
                    const data = rows[key];
                    this.sections[key] = data?.items?.length ? this.processSection(key, data) : {
                        items: [],
                        total_count: 0
                    };
                });

                if (this.latestQuery.length >= this.minSearchLength) return;

                Object.keys(this.slider).forEach(key => {
                    const items = rows[key]?.items;

                    if (items?.length && !this.slider[key]) {
                        this.slider[key] = this.amXsearchCarouselComponent(key, items.length);
                    }
                });

                window.dispatchEvent(new CustomEvent('amxsearch-updated-sections'));
            },

            getBlockOrder() {
                const enabled = [];
                const order = (this.config.amasty_xsearch_bestsellers_position === '1')
                    ? ['bestsellers', 'recentlyViewed']
                    : ['recentlyViewed', 'bestsellers'];
                return order.filter(item => enabled.includes(item));
            },

            shouldRenderComponent(component) {
                const enabledComponents = {
                    bestsellers: false,
                    recentlyViewed: false                };

                return enabledComponents[component] && this.slider[component];
            },
            mapGraphAliases(config) {
                const aliasMap = {
                    amasty_xsearch_product_reviews: 'isProductReviewsBlockEnabled',
                    amasty_xsearch_product_add_to_cart: 'isProductAddToCartBlockEnabled',
                    amasty_xsearch_product_redirect_single_product: 'isRedirectToSingleProductEnabled',
                    amasty_xsearch_general_full_screen: 'isFullScreenMode',
                    amasty_xsearch_product_popup_display: 'isGridView',
                    amasty_xsearch_product_show_sku: 'isShowSku',
                    amasty_xsearch_product_desc_length: 'shortDescriptionLength',
                    secure_base_media_url: 'customMediaUrl',
                    amasty_xsearch_product_title: 'amasty_xsearch_products_title',
                    amasty_xsearch_popular_searches_title: 'amasty_xsearch_popularSearches_title',
                    amasty_xsearch_browsing_history_title: 'amasty_xsearch_browsingHistory_title',
                    amasty_xsearch_recent_searches_title: 'amasty_xsearch_recentSearches_title',
                    amasty_xsearch_recently_viewed_title: 'amasty_xsearch_recentlyViewed_title',
                    amasty_xsearch_landing_page_title: 'amasty_xsearch_landingPage_title',
                    amasty_xsearch_popular_searches_first_click: 'amasty_xsearch_popularSearches_first_click',
                    amasty_xsearch_browsing_history_first_click: 'amasty_xsearch_browsingHistory_first_click',
                    amasty_xsearch_recent_searches_first_click: 'amasty_xsearch_recentSearches_first_click'
                };
                const result = {};

                for (let key in config) {
                    const newKey = aliasMap[key] ? aliasMap[key] : key;
                    result[newKey] = config[key];
                }

                return result;
            }
        }
    }
</script>
<script>
    'use strict';

    function deepMerge(target, ...sources) {
        if (!sources.length) return target;

        for (const source of sources) {
            if (typeof source !== 'object' || source === null) continue;

            for (const key in source) {
                if (!source.hasOwnProperty(key)) continue;

                if (Array.isArray(source[key])) {
                    target[key] = (target[key] || []).concat(source[key]);
                } else if (typeof source[key] === 'object' && source[key] !== null) {
                    target[key] = deepMerge(target[key] || {}, source[key]);
                } else {
                    target[key] = source[key];
                }
            }
        }

        return target;
    }

    function mergeFunctions(functions) {
        return function (...args) {
            functions.forEach(func => func && func.apply(this, args));
        };
    }

    /**
     * Carousel component for xsearch
     *
     * @param key
     * @param itemCount
     * @returns Object
     */
    function amXsearchCarouselComponent(key, itemCount) {
        return {
            itemCount,
            pageSize: 4,
            active: 0,
            slider: null,
            pageFillers: 0,
            sliderEl: false,
            smallWindowItemWidth: false,
            init($refs) {
                const sliderEl = $refs[`${key}Container`];
                if (!sliderEl || itemCount === 0) {
                    return this;
                }

                if (sliderEl) {
                    if (!this.isDefaultSearchInput && !this.isFullWidthSearch) {
                        if (this.searchPopupWidth <= 900) {
                            this.smallWindowItemWidth = sliderEl.clientWidth / 3;
                        }
                        if (this.searchPopupWidth <= 700) {
                            this.smallWindowItemWidth = sliderEl.clientWidth / 2;
                        }
                        if (this.searchPopupWidth <= 500) {
                            this.smallWindowItemWidth = sliderEl.clientWidth - 30;
                        }
                    }
                }

                this.sliderEl = sliderEl;
                this.recalculate();
            },
            getSlider() {
                return this.sliderEl.querySelector('.carousel-slides');
            },
            calcPageSize() {
                const slider = this.getSlider();
                if (!slider) {
                    return this;
                }

                const slides = slider.querySelectorAll('.carousel-slide');
                if (this.smallWindowItemWidth) {
                    slides.forEach(slide => {
                        slide.style.width = `${this.smallWindowItemWidth}px`;
                    });
                }

                const firstSlide = slides[0];

                this.itemCount = slides.length;
                this.pageSize = Math.round(slider.clientWidth / firstSlide.clientWidth);

                this.pageFillers = this.pageSize * Math.ceil(this.itemCount / this.pageSize) - this.itemCount;
            },
            calcActive() {
                const slider = this.getSlider();
                if (!slider) {
                    return this;
                }

                const sliderItems = Math.round(this.itemCount) + Math.round(this.pageFillers);
                const calculatedActiveSlide = Math.round(
                    Math.round(slider.scrollLeft) / (Math.round(slider.scrollWidth) / sliderItems)
                );

                this.active = Math.round(calculatedActiveSlide / Math.round(this.pageSize)) * Math.round(this.pageSize);
            },
            prev() {
                this.scrollTo(this.active - this.pageSize);
            },
            next() {
                this.scrollTo(this.active + this.pageSize);
            },
            scrollTo(index) {
                const slider = this.getSlider();
                if (!slider) {
                    return this;
                }

                const slideWidth = slider.scrollWidth / (this.itemCount + this.pageFillers);
                slider.scrollLeft = Math.floor(slideWidth) * index;

                this.calcActive();
            },

            isActive(index) {
                return index === this.active;
            },

            recalculate() {
                this.calcPageSize();
                setTimeout(() => this.calcActive(), 100);
            },
            onResize() {
                this.calcPageSize();
                setTimeout(() => this.calcActive(), 100);
            }
        };
    }
</script>

    <script>
    'use strict';

    function amXsearchAutocompleteHyvaUIHeaderCompat() {
        const HEADER_TYPE = 'b';
        return HEADER_TYPE ? {
            applyHyvaUiHeaderConfig() {
                const searchContent = document.getElementById('search-content');

                if (this.isFullWidthSearch) {
                    if (!this.isHorizontalView) {
                        if (this.checkHyvaUiHeaderVariant('b')) {
                            searchContent.style = 'max-width:none';
                            searchContent.parentNode.style = 'padding-right:0; padding-left:0;';
                        }

                        if (this.checkHyvaUiHeaderVariant('c')) {
                            this.$refs.searchContainerDesktop.classList.add(HEADER_TYPE + '-header-type');
                            this.$refs.searchForm.style = 'padding-right:0; padding-left:0;';
                        }
                    }

                    if (this.checkHyvaUiHeaderVariant('a')) {
                        searchContent.style = 'max-width: none';
                    }
                }
            },

            applyHeaderTypeToContainers() {
                const searchHeader = document.getElementById('header');
                const columnMain = document.querySelector('.column.main');
                const searchContent = document.getElementById('search-content');
                const headerTypeClass = HEADER_TYPE + '-header-type';

                if (searchHeader) {
                    searchHeader.classList.add(headerTypeClass);
                }

                if (columnMain) {
                    columnMain.classList.add(headerTypeClass);
                }

                if (this.checkHyvaUiHeaderVariant('a')) {
                    searchContent.className = 'container';
                }
            },

            normalizeBaseUrl() {
                let url = new URL(BASE_URL);
                BASE_URL = url.origin + url.pathname
            }
        } : {};
    }
</script>

<div :class="{
            'container': !config.isFullScreenMode,
            'relative lg:py-2 mx-auto text-black z-20': true,
            'max-w-none px-0': isHyvaUiHeader() && isFullWidthSearch,
            'px-0': isHyvaUiHeader() && isHorizontalView
     }"
     id="form-wrapper"
     x-data="Object.assign(
        searchButtonsComponent(),
        {amXsearchCarouselComponent},
         amXsearchProductsComponent(),
         amXsearchAutocompleteComponent(),
                     amXsearchAutocompleteHyvaUIHeaderCompat(),
                  amXsearchHeaderScripts(),
     )"
     x-init="dynamicLayout($el)">

    <div
    class="z-50 fixed inset-0 flex justify-center items-center bg-white/70 select-none"
    x-show="isLoading"
    x-cloak
    x-transition.opacity.duration.200ms
>
    <div class="flex items-center">
        <svg xmlns="http://www.w3.org/2000/svg" width="54" height="54" viewBox="0 0 50 50" aria-hidden="true">
    <path fill="#d9dddd" d="M43.935 25.145c0-10.318-8.364-18.683-18.683-18.683-10.318 0-18.683 8.365-18.683 18.683h4.068c0-8.071 6.543-14.615 14.615-14.615s14.615 6.543 14.615 14.615h4.068z">
        <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/>
    </path>
</svg>
        <div class="ml-10 text-xl">
            Loading...        </div>
    </div>
</div>

    <div x-show="showOverlay"
         x-cloak 
         class="fixed inset-0 bg-black/50 z-20 w-full h-full top-0 left-0 right-0 bottom-0"
         @click.prevent="closeSearch()"
         @keydown.window.escape="closeSearch()"></div>

    <div class="form mx-2 mini-search z-20 relative flex flex-col items-center"
         :class="{
         'right-0': !isHyvaUiHeader(),
         'md:flex md:justify-center': checkHyvaUiHeaderVariant('c') && !isDefaultSearchInput && !isFullWidthSearch
         }"
    >
        <form id="search_mini_form" @submit.prevent="redirect()"
              action="https://www.masterbooks.com/catalogsearch/result/?q="
              :class="{
              'absolute right-0': checkHyvaUiHeaderVariant('a') && !isDefaultSearchInput && !isFullWidthSearch
              }"
              class="flex justify-center w-full xl:max-w-[100%]" method="GET">
            <label class="hidden" for="search" data-role="mini-search-label">
                <span>Search</span>
            </label>
            <div class="relative w-full flex align-center justify-center items-center">
                <input id="search"
                       @mouseover="checkClearBtn()"
                       @mouseleave="if (!showOverlay) showClearBtn = false"
                       @click.outside="showClearBtn = false"
                       x-ref="searchInput"
                       x-model="searchValue"
                       maxlength="128"
                       form="search_mini_form"
                       type="search"
                       name="q"
                       value=""
                       autocomplete="off"
                       placeholder="Search&#x20;by..."
                       class="p-2 text-lg leading-normal transition appearance-none text-grey-800 relative z-20
                    focus:outline-hidden focus:border-transparent lg:text-xl flex-am-search-sidebar placeholder:text-sm"
                       :style="`width: ${checkHyvaUiHeaderVariant('c') && !isDefaultSearchInput && !isFullWidthSearch ? searchPopupWidth + 'px' : '100%'}`"
                       @focus="doSearch()"
                       @search="checkSearchInput()"
                       @input.debounce.500="doSearch()"
                                            x-intersect:enter.once="applyHyvaUiHeaderConfig()"
                                           @keydown.arrow-down.prevent="focusElement($el.querySelector('[tabindex]'))"/>
                <button type="button"
                        class="absolute right-10 z-20"
                        x-show="showClearBtn"
                        onclick="getElementById('search').value='';"
                        x-cloak>
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="md:h-4 md:w-4" width="25" height="25" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
</svg>
                </button>
                <button type="submit" title="Search"
                        class="absolute right-2 z-20 am-custom-search-button h-full action search w-auto justify-center text-sm md:mb-0 mr-auto rounded-none"
                        x-bind:disabled="isLoading || latestQuery.length < minSearchLength"
                        :class="{
                            'opacity-50': isLoading || latestQuery.length < minSearchLength,
                            'am-custom-search-button': false,
                            'rounded-tr': isHyvaUiHeader()
                        }"
                        aria-label="Search">
                                            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="md:h-6 md:w-6" width="25" height="25" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
                                    </button>
            </div>
        </form>
        <template x-if="searchInitialized">
            <div
            class="top-[46px] w-[calc(100vw-2rem)] -right-position -bottom-position bg-white shadow-lg max-h-screen-75 overflow-auto text-sm amsearch-container lg:ml-[-2.5rem] lg:mr-16"
            :class="{
                    'absolute': !config.isFullScreenMode || isHyvaUiHeader(),
                }"
                tabindex="-1"
                x-cloak
                :style="`${!isDefaultSearchInput && !isFullWidthSearch ? 'max-width:' + searchPopupWidth + 'px' : ''}; ${!isHorizontalView && checkHyvaUiHeaderVariant('a') ? 'top: 44px; margin-top: 1px;' : ''}`"
                x-show="!isLoading && showOverlay">
                <div
                    class="flex w-full content-start flex-wrap box-border relative"
                    :class="{
                            'flex-col': isHorizontalView,
                            'flex-col md:flex-row': !isHorizontalView,
                         }">
                    <div class="w-full md:border-r pt-6 am-search-sidebar"
                         :class="{
                            'border-gray-600': showSideBar() && getResultProductsCount() > 0,
                            'hidden': latestQuery.length < minSearchLength && (
                                !showOnFirstClick('recentSearches') && !showOnFirstClick('popularSearches') && !showOnFirstClick('browsingHistory')
                            ) || isSidebarSectionsDisabled(),
                            'am-search-horizontal-view': isHorizontalView,
                         }">
                                                    <template
                                x-if="                                        sections?.landingPage?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('landingPage'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="landingPageTitle"></h3>

    <template x-for="(item, index) in landingPageItems" :key="index">
        <a
            class="w-full block hover:bg-gray-100 py-2 px-4"
            :href="landingPageItemUrl"
            x-html="landingPageitemTitle"
        ></a>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="isHorizontalView &amp;&amp; !noResultsFound &amp;&amp;                                         sections?.products?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('products'))"
                                    x-cloak>
                                    <div class="w-full" data-amsearch-analytics="block">
    <div class="flex row justify-between w-full mb-2 pb-4 p-2 items-center">
        <h3 class="text-lg font-bold">
           <span x-text="productsTitle"></span> (<span x-text="productsTotalCount"></span>)
        </h3>

        <div class="am-search-view-all" x-show="isShowResultProducts">
            <a
                :href="latestQueryUrl"
                class="text-blue-600 hover:text-blue-800 "
            >
                View All <span x-show="isShowResultProducts">(+<span x-text="getResultProductsCount"></span>)</span>
            </a>
        </div>
    </div>

    <div class="relative flex flex-wrap w-full">
        <template x-for="(product, index) in productsItems" :key="index">
            
<div class="item product product-item card card-interactive flex round-none shadow-none border-none"
     :class="{
        'flex-row mb-5 list-view': config.isGridView
                                    && (isFullWidthSearch || isDefaultSearchInput || searchPopupWidth > 900),
        'flex-col mt-2 w-1/2 lg:w-full xl:w-1/2 2xl:w-1/3': !config.isGridView
                                    && (!isFullWidthSearch || !isDefaultSearchInput || searchPopupWidth <= 900)
     }">
    <a :href="getProductUrl(product)"
       class="photo product-item-photo block mb-3 flex justify-center align-center h-52 w-full"
       tabindex="-1"
              :class="{'md:w-1/6 md:mb-0 mr-5': config.isGridView}"
    >
        <img class="object-contain min-w-52 h-full"
             src="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/images/product/placeholder/image.svg"
             x-bind:src="getProductImageUrl(product)"
             :alt="product.small_image.label"
                          width="200"
        />

            </a>
    <div class="product-info flex flex-col grow">
        <div class="mt-2 mb-1 items-center justify-center text-primary text-lg min-h-[5rem]"
             :class="{'md:text-left': config.isGridView, 'text-center': !config.isGridView}"
        >
            <a class="product-item-link action link"
               :href="getProductUrl(product)"
            >
                <span x-html="product.name" class="amsearch-product-name"></span>
            </a>
            <template x-if="config.isShowSku">
                <div class="text-sm font-normal">
                    <span>SKU:</span>
                    <span x-html="product.sku"></span>
                </div>
            </template>
        </div>
        <template x-if="config.isProductReviewsBlockEnabled">
            <div class="py-1 max-w-full"
     :class="{'mx-0 w-full': config.isGridView, 'mx-auto': !config.isGridView}">
    <div class="rating-summary cursor-pointer text-center inline-block"
         :class="{'flex items-center': config.isGridView && !product.isSliderItem}"
         :title="product.rating_summary === 0 ? 'Be&#x20;the&#x20;first&#x20;to&#x20;review&#x20;this&#x20;product' : ''">
        <div class="flex">
            <template x-for="starFilled in product.ratingData.starsFilled">
                <svg xmlns="http://www.w3.org/2000/svg" class="fill-current w-6 h-6" viewBox="3 0 20 20"
                     :style="`color: ${product.ratingData.yellowHex}`"
                     fill="currentColor">
                    <path
                        d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371
                        1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1
                        1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                </svg>
            </template>
            <template x-if="product.ratingData.starFragment > 0">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="3 0 20 20" fill="currentColor" class="w-6 h-6">
                    <defs>
                        <linearGradient :id="'partialFill' + product.id">
                            <stop offset="0%" :stop-color="product.ratingData.yellowHex"/>
                            <stop :offset="product.ratingData.starFragment * 100 + '%'" :stop-color="product.ratingData.yellowHex"/>
                            <stop :offset="product.ratingData.starFragment * 100 + '%'" :stop-color="product.ratingData.greyHex"/>
                            <stop offset="100%" :stop-color="product.ratingData.greyHex"/>
                        </linearGradient>
                    </defs>
                    <g :fill="'url(#partialFill' + product.id + ')'">
                        <path
                            d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969
                        0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1
                        0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                    </g>
                </svg>
            </template>
            <template x-for="starEmpty in product.ratingData.starsEmpty">
                <svg xmlns="http://www.w3.org/2000/svg"
                     class="fill-current w-6 h-6"
                     :style="`color: ${product.ratingData.greyHex}`"
                     viewBox="3 0 20 20"
                     fill="currentColor">
                    <path
                        d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0
                        1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1
                        1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
                    />
                </svg>
            </template>
        </div>

        <template x-if="product.rating_summary > 0">
            <a :href="`${getProductUrl(product)}`" class="inline-block reviews-link text-links">
                <span class="ml-2 text-sm" x-text="product.reviews_count"></span>
                Reviews            </a>
        </template>
    </div>
</div>
        </template>
        <div class="mt-2 mb-1 items-center justify-center text-primary min-h-[8rem]"
             :class="{'text-left': config.isGridView, 'text-center': !config.isGridView}"
             x-html="truncateWithDots(product.short_description.html, config.shortDescriptionLength)"
        ></div>
        <div class="flex flex-row justify-between items-center w-full">
            <div class="final-price flex-1">
                <template x-if="product.grouped_final_price && product.grouped_final_price.final_price">
                    <span class="inline-flex items-baseline flex-wrap">
                        <span class="mr-2 price-wrapper title-font font-bold leading-5 text-lg text-gray-900">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.grouped_final_price.final_price.value)">
                            </span>
                        </span>
                        <span x-show="product.grouped_final_price.has_discount"
                              class="price-wrapper line-through text-gray-500">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.grouped_final_price.regular_price.value)">
                            </span>
                        </span>
                    </span>
                </template>
                <template x-if="!product.grouped_final_price || !product.grouped_final_price.final_price">
                    <span class="inline-flex items-baseline flex-wrap">
                        <span class="price-label"
                              x-show="product.price_range.minimum_price.final_price.value < product.price_range.maximum_price.final_price.value">
                            As low as                        </span>
                        <span class="price-wrapper title-font font-bold leading-5 text-lg text-gray-900">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.price_range.minimum_price.final_price.value)">
                            </span>
                        </span>
                    </span>
                </template>
            </div>
                                        <button
                    x-data="initWishlist()"
                    aria-label="Add&#x20;to&#x20;Wish&#x20;List"
                    x-on:click.prevent="addToWishlist(product.id)"
                    class="rounded-full w-7 h-7 bg-gray-200 p-0 border-0
                                            inline-flex shrink-0 items-center justify-center
                                            text-gray-500 hover:text-red-600 ml-1"
                >
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5" width="25" height="25" role="img">
  <path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"/>
<title>heart</title></svg>
                </button>
                    </div>
        <div class="pt-3 flex items-center"
             :class="{
             'mt-auto justify-center': !config.isGridView ,
             'flex-wrap': config.isGridView && config.isProductAddToCartBlockEnabled && product.is_salable,
             'justify-start': config.isGridView
             }">
            <template x-if="config.isProductAddToCartBlockEnabled && product.is_salable">
                <button type="button"
                        x-on:click.prevent="addToCart(product, $event)"
                        class="w-full btn-atc btn btn-primary justify-center text-sm">
                    <span class="ml-2 inline">Add to Cart</span>
                </button>
            </template>
            <template x-if="config.isProductAddToCartBlockEnabled && !product.is_salable">
                <div class="w-auto justify-center text-sm text-left">
                    <span class="inline-block w-3 h-3 bg-red-500 rounded-full shrink-0"></span>
                    <span class="text-sm text-gray-700 text-left">Out of stock</span>
                </div>
            </template>
                    </div>
    </div>
</div>
        </template>
    </div>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.blog?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('blog'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="blogTitle"></h3>

    <div>
        <template x-for="(item, index) in blogItems" :key="index">
           <div>
               <a
                    class="w-full block hover:bg-gray-100 py-2 px-4"
                    :href="blogItemUrl"
                >
                    <span x-html="blogItemTitle" class="font-semibold"></span>
                </a>
                <span
                    class="text-black block mt-1 px-4"
                    x-html="blogItemDescription"
                ></span>
           </div>
        </template>
    </div>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.faq?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('faq'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="faqTitle"></h3>

    <template x-for="(item, index) in faqItems" :key="index">
        <a class="w-full block hover:bg-gray-100 py-2 px-4"
           :href="faqItemUrl"
           x-html="faqItemName">
        </a>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.page?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('page'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="pageTitle"></h3>

    <template x-for="(item, index) in pageItems" :key="index">
        <div>
            <a
                class="w-full block hover:bg-gray-100 py-2 px-4"
                :href="pageItemUrl"
            >
                <span x-html="itemTitle" class="font-semibold"></span>
            </a>
            <span
                class="text-black block mt-1 px-4"
                x-html="itemDescription"
            ></span>
        </div>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.brand?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('brand'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="brandTitle"></h3>

    <template x-for="(item, index) in brandItems" :key="index">
        <a
            class="w-full block hover:bg-gray-100 py-2 px-4"
            :href="brandItemUrl"
            x-html="brandItemName"
        ></a>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.category?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('category'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="categoryTitle"></h3>

    <template x-for="(item, index) in categoryItems" :key="index">
        <div>
            <a
                class="w-full block hover:bg-gray-100 py-2 px-4"
                :href="categoryItemUrl"
            >
                <span x-html="categoryItemName" class="font-semibold"></span>
            </a>
            <span
                class="text-black block mt-1 px-4"
                x-html="categoryItemDescription"
                x-show="categoryItemDescription"
            ></span>
        </div>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.recentSearches?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('recentSearches'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list">
    <h3
        class="text-lg font-bold mb-2 px-4"
        x-text="recentSearchesTitle"
    ></h3>

    <div class="flex direction-row flex-wrap mx-4">
        <template x-for="(searchItem, index) in recentSearchesItems" :key="index">
            <a
                class="bg-gray-100 hover:bg-gray-200 py-1 px-4 rounded-lg mr-2 mb-2"
                :href="recentSearchesLink"
                x-html="recentSearchesItemName"
            ></a>
        </template>
    </div>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.popularSearches?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('popularSearches'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list">
    <h3 class="text-lg font-bold mb-2 px-4" x-text="popularSearchesTitle"></h3>

    <template x-for="(searchItem, index) in popularSearchesItems" :key="index">
        <a
            class="w-full block hover:bg-gray-100 py-2 px-4"
            :href="popularSearchesItemUrl"
            x-html="popularSearchesItemName"
        ></a>
    </template>
</div>
                                </div>
                            </template>
                                                    <template
                                x-if="                                        sections?.browsingHistory?.items?.length">
                                <div
                                    x-show="(latestQuery.length >= minSearchLength || showOnFirstClick('browsingHistory'))"
                                    x-cloak>
                                    <div class="w-full mb-6 am-search-item-list" data-amsearch-analytics="block">
    <h3
        class="text-lg font-bold mb-2 px-4"
        x-text="browsingHistoryTitle"
    ></h3>

    <template x-for="(searchItem, index) in browsingHistoryItems" :key="index">
        <a
            class="w-full block hover:bg-gray-100 py-2 px-4"
            :href="browsingHistoryItemUrl"
            x-html="browsingHistoryItemName"
        ></a>
    </template>
</div>
                                </div>
                            </template>
                                            </div>
                    <div class="relative"
                         :class="{
                            'am-search-content p-2 pt-6': latestQuery.length >= minSearchLength || (
                                showOnFirstClick('recentSearches') || showOnFirstClick('popularSearches') || showOnFirstClick('browsingHistory')
                            ),
                            'w-full': latestQuery.length < minSearchLength && (
                                !showOnFirstClick('recentSearches') && !showOnFirstClick('popularSearches') && !showOnFirstClick('browsingHistory')
                            ),
                            'am-search-horizontal-view': isHorizontalView,
                            'p-2 pt-6': slider.recentlyViewed || slider.bestsellers,
                            'am-search-sidebar-disabled': isSidebarSectionsDisabled(),
                         }">
                        <div class="flex flex-nowrap flex-col" x-show="latestQuery.length < minSearchLength" x-cloak>
                            
                                                    </div>

                        <template x-if="!noResultsFound && !isHorizontalView && latestQuery.length >= minSearchLength">
                            <div class="w-full" data-amsearch-analytics="block">
    <div class="flex row justify-between w-full mb-2 pb-4 p-2 items-center">
        <h3 class="text-lg font-bold">
           <span x-text="productsTitle"></span> (<span x-text="productsTotalCount"></span>)
        </h3>

        <div class="am-search-view-all" x-show="isShowResultProducts">
            <a
                :href="latestQueryUrl"
                class="text-blue-600 hover:text-blue-800 "
            >
                View All <span x-show="isShowResultProducts">(+<span x-text="getResultProductsCount"></span>)</span>
            </a>
        </div>
    </div>

    <div class="relative flex flex-wrap w-full">
        <template x-for="(product, index) in productsItems" :key="index">
            
<div class="item product product-item card card-interactive flex round-none shadow-none border-none"
     :class="{
        'flex-row mb-5 list-view': config.isGridView
                                    && (isFullWidthSearch || isDefaultSearchInput || searchPopupWidth > 900),
        'flex-col mt-2 w-1/2 lg:w-full xl:w-1/2 2xl:w-1/3': !config.isGridView
                                    && (!isFullWidthSearch || !isDefaultSearchInput || searchPopupWidth <= 900)
     }">
    <a :href="getProductUrl(product)"
       class="photo product-item-photo block mb-3 flex justify-center align-center h-52 w-full"
       tabindex="-1"
              :class="{'md:w-1/6 md:mb-0 mr-5': config.isGridView}"
    >
        <img class="object-contain min-w-52 h-full"
             src="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/images/product/placeholder/image.svg"
             x-bind:src="getProductImageUrl(product)"
             :alt="product.small_image.label"
                          width="200"
        />

            </a>
    <div class="product-info flex flex-col grow">
        <div class="mt-2 mb-1 items-center justify-center text-primary text-lg min-h-[5rem]"
             :class="{'md:text-left': config.isGridView, 'text-center': !config.isGridView}"
        >
            <a class="product-item-link action link"
               :href="getProductUrl(product)"
            >
                <span x-html="product.name" class="amsearch-product-name"></span>
            </a>
            <template x-if="config.isShowSku">
                <div class="text-sm font-normal">
                    <span>SKU:</span>
                    <span x-html="product.sku"></span>
                </div>
            </template>
        </div>
        <template x-if="config.isProductReviewsBlockEnabled">
            <div class="py-1 max-w-full"
     :class="{'mx-0 w-full': config.isGridView, 'mx-auto': !config.isGridView}">
    <div class="rating-summary cursor-pointer text-center inline-block"
         :class="{'flex items-center': config.isGridView && !product.isSliderItem}"
         :title="product.rating_summary === 0 ? 'Be&#x20;the&#x20;first&#x20;to&#x20;review&#x20;this&#x20;product' : ''">
        <div class="flex">
            <template x-for="starFilled in product.ratingData.starsFilled">
                <svg xmlns="http://www.w3.org/2000/svg" class="fill-current w-6 h-6" viewBox="3 0 20 20"
                     :style="`color: ${product.ratingData.yellowHex}`"
                     fill="currentColor">
                    <path
                        d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371
                        1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1
                        1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                </svg>
            </template>
            <template x-if="product.ratingData.starFragment > 0">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="3 0 20 20" fill="currentColor" class="w-6 h-6">
                    <defs>
                        <linearGradient :id="'partialFill' + product.id">
                            <stop offset="0%" :stop-color="product.ratingData.yellowHex"/>
                            <stop :offset="product.ratingData.starFragment * 100 + '%'" :stop-color="product.ratingData.yellowHex"/>
                            <stop :offset="product.ratingData.starFragment * 100 + '%'" :stop-color="product.ratingData.greyHex"/>
                            <stop offset="100%" :stop-color="product.ratingData.greyHex"/>
                        </linearGradient>
                    </defs>
                    <g :fill="'url(#partialFill' + product.id + ')'">
                        <path
                            d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969
                        0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1
                        0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
                    </g>
                </svg>
            </template>
            <template x-for="starEmpty in product.ratingData.starsEmpty">
                <svg xmlns="http://www.w3.org/2000/svg"
                     class="fill-current w-6 h-6"
                     :style="`color: ${product.ratingData.greyHex}`"
                     viewBox="3 0 20 20"
                     fill="currentColor">
                    <path
                        d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0
                        1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54
                        1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1
                        1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
                    />
                </svg>
            </template>
        </div>

        <template x-if="product.rating_summary > 0">
            <a :href="`${getProductUrl(product)}`" class="inline-block reviews-link text-links">
                <span class="ml-2 text-sm" x-text="product.reviews_count"></span>
                Reviews            </a>
        </template>
    </div>
</div>
        </template>
        <div class="mt-2 mb-1 items-center justify-center text-primary min-h-[8rem]"
             :class="{'text-left': config.isGridView, 'text-center': !config.isGridView}"
             x-html="truncateWithDots(product.short_description.html, config.shortDescriptionLength)"
        ></div>
        <div class="flex flex-row justify-between items-center w-full">
            <div class="final-price flex-1">
                <template x-if="product.grouped_final_price && product.grouped_final_price.final_price">
                    <span class="inline-flex items-baseline flex-wrap">
                        <span class="mr-2 price-wrapper title-font font-bold leading-5 text-lg text-gray-900">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.grouped_final_price.final_price.value)">
                            </span>
                        </span>
                        <span x-show="product.grouped_final_price.has_discount"
                              class="price-wrapper line-through text-gray-500">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.grouped_final_price.regular_price.value)">
                            </span>
                        </span>
                    </span>
                </template>
                <template x-if="!product.grouped_final_price || !product.grouped_final_price.final_price">
                    <span class="inline-flex items-baseline flex-wrap">
                        <span class="price-label"
                              x-show="product.price_range.minimum_price.final_price.value < product.price_range.maximum_price.final_price.value">
                            As low as                        </span>
                        <span class="price-wrapper title-font font-bold leading-5 text-lg text-gray-900">
                            <span class="price"
                                  x-html="hyva.formatPrice(product.price_range.minimum_price.final_price.value)">
                            </span>
                        </span>
                    </span>
                </template>
            </div>
                                        <button
                    x-data="initWishlist()"
                    aria-label="Add&#x20;to&#x20;Wish&#x20;List"
                    x-on:click.prevent="addToWishlist(product.id)"
                    class="rounded-full w-7 h-7 bg-gray-200 p-0 border-0
                                            inline-flex shrink-0 items-center justify-center
                                            text-gray-500 hover:text-red-600 ml-1"
                >
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5" width="25" height="25" role="img">
  <path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"/>
<title>heart</title></svg>
                </button>
                    </div>
        <div class="pt-3 flex items-center"
             :class="{
             'mt-auto justify-center': !config.isGridView ,
             'flex-wrap': config.isGridView && config.isProductAddToCartBlockEnabled && product.is_salable,
             'justify-start': config.isGridView
             }">
            <template x-if="config.isProductAddToCartBlockEnabled && product.is_salable">
                <button type="button"
                        x-on:click.prevent="addToCart(product, $event)"
                        class="w-full btn-atc btn btn-primary justify-center text-sm">
                    <span class="ml-2 inline">Add to Cart</span>
                </button>
            </template>
            <template x-if="config.isProductAddToCartBlockEnabled && !product.is_salable">
                <div class="w-auto justify-center text-sm text-left">
                    <span class="inline-block w-3 h-3 bg-red-500 rounded-full shrink-0"></span>
                    <span class="text-sm text-gray-700 text-left">Out of stock</span>
                </div>
            </template>
                    </div>
    </div>
</div>
        </template>
    </div>
</div>
                        </template>

                        <div class="p-4 box-border w-full h-full flex" x-show="noResultsFound && !errorMessage" x-cloak>
                            <div
                                class="text-center flex align-center w-full text-xl justify-center content-center flex-row bg-gray-100 items-center flex-wrap h-full max-h-[90vh] word-break"
                                x-html="'😔 We could not find anything for&nbsp;<strong>&quot;%s&quot;</strong>'.replace('%s', latestQuery)">
                            </div>
                        </div>

                        <div class="p-4 box-border w-full h-full flex" x-show="noResultsFound && errorMessage" x-cloak>
                            <div
                                class="text-center flex align-center w-full text-xl justify-center content-center flex-row bg-gray-100 items-center flex-wrap h-full max-h-[90vh] word-break"
                                x-html="errorMessage">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </template>
    </div>
</div>



<script>
    function amXsearchRecentSearches() {
        return {
            recentSearchesItems() {
                return this.sections.recentSearches.items
            },

            recentSearchesLink() {
                return this.resultPageUrl + this.searchItem.name.toLowerCase().replace(/<[^>]*>?/gm, '');
            },

            recentSearchesItemName() {
                return this.searchItem.name
            },

            recentSearchesTitle() {
                return this.sections.recentSearches.title
            }
        }
    }
</script>

<script>
    function amXsearchRecentlyViewed() {
        return {
            goToItemButtonAriaLabel() {
                return `${this.$el.dataset.label} ` + (this.item)
            },
            recentlyViewedPopupClass() {
                return { 'lg:w-1/3 xl:w-1/4' : this.isDefaultSearchInput ||
                    this.isFullWidthSearch || (!this.isDefaultSearchInput && this.searchPopupWidth > 1000 )
                }
            },
            previousButtonClass() {
                return {
                    'opacity-25 pointer-events-none': this.slider.recentlyViewed.active === 0
                }
            },
            goToItemButtonClass() {
                return {
                    'bg-opacity-100': this.slider.recentlyViewed.isActive(this.item - 1),
                    'bg-opacity-25': !this.slider.recentlyViewed.isActive(this.item - 1),
                    'hidden': (
                        this.slider.recentlyViewed.pageSize !== 1
                        && !!((this.item - 1) % this.slider.recentlyViewed.pageSize)
                    )
                }
            },
            nextButtonClass() {
                return {
                    'opacity-25 pointer-events-none':
                        this.slider.recentlyViewed.active >= this.slider.recentlyViewed.itemCount - this.slider.recentlyViewed.pageSize
                }
            },
            previousButtonClickEvent() {
                return this.slider.recentlyViewed.prev()
            },
            goToItemButtonClickEvent() {
                return this.slider.recentlyViewed.scrollTo(this.item - 1)
            },
            nextButtonClickEvent() {
                return this.slider.recentlyViewed.next()
            },
            enterOnceEvent() {
                return this.slider.recentlyViewed.init(this.$refs)
            },
            recentlyViewedItems() {
                return this.sections.recentlyViewed.items
            },
            recentlyViewedItemCount() {
                return this.slider.recentlyViewed.itemCount
            },
            isPages() {
                return this.slider.recentlyViewed.itemCount > this.slider.recentlyViewed.pageSize
            },
            previousButtonKeydownEnterEvent() {
                return this.slider.recentlyViewed.prev()
            },
            goToItemButtonKeydownEnterEvent() {
                return this.slider.recentlyViewed.scrollTo(this.item - 1)
            },
            nextButtonKeydownEnterEvent() {
                return this.slider.recentlyViewed.next()
            },
            previousButtonKeydownSpaceEvent() {
                return this.slider.recentlyViewed.prev()
            },
            goToItemButtonKeydownSpaceEvent() {
                return this.slider.recentlyViewed.scrollTo(this.item - 1)
            },
            nextButtonKeydownSpaceEvent() {
                return this.slider.recentlyViewed.next()
            },
            resizeWindowEvent() {
                return this.slider.recentlyViewed.onResize()
            },
            scrollEvent() {
                return this.slider.recentlyViewed.calcActive()
            },
            recentlyViewedTitle() {
                return this.sections.recentlyViewed.title
            }
        }
    }
</script>

<script>
    function amXsearchPopularSearches() {
        return {
            popularSearchesItems() {
                return this.sections.popularSearches.items
            },
            popularSearchesItemUrl() {
                return this.resultPageUrl + this.searchItem.name.toLowerCase().replace(/<[^>]*>?/gm, '')
            },
            popularSearchesItemName() {
                return this.searchItem.name
            },
            popularSearchesTitle() {
                return this.sections.popularSearches.title
            }
        }
    }
</script>

<script>
    function amXsearchProducts() {
        return {
            productsItems() {
                return (this.sections.products.items || [])
            },
            latestQueryUrl() {
                return this.resultPageUrl + encodeURIComponent(this.latestQuery)
            },
            isShowResultProducts() {
                return this.getResultProductsCount() >= 1
            },
            productsTitle() {
                return this.sections.products.title
            },
            productsTotalCount() {
                return this.sections.products.total_count
            }
        }
    }
</script>

<script>
    function amXsearchPages() {
        return {
            pageItems() {
                return this.sections.page.items
            },
            pageItemUrl() {
                return `${BASE_URL + this.item.url}`
            },
            itemTitle() {
                return this.item.title
            },
            itemDescription() {
                return this.item.description
            },
            pageTitle() {
                return this.sections.page.title
            }
        }
    }
</script>

<script>
    function amXsearchLandingPages() {
        return {
            landingPageItems() {
                return this.sections.landingPage.items
            },
            landingPageItemUrl() {
                return window.BASE_URL + this.item.url
            },
            landingPageitemTitle() {
                return this.item.title
            },
            landingPageTitle() {
                return this.sections.landingPage.title
            }
        }
    }
</script>

<script>
    function amXsearchFaq() {
        return {
            faqItems() {
                return this.sections.faq.items
            },
            faqItemUrl() {
                return window.BASE_URL + this.item.url
            },
            faqItemName() {
                return this.item.name
            },
            faqTitle() {
                return this.sections.faq.title
            }
        }
    }
</script>

<script>
    function amXsearchFaqQuestions() {
        return {
            faqQuestionsItems() {
                return this.sections.faq.items
            },
            faqQuestionsItemUrl() {
                return window.BASE_URL + this.item.url
            },
            faqQuestionsItemName() {
                return this.item.name
            },
            faqQuestionsTitle() {
                return this.sections.faq.title
            }
        }
    }
</script>

<script>
    function amXsearchCategory() {
        return {
            categoryItems() {
                return this.sections.category.items
            },
            categoryItemUrl() {
                return window.BASE_URL + this.item.url
            },
            categoryItemName() {
                return this.item.name
            },
            categoryItemDescription() {
                return this.item.description
            },
            categoryTitle() {
                return this.sections.category.title
            }
        }
    }
</script>

<script>
    function amXsearchBrowsingHistory() {
        return {
            browsingHistoryItems() {
                return this.sections.browsingHistory.items
            },
            browsingHistoryItemUrl() {
                return this.resultPageUrl + this.searchItem.name.toLowerCase().replace(/<[^>]*>?/gm, '')
            },
            browsingHistoryItemName() {
                return this.searchItem.name
            },
            browsingHistoryTitle() {
                return this.sections.browsingHistory.title
            }
        }
    }
</script>

<script>
    function amXsearchBrands() {
        return {
            brandItems() {
                return this.sections.brand.items
            },
            brandItemUrl() {
                return `${BASE_URL + this.item.url}`
            },
            brandItemName() {
                return this.item.name
            },
            brandTitle() {
                return this.sections.brand.title
            }
        }
    }
</script>

<script>
    function amXsearchBlog() {
        return {
            blogItems() {
                return this.sections.blog.items
            },
            blogItemUrl() {
                return window.BASE_URL + this.item.url
            },
            blogItemTitle() {
                return this.item.title
            },
            blogItemDescription() {
                return this.item.description
            },
            blogTitle() {
                return this.sections.blog.title
            }
        }
    }
</script>

<script>
    function amXsearchBestsellers() {
        return {
            bestsellersGoToItemAriaLabel() {
                return `${this.$el.dataset.label} ` + (this.index + 1)
            },
            bestsellersPreviousClass() {
                return {
                    'opacity-25 pointer-events-none': this.slider.bestsellers.active === 0
                }
            },
            bestsellersGoToItemClass() {
                return {
                    'bg-opacity-100': this.slider.bestsellers.isActive(this.index),
                    'bg-opacity-25': !this.slider.bestsellers.isActive(this.index),
                    'hidden': (this.slider.bestsellers.pageSize !== 1 && !!(this.index % this.slider.bestsellers.pageSize))
                }
            },
            bestsellersNextClass() {
                return {
                    'opacity-25 pointer-events-none':
                        this.slider.bestsellers.active >= this.slider.bestsellers.itemCount - this.slider.bestsellers.pageSize
                }
            },
            bestsellersPreviousEvent() {
                return this.slider.bestsellers.prev()
            },
            bestsellersGoToItemEvent() {
                return this.slider.bestsellers.scrollTo(this.index)
            },
            bestsellersNextEvent() {
                return this.slider.bestsellers.next()
            },
            bestsellersEnterOnceEvent() {
                return this.slider.bestsellers.init(this.$refs)
            },
            bestsellersItems() {
                return this.sections.bestsellers.items
            },
            bestsellersItemCount() {
                return this.slider.bestsellers.itemCount
            },
            isBestsellersPages() {
                return this.slider.bestsellers.itemCount > this.slider.bestsellers.pageSize
            },
            bestsellersResizeWindowEvent() {
                return this.slider.bestsellers.onResize()
            },
            bestsellersScrollEvent() {
                return this.slider.bestsellers.calcActive()
            },
            bestsellersTitle() {
                return this.sections.bestsellers.title
            }
        }
    }
</script>

<script>
    function amXsearchProduct() {
        return {
            productSmallImageLabel() {
                return this.product.small_image.label
            },
            productItemViewClass() {
                return {
                    'flex-1': !this.config.isGridView,
                    'flex-row mb-5 list-view': this.config.isGridView && (this.isFullWidthSearch || this.isDefaultSearchInput || this.searchPopupWidth > 900),
                    'flex-col mt-2 w-full md:w-auto md:max-w-md': !this.config.isGridView && (!this.isFullWidthSearch || !this.isDefaultSearchInput || this.searchPopupWidth <= 900)
                }
            },
            productSmallImageWrapperClass() {
                return { 'md:w-1/6 md:mb-0 mr-5': this.config.isGridView }
            },
            productSmallImageClass() {
                return { 'min-w-52': !this.config.isGridView }
            },
            productInfoClass() {
                return {
                    'md:text-left': this.config.isGridView,
                    'text-center': !this.config.isGridView
                }
            },
            productDescriptionClass() {
                return {
                    'text-left': this.config.isGridView,
                    'text-center': !this.config.isGridView
                }
            },
            productActionsWrapperClass() {
                return {
                    'mt-auto': !this.config.isGridView,
                    'flex-wrap': this.config.isGridView && this.config.isProductAddToCartBlockEnabled && this.product.is_salable,
                    'justify-start': this.config.isGridView
                }
            },
            productAddToCartButtonClass() {
                return {
                    'mr-auto w-auto': !this.config.isGridView,
                    'w-full sm:w-auto mb-3 sm:mb-0': this.config.isGridView
                }
            },
            productAddToCartButtonClickEvent(event) {
                return this.addToCart(this.product, this.$event)
            },
            productAddToWishlistClickEvent() {
                return this.addToWishlist(this.product)
            },
            productAddToCompareClickEvent() {
                return this.addToCompare(this.product)
            },
            productUrl() {
                return this.getProductUrl(this.product)
            },
            productNameHtml() {
                return this.product.name
            },
            productSku() {
                return this.product.sku
            },
            productDescriptionHtml() {
                return this.truncateWithDots(
                    this.product.short_description.html,
                    this.config.shortDescriptionLength
                )
            },
            isShowProductSkuConfig() {
                return this.config.isShowSku
            },
            isProductReviewsBlockEnabledConfig() {
                return this.config.isProductReviewsBlockEnabled
            },
            isProductAddToCartBlockEnabledAndSalable() {
                return this.config.isProductAddToCartBlockEnabled && this.product.is_salable
            },
            isProductAddToCartButtonEnabled() {
                return this.isProductAddToCartBlockEnabledAndSalable() &&
                    !this.productAmHidePriceAddtocart() &&
                    !this.productHidePriceNewAddToCart()
            },
            productSmallImageUrl() {
                return this.getProductImageUrl(this.product)
            },
            productAmHidePriceAddtocart() {
                return this.product.am_hide_price_addtocart || false;
            },
            productHidePriceNewAddToCart() {
                return this.product.hide_price_newAddToCart || '';
            },
            productAmHidePriceWishlist() {
                return this.product.am_hide_price_wishlist || false;
            },
            isNotProductAmHidePriceWishlist() {
                return !this.productAmHidePriceWishlist()
            },
            productAmHidePriceCompare() {
                return this.product.am_hide_price_compare || false;
            },
            isNotProductAmHidePriceCompare() {
                return !this.productAmHidePriceCompare()
            },
            isProductOutOfStock() {
                return this.isProductAddToCartBlockEnabledConfig() && !this.productIsSalable()
            },
            isProductAddToCartBlockEnabledConfig() {
                return this.config.isProductAddToCartBlockEnabled || false;
            },
            productIsSalable() {
                return this.product.is_salable || false;
            }
        }
    }
</script>

<script>
    function amXsearchRating() {
        return {
            ratingWrapperClass() {
                return {
                    'mx-0 w-full': this.config.isGridView,
                    'mx-auto': !this.config.isGridView
                }
            },
            ratingSummaryClass() {
                return {
                    'flex items-center': this.config.isGridView && !this.product.isSliderItem
                }
            },
            svgFill() {
                return 'url(#partialFill' + this.product.id + ')'
            },
            ratingStarsFilled() {
                return this.product.ratingData.starsFilled
            },
            ratingStarsEmpty() {
                return this.product.ratingData.starsEmpty
            },
            productUrl() {
                return `${this.getProductUrl(this.product)}`
            },
            productReviewsCountHtml() {
                return this.product.reviews_count
            },
            svgProductId() {
                return 'partialFill' + this.product.id
            },
            isRatingStarFragment() {
                return this.product.ratingData.starFragment > 0
            },
            isProductRatingSummary() {
                return this.product.rating_summary > 0
            },
            ratingStarFragmentPercent() {
                return this.product.ratingData.starFragment * 100 + '%'
            },
            ratingStarYellowHex() {
                return this.product.ratingData.yellowHex
            },
            ratingStarGreyHex() {
                return this.product.ratingData.greyHex
            },
            ratingStarYellowStyle() {
                return `color: ${this.product.ratingData.yellowHex}`
            },
            ratingStarGreyStyle() {
                return `color: ${this.product.ratingData.greyHex}`
            },
            ratingSummaryTitle() {
                return this.product.rating_summary === 0 ? `${this.$el.dataset.title}` : ''
            }
        }
    }
</script>

<script>
    function amXsearchProductItem() {
        return {
            productItemSmallImageLabel() {
                return this.product.small_image.label
            },
            productItemAddToCartClickEvent(event) {
                return this.addToCart(this.product, this.$event)
            },
            productItemAddToWishlistClickEvent() {
                return this.addToWishlist(this.product)
            },
            productItemAddToCompareClickEvent() {
                return this.addToCompare(this.product)
            },
            productItemUrl() {
                return this.getProductUrl(this.product)
            },
            productItemName() {
                return this.product.name
            },
            isShowProductItemSkuConfig() {
                return this.config.isShowSku
            },
            isProductItemReviewsBlockEnabledConfig() {
                return this.config.isProductReviewsBlockEnabled
            },
            isProductItemAddToCartBlockEnabledAndSalable() {
                return this.config.isProductAddToCartBlockEnabled && this.product.is_salable
            },
            ['!isProductItemAddToCartBlockEnabledAndSalable']() {
                return this.config.isProductAddToCartBlockEnabled && !this.product.is_salable
            },
            productItemSmallImageUrl() {
                return this.getProductImageUrl(this.product)
            },
            productItemSku() {
                return this.product.sku
            }
        }
    }
</script>

<script>
    function advancedSearchPriceComponentData() {
        return Object.assign(
            {
                ...amXsearchPriceComponent(this.product)
            }, {
                isPriceInclAndExclTax() {
                    return this.product.price_range?.minimum_price?.regular_price && !this.product?.hide_price_html
                }
            }
        )
    }
    function hidePriceHandler(el) {
        return {
            el,
            productId: null,

            init() {
                this.productId = this.el.dataset.productId;

                const observer = new MutationObserver(() => {
                    const selector = `a[data-amhide="AmastyHidePricePopup"][data-product-id="${this.productId}"]`;
                    const linkNode = this.el.querySelector(selector) ?? document.querySelector(selector);

                    if (linkNode) {
                        linkNode.addEventListener('click', () => {
                            const event = new CustomEvent('open-am-hideprice-popup', {
                                detail: {
                                    productId: this.productId,
                                    productName: this.cleanText(this.el.dataset.name),
                                },
                            });
                            window.dispatchEvent(event);
                        });
                        observer.disconnect();
                    }
                });

                observer.observe(document.body, { childList: true, subtree: true });
            },

            cleanText(input) {
                const div = document.createElement('div');
                div.innerHTML = input;
                return (div.textContent || div.innerText || '').replace(/\s+/g, ' ').trim();
            },
        }
    }

    window.addEventListener(
        'alpine:init',
        () => {
            Alpine.data('advancedSearchPriceComponentData', advancedSearchPriceComponentData);
            Alpine.data('hidePriceHandler', hidePriceHandler);
        },
        { once: true }
    );
</script>

<script>
    function amXsearchHeaderScripts() {
        return Object.assign(
            amXsearchRecentSearches(),
            amXsearchRecentlyViewed(),
            amXsearchPopularSearches(),
            amXsearchProducts(),
            amXsearchPages(),
            amXsearchLandingPages(),
            amXsearchFaq(),
            amXsearchFaqQuestions(),
            amXsearchCategory(),
            amXsearchBrowsingHistory(),
            amXsearchBrands(),
            amXsearchBlog(),
            amXsearchBestsellers(),
            amXsearchProduct(),
            amXsearchRating(),
            amXsearchProductItem()
        )
    }
</script>

<script>
    'use strict';
    function searchButtonsComponent() {
        return {
            showClearBtn: false,
            searchValue: null,
            init: function () {
                this.$watch('searchValue', (value) => {
                    this.showClearBtn = value && this.showOverlay;
                })
            },
            checkClearBtn: function () {
                this.showClearBtn = !!this.searchValue;
            }
        }
    }
</script>
        </div>
    </div>

    <!--Cart Drawer-->
    
<script>
    function initCartDrawer() {
        return {
            open: false,
            isLoading: false,
            cart: {},
            maxItemsToDisplay: 10,
            itemsCount: 0,
            showSku: true,
            freeShippingBarEnabled: 1,
            freeShippingBarMinAmount: 1,
            freeShippingProgress: 0,
            freeShippingDifference: 0,
            freeShippingEligible: false,
            getData(data) {
                if (data.cart) {
                    if (this.freeShippingBarEnabled && this.freeShippingBarMinAmount && this.cart.subtotalAmount != data.cart.subtotalAmount) {
                        this.updateFreeShippingProgress();
                    }
                    this.cart = data.cart;
                    this.itemsCount = data.cart.items && data.cart.items.length || 0;
                    this.setCartItems();
                }
                this.isLoading = false;
            },
            cartItems: [],
            getItemCountTitle() {
                return hyva.strf('\u00250\u0020of\u0020\u00251\u0020products\u0020in\u0020cart\u0020displayed', this.maxItemsToDisplay, this.itemsCount)
            },
            setCartItems() {
                this.cartItems = this.cart.items && this.cart.items.sort((a, b) => b.item_id - a.item_id) || [];

                if (this.maxItemsToDisplay > 0) {
                    this.cartItems = this.cartItems.slice(0, parseInt(this.maxItemsToDisplay, 10));
                }
            },
            updateItemQty(form) {
                if (!form.action) return;
                this.isLoading = true;
                const action = form.action;
                const formData = new FormData(form);
                formData.append('form_key', hyva.getFormKey());

                if (!formData.uenc) {
                    formData.append('uenc', hyva.getUenc());
                }

                fetch(action, {
                    body: formData,
                    method: 'POST',
                    mode: "cors",
                    credentials: "include"
                }).then((result) => {
                    return result.text()
                }).then((content) => {
                    window.dispatchEvent(new CustomEvent("reload-customer-section-data"));
                }).catch((error) => {
                    window.dispatchMessages && window.dispatchMessages([{
                        type: 'error',
                        text: 'Something\u0020went\u0020wrong.\u0020Please\u0020try\u0020again.'
                    }]);
                }).finally(() => {
                    this.isLoading = false;
                })
            },
            deleteItemFromCart(itemId) {
                this.isLoading = true;

                const formKey = hyva.getFormKey();
                const postUrl = BASE_URL + 'checkout/sidebar/removeItem/';

                fetch(postUrl, {
                    headers: {
                        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                    },
                    body: "form_key=" + formKey + "&item_id=" + itemId,
                    method: "POST",
                    mode: "cors",
                    credentials: "include"
                }).then(response => {
                    if (response.redirected) {
                        window.location.href = response.url;
                    } else if (response.ok) {
                        return response.json();
                    } else {
                        window.dispatchMessages && window.dispatchMessages([{
                            type: 'warning',
                            text: 'Could\u0020not\u0020remove\u0020item\u0020from\u0020quote.'
                        }]);
                        this.isLoading = false;
                    }
                }).then(result => {
                    window.dispatchMessages && window.dispatchMessages([{
                        type: result.success ? 'success' : 'error',
                        text: result.success
                            ? 'You\u0020removed\u0020the\u0020item.'
                            : result.error_message
                    }], result.success ? 5000 : 0)
                    window.dispatchEvent(new CustomEvent('reload-customer-section-data'));
                });
            },
            scrollLock(use = true) {
                document.documentElement.style.scrollbarGutter = use ? "stable" : "";
                document.body.style.overflow = use ? "hidden" : "";
            },
            toggleCartDrawer(event) {
                if (event.detail && event.detail.isOpen) {
                    this.open = event.detail.isOpen;
                } else {
                    this.open = !this.open;
                }

                if (this.open) {
                    this.$root.showModal();
                } else {
                    this.$root.close();
                }

                this.scrollLock(this.open);
            },
            openCartDrawer() {
                this.$root.showModal();
                this.open = true;
                this.scrollLock(true);
            },
            closeCartDrawer() {
                this.$root.close();
                this.open = false;
                this.scrollLock(false);
            },
            getSectionDataExtraActions() {
                if (!this.cart.extra_actions || typeof hyva.activateScripts === "undefined") {
                    return '';
                }

                const contentNode = document.createElement('div');
                contentNode.innerHTML = this.cart.extra_actions;
                hyva.activateScripts(contentNode);

                return contentNode.innerHTML;
            },
            onDialogBackdropClickHelper(event, target) {
                const rect = target.getBoundingClientRect();
                const isInDialog =
                    rect.top <= event.clientY &&
                    event.clientY <= rect.top + rect.height &&
                    rect.left <= event.clientX &&
                    event.clientX <= rect.left + rect.width;
                return isInDialog;
            },
            updateFreeShippingProgress() {
                fetch('https://www.masterbooks.com/freeshipping/cart/freeshippingprogress/', {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    credentials: 'include'
                })
                    .then(response => response.json())
                    .then(data => {
                        this.freeShippingProgress = data.progress;
                        this.freeShippingDifference = data.difference;
                        this.freeShippingEligible = data.eligible;
                    })
                    .catch(error => console.error('Error fetching free shipping progress:', error));
            },
            cartListeners: {
                ['@private-content-loaded.window'](event) {
                    this.getData(event.detail.data);
                },
                ['@click'](event) {
                    if (this.onDialogBackdropClickHelper(event, this.$root)) return;
                    this.closeCartDrawer();
                },
                ['@toggle-cart.window'](event) {
                    this.toggleCartDrawer(event);
                },
                ['@keydown.window.escape']() {
                    this.closeCartDrawer();
                }
            }
        }
    }
</script>

<dialog
        id="cart-drawer"
        aria-labelledby="cart-drawer-title"
        class="z-30 fixed inset-0 flex flex-col py-6 px-4 [&_>*]:px-2 gap-y-8 max-h-screen max-w-full h-full mr-0 w-[480px] md:w-[640px]
        transition ease-in-out shadow-2xl bg-gray-50 text-slate-800 backdrop:bg-black/25 backdrop:backdrop-blur-xs"
        x-show="open"
        x-transition:enter="duration-700"
        x-transition:enter-start="translate-x-full"
        x-transition:enter-end="translate-x-0"
        x-transition:leave="duration-500"
        x-transition:leave-start="translate-x-0"
        x-transition:leave-end="translate-x-full"
        x-ref="cartDialogContent"
        x-data="initCartDrawer()"
        x-bind="cartListeners"
        x-cloak
>
    
    <div class="flex gap-2 justify-between items-center">
        <p id="cart-drawer-title" class="text-2xl">
            <strong>My Cart</strong>
            <span
                    class="items-total text-xs"
                    x-show="maxItemsToDisplay && maxItemsToDisplay < itemsCount"
                    x-text="getItemCountTitle()"
            ></span>
        </p>
        <button
                type="button"
                class="btn justify-center rounded-full p-2.5 text-base text-slate-700 shadow-none hover:shadow-lg active:shadow disabled:shadow-none transition
                bg-white border border-primary hover:bg-white focus:ring-primary-lighter disabled:bg-white disabled:border-slate-200 disabled:text-slate-600 disabled:opacity-70"
                @click="closeCartDrawer"
                aria-label="Close&#x20;minicart"
        >
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="20" height="20" aria-hidden="true">
  <path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
</svg>
        </button>
    </div>

    
    <template x-if="!itemsCount">
        <div class="grow grid place-items-center">
            <div class="text-center">
                <div class="max-w-full max-h-full aspect-square w-44 h-44 inline-flex items-center justify-center rounded-full
                    bg-primary outline-2 outline-dashed outline-offset-8">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="120" height="120" aria-hidden="true">
  <path d="M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3zM16 16.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM6.5 18a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"/>
</svg>
                </div>
                <p class="mt-10 text-xl">
                    <strong>Your cart is empty</strong>
                </p>
                <p class="text-slate-500">
                    Looks like you haven&#039;t made your choice yet.                </p>
            </div>
        </div>
    </template>

    <template x-if="itemsCount">
        <ul class="grow flex flex-col overflow-y-auto overscroll-y-contain mask-overflow mask-dir-y">
            <template x-for="item in cartItems">
                <li class="flex gap-4 md:gap-6 items-start py-7 border-b border-slate-200">
                    <a
                            class="block block max-w-[19%] basis-1/2"
                            :href="item.product_url"
                            :title="hyva.str('Product\u0020\u0022\u00251\u0022', item.product_name)"
                    >
                        
<!-- Render picture tag when webp or avif existed -->
<picture>
        <source type="image/webp" :srcset="item.product_image.src_webp">
        <source :srcset="item.product_image.src">
        <img
                                :src="item.product_image.src"
                                :width="item.product_image.width"
                                :height="item.product_image.height"
                                loading="lazy"
                                :alt="hyva.str('Product\u0020\u0022\u00251\u0022', item.product_name)"
                                class="imgCustomShadow w-4/5 h-auto mx-auto"
                        /></picture>

                    </a>
                    <div class="grow space-y-4">
                        <div class="flex gap-2 justify-between items-center">
                            <p class="text-lg">
                                                                <strong x-html="item.product_name"></strong>
                            </p>
                            <span class="[&_.price]:font-normal" x-html="item.product_price"></span>
                        </div>
                        <template x-if="showSku">
                            <dl class="table text-sm">
                                <template x-if="showSku">
                                    <div class="table-row">
                                        <dt class="table-cell font-normal text-slate-500 min-w-[theme(spacing.16)] pr-2 pb-2">
                                            SKU                                        </dt>
                                        <dd class="table-cell pb-2 font-bold" x-html="item.product_sku"></dd>
                                    </div>
                                </template>
                            </dl>
                        </template>
                        <template x-if="item.options && item.options.length">
                            <dl class="table text-sm">
                                <template x-for="option in item.options">
                                    <div class="table-row">
                                        <!--<dt
                                                class="table-cell font-normal text-slate-500 min-w-[theme(spacing.16)] pr-2 pb-2"
                                                x-text="option.label"
                                        ></dt>-->
                                        <dd class="table-cell pb-2" x-html="option.value"></dd>
                                    </div>
                                </template>
                            </dl>
                        </template>
                        <div class="flex flex-wrap gap-2 justify-between items-center">
                                                            <form
                                        action="https://www.masterbooks.com/checkout/cart/updatePost/"
                                        x-data="{
                                        initQty: item.qty,
                                        itemQty: item.qty,
                                        prevQty: item.qty,
                                        updateQty() {
                                            const submitEvent = new Event('submit', { cancelable: true });
                                            this.$root.dispatchEvent(submitEvent);
                                        },
                                        setQtyDefaults() {
                                            this.initQty = item.qty;
                                            this.itemQty = item.qty;
                                            this.prevQty = item.qty;
                                        }
                                    }"
                                        @submit.prevent="updateItemQty($event.target);"
                                        x-init="$watch('item.qty', () => setQtyDefaults());"
                                        method="post"
                                        class="form form-cart flex gap-1"
                                >
                                    <input name="form_key" type="hidden" value="zoOV9lBFMarBAz0K" />                                                                        <label class="mb-0">
                                        <span class="sr-only">Qty</span>
                                        <input
                                                type="number"
                                                class="qty border-slate-300 shadow-none [-moz-appearance:textfield]
                                                form-input                                                w-20                                                hover:[-moz-appearance:auto] [&::-webkit-inner-spin-button]:invisible hover:[&::-webkit-inner-spin-button]:visible"
                                                required
                                                min="0"
                                                step="any"
                                                x-model.number="itemQty"
                                                :id="`minicart-${item.item_id}-qty`"
                                                :name="`cart[${item.item_id}][qty]`"
                                                                                                                                                                            >
                                    </label>
                                                                                                                <button
                                                type="submit"
                                                class="btn justify-center w-11 p-2 text-base shadow-none hover:shadow-lg active:shadow disabled:shadow-none transition
                                                !bg-primary text-white border border-transparent hover:bg-primary-lighter focus:ring-primary-lighter active:bg-primary
                                                disabled:bg-slate-600 disabled:text-slate-50 disabled:opacity-70 disabled:invisible"
                                                :disabled="itemQty === initQty || itemQty === null"
                                                :aria-label="hyva.str(
                                                'Update\u0020qty\u0020for\u0020\u0022\u00251\u0022',
                                                item.product_name
                                            )"
                                        >
                                            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="20" height="20" aria-hidden="true">
  <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
</svg>
                                        </button>
                                                                    </form>
                                                        <div class="inline-flex flex-wrap items-center gap-1">
                                <a
                                        :href="item.configure_url"
                                        x-show="item.product_type !== 'grouped'"
                                        class="btn btn-primary justify-center rounded-full p-2 text-base shadow-none hover:shadow-lg active:shadow transition
                                        active:bg-primary disabled:bg-slate-50 disabled:text-slate-600 disabled:opacity-70"
                                        :aria-label="hyva.str(
                                        'Edit\u0020product\u0020\u0022\u00251\u0022',
                                        item.product_name
                                    )"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="20" height="20" aria-hidden="true">
  <path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"/>
</svg>
                                </a>
                                <button
                                        type="button"
                                        class="btn justify-center rounded-full p-2 text-base shadow-none hover:shadow-lg active:shadow disabled:shadow-none transition
                                        bg-white text-slate-700 border border-slate-400 hover:bg-white focus:ring-slate-200 disabled:bg-white disabled:border-slate-200 disabled:text-slate-600 disabled:opacity-70"
                                        @click="deleteItemFromCart(item.item_id)"
                                        :aria-label="hyva.str(
                                        'Remove\u0020product\u0020\u0022\u00251\u0022\u0020from\u0020cart',
                                        item.product_name
                                    )"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="20" height="20" aria-hidden="true">
  <path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd"/>
</svg>
                                </button>
                            </div>
                        </div>
                    </div>
                </li>
            </template>
        </ul>
    </template>

    <template x-if="itemsCount && freeShippingBarEnabled && freeShippingBarMinAmount">
        <div class="freeship-progress">
            <template x-if="!freeShippingEligible">
                <div>
                    <p class="upsell">
                        Add <span class="freeship-price" x-text="freeShippingDifference"></span> more to get <span class="freeship-bold">FREE SHIPPING!</span> <span class="freeship-stipulation">(Within contiguous USA)</span>                    </p>
                    <div class="freeship-progress-bar-wrapper">
                        <span class="min">$0</span>
                        <div class="freeship-progress-bar">
                            <div class="freeship-progress-bar-bg">
                                <div class="freeship-progress-bar-fill freeship-progress-bar-progress"
                                     :style="'width: ' + freeShippingProgress + '%; background: linear-gradient(to right, #00b052 0%, #00b052 ' + freeShippingProgress + '%, lightgreen);'"
                                ></div>
                            </div>
                        </div>
                        <span class="max">
                        $75                    </span>
                    </div>
                </div>
            </template>
            <template x-if="freeShippingEligible">
                <div class="freeship-text">
                    <p>
                        Your order is eligible for <span class="freeship-bold">FREE SHIPPING!</span> <span class="freeship-stipulation">(Within contiguous USA)</span>                    </p>
                </div>
            </template>
        </div>
    </template>

    
    <template x-if="itemsCount">
        <div>
            
            <dl class="flex gap-2 justify-between items-center text-sm font-bold">
                <dt class="text-slate-500">Subtotal</dt>
                <dd x-html="cart.subtotal"></dd>
            </dl>

            <div class="flex flex-col gap-y-4 mt-8">
                <a
                        @click.prevent.stop="closeCartDrawer; $dispatch(
                        'toggle-authentication',
                        { url: 'https://www.masterbooks.com/checkout/' }
                    );"
                        href="https://www.masterbooks.com/checkout/"
                        class="btn btn-primary justify-center py-3 px-6 text-base shadow-none hover:shadow-lg active:shadow transition
                        text-white border border-transparent"
                >
                    Checkout                </a>
                <a
                        href="https://www.masterbooks.com/checkout/cart/"
                        class="btn justify-center py-3 px-6 text-base text-slate-700 shadow-none hover:shadow-lg active:shadow transition
                        bg-white border border-primary hover:bg-white focus:ring-primary-lighter"
                >
                    View and Edit Cart                </a>
                <div x-html="getSectionDataExtraActions()"></div>
                            </div>
        </div>
    </template>

    <template x-if="!itemsCount">
        <div class="flex flex-col">
            <button
                    type="button"
                    @click="closeCartDrawer"
                    class="btn justify-center py-3 px-6 text-base shadow-none hover:shadow-lg active:shadow disabled:shadow-none transition
                    bg-primary text-white border border-transparent hover:bg-primary-lighter focus:ring-primary active:bg-primary disabled:bg-slate-600 disabled:text-slate-50 disabled:opacity-70"
            >Continue shopping</button>
        </div>
    </template>

    
    <div
    class="z-50 fixed inset-0 flex justify-center items-center bg-white/70 select-none"
    x-show="isLoading"
    x-cloak
    x-transition.opacity.duration.200ms
>
    <div class="flex items-center">
        <svg xmlns="http://www.w3.org/2000/svg" width="54" height="54" viewBox="0 0 50 50" aria-hidden="true">
    <path fill="#d9dddd" d="M43.935 25.145c0-10.318-8.364-18.683-18.683-18.683-10.318 0-18.683 8.365-18.683 18.683h4.068c0-8.071 6.543-14.615 14.615-14.615s14.615 6.543 14.615 14.615h4.068z">
        <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/>
    </path>
</svg>
        <div class="ml-10 text-xl">
            Loading...        </div>
    </div>
</div>
</dialog>

    <!--Authentication Pop-Up-->
    <!-- BLOCK authentication-popup --><script>
    function initAuthentication() {
        return {
            open: false,
            close() {
                this.open = false;
            },
            forceAuthentication: false,
            checkoutUrl: 'https://www.masterbooks.com/checkout/index/',
            errors: 0,
            hasCaptchaToken: 0,
            displayErrorMessage: false,
            errorMessages: [],
            setErrorMessages(message) {
                this.errorMessages = [message];
                this.displayErrorMessage = true;
            },
            submitForm() {
                // Do not rename $form, the variable is expected to be declared in the recaptcha output
                const $form = document.querySelector('#login-form');
                    if (!this.hasCaptchaToken) {
        this.errors = 1;


        const executeGreCaptcha = () => {
            grecaptcha.ready(() => {
                grecaptcha.execute(
                    '6LceWLgUAAAAAH7dwYx36tmo_UKPXJUNRLcGWaEo',
                    {action: 'submit'}
                ).then((token) => {
                    const tokenElement = $form['g\u002Drecaptcha\u002Dresponse'];

                    if (tokenElement && token && token.length > 0) {
                        $form['g\u002Drecaptcha\u002Dresponse'].value = token;
                        this.errors = 0;
                        this.hasCaptchaToken = 1;
                        (this.submitForm || $form.submit).call(this);
                    } else {
                        this.errors = 1;
                        const error = tokenElement
                            ? 'ReCaptcha\u0020validation\u0020failed,\u0020please\u0020try\u0020again'
                            : 'ReCaptcha\u0020token\u0020element\u0020is\u0020missing.\u0020Please\u0020refresh\u0020the\u0020page\u0020and\u0020trying\u0020again.';
                        if (this.setErrorMessages) {
                            this.setErrorMessages([error])
                            this.displayErrorMessage = true;
                        } else {
                            window.dispatchMessages && window.dispatchMessages([{type: "error", text: error}], 5000);
                        }
                    }
                }).catch(exception => {
                    console.error(exception || `An unknown error occurred during ReCaptcha validation. Are the tokens and the domain correctly set up in the Google console?`)
                });
            })
        }

        if (window.grecaptcha) {
            executeGreCaptcha();
        } else {
            const recaptchaUrl = "https://www.google.com/recaptcha/api.js?render=6LceWLgUAAAAAH7dwYx36tmo_UKPXJUNRLcGWaEo";
            const script = document.createElement('script');
            script.setAttribute('type', 'text/javascript');
            script.setAttribute('src', recaptchaUrl);
            document.head.appendChild(script);

            script.addEventListener("load", executeGreCaptcha, false);
        }
    }

                if (this.errors === 0) {
                    this.dispatchLoginRequest($form);
                }
            },
            onPrivateContentLoaded() {
                const data = this.$event.detail.data;
                const isLoggedIn = data.customer && data.customer.firstname;
                if (data.cart && !isLoggedIn) {
                    this.forceAuthentication = !data.cart.isGuestCheckoutAllowed;
                }
            },
            redirectIfAuthenticated() {
                const event = this.$event;
                this.open = this.forceAuthentication;
                if (event.detail && event.detail.url) {
                    this.checkoutUrl = event.detail.url;
                }
                if (!this.forceAuthentication) {
                    window.location.href = this.checkoutUrl;
                }
            },
            resetErrors() {
                this.errors = 0;
            },
            dispatchLoginRequest(form) {
                this.isLoading = true;
                const username = this.$refs['customer-email'].value;
                const password = this.$refs['customer-password'].value;
                const formKey = hyva.getFormKey();
                const bodyFields = {
                    'username': username,
                    'password': password,
                    'formKey': formKey
                };
                                const fieldName = 'g\u002Drecaptcha\u002Dresponse';
                const recaptchaField = fieldName && form[fieldName];
                if (recaptchaField) {
                    bodyFields[fieldName] = recaptchaField.value;
                }
                fetch('https://www.masterbooks.com/customer/ajax/login/', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                            'X-Requested-With': 'XMLHttpRequest'
                        },
                        body: JSON.stringify(bodyFields)
                    }
                ).then(response => {
                        return response.json()
                    }
                ).then(data => {
                    this.isLoading = false;
                    if (data.errors) {
                        dispatchMessages([{
                            type: 'error',
                            text: data.message
                        }], 5000);
                        this.errors = 1;
                        this.hasCaptchaToken = 0;
                    } else {
                        window.location.href = this.checkoutUrl;
                    }
                });
            }
        }
    }
</script>
<section id="authentication-popup"
         x-data="initAuthentication"
         @private-content-loaded.window="onPrivateContentLoaded"
         @toggle-authentication.window="redirectIfAuthenticated"
         @keydown.window.escape="close"
>
        <div role="dialog"
             aria-modal="true"
             @click.outside="close"
             class="fixed inset-y-0 right-0 z-30 flex max-w-full"
             x-cloak x-show="open"
        >
            <div class="relative w-screen max-w-md pt-16 bg-container-lighter"
                 x-show="open"
                 x-cloak
                 x-transition:enter="transform transition ease-in-out duration-500 sm:duration-700"
                 x-transition:enter-start="translate-x-full"
                 x-transition:enter-end="translate-x-0"
                 x-transition:leave="transform transition ease-in-out duration-500 sm:duration-700"
                 x-transition:leave-start="translate-x-0"
                 x-transition:leave-end="translate-x-full"
            >
                <div
                    x-show="open"
                    x-cloak
                    x-transition:enter="ease-in-out duration-500"
                    x-transition:enter-start="opacity-0"
                    x-transition:enter-end="opacity-100"
                    x-transition:leave="ease-in-out duration-500"
                    x-transition:leave-start="opacity-100"
                    x-transition:leave-end="opacity-0" class="absolute top-0 right-0 flex p-2 mt-2">
                    <button @click="close" aria-label="Close panel"
                            class="p-2 text-gray-300 transition duration-150 ease-in-out hover:text-black">
                        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="24" height="24" role="img">
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
<title>x</title></svg>
                    </button>
                </div>
                <div class="flex flex-col h-full py-6 space-y-6 bg-white shadow-xl overflow-y-auto">
                    <div class="block-customer-login bg-container border border-container mx-4 p-4 shadow-xs">
                        <p id="authenticate-customer-login" class="text-lg leading-7 text-gray-900">
                            <strong class="font-medium">Checkout using your account</strong>
                        </p>

                        <form class="form form-login"
                              method="post"
                              @submit.prevent="submitForm;"
                              id="login-form"
                        >
                            <div class="control">
    <input type="hidden"
           value=""
           name="g-recaptcha-response"
    >
</div>
                            <div class="fieldset login">
                                <div class="field email required">
                                    <label class="label" for="form-login-username" form="login-form" >
                                        <span>Email Address</span>
                                    </label>
                                    <div class="control">
                                        <input name="username"
                                               id="form-login-username"
                                               x-ref="customer-email"
                                               @change="resetErrors"
                                               type="email"
                                               required
                                               class="form-input input-text"
                                        >
                                    </div>
                                </div>
                                <div class="field password required">
                                    <label for="form-login-password" class="label" form="login-form">
                                        <span>Password</span>
                                    </label>
                                    <div class="control">
                                        <input name="password"
                                               id="form-login-password"
                                               type="password"
                                               class="form-input input-text"
                                               required
                                               x-ref="customer-password"
                                               @change="resetErrors"
                                        >
                                    </div>
                                </div>

                                <input name="context" type="hidden" value="checkout" />
                                <div class="actions-toolbar flex justify-between pt-6 pb-2 items-center">
                                    <button type="submit"                                            class="inline-flex btn btn-primary disabled:opacity-75"
                                    >
                                        Sign In                                    </button>
                                    <a href="https://www.masterbooks.com/customer/account/forgotpassword/"
                                    >
                                        Forgot Your Password?                                    </a>
                                </div>

                            </div>
                        </form>
                    </div>
                    <div class="mx-4">
                        <p class="prose my-4 text-sm">
    <em>This form is protected by reCAPTCHA - the <a class="underline" href="https://policies.google.com/privacy" target="_blank" rel="noopener">Google Privacy Policy</a> and <a class="underline" href="https://policies.google.com/terms" target="_blank" rel="noopener">Terms of Service</a> apply.</em>
</p>
                    </div>
                    <div class="block-new-customer bg-container border border-container mx-4 p-4 shadow-xs">
                        <p id="authenticate-new-customer" class="text-lg mb-2 leading-7 text-gray-900">
                            <strong class="font-medium">Checkout as a new customer</strong>
                        </p>

                        <div class="block-content">
                            <p class="mb-1">
                                Creating an account has many benefits:                            </p>
                            <ul class="list-disc pl-5">
                                <li> See order and shipping status</li>
                                <li> Track order history</li>
                                <li> Check out faster</li>
                            </ul>
                            <div class="actions-toolbar flex justify-between mt-6 mb-2 items-center">
                                <a href="https://www.masterbooks.com/customer/account/create/"
                                   class="inline-flex btn btn-primary">
                                    Create an Account                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</section>
<!-- /BLOCK authentication-popup --></div>
    <script src="https&#x3A;&#x2F;&#x2F;cdn.masterbooks.com&#x2F;static&#x2F;version1780560499&#x2F;frontend&#x2F;Ecommerce121&#x2F;masterbooks-hyva&#x2F;en_US&#x2F;Dotdigitalgroup_Email&#x2F;js&#x2F;dotdigital-tag.js"></script>    <script>window.ddg.init("r2", "DM-0120242074-02");</script>
</header><div class="top-container">    <nav class="breadcrumbs" aria-label="Breadcrumb">
        <div class="container px-2 sm:px-8">
            <ol class="items list-reset py-4 rounded flex flex-wrap text-grey text-sm">
                                    <li class="item flex home">
                                                                            <a href="https://www.masterbooks.com/"
                               class="no-underline"
                               title="Go&#x20;to&#x20;Home&#x20;Page"
                            >Home</a>
                                            </li>
                                    <li class="item flex cms_page">
                                                    <span aria-hidden="true" class="separator text-primary-lighter px-2">/</span>
                                                                            <span
                                class="text-primary-lighter"
                                aria-current="page"
                            >Knowledge Quest</span>
                                            </li>
                            </ol>
        </div>
    </nav>
</div><div class="container widget block block-static-block">
    </div>
<div class="container widget block block-static-block">
    </div>
<main id="maincontent" class="page-main flex-grow"><div id="contentarea" tabindex="-1"></div>
<div class="page messages"><script>
        window.defaultSuccessMessageTimeout = 2500;
        function initMessages() {
        "use strict";
        return {
            messages: window.mageMessages || [],
            isEmpty() {
                return this.messages.reduce(
                    function (isEmpty, message) {
                        return isEmpty && message === undefined
                    }, true
                )
            },
            hasMessages() {
                return !this.isEmpty();
            },
            hasMessage() {
                return !!this.message;
            },
            removeMessage() {
                this.messages[this.index] = undefined;
            },
            addMessages(messages, hideAfter) {
                messages.map((message) => {
                    if (!message.text || !message.text.trim()) return;
                    this.messages = this.messages.concat(message);
                    if (hideAfter === undefined && message.type === 'success' && window.defaultSuccessMessageTimeout) {
                        hideAfter = window.defaultSuccessMessageTimeout;
                    }
                    if (hideAfter) {
                        this.setHideTimeOut(this.messages.length -1, hideAfter);
                    }
                });
            },
            setHideTimeOut(messageIndex, hideAfter) {
                setTimeout((messageIndex) => {
                    this.messages[messageIndex] = undefined;
                }, hideAfter, messageIndex);
            },
            eventListeners: {
                ['@messages-loaded.window'](event) {
                    this.addMessages(event.detail.messages, event.detail.hideAfter)
                },
                ['@private-content-loaded.window'](event) {
                    const data = event.detail.data;
                    if (
                        data.messages &&
                        data.messages.messages &&
                        data.messages.messages.length
                    ) {
                        this.addMessages(data.messages.messages);
                    }
                },
                ['@clear-messages.window']() {
                    this.messages = [];
                },
                ['@pageshow.window'](event) {
                    if (event.persisted) {
                        this.messages = [];
                    };
                }
            },
            getMessageUiId() {
                return 'message-' + this.message.type;
            }
        }
    }

    window.addEventListener('alpine:init', () => Alpine.data('initMessages', initMessages), {once: true})
</script>
<section id="messages"
         x-data="initMessages"
         x-bind="eventListeners"
         role="alert"
>
    <template x-if="hasMessages">
        <div class="w-full">
            <div class="messages container mx-auto py-3">
                <template x-for="(message, index) in messages" :key="index">
                    <div>
                        <template x-if="hasMessage">
                            <div class="message"
                                 :class="message.type"
                                 :ui-id="getMessageUiId"
                            >
                                <span x-html="message.text"></span>
                                <button
                                    type="button"
                                    class="text-gray-600 hover:text-black"
                                    aria-label="Close message"
                                    @click.prevent="removeMessage"
                                >
                                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="stroke-current" width="18" height="18" aria-hidden="true">
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
</svg>
                                </button>
                            </div>
                        </template>
                    </div>
                </template>
            </div>
        </div>
    </template>
</section>
</div><div class="columns"><div class="column main"><style>.cmsp102-container {
width: 100%
}
@media (min-width: 640px) {
.cmsp102-container {
max-width: 640px
}
}
@media (min-width: 768px) {
.cmsp102-container {
max-width: 768px
}
}
@media (min-width: 1024px) {
.cmsp102-container {
max-width: 1024px
}
}
@media (min-width: 1280px) {
.cmsp102-container {
max-width: 1280px
}
}
@media (min-width: 1536px) {
.cmsp102-container {
max-width: 1536px
}
}
.cmsp102-absolute {
position: absolute
}
.cmsp102-relative {
position: relative
}
.cmsp102-mx-auto {
margin-left: auto;
margin-right: auto
}
.cmsp102-my-2 {
margin-top: 0.5rem;
margin-bottom: 0.5rem
}
.cmsp102-\!ml-0 {
margin-left: 0px !important
}
.cmsp102-\!mt-4 {
margin-top: 1rem !important
}
.cmsp102-mb-16 {
margin-bottom: 4rem
}
.cmsp102-mb-4 {
margin-bottom: 1rem
}
.cmsp102-block {
display: block
}
.cmsp102-flex {
display: flex
}
.cmsp102-grid {
display: grid
}
.cmsp102-hidden {
display: none
}
.cmsp102-grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr))
}
.cmsp102-justify-center {
justify-content: center
}
.cmsp102-gap-8 {
gap: 2rem
}
.cmsp102-pb-4 {
padding-bottom: 1rem
}
.cmsp102-text-center {
text-align: center
}
.cmsp102-font-bold {
font-weight: 700
}
.cmsp102-outline {
outline-style: solid
}
.cmsp102-hover\:underline:hover {
text-decoration-line: underline
}
@media (min-width: 640px) {
.cmsp102-sm\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr))
}
}
@media (min-width: 768px) {
.cmsp102-md\:block {
display: block
}
.cmsp102-md\:hidden {
display: none
}
}
@media (min-width: 1024px) {
.cmsp102-lg\:grid-cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr))
}
}</style>
<style>#html-body [data-pb-style=R6IAA5Q]{justify-content:flex-start;display:flex;flex-direction:column;background-position:left top;background-size:cover;background-repeat:no-repeat;background-attachment:scroll;border-style:none;border-width:1px;border-radius:0;margin:0 0 10px;padding:10px}#html-body [data-pb-style=U6NCY8P]{border-style:none;border-width:1px;border-radius:0;margin:0;padding:0}</style><div data-content-type="row" data-appearance="contained" data-element="main"><div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-background-type="image" data-video-loop="true" data-video-play-only-visible="true" data-video-lazy-load="true" data-video-fallback-src="" data-element="inner" data-pb-style="R6IAA5Q"><div data-content-type="html" data-appearance="default" data-element="main" data-pb-style="U6NCY8P" data-decoded="true"><style>
    .checkmark {
        display: block;
        position: relative;
        padding-left: 2.5rem;
        line-height: 1.5;
    }

    .checkmark::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0; /* Center the icon vertically, adjust as needed */
        width: 32px; /* Fixed width for the icon */
        height: 32px; /* Fixed height for the icon */
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5l10 -10"/></svg>');
        background-size: contain; /* Ensures the icon does not stretch */
        background-repeat: no-repeat;
    }
</style>
<div id="nlpg-landing-page-container">
    <div class="argento-grid">
        <div class="cmsp102-justify-center" style="display: flex;">
            <div class="cmsp102-hidden cmsp102-md:block">
                <img
                    src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/knowledge-quest-banner-desktop.webp"
                    alt=""/>
            </div>
            <div class="cmsp102-block cmsp102-md:hidden">
                <img
                    src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/knowledge-quest-banner-mobile.webp"
                    alt=""/>
            </div>
        </div>
        <div class="features text cmsp102-mb-16">
            <p>We are excited to announce that Knowledge Quest is now part of the Master Books <a href="https://www.masterbooks.com/">Christian homeschool curriculum</a> line,
                including the best-selling, <em><a href="/a-childs-geography-series">A Child’s Geography</a></em> series (grades 1-8) and the <em><a href="/blog/add-geography-to-history-curriculum-map-trek">Map Trek</a></em> series (grades 1-12).</p>
            <p>Master Books has been the leading publisher of Creation science apologetics books and resources for over
                40 years. In 2012, Master Books began developing the Master Books curriculum line which incorporates new
                projects as well as re-publishing some homeschool classics, like Jensen’s Grammar, Writing Strands,
                Jacobs’ Math, God’s Design Science, and Math Lessons for a Living Education. Knowledge Quest developed
                books and resources to help students make connections in history and geography. The Knowledge Quest
                series is a perfect complement to the Master Books product line.</p>
            <p>Stay tuned over the coming months as the Master Books team goes through these resources and revises them
                to remove the friction points and fit the Master Books method.</p>
        </div>

        <div class="cmsp102-container cmsp102-mx-auto">
            <div class="cmsp102-grid cmsp102-grid-cols-1 cmsp102-sm:grid-cols-2 cmsp102-lg:grid-cols-3 cmsp102-gap-8">
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/map-trek-set-atlas-outlines">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/map-trek-book.webp"
                            alt="Map Trek: The Complete Collection"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/map-trek-set-atlas-outlines">Map Trek: Set (Atlas &
                            Outlines)</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Hundreds of historical outline maps at your fingertips</li>
                        <li class="checkmark">Save yourself countless hours scouring the internet for the perfect
                            printable map for your
                            history lesson
                        </li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/meet-the-chief">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/meet-the-chief.webp"
                            alt="Meet the Chief"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/meet-the-chief">Meet the Chief</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Get acquainted with our nation's presidents, from George Washington to our
                            former president,
                            Barack Obama
                        </li>
                        <li class="checkmark">Find out about the events that propelled these men into the highest office
                            of the USA and
                            what
                            remarkable and memorable deeds marked each of their presidencies
                        </li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/wonders-of-old">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/wonders-of-old.webp"
                            alt="Wonders of Old"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/wonders-of-old">Wonders of Old</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Dates pre-marked from 5000BC to 2020AD</li>
                        <li class="checkmark">Provides your student with a better understanding of the flow of history
                        </li>
                        <li class="checkmark">Significant dates listed at the conclusion of each section as a helpful
                            reference
                        </li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/a-child-s-geography-vol-1-explore-his-earth">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/explore-his-earth.webp"
                            alt="Explore His Earth"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/a-child-s-geography-vol-1-explore-his-earth">Explore His
                            Earth</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Fascination journey through some aspect of our Earth</li>
                        <li class="checkmark">Narration prompts through the chapters</li>
                        <li class="checkmark">Note booking directions at each chapter's conclusion</li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/a-childs-geography-vol-2-explore-the-holy-land-revised">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/explore-the-holy-land.webp"
                            alt="Explore the Holy Land"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/a-childs-geography-vol-2-explore-the-holy-land-revised">Explore
                            the Holy Land</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Delight in incredible, mysterious landscapes, hidden wonders and beautiful
                            people all
                            created in
                            God's image
                        </li>
                        <li class="checkmark">Travel through the lands of Scripture, discovering familiar Biblical
                            landmarks
                        </li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/a-child-s-geography-vol-3-explore-the-classical-world">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/explore-classical-world.webp"
                            alt="Explore The Classical World"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/a-child-s-geography-vol-3-explore-the-classical-world">Explore
                            the Classical World</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Walk in the footsteps of Scorates, Alexander the Great, the Apostle Paul
                        </li>
                        <li class="checkmark">See and understand ancient civilizations and great empires from what has
                            been left behind
                            and
                            carefully preserved
                        </li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/a-child-s-geography-vol-4-explore-medieval-kingdoms">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/explore-medieval-kingdoms.webp"
                            alt="Explore Medieval Kingdoms"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="https://www.masterbooks.com/a-child-s-geography-vol-4-explore-medieval-kingdoms">Explore
                            the Medieval Kingdoms</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Adventure through our Father's world through 12 countries of Western
                            Europe
                        </li>
                        <li class="checkmark">narration prompts to cement learning and understanding</li>
                    </ul>
                </div>
                <div class="cmsp102-mb-4 cmsp102-pb-4">
                    <a href="https://www.masterbooks.com/catalog/product/view/id/4636">
                        <img class="imgCustomShadow"
                            src="https://cdn.masterbooks.com/media/converted/wysiwyg/landing-pages/knowledge-quest/viking-realms_1.webp"
                            alt="Explore Viking Realms"/>
                    </a>
                    <h4 class="cmsp102-text-center cmsp102-!mt-4">
                        <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                           href="/a-childs-geography-explore-viking-realms-vol-5">Explore Viking Realms</a>
                    </h4>
                    <ul class="cmsp102-my-2 cmsp102-!ml-0">
                        <li class="checkmark">Over the course of 16 chapters, explore the 13 countries of Northern
                            Europe
                        </li>
                        <li class="checkmark">engaging text and vivid photos that bring each country to life</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="cmsp102-grid cmsp102-justify-center">
            <h4 class="cmsp102-text-center">Looking for MapStudio?</h4>
            <p>We are happy to announce that MapStudio has been updated and now allows you to download and
                restore
                your maps' data to continue refining and updating them!</p>
            <p>Check out <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                    href="https://www.masterbooks.com/knowledge-base/map-studio-tutorials/"><strong>tutorials</strong></a>,
                or start creating customized maps in minutes by <a class="text-links cmsp102-font-bold cmsp102-hover:underline"
                    href="https://www.masterbooks.com/map-studio"><strong>signing in</strong></a> with your
                Master Books account.</p>
        </div>
    </div>
</div>
</div></div></div><script>
    'use strict';

    function amXsearchAnalytics() {
        return {
            backendUrl: 'https://www.masterbooks.com/amasty_xsearch/analytics/collect/',
            throttleTime: 500,
            localStorageKey: 'amasty_xsearch_analytics',
            observer: null,

            init() {
                this.loadStoredData();
                this.addListener();
                this.sendData = this.throttle(this.sendData.bind(this), this.throttleTime);
            },

            addListener() {
                document.addEventListener('click', (event) => {
                    this.handleClick(event.target);
                });

                window.addEventListener('load', () => {
                    this.sendData();
                });
            },

            handleClick(target) {
                const searchInput = this.$refs?.searchInput?.value || '';
                const item = target.closest('.product-item');
                const isSearchClick = !!target.closest('[data-amsearch-analytics="block"] .product-item-link,' +
                    ' [data-amsearch-analytics="block"] a,' +
                    ' [data-amsearch-analytics="block"] .action-addtocart');

                if (searchInput.length >= 3 && (item || isSearchClick)) {
                    this.addToQueue({ type: 'search_click', timestamp: Date.now() });
                }
            },

            addToQueue(eventData) {
                let queue = JSON.parse(localStorage.getItem(this.localStorageKey) || '[]');
                queue.push(eventData);
                localStorage.setItem(this.localStorageKey, JSON.stringify(queue));
            },

            async sendData() {
                let queue = JSON.parse(localStorage.getItem(this.localStorageKey) || '[]');
                if (queue.length === 0) return;

                try {
                    const params = new URLSearchParams({
                        isAjax: "1",
                        form_key: hyva.getFormKey()
                    });
                    queue.forEach((item, index) => {
                        Object.entries(item).forEach(([key, value]) => {
                            params.append(`telemetry[${index}][${key}]`, value);
                        });
                    });
                    await fetch(`${this.backendUrl}?${params.toString()}`, {
                        method: 'GET',
                        headers: {
                            'X-Requested-With': 'XMLHttpRequest'
                        }
                    });
                    localStorage.removeItem(this.localStorageKey);
                } catch (error) {
                    console.error('Error sending analytics data:', error);
                }
            },

            loadStoredData() {
                let storedData = JSON.parse(localStorage.getItem(this.localStorageKey) || '[]');
                if (storedData.length > 0) {
                    console.log('Found unsent analytics data:', storedData);
                }
            },

            throttle(func, limit) {
                let lastCall = 0;
                return function (...args) {
                    const now = Date.now();
                    if (now - lastCall >= limit) {
                        lastCall = now;
                        func(...args);
                    }
                };
            }
        }
    }
</script>
</div></div></main><footer class="page-footer"><div class="footer content">
<div class="footer-content-before-container bg-footerCommunication"><div class="lg:container flex flex-col lg:flex-row lg:justify-between items-center"><div class="py-4 lg:bg-transparent">
    <form
        class="form subscribe container max-w-3xl lg:pl-0"
        action="https://www.masterbooks.com/newsletter/subscriber/new/"
        method="post"
        x-data="initNewsletterForm"
        @submit.prevent="submitForm"
        id="newsletter-validate-detail"
        aria-label="Subscribe&#x20;to&#x20;Newsletter"
    >
        <div class="flex flex-row sm:flex-row">
            <div class="grow m-0">
                <span class="sr-only">Email Address</span>
                <input
                    type="email"
                    id="newsletter-subscribe"
                    name="email"
                    class="form-input w-full py-2.5 px-5 rounded-none"
                    required
                    placeholder="Enter&#x20;your&#x20;email&#x20;address"
                    autocomplete="email"
                >
                <input name="form_key" type="hidden" value="zoOV9lBFMarBAz0K" />                <div class="control">
    <input type="hidden"
           value=""
           name="g-recaptcha-response"
    >
</div>
            </div>
            <button class="
                shrink-0 btn btn-primary justify-center py-2.5 px-5 text-base shadow-none hover:shadow-lg active:shadow
                transition text-white border border-transparent hover:bg-primary-lighter focus:ring-orange-300 active:bg-primary-darker
                disabled:bg-primary-lighter
            ">
                Subscribe            </button>
        </div>
        <template x-if="displayErrorMessage">
            <p class="flex items-center text-red mt-2">
                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="inline-block mr-3" width="24" height="24" role="img">
  <path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
<title>exclamation-circle</title></svg>
                <template x-for="errorMessage in errorMessages">
                    <span x-html="errorMessage"></span>
                </template>
            </p>
        </template>
    </form>
    <div class="w-full">
        <p class="prose my-4 text-sm">
    <em>This form is protected by reCAPTCHA - the <a class="underline" href="https://policies.google.com/privacy" target="_blank" rel="noopener">Google Privacy Policy</a> and <a class="underline" href="https://policies.google.com/terms" target="_blank" rel="noopener">Terms of Service</a> apply.</em>
</p>
    </div>
    <script>
        function initNewsletterForm() {
            return {
                errors: 0,
                hasCaptchaToken: 0,
                displayErrorMessage: false,
                errorMessages: [],
                setErrorMessages(messages) {
                    this.errorMessages = [messages]
                    this.displayErrorMessage = this.errorMessages.length
                },
                submitForm() {
                    // Do not rename $form, the variable is expected to be declared in the recaptcha output
                    const $form = document.querySelector('#newsletter-validate-detail');
                        if (!this.hasCaptchaToken) {
        this.errors = 1;


        const executeGreCaptcha = () => {
            grecaptcha.ready(() => {
                grecaptcha.execute(
                    '6LceWLgUAAAAAH7dwYx36tmo_UKPXJUNRLcGWaEo',
                    {action: 'submit'}
                ).then((token) => {
                    const tokenElement = $form['g\u002Drecaptcha\u002Dresponse'];

                    if (tokenElement && token && token.length > 0) {
                        $form['g\u002Drecaptcha\u002Dresponse'].value = token;
                        this.errors = 0;
                        this.hasCaptchaToken = 1;
                        (this.submitForm || $form.submit).call(this);
                    } else {
                        this.errors = 1;
                        const error = tokenElement
                            ? 'ReCaptcha\u0020validation\u0020failed,\u0020please\u0020try\u0020again'
                            : 'ReCaptcha\u0020token\u0020element\u0020is\u0020missing.\u0020Please\u0020refresh\u0020the\u0020page\u0020and\u0020trying\u0020again.';
                        if (this.setErrorMessages) {
                            this.setErrorMessages([error])
                            this.displayErrorMessage = true;
                        } else {
                            window.dispatchMessages && window.dispatchMessages([{type: "error", text: error}], 5000);
                        }
                    }
                }).catch(exception => {
                    console.error(exception || `An unknown error occurred during ReCaptcha validation. Are the tokens and the domain correctly set up in the Google console?`)
                });
            })
        }

        if (window.grecaptcha) {
            executeGreCaptcha();
        } else {
            const recaptchaUrl = "https://www.google.com/recaptcha/api.js?render=6LceWLgUAAAAAH7dwYx36tmo_UKPXJUNRLcGWaEo";
            const script = document.createElement('script');
            script.setAttribute('type', 'text/javascript');
            script.setAttribute('src', recaptchaUrl);
            document.head.appendChild(script);

            script.addEventListener("load", executeGreCaptcha, false);
        }
    }

                    if (this.errors === 0) {
                        $form.submit();
                    }
                }
            }
        }
        window.addEventListener('alpine:init', () => Alpine.data('initNewsletterForm', initNewsletterForm), {once: true})
    </script>
    </div>
<style>.cmsb238-container {
width: 100%
}
@media (min-width: 640px) {
.cmsb238-container {
max-width: 640px
}
}
@media (min-width: 768px) {
.cmsb238-container {
max-width: 768px
}
}
@media (min-width: 1024px) {
.cmsb238-container {
max-width: 1024px
}
}
@media (min-width: 1280px) {
.cmsb238-container {
max-width: 1280px
}
}
@media (min-width: 1536px) {
.cmsb238-container {
max-width: 1536px
}
}
.cmsb238-mb-3 {
margin-bottom: 0.75rem
}
.cmsb238-flex {
display: flex
}
.cmsb238-h-10 {
height: 2.5rem
}
.cmsb238-w-10 {
width: 2.5rem
}
.cmsb238-flex-col {
flex-direction: column
}
.cmsb238-items-center {
align-items: center
}
.cmsb238-justify-center {
justify-content: center
}
.cmsb238-gap-2 {
gap: 0.5rem
}
.cmsb238-rounded-full {
border-radius: 9999px
}
.cmsb238-border-zinc-200 {
--tw-border-opacity: 1;
border-color: rgb(228 228 231 / var(--tw-border-opacity))
}
.cmsb238-pb-4 {
padding-bottom: 1rem
}
.cmsb238-text-center {
text-align: center
}
.cmsb238-text-lg {
font-size: 1.125rem;
line-height: 1.75rem
}
.cmsb238-font-bold {
font-weight: 700
}
.cmsb238-uppercase {
text-transform: uppercase
}
.cmsb238-text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity))
}
.cmsb238-transition-colors {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms
}
@media (min-width: 1024px) {
.cmsb238-lg\:container {
width: 100%
}
@media (min-width: 640px) {
.cmsb238-lg\:container {
max-width: 640px
}
}
@media (min-width: 768px) {
.cmsb238-lg\:container {
max-width: 768px
}
}
@media (min-width: 1024px) {
.cmsb238-lg\:container {
max-width: 1024px
}
}
@media (min-width: 1280px) {
.cmsb238-lg\:container {
max-width: 1280px
}
}
@media (min-width: 1536px) {
.cmsb238-lg\:container {
max-width: 1536px
}
}
.cmsb238-lg\:mb-0 {
margin-bottom: 0px
}
.cmsb238-lg\:mr-8 {
margin-right: 2rem
}
.cmsb238-lg\:flex {
display: flex
}
.cmsb238-lg\:max-w-none {
max-width: none
}
.cmsb238-lg\:flex-row {
flex-direction: row
}
.cmsb238-lg\:items-center {
align-items: center
}
.cmsb238-lg\:justify-end {
justify-content: flex-end
}
.cmsb238-lg\:justify-between {
justify-content: space-between
}
.cmsb238-lg\:gap-4 {
gap: 1rem
}
.cmsb238-lg\:border-b-0 {
border-bottom-width: 0px
}
.cmsb238-lg\:bg-transparent {
background-color: transparent
}
.cmsb238-lg\:px-0 {
padding-left: 0px;
padding-right: 0px
}
.cmsb238-lg\:pb-0 {
padding-bottom: 0px
}
.cmsb238-lg\:text-right {
text-align: right
}
.cmsb238-lg\:text-base {
font-size: 1rem;
line-height: 1.5rem
}
.cmsb238-lg\:text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity))
}
}</style>
<div data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><div class="bg-footerCommunication cmsb238-lg:bg-transparent cmsb238-lg:flex">
       <div class="cmsb238-lg:container cmsb238-lg:flex cmsb238-lg:justify-between cmsb238-lg:gap-4">
          <div class="join-our-community-container cmsb238-flex cmsb238-flex-col cmsb238-lg:flex-row cmsb238-lg:items-center cmsb238-container cmsb238-lg:text-white cmsb238-lg:px-0 cmsb238-lg:max-w-none">
             <div class="join-our-community-title cmsb238-mb-3 cmsb238-lg:mb-0 cmsb238-lg:mr-8 cmsb238-text-lg cmsb238-font-bold cmsb238-text-center cmsb238-lg:text-right cmsb238-lg:text-base cmsb238-text-white cmsb238-uppercase">
                Join our community
             </div>
             <div class="join-our-community-icons-container cmsb238-flex cmsb238-justify-center cmsb238-gap-2 cmsb238-pb-4 cmsb238-lg:pb-0 cmsb238-border-zinc-200 cmsb238-lg:border-b-0 cmsb238-lg:justify-end">
                 <a href="https://masterbooks.disciplemedia.com/"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                    <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 223.58 220.08" id="our-comunity">
                        <defs><style>.mb-social-b{fill:#fff;stroke-width:0px;}</style></defs>
                        <path class="color000000 svgShape" fill="#ffffff" d="M133.08,146.82c1.34.31,2.42.46,3.22.45,2.41-.03,3.33-1.2,3.31-2.51,0-.83-.28-1.65-.7-2.47-.28-.49-.42-1.47-.44-2.96-.12-9.07,4.78-34.04,9.13-49.76,1.66-5.96,2.14-10.26,2.08-15.37-.12-9.23-3.04-16.78-11.06-16.68-8.44.11-22.64,9.21-45.07,35.39-.26.33-1.71,1.84-2.38,2.35-.01-.84.11-1.5.5-2.32,3.63-8.79,8.56-21.38,8.42-31.77-.05-3.63-.76-7.09-2.41-9.87-1.78-3.11-4.07-4.4-6.61-4.37-9.64.13-23.72,18.94-33.21,31.1-2.64,3.34-3.29,4.17-4.09,4.84.25-1.48,1.03-3.14,1.95-4.98,6.13-12.28,8.81-22.87,8.71-29.96-.17-13.03-8.53-17.54-17.09-17.43-3.88.05-7.75,1.1-10.95,2.61-13.57,6.77-20.74,11.98-30.41,19.2-2.13,1.51-2.92,2.02-3.32,2.02-.14,0-.54,0-.54-.16-.01-.99,2.23-3.33,2.49-4.15C1.28,52.05-.03,53.88,0,56.03c.01.82.29,1.8.84,2.95,1.1,2.29,2.45,3.59,4.33,3.57,1.87-.02,4.13-1.21,7.31-3.89,19.47-16.74,29.97-22.98,35.32-23.05,2.95-.04,4.31,1.92,4.35,5.06.14,10.89-13.85,37.29-26.42,58.39-8.39,13.97-11.33,25.22-11.23,32.8.07,5.77,2,9.55,4.69,10.66.67.32,1.34.48,1.88.47,2.01-.03,3.33-1.69,4.24-3.52,7.68-16.6,54.07-84.48,61.04-84.57.53,0,.95.48.96,1.3,0,.84-.25,1.82-.63,3.32-4.09,14.73-26.93,50.65-26.68,70.1.07,5.28,2,9.55,6.45,11.46,1.48.65,2.55.96,3.36.95,3.34-.04,3.16-4.17,5.25-7.81,24.87-43.86,47.72-68.24,54.95-68.34,1.34-.02,2.16.96,2.19,2.94,0,.83-.12,1.65-.24,2.64-1.5,8.43-13.61,34.31-13.36,53.78.13,10.22,3.72,18.75,14.47,21.58"/><path class="mb-social-b" d="M105.78,102.34c1.61.97,3.93,1.3,6.83,1.26,14.05-.18,41.58-10.12,57.65-10.33,1.6-.02,3.19.08,4.5.3,5.95.91,8.43,2.1,8.46,3.83.1,7.62-50.69,22.91-50.48,39.13,0,.73.17,1.35.32,2.09.46,1.71,1.48,2.56,2.79,2.55.71,0,1.45-.27,2.3-.77,8.47-5.88,21.46-9.62,29.57-9.73,6.08-.08,9.44,2.46,9.47,4.92.11,8.73-29.51,24.73-62.03,30.43-.87.14-1.43,1.25-1.42,2.24.02,1.35.76,2.56,2.78,2.54.87-.01,2.02-.51,3.9-.53,5.21-.07,9.91,4.17,22.22,4.01,2.89-.04,6.22-.33,10.12-1,26.88-4.53,40.76-17.62,40.62-28.68-.11-8.36-8.31-15.64-24.85-17.14-1.15-.11-1.88-.47-1.89-.83,0-.25.28-.5,1-.76,24.5-9.17,32.65-17.14,32.58-23.16-.1-7.5-12.32-12.02-21.6-12.75-1.6-.11-3.34-.21-5.22-.18-20.56.27-60.14,8.4-66.95,8.49-.73,0-1.01-.11-1.02-.23,0-.24.57-.62,2.16-1.25.43-.14.57-.26.57-.38,0-.13-1.01-.12-1.88.02-.58.13-3.76.66-3.74,2.38.01.98.9,2.08,3.23,3.53"/><path class="mb-social-b" d="M54.79,16.98C58.71,7.8,94.41.9,107.42.17c2.08-.12,4.15-.17,6.21-.17,57.98,0,106.5,45.33,109.77,103.92.11,2.08.17,4.15.17,6.21,0,37.69-19.16,71.4-48.66,91.25-15.88,10.69-34.78,17.38-55.26,18.52-2.08.12-4.15.17-6.21.17-39.6,0-74.79-21.14-94.16-53.21h0c-1.32-2.19-11.83-21.87-6.37-19.14,0,0-1.13,3.06,9.4,5.64,1.26.31,3.96,6.56,5.16,8.55v.02s0-.02,0-.02c17.7,29.29,49.83,48.59,85.97,48.59,1.88,0,3.77-.05,5.67-.16,18.74-1.05,35.95-7.14,50.45-16.9,26.95-18.14,44.44-48.91,44.44-83.31,0-1.88-.05-3.78-.16-5.68-2.97-53.5-47.3-95.08-100.22-94.88-31.35.12-60.05,12.25-53.73,15.49,6.32,3.24-9.03,1.09-5.11-8.09Z"/>
                    </svg>
                </a>
                <a href="https://www.facebook.com/MasterBooks"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                   <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24" id="facebook">
                      <path d="M15.12,5.32H17V2.14A26.11,26.11,0,0,0,14.26,2C11.54,2,9.68,3.66,9.68,6.7V9.32H6.61v3.56H9.68V22h3.68V12.88h3.06l.46-3.56H13.36V7.05C13.36,6,13.64,5.32,15.12,5.32Z" fill="#ffffff" class="color000000 svgShape"></path>
                   </svg>
                </a>
                <a href="https://www.instagram.com/masterbooks"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                   <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24" id="instagram">
                      <path d="M17.34,5.46h0a1.2,1.2,0,1,0,1.2,1.2A1.2,1.2,0,0,0,17.34,5.46Zm4.6,2.42a7.59,7.59,0,0,0-.46-2.43,4.94,4.94,0,0,0-1.16-1.77,4.7,4.7,0,0,0-1.77-1.15,7.3,7.3,0,0,0-2.43-.47C15.06,2,14.72,2,12,2s-3.06,0-4.12.06a7.3,7.3,0,0,0-2.43.47A4.78,4.78,0,0,0,3.68,3.68,4.7,4.7,0,0,0,2.53,5.45a7.3,7.3,0,0,0-.47,2.43C2,8.94,2,9.28,2,12s0,3.06.06,4.12a7.3,7.3,0,0,0,.47,2.43,4.7,4.7,0,0,0,1.15,1.77,4.78,4.78,0,0,0,1.77,1.15,7.3,7.3,0,0,0,2.43.47C8.94,22,9.28,22,12,22s3.06,0,4.12-.06a7.3,7.3,0,0,0,2.43-.47,4.7,4.7,0,0,0,1.77-1.15,4.85,4.85,0,0,0,1.16-1.77,7.59,7.59,0,0,0,.46-2.43c0-1.06.06-1.4.06-4.12S22,8.94,21.94,7.88ZM20.14,16a5.61,5.61,0,0,1-.34,1.86,3.06,3.06,0,0,1-.75,1.15,3.19,3.19,0,0,1-1.15.75,5.61,5.61,0,0,1-1.86.34c-1,.05-1.37.06-4,.06s-3,0-4-.06A5.73,5.73,0,0,1,6.1,19.8,3.27,3.27,0,0,1,5,19.05a3,3,0,0,1-.74-1.15A5.54,5.54,0,0,1,3.86,16c0-1-.06-1.37-.06-4s0-3,.06-4A5.54,5.54,0,0,1,4.21,6.1,3,3,0,0,1,5,5,3.14,3.14,0,0,1,6.1,4.2,5.73,5.73,0,0,1,8,3.86c1,0,1.37-.06,4-.06s3,0,4,.06a5.61,5.61,0,0,1,1.86.34A3.06,3.06,0,0,1,19.05,5,3.06,3.06,0,0,1,19.8,6.1,5.61,5.61,0,0,1,20.14,8c.05,1,.06,1.37.06,4S20.19,15,20.14,16ZM12,6.87A5.13,5.13,0,1,0,17.14,12,5.12,5.12,0,0,0,12,6.87Zm0,8.46A3.33,3.33,0,1,1,15.33,12,3.33,3.33,0,0,1,12,15.33Z" fill="#ffffff" class="color000000 svgShape"></path>
                   </svg>
                </a>
                <a href="https://www.pinterest.com/homeschoolbooks"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                   <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" id="Pinterest">
                      <path fill="#ffffff" d="M8.717 0C4.332 0 2 2.81 2 5.874c0 1.421.794 3.193 2.065 3.755.193.087.298.05.341-.129.038-.136.205-.791.286-1.1a.283.283 0 0 0-.068-.278c-.422-.488-.757-1.377-.757-2.211 0-2.137 1.699-4.212 4.59-4.212 2.5 0 4.249 1.624 4.249 3.947 0 2.625-1.389 4.441-3.194 4.441-.999 0-1.743-.784-1.507-1.754.285-1.155.844-2.397.844-3.23 0-.747-.422-1.365-1.284-1.365-1.017 0-1.842 1.007-1.842 2.359 0 .859.304 1.439.304 1.439l-1.193 4.823c-.316 1.285.043 3.366.074 3.545.019.099.13.13.192.049.099-.13 1.315-1.865 1.656-3.119.124-.457.633-2.31.633-2.31.335.605 1.302 1.112 2.332 1.112 3.064 0 5.278-2.693 5.278-6.035C14.988 2.397 12.246 0 8.717 0" class="colord32f2f svgShape"></path>
                   </svg>
                </a>
                <a href="https://www.youtube.com/c/MasterBooksCurriculum"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                   <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24" id="youtube">
                      <path d="M23,9.71a8.5,8.5,0,0,0-.91-4.13,2.92,2.92,0,0,0-1.72-1A78.36,78.36,0,0,0,12,4.27a78.45,78.45,0,0,0-8.34.3,2.87,2.87,0,0,0-1.46.74c-.9.83-1,2.25-1.1,3.45a48.29,48.29,0,0,0,0,6.48,9.55,9.55,0,0,0,.3,2,3.14,3.14,0,0,0,.71,1.36,2.86,2.86,0,0,0,1.49.78,45.18,45.18,0,0,0,6.5.33c3.5.05,6.57,0,10.2-.28a2.88,2.88,0,0,0,1.53-.78,2.49,2.49,0,0,0,.61-1,10.58,10.58,0,0,0,.52-3.4C23,13.69,23,10.31,23,9.71ZM9.74,14.85V8.66l5.92,3.11C14,12.69,11.81,13.73,9.74,14.85Z" fill="#ffffff" class="color000000 svgShape"></path>
                   </svg>
                </a>
                <a href="https://www.tiktok.com/@master_books_homeschool"
                   target="_blank"
                   rel="noopener noreferrer"
                   class="join-our-community-icon cmsb238-flex cmsb238-items-center cmsb238-justify-center cmsb238-w-10 cmsb238-h-10 cmsb238-text-white cmsb238-rounded-full cmsb238-transition-colors bg-primary-darker hover:bg-primary-lighter">
                   <svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24" id="tiktok">
  <path fill="#ffffff" d="M12.75 2h3.07a5.93 5.93 0 0 0 4.51 4.44v3.06a8.92 8.92 0 0 1-4.51-1.23v7.22a6.5 6.5 0 1 1-6.5-6.5 6.4 6.4 0 0 1 1.43.16v3.22a3.28 3.28 0 1 0 2 3.01V2z"/>
</svg>

                   </svg>
                </a>
             </div>
          </div>
       </div>
    </div></div></div></div><div class="bg-zinc-100 border-t border-zinc-200 text-gray-700">
    <div class="container py-5 mx-auto flex justify-center text-center lg:text-left">
        <div class="grid grid-cols-1 lg:grid-cols-12 lg:gap-8 xl:gap-2 lg:w-full">
                                                        <style>.cmsb241-mb-2 {
margin-bottom: 0.5rem
}
.cmsb241-mb-8 {
margin-bottom: 2rem
}
.cmsb241-block {
display: block
}
.cmsb241-py-1\.5 {
padding-top: 0.375rem;
padding-bottom: 0.375rem
}
.cmsb241-font-semibold {
font-weight: 600
}
.cmsb241-uppercase {
text-transform: uppercase
}
.cmsb241-hover\:underline:hover {
text-decoration-line: underline
}
@media (min-width: 1024px) {
.cmsb241-lg\:col-span-3 {
grid-column: span 3 / span 3
}
.cmsb241-lg\:col-start-1 {
grid-column-start: 1
}
}
@media (min-width: 1280px) {
.cmsb241-xl\:col-span-2 {
grid-column: span 2 / span 2
}
}</style>
<div class="cmsb241-lg:col-start-1 cmsb241-lg:col-span-3 cmsb241-xl:col-span-2" data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><div class="footer-links-group cmsb241-mb-8">
        <h4 class="footer-links-group-title cmsb241-font-semibold cmsb241-uppercase cmsb241-mb-2">About Us</h4>
        <ul>
            <li>
                <a
                    href="/about"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >About Us</a>
            </li>
            <li>
                <a
                    href="/request-catalog"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >Education Catalog</a>
            </li>
           <li>
                <a
                    href="/homeschool-curriculum-scope-and-sequence"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >Scope & Sequence</a>
            </li>
 <li>
                <a
                    href="/assessment-and-placement-tests"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >Placement Tests</a>
            </li>
            <li>
                <a
                    href="/homeschooling-conferences"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >Homeschool Conferences</a>
            </li>
 <li>
                <a
                    href="/master-books-curriculum-for-schools"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >For Schools & Co-Ops</a>
            </li>
 <li>
                <a
                    href="/scholarships"
                    class="footer-links-group-item cmsb241-block cmsb241-py-1.5 cmsb241-hover:underline"
                >College Scholarships</a>
            </li>
        </ul>
    </div></div>                            <style>.cmsb243-mb-2 {
margin-bottom: 0.5rem
}
.cmsb243-mb-8 {
margin-bottom: 2rem
}
.cmsb243-block {
display: block
}
.cmsb243-py-1\.5 {
padding-top: 0.375rem;
padding-bottom: 0.375rem
}
.cmsb243-font-semibold {
font-weight: 600
}
.cmsb243-uppercase {
text-transform: uppercase
}
.cmsb243-hover\:underline:hover {
text-decoration-line: underline
}
@media (min-width: 1024px) {
.cmsb243-lg\:col-span-3 {
grid-column: span 3 / span 3
}
.cmsb243-lg\:col-start-4 {
grid-column-start: 4
}
}
@media (min-width: 1280px) {
.cmsb243-xl\:col-span-2 {
grid-column: span 2 / span 2
}
.cmsb243-xl\:col-start-3 {
grid-column-start: 3
}
}</style>
<div class="cmsb243-lg:col-start-4 cmsb243-lg:col-span-3 cmsb243-xl:col-start-3 cmsb243-xl:col-span-2" data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><div class="footer-links-group cmsb243-mb-8">
        <h4 class="footer-links-group-title cmsb243-font-semibold cmsb243-uppercase cmsb243-mb-2">Customer Center</h4>
        <ul>
            <li>
                <a
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                    onclick="hyva.setCookie && hyva.setCookie(
                        'login_redirect',
                        window.location.href,
                        1
                        )"
                    href="/customer/account/index"
                >My Account</a>
            </li>
            <li>
                <a
                    href="/rewards"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Reward Program</a>
            </li>
   <li>
                <a
                    href="/affiliate/account/welcome/"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Affiliate Program</a>
            </li>

           <li>
                <a
                    href="/educational-savings-accounts"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Educational Savings Accounts</a>
            </li>
            <li>
                <a
                    href="/classroom-aids"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Free Downloads</a>
            </li>
<li>
                <a
                    href="/knowledge-base/what-is-your-return-policy"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Return Policy</a>
            </li>
            <li>
                <a
                    href="/contact"
                    class="footer-links-group-item cmsb243-block cmsb243-py-1.5 cmsb243-hover:underline"
                >Contact Us</a>
            </li>
        </ul>
    </div></div>                            <style>.cmsb240-mb-1 {
margin-bottom: 0.25rem
}
.cmsb240-pt-3 {
padding-top: 0.75rem
}
.cmsb240-font-semibold {
font-weight: 600
}
.cmsb240-uppercase {
text-transform: uppercase
}
.cmsb240-underline {
text-decoration-line: underline
}
@media (min-width: 1024px) {
.cmsb240-lg\:col-span-3 {
grid-column: span 3 / span 3
}
.cmsb240-lg\:col-start-10 {
grid-column-start: 10
}
}
@media (min-width: 1280px) {
.cmsb240-xl\:col-span-2 {
grid-column: span 2 / span 2
}
.cmsb240-xl\:col-start-11 {
grid-column-start: 11
}
}</style>
<div class="cmsb240-lg:col-start-10 cmsb240-lg:col-span-3 cmsb240-xl:col-start-11 cmsb240-xl:col-span-2" data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><div class="footer-our-office">
    <h4 class="footer-links-group-title cmsb240-font-semibold cmsb240-uppercase cmsb240-mb-1">Our Office</h4>
    <p class="cmsb240-pt-3">
        3142 Highway 103 N<br>
        Green Forest, AR 72638<br>
    </p>
    <p class="cmsb240-pt-3">
        <strong>(870) 438-5288</strong>
    </p>
    <p class="cmsb240-pt-3">
        <a class="footer-links-group-item-link cmsb240-underline" tabindex="0" href="/cdn-cgi/l/email-protection#8cfff9fcfce3fef8cce1edfff8e9feeee3e3e7ffa2efe3e1"><span class="__cf_email__" data-cfemail="10636560607f6264507d7163647562727f7f7b633e737f7d">[email&#160;protected]</span></a>
    </p>
    <p class="cmsb240-pt-3">
        <a class="footer-links-group-item-link cmsb240-underline" tabindex="0" title="Get Directions" href="/map">Get Directions</a>
    </p>
</div></div>                                                                            </div>
    </div>
        <div class="bg-headerFooter">
        <div class="container pt-7 pb-5 flex justify-between items-center flex-col sm:flex-row lg:flex-row-reverse text-sm">
            <nav class="text-white text-center mb-2" aria-label="Legal Menu">
                <a href="https://www.masterbooks.com/privacy-policy-cookie-restriction-mode/"
                   class="inline-block py-1 px-2 sm:px-0 sm:mr-4 sm:last:mr-0 hover:underline">
                    Privacy And Cookie Policy                </a>
                <a href="https://www.masterbooks.com/sales/guest/form/"
                   class="inline-block py-1 px-2 sm:px-0 sm:mr-4 sm:last:mr-0 hover:underline">
                    Orders and Returns                </a>
                <a href="https://www.masterbooks.com/sitemap.html/"
                   class="inline-block py-1 px-2 sm:px-0 sm:mr-4 sm:last:mr-0 hover:underline">
                    Sitemap                </a>
                <a href="https://www.masterbooks.com/contact/"
                   class="inline-block py-1 px-2 sm:px-0 sm:mr-4 sm:last:mr-0 hover:underline">
                    Contact Us                </a>
            </nav>
            <small class="text-sm text-white">
    <span>&copy; Master Books</span>
</small>
        </div>
    </div>
</div>
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script>
    'use strict';

    function amBrandsPopup() {
        let cached = false;

        const displayError = (error) => {
            console.error(error);
            typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                [{
                    type: "error",
                    text: "Something\u0020went\u0020wrong.\u0020Please\u0020try\u0020again."
                }], 10000
            );
        };

        let letters = [
            "A","B","C","D",
            "E","F","G","H","I","J","K","L","M",
            "N","O","P","Q","R","S","T","U","V","W","X","Y","Z","#"
        ];

        return {
            hoverPanelActiveId: null,
            selectedLetter: null,
            items: [],
            letters: [],
            showCount: null,
            showFilter: null,
            showImages: true,
            showSearch: null,
            loading: false,
            label: 'Authors',
            isPopupEnabled: false,
            isTopMenuItemEnabled: false,
            cache: false,
            isMobile: false,

            initErrorMessages(errors) {
                const messages = [];
                for (let error in Object.keys(errors)) {
                    messages.push({type: 'error', text: errors[error].message});
                }
                typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(messages, 10000);
            },

            chooseLetter(letter) {
                this.selectedLetter = this.selectedLetter === letter ? null : letter;
            },

            getQuery() {
                return "query BrandsPopupQuery { ambrandlist(\n                    showCount: true\n                    displayZero: true\n                  ) {\n                    all_letters,\n                    items {\n                      alt\n                      brandId\n                      cnt\n                      image\n                      img\n                      label\n                      letter\n                      url\n                    }\n                  }\n                  storeConfig {\n                    amshopby_brand_general_brands_brands_popup,\n                    amshopby_brand_general_menu_item_label,\n                    amshopby_brand_general_brands_page,\n                    amshopby_brand_general_topmenu_enabled,\n                    amshopby_brand_general_brands_popup_config {\n                      show_images,\n                      display_zero,\n                      filter_display_all,\n                      image_width,\n                      image_height,\n                      show_filter,\n                      show_count\n                    }\n                  } }"            },

            /**
             * Retrieve media url for given path
             *
             * @param path
             * @returns {string}
             */
            getMediaUrl(path) {
                const baseUrl = BASE_URL.replace('index.php/', '');
                if (path.includes('://')) {
                    return path;
                }

                let productImageUrl = `${baseUrl}${path}`;
                const regexDuplicateDomain = new RegExp(`^(https?:\/\/[^/]+).*\\1`);
                productImageUrl = productImageUrl.replace(regexDuplicateDomain, '$1');

                return productImageUrl.includes('/product/placeholder/')
                    ? productImageUrl.replace(/\/media(?=\/static)/, '')
                    : productImageUrl;
            },

            checkIsMobileResolution() {
                this.isMobile = window.matchMedia('(max-width: 1023px)').matches;
            },

            getBrandUrl(url){
                return BASE_URL + url;
            },

            init() {
                this.checkIsMobileResolution();

                                    this.$watch('hoverPanelActiveId', (value) => {
                        if (value === 'am-brand') {
                            this.sendRequest();
                        }
                    });
                            },

            /**
             * Get brands by letter
             *
             * @param result
             * @returns {{imageWidth: *, isTopMenuItemEnabled: *, showCount: *, displayAll: *, showFilter: *, showImages: *, isPopupEnabled: *, label: *, imageHeight: *, filterDisplayAll: *, brandsPage: *}}
             */
            settingsMapper(result) {
                const config = result.data.storeConfig?.amshopby_brand_general_brands_popup_config;
                return {
                    showImages: config.show_images,
                    showCount: config.show_count,
                    showFilter: config.show_filter,
                    imageWidth: config.image_width,
                    imageHeight: config.image_height,
                    filterDisplayAll: config.filter_display_all,
                    displayAll: config.display_zero,
                    isPopupEnabled: result.data.storeConfig?.amshopby_brand_general_brands_brands_popup,
                    label: result.data.storeConfig?.amshopby_brand_general_menu_item_label,
                    isTopMenuItemEnabled: result.data.storeConfig?.amshopby_brand_general_topmenu_enabled,
                    brandsPage: result.data.storeConfig?.amshopby_brand_general_brands_page,
                }
            },

            /**
             * Send request to graphql
             *
             * @returns {Promise<any>}
             */
            async sendRequest() {
                if (this.isMobile) {
                    return false;
                }

                this.loading = true;

                try {
                    if (cached) {
                        this.loading = false;
                        return false;
                    }

                    const response = await fetch('https://www.masterbooks.com/graphql', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                            'Store': 'masterbooks'
                        },
                        credentials: 'include',
                        body: JSON.stringify({query: this.getQuery(), variables: {}})
                    });

                    const result = await response.json();

                    if (result?.errors) {
                        this.initErrorMessages(result.errors);
                        return;
                    }

                    const data = result.data?.ambrandlist;
                    const mapper = this.settingsMapper(result);

                    // Update component settings
                    Object.keys(mapper).forEach(config => {
                        this[config] = mapper[config];
                    });

                    if (!this.filterDisplayAll) {
                        letters = data.all_letters.split(',');
                    }

                    const items = data.items.map(brand => {
                        brand.image = brand.img
                            ? this.getMediaUrl(brand.img) : (brand.image ? this.getMediaUrl(brand.image) : null);
                        return brand;
                    });

                    this.letters = letters.map(letter => ({
                        letter,
                        brands: this.getLetterItems(items, letter),
                    }));

                    this.items = this.letters.filter(row => row.brands?.length > 0);

                    cached = true;
                } catch (error) {
                    displayError(error);
                } finally {
                    this.loading = false;
                }
            },

            /**
             * Get brands by letter
             *
             * @param items
             * @param letter
             * @returns {*}
             */
            getLetterItems(items, letter) {
                return items.filter(row => row.letter === letter);
            },

            convertHtml(text) {
                let textField = document.createElement("textarea");
                textField.innerHTML = text;
                return textField.value;
            }
        }
    }
    
    function amBrandsPopupData() {
        return Object.assign(
            amBrandsPopup(),
            {
                brandPopupClass() {
                    return {
                        'hover:border-primary data-[active]:border-primary': !this.isPopupEnabled
                    }
                },
                labelPopupClass() {
                    return {'w-14 opacity-0': this.label === ''}
                },
                popupcontentClass() {
                    return {
                        'hidden' : this.hoverPanelActiveId !== 'am-brand',
                        'left-0' : `${this.$el.dataset.first}`,
                        'right-0' : `${this.$el.dataset.last}`
                    }
                },
                panelActiveMouseenterEvent() {
                    return this.hoverPanelActiveId = 'am-brand'
                },
                panelActiveMouseleaveEvent() {
                    return this.hoverPanelActiveId = null
                },
                isPopupShow() {
                    return this.hoverPanelActiveId === 'am-brand'
                },
                labelText(){
                    return this.label
                },
                isEnabledPopup(){
                    return this.isPopupEnabled
                },
                showExtMessage(){
                    return false
                },
                notLoading() {
                    return !this.loading
                },
                brandLabel() {
                    return this.brand.label
                },
                letterClass() {
                    return {
                        'border-blue-400 text-blue-400 bg-blue-100': this.selectedLetter === this.letter.letter,
                        'bg-gray-200 text-gray-700 cursor-default pointer-events-none': !this.letter.brands || this.letter.brands.length === 0
                    }
                },
                letterClickEvent(event) {
                    return this.chooseLetter(this.letter.letter)
                },
                letterBrands() {
                    return this.letter.brands
                },
                brandUrl() {
                    return this.getBrandUrl(this.brand.url)
                },
                brandImage() {
                    return this.brand.image
                },
                notBrandImage() {
                    return !this.brand.image
                },
                letterLetter() {
                    return this.letter.letter
                },
                brandBrandId() {
                    return this.brand.brandId
                },
                isLetterShow() {
                    return !this.selectedLetter || this.selectedLetter === this.letter.letter
                },
                brandImageMediaUrl() {
                    return this.getMediaUrl(this.brand.image)
                },
                brandImageStyle() {
                    return `max-width: ${this.imageWidth ? this.imageWidth + 'px' : '100px' };max-height: ${this.imageHeight ? this.imageHeight + 'px' : 'inherit'}`
                },
                brandsLabelStyle() {
                    return `min-width: ${this.imageWidth}px`
                },
                brandLabelFilter() {
                    return this.brand.label.charAt(0)
                },
                brandCnt() {
                    return '(' + this.brand.cnt + ')'
                }
            }
        )
    }
    window.addEventListener('alpine:init', () => Alpine.data('amBrandsPopupData', amBrandsPopupData), {once: true});
</script>
</div></footer>
<script>
    function amBannerInjectorResolver () {
        const injectors = Object.values({"products.among.injector":{"position":14,"name":"amBannerAmongCategoryInjector"},"products.belowcart.injector":{"position":15,"name":"amBannerBelowCartInjector"}});

        return {
            amBannerAmongCategoryInjector: function (sectionId, injectorParams) {
                const container = document.querySelector('[data-role="amasty-banner-container"][data-position="' + sectionId + '"]');

                Object.keys(injectorParams.banners).map((id) => {
                    const params = injectorParams.banners[id];
                    const element = container.querySelector('[data-banner-id="' + id + '"]');
                    insertBannerAmongCategoryByConfig({
                        containerSelector: injectorParams.containerSelector,
                        itemSelector: injectorParams.itemSelector,
                        afterProductRow: params.afterProductRow,
                        afterProductNum: params.afterProductNum,
                        span: params.width
                    }, element);
                });

                function insertBannerAmongCategoryByConfig (injectorConfig, element) {
                    const options = {
                        injectorConfig: {},
                        container: null,
                        after: null,
                        wrapper: null,
                        initialized: false,
                        gridSizes: ['sm', 'xl'],
                        bannerWidthClass: 'col-span',
                        ...injectorConfig
                    }

                    insertBanner(element);

                    function insertBanner(element) {
                        const initialized = setOptions();

                        if (!initialized) {
                            return;
                        }

                        element.classList.add('ambanners-injected-banner');
                        const wrapper = options.wrapper.cloneNode(true);

                        wrapper.classList.remove('card', 'card-interactive');
                        addStylesForDifferentSizes(wrapper);

                        insertWrapper(wrapper);
                        wrapper.append(element);
                    }

                    function setOptions () {
                        const initialized = document.querySelector(options.containerSelector) !== null;

                        if (!initialized) {
                            console.warn(
                                'Failed to initialize banner: Can\'t find an element with selector "' + options.containerSelector + '"'
                            );

                            return;
                        }

                        options.container = document.querySelector(options.containerSelector);

                        setLineToInject();

                        if (!options.after) {
                            return;
                        }

                        setWrapper();

                        return true;
                    }

                    function setLineToInject() {
                        if (options.afterProductNum === -1) {
                            setFirstLineToInject();
                        } else {
                            setLineByPositionToInject();
                        }
                    }

                    function setWrapper() {
                        if (options.after) {
                            options.wrapper = options.after.cloneNode();
                        }
                    }

                    function setFirstLineToInject() {
                        options.after = document.querySelector(options.itemSelector);
                    }

                    function setLineByPositionToInject() {
                        // calc banner insert offset
                        const offset = calculateOffsetBasedOnPreviousBanners();

                        options.after = document.querySelectorAll(options.itemSelector)[options.afterProductNum - offset];
                    }

                    function calculateOffsetBasedOnPreviousBanners () {
                        return [...document.querySelectorAll(`${options.itemSelector}`)]
                            ?.reduce((accumulator, amInjectedBannerWrapper) => {
                                const widthAttributeValue = Number(amInjectedBannerWrapper?.getAttribute('am-banner-span'))

                                if (widthAttributeValue > 1) {
                                    accumulator += (widthAttributeValue - 1);
                                }

                                return accumulator;
                            }, 0);
                    }

                    function insertWrapper(insert) {
                        if (options.after) {
                            insertWrapperAfterFoundProduct(insert);
                        } else if (options.container) {
                            insertWrapperInProductListContainer(insert);
                        }
                    }

                    function insertWrapperAfterFoundProduct(insert) {
                        if (options.afterProductNum === -1) {
                            options.after.parentNode.insertBefore(insert, options.after);
                        } else {
                            options.after.parentNode.insertBefore(insert, options.after.nextSibling);
                        }
                    }

                    function insertWrapperInProductListContainer(insert) {
                        if (parseInt(options.afterProductRow) > 1) {
                            options.container.innerHTML += insert.innerHTML;
                        } else {
                            options.container.innerHTML = insert.innerHTML + options.container.innerHTML;
                        }
                    }

                    function addStylesForDifferentSizes (wrapper) {
                        options.gridSizes?.forEach((size, index) => {
                            const widthValue = options.span > index + 1 ? index + 2 : options.span;
                            wrapper?.classList.add(`${size}:${options.bannerWidthClass}-${widthValue}`);
                            wrapper?.setAttribute('am-banner-span', widthValue);
                        });
                    }
                }
            },

            amBannerBelowCartInjector: function (sectionId) {
                const belowProductAddToCartBanner = document.querySelector('.ambanners.ambanner-' + sectionId);
                belowProductAddToCartBanner.style.display = 'block';
                document.querySelectorAll('.product-item')?.forEach(product => {
                    product.querySelector('[data-role="amasty-banner-container"]')?.remove();
                    product?.append(belowProductAddToCartBanner.cloneNode(true));
                });
                belowProductAddToCartBanner.style.display = 'none';
            },

            resolve: function (position, injectorParams) {
                const injector = injectors.find((injector) => {
                    return injector.position === Number(position);
                });

                return this[injector?.name]?.(position, injectorParams);
            }
        }
    }
</script>
<script>
    function dataAmPreorderAvailability() {
        return {
            note: '',
            isNeedShow: false,
            productId: null,

            initAmPreorderAvailability() {
                this.note = `${this.$el.dataset.note}`;
                this.isNeedShow = `${this.$el.dataset.isNeedShow === 'true'}`;
                this.productId = `${this.$el.dataset.productId}`;
                
                window.addEventListener(`am-preorder-change-availability-${this.productId}`, (event) => {
                    this.note = event.detail.preOrderNote;
                    this.isNeedShow = event.detail.isNeedShow;
                });
            }
        }
    }

    window.addEventListener(
        'alpine:init',
        () => Alpine.data(
            'dataAmPreorderAvailability',
            dataAmPreorderAvailability
        ),
        {once: true}
    );
</script>
<script>
    function dataAmPreorderBtn() {
        return {
            cartLabel: '',
            title: '',
            ariaLabel: '',
            productId: this.$el.dataset.productId,

            initAmPreorderBtn() {
                this.cartLabel = `${this.$el.dataset.label}`;
                this.title = `${this.$el.dataset.title}`;
                this.ariaLabel = `${this.$el.dataset.ariaLabel}`;
                this.productId = `${this.$el.dataset.productId}`;
                
                window.addEventListener(`am-preorder-change-btn-${this.productId}`, (event) => {
                    this.cartLabel = event.detail.addToCartLabel;
                    this.title = event.detail.title;
                    this.ariaLabel = event.detail.ariaLabel;
                });
            }
        }
    }

    window.addEventListener(
        'alpine:init',
        () => Alpine.data(
            'dataAmPreorderBtn',
            dataAmPreorderBtn
        ),
        {once: true}
    );
</script>


<script type="text/x-magento-init">
{
    "body": {
        "Amasty_MWishlist/js/multiple-wishlist": {
                        "loginUrl": "https://www.masterbooks.com/customer/account/login/referer/aHR0cHM6Ly93d3cubWFzdGVyYm9va3MuY29tL2tub3dsZWRnZS1xdWVzdA~~/",
                        "addItemUrl": "https://www.masterbooks.com/mwishlist/item/add/",
            "isCustomerLoggedIn": 0        }
    }
}
</script>
<aside class="amwishlist-popup-block"
       x-data="initAmastyWishlistPopup()"
       x-show="showPopup"
       :class="{'-active': showPopup}"
       @open-amasty-wishlist-popup.window = "handleOpenPopupAction($event.detail)"
       @private-content-loaded.window="extractSectionData($event.detail.data)"
       @add-new-list-customer-account.window="addNewList($event.detail.newListNameCustomerAccount, true)"
       @amasty-validate-wishlist-name.window="isNameValid($event.detail.wishlistName)"
       @amasty-delete-wish-list.window="deleteWishList($event.detail.element)"
       @amasty-add-wishlist-to-cart.window="addToCart($event.detail.wishListId)"
       @amasty-add-wishlist-single-item-to-cart.window="addToCartSingleItem($event.detail.element)"
       @amasty-trigger-delete-wishlist-popup.window="popupType=$event.detail.popupType;handleOpenPopupAction({})"
       x-cloak
       data-ampopup-js="popup"
       data-bind="
            scope:'ampopup',
            mageInit: {
             'Magento_Ui/js/core/app': {&quot;components&quot;:{&quot;ampopup&quot;:{&quot;component&quot;:&quot;Amasty_MWishlist\/js\/components\/popup\/popup&quot;,&quot;config&quot;:{&quot;wrapper&quot;:&quot;[data-amwishlist-js=\&quot;popup\&quot;]&quot;,&quot;template&quot;:&quot;Amasty_MWishlist\/components\/popup\/wrapper&quot;},&quot;children&quot;:{&quot;amwishlist&quot;:{&quot;component&quot;:&quot;Amasty_MWishlist\/js\/components\/popup\/wishlist&quot;,&quot;config&quot;:{&quot;template&quot;:&quot;Amasty_QuickOrder\/components\/popup\/wishlist&quot;,&quot;actions&quot;:{&quot;addNewList&quot;:&quot;https:\/\/www.masterbooks.com\/mwishlist\/wishlist\/create\/&quot;,&quot;validateNewName&quot;:&quot;https:\/\/www.masterbooks.com\/mwishlist\/wishlist\/validateWishlistName\/custom\/1\/&quot;},&quot;typesMap&quot;:[&quot;Wish Lists&quot;]}}}}}}            }"
       aria-modal="true"
       :aria-expanded="showPopup">
    <div class="amwishlist-popup"
     @click.outside="closePopup()">
    <div class="amwishlist-toolbar -header">
        <button class="amwishlist-button -close -clear"
                @click.prevent="closePopup()">
        </button>
    </div>
    <div class="amwishlist-title">
        <h5 class="amwishlist-header" x-show="popupType !== 'delete'">
            Choose the list for selected product        </h5>
        <p class="amwishlist-desc" data-bind="visible: description, html: description"></p>
    </div>
    <div class="amwishlist-content">
        <template x-if="popupType !== 'delete'">
            <div class="amwishlist-list-block amwishlist-newlist-block">
    <button class="amwishlist-button -clear -link -plus"
            @click="displayAddNewWishlist =! displayAddNewWishlist">
        Create New List    </button>

    <div class="amwishlist-newlist" x-show="displayAddNewWishlist" x-cloak>
        <input class="amwishlist-input"
               placeholder="Enter List name"
               type="text"
               @input="isValidationFinished = false"
               x-model="newListName"
        >
        <button class="amwishlist-button -fill -primary -add"
                :class="{
                    '-disabled': hasWishlistNameValidationError || !newListName || !isValidationFinished
                }"
                @click="addNewList(newListName)">
            Add        </button>

        <ul class="amwishlist-messages-list"
            x-show="hasWishlistNameValidationError">
            <li class="amwishlist-item"
                x-text="wishlistNameValidationErrorMessage"></li>
        </ul>
    </div>
    <div class="amwishlist-tabs-block -block">
        <section class="amwishlist-content-tab -active">
            <ul class="amwishlist-list">
                <template x-for="shortList in shortLists">
                    <li class="amwishlist-item"
                        :data-label="getWishListData(shortList.id).count ? shortList.name[0] : 'The folder is empty'"
                        :data-id="shortList.id"
                        :class="{
                            '-active': activeWishListId && activeWishListId === shortList.id,
                            '-empty': getWishListData(shortList.id).count === 0
                        }"
                        @click="activeWishListId = shortList.id">
                        <span class="amwishlist-name" x-text="shortList.name"></span>
                        <span class="amwishlist-desc" x-text="getWishListData(shortList.id).wishlist_desc"></span>
                    </li>
                </template>
            </ul>
        </section>
    </div>
</div>
        </template>
        <template x-if="popupType === 'delete'">
            <div>
                Are you sure? This action can&#039;t be undone.            </div>
        </template>
    </div>
    <div class="amwishlist-toolbar -footer" data-bind="foreach: buttons, visible: buttons" x-show="popupType !== 'delete'" x-cloak>
        <button class="-fill -primary -addtolist amwishlist-button"
                :class="!activeWishListId ? '-disabled' : ''"
                @click="executeWishListEvent()"
                x-text="popupButtonLabel">
        </button>
    </div>
    <div class="amwishlist-toolbar -footer" data-bind="foreach: buttons, visible: buttons" x-show="popupType === 'delete'" x-cloak>
        <button class="-fill -primary -addtolist amwishlist-button"
                @click="closePopup()">
            Cancel        </button>
        <button class="-fill -primary -addtolist amwishlist-button"
                @click.prevent="$dispatch('amasty-delete-wish-list', {element: elementStorage})"
                x-text="popupButtonLabel">
        </button>
    </div>
</div>
</aside>
<script>
    function initAmastyWishlistPopup() {
        return {
            wishListEvent: 'add',
            showPopup: false,
            popupType: null,
            popupDefaultType: 'add',
            isCustomerLoggedIn: false,
            productId: null,
            displayAddNewWishlist: false,
            privateContentData: null,
            validateNewNameAction: 'mwishlist/wishlist/validateWishlistName',
            shortLists: null,
            wishListsData: null,
            activeWishListId: null,
            newListName: null,
            wishlistNameValidationErrorMessage: null,
            hasWishlistNameValidationError: false,
            popupButtonLabel: 'Add to List',
            popupActionButtonLabelMap: {
                'copy': 'Copy',
                'move': 'Move',
                'add': 'Add to List',
                'delete': 'OK'
            },
            actionEventData: null,
            elementStorage: null,
            isValidationFinished: false,
            handleOpenPopupAction: function (data) {
                if (!this.isCustomerLoggedIn) {
                    window.location.href = 'https://www.masterbooks.com/customer/account/login/';
                    return;
                }
                this.showPopup = true;

                if (data.hasOwnProperty('productId')) {
                    this.productId = data.productId;
                }

                if (data.actionEventData) {
                    this.actionEventData = data.actionEventData;

                    if (this.actionEventData.hasOwnProperty('element')) {
                        this.elementStorage = this.actionEventData.element;
                    }

                    this.shortLists = Object.values(this.shortLists).filter((list) => list.id != this.actionEventData.wishlistId);
                    this.wishListEvent = this.popupType = this.actionEventData.event;
                    this.popupButtonLabel = this.popupActionButtonLabelMap[this.wishListEvent] ?? this.popupActionButtonLabelMap['add'];
                }
            },
            init: function () {
                let validateName;
                this.$watch('newListName', (value, oldValue) => {
                    if (value && value !== oldValue) {
                        clearInterval(validateName);

                        validateName = setTimeout(() => {
                            this.isNameValid(value);
                        }, 1000);
                    }
                });
            },
            extractSectionData: function (sectionData) {
                this.shortLists = sectionData.multiplewishlist.short_list ?? [];
                this.shortLists.sort((a, b) => parseInt(b.id) - parseInt(a.id));
                this.wishListsData = sectionData.mwishlist.wishlist_list ?? [];
                this.isCustomerLoggedIn = !!(sectionData.customer.signin_token) ?? false;
                this.$dispatch('amasty-share-recently-lists', {recentlyLists: sectionData.mwishlist.recently_list ?? []});
            },
            deleteWishList: function (element) {
                let deleteData = JSON.parse(element.dataset.mwishlistAjax);
                deleteData.data.form_key = hyva.getFormKey();
                fetch(
                    deleteData.action,
                    {
                        method: 'POST',
                        body: this.buildFormData(deleteData.data)
                    }
                ).then(response => {
                    if (!response.ok) {
                        throw new Error('Response issues');
                    }

                    return response.json();
                }).then(data => {
                    this.$dispatch('amasty-response-delete-wish-list', {isSuccess: true});
                    window.location.href = 'https://www.masterbooks.com/mwishlist/index/index/'
                }).catch(error => {
                    console.error('Error adding item to wishlist: ' + error);
                });
            },
            getWishListData: function (wishListId) {
                let count = 0;

                if (this.wishListsData) {
                    this.wishListsData.forEach(item => {
                        if (Array.isArray(item)) {
                            item.forEach(subitem => {
                                if (wishListId == subitem.wishlist_id) {
                                    count = subitem.items_count;
                                }
                            })
                        }
                    })
                }

                return {
                    'wishlist_desc': hyva.str('%1 items', count),
                    'count': count
                }
            },
            addToWishList: function () {
                const activeWishList = document.querySelector('.amwishlist-item.-active');
                const wishListId = activeWishList.dataset.id;
                const payload = {
                    product: this.productId,
                    uenc: hyva.getUenc(),
                    form_key: hyva.getFormKey(),
                    wishlist_id: wishListId
                };
                fetch('https://www.masterbooks.com/mwishlist/item/add/', {
                    method: 'POST',
                    body: this.buildFormData(payload)
                })
                    .then(response => {
                        if (!response.ok) {
                            throw new Error('Network response issues');
                        }

                        return response.json();
                    })
                    .then(data => {
                        this.closePopup();
                        this.$dispatch('reload-customer-section-data');
                    })
                    .catch(error => {
                        console.error('Error adding item to wishlist:', error);
                    });
            },
            moveToWishListFromCart: function () {
                const activeWishList = document.querySelector('.amwishlist-item.-active');
                const wishListId = activeWishList.dataset.id;
                const payload = {
                    uenc: hyva.getUenc(),
                    form_key: hyva.getFormKey(),
                    item: _.get(this.actionEventData, 'itemId'),
                    wishlist_id: wishListId
                };
                fetch(_.get(this.actionEventData, 'action'),
                    {
                        method: 'POST',
                        body: this.buildFormData(payload)
                    }).then(response => {
                        if (!response.ok) {
                            throw new Error('Network response issues');
                        }

                        return response.json();
                    }).then(data => {
                        this.closePopup();
                        this.$dispatch('reload-customer-section-data');
                    }).catch(error => {
                        console.error('Error adding item to wishlist:', error);
                    });
            },
            addNewList: function (newListName, isExternalCall = false) {
                if (isExternalCall) {
                    this.isNameValid(newListName, true);
                    if (this.hasWishlistNameValidationError) {
                        return;
                    }
                }

                const payload = {
                    'wishlist[name]': newListName,
                    'wishlist[type]': 0,
                    'form_key': hyva.getFormKey()
                };
                fetch('https://www.masterbooks.com/mwishlist/wishlist/create/', {
                    method: 'POST',
                    body: this.buildFormData(payload)
                }).then(response => {
                    if (!response.ok) {
                        throw new Error('Response issues');
                    }

                    return response.json();
                }).then(data => {
                    this.displayAddNewWishlist = false;
                    this.newListName = null;
                    this.$dispatch('reload-customer-section-data');
                }).catch(error => {
                    console.error('Error adding item to wishlist: ' + error);
                });
            },
            buildFormData: function (object) {
                const formData = new FormData();
                Object.entries(object).forEach(([key, value]) => {
                    formData.append(key, value);
                });

                return formData;
            },
            closePopup: function () {
                this.showPopup = false;
                this.activeWishListId = false;
                this.newListName = null;
                this.popupType = this.popupDefaultType;
            },
            isNameValid: function (value, isExternalCall = false) {
                let amValidationEventObject = {};
                this.hasWishlistNameValidationError = false;
                if (!value || this.isWhitespaceString(value)) {
                    if (isExternalCall) {
                        this.hasWishlistNameValidationError = true;
                        amValidationEventObject = {
                            hasWishlistNameValidationError: this.hasWishlistNameValidationError,
                            wishlistNameValidationErrorMessage: 'Empty Value.'
                        };
                        this.$dispatch('amasty-new-wishlist-name-validation-error', amValidationEventObject);
                    }
                    return;
                }
                this.wishlistNameValidationErrorMessage = null;
                const payload = {
                    'wishlist[name]': value,
                    'custom': true,
                    'form_key': hyva.getFormKey()
                };
                fetch('https://www.masterbooks.com/mwishlist/wishlist/validateWishlistName/', {
                    method: 'POST',
                    body: this.buildFormData(payload)
                })
                    .then(response => {
                        if (!response.ok) {
                            throw new Error('Network response was not ok');
                        }
                        return response.json();
                    })
                    .then(data => {
                        this.isValidationFinished = true;
                        this.hasWishlistNameValidationError = data.hasOwnProperty('errors') && data.errors.length;
                        amValidationEventObject = {
                            hasWishlistNameValidationError: this.hasWishlistNameValidationError
                        };

                        if (this.hasWishlistNameValidationError) {
                            amValidationEventObject['wishlistNameValidationErrorMessage'] = this.wishlistNameValidationErrorMessage = data.errors.pop();
                        }

                        this.$dispatch('amasty-new-wishlist-name-validation-error', amValidationEventObject);
                    })
                    .catch(error => {
                        console.error('Error adding item to wishlist:' + error);
                    });
            },
            migrateWishlistItemsAction: function () {
                let payload = {
                    'wishlist_id': this.actionEventData.wishlistId,
                    'form_key': hyva.getFormKey(),
                    'to_wishlist_id': this.activeWishListId
                };
                payload = this.addItemIdsAndQtys(payload, this.actionEventData);
                fetch(
                    this.actionEventData.action,
                        {
                            method: 'POST',
                            body: this.buildFormData(payload)
                        }
                    ).then(response => {
                        if (!response.ok) {
                            throw new Error('Network response was not ok');
                        }
                        return response.json();
                    }).then(data => {
                        if (this.wishListEvent === 'move') {
                            this.$dispatch('amasty-delete-items-by-id');
                        }
                        this.$dispatch('reload-customer-section-data');
                        this.closePopup();
                    }).catch(error => {
                        console.error('Error adding item to wishlist:' + error);
                    });
            },
            addItemIdsAndQtys: function (payload, copyData) {
                Object.values(copyData.itemIds).forEach(id => {
                    payload[`selected[${id}]`] = 'on';
                });
                copyData.productQtyList.forEach(((element, index) => {
                    payload[`qty[${index}]`] = element;
                }))

                return payload;
            },
            executeWishListEvent: function () {
                if (this.wishListEvent === 'add') {
                    this.addToWishList();
                }
                if (this.wishListEvent === 'move_from_cart') {
                    this.moveToWishListFromCart();
                }
                if (['move', 'copy'].includes(this.wishListEvent)) {
                    this.migrateWishlistItemsAction();
                }
            },
            addToCart: function (wishListId) {
                let payload = {
                    'wishlist_id': wishListId,
                    'form_key': hyva.getFormKey(),
                    'uenc': hyva.getUenc()
                };
                fetch(
                    'https://www.masterbooks.com/wishlist/index/allcart/',
                    {
                        method: 'POST',
                        body: this.buildFormData(payload)
                    }
                ).then(response => {
                    if (!response.ok) {
                        throw new Error('Network response was not ok');
                    }

                    return response.text();
                }).then(data => {
                    window.location.reload();
                }).catch(error => {
                    console.error('Error adding item to wishlist. Reason: ' + error);
                });
            },
            addToCartSingleItem: function (element) {
                const itemData = JSON.parse(element.dataset.mwishlistAjax);
                let payload = {
                    'item': _.get(itemData, 'data.item'),
                    'qty': _.get(itemData, 'data.qty'),
                    'wishlist_id': _.get(itemData, 'data.wishlist_id'),
                    'block': _.get(itemData, 'data.block'),
                    'component': _.get(itemData, 'data.component'),
                    'form_key': hyva.getFormKey()
                };
                fetch(
                    _.get(itemData, 'action'),
                    {
                        method: 'POST',
                        body: this.buildFormData(payload)
                    }
                ).then(response => {
                    if (!response.ok) {
                        throw new Error('Network response was not ok');
                    }
                    return response.json();
                }).then(data => {
                    window.location.reload();
                }).catch(error => {
                    console.error('Error adding item to cart:' + error);
                });
            },
            isWhitespaceString: function (string) {
                return !string.replace(/\s/g, '').length;
            }
        }
    }
</script>
<script src="https://www.youtube.com/iframe_api"></script>

<script type="module"
        src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"
        defer
        crossorigin
></script>

<script>
    let SnapSlider = class {
        constructor(el, {
            labelSepparator = 'of',
            autoPager,
            groupPager
        } = {}) {
            this.el = el;
            this.track = this.el.querySelector("[data-track]");
            if (!this.track) {
                console.warn(
                    "No Slider track defined, reverting back to CSS slider.\nPlease create a wrapper for your slides with the attribute data-track",
                    this.el
                );
                return;
            }
            this.initialLoad = true;
            this.slides = [];
            this.inViewObserver;
            this.mutationObserver;
            this.resizeObserver;
            this.pager = this.el.querySelector("[data-pager]");
            this.navBtns = Array.from(
                this.el.querySelectorAll("[data-next], [data-prev]")
            );
            this.slideLabelSepparator = this.el.dataset.slideLabelSepparator || labelSepparator;
            this.useAutoPager = autoPager || this.el.hasAttribute("data-auto-pager") || false;
            this.useGroupPager = groupPager || this.el.hasAttribute("data-group-pager") || false;
            this.sliderLabel = this.el.hasAttribute("aria-label") && this.el.getAttribute("aria-label").toLowerCase().trim().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
            this.sliderId = this.el.id || this.sliderLabel || "slider";
            this.markerIdName = "data-target-id";
            this.pagerClasses = this.el.dataset.pagerClass || "snap-pager";
            this.markerClasses = this.el.dataset.markerClass || "snap-marker";
            this.init();
        }
        init() {
            this.setupSlides();
            this.setupNav();
            if (this.useAutoPager) {
                this.createPager();
            } else {
                this.setupPager();
            }
            this.setupObservers();
            this.setupMutationObserver();
            this.setupResizeObserver();
            this.el.addEventListener("click", this.eventHandler.bind(this));
            this.el.addEventListener("keydown", this.eventHandler.bind(this));
        }
        destroy() {
            this.inViewObserver?.disconnect();
            this.mutationObserver?.disconnect();
            this.resizeObserver?.disconnect();
            this.el.removeEventListener("click", this.eventHandler.bind(this));
            this.el.removeEventListener("keydown", this.eventHandler.bind(this));
        }
        roundUpIfGreaterThan(number, min = 8) {
            const decimalPart = number - Math.floor(number);
            return decimalPart >= min ? Math.ceil(number) : Math.floor(number);
        }
        getInViewItems() {
            const inViewSlides = this.track.querySelectorAll("[data-in-view]");
            const firstInViewSlide = inViewSlides[0] || null;
            const lastInViewSlide = inViewSlides[inViewSlides.length - 1] || null;
            const isAtStart = firstInViewSlide === this.slides[0];
            const isAtEnd = lastInViewSlide === this.slides[this.slides.length - 1];
            return {
                inViewSlides,
                totalInViewSlides: inViewSlides.length,
                firstInViewSlide,
                lastInViewSlide,
                isAtStart,
                isAtEnd,
                hasNoOverflow: isAtStart && isAtEnd
            };
        }
        groupPagerMarkers() {
            if (this.slides.length === 0 || !this.pager || !this.useGroupPager) return;
            const totalVisibleSlides = this.roundUpIfGreaterThan(
                this.track.offsetWidth / this.slides[0].offsetWidth
            );
            const markers = Array.from(this.pager.querySelectorAll("a, button"));
            markers.forEach((marker, index) => {
                marker.style.display = index % totalVisibleSlides === 0 ? null : "none";
            });
        }
        handleInView(entries) {
            entries.forEach((entry) => {
                const marker = this.pager && (this.pager.querySelector(`[href="#${entry.target.id}"]`) || this.pager.querySelector(
                    `[${this.markerIdName}="${entry.target.id}"]`
                ));
                entry.target.toggleAttribute("data-in-view", entry.isIntersecting);
                entry.target.toggleAttribute("inert", !entry.isIntersecting);
                marker?.setAttribute("aria-current", entry.isIntersecting);
                marker?.setAttribute("tabindex", entry.isIntersecting ? "0" : "-1");
            });
            const {
                isAtStart,
                isAtEnd,
                hasNoOverflow
            } = this.getInViewItems();
            this.navBtns.forEach((btn) => {
                if (btn.hasAttribute("data-next")) {
                    btn.style.visibility = hasNoOverflow ? "hidden" : null;
                    isAtEnd ? btn.setAttribute("disabled", "") : btn.removeAttribute("disabled");
                }
                if (btn.hasAttribute("data-prev")) {
                    btn.style.visibility = hasNoOverflow ? "hidden" : null;
                    isAtStart ? btn.setAttribute("disabled", "") : btn.removeAttribute("disabled");
                }
            });
            if (this.pager) {
                this.pager.style.visibility = hasNoOverflow ? "hidden" : null;
            }
            if (!this.initialLoad) {
                this.el.dispatchEvent(
                    new CustomEvent("slideChange", {
                        detail: this.getInViewItems()
                    })
                );
            } else {
                this.initialLoad = false;
            }
            if (document.activeElement.parentElement.hasAttribute("data-pager")) {
                const activeItems = this.pager.querySelectorAll('[tabindex="0"]');
                if (activeItems.length) {
                    activeItems[0].focus({ preventScroll: true });
                }
            }
        }
        getSlides() {
            if (!this.track) return [];
            return Array.from(this.track.children).filter(
                (child) => child.tagName.toLowerCase() !== "template" && child.tagName.toLowerCase() !== "style" && child.tagName.toLowerCase() !== "script"
            );
        }
        refreshSlides() {
            this.initialLoad = true;
            this.slides = this.getSlides();
            this.setupSlides();
            if (this.useAutoPager) {
                this.createPager();
            } else {
                this.setupPager();
            }
            this.groupPagerMarkers();
            this.setupObservers();
        }
        setupSlides() {
            this.slides = this.getSlides();
            this.slides.forEach((slide, index) => {
                const totalSlides = this.slides.length;
                const currentSlide = index + 1;
                const existingLabel = slide.getAttribute("aria-label") || "";
                const isImage = slide.tagName.toLowerCase() === "img" || slide.tagName.toLowerCase() === "picture";
                const slideLabelTag = isImage ? "alt" : "aria-label";
                const hasAutoLabel = existingLabel.startsWith(
                    `${currentSlide} ${this.slideLabelSepparator} `
                );
                if (!slide.hasAttribute("id")) {
                    slide.setAttribute(
                        "id",
                        `${this.sliderId}-item-${currentSlide}`
                    );
                }
                if (!slide.hasAttribute(slideLabelTag) || slide.getAttribute(slideLabelTag) === "" || hasAutoLabel) {
                    slide.setAttribute(
                        slideLabelTag,
                        `${currentSlide} ${this.slideLabelSepparator} ${totalSlides}`
                    );
                }
                if (slide.tagName.toLowerCase() === "div" && !slide.hasAttribute("role")) {
                    slide.setAttribute("role", "group");
                }
                if (this.pager && !isImage) {
                    slide.setAttribute("role", "tabpanel");
                }
                if (slide.getAttribute("role") === "group") {
                    slide.setAttribute("aria-roledescription", "item");
                }
            });
            if (!this.el.hasAttribute("role") && this.el.tagName !== "SECTION") {
                this.el.setAttribute("role", "region");
            }
            if (!this.el.hasAttribute("aria-roledescription")) {
                this.el.setAttribute("aria-roledescription", "carousel");
            }
            this.track.setAttribute("tabindex", 0);
            this.track.setAttribute("aria-live", "polite");
        }
        setupNav() {
            this.navBtns.forEach((btn) => {
                btn.setAttribute("disabled", "");
                btn.removeAttribute("hidden");
                btn.classList.remove("invisible");
                btn.style.visibility = null;
            });
        }
        createPager() {
            const newPager = document.createElement("nav");
            newPager.setAttribute("data-pager", "");
            newPager.setAttribute("role", "tablist");
            newPager.classList.add(...this.pagerClasses.split(" "));
            this.slides.forEach((slide, index) => {
                const marker = document.createElement("button");
                const slideId = slide.id || `${this.sliderId}-item-${index + 1}`;
                marker.setAttribute(this.markerIdName, slideId);
                marker.classList.add(...this.markerClasses.split(" "));
                this.setupPagerMarker(marker, index);
                newPager.appendChild(marker);
                if (slide.tagName.toLowerCase() !== "img" && slide.tagName.toLowerCase() !== "picture") {
                    slide.removeAttribute("aria-roledescription");
                    slide.setAttribute("role", "tabpanel");
                }
            });
            if (this.pager) {
                this.pager.setAttribute("role", "tablist");
                this.pager.replaceChildren(...newPager.children);
            } else {
                this.track.after(newPager);
                this.pager = this.el.querySelector("[data-pager]");
            }
        }
        setupPager() {
            if (!this.pager) return;
            this.pager.setAttribute("role", "tablist");
            const items = Array.from(this.pager.querySelectorAll("a, button"));
            items.forEach((marker, index) => this.setupPagerMarker(marker, index));
        }
        setupPagerMarker(marker, index) {
            const markerId = marker.getAttribute("href")?.slice(1) || marker.getAttribute(this.markerIdName);
            const slideId = markerId || `${this.sliderId}-item-${index + 1}`;
            if (!markerId) {
                marker.setAttribute(this.markerIdName, slideId);
            }
            marker.setAttribute("role", "tab");
            marker.setAttribute("aria-controls", slideId);
            marker.setAttribute("aria-posinset", index + 1);
            marker.setAttribute("aria-setsize", this.slides.length);
            marker.setAttribute("tabindex", "-1");
            if (!marker.hasAttribute("aria-label")) {
                marker.setAttribute("aria-label", `Slide ${index + 1}`);
            }
        }
        setupObservers() {
            if (this.inViewObserver) {
                this.inViewObserver.disconnect();
            }
            this.inViewObserver = new IntersectionObserver(
                this.handleInView.bind(this), {
                    root: this.track,
                    threshold: 0.8
                }
            );
            this.slides.forEach((slide) => this.inViewObserver.observe(slide));
        }
        setupMutationObserver() {
            this.mutationObserver = new MutationObserver(
                this.refreshSlides.bind(this)
            );
            this.mutationObserver.observe(this.track, {
                childList: true,
                subtree: false
            });
        }
        setupResizeObserver() {
            this.resizeObserver = new ResizeObserver(
                this.groupPagerMarkers.bind(this)
            );
            this.resizeObserver.observe(this.el);
        }
        goToSlideDir(dir = "next") {
            const {
                firstInViewSlide,
                lastInViewSlide
            } = this.getInViewItems();
            const isPrev = dir === "prev";
            let targetSlide = isPrev ? firstInViewSlide?.previousElementSibling : lastInViewSlide?.nextElementSibling;
            if (!targetSlide) return;
            if (targetSlide.tagName.toLowerCase() === "template") {
                targetSlide = isPrev ? targetSlide?.previousElementSibling : targetSlide?.nextElementSibling;
            }
            targetSlide.scrollIntoView({ block: "nearest", inline: isPrev ? "end" : "start" });
        }
        pagerToSlide(event) {
            if (!event.target.closest("[data-pager]")) return;
            const marker = event.target.closest("a, button");
            if (!marker) return;
            event.preventDefault();
            const slideId = marker.getAttribute("href")?.slice(1) || marker.getAttribute(this.markerIdName);
            const targetSlide = this.track.querySelector(`#${slideId}`);
            targetSlide?.scrollIntoView({ block: "nearest", inline: "start" });
        }
        eventHandler(event) {
            const target = event.target.closest(
                "[data-next], [data-prev], [data-pager]"
            );
            if (!target) return;
            if (event.type === "click") {
                if (target.hasAttribute("data-next")) {
                    this.goToSlideDir("next");
                } else if (target.hasAttribute("data-prev")) {
                    this.goToSlideDir("prev");
                } else if (target.closest("[data-pager]")) {
                    this.pagerToSlide(event);
                }
            }
            if (event.type === "keydown" && target.closest("[data-pager]")) {
                if (event.key === "ArrowRight") {
                    this.goToSlideDir("next");
                } else if (event.key === "ArrowLeft") {
                    this.goToSlideDir("prev");
                }
            }
        }
    };

    (() => {
        function alpineSnapSlider(Alpine) {
            Alpine.directive("snap-slider", (el, {
                modifiers
            }, {
                cleanup
            }) => {
                const autoPager = modifiers.includes("auto-pager");
                const groupPager = modifiers.includes("group-pager");
                const slider = new SnapSlider(el, {
                    autoPager,
                    groupPager
                });
                cleanup(() => {
                    slider.destroy();
                });
            });
        }

        document.addEventListener("alpine:init", () => {
            window.Alpine.plugin(alpineSnapSlider);
        });
    })();
    //# sourceURL=alpine-snap-slider.js
</script>

<script>
    (() => {
        // src/dialog.js
        function dialog_default(Alpine) {
            Alpine.directive("htmldialog", fylgjaAlpineDialog);
            function fylgjaAlpineDialog(el, { expression, modifiers }, { evaluateLater, cleanup }) {
            const evaluate = expression.length ? evaluateLater(expression) : () => {};
            const canEvaluate = expression.length > 0;
            const lockPageScroll = modifiers.includes("noscroll");
            const closeBy = el.getAttribute("closeby") || modifierValue(modifiers, "closeby", "closerequest");
            el.style.display = null;
            el.style.length === 0 && el.removeAttribute("style");
            if (el._x_isShown) {
                open();
            }
            const closeBySupported = (() => {
                return "closedBy" in HTMLDialogElement.prototype;
            })();
            function scrollLock(use = true) {
                document.body.style.overflow = use ? "hidden" : "";
            }
            function dialogSubmit(event) {
                if (event.target.getAttribute("method") === "dialog" || event.submitter?.getAttribute("formmethod") === "dialog") {
                event.preventDefault();
                evaluate();
                }
            }
            function escapeDialog(event) {
                if (event.key !== "Escape") return;
                event.preventDefault();
                if (closeBy === "none") return;
                evaluate();
            }
            function handleCloseByEvent(event) {
                if (event.target !== el) return;
                const rect = el.getBoundingClientRect();
                const isInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
                if (!isInDialog) {
                if (closeBy === "any") {
                    if (closeBySupported) {
                    event.preventDefault();
                    }
                    evaluate();
                }
                }
            }
            function handleCloseEvent() {
                evaluate();
            }
            function open() {
                if (el.hasAttribute("open")) return;
                el.showModal();
                scrollLock(lockPageScroll);
            }
            function close() {
                if (!el.hasAttribute("open")) return;
                el.close();
                scrollLock(false);
            }
            el._x_doShow = () => open();
            el._x_doHide = () => close();
            el.addEventListener("keydown", escapeDialog);
            el.addEventListener("submit", dialogSubmit);
            el.addEventListener("click", handleCloseByEvent);
            el.addEventListener("cancel", handleCloseEvent);
            cleanup(() => {
                el.removeEventListener("keydown", escapeDialog);
                el.removeEventListener("submit", dialogSubmit);
                el.removeEventListener("click", handleCloseByEvent);
                el.removeEventListener("cancel", handleCloseEvent);
                scrollLock(false);
            });
            }
        }
        function modifierValue(modifiers, key, fallback) {
            if (modifiers.indexOf(key) === -1) return fallback;
            const rawValue = modifiers[modifiers.indexOf(key) + 1];
            if (!rawValue) return fallback;
            if (key === "closeby") {
            const allowedValues = ["auto", "none", "closerequest", "any"];
            const options = allowedValues.join(", ");
            if (!allowedValues.includes(rawValue)) {
                console.warn(
                `"${rawValue}" is not one of the allowed values for closeby: ${options}`
                );
                return fallback;
            }
            }
            return rawValue;
        }

        // src/cdn.js
        document.addEventListener("alpine:init", () => {
            window.Alpine.plugin(dialog_default);
        });
    })();
    //# sourceURL=alpine-htmldialog.js
</script>

<script>
    (() => {
        function src_default(Alpine) {
            Alpine.directive("intersect", Alpine.skipDuringClone((el, { value, expression, modifiers }, { evaluateLater, cleanup }) => {
                let evaluate = evaluateLater(expression);
                let options = {
                    rootMargin: getRootMargin(modifiers),
                    threshold: getThreshold(modifiers)
                };
                let observer = new IntersectionObserver((entries) => {
                    entries.forEach((entry) => {
                        if (entry.isIntersecting === (value === "leave"))
                            return;
                        evaluate();
                        modifiers.includes("once") && observer.disconnect();
                    });
                }, options);
                observer.observe(el);
                cleanup(() => {
                    observer.disconnect();
                });
            }));
        }
        function getThreshold(modifiers) {
            if (modifiers.includes("full"))
                return 0.99;
            if (modifiers.includes("half"))
                return 0.5;
            if (!modifiers.includes("threshold"))
                return 0;
            let threshold = modifiers[modifiers.indexOf("threshold") + 1];
            if (threshold === "100")
                return 1;
            if (threshold === "0")
                return 0;
            return Number(`.${threshold}`);
        }
        function getLengthValue(rawValue) {
            let match = rawValue.match(/^(-?[0-9]+)(px|%)?$/);
            return match ? match[1] + (match[2] || "px") : void 0;
        }
        function getRootMargin(modifiers) {
            const key = "margin";
            const fallback = "0px 0px 0px 0px";
            const index = modifiers.indexOf(key);
            if (index === -1)
                return fallback;
            let values = [];
            for (let i = 1; i < 5; i++) {
                values.push(getLengthValue(modifiers[index + i] || ""));
            }
            values = values.filter((v) => v !== void 0);
            return values.length ? values.join(" ").trim() : fallback;
        }

        document.addEventListener("alpine:init", () => {
            window.Alpine.plugin(src_default);
        });
    })();
    //# sourceURL=alpine-intersect.js
</script>

<script>
    for (const [selector, deferUntil] of Object.entries({".product-slider section[x-data]":"intersect",".product-info [x-data]":"intersect","#filters-content [x-data]":"intersect","#review_form":"intersect","section[x-data^=initRecentlyViewedProductsComponent]":"intersect","div[x-data^=initBundleOptions]":"intersect","#product_addtocart_form [x-data]":"intersect","#notice-cookie-block":"intersect"})) {
        document.querySelectorAll(selector).forEach(el => el.setAttribute('x-defer', `${deferUntil}`));
    }
    //# sourceURL=alpine-defer-rules.js
</script>
<script>
    (() => {
        const hasAlpine = new Promise(resolve => {
            window.addEventListener('alpine:initialized', resolve, {once: true, passive: true});
        });

        const hasInteract = new Promise(resolve => {
            (events => {
                const onInteract = () => {
                    resolve();
                    events.forEach(type => window.removeEventListener(type, onInteract));
                }
                events.forEach(type => window.addEventListener(type, onInteract, {once: true, passive: true}))
            })(['touchstart', 'mouseover', 'wheel', 'scroll', 'keydown'])
        });

        const onIntersect = (el) => {
            return new Promise(resolve => {
                const observer = new IntersectionObserver(entries => {
                    for (const entry of entries) {
                        if (entry.isIntersecting) {
                            observer.disconnect()
                            resolve();
                        }
                    }
                }, {});
                observer.observe(el);
            });
        }

        function runComponent(el) {
            hasAlpine.then(() => {
                el.removeAttribute('x-ignore');
                queueMicrotask(() => Alpine.initTree(el));
            });
        }

        function initDeferredComponents() {
            document.querySelectorAll('[x-data][x-defer]').forEach(el => {
                el.setAttribute('x-ignore', '');
                const deferUntil = (el.getAttribute('x-defer') || '').trim();
                switch (deferUntil) {
                    case 'interact':
                        hasInteract.then(() => runComponent(el));
                        break;
                    case 'intersect':
                        onIntersect(el).then(() => runComponent(el))
                        break;
                    case 'idle':
                        window.requestIdleCallback
                            ? window.requestIdleCallback(() => runComponent(el), {timeout: 4000})
                            : setTimeout(() => runComponent(el), 4000);
                        break;
                    case 'eager':
                        runComponent(el);
                        break;
                    default:
                        if (deferUntil.startsWith('event:') && deferUntil.length > 6) {
                            window.addEventListener(deferUntil.substring(6), () => runComponent(el), {once: true, passive: true});
                        }
                }
            });
        }

        window.addEventListener('alpine:init', initDeferredComponents, {once: true, passive: true});
    })();
    //# sourceURL=alpine-defer.js
</script>


<script>
    function createAjaxLoader() {
        const loader = document.createElement('div');
        loader.className = 'absolute inset-0 flex justify-center items-center loader';
        loader.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 50 50" class="w-full h-full p-2" role="img">
    <path fill="#d9dddd" d="M43.935 25.145c0-10.318-8.364-18.683-18.683-18.683-10.318 0-18.683 8.365-18.683 18.683h4.068c0-8.071 6.543-14.615 14.615-14.615s14.615 6.543 14.615 14.615h4.068z">
        <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/>
    </path>
<title>Loading...</title></svg>
`;
        return loader;
    }

    function addAjaxLoader(button, loader) {
        button.setAttribute('data-label', button.getAttribute('aria-label'));
        button.removeAttribute('aria-label');
        button.prepend(loader);
        button.classList.add('relative', '[&>:not(.loader)]:invisible');
        button.disabled = true;
    }

    function removeAjaxLoader(button, loader) {
        button.setAttribute('aria-label', button.getAttribute('data-label'));
        button.removeAttribute('data-label');
        loader.remove();
        button.classList.remove('[&>:not(.loader)]:invisible');
        button.disabled = false;
    }

    window.setAjaxCart = ({
        formSelectors = ['#product_addtocart_form', '.product_addtocart_form'],
        extraDelay = 500    } = {}) => {
        const forms = document.querySelectorAll(formSelectors.toString());

        forms.forEach(form => {
            form.addEventListener('submit', async (event) => {
                event.preventDefault();

                const formData = new FormData(form);
                const button = form.querySelector('button.btn-atc')
                    ? form.querySelector('button.btn-atc')
                    : document.getElementById('product-addtocart-button');
                const loader = createAjaxLoader(button);
                const postUrl = event.target.action.replace('%25uenc%25', hyva.getUenc());
                let bodyUrl = new URLSearchParams(formData);
                bodyUrl.append("uenc", hyva.getUenc());
                addAjaxLoader(button, loader);

                try {
                    const response = await fetch(postUrl, {
                        method: 'POST',
                        body: bodyUrl.toString(),
                        mode: "cors",
                        credentials: "include",
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                            'X-Requested-With': 'XMLHttpRequest'
                        }
                    });

                    if (!response.ok) {
                        return form.submit();
                    }

                    if (response.redirected) {
                        return window.location.href = response.url;
                    }

                    window.dispatchEvent(new CustomEvent("reload-customer-section-data"));

                                            window.dispatchEvent(new CustomEvent('toggle-cart'));
                    
                                    } catch (err) {
                    console.warn(err);
                    window.dispatchEvent(new CustomEvent('product-addtocart-error'));

                    if (typeof window.dispatchMessages === "undefined") return;
                    window.dispatchMessages([{
                        text:'There\u0020was\u0020a\u0020problem\u0020adding\u0020your\u0020item\u0020to\u0020the\u0020cart.',
                        type: 'error'
                    }], 5000);
                } finally {
                    setTimeout(() => removeAjaxLoader(button, loader), extraDelay);
                }
            });
        });
    }

    window.setAjaxCart();

    </script>

<script>
// x-teleport implementation
(_ => {
    document.addEventListener('DOMContentLoaded', event => {
        // x-teleport available only for template
        if (!Alpine.version.startsWith('2')) {
            return;
        }

        const teleportDirective = (el, expression) => {
            let target = document.querySelector(expression)
            let clone = el.content.cloneNode(true).firstElementChild;

            target.appendChild(clone);
            setTimeout(() => {
                target.querySelectorAll('[x-data]')
                    .forEach(el => Alpine.initializeComponent(el));
            }, 0)
        };

        document.querySelectorAll('template').forEach(el => {
            if (!el.hasAttribute('x-teleport')) {
                return;
            }

            teleportDirective(el, el.getAttribute('x-teleport'));
        });

        document.querySelectorAll('[x-data]').forEach(el => {
            if (el.hasAttribute('x-init')) {
                return;
            }

            setTimeout(() => {
                Alpine.initializeComponent(el);
            }, 0);
        });
    });
})()
</script>

<script type="module"
        src="https://cdn.masterbooks.com/static/version1780560499/frontend/Ecommerce121/masterbooks-hyva/en_US/Hyva_Theme/js/alpine3.min.js"
        defer
        crossorigin
></script>
<script>
    document.addEventListener("alpine:init", () => {
        Alpine.data('hyvaCmsToggle', () => ({
            open: false,
            notOpen() {
                return !this.open;
            },
            show() {
                this.open = true
            },
            hide() {
                this.open = false
            },
            toggle() {
                this.open = !this.open
            }
        }))
    });
</script>
<script>
    function dispatchMessages(messages, hideAfter) {
        const messagesEvent = new CustomEvent("messages-loaded", {
            detail: {
                messages: messages,
                hideAfter: hideAfter
            }
        });
        window.dispatchEvent(messagesEvent);
    }

    if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) {
        console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script");
    }

    (function( hyva, undefined ) {

        hyva.initFormKey = () => {
            const inputSelector = 'input[name="form_key"]',
                formKey = hyva.getFormKey();

            Array.from(document.querySelectorAll(inputSelector)).map(function (input) {
                input.value = formKey
            });
        }

        hyva.initMessages = () => {
            try {
                const messages = hyva.getCookie('mage-messages');
                window.mageMessages = messages ? JSON.parse(decodeURIComponent(messages).replace(/\+/g, ' ')) : [];

                dispatchMessages(window.mageMessages);

                                // empty `mage-messages` cookie
                const skipSetDomain = true;
                hyva.setCookie('mage-messages','', -1, skipSetDomain);

            } catch (error) {
                console.warn('Error parsing Cookie Messages:', error);
            }
        }

        window.addEventListener('DOMContentLoaded', hyva.initFormKey);
        hyva.alpineInitialized(hyva.initMessages)

    }( window.hyva = window.hyva || {} ));
    //# sourceURL=hyva-cookies.js
</script>
<script>
    {
        const private_content_key = 'mage-cache-storage';
        const private_content_expire_key = 'mage-cache-timeout';
        const private_content_version_key = 'private_content_version';
        const section_data_ids_key = 'section_data_ids';
        const mage_cache_session_id_key = 'mage-cache-sessid';
        const last_visited_store_key = 'last_visited_store';

        const ttl = 28800;

        if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) {
            console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script");
        }

        function loadSectionData () {
            const browserStorage = hyva.getBrowserStorage();
            if (!browserStorage) {
                typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                    [{
                        type: "warning",
                        text: "Please enable LocalStorage in your browser."
                    }]
                );
                return;
            }
            try {
                let isInvalid = false;

                if (hyva.getCookie(last_visited_store_key) !== CURRENT_STORE_CODE) {
                    isInvalid = true;
                }
                hyva.setCookie(last_visited_store_key, CURRENT_STORE_CODE, false, false);

                if (!hyva.getCookie(mage_cache_session_id_key)) {
                    isInvalid = true;
                    browserStorage.removeItem(private_content_key);
                    const skipSetDomain = true;
                    const days = false;
                    hyva.setCookie(mage_cache_session_id_key, true, days, skipSetDomain)
                }

                const cookieVersion = hyva.getCookie(private_content_version_key);
                const storageVersion = browserStorage.getItem(private_content_version_key);

                if (cookieVersion && !storageVersion || cookieVersion !== storageVersion) {
                    isInvalid = true;
                }

                const privateContentExpires = browserStorage.getItem(private_content_expire_key);
                if (privateContentExpires && new Date(privateContentExpires) < new Date()) {
                    browserStorage.removeItem(private_content_key);
                }

                if (isInvalid && cookieVersion) {
                    fetchPrivateContent([]);
                } else if (cookieVersion && storageVersion && cookieVersion === storageVersion) {
                    const privateContent = JSON.parse(browserStorage.getItem(private_content_key));
                    if (
                        privateContent &&
                        privateContentExpires &&
                        privateContent.cart &&
                        privateContent.customer
                    ) {
                        dispatchPrivateContent(privateContent);
                    } else {
                        fetchPrivateContent([]);
                    }
                } else {
                    if (document.getElementById('default-section-data')) {
                        const privateContent = JSON.parse(document.getElementById('default-section-data').innerText.trim());
                        dispatchPrivateContent(privateContent);
                    } else {
                        dispatchPrivateContent({});
                    }
                }

            } catch (error) {
                console.warn('Error retrieving Private Content:', error);
            }
        }

        hyva.alpineInitialized(loadSectionData)
        window.addEventListener('reload-customer-section-data', loadSectionData);

        window.processSectionDataBeforeDispatch = window.processSectionDataBeforeDispatch || (data => data);

        function dispatchPrivateContent(data) {

            const privateContentEvent = new CustomEvent("private-content-loaded", {
                detail: {
                    data: window.processSectionDataBeforeDispatch(data)
                }
            });
            window.dispatchEvent(privateContentEvent);
        }

        function fetchPrivateContent(sections) {
            fetch(`${BASE_URL}customer/section/load/?sections=${encodeURIComponent(sections.join(','))}`, {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json',
                    'X-Requested-With': 'XMLHttpRequest'
                }
            })
                .then(response => response.ok && response.json())
                .then(
                    data => {
                        if (data) {
                            try {
                                const browserStorage = hyva.getBrowserStorage();

                                // merge new data preserving non-invalidated sections
                                const oldSectionData = JSON.parse(browserStorage.getItem(private_content_key) || '{}') || {};

                                                                if ((! data.cart || ! data.cart.cartId) && oldSectionData['checkout-data']) {
                                    delete oldSectionData['checkout-data'];
                                }
                                const newSectionData = Object.assign(oldSectionData, data);

                                dispatchPrivateContent(newSectionData);

                                // don't persist messages, they've been dispatched already
                                if (newSectionData.messages && newSectionData.messages.messages ) {
                                    newSectionData.messages.messages = [];
                                }

                                browserStorage.setItem(private_content_key, JSON.stringify(newSectionData));

                                const expiresAt = new Date(Date.now() + (ttl * 1000)).toISOString();
                                browserStorage.setItem(private_content_expire_key, expiresAt);

                                const newCookieVersion = hyva.getCookie(private_content_version_key);
                                browserStorage.setItem(private_content_version_key, newCookieVersion);

                                // We don't need the section_data_ids in Hyvä, but we store them for compatibility
                                // with Luma Fallback. Otherwise, not all sections are loaded in Luma Checkout
                                hyva.setCookie(
                                    section_data_ids_key,
                                    JSON.stringify(
                                        Object.keys(data).reduce((sectionDataIds, sectionKey) => {
                                            sectionDataIds[sectionKey] = data[sectionKey]['data_id'];
                                            return sectionDataIds;
                                        }, {})
                                    ),
                                    false,
                                    true
                                );
                            } catch (error) {
                                console.warn("Couldn't store privateContent", error);
                            }
                        }
                    }
                )
                .catch(error => {
                    console.warn("Couldn't fetch privateContent", error);
                });
        }
    }
    //# sourceURL=hyva-private-content.js
</script>
<script>
    (() => {
        document.addEventListener('submit', event => event.target.action = event.target.action.replace('%25uenc%25', hyva.getUenc()));
    })()
</script>
<script>
    (events => {
        const dispatchUserInteractionEvent = () => {
            events.forEach(type => window.removeEventListener(type, dispatchUserInteractionEvent))
            window.dispatchEvent(new Event('init-external-scripts'))
        };
        events.forEach(type => window.addEventListener(type, dispatchUserInteractionEvent, {once: true, passive: true}))
    })(['touchstart', 'mousemove', 'wheel', 'scroll', 'keydown']);
    //# sourceURL=hyva-init-external-scripts.js
</script>
<script>
    (function () {
        const modals = [];
        const excludedFromFocusTrapping = new Set();

        function trapFocusInNextModalWithOverlay() {
            for (let idx = modals.length -1; idx >= 0; idx--) {
                const nextOnStack = modals[idx];
                const nextDialogElement = nextOnStack.instance.$refs[nextOnStack.name];
                if (! isOverlayDisabled(nextDialogElement)) {
                    hyva.trapFocus(nextDialogElement);
                    break;
                }
            }
        }

        function focusables(dialogElement) {
            const selector = 'button, [href], input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
            return Array.from(dialogElement.querySelectorAll(selector))
                .filter(el => !el.hasAttribute('disabled'));
        }

        function firstVisible(elements) {
            const a = Array.from(elements);
            for (let i = 0; i < a.length; i++) {
                if (a[i].offsetWidth || a[i].offsetHeight || a[i].getClientRects().length) return a[i];
            }
            return null;
        }

        function isInViewport(element) {
            const rect = element && element.getBoundingClientRect();
            return rect &&
                rect.top >= 0 &&
                rect.left >= 0 &&
                rect.right <= window.innerWidth &&
                rect.bottom <= window.innerHeight;
        }

        function setFocusAfterTransition(dialogElement, duration) {
                        const nested = Array.from(dialogElement.querySelectorAll('[role="dialog"]'));
            const candidates = Array.from(dialogElement.querySelectorAll('[x-focus-first]'));
            next: for (let candidate of candidates) {
                for (let child of nested) {
                    if (child.contains(candidate)) continue next;
                }
                setTimeout(() => candidate.focus(), 50);
                break;
            }
            window.setTimeout(() => {
                const focusElement = firstVisible(dialogElement.querySelectorAll('[x-focus-first]')) ||
                    focusables(dialogElement)[0] ||
                    null;
                focusElement && isInViewport(focusElement) && focusElement.focus();
            }, Math.max(1, duration));
        }

        function determineTrigger($refs, dialog, trigger) {
                        if (typeof trigger === 'undefined' && typeof dialog === 'object' && dialog.target instanceof HTMLElement) {
                return dialog.target;
            }
                        if (typeof dialog === 'string' && typeof trigger === 'object' && trigger.target instanceof HTMLElement) {
                return trigger.target;
            }
                        if (typeof trigger === 'string') {
                try {
                    return $refs[trigger] || document.querySelector(trigger)
                } catch (e) {}
            }
                        if (trigger instanceof Element) {
                return trigger;
            }

                        return null;
        }

        function isOverlayDisabled(dialog) {
            return dialog && dialog.hasAttribute('x-no-overlay')
        }

        function areRemainingModalsWithoutOverlay(modals)
        {
            const overflowDisabled = modals.map(modal => modal.instance.$refs[modal.name]).filter(isOverlayDisabled);

            return overflowDisabled.length === modals.length;
        }

        window.hyva.modal = function(options = {}) {
                        if (this.$el && this.$el.dataset && this.$el.dataset.options) {
                try {
                    options = Object.assign(options, JSON.parse(this.$el.dataset.options || '{}'));
                } catch (e) {
                    throw new Error('Cannot read the dialog options from the data-options attribute: not valid JSON');
                }
            }

            const config = Object.assign({
                dialog: 'dialog',                 duration: 300,                 transitionEnter: 'transition ease-out duration-300',
                transitionEnterStart: 'opacity-0',
                transitionEnterEnd: 'opacity-100',
                transitionLeave: 'transition ease-in duration-300',
                transitionLeaveStart: 'opacity-100',
                transitionLeaveEnd: 'opacity-0',
            }, options);
            let lastHide = 0;

            return {
                opened: {},
                show(dialog, trigger) {
                    const focusTargetAfterHide = determineTrigger(this.$refs, dialog, trigger);
                    const name = typeof dialog === 'string' ? dialog : config.dialog;
                    const dialogElement = this.$refs[name];
                    if (! dialogElement) {
                                                return;
                    }
                    const useOverlay = ! dialogElement.hasAttribute('x-no-overlay');

                    dialogElement.scrollTop = 0;

                                        if (this.opened[name]) {
                        return;
                    }

                    if (focusTargetAfterHide) {
                        focusTargetAfterHide.setAttribute('aria-expanded', 'true');
                    }

                    this.opened[name] = true;
                    useOverlay && this.$nextTick(() => hyva.trapFocus(dialogElement));
                    setFocusAfterTransition(dialogElement, config.duration);

                    const frame = {name, instance: this, focusTarget: focusTargetAfterHide, time: Date.now()};

                    modals.push(frame);
                    if (useOverlay) {
                        document.body.classList.add('overflow-hidden');
                    }
                    return new Promise(resolve => frame.resolve = resolve);
                },
                cancel() {
                    this.hide(false);
                },
                ok() {
                    this.hide(true);
                },
                hide(value) {
                                        if (Date.now() - lastHide < config.duration) {
                        return;
                    }
                    lastHide = Date.now();

                    const modal = modals.pop() || {};
                    if (! modal.instance) {
                        return;
                    }

                    const name = modal.name;
                    this.opened[name] = false;
                    hyva.releaseFocus(modal.instance.$refs[modal.name])
                    trapFocusInNextModalWithOverlay();

                    const nextFocusAfterHide = modal.focusTarget;
                    nextFocusAfterHide && setTimeout(() => {
                        nextFocusAfterHide.setAttribute('aria-expanded', 'false');
                        nextFocusAfterHide.focus()
                    }, config.duration);

                    if (modals.length === 0 || areRemainingModalsWithoutOverlay(modals)) {
                        document.body.classList.remove('overflow-hidden');
                    }

                    modal.resolve(value);
                },
                overlay(dialog) {
                    dialog = this.$el.dataset.dialogRefName || dialog;
                    const name = typeof dialog === 'string' ? dialog : config.dialog;
                    return {
                        ['x-show']() {
                            return this.opened[name]
                        },
                        ['x-transition:enter']: config.transitionEnter,
                        ['x-transition:enter-start']: config.transitionEnterStart,
                        ['x-transition:enter-end']: config.transitionEnterEnd,
                        ['x-transition:leave']: config.transitionLeave,
                        ['x-transition:leave-start']: config.transitionLeaveStart,
                        ['x-transition:leave-end']: config.transitionLeaveEnd,
                        ['@hyva-modal-show.window'](event) {
                            event.detail && event.detail.dialog === name && this.show(name, event.detail.focusAfterHide)
                        }
                    };
                },
                showDialogOnInit() {
                    const parent = this.$el.closest('[data-dialog-ref-name]');
                    if (parent && parent.dataset.dialogRefName) {
                        this.$dispatch('hyva-modal-show', {dialog: parent.dataset.dialogRefName})
                    }
                }
            };
        }

        window.hyva.modal.peek = () => modals.length > 0 && modals[modals.length -1]

        window.hyva.modal.pop = function () {
            if (modals.length > 0) {
                const modal = modals[modals.length -1];
                modal.instance.hide();
            }
        }

        window.hyva.modal.excludeSelectorsFromFocusTrap = function (selectors) {
            typeof selectors === 'string' || selectors instanceof String
                ? excludedFromFocusTrapping.add(selectors)
                : selectors.map(selector => excludedFromFocusTrapping.add(selector));
        }

        window.hyva.modal.eventListeners = {
            keydown: event => {
                if (event.key === 'Escape') {
                    window.hyva.modal.pop();
                }
            },
                        click: event => {
                if (modals.length > 0) {
                    const modal = modals[modals.length -1];
                    const dialog = modal.instance.$refs[modal.name];
                    if (modal.time + 50 < Date.now() && // if last click processing is more than 50ms ago
                        ! isOverlayDisabled(dialog) && // if dialog has overlay
                        ! dialog.contains(event.target)) { // if click is outside of dialog
                        modal.instance.hide();
                    }
                }
            }
        };

        document.addEventListener('keydown', window.hyva.modal.eventListeners.keydown);

        document.addEventListener('click', window.hyva.modal.eventListeners.click);
    })();
    window.addEventListener('alpine:init', () => {
        Alpine.data('hyvaModal', window.hyva.modal);
    }, {once: true});
</script>
<script>
    'use strict';

    const grecaptchaV2LoadCallbacks = [];

    function executeRecaptchaLoadCallbacks () {
        while (window.grecaptcha && grecaptchaV2LoadCallbacks.length > 0) {
            const callback = grecaptchaV2LoadCallbacks.pop();
            typeof callback === 'string' ? window[callback]() : callback();
        }
    }

    (function() {
        const loadRecaptchaScript = (event) => {

            if (window.grecaptcha || !event.target.form) {
                return;
            }

            const url = 'https://www.google.com/recaptcha/api.js?onload=executeRecaptchaLoadCallbacks';
            const siteKey = '6LceWLgUAAAAAH7dwYx36tmo_UKPXJUNRLcGWaEo';
            const script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = siteKey ? `${url}&render=${siteKey}` : `${url}&render=explicit`;
            script.async = true;
            document.head.appendChild(script);

            script.addEventListener('load', () => {
                Array.from(document.querySelectorAll('button[data-recaptcha-btn]:disabled')).forEach(btn => btn.removeAttribute('disabled'));
            });
        }

        window.forceLoadRecaptchaScript = (form) => {
            loadRecaptchaScript({target: {form: form || 'dummy'}});
            executeRecaptchaLoadCallbacks();
        };

        document.body.addEventListener('input', loadRecaptchaScript, { once: true });
        document.body.addEventListener('focus', loadRecaptchaScript, { once: true });

    }());

</script>

<script>
    function initAmPreorder(availabilityElementSelector, preOrderNote, addToCartLabel, productId, isCategory = false, isSimple = false) {
        return {
            availabilityElementSelector: availabilityElementSelector,
            addToCartBtnSelector: '#product-addtocart-button',
            defaultStockSelector: '.stock span',
            preOrderNote: preOrderNote,
            addToCartLabel: addToCartLabel,
            availabilityElement: null,
            originalNote: '',
            originalCartLabel: '',
            origBtnTitle: '',
            origBtnAriaLabel: '',
            currentNote: '',
            currentCartLabel: '',
            currentBtnTitle: '',
            currentBtnAriaLabel: '',
            productId: productId,
            isCategory: isCategory,
            productForm: null,
            isSimple: isSimple,
            isNeedShowPreorderStatus: false,

            initPreorder() {
                if (this.preOrderNote || this.addToCartLabel) {
                    this.setStatusToPreorder();
                }
                this.initAvailabilityElement();
                this.initAddToCartButton();
            },

            initAvailabilityElement() {
                let availabilityElement;

                if (this.isCategory) {
                    this.productForm = document.querySelector(`input[name='product'][value='${productId}']`)?.parentNode;
                    availabilityElement = this.productForm?.querySelector('.ampreorder-category');
                } else {
                    availabilityElement = document.querySelector(this.availabilityElementSelector)
                        || document.querySelector(this.availabilityElementSelector);

                    if (this.availabilityElementSelector === this.defaultStockSelector) {
                        availabilityElement = availabilityElement?.parentNode;
                    }
                }

                this.originalNote = this.originalNote || availabilityElement?.innerHTML;

                if (!availabilityElement || window.amXnotifSubscribeComponentFactory) {
                    return;
                }

                note = this.currentNote || this.originalNote;
                dataIsNeedShow = this.isCategory ? this.isNeedShowPreorderStatus : true;

                availabilityElement.setAttribute('x-data', 'dataAmPreorderAvailability');
                availabilityElement.setAttribute('x-init', 'initAmPreorderAvailability');
                availabilityElement.setAttribute('data-note', note);
                availabilityElement.setAttribute('data-is-need-show', dataIsNeedShow);
                availabilityElement.setAttribute('data-product-id', productId);
                availabilityElement.setAttribute('x-html', 'note');
                availabilityElement.setAttribute('x-show', 'isNeedShow');
            },

            initAddToCartButton() {
                let addToCartBtn,
                    addToCartSpan,
                    label,
                    title,
                    ariaLabel;

                if (typeof this.productForm === 'undefined' || this.productForm === null) {
                    return;
                }

                if (this.isCategory) {
                    addToCartBtn = this.productForm.querySelector('.btn-primary:not(.subscribe-button)');
                } else {
                    addToCartBtn = document.querySelector(this.addToCartBtnSelector);
                }

                addToCartSpan = addToCartBtn.querySelector('span');

                if (!addToCartSpan) {
                    return;
                }

                this.originalCartLabel = addToCartSpan.innerHTML.replace(/(\r\n|\n|\r)/gm, '');
                this.origBtnTitle = addToCartBtn.getAttribute('title');
                this.origBtnAriaLabel = addToCartBtn.getAttribute('aria-label');

                label = this.currentCartLabel || this.originalCartLabel;
                title = this.currentBtnTitle || this.origBtnTitle;
                ariaLabel = this.currentBtnAriaLabel || this.origBtnAriaLabel;

                addToCartBtn.setAttribute('x-data', 'dataAmPreorderBtn');
                addToCartBtn.setAttribute('x-init', 'initAmPreorderBtn');
                addToCartBtn.setAttribute('data-label', label);
                addToCartBtn.setAttribute('data-title', title);
                addToCartBtn.setAttribute('data-aria-label', ariaLabel);
                addToCartBtn.setAttribute('data-product-id', this.productId);
                addToCartBtn.setAttribute(':title', 'title');
                addToCartBtn.setAttribute(':aria-label', 'ariaLabel');
                addToCartSpan.setAttribute('x-text', 'cartLabel');
            },

            setStatusToPreorder() {
                this.currentNote = this.preOrderNote || this.originalNote;
                this.currentCartLabel = this.addToCartLabel || this.originalCartLabel;
                this.isNeedShowPreorderStatus = true;
                this.currentBtnAriaLabel = this.currentBtnTitle = this.currentCartLabel;
            },

            resetToOriginalStatus() {
                this.currentNote = this.originalNote;
                this.currentCartLabel = this.originalCartLabel;
                this.isNeedShowPreorderStatus = false;
                this.currentBtnTitle = this.origBtnTitle;
                this.currentBtnAriaLabel = this.origBtnAriaLabel;
            },

            dispatchChangeAvailabilityElement() {
                window.dispatchEvent(new CustomEvent(`am-preorder-change-availability-${this.productId}`, {
                    detail: {
                        isNeedShow: this.isCategory ? this.isNeedShowPreorderStatus : true,
                        preOrderNote: this.currentNote
                    }
                }));
            },

            dispatchChangeBtnElement() {
                window.dispatchEvent(
                    new CustomEvent(`am-preorder-change-btn-${this.productId}`, {
                        detail: {
                            addToCartLabel: this.currentCartLabel,
                            title: this.currentBtnTitle,
                            ariaLabel: this.currentBtnAriaLabel
                        }
                    })
                );
            },
            
            dispatchChanges() {
                this.dispatchChangeAvailabilityElement();
                this.dispatchChangeBtnElement();
            }
        }
    }
</script>
<script>
    function initAmPreorderConfigurable(isAllProductsPreorder = false, map = [], originalNote = '') {
        return {
            isAllProductsPreorder: isAllProductsPreorder,
            map: map,
            originalNote: originalNote,
            canShowButton: false,
            initPreorderConfigurable() {
                if (this.isAllProductsPreorder) {
                    this.setStatusToPreorder();
                }

                this.initAvailabilityElement();
                this.initAddToCartButton();
                this.addSwatchGridEvent();
            },

            addSwatchGridEvent() {
                const swatchGrid = document.querySelector(`[x-data*="Options"]`);

                if (swatchGrid) {
                    const dataComponent = swatchGrid.getAttribute('x-data');

                    ['configurable-selection-changed', 'listing-configurable-selection-changed'].forEach(eventName => {
                        window.addEventListener(eventName, (e) => {
                            if (e.detail.productId === this.productId) {
                                const selectedValues = e.detail.selectedValues;
                                const foundSwatch = Object.values(map).find(item =>
                                    JSON.stringify(Object.values(item && item.attributes ? item.attributes : {})) === JSON.stringify(Object.values(selectedValues))
                                );
                                if (foundSwatch || this.isAllProductsPreorder) {
                                    if (foundSwatch) {
                                        this.currentNote = foundSwatch['note'];
                                        this.currentCartLabel = foundSwatch['cartLabel'];
                                        this.currentBtnTitle = foundSwatch['cartLabel'];
                                        this.currentBtnAriaLabel = foundSwatch['cartLabel'];
                                    } else {
                                        this.setStatusToPreorder();
                                    }
                                    this.isNeedShowPreorderStatus = true;
                                    this.dispatchChanges();
                                } else {
                                    this.resetToOriginalStatus();
                                    this.dispatchChanges();
                                }
                            }
                        });
                    });
                }
            }
        }
    }
</script>
<script>
    'use strict';

    function initParentContainerProcessor() {
        const selectors = {
            labelContainer: '.amasty-label-container',
            galleryImg: '#gallery img:not(.amasty-label-image)'
        }

        return {
            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            process: function (label) {
                this.moveLabelToParent(label);
                this.setParentStyles(label);
            },

            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            moveLabelToParent: function (label) {
                const newParent = this.getNewParent(label);

                if (!newParent) {
                    return;
                }

                const wrapperElement = newParent.querySelector(label.wrapperClass);
                label.parent = newParent;

                // if same wrapper already exists - move label there
                if (wrapperElement && !wrapperElement.isSameNode(label.element)) {
                    this.insertLabelByPriority(label, wrapperElement);
                } else {
                    newParent.prepend(label.element);
                }
            },

            /**
             * @param {AmlabelComponent} label
             * @return {HTMLElement|undefined}
             */
            getNewParent: function (label) {
                // move label to container from settings
                let newParent = label.element.closest(label.config.path)
                    || this.findPreviousNodeExcludingScriptsAndDifferentLabels(label.element)?.querySelector(label.config.path)
                    || label.parent.querySelector(label.config.path);

                if (!newParent) {
                    newParent = this.fallbackParentSearch(label);
                }

                return newParent;
            },

            fallbackParentSearch: function (label) {
                switch (true) {
                    case label.config.move !== 1 && label.config.mode === 'prod':
                        // Try to find default gallery container on product page if none of the config selectors found
                        return document.querySelector(selectors.galleryImg)?.parentElement;
                    case label.config.mode === 'cart':
                        const potentialParent
                            = label.element.closest(':not([data-teleport-target]):not(.amlabel-position-wrapper)');

                        // If label parent node has an img
                        return potentialParent?.querySelector(':scope > img')
                            ? potentialParent
                            : undefined;
                    default:
                        return undefined;
                }
            },

            /**
             * @param {HTMLElement} element
             * @return {HTMLElement|null}
             */
            findPreviousNodeExcludingScriptsAndDifferentLabels: function (element) {
                const previousElement = element?.previousElementSibling;
                if (!previousElement) {
                    return null;
                }

                if (previousElement?.tagName !== 'SCRIPT'
                    && !previousElement?.className?.includes?.('amlabel-position-wrapper')
                ) {
                    return previousElement;
                }

                return this.findPreviousNodeExcludingScriptsAndDifferentLabels(previousElement);
            },

            /**
             * @param {AmlabelComponent} label
             * @param {HTMLElement} wrapperElement
             * @return {void}
             */
            insertLabelByPriority: function (label, wrapperElement) {
                const labelContainers = wrapperElement.querySelectorAll(selectors.labelContainer);
                const currentLabelOrder = label.labelContainer.dataset.amlabelOrder;
                let insertAfterContainer = null;

                // find the label behind which we want to insert current one by priority
                labelContainers.forEach(labelContainer => {
                    if (labelContainer.dataset.amlabelOrder < currentLabelOrder) {
                        insertAfterContainer = labelContainer;
                    }
                });

                insertAfterContainer === null
                    ? wrapperElement.prepend(label.labelContainer)
                    : insertAfterContainer.after(label.labelContainer);

                label.element.remove();
                label.element = wrapperElement;
            },

            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            setParentStyles: function (label) {
                const parent = label.parent.hasAttribute('data-teleport-target')
                    ? label.parent.parentElement
                    : label.parent;

                /* required for child position absolute */
                !(parent.style.position === 'absolute') && (parent.style.position = 'relative');
                !parent.style.width && parent.classList.add('w-fit-content');
                !parent.style.marginLeft && parent.classList.add('ml-auto');
                !parent.style.marginRight && parent.classList.add('mr-auto');
            },
        }
    }
</script>
<script>
    'use strict';

    function initLabelItemProcessor() {
        /**
         * @typedef {Object} AmlabelComponent
         *
         * @property {HTMLElement} element Label wrapper element
         * @property {HTMLElement} parent Element where label should be placed
         * @property {boolean} initialized Is label initialized
         * @property {string} wrapperClass Dynamic class for label wrapper to place multiple labels properly by position
         * @property {HTMLElement} labelContainer Container for label text image and tooltip
         * @property {Config} config Label Configuration
         * @property {Object} parentContainerProcessor
         * @property {Object} labelItemProcessor
         */

        /**
         * @typedef {Object} AmLabelConfig
         *
         * @property {0|1} alignment Labels Alignment config value (0 - Horizontal| 1 - Vertical)
         * @property {number} label Label Id
         * @property {number} margin Margin between labels config value
         * @property {('cat'|'prod')} mode Label mode
         * @property {number} move
         * @property {number} order Label order
         * @property {string} path The css selector to which label should place
         * @property {string} position Label position
         * @property {string} product Product Id
         * @property {string} redirect_url
         * @property {string} size Label size
         * @property {{
         *     backgroundColor: string,
         *     color: string,
         *     content: string,
         *     status: 1|2|3
         * }} tooltip
         */

        return {
            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            process: function(label) {
                this.setLabelSize(label);
                this.setLinkProps(label);
            },

            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            setLabelSize: function (label) {
                if (!label.config.size) {
                    return;
                }

                label.labelContainer.style.width = label.parent.offsetWidth * label.config.size / 100 + 'px';
            },

            /**
             *
             * @param {Object} $event
             * @param {HTMLElement} tooltipNode
             */
            placeTooltip: function() {
                const labelNode = this.$event.target;
                const tooltipNode = document.getElementById(`label-tooltip-${this.$el.dataset.labelId}-${this.$el.dataset.productId}`);
                const labelNodeRect = labelNode.getBoundingClientRect();

                tooltipNode.style.bottom = (window.innerHeight - labelNodeRect.top)  + 'px';
                tooltipNode.style.left = (labelNodeRect.left + labelNode.offsetWidth / 2 ) + 'px';
            },

            /**
             * @param {AmlabelComponent} label
             * @return {void}
             */
            setLinkProps: function (label) {
                !!label.config.redirect_url && label.labelContainer.classList.add('-link', 'cursor-pointer');
            },

            /**
             * @param {Object} $event Click event
             * @param {string} redirectUrl
             */
            openLink: function($event, redirectUrl) {
                if (redirectUrl.length === 0) {
                    return;
                }

                $event.preventDefault();
                window.open(redirectUrl, '_blank');
            }
        }
    }
</script>

<script>
    (function () {
        'use strict';

        const observedEvent = 'amlabel-swatch-product-changed';
        const selectors = {
            swatchOptions: 'div[x-data^=initConfigurable][x-data*=Options]',
            addToCartFormOnListing: 'form.product_addtocart_form',
            galleryImage: '#gallery img:not(.amasty-label-image)',
            labelWrapper: '.amlabel-position-wrapper'
        }

        /**
         * @return {void}
         */
        const injectLabelObserver = function () {
            const swatches = document.querySelectorAll(selectors.swatchOptions);

            swatches.forEach(swatch => {
                const isListing = !!swatch.closest(selectors.addToCartFormOnListing);
                const injectedDispatch = `$dispatch('${observedEvent}', `
                    + `{productIndex: productIndex, element: $el, optionConfig: optionConfig, isListing: ${isListing ? 1 : 0}})`;

                let mutatedInitAttribute = swatch.getAttribute('x-init');
                mutatedInitAttribute += `; $watch('productIndex', (productIndex) => { ${injectedDispatch} });`;
                swatch.setAttribute('x-init', mutatedInitAttribute);
            });
        }

        /**
         * @param {{
         *  productIndex: number,
         *  element: HTMLElement,
         *  optionConfig: Object,
         *  isListing: 0|1
         * }} payload
         * @return {void}
         */
        const updateLabel = function ({detail: payload}) {
            const {productIndex, element, optionConfig, isListing} = payload;

            if (!productIndex) {
                return;
            }

            const reloadUrl = optionConfig.label_reload;
            const headers = {
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
            };
            const body = new URLSearchParams({
                product_ids: productIndex,
                in_product_list: isListing
            });
            const labelContainerSelector = isListing ? optionConfig.label_category : optionConfig.label_product;

            fetch(`${reloadUrl}?${body.toString()}`, {headers: headers, method: 'GET'}).then((response) => {
                if (response.ok) {
                    return response.json();
                }
            }).then((result) => {
                const labelHtml = result.labels && result.labels[productIndex];
                let labelContainer = findClosest(element, labelContainerSelector);

                // Try to find default gallery container on product page if none of the config selectors found
                if (labelContainer === null && isListing === 0) {
                    labelContainer = document.querySelector(selectors.galleryImage)?.parentElement;
                }

                if (!!labelContainer) {
                    !!labelHtml ? replaceLabels(labelContainer, labelHtml) : clearLabelWrapper(labelContainer);
                }
            }).catch((error) => {
                typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                    [{
                        type: 'error',
                        text: error
                    }],
                    5000
                );
            });
        }

        /**
         * @param {HTMLElement} labelContainer
         * @param {string} labelHtml
         * @return {void}
         */
        function replaceLabels(labelContainer, labelHtml) {
            const parser = new DOMParser();
            const doc = parser.parseFromString(labelHtml, 'text/html');
            const nodes = doc.querySelectorAll(selectors.labelWrapper);

            if (!nodes) {
                return;
            }

            clearLabelWrapper(labelContainer);
            labelContainer.append(...nodes);
        }

        /**
         * @param {HTMLElement} labelContainer
         * @return {void}
         */
        function clearLabelWrapper(labelContainer) {
            labelContainer.querySelectorAll(selectors.labelWrapper).forEach(wrapper => wrapper.remove());
        }

        /**
         * @param {HTMLElement} currentElement
         * @param {string} selector
         * @return {HTMLElement|null}
         */
        function findClosest(currentElement, selector) {
            // We need to limit parent searches to prevent labels from being associated with the wrong product.
            const maxDepth = 3;
            let counter = 0;
            let closest = null;

            while (currentElement.parentNode && closest === null && counter < maxDepth) {
                ++counter;
                currentElement = currentElement.parentNode;
                closest = currentElement.querySelector(selector);
            }

            return closest;
        }

        injectLabelObserver();
        window.addEventListener(observedEvent, updateLabel);
    })();
</script>
<script>
    'use strict';

    (function () {
        window.amLabels = {
            productLabelsUrl: 'amasty_label/ajax/label',

            /**
             * @param {Array} productKeys
             * @param {string} queryParam
             * @returns {URLSearchParams}
             */
            getBody: function (productKeys, queryParam) {
                const baseParams = {
                    in_product_list: true
                };

                return  new URLSearchParams({
                    ...baseParams,
                    [queryParam]: productKeys
                })
            },

            /**
             * @param {Array} productKeys
             * @param {string} [queryParam='product_ids']
             * @return {Promise<any>}
             */
            getLabelsHtml: function (productKeys, queryParam = 'product_ids') {
                const headers = {
                    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                };
                const body = this.getBody(productKeys, queryParam);

                return fetch(BASE_URL + this.productLabelsUrl + '?' + body.toString(), {
                    headers: headers,
                    method: 'GET'
                }).then((response) => {
                    if (response.ok) {
                        return response.json();
                    }
                }).then((result) => {
                    return result.labels;
                }).catch((error) => {
                    typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                        [{
                            type: 'error',
                            text: error
                        }],
                        5000
                    );
                });
            }
        };
    })();
</script>
<script>
    'use strict';

    (function () {
        window.initAmRecentlyViewedLabels = window.initAmRecentlyViewedLabels || {
            selectors: {
                recentlyViewedContainer: '[x-data^=initRecentlyViewedProductsComponent]',
                productPhoto: '.product-item-photo'
            },
            recentlyViewedProductsKey: 'recently_viewed_products',
            itemIdentifierType: 'id',
            queryParam: 'product_ids',
            recentlyViewedProducts: [],

            /**
             * @return number[]
             */
            getProductIds: function () {
                const startIndex = '' === '' ? 0 : 1;

                return JSON.parse(hyva.getBrowserStorage().getItem(this.recentlyViewedProductsKey) ?? '[]')
                    .slice(startIndex)
                    .map((item) => item[this.itemIdentifierType]);
            },

            /**
             * @return {void}
             */
            mutationObserver: function () {
                const recentlyViewedContainers = document.querySelectorAll(this.selectors.recentlyViewedContainer);

                recentlyViewedContainers.forEach(recentlyViewedContainer => {
                    const mutationObserver = new MutationObserver((mutationsList, observer) => {
                        for(let mutation of mutationsList) {
                            if (mutation.type === 'childList') {
                                this.addLabels(recentlyViewedContainer, this.getProductIds());
                                observer.disconnect();
                            }
                        }
                    });

                    mutationObserver.observe(recentlyViewedContainer, {childList: true});
                })
            },

            /**
             * @param {HTMLElement} element
             * @param {Array} productIds
             * @return {void}
             */
            addLabels: function (element, productIds) {
                if (!productIds.length) {
                    return;
                }

                const productPhotos = element.querySelectorAll(this.selectors.productPhoto);
                const productPhotosById = []

                this.recentlyViewedProducts.forEach((product, index) => {
                    if (productPhotos[index]) {
                        productPhotosById[product.id] = productPhotos[index];
                    }
                });

                window.amLabels.getLabelsHtml(productIds, this.queryParam).then(
                    (result) => {
                        Object.keys(result).length && productPhotosById?.forEach((productPhoto, index) => {
                            !!result[index] && this.appendLabel({
                                productPhoto: productPhoto,
                                labelHtml: result[index],
                                productId: index
                            });
                        })
                    }
                );
            },

            /**
             * @param {{
             *  productContainer: Element,
             *  labelHtml: string,
             *  productId: number,
             * }} labelConfig
             * @return {void}
             */
            appendLabel: function (labelConfig) {
                const {productPhoto, labelHtml, productId} = labelConfig;
                const labelClass = 'am-label-product-id-' + productId;

                productPhoto.innerHTML += labelHtml;
                productPhoto.classList.add(labelClass);
                this.overrideParentLabelStyle(productPhoto);
                hyva.replaceDomElement(
                    '.' + labelClass,
                    productPhoto.outerHTML
                );
            },

            /**
             * @param {HTMLElement} productPhoto
             * @return {void}
             */
            overrideParentLabelStyle: function (productPhoto) {
                productPhoto.classList.add('!w-auto');
            },

            /**
             * The Recently Viewed Products block on the page doesn't include product IDs,
             * so we need to capture them here for matching with product photos in productPhotosById.
             *
             * @return {void}
             */
            initComponentInterceptor: function () {
                const componentName = this.getRecentlyViewedComponentName();

                if (!componentName) {
                    return;
                }

                const originInitRecentlyViewedProductsComponent = window[componentName];

                window[componentName] = function () {
                    const instance = originInitRecentlyViewedProductsComponent.apply(this, arguments)
                    const originalRender = instance.renderRecentlyViewedProducts;

                    instance.renderRecentlyViewedProducts = function(products) {
                        window.initAmRecentlyViewedLabels.recentlyViewedProducts = products;

                        return originalRender.call(this, products);
                    }

                    return instance;
                }
            },

            getRecentlyViewedComponentName: function () {
                if (window.initRecentlyViewedProductsComponent) {
                    return 'initRecentlyViewedProductsComponent';
                }

                // In Hyvä 1.3+ the component name may get a dynamic suffix, so we extract it from x-data.
                const xData = document.querySelector('[x-data^="initRecentlyViewedProductsComponent"]')
                    ?.getAttribute('x-data');

                return xData?.match(/initRecentlyViewedProductsComponent(_[a-zA-Z0-9]+)/)?.[0] ?? null;
            }
        };

        window.initAmRecentlyViewedLabels.mutationObserver();
        window.initAmRecentlyViewedLabels.initComponentInterceptor();
    })();
</script>
<script>
    (function () {
        'use strict';

        const selectors = {
            body: '.catalog-product-view',
            productItem: 'product-item',
            productGalleryImage: '#gallery img'
        }

        window.addEventListener('alpine:init', () => {
            Alpine.directive('amintersect', (el, { expression }, { evaluate, cleanup }) => {
                const observer = new IntersectionObserver(entries => {
                    entries.forEach(entry => {
                        if (entry.isIntersecting) {
                            evaluate(expression);
                            observer.disconnect();
                        }
                    })
                },  { threshold: 0.5 });

                observer.observe(getElement());

                cleanup(() => {
                    observer.disconnect()
                });

                function getElement() {
                    return !!document.querySelector(selectors.body) ? getImageProductBlock(el) : getCategoryProductBlock(el);
                }

                function getCategoryProductBlock(el) {
                    if (el.previousElementSibling === null) {
                        return el;
                    }

                    if (!el.previousElementSibling.classList.contains(selectors.productItem)) {
                        return getCategoryProductBlock(el.previousElementSibling);
                    }

                    return el.previousElementSibling;
                }

                function getImageProductBlock(el) {
                    return el.parentNode.querySelector(selectors.productGalleryImage)?.parentNode ?? el.parentNode;
                }
            });
        });
    })();
</script>
<script>
    'use strict';

    function initAmlabel() {
        return {
            element: null,
            parent: null,
            initialized: false,
            wrapperClass: '',
            labelContainer: null,
            config: '',
            parentContainerProcessor: initParentContainerProcessor(),
            labelItemProcessor: initLabelItemProcessor(),

            /**
             * @return {void}
             */
            init() {
                this.config = JSON.parse(this.$el.dataset.amlabelConfig);

                if (this.hasGliderParent(this.$el)) {
                    this.$el.removeAttribute('x-amintersect');
                }
            },

            /**
             * @return {void}
             */
            initLabel: function () {
                this.element = this.$el;
                this.labelContainer = this.$refs.amLabel;
                this.parent = this.$el.parentElement;
                this.wrapperClass = `.amlabel-position-${this.config.position}-${this.config.product}-${this.config.mode}`;
                if (this.hasGliderParent(this.$el)) {
                    this.render(this.$el);
                }
            },

            /**
             * @return {void}
             */
            render: function (el) {
                if (el) {
                    this.element = el;
                }

                if (this.element.dataset.amlabelObserved) {
                    return;
                }

                this.element.dataset.amlabelObserved = true;
                this.parentContainerProcessor.process(this);
                this.labelItemProcessor.process(this);
                this.initialized = true;
            },

            /**
             * @return {void}
             */
            resize: function () {
                this.config.size && this.labelItemProcessor.setLabelSize(this);
            },

            /**
             * @return {Object}
             */
            labelClasses() {
                return {
                    'top-0': this.config.position.includes('top'),
                    'top-0 bottom-0': this.config.position.includes('middle'),
                    'bottom-0': this.config.position.includes('bottom'),
                    'left-0': this.config.position.includes('left'),
                    'left-0 right-0': this.config.position.includes('center'),
                    'right-0': this.config.position.includes('right')
                }
            },

            /**
             * @return {void}
             */
            labelClick: function () {
                this.labelItemProcessor.openLink(this.$event, this.config.redirect_url);
            },

            /**
             * @param {Object} el
             * @return {boolean}
             */
            hasGliderParent: function (el) {
                return !!el.closest('[data-role="glider-content"]');
            }
        }
    }
    (() => {
        const initFn = () => Alpine.data('initAmlabel', initAmlabel);
        window.Alpine ? initFn() : window.addEventListener('alpine:init', initFn, {once: true})
    })()
</script>
<script>
    'use strict';

    let isAmlabelGliderLoad = false;

    window.addEventListener('glider-loaded', (e) => {
        if (isAmlabelGliderLoad) {
            return;
        }

        let gliderPrototype = Glider.prototype;
        let originalInit = gliderPrototype.init;
        let originalRemoveItem = gliderPrototype.removeItem;
        let originalAddItem = gliderPrototype.addItem;
        let originalUpdateControls = gliderPrototype.updateControls;

        document.querySelectorAll('.glider-track .amlabel-position-wrapper').forEach((el) => {
            el.classList.remove('glider-slide');
            el.removeAttribute('style');
        })

        gliderPrototype.init = function (refresh, paging) {
            let _ = this;
            let track = this.track;

            _.track = {
                children: Array.from(_.track.children).filter(
                    (el) => { return !el.classList.contains('amlabel-position-wrapper') }
                ),
                style: { width: '' }
            }
            originalInit.call(_, refresh, paging);
            track.style.width = _.track.style.width;
        };

        gliderPrototype.removeItem = function (index) {
            let _ = this;

            _.track = _.ele.querySelector('.glider-track');
            originalRemoveItem.call(_, index);
        }

        gliderPrototype.addItem = function (ele) {
            let _ = this;

            _.track = _.ele.querySelector('.glider-track');
            originalAddItem.call(_, ele);
        }

        gliderPrototype.updateControls = function (event) {
            let _ = this;

            _.slides = Array.from(_.slides).filter(
                (el) => { return !el.classList.contains('amlabel-position-wrapper') }
            );
            originalUpdateControls.call(_, event);
        }

        isAmlabelGliderLoad = true;
    })

    window.addEventListener('glider-loaded', (e) => {
        Glider(e.srcElement).refresh(true);
    })

</script>
<script>
    'use strict';

    function initAmInitConfigurableSwatchOptions() {
        const productId = this.$el.dataset.productId ?? this.$el.closest('form')?.querySelector('input[name="product"]').value;
        const component = window['initConfigurableSwatchOptions'] ?? window['initConfigurableSwatchOptions_' + productId]
        const originInitConfigurableSwatchOptions = component.call(this);

        return {
            ...originInitConfigurableSwatchOptions,
            init() {
                if (this.showSwatches !== undefined) {
                    this.$watch('showSwatches', value => {
                        if (value) {
                            this.dispatchConfigurableShowEvent();
                        }
                    });
                } else {
                    this.$nextTick(() => {
                        this.dispatchConfigurableShowEvent();
                    });
                }

                this.findAllowedAttributeOptions();
                this.$nextTick(() => {
                    if (typeof this.optionConfig.defaultValues === 'object') {
                        for (const [attributeId, value] of Object.entries(this.optionConfig.defaultValues)) {
                            this.changeOption(attributeId, value + '');
                        }
                    }
                });
            },

            dispatchConfigurableShowEvent() {
                window.dispatchEvent(new CustomEvent('configurable-show-swatches', {
                    detail: {
                        productId: this.productId,
                        element: this.$el
                    }
                }));
            }
        }
    }

    window.addEventListener('alpine:init', () => {
        Alpine.data('initAmInitConfigurableSwatchOptions', initAmInitConfigurableSwatchOptions);
    }, {once: true});
</script>
<script type="application&#x2F;json" id="dotdigital-email-capture-config">{"capture_url":"https:\/\/www.masterbooks.com\/connector\/ajax\/emailcapture\/","form_key":"zoOV9lBFMarBAz0K","layout":"cms_page_view","layout_postable":["checkout_index_index"],"layout_identifiers":{"default":["#newsletter"],"checkout_index_index":["#customer-email","#login-email"],"customer_account_login":["#email"],"customer_account_create":["#email_address"]}}</script><script src="https&#x3A;&#x2F;&#x2F;cdn.masterbooks.com&#x2F;static&#x2F;version1780560499&#x2F;frontend&#x2F;Ecommerce121&#x2F;masterbooks-hyva&#x2F;en_US&#x2F;Dotdigitalgroup_Email&#x2F;js&#x2F;emailCapture.js"></script>
<script>
    'use strict';

    (() => {
        const browserStorage = hyva.getBrowserStorage();
        const storageKey = 'mage-banners-cache-storage';
        const cacheTimeoutKey = 'mage-banners-cache-timeout';
        const storeIdKey = 'mage-banners-storeId';
        const cartIdKey = 'mage-banners-cartDataId';
        const options = {
            cacheTtl: 30000,
            sectionLoadUrl: 'https://www.masterbooks.com/banner/ajax/load/'
        };

        if (browserStorage && browserStorage.getItem(storageKey) === null) {
            browserStorage.setItem(storageKey, "{}");
        }

        async function initBanners(elements) {
            invalidateCacheBySessionTimeOut();

            const storageData = JSON.parse(browserStorage.getItem(storageKey));
            let items = [];

            if (storageData.data) {
                items = getFromStorage();
            } else {
                items = await getFromServer();
            }

            populateDynamicBlocks(elements, items);
        }

        // Cache invalidation. Banner cache ttl is 30 sec by default.
        function invalidateCacheBySessionTimeOut() {
            const cacheEol = new Date(browserStorage.getItem(cacheTimeoutKey))
            const dateTo = new Date(Date.now() + options.cacheTtl);
            const globalStoreId = hyva.getCookie('store') || 'default';
            const mageCacheStorage = JSON.parse(browserStorage.getItem('mage-cache-storage'));
            let cartDataId = null;

            if (browserStorage.getItem(storeIdKey) === null) {
                browserStorage.setItem(storeIdKey, globalStoreId);
            }

            if (mageCacheStorage !== null &&
                mageCacheStorage.hasOwnProperty('cart')) {
                cartDataId = mageCacheStorage.cart['data_id'];
            }

            if (cacheEol < new Date() ||
                browserStorage.getItem(storeIdKey) !== globalStoreId ||
                Number(browserStorage.getItem(cartIdKey)) !== cartDataId)
            {
                browserStorage.setItem(storageKey, "{}");
                browserStorage.setItem(cacheTimeoutKey, dateTo);
                browserStorage.setItem(storeIdKey, globalStoreId);

                if (cartDataId) {
                    browserStorage.setItem(cartIdKey, cartDataId);
                }
            }
        }

        async function getFromServer() {
            try {
                const url = new URL(options.sectionLoadUrl);
                url.searchParams.append('requesting_page_url', url.origin);
                url.searchParams.append('_', Date.now());

                const response = await fetch(url.href, {
                    headers: {
                        'Content-Type': 'application/json',
                        'X-Requested-With': 'XMLHttpRequest'
                    }
                });
                const storageData = await response.json();

                browserStorage.setItem(storageKey, JSON.stringify(storageData));

                if (storageData.data && storageData.data.items) {
                    return storageData.data.items.fixed ? storageData.data.items.fixed : [];
                }
            } catch (error) {
                console.warn(error);

                return [];
            }
        }

        function getFromStorage() {
            const storageData = JSON.parse(browserStorage.getItem(storageKey));
            if (storageData.data && storageData.data.items) {
                return storageData.data.items.fixed || [];
            }
        }

        function populateDynamicBlocks(elements, items) {
            if (!items || items.length === 0) {
                console.log(`No\u0020banners\u0020found`);

                return;
            }

            for (const element of elements) {
                // Filter IDs by those allowed for current customer segment
                const ids = element.getAttribute('data-ids').split(',').filter((id) => items.hasOwnProperty(id));
                const config = {
                    type: element.getAttribute('data-rotate'),
                    dynamicBlockId: element.getAttribute('data-banner-id'),
                };

                getByType(config, element, items, ids);
            }
        }

        function getByType(config = null, element, items, ids) {
            if (!config) return;

            if (config.type === 'random') {
                ids = [ids[Math.floor(Math.random() * ids.length)]];
            }

            if (config.type === 'series' || config.type === 'shuffle') {
                ids = [getNextInOrder(config, ids)];
            }

            for (const id of ids) {
                if (items[id]) {
                    element.insertAdjacentHTML('beforeend', items[id].content);
                }
            }
        }

        function getNextInOrder(config, ids) {
            const dynamicBlockId = config.dynamicBlockId;
            const localStorageKey = 'dynamic-block-banner-rotator';
            let localStorageData = JSON.parse(localStorage.getItem(localStorageKey)) || {};
            let nextId;

            if (localStorageData[dynamicBlockId] && localStorageData[dynamicBlockId].length > 0) {
                nextId = localStorageData[dynamicBlockId].shift(0);
            } else {
                if (config.type === 'shuffle') {
                    ids.sort(() => Math.random() - 0.5);
                }
                nextId = ids.shift(0);
                localStorageData[dynamicBlockId] = ids;
            }

            localStorage.setItem(
                localStorageKey,
                JSON.stringify(localStorageData)
            );

            return nextId;
        }

        const elements = document.querySelectorAll('[data-banner-id][data-ids]');
        if (elements.length > 0) {
            initBanners(elements);
        }
    })();
</script>
<script>
    // Functionality directly ported from original uiComponent, with minor modifications to work with Alpine
    function initBraintreePayPalExpress(clientToken, currency)
    {
        return {
            clientToken: clientToken,
            currency: currency,
            cart: null,
            customer: 0,
            isGuestCheckoutAllowed: null,
            init()
            {
                // don't do anything
            },
            custom_init()
            {
                // called by nextTick
                this.loadScript('https://js.braintreegateway.com/web/3.92.2/js/client.min.js', function() {
                    this.setupButton(this.$root);
                }.bind(this));
            },
            receiveCustomerData(event)
            {
                if(event.detail && event.detail.data){
                    this.cart = event.detail.data.cart;
                    if(this.cart){
                        this.isGuestCheckoutAllowed = this.cart.isGuestCheckoutAllowed;
                    }
                    this.customer = event.detail.data.customer;
                }
            },
            loadScript(url, callback)
            {
                const script = document.createElement('script');
                script.type = 'text/javascript';
                script.src = url;
                script.addEventListener('load', callback);
                document.head.appendChild(script);
            },
            buildForm(actionUrl, fields)
            {
                const form = document.createElement('form');
                form.action = actionUrl;
                form.method = 'POST';
                form.hidden = true;
                form.enctype = 'application/x-www-form-urlencoded';

                Object.entries(fields).forEach(field => {
                    const [key, value] = field;
                    let fieldElement;

                    fieldElement = document.createElement('input');
                    fieldElement.type = 'hidden';
                    fieldElement.name = key;
                    fieldElement.value = value;
                    form.appendChild(fieldElement);
                });

                document.body.appendChild(form);
                form.submit();
            },
            payPalButton(element, paypalCheckoutInstance)
            {
                let self = this,
                    style = {
                        color: element.dataset.color,
                        shape: element.dataset.shape,
                        size: element.dataset.size,
                    };

                if (element.dataset.fundingicons) {
                    style.fundingicons = element.dataset.fundingicons;
                }

                // Render
                let paypalActions;
                let button = paypal.Buttons({
                    fundingSource: element.dataset.funding,
                    style: style,

                    createOrder: function ()
                    {
                        return paypalCheckoutInstance.createPayment({
                            amount: element.dataset.amount,
                            locale: element.dataset.locale,
                            currency: element.dataset.currency,
                            flow: 'checkout',
                            enableShippingAddress: true,
                            displayName: element.dataset.displayname,
                        });
                    },

                    validate: function(actions)
                    {
                        if (!self.customer.firstname && !self.isGuestCheckoutAllowed) {
                            actions.disable();
                        }

                        paypalActions = actions;
                    },

                    onCancel: function (data)
                    {
                        console.warn('paypalCheckout\u0020has\u0020been\u0020cancelled', data);
                    },

                    onError: function (err)
                    {
                        console.error('paypalCheckout\u0020button\u0020render\u0020error', err);
                    },

                    onClick: function(data)
                    {
                        if (!self.customer.firstname && !self.isGuestCheckoutAllowed) {
                            alert('To\u0020check\u0020out,\u0020please\u0020sign\u0020in\u0020with\u0020your\u0020email\u0020address.');
                        }
                    },

                    onApprove: function (data1)
                    {
                        return paypalCheckoutInstance.tokenizePayment(data1, function(err, payload) {
                            // Map the shipping address correctly
                            var address = payload.details.shippingAddress,
                                recipientFirstName,
                                recipientLastName;

                            if (typeof address.recipientName !== 'undefined') {
                                var recipientName = address.recipientName.split(" ");

                                recipientFirstName = recipientName[0].replace(/'/g, "&apos;");
                                recipientLastName = recipientName[1].replace(/'/g, "&apos;");
                            } else {
                                recipientFirstName = payload.details.firstName.replace(/'/g, "&apos;");
                                recipientLastName = payload.details.lastName.replace(/'/g, "&apos;");
                            }

                            payload.details.shippingAddress = {
                                streetAddress: typeof address.line2 !== 'undefined'
                                    ? address.line1.replace(/'/g, '&apos;') + ' ' + address.line2.replace(/'/g, '&apos;')
                                    : address.line1.replace(/'/g, '&apos;'),
                                locality: address.city.replace(/'/g, '&apos;'),
                                postalCode: address.postalCode,
                                countryCodeAlpha2: address.countryCode,
                                email: payload.details.email.replace(/'/g, '&apos;'),
                                recipientFirstName: recipientFirstName,
                                recipientLastName: recipientLastName,
                                telephone: typeof payload.details.phone !== 'undefined'
                                    ? payload.details.phone
                                    : '',
                                region: typeof address.state !== 'undefined'
                                    ? address.state.replace(/'/g, '&apos;')
                                    : '',
                            };

                            if(element.dataset.location === 'productpage') {
                                var form = document.getElementById('product_addtocart_form');

                                if (!form.checkValidity()) {
                                    return false;
                                }

                                payload.additionalData = form.serialize();
                            }

                            var actionSuccess = element.dataset.actionsuccess;

                            self.buildForm(
                                actionSuccess,
                                {
                                    result: JSON.stringify(payload),
                                    form_key: hyva.getFormKey(),
                                }
                            );
                        });
                    }
                });

                if (!button.isEligible()) {
                    element.parentNode.remove();

                    return;
                }

                // Clear element content prior to render to prevent duplicated buttons
                element.innerHTML = '';
                button.render(element);
            },
            renderpayPalMessages()
            {
                document.querySelectorAll('.action-braintree-paypal-message').forEach((container) => {
                    paypal.Messages({
                        amount: container.dataset['pp-amount'],
                        pageType: container.dataset['pp-type'],
                        style: {
                            layout: 'text',
                        },
                    }).render('#' + container.id);
                })
            },
            loadBraintreeSDK(token, currency, button)
            {
                let self = this;

                braintree.client.create({
                    authorization: token
                }, (clientErr, clientInstance) => {
                    if (clientErr) {
                        return console.error('paypalCheckout\u0020error', clientErr);
                    }

                    self.loadScript('https://js.braintreegateway.com/web/3.92.2/js/data-collector.min.js', () => {
                        braintree.dataCollector.create({
                            client: clientInstance,
                            paypal: true
                        }, (err, dataCollectorinstance) => {
                            if (err) {
                                return console.error(err);
                            }
                        });
                    });

                    self.loadScript('https://js.braintreegateway.com/web/3.92.2/js/paypal-checkout.min.js', () => {
                        braintree.paypalCheckout.create({
                            client: clientInstance
                        }, (err, paypalCheckoutInstance) => {
                            if (typeof paypal !== 'undefined' ) {
                                self.payPalButton(button, paypalCheckoutInstance);
                                self.renderpayPalMessages();
                            } else {
                                paypalCheckoutInstance.loadPayPalSDK({
                                    components: 'buttons,messages,funding-eligibility',
                                    currency: currency,
                                }, () => {
                                    self.payPalButton(button, paypalCheckoutInstance);
                                    self.renderpayPalMessages();
                                });
                            }
                        });
                    });
                });
            },
            setupButton(button)
            {
                this.loadBraintreeSDK(this.clientToken, this.currency, button);
            },
        }
    }
</script>
<script>
    function initBraintreeApplePayExpress()
    {
        return {
            buttonApi: {},

            /**
             * Initialise Apple Pay.
             */
            init()
            {
                if (!this.deviceSupported()) {
                    return;
                }

                this.loadScript('https://js.braintreegateway.com/web/3.92.2/js/client.min.js', function() {
                    this.setupButton(this.$root);
                }.bind(this));
            },

            /**
             * Dynamically load a script from a given url.
             *
             * @param {String} url
             * @param callback
             * @return void
             */
            loadScript(url, callback)
            {
                const script = document.createElement('script');

                script.type = 'text/javascript';
                script.src = url;
                script.addEventListener('load', callback);

                document.head.appendChild(script);
            },

            /**
             * Fetch the countries via the Magento API.
             *
             * @return void
             */
            setupCountryDirectory()
            {
                if (!this.countryDirectory) {
                    fetch(
                        BASE_URL + 'rest/V1/directory/countries',
                        {
                            method: 'GET',
                        }
                    ).then(function (response) {
                        return response.json();
                    }).then(function (response) {
                        this.countryDirectory = {};

                        for (let i = 0; i < response.length; i++) {
                            let data = response[i];
                            this.countryDirectory[data.two_letter_abbreviation] = {};

                            if (typeof data.available_regions !== 'undefined') {
                                for (let x = 0; x < data.available_regions.length; x++) {
                                    let region = data.available_regions[x];
                                    let regionName = region.name.toLowerCase().replace(/[^A-Z0-9]/ig, '');

                                    this.countryDirectory[data.two_letter_abbreviation][regionName] = region.id;
                                }
                            }
                        }
                    }.bind(this));
                }
            },

            /**
             * Get the API URL based on whether the customer is logged in or not.
             *
             * @param {String} uri
             * @return {String}
             */
            getApiUrl(uri)
            {
                const baseUrl = BASE_URL + 'rest/' + this.storeCode + '/V1/';

                if (this.isLoggedIn) {
                    return baseUrl + 'carts/mine/' + uri;
                } else {
                    return baseUrl + 'guest-carts/' + this.quoteId + '/' + uri;
                }
            },

            /**
             * Get the region ID given a country code and region name combination.
             *
             * @param {String} countryCode
             * @param {String} regionName
             * @return {String|Number}
             */
            getRegionId(countryCode, regionName)
            {
                if (typeof regionName !== 'string') {
                    return null;
                }

                regionName = regionName.toLowerCase().replace(/[^A-Z0-9]/ig, '');

                if (typeof this.countryDirectory[countryCode] !== 'undefined'
                    && typeof this.countryDirectory[countryCode][regionName] !== 'undefined'
                ) {
                    return this.countryDirectory[countryCode][regionName];
                }

                return 0;
            },

            /**
             * Check the site is using HTTPS & Apple Pay is supported on the device.
             *
             * @return boolean
             */
            deviceSupported()
            {
                if (location.protocol !== 'https:') {
                    console.warn('Braintree\u0020Apple\u0020Pay\u0020requires\u0020your\u0020checkout\u0020be\u0020served\u0020over\u0020HTTPS');

                    return false;
                }

                if (!(window.ApplePaySession && ApplePaySession.canMakePayments())) {
                    console.warn('Braintree\u0020Apple\u0020Pay\u0020is\u0020not\u0020supported\u0020on\u0020this\u0020device\u002Fbrowser');

                    return false;
                }

                return true;
            },

            /**
             * Retrieve shipping methods based on address.
             *
             * @param {Object} event
             * @param {Object} session
             * @return false on error
             */
            onShippingContactSelect(event, session)
            {
                // get the address
                let address = event.shippingContact;

                // create a payload
                let payload = {
                    address: {
                        city: address.locality,
                        region: address.administrativeArea,
                        country_id: address.countryCode.toUpperCase(),
                        postcode: address.postalCode,
                        save_in_address_book: 0,
                    },
                };

                this.shippingAddress = payload.address;

                // POST to endpoint for shipping methods
                fetch(
                    this.getApiUrl('estimate-shipping-methods'),
                    {
                        method: 'POST',
                        body: JSON.stringify(payload),
                        headers: {
                            'Content-Type': 'application/json',
                            'X-Requested-With': 'XMLHttpRequest'
                        },
                    }
                ).then(function (response) {
                    return response.json();
                }).then(function (response) {
                    // stop if no shipping methods
                    if (response.length === 0) {
                        let virtualFlag = false;
                        let productItems = customerData.get('cart')().items;

                        productItems.forEach((item) => {
                            virtualFlag = item.product_type === 'virtual';
                        });

                        if (virtualFlag) {
                            session.completeShippingContactSelection(
                                ApplePaySession.STATUS_SUCCESS,
                                [],
                                {
                                    label: this.displayName,
                                    amount: this.grandTotalAmount,
                                },
                                [
                                    {
                                        type: 'final',
                                        label: 'Shipping',
                                        amount: 0,
                                    },
                                ]
                            );
                        } else {
                            session.abort();
                            alert('There\u0020are\u0020no\u0020shipping\u0020methods\u0020available\u0020for\u0020you\u0020right\u0020now.\u0020Please\u0020try\u0020again\u0020or\u0020use\u0020an\u0020alternative\u0020payment\u0020method.');

                            return false;
                        }
                    }

                    let shippingMethods = [];
                    this.shippingMethods = {};

                    // format shipping methods array
                    for (let i = 0; i < response.length; i++) {
                        if (typeof response[i].method_code !== 'string') {
                            continue;
                        }

                        let method = {
                            identifier: response[i].method_code,
                            label: response[i].method_title,
                            detail: response[i].carrier_title ? response[i].carrier_title : '',
                            amount: parseFloat(response[i].amount).toFixed(2),
                        };

                        // add method object to array
                        shippingMethods.push(method);

                        this.shippingMethods[response[i].method_code] = response[i];

                        if (!this.shippingMethod) {
                            this.shippingMethod = response[i].method_code;
                        }
                    }

                    // create payload to get totals
                    let totalsPayload = {
                        'addressInformation': {
                            'address': {
                                'countryId': this.shippingAddress.country_id,
                                'region': this.shippingAddress.region,
                                'regionId': this.getRegionId(
                                    this.shippingAddress.country_id,
                                    this.shippingAddress.region
                                ),
                                'postcode': this.shippingAddress.postcode
                            },
                            'shipping_method_code': this.shippingMethods[shippingMethods[0].identifier].method_code,
                            'shipping_carrier_code': this.shippingMethods[shippingMethods[0].identifier].carrier_code,
                        },
                    };

                    // POST to endpoint to get totals, using first shipping method
                    fetch(
                        this.getApiUrl('totals-information'),
                        {
                            method: 'POST',
                            body: JSON.stringify(totalsPayload),
                            headers: {
                                'Content-Type': 'application/json',
                                'X-Requested-With': 'XMLHttpRequest'
                            },
                        }
                    ).then(function (response) {
                        return response.json();
                    }).then(function (response) {
                        // set total
                        this.grandTotalAmount = response.base_grand_total;

                        // pass shipping methods back
                        session.completeShippingContactSelection(
                            ApplePaySession.STATUS_SUCCESS,
                            shippingMethods,
                            {
                                label: this.displayName,
                                amount: this.grandTotalAmount,
                            },
                            [
                                {
                                    type: 'final',
                                    label: 'Shipping',
                                    amount: shippingMethods[0].amount,
                                },
                            ]
                        );
                    }.bind(this)).catch(function (response) {
                        session.abort();
                        alert('We\u0020are\u0020unable\u0020to\u0020fetch\u0020the\u0020cart\u0020totals\u0020for\u0020you.\u0020Please\u0020try\u0020an\u0020alternative\u0020payment\u0020method.');
                        console.error(
                            'Braintree\u0020ApplePay\u003A\u0020Unable\u0020to\u0020get\u0020totals',
                            response
                        );

                        return false;
                    });
                }.bind(this)).catch(function (response) {
                    session.abort();
                    alert('We\u0020are\u0020unable\u0020to\u0020find\u0020any\u0020shipping\u0020methods\u0020for\u0020you.\u0020Please\u0020try\u0020an\u0020alternative\u0020payment\u0020method.');
                    console.error(
                        'Braintree\u0020ApplePay\u003A\u0020Unable\u0020to\u0020find\u0020shipping\u0020methods\u0020for\u0020estimate\u002Dshipping\u002Dmethods',
                        response
                    );

                    return false;
                });
            },

            /**
             * Record which shipping method has been selected and update totals.
             *
             * @param {Object} event
             * @param {Object} session
             * @return void
             */
            onShippingMethodSelect(event, session)
            {
                let shippingMethod = event.shippingMethod;
                this.shippingMethod = shippingMethod.identifier;

                let payload = {
                    'addressInformation': {
                        'address': {
                            'countryId': this.shippingAddress.country_id,
                            'region': this.shippingAddress.region,
                            'regionId': this.getRegionId(this.shippingAddress.country_id, this.shippingAddress.region),
                            'postcode': this.shippingAddress.postcode,
                        },
                        'shipping_method_code': this.shippingMethods[this.shippingMethod].method_code,
                        'shipping_carrier_code': this.shippingMethods[this.shippingMethod].carrier_code,
                    },
                };

                fetch(
                    this.getApiUrl('totals-information'),
                    {
                        method: 'POST',
                        body: JSON.stringify(payload),
                        headers: {
                            'Content-Type': 'application/json',
                            'X-Requested-With': 'XMLHttpRequest'
                        },
                    }
                ).then(function (response) {
                    return response.json();
                }).then(function (response) {
                    this.grandTotalAmount = response.base_grand_total;

                    session.completeShippingMethodSelection(
                        ApplePaySession.STATUS_SUCCESS,
                        {
                            label: this.displayName,
                            amount: this.grandTotalAmount,
                        },
                        [
                            {
                                type: 'final',
                                label: 'Shipping',
                                amount: shippingMethod.amount,
                            },
                        ]
                    );
                }.bind(this));
            },

            /**
             * Get the payment request.
             *
             * @return {Object}
             */
            getPaymentRequest()
            {
                return {
                    total: {
                        label: this.displayName,
                        amount: this.grandTotalAmount,
                    },
                    requiredShippingContactFields: ['postalAddress', 'name', 'email', 'phone'],
                    requiredBillingContactFields: ['postalAddress', 'name'],
                };
            },

            /**
             * Initiate the order placement process.
             *
             * @param {String} nonce
             * @param {Object} event
             * @param {Object} session
             */
            startPlaceOrder(nonce, event, session)
            {
                let shippingContact = event.payment.shippingContact;
                let billingContact = event.payment.billingContact;
                let payload = {
                    'addressInformation': {
                        'shipping_address': {
                            'email': shippingContact.emailAddress,
                            'telephone': shippingContact.phoneNumber,
                            'firstname': shippingContact.givenName,
                            'lastname': shippingContact.familyName,
                            'street': shippingContact.addressLines,
                            'city': shippingContact.locality,
                            'region': shippingContact.administrativeArea,
                            'region_id': this.getRegionId(
                                shippingContact.countryCode.toUpperCase(),
                                shippingContact.administrativeArea
                            ),
                            'region_code': null,
                            'country_id': shippingContact.countryCode.toUpperCase(),
                            'postcode': shippingContact.postalCode,
                            'same_as_billing': 0,
                            'customer_address_id': 0,
                            'save_in_address_book': 0,
                        },
                        'billing_address': {
                            'email': shippingContact.emailAddress,
                            'telephone': '0000000000',
                            'firstname': billingContact.givenName,
                            'lastname': billingContact.familyName,
                            'street': billingContact.addressLines,
                            'city': billingContact.locality,
                            'region': billingContact.administrativeArea,
                            'region_id': this.getRegionId(
                                billingContact.countryCode.toUpperCase(),
                                billingContact.administrativeArea
                            ),
                            'region_code': null,
                            'country_id': billingContact.countryCode.toUpperCase(),
                            'postcode': billingContact.postalCode,
                            'same_as_billing': 0,
                            'customer_address_id': 0,
                            'save_in_address_book': 0,
                        },
                        'shipping_method_code': this.shippingMethod
                            ? this.shippingMethods[this.shippingMethod].method_code
                            : '' ,
                        'shipping_carrier_code': this.shippingMethod
                            ? this.shippingMethods[this.shippingMethod].carrier_code
                            : '',
                    }
                };

                // set addresses
                fetch(
                    this.getApiUrl('shipping-information'),
                    {
                        method: 'POST',
                        body: JSON.stringify(payload),
                        headers: {
                            'Content-Type': 'application/json',
                            'X-Requested-With': 'XMLHttpRequest'
                        },
                    }
                ).then(function () {
                    // submit payment information
                    fetch(
                        this.getApiUrl('payment-information'),
                        {
                            method: 'POST',
                            body: JSON.stringify(
                                {
                                    'email': shippingContact.emailAddress,
                                    'paymentMethod': {
                                        'method': 'braintree_applepay',
                                        'additional_data': {
                                            'payment_method_nonce': nonce,
                                        },
                                        'extension_attributes': {
                                            'agreement_ids': [1],
                                        },
                                    },
                                }
                            ),
                            headers: {
                                'Content-Type': 'application/json',
                                'X-Requested-With': 'XMLHttpRequest'
                            },
                        }
                    ).then(function (response) {
                        document.location = this.actionSuccess;
                        session.completePayment(ApplePaySession.STATUS_SUCCESS);
                    }.bind(this)).catch(function (response) {
                        session.completePayment(ApplePaySession.STATUS_FAILURE);
                        session.abort();
                        alert('We\u0020are\u0020unable\u0020to\u0020take\u0020your\u0020payment\u0020through\u0020Apple\u0020Pay.\u0020Please\u0020try\u0020an\u0020again\u0020or\u0020use\u0020an\u0020alternative\u0020payment\u0020method.');
                        console.error(
                            'Braintree\u0020ApplePay\u003A\u0020Unable\u0020to\u0020take\u0020payment',
                            response
                        );

                        return false;
                    });
                }.bind(this)).catch(function (response) {
                    console.error(
                        'Braintree\u0020ApplePay\u0020Unable\u0020to\u0020set\u0020shipping\u0020information',
                        response
                    );
                    session.completePayment(ApplePaySession.STATUS_INVALID_BILLING_POSTAL_ADDRESS);
                });
            },

            /**
             * Initialise the Apple Pay button.
             *
             * @param {HTMLElement} button
             * @param {Object} context = this.buttonApi
             */
            initButton(button, context)
            {
                // no element or context
                if (!button || !context) {
                    return;
                }

                // context must implement these methods/have this data
                if (!context.clientToken) {
                    console.error(
                        'Braintree\u0020ApplePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020client\u0020token',
                        context
                    );

                    return;
                }

                if (typeof context.getPaymentRequest !== 'function') {
                    console.error(
                        'Braintree\u0020ApplePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020getPaymentRequest\u0020method',
                        context
                    );

                    return;
                }

                if (typeof context.startPlaceOrder !== 'function') {
                    console.error(
                        'Braintree\u0020ApplePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020startPlaceOrder\u0020method',
                        context
                    );

                    return;
                }

                if (this.deviceSupported() === false) {
                    return;
                }

                this.loadScript('https://js.braintreegateway.com/web/3.92.2/js/apple-pay.min.js', () => {
                    // init braintree api
                    braintree.client.create({authorization: context.clientToken}, function (clientErr, clientInstance) {
                        if (clientErr) {
                            console.error('Error\u0020creating\u0020client\u003A', clientErr);

                            return;
                        }

                        braintree.applePay.create({client: clientInstance}, function (applePayErr, applePayInstance) {
                            // no instance
                            if (applePayErr) {
                                console.error(
                                    'Braintree\u0020ApplePay\u0020Error\u0020creating\u0020applePayInstance\u003A',
                                    applePayErr
                                );

                                return;
                            }

                            var el = document.createElement('div');

                            el.className = 'braintree-apple-pay-button';
                            el.title = 'Pay\u0020with\u0020Apple\u0020Pay';
                            el.alt = 'Pay\u0020with\u0020Apple\u0020Pay';

                            el.addEventListener('click', function (e) {
                                e.preventDefault();

                                // payment request object
                                var paymentRequest = applePayInstance.createPaymentRequest(context.getPaymentRequest());

                                if (!paymentRequest) {
                                    alert('We\u0020are\u0020unable\u0020to\u0020take\u0020payments\u0020through\u0020Apple\u0020Pay\u0020at\u0020the\u0020moment.\u0020Please\u0020try\u0020an\u0020alternative\u0020payment\u0020method.');
                                    console.error(
                                        'Braintree\u0020ApplePay\u0020Unable\u0020to\u0020create\u0020paymentRequest',
                                        paymentRequest
                                    );

                                    return;
                                }

                                // init Apple Pay session
                                try {
                                    var session = new ApplePaySession(1, paymentRequest);
                                } catch (err) {
                                    console.error(
                                        'Braintree\u0020ApplePay\u0020Unable\u0020to\u0020create\u0020ApplePaySession',
                                        err
                                    );
                                    alert('We\u0020are\u0020unable\u0020to\u0020take\u0020payments\u0020through\u0020Apple\u0020Pay\u0020at\u0020the\u0020moment.\u0020Please\u0020try\u0020an\u0020alternative\u0020payment\u0020method.');

                                    return false;
                                }

                                // handle invalid merchant
                                session.onvalidatemerchant = function (event) {
                                    applePayInstance.performValidation({
                                        validationURL: event.validationURL,
                                        displayName: context.displayName,
                                    }, function (validationErr, merchantSession) {
                                        if (validationErr) {
                                            session.abort();
                                            console.error(
                                                'Braintree\u0020ApplePay\u0020Error\u0020validating\u0020merchant\u003A',
                                                validationErr
                                            );
                                            alert('We\u0020are\u0020unable\u0020to\u0020take\u0020payments\u0020through\u0020Apple\u0020Pay\u0020at\u0020the\u0020moment.\u0020Please\u0020try\u0020an\u0020alternative\u0020payment\u0020method.');

                                            return;
                                        }

                                        session.completeMerchantValidation(merchantSession);
                                    });
                                };

                                // attach payment auth event
                                session.onpaymentauthorized = function (event) {
                                    applePayInstance.tokenize({
                                        token: event.payment.token
                                    }, function (tokenizeErr, payload) {
                                        if (tokenizeErr) {
                                            console.error(
                                                'Error\u0020tokenizing\u0020Apple\u0020Pay\u003A',
                                                tokenizeErr
                                            );
                                            session.completePayment(ApplePaySession.STATUS_FAILURE);

                                            return;
                                        }

                                        // pass the nonce back to the payment method
                                        context.startPlaceOrder(payload.nonce, event, session);
                                    });
                                };

                                // attach onShippingContactSelect method
                                if (typeof context.onShippingContactSelect === 'function') {
                                    session.onshippingcontactselected = function (event) {
                                        return context.onShippingContactSelect(event, session);
                                    };
                                }

                                // attach onShippingMethodSelect method
                                if (typeof context.onShippingMethodSelect === 'function') {
                                    session.onshippingmethodselected = function (event) {
                                        return context.onShippingMethodSelect(event, session);
                                    };
                                }

                                // hook
                                if (typeof context.onButtonClick === 'function') {
                                    context.onButtonClick(session, this, e);
                                } else {
                                    session.begin();
                                }
                            });

                            button.appendChild(el);
                        });
                    });
                });
            },

            /**
             * Perform Apple Pay button setup.
             *
             * @param {HTMLElement} button
             * @returns {*}
             */
            setupButton(button)
            {
                this.buttonApi = {
                    actionSuccess: button.getAttribute('data-success'),
                    clientToken: button.getAttribute('data-client-token'),
                    countryDirectory: this.setupCountryDirectory,
                    displayName: button.getAttribute('data-display-name'),
                    getApiUrl: this.getApiUrl,
                    getPaymentRequest: this.getPaymentRequest,
                    getRegionId: this.getRegionId,
                    grandTotalAmount: parseFloat(button.getAttribute('data-amount')),
                    isLoggedIn: (button.getAttribute('data-is-logged-in') === 'true'),
                    onShippingContactSelect: this.onShippingContactSelect,
                    onShippingMethodSelect: this.onShippingMethodSelect,
                    quoteId: button.getAttribute('data-quote-id'),
                    shippingAddress: {},
                    shippingMethods: {},
                    startPlaceOrder: this.startPlaceOrder,
                    storeCode: button.getAttribute('data-store-code'),
                };

                // attach the button
                this.initButton(
                    button,
                    this.buttonApi
                );

                return this;
            },
        }
    }
</script>
<script>
    // Functionality directly ported from original uiComponent, with minor modifications to work with Alpine
    function initBraintreeGooglePayExpress(merchantId, clientToken)
    {
        return {
            merchantId: merchantId,
            clientToken: clientToken,
            buttonApi: {},
            init()
            {
                if (!this.deviceSupported()) {
                    return;
                }

                this.loadScript('https://pay.google.com/gp/p/js/pay.js', function() {
                    this.setupButton(this.$root);
                }.bind(this));
            },
            loadScript(url, callback)
            {
                const script = document.createElement('script');

                script.type = 'text/javascript';
                script.src = url;
                script.addEventListener('load', callback);
                document.head.appendChild(script);
            },
            buildForm(actionUrl, fields)
            {
                const form = document.createElement('form');
                form.action = actionUrl;
                form.method = 'POST';
                form.hidden = true;
                form.enctype = 'application/x-www-form-urlencoded';

                Object.entries(fields).forEach(field => {
                    const [key, value] = field;
                    let fieldElement;

                    fieldElement = document.createElement('input');
                    fieldElement.type = 'hidden';
                    fieldElement.name = key;
                    fieldElement.value = value;
                    form.appendChild(fieldElement);
                });

                document.body.appendChild(form);
                form.submit();
            },
            getMerchantId()
            {
                return this.merchantId;
            },
            getClientToken()
            {
                return this.clientToken;
            },
            deviceSupported()
            {
                return !!(window.PaymentRequest);
            },
            getPaymentRequest()
            {
                var buttonApi = this.buttonApi,
                    result = {
                        transactionInfo: {
                            totalPriceStatus: 'ESTIMATED',
                            totalPrice: buttonApi.amount,
                            currencyCode: buttonApi.currencyCode,
                        },
                        allowedPaymentMethods: ['CARD'],
                        phoneNumberRequired: true,
                        emailRequired: true,
                        shippingAddressRequired: true,
                        cardRequirements: {
                            billingAddressRequired: true,
                            billingAddressFormat: 'FULL',
                            allowedCardNetworks: Object.values({...buttonApi.cardTypes}), // Needs to be Array protototype not object
                        },
                    };

                if (buttonApi.environment !== "TEST") {
                    result['merchantId'] = this.getMerchantId();
                }

                return result;
            },
            startPlaceOrder(nonce, paymentData)
            {
                var payload = {
                    details: {
                        shippingAddress: {
                            streetAddress: paymentData.shippingAddress.address1
                                + "\n"
                                + paymentData.shippingAddress.address2,
                            locality: paymentData.shippingAddress.locality,
                            postalCode: paymentData.shippingAddress.postalCode,
                            countryCodeAlpha2: paymentData.shippingAddress.countryCode,
                            email: paymentData.email,
                            name: paymentData.shippingAddress.name,
                            telephone: typeof paymentData.shippingAddress.phoneNumber !== 'undefined'
                                ? paymentData.shippingAddress.phoneNumber
                                : '',
                            region: typeof paymentData.shippingAddress.administrativeArea !== 'undefined'
                                ? paymentData.shippingAddress.administrativeArea
                                : '',
                        },
                        billingAddress: {
                            streetAddress: paymentData.cardInfo.billingAddress.address1
                                + "\n"
                                + paymentData.cardInfo.billingAddress.address2,
                            locality: paymentData.cardInfo.billingAddress.locality,
                            postalCode: paymentData.cardInfo.billingAddress.postalCode,
                            countryCodeAlpha2: paymentData.cardInfo.billingAddress.countryCode,
                            email: paymentData.email,
                            name: paymentData.cardInfo.billingAddress.name,
                            telephone: typeof paymentData.cardInfo.billingAddress.phoneNumber !== 'undefined'
                                ? paymentData.cardInfo.billingAddress.phoneNumber
                                : '',
                            region: typeof paymentData.cardInfo.billingAddress.administrativeArea !== 'undefined'
                                ? paymentData.cardInfo.billingAddress.administrativeArea
                                : '',
                        },
                    },
                    nonce: nonce,
                };

                this.buildForm(
                    this.buttonApi.actionSuccess,
                    {
                        result: JSON.stringify(payload),
                        form_key: hyva.getFormKey(),
                    }
                );
            },
            initButton(element, context)
            {
                // No element or context
                if (!element || !context || !this.deviceSupported()) {
                    return;
                }

                // Context must implement these methods
                if (!context.clientToken) {
                    console.error(
                        'Braintree\u0020GooglePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020clientToken',
                        context
                    );

                    return;
                }
                if (typeof context.getPaymentRequest !== 'function') {
                    console.error(
                        'Braintree\u0020GooglePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020getPaymentRequest\u0020method',
                        context
                    );

                    return;
                }
                if (typeof context.startPlaceOrder !== 'function') {
                    console.error(
                        'Braintree\u0020GooglePay\u0020Context\u0020passed\u0020does\u0020not\u0020provide\u0020a\u0020startPlaceOrder\u0020method',
                        context
                    );

                    return;
                }

                // init google pay object
                let paymentsClient = new google.payments.api.PaymentsClient({
                    environment: context.environment
                });

                // Create a button within the KO element, as google pay can only be instantiated through
                // a valid on click event (ko onclick bind interferes with this).
                var button = document.createElement('button');
                var self = this;
                button.className = `braintree-googlepay-button long ${context.btnColor ? 'black' : 'white'}`;
                button.title = 'Buy with Google Pay';

                self.loadScript('https://js.braintreegateway.com/web/3.67.0/js/client.min.js', () => {
                    // init braintree api
                    braintree.client.create({
                        authorization: context.clientToken
                    }, function (clientErr, clientInstance) {
                        if (clientErr) {
                            console.error('Error\u0020creating\u0020client\u003A', clientErr);
                            return;
                        }

                        self.loadScript('https://js.braintreegateway.com/web/3.67.0/js/google-payment.min.js', () => {
                            braintree.googlePayment.create({
                                client: clientInstance
                            }, function (googlePayErr, googlePaymentInstance) {
                                // No instance
                                if (googlePayErr) {
                                    console.error(
                                        'Braintree\u0020GooglePay\u0020Error\u0020creating\u0020googlePayInstance\u003A',
                                        googlePayErr
                                    );

                                    return;
                                }

                                paymentsClient.isReadyToPay({
                                    allowedPaymentMethods: googlePaymentInstance.createPaymentDataRequest().allowedPaymentMethods
                                }).then(function(response) {
                                    if (response.result) {
                                        button.addEventListener('click', function (event) {
                                            event.preventDefault();

                                            var responseData;
                                            var paymentDataRequest = googlePaymentInstance.createPaymentDataRequest(
                                                context.getPaymentRequest.call(self)
                                            );

                                            paymentsClient.loadPaymentData(
                                                paymentDataRequest
                                            ).then(function (paymentData) {
                                                // Persist the paymentData (shipping address etc)
                                                responseData = paymentData;

                                                // Return the braintree nonce promise
                                                return googlePaymentInstance.parseResponse(paymentData);
                                            }).then(function (result) {
                                                context.startPlaceOrder.call(self, result.nonce, responseData);
                                            }).catch(function (err) {
                                                // Handle errors
                                                // err = {statusCode: "CANCELED"}
                                                console.error(err);
                                            });
                                        });

                                        element.appendChild(button);
                                    }
                                }).catch(function (err) {
                                    console.error(err);
                                });
                            });
                        });
                    });
                });
            },
            setupButton(button)
            {
                this.buttonApi = {
                    environment: button.getAttribute('data-environment'),
                    currencyCode: button.getAttribute('data-currency'),
                    clientToken: this.getClientToken(),
                    merchantId: this.getMerchantId(),
                    actionSuccess: button.getAttribute('data-success'),
                    amount: parseFloat(button.getAttribute('data-amount')),
                    cardTypes: button.getAttribute('data-card-types').split(','),
                    btnColor: button.getAttribute('data-color'),
                    getPaymentRequest: this.getPaymentRequest,
                    startPlaceOrder: this.startPlaceOrder,
                };

                // Attach the button
                this.initButton(
                    button,
                    this.buttonApi
                );

                return this;
            },
        }
    }
</script>
<div class="container widget block block-static-block">
    <style>.cmsb236-fixed {
position: fixed
}
.cmsb236-transform {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
}
.cmsb236-border {
border-width: 1px
}
.cmsb236-transition {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms
}</style>
<div data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><a id="supportFooterOverlayLink" 
x-data="initStickySupportFooter()"
x-on:scroll.window.throttle.debounce.passive="handleStickySupportFooter()"
href="/contact" 
style="z-index: 10; position: fixed; left: 0; bottom: 0; padding: 15px 15px 15px 15px; background-color: white; border-radius: 0 15px 0 0; border: solid; border-width: 1px 1px 0 0; border-color: #e5e7eb; transition: bottom 0.3s ease-in-out; bottom: -81px;" 
>
<!--<img src="https://cdn.masterbooks.com/media/converted/wysiwyg/callouts/life-ring.webp" alt="" />-->
<svg id="a" width="50" height = "50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 417.08 348.88"><defs><style>.support-overlay-b{fill:#f37021;}.support-overlay-c{fill:#fff;}.support-overlay-d{fill:#242424;}</style></defs><path class="support-overlay-b" d="M208.54,40.5c-73.26,0-132.65,59.39-132.65,132.65,0,37.93,15.92,72.15,41.45,96.32l-11.16,59.61c-.57,3.07,2.64,5.45,5.41,4l60.42-31.54c.32-.17.6-.37.84-.6,11.36,3.17,23.33,4.86,35.7,4.86,73.26,0,132.65-59.39,132.65-132.65S281.8,40.5,208.54,40.5Z"/><path class="support-overlay-d" d="M408.37,161.69h-6.44v85.81h6.44c4.81,0,8.71-3.9,8.71-8.71v-68.4c0-4.81-3.9-8.71-8.71-8.71Z"/><path class="support-overlay-d" d="M0,170.4v68.4c0,4.81,3.9,8.71,8.71,8.71h6.44v-85.81h-6.44c-4.81,0-8.71,3.9-8.71,8.71Z"/><path class="support-overlay-d" d="M384.23,147.23h-.23C369.36,63.58,296.38,0,208.54,0S47.71,63.58,33.08,147.23h-.2c-7.07,2.65-12.07,9.22-12.07,16.92v80.89c0,10.04,8.5,18.18,19,18.18h7.57c10.49,0,19-8.14,19-18.18v-80.89c0-7.12-4.27-13.28-10.49-16.26,14.08-71.46,77.08-125.36,152.67-125.36s138.59,53.9,152.67,125.36c-6.22,2.99-10.49,9.14-10.49,16.26v80.89c0,8.72,6.41,16,14.97,17.77l-3,4.51c-19.13,28.82-46.33,50.89-76.57,62.15l-3.98,1.48-2.25-3.47c-5.14-7.91-13.14-12.44-21.94-12.44h-2.33c-14.93,0-27.07,13.44-27.07,29.95v1.15c0,1.37,1.08,2.5,2.45,2.56,15.59.74,31.77-.87,47.39-4.76,42.12-8.84,77.58-36.88,102.93-81.13,8.55-1.77,14.97-9.05,14.97-17.77v-80.89c0-7.69-4.99-14.27-12.04-16.92Z"/><circle class="support-overlay-c" cx="267.23" cy="180.22" r="14.78" transform="translate(47.08 415.64) rotate(-80.92)"/><circle class="support-overlay-c" cx="208.54" cy="180.22" r="14.78" transform="translate(-66.35 200.24) rotate(-45)"/><circle class="support-overlay-c" cx="149.84" cy="180.22" r="14.78" transform="translate(-51.77 299.72) rotate(-80.92)"/></svg>
</a>

<script>
function initStickySupportFooter() {
 return {
  isStickySupportFooterVisible: false,
  stickySupportFooterTriggerHeight: 400,
    supportFooter: document.getElementById('supportFooterOverlayLink'),
    handleStickySupportFooter() {
      this.isStickySupportFooterVisible = document.body.scrollTop > this.stickySupportFooterTriggerHeight
        || document.documentElement.scrollTop > this.stickySupportFooterTriggerHeight;
(this.isStickySupportFooterVisible ? this.supportFooter.style.bottom = 0 : this.supportFooter.style.bottom = "-81px")


 }
}
}
</script></div></div>
<div x-cloak x-data="{...initAmBanners()}" x-init="initBanners()">
    <div
    class="z-50 fixed inset-0 flex justify-center items-center bg-white/70 select-none"
    x-show="isLoading"
    x-cloak
    x-transition.opacity.duration.200ms
>
    <div class="flex items-center">
        <svg xmlns="http://www.w3.org/2000/svg" width="54" height="54" viewBox="0 0 50 50" aria-hidden="true">
    <path fill="#d9dddd" d="M43.935 25.145c0-10.318-8.364-18.683-18.683-18.683-10.318 0-18.683 8.365-18.683 18.683h4.068c0-8.071 6.543-14.615 14.615-14.615s14.615 6.543 14.615 14.615h4.068z">
        <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"/>
    </path>
</svg>
        <div class="ml-10 text-xl">
            Loading...        </div>
    </div>
</div>
</div>
<script>
    'use strict';

    function initAmBanners() {
        const productId = "";
        const categoryId = "";
        const searchQuery = "";

        return {
            options: {
                sections: [],
                content: [],
                banners: [],
                injectorSectionId: null,
                injectorParams: {}
            },
            isLoading: true,
            injectorResolver: {},

            initBanners: function () {
                this.options = {"sections":{"2":[3,5],"7":[6]},"content":{"3":"\n<div data-banner-id=\"3\">\n    <a href='\/request-catalog'><img src='https:\/\/cdn.masterbooks.com\/media\/amasty\/ampromobanners\/banner_3_catalog-ad-v2-360x360.jpg' alt='Explore the Master Books Christian Homeschool Catalog' \/><\/a>    <\/div>\n","5":"\n<div data-banner-id=\"5\">\n    <a href='\/america-250-homeschool'><img src='https:\/\/cdn.masterbooks.com\/media\/amasty\/ampromobanners\/banner_5_3-america-250-homepage-360x360.jpg' alt='Celebrate America\u2019s 250th Birthday in Your Homeschool. Download a FREE America 250 Unit Study.' \/><\/a>    <\/div>\n","6":"\n<div data-banner-id=\"6\">\n    <p style=\"font-weight: bold; text-align: left; color: black; clear: both;\">Note for ebook customers:<\/p>\r\n<p style=\"text-align: left; color: black;\">The design and layout of this book play a key role in conveying the author's message. When creating the ebooks, we've tried to keep the look and feel of the print edition, but this means that not all e-reading devices will support the files. \r\n<\/p>\r\n<p style=\"text-align: left; color: black;\">The EPUB format is optimized for iPad. The Kindle\/Mobi files are optimized for Kindle Fire tablets and phones and for Kindle reading apps.<\/p>    <\/div>\n"},"injectorParams":{"containerSelector":".products-grid .product-items:not(.amasty-banner-items)","itemSelector":".products-grid .product-items:not(.amasty-banner-items) > .product-item","banners":[]},"banners":[],"injectorSectionId":14};
                this.injectorResolver = amBannerInjectorResolver?.();

                this.insertBanners();
                this.isLoading = false;
                window.addEventListener('private-content-loaded', event => this.cartUpdatedEventHandler(event.detail.data));
            },

            insertBanners: function (sectionId) {
                let selector = '[data-role="amasty-banner-container"]';
                if (sectionId) {
                    selector += `[data-position="${sectionId}"]`;
                }
                document.querySelectorAll(selector).forEach((container) => {
                    const sectionId = container.getAttribute('data-position');

                    if (sectionId) {
                        this.loadBannerBySection(sectionId, container);
                    } else {
                        this.loadBannerByBannerId(container);
                    }
                });
            },

            getBanners: function (bannerId) {
                if (this.options.banners.indexOf(bannerId) === -1) {
                    return [];
                }
                const insertedBanner = this.banners.find((element) => {
                    return element === bannerId;
                });

                return content[insertedBanner];
            },

            getSectionBanners: function (section) {
                if (!(section in this.options.sections)) {
                    return [];
                }

                return this.options.sections[section].map((id) => {
                    return this.options.content[id];
                });
            },

            loadBannerBySection: function (sectionId, container) {
                container.innerHTML = this.getSectionBanners(sectionId).join('');
                this.injectorResolver?.resolve(sectionId, this.options.injectorParams);
                this.updateSection(`[data-role="amasty-banner-container"][data-position="${sectionId}"]`, container);
            },

            loadBannerByBannerId: function (container) {
                const bannerId = container.getAttribute('data-bannerid');
                container.innerHTML = (this.getBanners(bannerId));
                this.updateSection(`[data-role="amasty-banner-container"][data-bannerid="${bannerId}"]`, container);
            },

            updateSection: function(containerSelector, container) {
                hyva.replaceDomElement(
                    containerSelector,
                    container.innerHTML
                );
            },

            cartUpdatedEventHandler: function(data) {
                return fetch(BASE_URL + "amasty_banners/data/getBannersData?productId=" + productId +
                    '&cataegoryId=' + categoryId +
                    '&q=' + searchQuery +
                    '&cart_data_id=' + data.cart.data_id, {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                }).then(response => response.json()).then(result => {
                    if (result?.bannersData) {
                        this.handleNewContent(result.bannersData);
                    }
                });
            },

            handleNewContent: function (bannersData) {
                this.cleanSections();
                const {sections} = bannersData;
                this.options = bannersData;
                Object.entries(sections).forEach(([position]) => {
                    this.insertBanners(position);
                });
            },

            cleanSections: function () {
                Object.entries(this.options.sections).forEach(([position]) => {
                    document.querySelectorAll(`[data-role="amasty-banner-container"][data-position="${position}"]`).forEach((container) => {
                        container.innerHTML = '';
                    });
                });
            }
        }
    }
</script>
<script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https:\/\/www.masterbooks.com\/","name":"Home"}}]}</script><script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"WebSite","url":"https:\/\/www.masterbooks.com\/","name":"Master Books","potentialAction":{"@type":"SearchAction","target":"https:\/\/www.masterbooks.com\/catalogsearch\/result\/?q={search_term_string}","query-input":"required name=search_term_string"}}</script><script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Organization","url":"https:\/\/www.masterbooks.com\/","name":"Master Books","logo":"https:\/\/www.masterbooks.com\/media\/images\/mb-curriculum-logo.png","address":{"addressCountry":"US","@type":"PostalAddress"},"sameAs":["https:\/\/www.facebook.com\/MasterBooks\/","https:\/\/www.instagram.com\/masterbooks\/","https:\/\/www.youtube.com\/channel\/UCMIRBrZys2p-6a1o_jz_6qw"]}</script><script type="text/json" id="default-section-data">
    {"messages":[],"customer":[],"compare-products":[],"last-ordered-items":[],"cart":[],"directory-data":{"AD":{"name":"Andorra"},"AE":{"name":"United Arab Emirates"},"AF":{"name":"Afghanistan"},"AG":{"name":"Antigua & Barbuda"},"AI":{"name":"Anguilla"},"AL":{"name":"Albania","regions":{"756":{"code":"AL-01","name":"Berat"},"757":{"code":"AL-09","name":"Dib\u00ebr"},"758":{"code":"AL-02","name":"Durr\u00ebs"},"759":{"code":"AL-03","name":"Elbasan"},"760":{"code":"AL-04","name":"Fier"},"761":{"code":"AL-05","name":"Gjirokast\u00ebr"},"762":{"code":"AL-06","name":"Kor\u00e7\u00eb"},"763":{"code":"AL-07","name":"Kuk\u00ebs"},"764":{"code":"AL-08","name":"Lezh\u00eb"},"765":{"code":"AL-10","name":"Shkod\u00ebr"},"766":{"code":"AL-11","name":"Tiran\u00eb"},"767":{"code":"AL-12","name":"Vlor\u00eb"}}},"AM":{"name":"Armenia"},"AO":{"name":"Angola"},"AQ":{"name":"Antarctica"},"AR":{"name":"Argentina","regions":{"769":{"code":"AR-B","name":"Buenos Aires"},"770":{"code":"AR-K","name":"Catamarca"},"771":{"code":"AR-H","name":"Chaco"},"772":{"code":"AR-U","name":"Chubut"},"768":{"code":"AR-C","name":"Ciudad Aut\u00f3noma de Buenos Aires"},"773":{"code":"AR-X","name":"C\u00f3rdoba"},"774":{"code":"AR-W","name":"Corrientes"},"775":{"code":"AR-E","name":"Entre R\u00edos"},"776":{"code":"AR-P","name":"Formosa"},"777":{"code":"AR-Y","name":"Jujuy"},"778":{"code":"AR-L","name":"La Pampa"},"779":{"code":"AR-F","name":"La Rioja"},"780":{"code":"AR-M","name":"Mendoza"},"781":{"code":"AR-N","name":"Misiones"},"782":{"code":"AR-Q","name":"Neuqu\u00e9n"},"783":{"code":"AR-R","name":"R\u00edo Negro"},"784":{"code":"AR-A","name":"Salta"},"785":{"code":"AR-J","name":"San Juan"},"786":{"code":"AR-D","name":"San Luis"},"787":{"code":"AR-Z","name":"Santa Cruz"},"788":{"code":"AR-S","name":"Santa Fe"},"789":{"code":"AR-G","name":"Santiago del Estero"},"790":{"code":"AR-V","name":"Tierra del Fuego"},"791":{"code":"AR-T","name":"Tucum\u00e1n"}}},"AS":{"name":"American Samoa"},"AT":{"name":"Austria","regions":{"102":{"code":"BL","name":"Burgenland"},"99":{"code":"KN","name":"K\u00e4rnten"},"96":{"code":"NO","name":"Nieder\u00f6sterreich"},"97":{"code":"OO","name":"Ober\u00f6sterreich"},"98":{"code":"SB","name":"Salzburg"},"100":{"code":"ST","name":"Steiermark"},"101":{"code":"TI","name":"Tirol"},"103":{"code":"VB","name":"Vorarlberg"},"95":{"code":"WI","name":"Wien"}}},"AU":{"name":"Australia","regions":{"485":{"code":"ACT","name":"Australian Capital Territory"},"486":{"code":"NSW","name":"New South Wales"},"492":{"code":"NT","name":"Northern Territory"},"488":{"code":"QLD","name":"Queensland"},"489":{"code":"SA","name":"South Australia"},"490":{"code":"TAS","name":"Tasmania"},"487":{"code":"VIC","name":"Victoria"},"491":{"code":"WA","name":"Western Australia"}}},"AW":{"name":"Aruba"},"AX":{"name":"\u00c5land Islands"},"AZ":{"name":"Azerbaijan"},"BA":{"name":"Bosnia & Herzegovina"},"BB":{"name":"Barbados"},"BD":{"name":"Bangladesh"},"BE":{"name":"Belgium","regions":{"525":{"code":"VAN","name":"Antwerpen"},"526":{"code":"WBR","name":"Brabant wallon"},"527":{"code":"BRU","name":"Brussels-Capital Region"},"528":{"code":"WHT","name":"Hainaut"},"530":{"code":"WLG","name":"Li\u00e8ge"},"529":{"code":"VLI","name":"Limburg"},"531":{"code":"WLX","name":"Luxembourg"},"532":{"code":"WNA","name":"Namur"},"533":{"code":"VOV","name":"Oost-Vlaanderen"},"534":{"code":"VBR","name":"Vlaams-Brabant"},"535":{"code":"VWV","name":"West-Vlaanderen"}}},"BF":{"name":"Burkina Faso"},"BG":{"name":"Bulgaria","regions":{"570":{"code":"BG-01","name":"Blagoevgrad"},"571":{"code":"BG-02","name":"Burgas"},"577":{"code":"BG-08","name":"Dobrich"},"576":{"code":"BG-07","name":"Gabrovo"},"595":{"code":"BG-26","name":"Haskovo"},"578":{"code":"BG-09","name":"Kardzhali"},"579":{"code":"BG-10","name":"Kyustendil"},"580":{"code":"BG-11","name":"Lovech"},"581":{"code":"BG-12","name":"Montana"},"582":{"code":"BG-13","name":"Pazardzhik"},"583":{"code":"BG-14","name":"Pernik"},"584":{"code":"BG-15","name":"Pleven"},"585":{"code":"BG-16","name":"Plovdiv"},"586":{"code":"BG-17","name":"Razgrad"},"587":{"code":"BG-18","name":"Ruse"},"596":{"code":"BG-27","name":"Shumen"},"588":{"code":"BG-19","name":"Silistra"},"589":{"code":"BG-20","name":"Sliven"},"590":{"code":"BG-21","name":"Smolyan"},"591":{"code":"BG-22","name":"Sofia City"},"592":{"code":"BG-23","name":"Sofia Province"},"593":{"code":"BG-24","name":"Stara Zagora"},"594":{"code":"BG-25","name":"Targovishte"},"572":{"code":"BG-03","name":"Varna"},"573":{"code":"BG-04","name":"Veliko Tarnovo"},"574":{"code":"BG-05","name":"Vidin"},"575":{"code":"BG-06","name":"Vratsa"},"597":{"code":"BG-28","name":"Yambol"}}},"BH":{"name":"Bahrain"},"BI":{"name":"Burundi"},"BJ":{"name":"Benin"},"BL":{"name":"St. Barth\u00e9lemy"},"BM":{"name":"Bermuda"},"BN":{"name":"Brunei"},"BO":{"name":"Bolivia","regions":{"800":{"code":"BO-H","name":"Chuquisaca"},"799":{"code":"BO-C","name":"Cochabamba"},"801":{"code":"BO-B","name":"El Beni"},"802":{"code":"BO-L","name":"La Paz"},"803":{"code":"BO-O","name":"Oruro"},"804":{"code":"BO-N","name":"Pando"},"805":{"code":"BO-P","name":"Potos\u00ed"},"806":{"code":"BO-S","name":"Santa Cruz"},"807":{"code":"BO-T","name":"Tarija"}}},"BR":{"name":"Brazil"},"BS":{"name":"Bahamas"},"BT":{"name":"Bhutan"},"BV":{"name":"Bouvet Island"},"BW":{"name":"Botswana"},"BY":{"name":"Belarus","regions":{"792":{"code":"BY-BR","name":"Bresckaja voblas\u0107"},"793":{"code":"BY-HO","name":"Homie\u013askaja voblas\u0107"},"794":{"code":"BY-HM","name":"Horad Minsk"},"795":{"code":"BY-HR","name":"Hrodzienskaja voblas\u0107"},"796":{"code":"BY-MA","name":"Mahilio\u016dskaja voblas\u0107"},"797":{"code":"BY-MI","name":"Minskaja voblas\u0107"},"798":{"code":"BY-VI","name":"Viciebskaja voblas\u0107"}}},"BZ":{"name":"Belize"},"CA":{"name":"Canada","regions":{"66":{"code":"AB","name":"Alberta"},"67":{"code":"BC","name":"British Columbia"},"68":{"code":"MB","name":"Manitoba"},"70":{"code":"NB","name":"New Brunswick"},"69":{"code":"NL","name":"Newfoundland and Labrador"},"72":{"code":"NT","name":"Northwest Territories"},"71":{"code":"NS","name":"Nova Scotia"},"73":{"code":"NU","name":"Nunavut"},"74":{"code":"ON","name":"Ontario"},"75":{"code":"PE","name":"Prince Edward Island"},"76":{"code":"QC","name":"Quebec"},"77":{"code":"SK","name":"Saskatchewan"},"78":{"code":"YT","name":"Yukon Territory"}}},"CC":{"name":"Cocos (Keeling) Islands"},"CD":{"name":"Congo - Kinshasa"},"CF":{"name":"Central African Republic"},"CG":{"name":"Congo - Brazzaville"},"CH":{"name":"Switzerland","regions":{"104":{"code":"AG","name":"Aargau"},"106":{"code":"AR","name":"Appenzell Ausserrhoden"},"105":{"code":"AI","name":"Appenzell Innerrhoden"},"108":{"code":"BL","name":"Basel-Landschaft"},"109":{"code":"BS","name":"Basel-Stadt"},"107":{"code":"BE","name":"Bern"},"110":{"code":"FR","name":"Friburg"},"111":{"code":"GE","name":"Geneva"},"112":{"code":"GL","name":"Glarus"},"113":{"code":"GR","name":"Graub\u00fcnden"},"114":{"code":"JU","name":"Jura"},"115":{"code":"LU","name":"Lucerne"},"116":{"code":"NE","name":"Neuch\u00e2tel"},"117":{"code":"NW","name":"Nidwalden"},"118":{"code":"OW","name":"Obwalden"},"120":{"code":"SH","name":"Schaffhausen"},"122":{"code":"SZ","name":"Schwyz"},"121":{"code":"SO","name":"Solothurn"},"119":{"code":"SG","name":"St. Gallen"},"123":{"code":"TG","name":"Thurgau"},"124":{"code":"TI","name":"Ticino"},"125":{"code":"UR","name":"Uri"},"126":{"code":"VD","name":"Vaud"},"127":{"code":"VS","name":"Wallis"},"128":{"code":"ZG","name":"Zug"},"129":{"code":"ZH","name":"Z\u00fcrich"}}},"CI":{"name":"C\u00f4te d\u2019Ivoire"},"CK":{"name":"Cook Islands"},"CL":{"name":"Chile","regions":{"808":{"code":"CL-AI","name":"Ais\u00e9n del General Carlos Iba\u00f1ez del Campo"},"809":{"code":"CL-AN","name":"Antofagasta"},"810":{"code":"CL-AP","name":"Arica y Parinacota"},"812":{"code":"CL-AT","name":"Atacama"},"813":{"code":"CL-BI","name":"Biob\u00edo"},"814":{"code":"CL-CO","name":"Coquimbo"},"811":{"code":"CL-AR","name":"La Araucan\u00eda"},"815":{"code":"CL-LI","name":"Libertador General Bernardo O'Higgins"},"816":{"code":"CL-LL","name":"Los Lagos"},"817":{"code":"CL-LR","name":"Los R\u00edos"},"818":{"code":"CL-MA","name":"Magallanes"},"819":{"code":"CL-ML","name":"Maule"},"820":{"code":"CL-NB","name":"\u00d1uble"},"821":{"code":"CL-RM","name":"Regi\u00f3n Metropolitana de Santiago"},"822":{"code":"CL-TA","name":"Tarapac\u00e1"},"823":{"code":"CL-VS","name":"Valpara\u00edso"}}},"CM":{"name":"Cameroon"},"CN":{"name":"China","regions":{"536":{"code":"CN-AH","name":"Anhui Sheng"},"537":{"code":"CN-BJ","name":"Beijing Shi"},"538":{"code":"CN-CQ","name":"Chongqing Shi"},"539":{"code":"CN-FJ","name":"Fujian Sheng"},"540":{"code":"CN-GS","name":"Gansu Sheng"},"541":{"code":"CN-GD","name":"Guangdong Sheng"},"542":{"code":"CN-GX","name":"Guangxi Zhuangzu Zizhiqu"},"543":{"code":"CN-GZ","name":"Guizhou Sheng"},"544":{"code":"CN-HI","name":"Hainan Sheng"},"545":{"code":"CN-HE","name":"Hebei Sheng"},"546":{"code":"CN-HL","name":"Heilongjiang Sheng"},"547":{"code":"CN-HA","name":"Henan Sheng"},"548":{"code":"CN-HK","name":"Hong Kong SAR"},"549":{"code":"CN-HB","name":"Hubei Sheng"},"550":{"code":"CN-HN","name":"Hunan Sheng"},"551":{"code":"CN-JS","name":"Jiangsu Sheng"},"552":{"code":"CN-JX","name":"Jiangxi Sheng"},"553":{"code":"CN-JL","name":"Jilin Sheng"},"554":{"code":"CN-LN","name":"Liaoning Sheng"},"555":{"code":"CN-MO","name":"Macao SAR"},"556":{"code":"CN-NM","name":"Nei Mongol Zizhiqu"},"557":{"code":"CN-NX","name":"Ningxia Huizi Zizhiqu"},"558":{"code":"CN-QH","name":"Qinghai Sheng"},"559":{"code":"CN-SN","name":"Shaanxi Sheng"},"560":{"code":"CN-SD","name":"Shandong Sheng"},"561":{"code":"CN-SH","name":"Shanghai Shi"},"562":{"code":"CN-SX","name":"Shanxi Sheng"},"563":{"code":"CN-SC","name":"Sichuan Sheng"},"564":{"code":"CN-TW","name":"Taiwan Sheng"},"565":{"code":"CN-TJ","name":"Tianjin Shi"},"566":{"code":"CN-XJ","name":"Xinjiang Uygur Zizhiqu"},"567":{"code":"CN-XZ","name":"Xizang Zizhiqu"},"568":{"code":"CN-YN","name":"Yunnan Sheng"},"569":{"code":"CN-ZJ","name":"Zhejiang Sheng"}}},"CO":{"name":"Colombia","regions":{"598":{"code":"CO-AMA","name":"Amazonas"},"599":{"code":"CO-ANT","name":"Antioquia"},"600":{"code":"CO-ARA","name":"Arauca"},"601":{"code":"CO-ATL","name":"Atl\u00e1ntico"},"602":{"code":"CO-BOL","name":"Bol\u00edvar"},"603":{"code":"CO-BOY","name":"Boyac\u00e1"},"604":{"code":"CO-CAL","name":"Caldas"},"605":{"code":"CO-CAQ","name":"Caquet\u00e1"},"606":{"code":"CO-CAS","name":"Casanare"},"607":{"code":"CO-CAU","name":"Cauca"},"608":{"code":"CO-CES","name":"Cesar"},"609":{"code":"CO-CHO","name":"Choc\u00f3"},"610":{"code":"CO-COR","name":"C\u00f3rdoba"},"611":{"code":"CO-CUN","name":"Cundinamarca"},"612":{"code":"CO-GUA","name":"Guain\u00eda"},"613":{"code":"CO-GUV","name":"Guaviare"},"614":{"code":"CO-HUL","name":"Huila"},"615":{"code":"CO-LAG","name":"La Guajira"},"616":{"code":"CO-MAG","name":"Magdalena"},"617":{"code":"CO-MET","name":"Meta"},"618":{"code":"CO-NAR","name":"Nari\u00f1o"},"619":{"code":"CO-NSA","name":"Norte de Santander"},"620":{"code":"CO-PUT","name":"Putumayo"},"621":{"code":"CO-QUI","name":"Quind\u00edo"},"622":{"code":"CO-RIS","name":"Risaralda"},"623":{"code":"CO-SAP","name":"San Andr\u00e9s y Providencia"},"624":{"code":"CO-SAN","name":"Santander"},"625":{"code":"CO-SUC","name":"Sucre"},"626":{"code":"CO-TOL","name":"Tolima"},"627":{"code":"CO-VAC","name":"Valle del Cauca"},"628":{"code":"CO-VAU","name":"Vaup\u00e9s"},"629":{"code":"CO-VID","name":"Vichada"}}},"CR":{"name":"Costa Rica","regions":{"1039":{"code":"CR-AL","name":"Alajuela"},"1040":{"code":"CR-CA","name":"Cartago"},"1042":{"code":"CR-GU","name":"Guanacaste"},"1041":{"code":"CR-HE","name":"Heredia"},"1044":{"code":"CR-LI","name":"Lim\u00f3n"},"1043":{"code":"CR-PU","name":"Puntarenas"},"1038":{"code":"CR-SJ","name":"San Jos\u00e9"}}},"CU":{"name":"Cuba"},"CV":{"name":"Cape Verde"},"CX":{"name":"Christmas Island"},"CY":{"name":"Cyprus"},"CZ":{"name":"Czechia","regions":{"1026":{"code":"CZ-31","name":"Jiho\u010desk\u00fd kraj"},"1034":{"code":"CZ-64","name":"Jihomoravsk\u00fd kraj"},"1028":{"code":"CZ-41","name":"Karlovarsk\u00fd kraj"},"1033":{"code":"CZ-63","name":"Kraj Vyso\u010dina"},"1031":{"code":"CZ-52","name":"Kr\u00e1lov\u00e9hradeck\u00fd kraj"},"1030":{"code":"CZ-51","name":"Libereck\u00fd kraj"},"1037":{"code":"CZ-80","name":"Moravskoslezsk\u00fd kraj"},"1035":{"code":"CZ-71","name":"Olomouck\u00fd kraj"},"1032":{"code":"CZ-53","name":"Pardubick\u00fd kraj"},"1027":{"code":"CZ-32","name":"Plze\u0148sk\u00fd kraj"},"1024":{"code":"CZ-10","name":"Praha, Hlavn\u00ed m\u011bsto"},"1025":{"code":"CZ-20","name":"St\u0159edo\u010desk\u00fd kraj"},"1029":{"code":"CZ-42","name":"\u00dasteck\u00fd kraj"},"1036":{"code":"CZ-72","name":"Zl\u00ednsk\u00fd kraj"}}},"DE":{"name":"Germany","regions":{"80":{"code":"BAW","name":"Baden-W\u00fcrttemberg"},"81":{"code":"BAY","name":"Bayern"},"82":{"code":"BER","name":"Berlin"},"83":{"code":"BRG","name":"Brandenburg"},"84":{"code":"BRE","name":"Bremen"},"85":{"code":"HAM","name":"Hamburg"},"86":{"code":"HES","name":"Hessen"},"87":{"code":"MEC","name":"Mecklenburg-Vorpommern"},"79":{"code":"NDS","name":"Niedersachsen"},"88":{"code":"NRW","name":"Nordrhein-Westfalen"},"89":{"code":"RHE","name":"Rheinland-Pfalz"},"90":{"code":"SAR","name":"Saarland"},"91":{"code":"SAS","name":"Sachsen"},"92":{"code":"SAC","name":"Sachsen-Anhalt"},"93":{"code":"SCN","name":"Schleswig-Holstein"},"94":{"code":"THE","name":"Th\u00fcringen"}}},"DJ":{"name":"Djibouti"},"DK":{"name":"Denmark","regions":{"824":{"code":"DK-84","name":"Hovedstaden"},"825":{"code":"DK-82","name":"Midtjylland"},"826":{"code":"DK-81","name":"Nordjylland"},"827":{"code":"DK-85","name":"Sj\u00e6lland"},"828":{"code":"DK-83","name":"Syddanmark"}}},"DM":{"name":"Dominica"},"DO":{"name":"Dominican Republic"},"DZ":{"name":"Algeria"},"EC":{"name":"Ecuador","regions":{"829":{"code":"EC-A","name":"Azuay"},"830":{"code":"EC-B","name":"Bol\u00edvar"},"831":{"code":"EC-F","name":"Ca\u00f1ar"},"832":{"code":"EC-C","name":"Carchi"},"833":{"code":"EC-H","name":"Chimborazo"},"834":{"code":"EC-X","name":"Cotopaxi"},"835":{"code":"EC-O","name":"El Oro"},"836":{"code":"EC-E","name":"Esmeraldas"},"837":{"code":"EC-W","name":"Gal\u00e1pagos"},"838":{"code":"EC-G","name":"Guayas"},"839":{"code":"EC-I","name":"Imbabura"},"840":{"code":"EC-L","name":"Loja"},"841":{"code":"EC-R","name":"Los R\u00edos"},"842":{"code":"EC-M","name":"Manab\u00ed"},"843":{"code":"EC-S","name":"Morona Santiago"},"844":{"code":"EC-N","name":"Napo"},"845":{"code":"EC-D","name":"Orellana"},"846":{"code":"EC-Y","name":"Pastaza"},"847":{"code":"EC-P","name":"Pichincha"},"848":{"code":"EC-SE","name":"Santa Elena"},"849":{"code":"EC-SD","name":"Santo Domingo de los Ts\u00e1chilas"},"850":{"code":"EC-U","name":"Sucumb\u00edos"},"851":{"code":"EC-T","name":"Tungurahua"},"852":{"code":"EC-Z","name":"Zamora Chinchipe"}}},"EE":{"name":"Estonia","regions":{"340":{"code":"EE-37","name":"Harjumaa"},"341":{"code":"EE-39","name":"Hiiumaa"},"342":{"code":"EE-44","name":"Ida-Virumaa"},"344":{"code":"EE-51","name":"J\u00e4rvamaa"},"343":{"code":"EE-49","name":"J\u00f5gevamaa"},"346":{"code":"EE-59","name":"L\u00e4\u00e4ne-Virumaa"},"345":{"code":"EE-57","name":"L\u00e4\u00e4nemaa"},"348":{"code":"EE-67","name":"P\u00e4rnumaa"},"347":{"code":"EE-65","name":"P\u00f5lvamaa"},"349":{"code":"EE-70","name":"Raplamaa"},"350":{"code":"EE-74","name":"Saaremaa"},"351":{"code":"EE-78","name":"Tartumaa"},"352":{"code":"EE-82","name":"Valgamaa"},"353":{"code":"EE-84","name":"Viljandimaa"},"354":{"code":"EE-86","name":"V\u00f5rumaa"}}},"EG":{"name":"Egypt"},"EH":{"name":"Western Sahara"},"ER":{"name":"Eritrea"},"ES":{"name":"Spain","regions":{"130":{"code":"A Coru\u0441a","name":"A Coru\u00f1a"},"131":{"code":"Alava","name":"Alava"},"132":{"code":"Albacete","name":"Albacete"},"133":{"code":"Alicante","name":"Alicante"},"134":{"code":"Almeria","name":"Almeria"},"135":{"code":"Asturias","name":"Asturias"},"136":{"code":"Avila","name":"Avila"},"137":{"code":"Badajoz","name":"Badajoz"},"138":{"code":"Baleares","name":"Baleares"},"139":{"code":"Barcelona","name":"Barcelona"},"140":{"code":"Burgos","name":"Burgos"},"141":{"code":"Caceres","name":"Caceres"},"142":{"code":"Cadiz","name":"Cadiz"},"143":{"code":"Cantabria","name":"Cantabria"},"144":{"code":"Castellon","name":"Castellon"},"145":{"code":"Ceuta","name":"Ceuta"},"146":{"code":"Ciudad Real","name":"Ciudad Real"},"147":{"code":"Cordoba","name":"Cordoba"},"148":{"code":"Cuenca","name":"Cuenca"},"149":{"code":"Girona","name":"Girona"},"150":{"code":"Granada","name":"Granada"},"151":{"code":"Guadalajara","name":"Guadalajara"},"152":{"code":"Guipuzcoa","name":"Guipuzcoa"},"153":{"code":"Huelva","name":"Huelva"},"154":{"code":"Huesca","name":"Huesca"},"155":{"code":"Jaen","name":"Jaen"},"156":{"code":"La Rioja","name":"La Rioja"},"157":{"code":"Las Palmas","name":"Las Palmas"},"158":{"code":"Leon","name":"Leon"},"159":{"code":"Lleida","name":"Lleida"},"160":{"code":"Lugo","name":"Lugo"},"161":{"code":"Madrid","name":"Madrid"},"162":{"code":"Malaga","name":"Malaga"},"163":{"code":"Melilla","name":"Melilla"},"164":{"code":"Murcia","name":"Murcia"},"165":{"code":"Navarra","name":"Navarra"},"166":{"code":"Ourense","name":"Ourense"},"167":{"code":"Palencia","name":"Palencia"},"168":{"code":"Pontevedra","name":"Pontevedra"},"169":{"code":"Salamanca","name":"Salamanca"},"170":{"code":"Santa Cruz de Tenerife","name":"Santa Cruz de Tenerife"},"171":{"code":"Segovia","name":"Segovia"},"172":{"code":"Sevilla","name":"Sevilla"},"173":{"code":"Soria","name":"Soria"},"174":{"code":"Tarragona","name":"Tarragona"},"175":{"code":"Teruel","name":"Teruel"},"176":{"code":"Toledo","name":"Toledo"},"177":{"code":"Valencia","name":"Valencia"},"178":{"code":"Valladolid","name":"Valladolid"},"179":{"code":"Vizcaya","name":"Vizcaya"},"180":{"code":"Zamora","name":"Zamora"},"181":{"code":"Zaragoza","name":"Zaragoza"}}},"ET":{"name":"Ethiopia"},"FI":{"name":"Finland","regions":{"339":{"code":"Ahvenanmaa","name":"Ahvenanmaa"},"333":{"code":"Etel\u00e4-Karjala","name":"Etel\u00e4-Karjala"},"326":{"code":"Etel\u00e4-Pohjanmaa","name":"Etel\u00e4-Pohjanmaa"},"325":{"code":"Etel\u00e4-Savo","name":"Etel\u00e4-Savo"},"337":{"code":"It\u00e4-Uusimaa","name":"It\u00e4-Uusimaa"},"322":{"code":"Kainuu","name":"Kainuu"},"335":{"code":"Kanta-H\u00e4me","name":"Kanta-H\u00e4me"},"330":{"code":"Keski-Pohjanmaa","name":"Keski-Pohjanmaa"},"331":{"code":"Keski-Suomi","name":"Keski-Suomi"},"338":{"code":"Kymenlaakso","name":"Kymenlaakso"},"320":{"code":"Lappi","name":"Lappi"},"334":{"code":"P\u00e4ij\u00e4t-H\u00e4me","name":"P\u00e4ij\u00e4t-H\u00e4me"},"328":{"code":"Pirkanmaa","name":"Pirkanmaa"},"327":{"code":"Pohjanmaa","name":"Pohjanmaa"},"323":{"code":"Pohjois-Karjala","name":"Pohjois-Karjala"},"321":{"code":"Pohjois-Pohjanmaa","name":"Pohjois-Pohjanmaa"},"324":{"code":"Pohjois-Savo","name":"Pohjois-Savo"},"329":{"code":"Satakunta","name":"Satakunta"},"336":{"code":"Uusimaa","name":"Uusimaa"},"332":{"code":"Varsinais-Suomi","name":"Varsinais-Suomi"}}},"FJ":{"name":"Fiji"},"FK":{"name":"Falkland Islands"},"FM":{"name":"Micronesia"},"FO":{"name":"Faroe Islands"},"FR":{"name":"France","regions":{"182":{"code":"1","name":"Ain"},"183":{"code":"2","name":"Aisne"},"184":{"code":"3","name":"Allier"},"185":{"code":"4","name":"Alpes-de-Haute-Provence"},"187":{"code":"6","name":"Alpes-Maritimes"},"188":{"code":"7","name":"Ard\u00e8che"},"189":{"code":"8","name":"Ardennes"},"190":{"code":"9","name":"Ari\u00e8ge"},"191":{"code":"10","name":"Aube"},"192":{"code":"11","name":"Aude"},"193":{"code":"12","name":"Aveyron"},"249":{"code":"67","name":"Bas-Rhin"},"194":{"code":"13","name":"Bouches-du-Rh\u00f4ne"},"195":{"code":"14","name":"Calvados"},"196":{"code":"15","name":"Cantal"},"197":{"code":"16","name":"Charente"},"198":{"code":"17","name":"Charente-Maritime"},"199":{"code":"18","name":"Cher"},"200":{"code":"19","name":"Corr\u00e8ze"},"201":{"code":"2A","name":"Corse-du-Sud"},"203":{"code":"21","name":"C\u00f4te-d'Or"},"204":{"code":"22","name":"C\u00f4tes-d'Armor"},"205":{"code":"23","name":"Creuse"},"261":{"code":"79","name":"Deux-S\u00e8vres"},"206":{"code":"24","name":"Dordogne"},"207":{"code":"25","name":"Doubs"},"208":{"code":"26","name":"Dr\u00f4me"},"273":{"code":"91","name":"Essonne"},"209":{"code":"27","name":"Eure"},"210":{"code":"28","name":"Eure-et-Loir"},"211":{"code":"29","name":"Finist\u00e8re"},"212":{"code":"30","name":"Gard"},"214":{"code":"32","name":"Gers"},"215":{"code":"33","name":"Gironde"},"250":{"code":"68","name":"Haut-Rhin"},"202":{"code":"2B","name":"Haute-Corse"},"213":{"code":"31","name":"Haute-Garonne"},"225":{"code":"43","name":"Haute-Loire"},"234":{"code":"52","name":"Haute-Marne"},"252":{"code":"70","name":"Haute-Sa\u00f4ne"},"256":{"code":"74","name":"Haute-Savoie"},"269":{"code":"87","name":"Haute-Vienne"},"186":{"code":"5","name":"Hautes-Alpes"},"247":{"code":"65","name":"Hautes-Pyr\u00e9n\u00e9es"},"274":{"code":"92","name":"Hauts-de-Seine"},"216":{"code":"34","name":"H\u00e9rault"},"217":{"code":"35","name":"Ille-et-Vilaine"},"218":{"code":"36","name":"Indre"},"219":{"code":"37","name":"Indre-et-Loire"},"220":{"code":"38","name":"Is\u00e8re"},"221":{"code":"39","name":"Jura"},"222":{"code":"40","name":"Landes"},"223":{"code":"41","name":"Loir-et-Cher"},"224":{"code":"42","name":"Loire"},"226":{"code":"44","name":"Loire-Atlantique"},"227":{"code":"45","name":"Loiret"},"228":{"code":"46","name":"Lot"},"229":{"code":"47","name":"Lot-et-Garonne"},"230":{"code":"48","name":"Loz\u00e8re"},"231":{"code":"49","name":"Maine-et-Loire"},"232":{"code":"50","name":"Manche"},"233":{"code":"51","name":"Marne"},"235":{"code":"53","name":"Mayenne"},"236":{"code":"54","name":"Meurthe-et-Moselle"},"237":{"code":"55","name":"Meuse"},"238":{"code":"56","name":"Morbihan"},"239":{"code":"57","name":"Moselle"},"240":{"code":"58","name":"Ni\u00e8vre"},"241":{"code":"59","name":"Nord"},"242":{"code":"60","name":"Oise"},"243":{"code":"61","name":"Orne"},"257":{"code":"75","name":"Paris"},"244":{"code":"62","name":"Pas-de-Calais"},"245":{"code":"63","name":"Puy-de-D\u00f4me"},"246":{"code":"64","name":"Pyr\u00e9n\u00e9es-Atlantiques"},"248":{"code":"66","name":"Pyr\u00e9n\u00e9es-Orientales"},"251":{"code":"69","name":"Rh\u00f4ne"},"253":{"code":"71","name":"Sa\u00f4ne-et-Loire"},"254":{"code":"72","name":"Sarthe"},"255":{"code":"73","name":"Savoie"},"259":{"code":"77","name":"Seine-et-Marne"},"258":{"code":"76","name":"Seine-Maritime"},"275":{"code":"93","name":"Seine-Saint-Denis"},"262":{"code":"80","name":"Somme"},"263":{"code":"81","name":"Tarn"},"264":{"code":"82","name":"Tarn-et-Garonne"},"272":{"code":"90","name":"Territoire-de-Belfort"},"277":{"code":"95","name":"Val-d'Oise"},"276":{"code":"94","name":"Val-de-Marne"},"265":{"code":"83","name":"Var"},"266":{"code":"84","name":"Vaucluse"},"267":{"code":"85","name":"Vend\u00e9e"},"268":{"code":"86","name":"Vienne"},"270":{"code":"88","name":"Vosges"},"271":{"code":"89","name":"Yonne"},"260":{"code":"78","name":"Yvelines"}}},"GA":{"name":"Gabon"},"GB":{"name":"United Kingdom"},"GD":{"name":"Grenada"},"GE":{"name":"Georgia"},"GF":{"name":"French Guiana"},"GG":{"name":"Guernsey"},"GH":{"name":"Ghana"},"GI":{"name":"Gibraltar"},"GL":{"name":"Greenland"},"GM":{"name":"Gambia"},"GN":{"name":"Guinea"},"GP":{"name":"Guadeloupe"},"GQ":{"name":"Equatorial Guinea"},"GR":{"name":"Greece","regions":{"866":{"code":"GR-69","name":"\u00c1gion \u00d3ros"},"853":{"code":"GR-A","name":"Anatolik\u00ed Makedon\u00eda kai Thr\u00e1ki"},"854":{"code":"GR-I","name":"Attik\u00ed"},"855":{"code":"GR-G","name":"Dytik\u00ed Ell\u00e1da"},"856":{"code":"GR-C","name":"Dytik\u00ed Makedon\u00eda"},"857":{"code":"GR-F","name":"Ion\u00eda N\u00edsia"},"858":{"code":"GR-D","name":"\u00cdpeiros"},"859":{"code":"GR-B","name":"Kentrik\u00ed Makedon\u00eda"},"860":{"code":"GR-M","name":"Kr\u00edti"},"861":{"code":"GR-L","name":"N\u00f3tio Aiga\u00edo"},"862":{"code":"GR-J","name":"Pelop\u00f3nnisos"},"863":{"code":"GR-H","name":"Stere\u00e1 Ell\u00e1da"},"864":{"code":"GR-E","name":"Thessal\u00eda"},"865":{"code":"GR-K","name":"V\u00f3reio Aiga\u00edo"}}},"GS":{"name":"South Georgia & South Sandwich Islands"},"GT":{"name":"Guatemala"},"GU":{"name":"Guam"},"GW":{"name":"Guinea-Bissau"},"GY":{"name":"Guyana","regions":{"867":{"code":"GY-BA","name":"Barima-Waini"},"868":{"code":"GY-CU","name":"Cuyuni-Mazaruni"},"869":{"code":"GY-DE","name":"Demerara-Mahaica"},"870":{"code":"GY-EB","name":"East Berbice-Corentyne"},"871":{"code":"GY-ES","name":"Essequibo Islands-West Demerara"},"872":{"code":"GY-MA","name":"Mahaica-Berbice"},"873":{"code":"GY-PM","name":"Pomeroon-Supenaam"},"874":{"code":"GY-PT","name":"Potaro-Siparuni"},"875":{"code":"GY-UD","name":"Upper Demerara-Berbice"},"876":{"code":"GY-UT","name":"Upper Takutu-Upper Essequibo"}}},"HK":{"name":"Hong Kong SAR China"},"HM":{"name":"Heard & McDonald Islands"},"HN":{"name":"Honduras"},"HR":{"name":"Croatia"},"HT":{"name":"Haiti"},"HU":{"name":"Hungary"},"ID":{"name":"Indonesia"},"IE":{"name":"Ireland"},"IL":{"name":"Israel"},"IM":{"name":"Isle of Man"},"IN":{"name":"India","regions":{"1072":{"code":"LA","name":"Ladakh"}}},"IO":{"name":"British Indian Ocean Territory"},"IQ":{"name":"Iraq"},"IR":{"name":"Iran"},"IS":{"name":"Iceland","regions":{"883":{"code":"IS-07","name":"Austurland"},"877":{"code":"IS-01","name":"H\u00f6fu\u00f0borgarsv\u00e6\u00f0i"},"882":{"code":"IS-06","name":"Nor\u00f0urland eystra"},"881":{"code":"IS-05","name":"Nor\u00f0urland vestra"},"884":{"code":"IS-08","name":"Su\u00f0urland"},"878":{"code":"IS-02","name":"Su\u00f0urnes"},"880":{"code":"IS-04","name":"Vestfir\u00f0ir"},"879":{"code":"IS-03","name":"Vesturland"}}},"IT":{"name":"Italy","regions":{"630":{"code":"AG","name":"Agrigento"},"631":{"code":"AL","name":"Alessandria"},"632":{"code":"AN","name":"Ancona"},"633":{"code":"AO","name":"Aosta"},"635":{"code":"AR","name":"Arezzo"},"636":{"code":"AP","name":"Ascoli-Piceno"},"637":{"code":"AT","name":"Asti"},"638":{"code":"AV","name":"Avellino"},"639":{"code":"BA","name":"Bari"},"640":{"code":"BT","name":"Barletta-Andria-Trani"},"641":{"code":"BL","name":"Belluno"},"642":{"code":"BN","name":"Benevento"},"643":{"code":"BG","name":"Bergamo"},"644":{"code":"BI","name":"Biella"},"645":{"code":"BO","name":"Bologna"},"646":{"code":"BZ","name":"Bolzano"},"647":{"code":"BS","name":"Brescia"},"648":{"code":"BR","name":"Brindisi"},"649":{"code":"CA","name":"Cagliari"},"650":{"code":"CL","name":"Caltanissetta"},"651":{"code":"CB","name":"Campobasso"},"652":{"code":"CI","name":"Carbonia Iglesias"},"653":{"code":"CE","name":"Caserta"},"654":{"code":"CT","name":"Catania"},"655":{"code":"CZ","name":"Catanzaro"},"656":{"code":"CH","name":"Chieti"},"657":{"code":"CO","name":"Como"},"658":{"code":"CS","name":"Cosenza"},"659":{"code":"CR","name":"Cremona"},"660":{"code":"KR","name":"Crotone"},"661":{"code":"CN","name":"Cuneo"},"662":{"code":"EN","name":"Enna"},"663":{"code":"FM","name":"Fermo"},"664":{"code":"FE","name":"Ferrara"},"665":{"code":"FI","name":"Firenze"},"666":{"code":"FG","name":"Foggia"},"667":{"code":"FC","name":"Forli-Cesena"},"668":{"code":"FR","name":"Frosinone"},"669":{"code":"GE","name":"Genova"},"670":{"code":"GO","name":"Gorizia"},"671":{"code":"GR","name":"Grosseto"},"672":{"code":"IM","name":"Imperia"},"673":{"code":"IS","name":"Isernia"},"634":{"code":"AQ","name":"L'Aquila"},"674":{"code":"SP","name":"La-Spezia"},"675":{"code":"LT","name":"Latina"},"676":{"code":"LE","name":"Lecce"},"677":{"code":"LC","name":"Lecco"},"678":{"code":"LI","name":"Livorno"},"679":{"code":"LO","name":"Lodi"},"680":{"code":"LU","name":"Lucca"},"681":{"code":"MC","name":"Macerata"},"682":{"code":"MN","name":"Mantova"},"683":{"code":"MS","name":"Massa-Carrara"},"684":{"code":"MT","name":"Matera"},"685":{"code":"VS","name":"Medio Campidano"},"686":{"code":"ME","name":"Messina"},"687":{"code":"MI","name":"Milano"},"688":{"code":"MO","name":"Modena"},"689":{"code":"MB","name":"Monza-Brianza"},"690":{"code":"NA","name":"Napoli"},"691":{"code":"NO","name":"Novara"},"692":{"code":"NU","name":"Nuoro"},"693":{"code":"OG","name":"Ogliastra"},"694":{"code":"OT","name":"Olbia Tempio"},"695":{"code":"OR","name":"Oristano"},"696":{"code":"PD","name":"Padova"},"697":{"code":"PA","name":"Palermo"},"698":{"code":"PR","name":"Parma"},"699":{"code":"PV","name":"Pavia"},"700":{"code":"PG","name":"Perugia"},"701":{"code":"PU","name":"Pesaro-Urbino"},"702":{"code":"PE","name":"Pescara"},"703":{"code":"PC","name":"Piacenza"},"704":{"code":"PI","name":"Pisa"},"705":{"code":"PT","name":"Pistoia"},"706":{"code":"PN","name":"Pordenone"},"707":{"code":"PZ","name":"Potenza"},"708":{"code":"PO","name":"Prato"},"709":{"code":"RG","name":"Ragusa"},"710":{"code":"RA","name":"Ravenna"},"711":{"code":"RC","name":"Reggio-Calabria"},"712":{"code":"RE","name":"Reggio-Emilia"},"713":{"code":"RI","name":"Rieti"},"714":{"code":"RN","name":"Rimini"},"715":{"code":"RM","name":"Roma"},"716":{"code":"RO","name":"Rovigo"},"717":{"code":"SA","name":"Salerno"},"718":{"code":"SS","name":"Sassari"},"719":{"code":"SV","name":"Savona"},"720":{"code":"SI","name":"Siena"},"721":{"code":"SR","name":"Siracusa"},"722":{"code":"SO","name":"Sondrio"},"723":{"code":"TA","name":"Taranto"},"724":{"code":"TE","name":"Teramo"},"725":{"code":"TR","name":"Terni"},"726":{"code":"TO","name":"Torino"},"727":{"code":"TP","name":"Trapani"},"728":{"code":"TN","name":"Trento"},"729":{"code":"TV","name":"Treviso"},"730":{"code":"TS","name":"Trieste"},"731":{"code":"UD","name":"Udine"},"732":{"code":"VA","name":"Varese"},"733":{"code":"VE","name":"Venezia"},"734":{"code":"VB","name":"Verbania"},"735":{"code":"VC","name":"Vercelli"},"736":{"code":"VR","name":"Verona"},"737":{"code":"VV","name":"Vibo-Valentia"},"738":{"code":"VI","name":"Vicenza"},"739":{"code":"VT","name":"Viterbo"}}},"JE":{"name":"Jersey"},"JM":{"name":"Jamaica"},"JO":{"name":"Jordan"},"JP":{"name":"Japan"},"KE":{"name":"Kenya"},"KG":{"name":"Kyrgyzstan"},"KH":{"name":"Cambodia"},"KI":{"name":"Kiribati"},"KM":{"name":"Comoros"},"KN":{"name":"St. Kitts & Nevis"},"KP":{"name":"North Korea"},"KR":{"name":"South Korea"},"KW":{"name":"Kuwait"},"KY":{"name":"Cayman Islands"},"KZ":{"name":"Kazakhstan"},"LA":{"name":"Laos"},"LB":{"name":"Lebanon"},"LC":{"name":"St. Lucia"},"LI":{"name":"Liechtenstein"},"LK":{"name":"Sri Lanka"},"LR":{"name":"Liberia"},"LS":{"name":"Lesotho"},"LT":{"name":"Lithuania","regions":{"475":{"code":"LT-AL","name":"Alytaus Apskritis"},"476":{"code":"LT-KU","name":"Kauno Apskritis"},"477":{"code":"LT-KL","name":"Klaip\u0117dos Apskritis"},"478":{"code":"LT-MR","name":"Marijampol\u0117s Apskritis"},"479":{"code":"LT-PN","name":"Panev\u0117\u017eio Apskritis"},"480":{"code":"LT-SA","name":"\u0160iauli\u0173 Apskritis"},"481":{"code":"LT-TA","name":"Taurag\u0117s Apskritis"},"482":{"code":"LT-TE","name":"Tel\u0161i\u0173 Apskritis"},"483":{"code":"LT-UT","name":"Utenos Apskritis"},"484":{"code":"LT-VL","name":"Vilniaus Apskritis"}}},"LU":{"name":"Luxembourg"},"LV":{"name":"Latvia","regions":{"471":{"code":"\u0100da\u017eu novads","name":"\u0100da\u017eu novads"},"366":{"code":"Aglonas novads","name":"Aglonas novads"},"367":{"code":"LV-AI","name":"Aizkraukles novads"},"368":{"code":"Aizputes novads","name":"Aizputes novads"},"369":{"code":"Akn\u012bstes novads","name":"Akn\u012bstes novads"},"370":{"code":"Alojas novads","name":"Alojas novads"},"371":{"code":"Alsungas novads","name":"Alsungas novads"},"372":{"code":"LV-AL","name":"Al\u016bksnes novads"},"373":{"code":"Amatas novads","name":"Amatas novads"},"374":{"code":"Apes novads","name":"Apes novads"},"375":{"code":"Auces novads","name":"Auces novads"},"376":{"code":"Bab\u012btes novads","name":"Bab\u012btes novads"},"377":{"code":"Baldones novads","name":"Baldones novads"},"378":{"code":"Baltinavas novads","name":"Baltinavas novads"},"379":{"code":"LV-BL","name":"Balvu novads"},"380":{"code":"LV-BU","name":"Bauskas novads"},"381":{"code":"Bever\u012bnas novads","name":"Bever\u012bnas novads"},"382":{"code":"Broc\u0113nu novads","name":"Broc\u0113nu novads"},"383":{"code":"Burtnieku novads","name":"Burtnieku novads"},"384":{"code":"Carnikavas novads","name":"Carnikavas novads"},"387":{"code":"LV-CE","name":"C\u0113su novads"},"385":{"code":"Cesvaines novads","name":"Cesvaines novads"},"386":{"code":"Ciblas novads","name":"Ciblas novads"},"388":{"code":"Dagdas novads","name":"Dagdas novads"},"355":{"code":"LV-DGV","name":"Daugavpils"},"389":{"code":"LV-DA","name":"Daugavpils novads"},"390":{"code":"LV-DO","name":"Dobeles novads"},"391":{"code":"Dundagas novads","name":"Dundagas novads"},"392":{"code":"Durbes novads","name":"Durbes novads"},"393":{"code":"Engures novads","name":"Engures novads"},"472":{"code":"\u0112rg\u013cu novads","name":"\u0112rg\u013cu novads"},"394":{"code":"Garkalnes novads","name":"Garkalnes novads"},"395":{"code":"Grobi\u0146as novads","name":"Grobi\u0146as novads"},"396":{"code":"LV-GU","name":"Gulbenes novads"},"397":{"code":"Iecavas novads","name":"Iecavas novads"},"398":{"code":"Ik\u0161\u0137iles novads","name":"Ik\u0161\u0137iles novads"},"399":{"code":"Il\u016bkstes novads","name":"Il\u016bkstes novads"},"400":{"code":"In\u010dukalna novads","name":"In\u010dukalna novads"},"401":{"code":"Jaunjelgavas novads","name":"Jaunjelgavas novads"},"402":{"code":"Jaunpiebalgas novads","name":"Jaunpiebalgas novads"},"403":{"code":"Jaunpils novads","name":"Jaunpils novads"},"357":{"code":"J\u0113kabpils","name":"J\u0113kabpils"},"405":{"code":"LV-JK","name":"J\u0113kabpils novads"},"356":{"code":"LV-JEL","name":"Jelgava"},"404":{"code":"LV-JL","name":"Jelgavas novads"},"358":{"code":"LV-JUR","name":"J\u016brmala"},"406":{"code":"Kandavas novads","name":"Kandavas novads"},"412":{"code":"K\u0101rsavas novads","name":"K\u0101rsavas novads"},"473":{"code":"\u0136eguma novads","name":"\u0136eguma novads"},"474":{"code":"\u0136ekavas novads","name":"\u0136ekavas novads"},"407":{"code":"Kokneses novads","name":"Kokneses novads"},"410":{"code":"LV-KR","name":"Kr\u0101slavas novads"},"408":{"code":"Krimuldas novads","name":"Krimuldas novads"},"409":{"code":"Krustpils novads","name":"Krustpils novads"},"411":{"code":"LV-KU","name":"Kuld\u012bgas novads"},"413":{"code":"Lielv\u0101rdes novads","name":"Lielv\u0101rdes novads"},"359":{"code":"LV-LPX","name":"Liep\u0101ja"},"360":{"code":"LV-LE","name":"Liep\u0101jas novads"},"417":{"code":"L\u012bgatnes novads","name":"L\u012bgatnes novads"},"414":{"code":"LV-LM","name":"Limba\u017eu novads"},"418":{"code":"L\u012bv\u0101nu novads","name":"L\u012bv\u0101nu novads"},"415":{"code":"Lub\u0101nas novads","name":"Lub\u0101nas novads"},"416":{"code":"LV-LU","name":"Ludzas novads"},"419":{"code":"LV-MA","name":"Madonas novads"},"421":{"code":"M\u0101lpils novads","name":"M\u0101lpils novads"},"422":{"code":"M\u0101rupes novads","name":"M\u0101rupes novads"},"420":{"code":"Mazsalacas novads","name":"Mazsalacas novads"},"423":{"code":"Nauk\u0161\u0113nu novads","name":"Nauk\u0161\u0113nu novads"},"424":{"code":"Neretas novads","name":"Neretas novads"},"425":{"code":"N\u012bcas novads","name":"N\u012bcas novads"},"426":{"code":"LV-OG","name":"Ogres novads"},"427":{"code":"Olaines novads","name":"Olaines novads"},"428":{"code":"Ozolnieku novads","name":"Ozolnieku novads"},"432":{"code":"P\u0101rgaujas novads","name":"P\u0101rgaujas novads"},"433":{"code":"P\u0101vilostas novads","name":"P\u0101vilostas novads"},"434":{"code":"P\u013cavi\u0146u novads","name":"P\u013cavi\u0146u novads"},"429":{"code":"LV-PR","name":"Prei\u013cu novads"},"430":{"code":"Priekules novads","name":"Priekules novads"},"431":{"code":"Prieku\u013cu novads","name":"Prieku\u013cu novads"},"435":{"code":"Raunas novads","name":"Raunas novads"},"361":{"code":"LV-REZ","name":"R\u0113zekne"},"442":{"code":"LV-RE","name":"R\u0113zeknes novads"},"436":{"code":"Riebi\u0146u novads","name":"Riebi\u0146u novads"},"362":{"code":"LV-RIX","name":"R\u012bga"},"363":{"code":"LV-RI","name":"R\u012bgas novads"},"437":{"code":"Rojas novads","name":"Rojas novads"},"438":{"code":"Ropa\u017eu novads","name":"Ropa\u017eu novads"},"439":{"code":"Rucavas novads","name":"Rucavas novads"},"440":{"code":"Rug\u0101ju novads","name":"Rug\u0101ju novads"},"443":{"code":"R\u016bjienas novads","name":"R\u016bjienas novads"},"441":{"code":"Rund\u0101les novads","name":"Rund\u0101les novads"},"444":{"code":"Salacgr\u012bvas novads","name":"Salacgr\u012bvas novads"},"445":{"code":"Salas novads","name":"Salas novads"},"446":{"code":"Salaspils novads","name":"Salaspils novads"},"447":{"code":"LV-SA","name":"Saldus novads"},"448":{"code":"Saulkrastu novads","name":"Saulkrastu novads"},"455":{"code":"S\u0113jas novads","name":"S\u0113jas novads"},"449":{"code":"Siguldas novads","name":"Siguldas novads"},"451":{"code":"Skr\u012bveru novads","name":"Skr\u012bveru novads"},"450":{"code":"Skrundas novads","name":"Skrundas novads"},"452":{"code":"Smiltenes novads","name":"Smiltenes novads"},"453":{"code":"Stopi\u0146u novads","name":"Stopi\u0146u novads"},"454":{"code":"Stren\u010du novads","name":"Stren\u010du novads"},"456":{"code":"LV-TA","name":"Talsu novads"},"458":{"code":"T\u0113rvetes novads","name":"T\u0113rvetes novads"},"457":{"code":"LV-TU","name":"Tukuma novads"},"459":{"code":"Vai\u0146odes novads","name":"Vai\u0146odes novads"},"460":{"code":"LV-VK","name":"Valkas novads"},"364":{"code":"Valmiera","name":"Valmiera"},"461":{"code":"LV-VM","name":"Valmieras novads"},"462":{"code":"Varak\u013c\u0101nu novads","name":"Varak\u013c\u0101nu novads"},"469":{"code":"V\u0101rkavas novads","name":"V\u0101rkavas novads"},"463":{"code":"Vecpiebalgas novads","name":"Vecpiebalgas novads"},"464":{"code":"Vecumnieku novads","name":"Vecumnieku novads"},"365":{"code":"LV-VEN","name":"Ventspils"},"465":{"code":"LV-VE","name":"Ventspils novads"},"466":{"code":"Vies\u012btes novads","name":"Vies\u012btes novads"},"467":{"code":"Vi\u013cakas novads","name":"Vi\u013cakas novads"},"468":{"code":"Vi\u013c\u0101nu novads","name":"Vi\u013c\u0101nu novads"},"470":{"code":"Zilupes novads","name":"Zilupes novads"}}},"LY":{"name":"Libya"},"MA":{"name":"Morocco"},"MC":{"name":"Monaco"},"MD":{"name":"Moldova"},"ME":{"name":"Montenegro"},"MF":{"name":"St. Martin"},"MG":{"name":"Madagascar"},"MH":{"name":"Marshall Islands"},"MK":{"name":"Macedonia"},"ML":{"name":"Mali"},"MM":{"name":"Myanmar (Burma)"},"MN":{"name":"Mongolia"},"MO":{"name":"Macau SAR China"},"MP":{"name":"Northern Mariana Islands"},"MQ":{"name":"Martinique"},"MR":{"name":"Mauritania"},"MS":{"name":"Montserrat"},"MT":{"name":"Malta"},"MU":{"name":"Mauritius"},"MV":{"name":"Maldives"},"MW":{"name":"Malawi"},"MX":{"name":"Mexico","regions":{"493":{"code":"AGU","name":"Aguascalientes"},"494":{"code":"BCN","name":"Baja California"},"495":{"code":"BCS","name":"Baja California Sur"},"496":{"code":"CAM","name":"Campeche"},"497":{"code":"CHP","name":"Chiapas"},"498":{"code":"CHH","name":"Chihuahua"},"499":{"code":"CMX","name":"Ciudad de M\u00e9xico"},"500":{"code":"COA","name":"Coahuila"},"501":{"code":"COL","name":"Colima"},"502":{"code":"DUR","name":"Durango"},"503":{"code":"MEX","name":"Estado de M\u00e9xico"},"504":{"code":"GUA","name":"Guanajuato"},"505":{"code":"GRO","name":"Guerrero"},"506":{"code":"HID","name":"Hidalgo"},"507":{"code":"JAL","name":"Jalisco"},"508":{"code":"MIC","name":"Michoac\u00e1n"},"509":{"code":"MOR","name":"Morelos"},"510":{"code":"NAY","name":"Nayarit"},"511":{"code":"NLE","name":"Nuevo Le\u00f3n"},"512":{"code":"OAX","name":"Oaxaca"},"513":{"code":"PUE","name":"Puebla"},"514":{"code":"QUE","name":"Quer\u00e9taro"},"515":{"code":"ROO","name":"Quintana Roo"},"516":{"code":"SLP","name":"San Luis Potos\u00ed"},"517":{"code":"SIN","name":"Sinaloa"},"518":{"code":"SON","name":"Sonora"},"519":{"code":"TAB","name":"Tabasco"},"520":{"code":"TAM","name":"Tamaulipas"},"521":{"code":"TLA","name":"Tlaxcala"},"522":{"code":"VER","name":"Veracruz"},"523":{"code":"YUC","name":"Yucat\u00e1n"},"524":{"code":"ZAC","name":"Zacatecas"}}},"MY":{"name":"Malaysia"},"MZ":{"name":"Mozambique"},"NA":{"name":"Namibia"},"NC":{"name":"New Caledonia"},"NE":{"name":"Niger"},"NF":{"name":"Norfolk Island"},"NG":{"name":"Nigeria"},"NI":{"name":"Nicaragua"},"NL":{"name":"Netherlands"},"NO":{"name":"Norway"},"NP":{"name":"Nepal"},"NR":{"name":"Nauru"},"NU":{"name":"Niue"},"NZ":{"name":"New Zealand"},"OM":{"name":"Oman"},"PA":{"name":"Panama"},"PE":{"name":"Peru","regions":{"904":{"code":"PE-AMA","name":"Amazonas"},"905":{"code":"PE-ANC","name":"Ancash"},"906":{"code":"PE-APU","name":"Apur\u00edmac"},"907":{"code":"PE-ARE","name":"Arequipa"},"908":{"code":"PE-AYA","name":"Ayacucho"},"909":{"code":"PE-CAJ","name":"Cajamarca"},"910":{"code":"PE-CUS","name":"Cusco"},"911":{"code":"PE-CAL","name":"El Callao"},"912":{"code":"PE-HUV","name":"Huancavelica"},"913":{"code":"PE-HUC","name":"Hu\u00e1nuco"},"914":{"code":"PE-ICA","name":"Ica"},"915":{"code":"PE-JUN","name":"Jun\u00edn"},"916":{"code":"PE-LAL","name":"La Libertad"},"917":{"code":"PE-LAM","name":"Lambayeque"},"918":{"code":"PE-LIM","name":"Lima"},"919":{"code":"PE-LOR","name":"Loreto"},"920":{"code":"PE-MDD","name":"Madre de Dios"},"921":{"code":"PE-MOQ","name":"Moquegua"},"903":{"code":"PE-LMA","name":"Municipalidad Metropolitana de Lima"},"922":{"code":"PE-PAS","name":"Pasco"},"923":{"code":"PE-PIU","name":"Piura"},"924":{"code":"PE-PUN","name":"Puno"},"925":{"code":"PE-SAM","name":"San Mart\u00edn"},"926":{"code":"PE-TAC","name":"Tacna"},"927":{"code":"PE-TUM","name":"Tumbes"},"928":{"code":"PE-UCA","name":"Ucayali"}}},"PF":{"name":"French Polynesia"},"PG":{"name":"Papua New Guinea"},"PH":{"name":"Philippines"},"PK":{"name":"Pakistan"},"PL":{"name":"Poland","regions":{"740":{"code":"PL-02","name":"dolno\u015bl\u0105skie"},"741":{"code":"PL-04","name":"kujawsko-pomorskie"},"742":{"code":"PL-06","name":"lubelskie"},"743":{"code":"PL-08","name":"lubuskie"},"746":{"code":"PL-14","name":"mazowieckie"},"745":{"code":"PL-12","name":"ma\u0142opolskie"},"747":{"code":"PL-16","name":"opolskie"},"748":{"code":"PL-18","name":"podkarpackie"},"749":{"code":"PL-20","name":"podlaskie"},"750":{"code":"PL-22","name":"pomorskie"},"751":{"code":"PL-24","name":"\u015bl\u0105skie"},"752":{"code":"PL-26","name":"\u015bwi\u0119tokrzyskie"},"753":{"code":"PL-28","name":"warmi\u0144sko-mazurskie"},"754":{"code":"PL-30","name":"wielkopolskie"},"755":{"code":"PL-32","name":"zachodniopomorskie"},"744":{"code":"PL-10","name":"\u0142\u00f3dzkie"}}},"PM":{"name":"St. Pierre & Miquelon"},"PN":{"name":"Pitcairn Islands"},"PR":{"name":"Puerto Rico"},"PS":{"name":"Palestinian Territories"},"PT":{"name":"Portugal","regions":{"929":{"code":"PT-01","name":"Aveiro"},"930":{"code":"PT-02","name":"Beja"},"931":{"code":"PT-03","name":"Braga"},"932":{"code":"PT-04","name":"Bragan\u00e7a"},"933":{"code":"PT-05","name":"Castelo Branco"},"934":{"code":"PT-06","name":"Coimbra"},"935":{"code":"PT-07","name":"\u00c9vora"},"936":{"code":"PT-08","name":"Faro"},"937":{"code":"PT-09","name":"Guarda"},"938":{"code":"PT-10","name":"Leiria"},"939":{"code":"PT-11","name":"Lisboa"},"940":{"code":"PT-12","name":"Portalegre"},"941":{"code":"PT-13","name":"Porto"},"948":{"code":"PT-30","name":"Regi\u00e3o Aut\u00f3noma da Madeira"},"947":{"code":"PT-20","name":"Regi\u00e3o Aut\u00f3noma dos A\u00e7ores"},"942":{"code":"PT-14","name":"Santar\u00e9m"},"943":{"code":"PT-15","name":"Set\u00fabal"},"944":{"code":"PT-16","name":"Viana do Castelo"},"945":{"code":"PT-17","name":"Vila Real"},"946":{"code":"PT-18","name":"Viseu"}}},"PW":{"name":"Palau"},"PY":{"name":"Paraguay","regions":{"886":{"code":"PY-16","name":"Alto Paraguay"},"887":{"code":"PY-10","name":"Alto Paran\u00e1"},"888":{"code":"PY-13","name":"Amambay"},"885":{"code":"PY-ASU","name":"Asunci\u00f3n"},"889":{"code":"PY-19","name":"Boquer\u00f3n"},"890":{"code":"PY-5","name":"Caaguaz\u00fa"},"891":{"code":"PY-6","name":"Caazap\u00e1"},"892":{"code":"PY-14","name":"Canindey\u00fa"},"893":{"code":"PY-11","name":"Central"},"894":{"code":"PY-1","name":"Concepci\u00f3n"},"895":{"code":"PY-3","name":"Cordillera"},"896":{"code":"PY-4","name":"Guair\u00e1"},"897":{"code":"PY-7","name":"Itap\u00faa"},"898":{"code":"PY-8","name":"Misiones"},"899":{"code":"PY-12","name":"\u00d1eembuc\u00fa"},"900":{"code":"PY-9","name":"Paraguar\u00ed"},"901":{"code":"PY-15","name":"Presidente Hayes"},"902":{"code":"PY-2","name":"San Pedro"}}},"QA":{"name":"Qatar"},"RE":{"name":"R\u00e9union"},"RO":{"name":"Romania","regions":{"278":{"code":"AB","name":"Alba"},"279":{"code":"AR","name":"Arad"},"280":{"code":"AG","name":"Arge\u015f"},"281":{"code":"BC","name":"Bac\u0103u"},"282":{"code":"BH","name":"Bihor"},"283":{"code":"BN","name":"Bistri\u0163a-N\u0103s\u0103ud"},"284":{"code":"BT","name":"Boto\u015fani"},"286":{"code":"BR","name":"Br\u0103ila"},"285":{"code":"BV","name":"Bra\u015fov"},"287":{"code":"B","name":"Bucure\u015fti"},"288":{"code":"BZ","name":"Buz\u0103u"},"290":{"code":"CL","name":"C\u0103l\u0103ra\u015fi"},"289":{"code":"CS","name":"Cara\u015f-Severin"},"291":{"code":"CJ","name":"Cluj"},"292":{"code":"CT","name":"Constan\u0163a"},"293":{"code":"CV","name":"Covasna"},"294":{"code":"DB","name":"D\u00e2mbovi\u0163a"},"295":{"code":"DJ","name":"Dolj"},"296":{"code":"GL","name":"Gala\u0163i"},"297":{"code":"GR","name":"Giurgiu"},"298":{"code":"GJ","name":"Gorj"},"299":{"code":"HR","name":"Harghita"},"300":{"code":"HD","name":"Hunedoara"},"301":{"code":"IL","name":"Ialomi\u0163a"},"302":{"code":"IS","name":"Ia\u015fi"},"303":{"code":"IF","name":"Ilfov"},"304":{"code":"MM","name":"Maramure\u015f"},"305":{"code":"MH","name":"Mehedin\u0163i"},"306":{"code":"MS","name":"Mure\u015f"},"307":{"code":"NT","name":"Neam\u0163"},"308":{"code":"OT","name":"Olt"},"309":{"code":"PH","name":"Prahova"},"311":{"code":"SJ","name":"S\u0103laj"},"310":{"code":"SM","name":"Satu-Mare"},"312":{"code":"SB","name":"Sibiu"},"313":{"code":"SV","name":"Suceava"},"314":{"code":"TR","name":"Teleorman"},"315":{"code":"TM","name":"Timi\u015f"},"316":{"code":"TL","name":"Tulcea"},"318":{"code":"VL","name":"V\u00e2lcea"},"317":{"code":"VS","name":"Vaslui"},"319":{"code":"VN","name":"Vrancea"}}},"RS":{"name":"Serbia"},"RU":{"name":"Russia"},"RW":{"name":"Rwanda"},"SA":{"name":"Saudi Arabia"},"SB":{"name":"Solomon Islands"},"SC":{"name":"Seychelles"},"SD":{"name":"Sudan"},"SE":{"name":"Sweden","regions":{"959":{"code":"SE-K","name":"Blekinge l\u00e4n"},"960":{"code":"SE-W","name":"Dalarnas l\u00e4n"},"962":{"code":"SE-X","name":"G\u00e4vleborgs l\u00e4n"},"961":{"code":"SE-I","name":"Gotlands l\u00e4n"},"963":{"code":"SE-N","name":"Hallands l\u00e4n"},"964":{"code":"SE-Z","name":"J\u00e4mtlands l\u00e4n"},"965":{"code":"SE-F","name":"J\u00f6nk\u00f6pings l\u00e4n"},"966":{"code":"SE-H","name":"Kalmar l\u00e4n"},"967":{"code":"SE-G","name":"Kronobergs l\u00e4n"},"968":{"code":"SE-BD","name":"Norrbottens l\u00e4n"},"978":{"code":"SE-T","name":"\u00d6rebro l\u00e4n"},"979":{"code":"SE-E","name":"\u00d6sterg\u00f6tlands l\u00e4n"},"969":{"code":"SE-M","name":"Sk\u00e5ne l\u00e4n"},"971":{"code":"SE-D","name":"S\u00f6dermanlands l\u00e4n"},"970":{"code":"SE-AB","name":"Stockholms l\u00e4n"},"972":{"code":"SE-C","name":"Uppsala l\u00e4n"},"973":{"code":"SE-S","name":"V\u00e4rmlands l\u00e4n"},"974":{"code":"SE-AC","name":"V\u00e4sterbottens l\u00e4n"},"975":{"code":"SE-Y","name":"V\u00e4sternorrlands l\u00e4n"},"976":{"code":"SE-U","name":"V\u00e4stmanlands l\u00e4n"},"977":{"code":"SE-O","name":"V\u00e4stra G\u00f6talands l\u00e4n"}}},"SG":{"name":"Singapore"},"SH":{"name":"St. Helena"},"SI":{"name":"Slovenia"},"SJ":{"name":"Svalbard & Jan Mayen"},"SK":{"name":"Slovakia"},"SL":{"name":"Sierra Leone"},"SM":{"name":"San Marino"},"SN":{"name":"Senegal"},"SO":{"name":"Somalia"},"SR":{"name":"Suriname","regions":{"949":{"code":"SR-BR","name":"Brokopondo"},"950":{"code":"SR-CM","name":"Commewijne"},"951":{"code":"SR-CR","name":"Coronie"},"952":{"code":"SR-MA","name":"Marowijne"},"953":{"code":"SR-NI","name":"Nickerie"},"954":{"code":"SR-PR","name":"Para"},"955":{"code":"SR-PM","name":"Paramaribo"},"956":{"code":"SR-SA","name":"Saramacca"},"957":{"code":"SR-SI","name":"Sipaliwini"},"958":{"code":"SR-WA","name":"Wanica"}}},"ST":{"name":"S\u00e3o Tom\u00e9 & Pr\u00edncipe"},"SV":{"name":"El Salvador"},"SY":{"name":"Syria"},"SZ":{"name":"Swaziland"},"TC":{"name":"Turks & Caicos Islands"},"TD":{"name":"Chad"},"TF":{"name":"French Southern Territories"},"TG":{"name":"Togo"},"TH":{"name":"Thailand"},"TJ":{"name":"Tajikistan"},"TK":{"name":"Tokelau"},"TL":{"name":"Timor-Leste"},"TM":{"name":"Turkmenistan"},"TN":{"name":"Tunisia"},"TO":{"name":"Tonga"},"TR":{"name":"Turkey"},"TT":{"name":"Trinidad & Tobago"},"TV":{"name":"Tuvalu"},"TW":{"name":"Taiwan"},"TZ":{"name":"Tanzania"},"UA":{"name":"Ukraine","regions":{"1069":{"code":"UA-43","name":"Avtonomna Respublika Krym"},"1045":{"code":"UA-71","name":"Cherkaska oblast"},"1046":{"code":"UA-74","name":"Chernihivska oblast"},"1047":{"code":"UA-77","name":"Chernivetska oblast"},"1048":{"code":"UA-12","name":"Dnipropetrovska oblast"},"1049":{"code":"UA-14","name":"Donetska oblast"},"1050":{"code":"UA-26","name":"Ivano-Frankivska oblast"},"1051":{"code":"UA-63","name":"Kharkivska oblast"},"1052":{"code":"UA-65","name":"Khersonska oblast"},"1053":{"code":"UA-68","name":"Khmelnytska oblast"},"1054":{"code":"UA-35","name":"Kirovohradska oblast"},"1070":{"code":"UA-30","name":"Kyiv"},"1055":{"code":"UA-32","name":"Kyivska oblast"},"1056":{"code":"UA-09","name":"Luhanska oblast"},"1057":{"code":"UA-46","name":"Lvivska oblast"},"1058":{"code":"UA-48","name":"Mykolaivska oblast"},"1059":{"code":"UA-51","name":"Odeska oblast"},"1060":{"code":"UA-53","name":"Poltavska oblast"},"1061":{"code":"UA-56","name":"Rivnenska oblast"},"1071":{"code":"UA-40","name":"Sevastopol"},"1062":{"code":"UA-59","name":"Sumska oblast"},"1063":{"code":"UA-61","name":"Ternopilska oblast"},"1064":{"code":"UA-05","name":"Vinnytska oblast"},"1065":{"code":"UA-07","name":"Volynska oblast"},"1066":{"code":"UA-21","name":"Zakarpatska oblast"},"1067":{"code":"UA-23","name":"Zaporizka oblast"},"1068":{"code":"UA-18","name":"Zhytomyrska oblast"}}},"UG":{"name":"Uganda"},"UM":{"name":"U.S. Outlying Islands"},"US":{"name":"United States","regions":{"1":{"code":"AL","name":"Alabama"},"2":{"code":"AK","name":"Alaska"},"3":{"code":"AS","name":"American Samoa"},"4":{"code":"AZ","name":"Arizona"},"5":{"code":"AR","name":"Arkansas"},"6":{"code":"AE","name":"Armed Forces Africa"},"7":{"code":"AA","name":"Armed Forces Americas"},"8":{"code":"AE","name":"Armed Forces Canada"},"9":{"code":"AE","name":"Armed Forces Europe"},"10":{"code":"AE","name":"Armed Forces Middle East"},"11":{"code":"AP","name":"Armed Forces Pacific"},"12":{"code":"CA","name":"California"},"13":{"code":"CO","name":"Colorado"},"14":{"code":"CT","name":"Connecticut"},"15":{"code":"DE","name":"Delaware"},"16":{"code":"DC","name":"District of Columbia"},"17":{"code":"FM","name":"Federated States Of Micronesia"},"18":{"code":"FL","name":"Florida"},"19":{"code":"GA","name":"Georgia"},"20":{"code":"GU","name":"Guam"},"21":{"code":"HI","name":"Hawaii"},"22":{"code":"ID","name":"Idaho"},"23":{"code":"IL","name":"Illinois"},"24":{"code":"IN","name":"Indiana"},"25":{"code":"IA","name":"Iowa"},"26":{"code":"KS","name":"Kansas"},"27":{"code":"KY","name":"Kentucky"},"28":{"code":"LA","name":"Louisiana"},"29":{"code":"ME","name":"Maine"},"30":{"code":"MH","name":"Marshall Islands"},"31":{"code":"MD","name":"Maryland"},"32":{"code":"MA","name":"Massachusetts"},"33":{"code":"MI","name":"Michigan"},"34":{"code":"MN","name":"Minnesota"},"35":{"code":"MS","name":"Mississippi"},"36":{"code":"MO","name":"Missouri"},"37":{"code":"MT","name":"Montana"},"38":{"code":"NE","name":"Nebraska"},"39":{"code":"NV","name":"Nevada"},"40":{"code":"NH","name":"New Hampshire"},"41":{"code":"NJ","name":"New Jersey"},"42":{"code":"NM","name":"New Mexico"},"43":{"code":"NY","name":"New York"},"44":{"code":"NC","name":"North Carolina"},"45":{"code":"ND","name":"North Dakota"},"46":{"code":"MP","name":"Northern Mariana Islands"},"47":{"code":"OH","name":"Ohio"},"48":{"code":"OK","name":"Oklahoma"},"49":{"code":"OR","name":"Oregon"},"50":{"code":"PW","name":"Palau"},"51":{"code":"PA","name":"Pennsylvania"},"52":{"code":"PR","name":"Puerto Rico"},"53":{"code":"RI","name":"Rhode Island"},"54":{"code":"SC","name":"South Carolina"},"55":{"code":"SD","name":"South Dakota"},"56":{"code":"TN","name":"Tennessee"},"57":{"code":"TX","name":"Texas"},"58":{"code":"UT","name":"Utah"},"59":{"code":"VT","name":"Vermont"},"60":{"code":"VI","name":"Virgin Islands"},"61":{"code":"VA","name":"Virginia"},"62":{"code":"WA","name":"Washington"},"63":{"code":"WV","name":"West Virginia"},"64":{"code":"WI","name":"Wisconsin"},"65":{"code":"WY","name":"Wyoming"}}},"UY":{"name":"Uruguay","regions":{"980":{"code":"UY-AR","name":"Artigas"},"981":{"code":"UY-CA","name":"Canelones"},"982":{"code":"UY-CL","name":"Cerro Largo"},"983":{"code":"UY-CO","name":"Colonia"},"984":{"code":"UY-DU","name":"Durazno"},"985":{"code":"UY-FS","name":"Flores"},"986":{"code":"UY-FD","name":"Florida"},"987":{"code":"UY-LA","name":"Lavalleja"},"988":{"code":"UY-MA","name":"Maldonado"},"989":{"code":"UY-MO","name":"Montevideo"},"990":{"code":"UY-PA","name":"Paysandu"},"991":{"code":"UY-RN","name":"R\u00edo Negro"},"992":{"code":"UY-RV","name":"Rivera"},"993":{"code":"UY-RO","name":"Rocha"},"994":{"code":"UY-SA","name":"Salto"},"995":{"code":"UY-SJ","name":"San Jos\u00e9"},"996":{"code":"UY-SO","name":"Soriano"},"997":{"code":"UY-TA","name":"Tacuaremb\u00f3"},"998":{"code":"UY-TT","name":"Treinta y Tres"}}},"UZ":{"name":"Uzbekistan"},"VA":{"name":"Vatican City"},"VC":{"name":"St. Vincent & Grenadines"},"VE":{"name":"Venezuela","regions":{"1001":{"code":"VE-Z","name":"Amazonas"},"1002":{"code":"VE-B","name":"Anzo\u00e1tegui"},"1003":{"code":"VE-C","name":"Apure"},"1004":{"code":"VE-D","name":"Aragua"},"1005":{"code":"VE-E","name":"Barinas"},"1006":{"code":"VE-F","name":"Bol\u00edvar"},"1007":{"code":"VE-G","name":"Carabobo"},"1008":{"code":"VE-H","name":"Cojedes"},"1009":{"code":"VE-Y","name":"Delta Amacuro"},"999":{"code":"VE-W","name":"Dependencias Federales"},"1000":{"code":"VE-A","name":"Distrito Capital"},"1010":{"code":"VE-I","name":"Falc\u00f3n"},"1011":{"code":"VE-J","name":"Gu\u00e1rico"},"1012":{"code":"VE-K","name":"Lara"},"1013":{"code":"VE-L","name":"M\u00e9rida"},"1014":{"code":"VE-M","name":"Miranda"},"1015":{"code":"VE-N","name":"Monagas"},"1016":{"code":"VE-O","name":"Nueva Esparta"},"1017":{"code":"VE-P","name":"Portuguesa"},"1018":{"code":"VE-R","name":"Sucre"},"1019":{"code":"VE-S","name":"T\u00e1chira"},"1020":{"code":"VE-T","name":"Trujillo"},"1021":{"code":"VE-X","name":"Vargas"},"1022":{"code":"VE-U","name":"Yaracuy"},"1023":{"code":"VE-V","name":"Zulia"}}},"VG":{"name":"British Virgin Islands"},"VI":{"name":"U.S. Virgin Islands"},"VN":{"name":"Vietnam"},"VU":{"name":"Vanuatu"},"WF":{"name":"Wallis & Futuna"},"WS":{"name":"Samoa"},"YE":{"name":"Yemen"},"YT":{"name":"Mayotte"},"ZA":{"name":"South Africa"},"ZM":{"name":"Zambia"},"ZW":{"name":"Zimbabwe"},"data_id":1781010631},"captcha":[],"wishlist":{"items":[]},"instant-purchase":[],"loggedAsCustomer":[],"multiplewishlist":[],"persistent":[],"review":[],"payments":[],"hyva_commerce_messages":[],"faq":[],"mwishlist":[],"ammessages":[],"hyva_enterprise":[],"gtm-checkout":[],"recently_viewed_product":[],"recently_compared_product":[],"product_data_storage":[],"paypal-billing-agreement":[],"paypal-buyer-country":[]}</script>
<script>
    window.processSectionDataBeforeDispatch && (window.processSectionDataBeforeDispatch = new Proxy(window.processSectionDataBeforeDispatch, {
        apply(target, thisArg, [data]) {
            data.hyva_commerce_messages = data.hyva_commerce_messages || {};
            return target.call(thisArg, data);
        }
    }));
</script>

<script>
    'use strict';

    function attributeIcon() {
        return {
            labelledById: '',

            init() {
                const timestamp = Date.now();
                const randomNum = Math.floor(Math.random() * 1000);
                this.labelledById = `amshopby-option-id-${timestamp}-${randomNum}`;
            }
        }
    }
    window.addEventListener(
        'alpine:init',
        () => Alpine.data('attributeIcon',attributeIcon),
        {once: true}
    );
</script>

<div x-data="amMessage" x-bind="eventListeners"></div>

<script>
    function amMessage() {
        let lastProcessedDataId = null;
        const processedMessageHashes = new Set();
        let debounceTimer;

        return {
            init() {
                this.processStoredMessages();

                window.addEventListener('beforeunload', () => {
                    processedMessageHashes.clear();
                    lastProcessedDataId = null;
                });
            },

            eventListeners: {
                ['@private-content-loaded.window'](event) {
                    const { ammessages } = event.detail.data;

                    clearTimeout(debounceTimer);
                    debounceTimer = setTimeout(() => {
                        if (ammessages?.data_id && ammessages.data_id === lastProcessedDataId) {
                            return;
                        }

                        lastProcessedDataId = ammessages?.data_id;

                        // Checking hash message
                        if (ammessages?.messages) {
                            const messageHash = JSON.stringify(ammessages.messages);
                            if (processedMessageHashes.has(messageHash)) {
                                return;
                            }
                            processedMessageHashes.add(messageHash);
                        }

                        const isCartPage = document.body.classList.contains('checkout-cart-index');
                        const isCheckoutPage = document.body.classList.contains('hyva_checkout-index-index');
                        const onePageSuccessPage = document.body.classList.contains('hyva_checkout_onepage_success');

                        if (!isCartPage && !isCheckoutPage && !onePageSuccessPage && ammessages?.messages) {
                            this.processMessages(ammessages.messages);
                        }
                    }, 500);
                },
                ['@am-promo:initialized.window']() {
                    this.processStoredMessages();
                },
                ['@am-promo-products-recollect.window']() {
                    this.processStoredMessages();
                }
            },

            processStoredMessages() {
                try {
                    const messages = JSON.parse(localStorage.getItem('amFreeGiftCartMessages'));
                    if (messages?.length) {
                        messages.forEach(message => dispatchMessages([message], 5000));
                        localStorage.removeItem('amFreeGiftCartMessages');
                    }
                } catch (e) {
                    console.error('Error processing stored messages:', e);
                }
            },

            processMessages(messages) {
                if (messages?.notice) {
                    this.handleNoticeMessage(messages.notice);
                }
            },

            handleNoticeMessage(notice) {
                if (!notice) return;
                dispatchMessages([{ type: notice.type, text: notice.text }]);
            }
        }
    }

    window.addEventListener(
        'alpine:init',
        () => Alpine.data(
            'amMessage',
            amMessage
        ),
        {once: true}
    );
</script>

<div x-data="initAffiliateJs"></div>

<script>
    function initAffiliateJs() {
        return {
            url:            'https://www.masterbooks.com/affiliate/event/click/',
            param:          'acc',
            cookieLifetime: 60,
            init() {
                let identifier = this.urlParam(this.param);
                let banner = this.urlParam('b');
                let currentDate = new Date();
                let sessionCookieName = 'affiliate';
                let referrerCookieName = 'affiliate_referrer';
                let referrer = '';
                let session = hyva.getCookie(sessionCookieName);

                if (!session) {
                    session = '' + Math.floor(currentDate.getTime() / 1000) + Math.floor(Math.random() * 10000001);
                }

                if (session && identifier) {
                    hyva.setCookie(sessionCookieName, session, this.cookieLifetime, false);
                    hyva.setCookie(sessionCookieName + '_identifier', identifier, this.cookieLifetime, false);

                    referrer = hyva.getCookie(referrerCookieName);
                    if (!referrer && document.referrer) {
                        if ((new URL(document.referrer)).hostname !== window.location.hostname) {
                            referrer = document.referrer;
                            hyva.setCookie(referrerCookieName, referrer, this.cookieLifetime, false);
                        }
                    }

                    let url = this.url
                        + '?rnd=' + Math.floor(Math.random() * 10000001)
                        + "&identifier=" + identifier
                        + "&session=" + session
                        + "&banner=" + banner
                        + "&referer=" + referrer;

                    fetch(url);
                }
            },
            urlParam(name) {
                let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
                if (results === null) {
                    return '';
                } else {
                    return results[1] || 0;
                }
            }
        }
    }

    window.addEventListener(
        'alpine:init',
        () => Alpine.data('initAffiliateJs', initAffiliateJs),
        {once: true}
    );
</script>
</div><script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    yireoGoogleTagManager2Pusher({"version":"3.10.7","page_type":"cms\/page\/view","page_path":"https:\/\/www.masterbooks.com\/knowledge-quest","page_title":"Knowledge Quest","virtual_page":"\/knowledge-quest","breadcrumb":[],"user":{"has_transacted":false}}, 'push (initial page) [data-layer.phtml]');
    </script>
<script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    function yireoGoogleTagManager2FindParentElementWithName(element, parentTagName) {
        if (!element.parentElement) {
            return null;
        }

        if (element.parentElement.tagName.toLowerCase() === parentTagName) {
            return element.parentElement;
        }

        return yireoGoogleTagManager2FindParentElementWithName(element.parentElement, parentTagName);
    }

    const products = document.querySelectorAll('.products\u0020a.product,\u0020.products\u0020a.product\u002Ditem\u002Dlink,\u0020.card\u0020a.product\u002Ditem\u002Dlink,\u0020.card\u0020a.product\u002Ditem\u002Dphoto,\u0020.card\u0020a.btn\u002Dprimary');
    if (products && products.length > 0) {
        products.forEach(function(product) {
            product.addEventListener('click', function(event, s) {
                let parentElement = yireoGoogleTagManager2FindParentElementWithName(event.target, 'form');
                if (!parentElement) {
                    return;
                }

                const inputElement = parentElement.querySelector('input[name="product"]');
                const productId = inputElement.value;
                const productData = window['YIREO_GOOGLETAGMANAGER2_PRODUCT_DATA_ID_' + productId] || {};
                productData.item_id = productId;

                const eventData = {
                    'event': 'select_item',
                    'ecommerce': {
                        'items': [productData]
                    }
                }

                yireoGoogleTagManager2Pusher(eventData, 'push (page event "select_item") [script-product-clicks.phtml]');

                if (window['YIREO_GOOGLETAGMANAGER2_DEBUG_CLICKS'] && confirm("Press to continue with redirect") === false) {
                    event.preventDefault();
                }
            });
        })
    }
</script>
<script nonce="OG9nYjlwejlham56Njl4NmI5ZXF0dDJ5cmY5YXQ1Mng=">
    window.addEventListener('private-content-loaded', function(event) {
        window.dataLayer = window.dataLayer || [];

        var isEmpty = function (variable) {
            if (typeof variable === 'undefined') {
                return true;
            }

            if (Array.isArray(variable) && variable.length === 0) {
                return true;
            }

            return typeof variable === 'object' && Object.keys(variable).length === 0;
        }

        var getSectionNames = function () {
            return ['cart', 'customer'];
        }

        getSectionNames().forEach(function (sectionName) {
            if (!event.detail.data[sectionName].gtm) {
                return;
            }

            const attributes = event.detail.data[sectionName].gtm;
            if (!Object.keys(attributes).length > 0) {
                return;
            }

            yireoGoogleTagManager2Pusher(attributes, 'push (attributes) [script-additions.phtml]');
        });

        let attributes = {};
        getSectionNames().forEach(function (sectionName) {
            if (!event.detail.data[sectionName].gtm_events) {
                return;
            }

            const gtmEvents = event.detail.data[sectionName].gtm_events;
            for (const [eventId, eventData] of Object.entries(gtmEvents)) {
                yireoGoogleTagManager2Logger('found event in section "' + sectionName + '"', eventData);

                const metaData = eventData.meta;
                yireoGoogleTagManager2Pusher(eventData, 'push (customerData "' + sectionName + '"  event "' + eventId + '")');

                if (!metaData || metaData.cacheable !== true) {
                    yireoGoogleTagManager2Logger('removing event "' + eventId + '" from section "' + sectionName + '"')

                    let mageCacheStorage = event.detail.data;

                    if (mageCacheStorage !== null
                        && typeof mageCacheStorage[sectionName] !== 'undefined'
                        && typeof mageCacheStorage[sectionName].gtm_events !== 'undefined'
                        && eventId in mageCacheStorage[sectionName].gtm_events) {
                        delete mageCacheStorage[sectionName].gtm_events[eventId];
                    }

                    window.localStorage.setItem('mage-cache-storage', JSON.stringify(mageCacheStorage));
                }
            }
        });

        if (false === isEmpty(attributes)) {
            yireoGoogleTagManager2Pusher(attributes, 'dataLayer (initial js) [script-additions.phtml]');
        }
    });

    window.addEventListener('toggle-cart', (event) => {
        if (!event.detail || !event.detail.isOpen) {
            return;
        }

        window.dispatchEvent(new CustomEvent('minicart_collapse'));
    });
</script>
</body>
</html>
