define(['jquery','domReady','consoleLogger','Magento_PageCache/js/form-key-provider','jquery-ui-modules/widget','mage/cookies'],function($,domReady,consoleLogger,formKeyInit){'use strict';function generateRandomString(chars,length){var result='';length=length>0?length:1;while(length--){result+=chars[Math.round(Math.random()*(chars.length-1))];} return result;} $.fn.comments=function(){var elements=[],contents,elementContents;(function lookup(element){var iframeHostName;if($(element).prop('tagName')==='IFRAME'){iframeHostName=$('').prop('href',$(element).prop('src')).prop('hostname');if(window.location.hostname!==iframeHostName){return[];}} contents=function(elem){return $.map(elem,function(el){try{return el.nodeName.toLowerCase()==='iframe'?el.contentDocument||(el.contentWindow?el.contentWindow.document:[]):$.merge([],el.childNodes);}catch(e){consoleLogger.error(e);return[];}});};elementContents=contents($(element));$.each(elementContents,function(index,el){switch(el.nodeType){case 1:lookup(el);break;case 8:elements.push(el);break;case 9:lookup($(el).find('body'));break;}});})(this);return elements;};$.widget('mage.formKey',{options:{inputSelector:'input[name="form_key"]',allowedCharacters:'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',length:16},_create:function(){var formKey=$.mage.cookies.get('form_key'),options={secure:window.cookiesConfig?window.cookiesConfig.secure:false};if(!formKey){formKey=generateRandomString(this.options.allowedCharacters,this.options.length);$.mage.cookies.set('form_key',formKey,options);} $(this.options.inputSelector).val(formKey);}});$.widget('mage.pageCache',{options:{url:'/',patternPlaceholderOpen:/^ BLOCK (.+) $/,patternPlaceholderClose:/^ \/BLOCK (.+) $/,versionCookieName:'private_content_version',handles:[]},_create:function(){var placeholders,version=$.mage.cookies.get(this.options.versionCookieName);if(!version){return;} placeholders=this._searchPlaceholders(this.element.comments());if(placeholders&&placeholders.length){this._ajax(placeholders,version);}},_searchPlaceholders:function(elements){var placeholders=[],tmp={},ii,len,el,matches,name;if(!(elements&&elements.length)){return placeholders;} for(ii=0,len=elements.length;ii