/* Help4 Builder Suite 1.3.316 | build e0bf22c8bac2c863f033078c97ae2049d42f0eab2d66bf4421fc207d92da6717 */
(function () {
    "use strict";

    function syncQuantityPolicy() {
        var toggle = document.querySelector("[data-h4bs-product-quantity-enabled]");
        var rules = document.querySelector("[data-h4bs-product-quantity-rules]");
        var enabled;
        if (!toggle || !rules) {
            return;
        }
        enabled = toggle.checked;
        rules.hidden = !enabled;
        rules.querySelectorAll("input, select").forEach(function (control) {
            control.disabled = !enabled;
        });
        toggle.setAttribute("aria-expanded", enabled ? "true" : "false");
    }

    function init() {
        var toggle = document.querySelector("[data-h4bs-product-quantity-enabled]");
        if (!toggle) {
            return;
        }
        toggle.addEventListener("change", syncQuantityPolicy);
        syncQuantityPolicy();
    }

    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", init, { once: true });
    } else {
        init();
    }
})();
