!function(e){"use strict";function n(n,t,i){"addEventListener"in e?n.addEventListener(t,i,!1):"attachEvent"in e&&n.attachEvent("on"+t,i)}function t(n,t,i){"removeEventListener"in e?n.removeEventListener(t,i,!1):"detachEvent"in e&&n.detachEvent("on"+t,i)}function i(){var n,t=["moz","webkit","o","ms"];for(n=0;n<t.length&&!j;n+=1)j=e[t[n]+"RequestAnimationFrame"];j||c("setup","RequestAnimationFrame not supported")}function o(n){var t="Host page: "+n;return e.top!==e.self&&(t=e.parentIFrame&&e.parentIFrame.getId?e.parentIFrame.getId()+": "+n:"Nested host page: "+n),t}function r(e){return S+"["+o(e)+"]"}function a(e){return B[e]?B[e].log:T}function c(e,n){s("log",e,n,a(e))}function u(e,n){s("info",e,n,a(e))}function f(e,n){s("warn",e,n,!0)}function s(n,t,i,o){!0===o&&"object"==typeof e.console&&console[n](r(t),i)}function l(i){function o(){function e(){y(X),h(Y)}a("Height"),a("Width"),v(e,X,"init")}function r(){var e=Q.substr(A).split(":");return{iframe:B[e[0]].iframe,id:e[0],height:e[1],width:e[2],type:e[3]}}function a(e){var n=Number(B[Y]["max"+e]),t=Number(B[Y]["min"+e]),i=e.toLowerCase(),o=Number(X[i]);c(Y,"Checking "+i+" is in range "+t+"-"+n),o<t&&(o=t,c(Y,"Set "+i+" to min value")),o>n&&(o=n,c(Y,"Set "+i+" to max value")),X[i]=""+o}function s(){function e(){function e(){var e=0,i=!1;for(c(Y,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===n){i=!0;break}return i}function i(){var e=B[Y].remoteHost;return c(Y,"Checking connection is from: "+e),n===e}return t.constructor===Array?e():i()}var n=i.origin,t=B[Y].checkOrigin;if(t&&""+n!="null"&&!e())throw new Error("Unexpected message received from: "+n+" for "+X.iframe.id+". Message was: "+i.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function l(){return S===(""+Q).substr(0,A)&&Q.substr(A).split(":")[0]in B}function F(){var e=X.type in{"true":1,"false":1,undefined:1};return e&&c(Y,"Ignoring init message from meta parent page"),e}function I(e){return Q.substr(Q.indexOf(":")+H+e)}function M(e){c(Y,"MessageCallback passed: {iframe: "+X.iframe.id+", message: "+e+"}"),j("messageCallback",{iframe:X.iframe,message:JSON.parse(e)}),c(Y,"--")}function z(){var n=document.body.getBoundingClientRect(),t=X.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(document.documentElement.clientHeight,e.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,e.innerWidth||0),offsetTop:parseInt(t.top-n.top,10),offsetLeft:parseInt(t.left-n.left,10),scrollTop:e.pageYOffset,scrollLeft:e.pageXOffset})}function E(e,n){function t(){w("Send Page Info","pageInfo:"+z(),e,n)}x(t,32)}function R(){function i(n,t){function i(){B[a]?E(B[a].iframe,a):o()}["scroll","resize"].forEach(function(o){c(a,n+o+" listener for sendPageInfo"),t(e,o,i)})}function o(){i("Remove ",t)}function r(){i("Add ",n)}var a=Y;r(),B[a].stopPageInfo=o}function C(){B[Y]&&B[Y].stopPageInfo&&(B[Y].stopPageInfo(),delete B[Y].stopPageInfo)}function O(){var e=!0;return null===X.iframe&&(f(Y,"IFrame ("+X.id+") not found"),e=!1),e}function N(e){var n=e.getBoundingClientRect();return g(Y),{x:Math.floor(Number(n.left)+Number(L.x)),y:Math.floor(Number(n.top)+Number(L.y))}}function T(n){function t(){L=a,P(),c(Y,"--")}function i(){return{x:Number(X.width)+r.x,y:Number(X.height)+r.y}}function o(){e.parentIFrame?e.parentIFrame["scrollTo"+(n?"Offset":"")](a.x,a.y):f(Y,"Unable to scroll to requested position, window.parentIFrame not found")}var r=n?N(X.iframe):{x:0,y:0},a=i();c(Y,"Reposition requested from iFrame (offset x:"+r.x+" y:"+r.y+")"),e.top!==e.self?o():t()}function P(){!1!==j("scrollCallback",L)?h(Y):p()}function W(n){function t(){var e=N(a);c(Y,"Moving to in page link (#"+o+") at x: "+e.x+" y: "+e.y),L={x:e.x,y:e.y},P(),c(Y,"--")}function i(){e.parentIFrame?e.parentIFrame.moveToAnchor(o):c(Y,"In page link #"+o+" not found and window.parentIFrame not found")}var o=n.split("#")[1]||"",r=decodeURIComponent(o),a=document.getElementById(r)||document.getElementsByName(r)[0];a?t():e.top!==e.self?i():c(Y,"In page link #"+o+" not found")}function j(e,n){return d(Y,e,n)}function q(){switch(B[Y].firstRun&&J(),X.type){case"close":m(X.iframe);break;case"message":M(I(6));break;case"scrollTo":T(!1);break;case"scrollToOffset":T(!0);break;case"pageInfo":E(B[Y].iframe,Y),R();break;case"pageInfoStop":C();break;case"inPageLink":W(I(9));break;case"reset":b(X);break;case"init":o(),j("initCallback",X.iframe),j("resizedCallback",X);break;default:o(),j("resizedCallback",X)}}function V(e){var n=!0;return B[e]||(n=!1,f(X.type+" No settings for "+e+". Message was: "+Q)),n}function D(){for(var e in B)w("iFrame requested init",k(e),document.getElementById(e),e)}function J(){B[Y].firstRun=!1}var Q=i.data,X={},Y=null;"[iFrameResizerChild]Ready"===Q?D():l()?(X=r(),Y=U=X.id,!F()&&V(Y)&&(c(Y,"Received: "+Q),O()&&s()&&q())):u(Y,"Ignored: "+Q)}function d(e,n,t){var i=null,o=null;if(B[e]){if(i=B[e][n],"function"!=typeof i)throw new TypeError(n+" on iFrame["+e+"] is not a function");o=i(t)}return o}function m(e){var n=e.id;c(n,"Removing iFrame: "+n),e.parentNode&&e.parentNode.removeChild(e),d(n,"closedCallback",n),c(n,"--"),delete B[n]}function g(n){null===L&&(L={x:void 0!==e.pageXOffset?e.pageXOffset:document.documentElement.scrollLeft,y:void 0!==e.pageYOffset?e.pageYOffset:document.documentElement.scrollTop},c(n,"Get page position: "+L.x+","+L.y))}function h(n){null!==L&&(e.scrollTo(L.x,L.y),c(n,"Set page position: "+L.x+","+L.y),p())}function p(){L=null}function b(e){function n(){y(e),w("reset","reset",e.iframe,e.id)}c(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),g(e.id),v(n,e,"reset")}function y(e){function n(n){e.iframe.style[n]=e[n]+"px",c(e.id,"IFrame ("+o+") "+n+" set to "+e[n]+"px")}function t(n){P||"0"!==e[n]||(P=!0,c(o,"Hidden iFrame detected, creating visibility listener"),I())}function i(e){n(e),t(e)}var o=e.iframe.id;B[o]&&(B[o].sizeHeight&&i("height"),B[o].sizeWidth&&i("width"))}function v(e,n,t){t!==n.type&&j?(c(n.id,"Requesting animation frame"),j(e)):e()}function w(e,n,t,i){function o(){var o=B[i].targetOrigin;c(i,"["+e+"] Sending msg to iframe["+i+"] ("+n+") targetOrigin: "+o),t.contentWindow.postMessage(S+n,o)}function r(){f(i,"["+e+"] IFrame("+i+") not found")}function a(){t&&"contentWindow"in t&&null!==t.contentWindow?o():r()}i=i||t.id,B[i]&&a()}function k(e){return e+":"+B[e].bodyMarginV1+":"+B[e].sizeWidth+":"+B[e].log+":"+B[e].interval+":"+B[e].enablePublicMethods+":"+B[e].autoResize+":"+B[e].bodyMargin+":"+B[e].heightCalculationMethod+":"+B[e].bodyBackground+":"+B[e].bodyPadding+":"+B[e].tolerance+":"+B[e].inPageLinks+":"+B[e].resizeFrom+":"+B[e].widthCalculationMethod}function F(e,t){function i(){function n(n){1/0!==B[F][n]&&0!==B[F][n]&&(e.style[n]=B[F][n]+"px",c(F,"Set "+n+" = "+B[F][n]+"px"))}function t(e){if(B[F]["min"+e]>B[F]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}t("Height"),t("Width"),n("maxHeight"),n("minHeight"),n("maxWidth"),n("minWidth")}function o(){var e=t&&t.id||D.id+N++;return null!==document.getElementById(e)&&(e+=N++),e}function r(n){return U=n,""===n&&(e.id=n=o(),T=(t||{}).log,U=n,c(n,"Added missing iframe ID: "+n+" ("+e.src+")")),n}function a(){switch(c(F,"IFrame scrolling "+(B[F].scrolling?"enabled":"disabled")+" for "+F),e.style.overflow=!1===B[F].scrolling?"hidden":"auto",B[F].scrolling){case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=B[F].scrolling}}function u(){"number"!=typeof B[F].bodyMargin&&"0"!==B[F].bodyMargin||(B[F].bodyMarginV1=B[F].bodyMargin,B[F].bodyMargin=""+B[F].bodyMargin+"px")}function s(){var n=B[F].firstRun,t=B[F].heightCalculationMethod in q;!n&&t&&b({iframe:e,height:0,width:0,type:"init"})}function l(){Function.prototype.bind&&(B[F].iframe.iFrameResizer={close:m.bind(null,B[F].iframe),resize:w.bind(null,"Window resize","resize",B[F].iframe),moveToAnchor:function(e){w("Move to anchor","moveToAnchor:"+e,B[F].iframe,F)},sendMessage:function(e){e=JSON.stringify(e),w("Send Message","message:"+e,B[F].iframe,F)}})}function d(t){function i(){w("iFrame.onload",t,e),s()}n(e,"load",i),w("init",t,e)}function g(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}function h(e){for(var n in D)D.hasOwnProperty(n)&&(B[F][n]=e.hasOwnProperty(n)?e[n]:D[n])}function p(e){return""===e||"file://"===e?"*":e}function y(n){n=n||{},B[F]={firstRun:!0,iframe:e,remoteHost:e.src.split("/").slice(0,3).join("/")},g(n),h(n),B[F].targetOrigin=!0===B[F].checkOrigin?p(B[F].remoteHost):"*"}function v(){return F in B&&"iFrameResizer"in e}var F=r(e.id);v()?f(F,"Ignored iFrame, already setup."):(y(t),a(),i(),u(),d(k(F)),l())}function x(e,n){null===V&&(V=setTimeout(function(){V=null,e()},n))}function I(){function n(){function e(e){function n(n){return"0px"===B[e].iframe.style[n]}function t(e){return null!==e.offsetParent}t(B[e].iframe)&&(n("height")||n("width"))&&w("Visibility change","resize",B[e].iframe,e)}for(var n in B)e(n)}function t(e){c("window","Mutation observed: "+e[0].target+" "+e[0].type),x(n,16)}function i(){var e=document.querySelector("body"),n={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},i=new o(t);i.observe(e,n)}var o=e.MutationObserver||e.WebKitMutationObserver;o&&i()}function M(e){function n(){E("Window "+e,"resize")}c("window","Trigger event: "+e),x(n,16)}function z(){function e(){E("Tab Visable","resize")}"hidden"!==document.visibilityState&&(c("document","Trigger event: Visiblity change"),x(e,16))}function E(e,n){function t(e){return"parent"===B[e].resizeFrom&&B[e].autoResize&&!B[e].firstRun}for(var i in B)t(i)&&w(e,n,document.getElementById(i),i)}function R(){n(e,"message",l),n(e,"resize",function(){M("resize")}),n(document,"visibilitychange",z),n(document,"-webkit-visibilitychange",z),n(e,"focusin",function(){M("focus")}),n(e,"focus",function(){M("focus")})}function C(){function e(e,n){function i(){if(!n.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==n.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+n.tagName+">")}n&&(i(),F(n,e),t.push(n))}function n(e){e&&e.enablePublicMethods&&f("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var t;return i(),R(),function(i,o){switch(t=[],n(i),typeof o){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(o||"iframe"),e.bind(void 0,i));break;case"object":e(i,o);break;default:throw new TypeError("Unexpected data type ("+typeof o+")")}return t}}function O(e){e.fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(e){function n(n,t){F(t,e)}return this.filter("iframe").each(n).end()}):u("","Unable to bind to jQuery, it is not fully loaded.")}var N=0,T=!1,P=!1,W="message",H=W.length,S="[iFrameSizer]",A=S.length,L=null,j=e.requestAnimationFrame,q={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},B={},V=null,U="Host Page",D={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){f("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};e.jQuery&&O(jQuery),"function"==typeof define&&define.amd?define([],C):"object"==typeof module&&"object"==typeof module.exports?module.exports=C():e.iFrameResize=e.iFrameResize||C()}(window||{});