UNPKG

@iframe-resizer/child

Version:

Keep iframes sized to their content.

21 lines (18 loc) 26 kB
/*! * @preserve * * @module iframe-resizer/child 5.5.1 (esm) - 2025-08-01 * * @license GPL-3.0 for non-commercial use only. * For commercial use, you must purchase a license from * https://iframe-resizer.com/pricing * * @description Keep same and cross domain iFrames sized to their content * * @author David J. Bradshaw <info@iframe-resizer.com> * * @see {@link https://iframe-resizer.com} * * @copyright (c) 2013 - 2025, David J. Bradshaw. All rights reserved. */ import e,{NORMAL as t,HIGHLIGHT as n,FOREGROUND as o,ITALIC as r,BOLD as i}from"auto-console-group";const a="5.5.1",s="iframeResizer",l=10,c="data-iframe-size",u="data-iframe-overflowed",d="data-iframe-ignore",f="bottom",m="right",p="autoResizeEnabled",h=Symbol("sizeChanged"),y="manualResize",g={},b="setOffsetSize",v="resizeObserver",z="overflowObserver",w="mutationObserver",$="visibilityObserver",S="none",O="init",M=(e,t,n,o)=>e.addEventListener(t,n,o||!1),E=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},j=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),T=["spjluzl","rlf","clyzpvu"],k=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],I=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],A=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),x=e=>j(k[e]),N=e=>{const t=e[j(T[0])]||e[j(T[1])]||e[j(T[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=E(j(e));return n in A&&(t=A[n]),t}(n[0]);return 0===o||(e=>e[2]===E(e[0]+e[1]))(n)||(o=-2),o},P=(e,...t)=>setTimeout(()=>e(...t),0),C=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},R=e=>e,B=e=>Math.round(1e3*e)/1e3,q=e=>e.charAt(0).toUpperCase()+e.slice(1),L=e=>""!=`${e}`&&void 0!==e;const W=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${q(t)}`)};let D=!0,F=s;var V;const H=(V=e,V?.__esModule?V.default:V)({label:`${s}(child)`});var U;const Z=(U="log",(...e)=>!D||H[U](...e));const{assert:J,debug:_,endAutoGroup:Q,error:Y,errorBoundary:G,event:X,label:K,purge:ee,warn:te}=H,ne=e=>{return H.warn((t=R,e=>window.chrome?t(e.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):t(e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(e));var t},oe=ne,re=(e=>(t,n="renamed to")=>(o,r,i="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${i}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>ne(t)),ie=re("Method"),ae=re("Method","replaced with"),se=re("Option"),le=["min-height","min-width","max-height","max-width"],ce=new Set,ue=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),de=(e,t)=>{return(n=ue(e,t))&&"0px"!==n&&"auto"!==n&&"none"!==n;var n};function fe({href:e}){ce.has(e)||ce.add(e)}const me=(e,t)=>function(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const e=o.style[t];if(e)return{source:"STYLE"===n.ownerNode.tagName?"an inline <style> block":`stylesheet (${n.href})`,value:e}}}catch(e){fe(n)}return{source:"cross-origin stylesheet",value:ue(e,t)}}(e,t),pe=(e,t)=>{const{source:n,value:o}=me(e,t),r=(e=>e.tagName?e.tagName.toLowerCase():"unknown")(e);ne(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.\n\nIf you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function he(){for(const e of[document.documentElement,document.body])for(const t of le)de(e,t)&&pe(e,t)}const ye=e=>t=>void 0===t?void 0:e(t),ge=ye(e=>"true"===e),be=ye(Number),ve=new Set,ze=new Set,we=[];let $e,Se=1,Oe=!1,Me=0;const Ee=e=>{for(const t of e){const{addedNodes:e,removedNodes:n}=t;for(const t of e)ve.add(t);for(const e of n)ve.has(e)?ve.delete(e):ze.add(e)}};function je(e){we.push(e),Oe||(Me=performance.now(),Oe=!0,requestAnimationFrame($e))}function Te(e){const t=new window.MutationObserver(je),r=document.querySelector("body"),i={attributes:!0,attributeFilter:[d,c],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return $e=(e=>()=>{const t=performance.now(),r=t-Me,i=16*Se+++2;if(r>i&&r<200)return X("MutationDelay"),Z("Update delayed due to heavy workload on the callStack"),Z(`EventLoop busy time: %c${B(r)}ms %c> Max wait: %c${i-2}ms`,n,o,n),setTimeout($e,16*Se),void(Me=t);Se=1,we.forEach(Ee),we.length=0,e({addedMutations:ve,removedMutations:ze}),Oe=!1,ve.clear(),ze.clear()})(e),t.observe(r,i),Z("Attached MutationObserver to body"),t}const ke=(e,o=!0)=>r=>{r>0&&Z(`${o?"At":"De"}tached ${e}Observer ${o?"to":"from"} %c${r}%c element${1===r?"":"s"}`,n,t)},Ie=(e,t,n)=>e=>{let o=0;for(const r of e)n.has(r)&&(t.unobserve(r),n.delete(r),o+=1);return o},Ae=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,xe=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||R,i=(t=!1)=>e(t),a=(e,t)=>0===e||e>t[n],s=(e,t)=>e.toggleAttribute(u,t);const l=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t,i=e[n],l=a(i,o)&&!Ae(r);s(r,l)}r(i)},o),c=new WeakSet;return{attachObservers:function(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=c.has(n);e&&(J(!o,"Node already observed for overflow",n),o||(l.observe(n),c.add(n),t+=1))}return t},detachObservers:Ie(0,l,c)}},Ne="--ifr-start",Pe="--ifr-end",Ce=[],Re=new WeakSet,Be=e=>"object"==typeof e&&Re.add(e);let qe={},Le=0;function We(e){e.getEntries().forEach(e=>{if(e.name===Pe){const{duration:t}=performance.measure("--ifr-measure",Ne,Pe);qe=e.detail,Ce.push(t),Ce.length>100&&Ce.shift()}})}function De(){Z("Attached PerformanceObserver to page");new PerformanceObserver(We).observe({entryTypes:["mark"]}),Be(document.documentElement),Be(document.body),function(){const e=setInterval(()=>{if(Ce.length<10)return;if(qe.hasTags&&qe.len<25)return;Ce.sort();const t=Math.min(Ce.reduce((e,t)=>e+t,0)/Ce.length,Ce[Math.floor(Ce.length/2)]),n=B(t);n>Le&&(Le=n,X("performanceObserver")),t<=4||(clearInterval(e),ne(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${B(t)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${qe.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3)}()}const Fe=ke("Resize"),Ve=new WeakSet;let He;function Ue(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=Ve.has(n);if(!e)continue;const r=getComputedStyle(n)?.position;""!==r&&"static"!==r&&(J(!o,"Node already observed for resize",n),o||(He.observe(n),Ve.add(n),t+=1))}Fe(t)}const Ze=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Je=Ze("function"),_e=Ze("number"),Qe=Ze("string");"undefined"!=typeof window&&function(){const e={height:()=>(te("Custom height calculation function not defined"),Wt.auto()),width:()=>(te("Custom width calculation function not defined"),Dt.auto())},E={},k={},A="auto",R="[iFrameSizer]",B="scroll";let V,U,J,_,Y,re,le,ce,ue,de=!0,fe="",me=0,pe="",ye="",ve=!1,ze=!0,we=!1,$e=!0,Se=!1,Oe=!1,Me=!1,Ee=1,je=A,Ae="",Ce=!0,Re={},Be=!1,qe=!0,Le=!1,We=0,Fe=!1,Ze=[],Ye="",Ge="child",Xe=!1,Ke="",et=[],tt=window.parent,nt="*",ot=0,rt=!1,it=1,at=B,st=window,lt=()=>{te("onMessage function not defined")},ct=()=>{},ut=null,dt=null;function ft(o){var r,i,u;!function(e){Ye=e[0]??Ye,me=be(e[1])??me,we=ge(e[2])??we,Le=ge(e[3])??Le,de=ge(e[6])??de,pe=e[7]??pe,je=e[8]??je,fe=e[9]??fe,ye=e[10]??ye,ot=be(e[11])??ot,Re.enable=ge(e[12])??!1,Ge=e[13]??Ge,at=e[14]??at,Fe=ge(e[15])??Fe,J=be(e[16])??J,_=be(e[17])??_,ze=ge(e[18])??ze,V=e[19]??V,ce=e[20]??ce,We=be(e[21])??We,qe=ge(e[23])??qe}(o),F=(r={id:Ye,enabled:Le,expand:qe}).id||s,H.label(`${F}`),H.expand(r.expand),D=r.enabled,function(){function t(e){ue=Je(e,"onBeforeResize")??ue,lt=Je(e,"onMessage")??lt,ct=Je(e,"onReady")??ct,"number"==typeof e?.offset&&(se("offset","offsetSize"),ze&&(J=_e(e,"offset")??J),we&&(_=_e(e,"offset")??_)),"number"==typeof e?.offsetSize&&(ze&&(J=_e(e,"offsetSize")??J),we&&(_=_e(e,"offsetSize")??_)),U=Qe(e,j(T[0]))??U,Ae=Qe(e,"ignoreSelector")??Ae,Ke=Qe(e,"sizeSelector")??Ke,nt=Qe(e,"targetOrigin")??nt,je=e?.heightCalculationMethod||je,at=e?.widthCalculationMethod||at}function o(t,n){return"function"==typeof t&&(ne(`<rb>Deprecated Option(${n}CalculationMethod)</>\n\nThe use of <b>${n}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.\n\nSee <u>https://iframe-resizer.com/api/child</> for more details.`),e[n]=t,t="custom"),t}if(1===We)return;const r=window.iframeResizer||window.iFrameResizer;"object"==typeof r&&(t(r),je=o(je,"height"),at=o(at,"width"),Z(`Set targetOrigin for parent: %c${nt}`,n))}(),vt(),function(){try{Xe=1===We||"iframeParentListener"in window.parent}catch(e){}}(),we===ze&&(ve=!0),function(){const e=We,n=N({key:V}),o=N({key:U});if(We=Math.max(n,o),We<0){if(We=Math.min(n,o),ee(),ne(`${x(We+2)}${x(2)}`),L(ce))throw x(We+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!L(ce)||e>-1&&We>e)&&(sessionStorage.getItem("ifr")!==a&&function(e,n){console.info(`${F} %ciframe-resizer ${e}`,D||n<1?"font-weight: bold;":t)}(`v${a} (${(e=>j(I[e]))(We)})`,We),We<2&&oe(x(3)),sessionStorage.setItem("ifr",a))}(),ce&&""!==ce&&"false"!==ce?ce!==a&&ne(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ce} - Child page: ${a}.\n`):ne("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/</> for more details.\n"),$t(),St(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(c,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&ne("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),"BackCompat"===document.compatMode&&ne("<rb>Quirks Mode Detected</>\n\nThis iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.\n\nFor more information see <u>https://iframe-resizer.com/quirks-mode</>.\n"),pt(),ve||he(),1!==We&&(st.parentIframe=Object.freeze({autoResize:e=>(W(e,"boolean","parentIframe.autoResize(enable) enable"),!1===we&&!1===ze?(X(p),ne(`Auto Resize can not be changed when <b>direction</> is set to '${S}'.`),!1):(!0===e&&!1===de?(de=!0,queueMicrotask(()=>Jt(p,"Auto Resize enabled"))):!1===e&&!0===de&&(de=!1),Qt(0,0,"autoResize",JSON.stringify(de)),de)),close(){Qt(0,0,"close")},getId:()=>Ye,getOrigin:()=>(ie("getOrigin()","getParentOrigin()"),Y),getParentOrigin:()=>Y,getPageInfo(e){if("function"==typeof e)return ut=e,Qt(0,0,"pageInfo"),void ae("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");ut=null,Qt(0,0,"pageInfoStop")},getParentProps:e=>(W(e,"function","parentIframe.getParentProps(callback) callback"),dt=e,Qt(0,0,"parentInfo"),()=>{dt=null,Qt(0,0,"parentInfoStop")}),getParentProperties(e){ie("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){W(e,"string","parentIframe.moveToAnchor(anchor) anchor"),Re.findTarget(e)},reset(){!function(){const e=je;je=A,rt||(rt=!0,requestAnimationFrame(()=>{rt=!1})),_t("reset"),je=e}()},setOffsetSize(e){W(e,"number","parentIframe.setOffsetSize(offset) offset"),J=e,_=e,Jt(b,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){W(e,"number","parentIframe.scrollBy(x, y) x"),W(t,"number","parentIframe.scrollBy(x, y) y"),Qt(t,e,"scrollBy")},scrollTo(e,t){W(e,"number","parentIframe.scrollTo(x, y) x"),W(t,"number","parentIframe.scrollTo(x, y) y"),Qt(t,e,"scrollTo")},scrollToOffset(e,t){W(e,"number","parentIframe.scrollToOffset(x, y) x"),W(t,"number","parentIframe.scrollToOffset(x, y) y"),Qt(t,e,"scrollToOffset")},sendMessage(e,t){t&&W(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Qt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){je=e,$t()},setWidthCalculationMethod(e){at=e,St()},setTargetOrigin(e){W(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),nt=e},resize(e,t){e&&W(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&W(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),Jt(y,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){ie("size()","resize()"),this.resize(e,t)}}),st.parentIFrame=st.parentIframe),function(){function e(e){Qt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){M(window.document,t,e)}!0===Fe&&(t("mouseenter"),t("mouseleave"))}(),Re=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function t(t){const n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,l)+parseInt(o.x,l),y:parseInt(n.top,l)+parseInt(o.y,l)}}function n(e){function n(e){const n=t(e);Qt(n.y,n.x,"scrollToOffset")}const o=e.split("#")[1]||e,r=decodeURIComponent(o),i=document.getElementById(r)||document.getElementsByName(r)[0];void 0===i?Qt(0,0,"inPageLink",`#${o}`):n(i)}function o(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&n(t)}function r(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&M(e,"click",t=>{t.preventDefault(),n(e.getAttribute("href"))})}function i(){M(window,"hashchange",o)}function a(){setTimeout(o,128)}function s(){r(),i(),a()}return Re.enable&&(1===We?ne("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):s()),{findTarget:n}}(),void 0===pe&&(pe=`${me}px`),gt("margin",(i="margin",(u=pe).includes("-")&&(te(`Negative CSS value ignored for ${i}`),u=""),u)),gt("background",fe),gt("padding",ye),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),ve||function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),function(e){zt({method:e,eventType:"After Print",eventName:"afterprint"}),zt({method:e,eventType:"Before Print",eventName:"beforeprint"}),zt({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=Ct(document.documentElement)();Te(xt),function(e){const t={root:document.documentElement,side:ze?f:m};re=xe(Mt,t),re.attachObservers(e)}(e),De(),function(e){He=new ResizeObserver(Et),He.observe(document.body),Ve.add(document.body),Z("Attached ResizeObserver to body"),le={attachObserverToNonStaticElements:Ue,detachObservers:Ie(0,He,Ve)},le.attachObserverToNonStaticElements(e)}(e),function(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;t.observe(n),Z("Attached VisibilityObserver to page")}(jt)}(),mt(C(ct)),Jt(O,"Init message from host page",void 0,void 0,`${a}:${We}`),document.title&&""!==document.title&&Qt(0,0,"title",document.title)}function mt(e){"complete"===document.readyState?P(e):M(document,"readystatechange",()=>mt(e))}function pt(){et=document.querySelectorAll(`[${c}]`),Me=et.length>0}let ht=0;function yt(){const e=document.querySelectorAll(`*[${d}]`);Se=e.length>0,Se&&e.length!==ht&&(function(e){const n=1===e.length?"":"s";te(`%c[${d}]%c found on %c${e.length}%c element${n}`,i,t,i,t)}(e),ht=e.length)}function gt(e,t){void 0!==t&&""!==t&&"null"!==t&&(document.body.style.setProperty(e,t),Z(`Set body ${e}: %c${t}`,n))}function bt(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function vt(){bt(0,c,Ke),bt(0,d,Ae)}function zt(e){({add(t){function n(){Jt(e.eventName,e.eventType)}k[t]=n,M(window,t,n,{passive:!0})},remove(e){const t=k[e];var n,o;delete k[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName)}function wt(e,t,n,o){return t!==e&&(e in n||(te(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in E)&&ne(`<rb>Deprecated ${o}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you ${ce?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),e}function $t(){je=wt(je,A,Wt,"height")}function St(){at=wt(at,B,Dt,"width")}function Ot(){const e=document.querySelectorAll(`[${u}]`);Ze=Array.from(e).filter(e=>!e.closest(`[${d}]`)),Oe=Ze.length>0}function Mt(e){Ot(),(Oe||e)&&(Ze.length>1?Z("Overflowed Elements:",...Ze):Oe||Z("Overflow removed"),Jt(z,"Overflow updated"))}function Et(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Jt(v,`Element resized <${function(e){switch(!0){case!L(e):return"";case L(e.id):return`${e.nodeName}#${e.id}`;case L(e.name):return`${e.nodeName} (${e.name}`;case L(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function jt(e){Be=!e,Jt($,"Visibility changed")}const Tt=ke("Overflow"),kt=ke("Overflow",!1),It=ke("Resize"),At=ke("Resize",!1);function xt(e){!function({addedMutations:e,removedMutations:t}){X("contentMutated"),vt(),pt(),Ot();let n=0,o=0,r=0,i=0;for(const e of t){const t=Ct(e)();o+=re.detachObservers(t),i+=le.detachObservers(t)}for(const t of e){const e=Ct(t)();n+=re.attachObservers(e),r+=le.attachObserverToNonStaticElements(e)}kt(o),At(i),Tt(n),It(r),Q()}(e),Jt(w,"Mutation Observed")}function Nt(e){performance.mark(Ne);const t=q(e);let n=0,o=document.documentElement,r=Me?0:document.documentElement.getBoundingClientRect().bottom;const i=Me?et:Oe?Ze:Ct(document)();for(const t of i)n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>r&&(r=n,o=t);return Z(`${t} position calculated from:`,o),performance.mark(Pe,{detail:{hasTags:Me,len:i.length,logging:Le,Side:t}}),r}const Pt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],Ct=e=>()=>{if(!(e=>e.nodeType===Node.ELEMENT_NODE)(e))return[e];const t=["* ","not(head)","not(meta)","not(base)","not(title)","not(script)","not(link)","not(style)","not(map)","not(area)","not(option)","not(optgroup)","not(template)","not(track)","not(wbr)","not(nobr)"];return yt(),Se&&t.push(`not([${d}])`,`not([${d}] *)`),[e,...e.querySelectorAll(t.join(":"))]},Rt={height:0,width:0},Bt={height:0,width:0},qt=[n,o,n];function Lt(e){function t(){return Bt[r]=i,Rt[r]=l,i}const o=e===Wt,r=o?"height":"width",i=e.boundingClientRect(),a=Math.ceil(i),s=Math.floor(i),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e),c=`HTML: %c${i}px %cPage: %c${l}px`;let u=0;switch(!0){case!e.enabled():return l;case Me:Z("Found element with data-iframe-size attribute"),u=e.taggedElement();break;case!Oe&&0===Bt[r]&&0===Rt[r]:Z(`Initial page size values: ${c}`,...qt),u=t();break;case rt&&i===Bt[r]&&l===Rt[r]:Z(`Size unchanged: ${c}`,...qt),u=Math.max(i,l);break;case 0===i:Z(`Page is hidden: ${c}`,...qt),u=l;break;case!Oe&&i!==Bt[r]&&l<=Rt[r]:Z(`New <html> size: ${c} `,...qt),Z(`Previous <html> size: %c${Bt[r]}px`,n),u=t();break;case!o:u=e.taggedElement();break;case!Oe&&i<Bt[r]:Z(`<html> size decreased: ${c}`,...qt),u=t();break;case l===s||l===a:Z(`<html> size equals page size: ${c}`,...qt),u=t();break;case i>l:Z(`Page size < <html> size: ${c}`,...qt),u=t();break;case Oe:Z("Found element overflowing <html> "),u=e.taggedElement();break;default:Z(`Using <html> size: ${c}`,...qt),u=t()}return Z(`Content ${r}: %c${u}px`,n),u+=function(e){const t=e.getOffset();return 0!==t&&Z(`Page offsetSize: %c${t}px`,n),t}(e),u}const Wt={enabled:()=>ze,getOffset:()=>J,auto:()=>Lt(Wt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,l)+parseInt(t.marginBottom,l)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Wt.bodyOffset(),custom:()=>e.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...Pt(Wt)),min:()=>Math.min(...Pt(Wt)),grow:()=>Wt.max(),lowestElement:()=>Nt(f),taggedElement:()=>Nt(f)},Dt={enabled:()=>we,getOffset:()=>_,auto:()=>Lt(Dt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>e.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...Pt(Dt)),min:()=>Math.min(...Pt(Dt)),rightMostElement:()=>Nt(m),scroll:()=>Math.max(Dt.bodyScroll(),Dt.documentElementScroll()),taggedElement:()=>Nt(m)},Ft=(e,t)=>!(Math.abs(e-t)<=ot);function Vt(e,t){const n=e[t]();return e.enabled()&&void 0!==ue?function(e){const t=ue(e);if(void 0===t)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);return t}(n):n}let Ht=!1;const Ut=C(()=>oe(x(4)));let Zt=!1;const Jt=G((e,t,n,o,r)=>{if(performance.now(),X(e),!0!==Ht){if(!de&&!(e in g))return Z("Resizing disabled"),void Q();if(Be){if(!0===Zt)return;Zt=!0}else Zt=!1,Ht=!0,requestAnimationFrame(()=>{Ht=!1}),function(e,t,n,o,r){const i=n??Vt(Wt,je),a=o??Vt(Dt,at);switch(ze&&Ft(Ee,i)||we&&Ft(it,a)?h:e){case O:case p:case h:Ee=i,it=a;case b:Qt(Ee,it,e,r);break;case z:case w:case v:case $:ee();break;default:ee(),Z("No change in content size detected")}}(e,0,n,o,r)}});function _t(e){Ee=Wt[je](),it=Dt[at](),Qt(Ee,it,e)}const Qt=G(function(e,t,o,i,a){We<-1||(X(o),void 0!==a||(a=nt),function(){const s=`${Ye}:${e}:${t}:${o}${void 0===i?"":`:${i}`}`;if(Xe)try{window.parent.iframeParentListener(R+s)}catch(e){if(1!==We)throw e;return void Ut()}else tt.postMessage(R+s,a);Z(`Sending message to parent page via ${Xe?"sameOrigin":"postMessage"}: %c%c${s}`,r,n)}(),Q())}),Yt=G(function(e){X("onMessage");const{freeze:t}=Object,{parse:n}=JSON,o=e=>Qt(0,0,`${e}Stop`),r={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(":");tt=e.source,Y=e.origin,ft(t),$e=!1,setTimeout(()=>{Ce=!1},128)},reset(){Ce||_t("resetPage")},resize(){Jt("parentResize","Parent window requested size check")},moveToAnchor(){Re.findTarget(a())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=a();ut?P(ut,n(e)):o("pageInfo")},parentInfo(){const e=(r=a(),t(n(r)));var r;dt?P(dt,e):o("parentInfo")},message(){const e=a();P(lt,n(e))}},i=()=>e.data.split("]")[1].split(":")[0],a=()=>e.data.slice(e.data.indexOf(":")+1),s=()=>e.data.split(":")[2]in{true:1,false:1};function l(){const t=i();X(t),t in r?r[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||s()||te(`Unexpected message (${e.data})`)}R===`${e.data}`.slice(0,13)&&function(){if(!1!==$e)return s()?(K(i()),X(O),void r.init()):void 0;l()}()});function Gt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?te("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>Yt({data:e,sameOrigin:!0})),M(window,"message",Yt),M(window,"readystatechange",Gt),Gt())}();