// haup-dependency.js
(function() {
    if (typeof window.haup_apply_dependency !== 'function') {
        window.haup_apply_dependency = function(toggleId, targetSelector) {
            const toggle = document.getElementById(toggleId);
            const target = document.querySelector(targetSelector);

            if (!toggle || !target) return;

            const update = function() {
                const isEnabled = toggle.checked;
                target.style.opacity = isEnabled ? '1' : '0.4';
                target.style.pointerEvents = isEnabled ? 'auto' : 'none';
                target.style.filter = isEnabled ? 'none' : 'grayscale(100%)';
                target.style.transition = 'all 0.3s ease';
            };

            toggle.addEventListener('change', update);
            update();
        };
    }
})();