;(function($){"use strict";ips.controller.register('cms.front.external.communication',{_blockID:'',_widgetID:'',initialize:function(){this.on(window,'message',this.windowMessage);this.on('click','a',this.clickLink);this.setup();},setup:function(){var self=this;var url=ips.utils.url.getURIObject();this._blockID=url.queryKey.blockid;this._widgetID=url.queryKey.widgetid;this._send('iframeReady');this._sendHeight();setInterval(this._sendHeight.bind(this),500);},windowMessage:function(e){try{var pmData=JSON.parse(e.originalEvent.data);var method=pmData.method;}catch(err){return;}
if(pmData.widgetID===undefined||pmData.widgetID!==this._widgetID){return;}
if(method&&this[method]!==undefined){this[method].call(this,pmData);}},probedStyles:function(data){var elem=$('<style/>').attr('type','text/css').appendTo('head');var stylesheet="				body {					font-family: "+data.font+"; 					color: "+data.text+";				}								a {					color: "+data.link+";				}			";elem.text(stylesheet);},clickLink:function(e){var link=$(e.currentTarget);var href=link.attr('href');if(href.startsWith('#')){return;}
e.preventDefault();this._send('goToLink',{link:href});},_sendHeight:function(){var currentSize=$('body').outerHeight();this._send('iframeSize',{size:currentSize});},_send:function(method,data){var output=JSON.stringify(Object.assign(data||{},{method:method,widgetID:this._widgetID,blockID:this._blockID}));window.top.postMessage(output,'*');}});}(jQuery));;