jQuery(function($){if($('body').hasClass('page-view-solr-search-content')){$('.checkmark').click(function(e){console.log($(this).next());$(this).next().click();});jQuery('#block-contenttype .content .facet-item input').after('<span class="checkmark"></span>');jQuery('#block-exposedformsolr-search-contentpage-1 form input[type="text"]').after('<span class="search-icon-term"><svg width="24" height="24" viewBox="0 0 23 22" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="9.56818" cy="8.56818" r="6.56818" stroke="#7A8089" stroke-width="3"></circle><path d="M14.5898 13.5898L19.9989 18.9989" stroke="#7A8089" stroke-width="3" stroke-linecap="square"></path></svg></span>');var title=jQuery('#block-contenttype h2').text();jQuery('#block-contenttype h2').hide();jQuery('#block-contenttype .content').before('<div class="ac-filter"><button class="ilight">'+title+'<i class="fa-solid fa-angle-down"></i></button>');jQuery('#block-contenttype .content').hide();jQuery('#block-contenttype .ac-filter button').click(function(){if(jQuery('#block-contenttype .content').is(":hidden")){setTimeout(function()
{jQuery('#block-contenttype .content').slideDown();jQuery('#block-contenttype .content').addClass('active');jQuery('#block-contenttype .ac-filter i').addClass('fa-angle-up');jQuery('#block-contenttype .ac-filter i').removeClass('fa-angle-down');},100);}else{jQuery('#block-contenttype .content').slideUp();jQuery('#block-contenttype .ac-filter i').addClass('fa-angle-down');jQuery('#block-contenttype .ac-filter i').removeClass('fa-angle-up');}});jQuery('#block-company .content .facet-item input').after('<span class="checkmark"></span>');var title=jQuery('#block-company h2').text();jQuery('#block-company h2').hide();jQuery('#block-company .content').before('<div class="ac-filter"><button class="ilight">'+title+'<i class="fa-solid fa-angle-down"></i></button>');jQuery('#block-company .content').hide();jQuery('#block-company .ac-filter button').click(function(){if(jQuery('#block-company .content').is(":hidden")){setTimeout(function()
{jQuery('#block-company .content').slideDown();jQuery('#block-company .content').addClass('active');jQuery('#block-company .ac-filter i').addClass('fa-angle-up');jQuery('#block-company .ac-filter i').removeClass('fa-angle-down');},100);}else{jQuery('#block-company .content').slideUp();jQuery('#block-company .ac-filter i').addClass('fa-angle-down');jQuery('#block-company .ac-filter i').removeClass('fa-angle-up');}});jQuery('#block-category .content .facet-item input').after('<span class="checkmark"></span>');var title=jQuery('#block-category h2').text();jQuery('#block-category h2').hide();jQuery('#block-category .content').before('<div class="ac-filter"><button class="ilight">'+title+'<i class="fa-solid fa-angle-down"></i></button>');jQuery('#block-category .content').hide();jQuery('#block-category .ac-filter button').click(function(){if(jQuery('#block-category .content').is(":hidden")){setTimeout(function()
{jQuery('#block-category .content').slideDown();jQuery('#block-category .content').addClass('active');jQuery('#block-category .ac-filter i').addClass('fa-angle-up');jQuery('#block-category .ac-filter i').removeClass('fa-angle-down');},100);}else{jQuery('#block-category .content').slideUp();jQuery('#block-category .ac-filter i').addClass('fa-angle-down');jQuery('#block-category .ac-filter i').removeClass('fa-angle-up');}});jQuery('#block-authoredon .content .facet-item input').after('<span class="checkmark"></span>');var title=jQuery('#block-authoredon h2').text();jQuery('#block-authoredon h2').hide();jQuery('#block-authoredon .content').before('<div class="ac-filter"><button class="ilight">'+title+'<i class="fa-solid fa-angle-down"></i></button>');jQuery('#block-authoredon .content').hide();jQuery('#block-authoredon .ac-filter button').click(function(){if(jQuery('#block-authoredon .content').is(":hidden")){setTimeout(function()
{jQuery('#block-authoredon .content').slideDown();jQuery('#block-authoredon .content').addClass('active');jQuery('#block-authoredon .ac-filter i').addClass('fa-angle-up');jQuery('#block-authoredon .ac-filter i').removeClass('fa-angle-down');},100);}else{jQuery('#block-authoredon .content').slideUp();jQuery('#block-authoredon .ac-filter i').addClass('fa-angle-down');jQuery('#block-authoredon .ac-filter i').removeClass('fa-angle-up');}});}
$('.c-sempra-blocks__custom-block select').select2({theme:"paper"});let c=1;setTimeout(function(){let $typeSelect=$('.container-ml .ml-type');const urlParams=new URLSearchParams(window.location.search);let $container=$('.container-ml');if(urlParams.has('current-page')||urlParams.has('type')){if($container.length){$([document.documentElement,document.body]).animate({scrollTop:$container.offset().top-200,},1000);}}
$('.container-ml select').on('change',function(e){const params=new URLSearchParams(window.location.search);if(params.has('current-page')){params.delete('current-page');}
if($typeSelect.val()){params.set('type',$typeSelect.val());}else if(params.has('type')){params.delete('type');}
window.location.href=`${window.location.pathname}?${params.toString()}`;});$('.c-sempra-blocks__outer-wrapper .container-ml .grid-item').each(function(){$(this).addClass('lightbox-open'+c);c++;});c=1;$('.lightbox-item').each(function(){$(this).addClass('lightbox-open'+c);c++;});$('.c-sempra-blocks__outer-wrapper .container-ml .grid-item .ml-thumbnail, .c-sempra-blocks__outer-wrapper .container-ml .grid-item .ml-link').click(function(){var lightbox=$(this).parent().attr("class").match(/lightbox-open[\w-]*\b/);$('.ml-lightbox').fadeIn("slow",function(){});$('.lightbox-item').hide();$('.ml-lightbox-container .'+lightbox[0]).addClass('open');$('.ml-lightbox-container .'+lightbox[0]).fadeIn("slow",function(){});});$('.c-sempra-blocks__outer-wrapper .ml-lightbox-close').click(function(){$('.ml-lightbox .lightbox-item').removeClass('open');$('.ml-lightbox').fadeOut("slow",function(){});$('.lightbox-item').fadeOut("slow",function(){});});$(".ml-lightbox").click(function(e){if(e.target!==e.currentTarget)return;$('.ml-lightbox-close').click();});$(document).on('keydown',function(event){if(event.key=="Escape"){$('.ml-lightbox-close').click();}});window.addEventListener("keydown",function(event){if($('.ml-lightbox .lightbox-item.open').length>0){if(event.defaultPrevented){return;}
let lightboxPos=$('.ml-lightbox .lightbox-item.open').attr("class").match(/\d+/);var position=parseInt(lightboxPos[0]);switch(event.key){case "Left":case "ArrowLeft":position=position-1;if(position<1){position=$('.ml-lightbox .lightbox-item').length;}
$('.ml-lightbox-close').click();setTimeout(function(){$('.ml-lightbox').fadeIn("slow",function(){});$('.ml-lightbox .lightbox-item').hide();$('.ml-lightbox-container .lightbox-open'+position).addClass('open');$('.ml-lightbox-container .lightbox-open'+position).fadeIn("slow",function(){});$('.ml-lightbox').scrollTop(0);},200);break;case "Right":case "ArrowRight":position=position+1;if(position>$('.lightbox-item').length){position=1;}
$('.ml-lightbox-close').click();setTimeout(function(){$('.ml-lightbox').fadeIn("slow",function(){});$('.ml-lightbox .lightbox-item').hide();$('.ml-lightbox-container .lightbox-open'+position).addClass('open');$('.ml-lightbox-container .lightbox-open'+position).fadeIn("slow",function(){});$('.ml-lightbox').scrollTop(0);},200);break;default:return;}
event.preventDefault();}},true);let $items=$('.container-ml .grid-item');let currentPage=1;let itemsCount=$items.length;let totalPages=1;let perPage=6;let scrollLoad=true;if(itemsCount>0){totalPages=Math.ceil(itemsCount/perPage);if(totalPages<1){totalPages=1;}}
$(window).scroll(function(){let $element=$('.c-sempra-blocks__footer-outer-wrapper');if(scrollLoad&&$(this).scrollTop()>=$(document).height()-$(this).height()-($element.height()/2)){if(currentPage<totalPages){scrollLoad=false;$('.container-ml').toggleClass('loading');setTimeout(function(){let startPaging=(currentPage)*perPage;let endPaging=startPaging+perPage;$items.slice(startPaging,endPaging).fadeIn();currentPage++;$('.container-ml').toggleClass('loading');scrollLoad=true;},1000);}}});},500);});