(function ($) {
	const ninodemModules = {
		init: function () {
			// Wrap .module items into .modules-inner and init ninodemSlick
			const $modules = $('.modules');
			$modules.toggleClass('alignwide alignfull is-layout-flex');
			$modules.children('.module').wrap('<div class="module-wrapper"></div>');
			const $modulesInner = $('<div class="modules-inner"></div>')
				.append($modules.children('.module-wrapper'));
			$modules.append($modulesInner);

			// Initialize ninodemSlick
			$('.modules-inner').ninodemSlick({
				infinite: false,
				slidesToShow: 4,
				slidesToScroll: 1,
				adaptiveHeight: true,
				overflow: 0.457831325,
				responsive: [
					{
						breakpoint: 1200,
						settings: {
							slidesToShow: 3,
							overflow: 0.2,
						}
					},
					{
						breakpoint: 992,
						settings: {
							slidesToShow: 2,
							overflow: 0.201183432,
						}
					},
					{
						breakpoint: 768,
						settings: {
							slidesToShow: 1,
							overflow: 0.0976443769,
						}
					},
				]
			});
		}
	};

	ninodemModules.init();
})(jQuery);
