( function( api ) {

	// Extends our custom "ecology-nature" section.
	api.sectionConstructor['ecology-nature'] = api.Section.extend( {

		// No events for this type of section.
		attachEvents: function () {},

		// Always make the section active.
		isContextuallyActive: function () {
			return true;
		}
	} );

} )( wp.customize );

// Override querySelector to handle Kirki's invalid selectors
(function() {
	const originalQuerySelector = document.querySelector;
	const originalQuerySelectorAll = document.querySelectorAll;

	document.querySelector = function(selector) {
		try {
			return originalQuerySelector.call(this, selector);
		} catch (e) {
			if (e instanceof DOMException && e.name === 'SyntaxError') {
				return null;
			}
			throw e;
		}
	};

	document.querySelectorAll = function(selector) {
		try {
			return originalQuerySelectorAll.call(this, selector);
		} catch (e) {
			if (e instanceof DOMException && e.name === 'SyntaxError') {
				return [];
			}
			throw e;
		}
	};
})();