define(['jquery'],function($){'use strict';function scrollToTargetBlock(config,targetBlock){var stickyHeaderHeight,targetBlockTop;stickyHeaderHeight=$(config.stickyHeaderSelector).outerHeight();targetBlockTop=targetBlock.offset().top;$('html, body').animate({scrollTop:targetBlockTop-stickyHeaderHeight-80},150);} function scrollToTargetBlockPastHeader(config,targetBlock){if($(config.stickyHeaderSelector).css("position")==="fixed"){scrollToTargetBlock(config,targetBlock);}else{$('html, body').animate({scrollTop:$(config.headerSelector).outerHeight()},150,function(){scrollToTargetBlock(config,targetBlock);});}} function loadReviews(config){$.ajax({url:config.productReviewUrl,cache:true,dataType:'html',showLoader:false,loaderContext:$('.product.data.items'),customConfig:config,}).done(function(data){let customConfig=this.customConfig;$('#product-review-container').html(data).trigger('contentUpdated');$('[data-role="product-review"] .pages a').each(function(index,element){$(element).click(function(event){customConfig.productReviewUrl=$(element).attr('href') loadReviews(customConfig);scrollAnchor(customConfig);event.preventDefault();});});}).complete(function(){if(location.hash==="#reviews"||location.hash==="#review-form"){scrollToTargetBlock(config,$(location.hash));}});} function scrollAnchor(config){let anchor,targetBlock;let el=$('.product-info-main .reviews-actions a');if(el.length<=0){return;} anchor=$(el).attr('href').replace(/^.*?(#|$)/,'');targetBlock=$('#'+anchor);if(targetBlock.length){if((anchor==="reviews"||anchor==="review-form")&&!targetBlock.is(":visible")){$("[href=#reviews]").trigger('click');} scrollToTargetBlockPastHeader(config,targetBlock);}} return function(config){loadReviews(config);$(function(){$('.product-info-main .reviews-actions a').click(function(event){event.preventDefault();scrollAnchor(config);});});};});