UNPKG

@iframe-resizer/child

Version:

Keep iframes sized to their content.

21 lines (18 loc) 28.9 kB
/*! * @preserve * * @module iframe-resizer/child 5.5.6 (esm) - 2025-09-10 * * @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 a}from"auto-console-group";const i="5.5.6",s="iframeResizer",c="beforeUnload",l="init",u="message",d="pageInfo",m="parentInfo",f="scrollToOffset",h="title",p=10,g="data-iframe-size",y="data-iframe-overflowed",b="data-iframe-ignore",v="height",z="width",w="readystatechange",$="bottom",S="right",O="autoResizeEnabled",E=Symbol("sizeChanged"),M="manualResize",k="parentResize",j={[M]:1,[k]:1},x="setOffsetSize",T="resizeObserver",A="overflowObserver",I="mutationObserver",N="visibilityObserver",C="[iFrameSizer]",P=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),R=(e,t,n,o)=>e.addEventListener(t,n,o||!1),B=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)},q=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),L=["spjluzl","rlf","clyzpvu"],D=["<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."],W=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],F=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),V=e=>q(D[e]),H=e=>{const t=e[q(L[0])]||e[q(L[1])]||e[q(L[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=B(q(e));return n in F&&(t=F[n]),t}(n[0]);return 0===o||(e=>e[2]===B(e[0]+e[1]))(n)||(o=-2),o},U=(e,...t)=>setTimeout(()=>e(...t),0),Z=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},J=e=>e,_=e=>Math.round(1e3*e)/1e3,Q=e=>e.charAt(0).toUpperCase()+e.slice(1),Y=e=>""!=`${e}`&&void 0!==e;const G=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${Q(t)}`)};let X=!0,K=s;var ee;const te=(ee=e,ee?.__esModule?ee.default:ee)({label:`${s}(child)`,expand:!1});var ne;const oe=(ne="log",(...e)=>!X||te[ne](...e));const{assert:re,endAutoGroup:ae,error:ie,errorBoundary:se,event:ce,label:le,purge:ue,warn:de}=te,me=e=>{return te.warn((t=J,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},fe=me,he=(e=>(t,n="renamed to")=>(o,r,a="",i="")=>e(i,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${a}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>me(t)),pe=he("Method"),ge=he("Method","replaced with"),ye=he("Option"),be=["min-height","min-width","max-height","max-width"],ve=new Set,ze=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),we=(e,t)=>{return(n=ze(e,t))&&"0px"!==n&&"auto"!==n&&"none"!==n;var n};function $e({href:e}){ve.has(e)||ve.add(e)}const Se=(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){$e(n)}return{source:"cross-origin stylesheet",value:ze(e,t)}}(e,t),Oe=(e,t)=>{const{source:n,value:o}=Se(e,t),r=(e=>e.tagName?e.tagName.toLowerCase():"unknown")(e);me(`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 Ee(){for(const e of[document.documentElement,document.body])for(const t of be)we(e,t)&&Oe(e,t)}const Me=e=>t=>void 0===t?void 0:e(t),ke=Me(e=>"true"===e),je=Me(Number),xe=e=>e=>{e.size},Te=((e="")=>t=>n=>{n.size>0&&ie(`${t}Observer ${e}:`,...Array.from(n).flatMap(e=>["\n",e]))})("already attached"),Ae=e=>e=>{e.size},Ie=(e,o=!0)=>r=>{r>0&&oe(`${o?"At":"De"}tached ${e}Observer ${o?"to":"from"} %c${r}%c element${1===r?"":"s"}`,n,t)},Ne=(e,t,n,o)=>{const r=Ae(e);return e=>{const a=new Set;let i=0;for(const o of e)n.has(o)&&(t.unobserve(o),n.delete(o),a.add(o),i+=1);r(a),o(i),a.clear()}},Ce=new Set,Pe=new Set,Re=new Set,Be=[],qe={attributes:!0,attributeFilter:[b,g],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let Le,De=1,We=!1,Fe=0;const Ve=e=>{e.size},He=e=>{e.size},Ue=e=>{e.size},Ze=e=>e.nodeType!==Node.ELEMENT_NODE||P.has(e.tagName.toLowerCase());function Je(e){const t=e.addedNodes;for(const e of t)Ze(e)||Ce.add(e)}function _e(e){const t=e.removedNodes;for(const e of t)Ze(e)||(Ce.has(e)?(Ce.delete(e),Re.add(e)):Pe.add(e))}const Qe=e=>{oe("Mutations:",e);for(const t of e)Je(t),_e(t);Ve(Ce),He(Pe),Ue(Re),Re.clear()};const Ye=e=>()=>{const t=performance.now(),r=t-Fe,a=16*De+++2;if(r>a&&r<200)return ce("mutationThrottled"),oe("Update delayed due to heavy workload on the callStack"),oe(`EventLoop busy time: %c${_(r)}ms %c> Max wait: %c${a-2}ms`,n,o,n),setTimeout(Le,16*De),void(Fe=t);De=1,Be.forEach(Qe),Be.length=0,We=!1,Pe.size,Ce.size,e({addedNodes:Ce,removedNodes:Pe}),Ce.clear(),Pe.clear()};function Ge(e){Be.push(e),We||(Fe=performance.now(),We=!0,requestAnimationFrame(Le))}function Xe(e){const t=new window.MutationObserver(Ge),n=document.body||document.documentElement;return Le=Ye(e),t.observe(n,qe),oe("Attached MutationObserver to body"),{...t,disconnect:()=>{Ce.clear(),Pe.clear(),Be.length=0,t.disconnect(),oe("Detached MutationObserver")}}}const Ke="Overflow",et=Ie(Ke),tt=Ie(Ke,!1),nt=xe(Ke),ot=Te(Ke),rt=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,at=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||J,a=(t=!1)=>e(t),i=(e,t)=>0===e||e>t[n],s=(e,t)=>e.toggleAttribute(y,t);const c=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t;if(!o)continue;const a=e[n],c=i(a,o)&&!rt(r);s(r,c)}r(a)},o),l=new WeakSet;return{attachObservers:function(e){const t=new Set,n=new Set;let o=0;for(const r of e)r.nodeType===Node.ELEMENT_NODE&&(l.has(r)?t.add(r):(c.observe(r),l.add(r),n.add(r),o+=1));ot(t),nt(n),et(o),n.clear(),t.clear()},detachObservers:Ne(Ke,c,l,tt),disconnect:()=>{c.disconnect(),oe("Detached OverflowObserver")}}},it="--ifr-start",st="--ifr-end",ct="--ifr-measure",lt=[];let ut,dt={},mt=0;function ft(){try{performance.clearMarks(it),performance.clearMarks(st),performance.clearMeasures(ct)}catch{}}function ht(e){e.getEntries().forEach(e=>{if(e.name===st)try{const{duration:t}=performance.measure(ct,it,st);dt=e.detail,lt.push(t),lt.length>100&&lt.shift()}catch{}})}function pt(){oe("Attached PerformanceObserver to page");const e=new PerformanceObserver(ht);return e.observe({entryTypes:["mark"]}),ut=setInterval(()=>{if(lt.length<10)return;if(dt.hasTags&&dt.len<25)return;lt.sort();const e=Math.min(lt.reduce((e,t)=>e+t,0)/lt.length,lt[Math.floor(lt.length/2)]),t=_(e);t>mt&&(mt=t,ce("performanceObserver")),ft(),e<=4||(clearInterval(ut),me(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${_(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${dt.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3),{disconnect:()=>{ft(),clearInterval(ut),e.disconnect(),oe("Detached PerformanceObserver")}}}const gt="Resize",yt=Ie(gt),bt=Ie(gt,!1),vt=xe(gt),zt=Te(gt),wt=new WeakSet,$t=new Set,St=new Set;let Ot;function Et(e){let t=0;for(const n of e){if(n.nodeType!==Node.ELEMENT_NODE)continue;const e=getComputedStyle(n)?.position;""!==e&&"static"!==e&&(wt.has(n)?$t.add(n):(Ot.observe(n),wt.add(n),St.add(n),t+=1))}zt($t),vt(St),yt(t),St.clear(),$t.clear()}function Mt(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;return t.observe(n),oe("Attached VisibilityObserver to page"),{disconnect:()=>{t.disconnect(),oe("Detached VisibilityObserver")}}}const kt=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},jt=kt("function"),xt=kt("number"),Tt=kt("string");"undefined"!=typeof window&&function(){const e={height:()=>(de("Custom height calculation function not defined"),Sn.auto()),width:()=>(de("Custom width calculation function not defined"),On.auto())},B={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},D={},F="auto",_=[],ee="scroll";let ne,he,be,ve,ze,we,$e,Se=!0,Oe="",Me=0,xe="",Te="",Ae=!1,Ie=!0,Ce=!1,Pe=!0,Re=!1,Be=!1,qe=!0,Le=!1,De=1,We=F,Fe="",Ve=!0,He={},Ue=!1,Ze=!1,Je=!1,_e=0,Qe=!1,Ye=0,Ge=0,Ke=new Set,et="",tt="child",nt=!1,ot="",rt=[],ct=window.parent,lt="*",ut=0,dt=!1,mt=1,ft=ee,ht=window,yt=()=>{de("onMessage function not defined")},vt=()=>{},zt=null,$t=null;function St(t){var o;!function(e){et=e[0]??et,Me=je(e[1])??Me,Ce=ke(e[2])??Ce,Je=ke(e[3])??Je,Se=ke(e[6])??Se,xe=e[7]??xe,We=e[8]??We,Oe=e[9]??Oe,Te=e[10]??Te,ut=je(e[11])??ut,He.enable=ke(e[12])??!1,tt=e[13]??tt,ft=e[14]??ft,Qe=ke(e[15])??Qe,Ye=je(e[16])??Ye,Ge=je(e[17])??Ge,Ie=ke(e[18])??Ie,ne=e[19]??ne,we=e[20]??we,_e=je(e[21])??_e,Ze=ke(e[23])??Ze}(t),K=(o={id:et,enabled:Je,expand:Ze}).id||s,te.label(`${K}`),te.expand(o.expand),X=o.enabled,function(){function t(e){$e=jt(e,"onBeforeResize")??$e,yt=jt(e,"onMessage")??yt,vt=jt(e,"onReady")??vt,"number"==typeof e?.offset&&(ye("offset","offsetSize"),Ie&&(Ye=xt(e,"offset")??Ye),Ce&&(Ge=xt(e,"offset")??Ge)),"number"==typeof e?.offsetSize&&(Ie&&(Ye=xt(e,"offsetSize")??Ye),Ce&&(Ge=xt(e,"offsetSize")??Ge)),he=Tt(e,q(L[0]))??he,Fe=Tt(e,"ignoreSelector")??Fe,ot=Tt(e,"sizeSelector")??ot,lt=Tt(e,"targetOrigin")??lt,We=e?.heightCalculationMethod||We,ft=e?.widthCalculationMethod||ft}function o(t,n){return"function"==typeof t&&(me(`<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===_e)return;const r=window.iframeResizer||window.iFrameResizer;"object"==typeof r&&(t(r),We=o(We,v),ft=o(ft,z),oe(`Set targetOrigin for parent: %c${lt}`,n))}(),[Rt,qt,Yt,Ct,Bt,_t,Qt,Zt,Pt,It,Ae?J:Ee,Wt,tn,en,Kt,Ft,()=>Lt("background",Oe),()=>Lt("padding",Te),Ae?J:Vt,Xt,Gt,hn,kt].forEach(e=>{try{e()}catch(e){if(_e<0)throw e;me("<rb>Error in setup function</>\n<i>iframe-resizer</> detected an error during setup.\n\nPlease report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>"),ie(e)}}),At(Z(vt)),An(l,"Init message from host page",void 0,void 0,`${i}:${_e}`),document.title&&""!==document.title&&Cn(0,0,h,document.title)}function kt(){R(window,c.toLowerCase(),()=>{_.forEach(e=>e()),Cn(0,0,c)})}function At(e){"complete"===document.readyState?U(e):R(document,w,()=>At(e))}function It(){rt=document.querySelectorAll(`[${g}]`),Le=rt.length>0}let Nt=0;function Ct(){const e=document.querySelectorAll(`*[${b}]`);return Re=e.length>0,Re&&e.length!==Nt&&(function(e){const n=1===e.length?"":"s";de(`%c[${b}]%c found on %c${e.length}%c element${n}`,a,t,a,t)}(e),Nt=e.length),Re}function Pt(){"BackCompat"===document.compatMode&&me("<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")}function Rt(){we&&""!==we&&"false"!==we?we!==i&&me(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${we} - Child page: ${i}.\n`):me("<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")}function Bt(){try{nt=1===_e||"iframeParentListener"in window.parent}catch(e){}}function qt(){Ce===Ie&&(Ae=!0)}function Lt(e,t){void 0!==t&&""!==t&&"null"!==t&&(document.body.style.setProperty(e,t),oe(`Set body ${e}: %c${t}`,n))}function Dt(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function Wt(){Dt(0,g,ot),Dt(0,b,Fe)}function Ft(){var e,t;void 0===xe&&(xe=`${Me}px`),Lt("margin",(e="margin",(t=xe).includes("-")&&(de(`Negative CSS value ignored for ${e}`),t=""),t))}function Vt(){const e=e=>e.style.setProperty(v,"auto","important");e(document.documentElement),e(document.body)}function Ht(e){({add(t){function n(){An(e.eventName,e.eventType)}D[t]=n,R(window,t,n,{passive:!0})},remove(e){const t=D[e];var n,o;delete D[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName)}function Ut(e){Ht({method:e,eventType:"After Print",eventName:"afterprint"}),Ht({method:e,eventType:"Before Print",eventName:"beforeprint"}),Ht({method:e,eventType:"Ready State Change",eventName:w})}function Zt(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(g,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&me("<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</>.")}function Jt(e,t,n){const{label:o}=n;return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in B)&&me(`<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 ${we?"remove this option.":`set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page. This can be done on the child page by adding the following code:\n \nwindow.iframeResizer = {\n license: 'xxxx',\n ${o}CalculationMethod: 'auto',\n}\n`}\n`),e}function _t(){We=Jt(We,F,Sn)}function Qt(){ft=Jt(ft,ee,On)}function Yt(){const e=_e,n=H({key:ne}),o=H({key:he});if(_e=Math.max(n,o),_e<0){if(_e=Math.min(n,o),ue(),me(`${V(_e+2)}${V(2)}`),Y(we))throw V(_e+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!Y(we)||e>-1&&_e>e)&&(sessionStorage.getItem("ifr")!==i&&function(e,n){console.info(`${K} %ciframe-resizer ${e}`,X||n<1?"font-weight: bold;":t)}(`v${i} (${(e=>q(W[e]))(_e)})`,_e),_e<2&&fe(V(3)),sessionStorage.setItem("ifr",i))}function Gt(){Ut("add"),_.push(()=>Ut("remove"))}function Xt(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Kt(){function e(e){const t=e.getBoundingClientRect(),n={x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};return{x:parseInt(t.left,p)+parseInt(n.x,p),y:parseInt(t.top,p)+parseInt(n.y,p)}}function t(t){const n=t.split("#")[1]||t,o=decodeURIComponent(n),r=document.getElementById(o)||document.getElementsByName(o)[0];void 0===r?Cn(0,0,"inPageLink",`#${n}`):function(t){const n=e(t);Cn(n.y,n.x,f)}(r)}function n(){const{hash:e,href:n}=window.location;""!==e&&"#"!==e&&t(n)}He.enable&&(1===_e?me("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):(function(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&R(e,"click",n=>{n.preventDefault(),t(e.getAttribute("href"))})}(),R(window,"hashchange",n),setTimeout(n,128))),He={findTarget:t}}function en(){function e(e){Cn(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){R(window.document,t,e)}!0===Qe&&(t("mouseenter"),t("mouseleave"))}function tn(){1!==_e&&(ht.parentIframe=Object.freeze({autoResize:e=>(G(e,"boolean","parentIframe.autoResize(enable) enable"),!1===Ce&&!1===Ie?(ce(O),me("Auto Resize can not be changed when <b>direction</> is set to 'none'."),!1):(!0===e&&!1===Se?(Se=!0,queueMicrotask(()=>An(O,"Auto Resize enabled"))):!1===e&&!0===Se&&(Se=!1),Cn(0,0,"autoResize",JSON.stringify(Se)),Se)),close(){Cn(0,0,"close")},getId:()=>et,getOrigin:()=>(ce("getOrigin"),pe("getOrigin()","getParentOrigin()"),be),getParentOrigin:()=>be,getPageInfo(e){if("function"==typeof e)return zt=e,Cn(0,0,d),void ge("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");zt=null,Cn(0,0,"pageInfoStop")},getParentProps:e=>(G(e,"function","parentIframe.getParentProps(callback) callback"),$t=e,Cn(0,0,m),()=>{$t=null,Cn(0,0,"parentInfoStop")}),getParentProperties(e){pe("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){G(e,"string","parentIframe.moveToAnchor(anchor) anchor"),He.findTarget(e)},reset(){!function(){const e=We;We=F,dt||(dt=!0,requestAnimationFrame(()=>{dt=!1})),In("reset"),We=e}()},setOffsetSize(e){G(e,"number","parentIframe.setOffsetSize(offset) offset"),Ye=e,Ge=e,An(x,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){G(e,"number","parentIframe.scrollBy(x, y) x"),G(t,"number","parentIframe.scrollBy(x, y) y"),Cn(t,e,"scrollBy")},scrollTo(e,t){G(e,"number","parentIframe.scrollTo(x, y) x"),G(t,"number","parentIframe.scrollTo(x, y) y"),Cn(t,e,"scrollTo")},scrollToOffset(e,t){G(e,"number","parentIframe.scrollToOffset(x, y) x"),G(t,"number","parentIframe.scrollToOffset(x, y) y"),Cn(t,e,f)},sendMessage(e,t){t&&G(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Cn(0,0,u,JSON.stringify(e),t)},setHeightCalculationMethod(e){We=e,_t()},setWidthCalculationMethod(e){ft=e,Qt()},setTargetOrigin(e){G(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),lt=e},resize(e,t){void 0!==e&&G(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),void 0!==t&&G(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),An(M,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){pe("size()","resize()"),this.resize(e,t)}}),ht.parentIFrame=ht.parentIframe)}let nn=new Set;function on(){const e=document.querySelectorAll(`[${y}]`);Ke=function(e){const t=new Set,n=new Set;for(const o of e)o.closest(`[${b}]`)?n.add(o):t.add(o);return n.size>0&&queueMicrotask(()=>{ce("overflowIgnored"),oe("Ignoring elements with [data-iframe-ignore] > *:\n",n),ae()}),t}(e),Be=Ke.size>0,"function"==typeof Set.prototype.symmetricDifference&&(qe=Ke.symmetricDifference(nn).size>0),nn=Ke}function rn(){switch(on(),!0){case!qe:return;case Ke.size>1:oe("Overflowed Elements:",Ke);break;case Be:break;default:oe("No overflow detected")}An(A,"Overflow updated")}function an(e){const t={root:document.documentElement,side:Ie?$:S};return ve=at(rn,t),ve.attachObservers(e),ve}function sn(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;An(T,`Element resized <${function(e){switch(!0){case!Y(e):return"";case Y(e.id):return`${e.nodeName}#${e.id}`;case Y(e.name):return`${e.nodeName} (${e.name}`;case Y(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function cn(e){return Ot=new ResizeObserver(sn),Ot.observe(document.body),wt.add(document.body),oe("Attached ResizeObserver to body"),ze={attachObserverToNonStaticElements:Et,detachObservers:Ne(gt,Ot,wt,bt),disconnect:()=>{Ot.disconnect(),oe("Detached ResizeObserver")}},ze.attachObserverToNonStaticElements(e),ze}function ln(e){Ue=!e,An(N,"Visibility changed")}const un=e=>{const t=new Set;for(const n of e){t.add(n);for(const e of bn(n))t.add(e)}return oe("Inspecting:\n",t),t},dn=e=>{if(0===e.size)return;ce("addObservers");const t=un(e);ve.attachObservers(t),ze.attachObserverToNonStaticElements(t),ae()},mn=e=>{if(0===e.size)return;ce("removeObservers");const t=un(e);ve.detachObservers(t),ze.detachObservers(t),ae()};function fn(e){!function({addedNodes:e,removedNodes:t}){ce("contentMutated"),Wt(),It(),on(),ae(),mn(t),dn(e)}(e),An(I,"Mutation Observed")}function hn(){const e=bn(document.documentElement);var t;t=[Xe(fn),an(e),pt(),cn(e),Mt(ln)],_.push(...t.map(e=>e.disconnect))}function pn(e){performance.mark(it);const t=Q(e);let r=1,a=document.documentElement,i=Le?0:document.documentElement.getBoundingClientRect().bottom;const s=Le?rt:Be?Array.from(Ke):bn(document.documentElement);for(const t of s)r=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),r>i&&(i=r,a=t);return oe(`${t} position calculated from:`,a),oe(`Checked %c${s.length}%c elements`,n,o),performance.mark(st,{detail:{hasTags:Le,len:s.length,logging:Je,Side:t}}),i}const gn=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],yn=`* ${Array.from(P).map(e=>`:not(${e})`).join("")}`,bn=e=>e.querySelectorAll(yn),vn={height:0,width:0},zn={height:0,width:0},wn=[n,o,n];function $n(e){function t(){return zn[r]=a,vn[r]=c,Math.max(a,1)}const o=e===Sn,r=e.label,a=e.boundingClientRect(),i=Math.ceil(a),s=Math.floor(a),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e),l=`HTML: %c${a}px %cPage: %c${c}px`;let u=1;switch(!0){case!e.enabled():return Math.max(c,1);case Le:oe("Found element with data-iframe-size attribute"),u=e.taggedElement();break;case!Be&&Pe&&0===zn[r]&&0===vn[r]:oe(`Initial page size values: ${l}`,...wn),u=t();break;case dt&&a===zn[r]&&c===vn[r]:oe(`Size unchanged: ${l}`,...wn),u=Math.max(a,c);break;case 0===a&&0!==c:oe(`Page is hidden: ${l}`,...wn),u=c;break;case!Be&&a!==zn[r]&&c<=vn[r]:oe(`New <html> size: ${l} `,...wn),oe(`Previous <html> size: %c${zn[r]}px`,n),u=t();break;case!o:u=e.taggedElement();break;case!Be&&a<zn[r]:oe(`<html> size decreased: ${l}`,...wn),u=t();break;case c===s||c===i:oe(`<html> size equals page size: ${l}`,...wn),u=t();break;case a>c:oe(`Page size < <html> size: ${l}`,...wn),u=t();break;case Be:oe("Found elements possibly overflowing <html> "),u=e.taggedElement();break;default:oe(`Using <html> size: ${l}`,...wn),u=t()}return oe(`Content ${r}: %c${u}px`,n),u+=function(e){const t=e.getOffset();return 0!==t&&oe(`Page offsetSize: %c${t}px`,n),t}(e),Math.max(u,1)}const Sn={label:v,enabled:()=>Ie,getOffset:()=>Ye,auto:()=>$n(Sn),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,p)+parseInt(t.marginBottom,p)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Sn.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(...gn(Sn)),min:()=>Math.min(...gn(Sn)),grow:()=>Sn.max(),lowestElement:()=>pn($),taggedElement:()=>pn($)},On={label:z,enabled:()=>Ce,getOffset:()=>Ge,auto:()=>$n(On),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(...gn(On)),min:()=>Math.min(...gn(On)),rightMostElement:()=>pn(S),scroll:()=>Math.max(On.bodyScroll(),On.documentElementScroll()),taggedElement:()=>pn(S)},En=(e,t)=>!(Math.abs(e-t)<=ut);function Mn(e,t){const n=e[t](),o=e.enabled()&&void 0!==$e?function(e){const t=$e(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`);if(t<1)throw new RangeError(`Out of range value returned from onBeforeResize(): ${t}, must be at least 1`);return t}(n):n;return re(o>=1,`New iframe ${e.label} is too small: ${o}, must be at least 1`),o}let kn=!1;const jn=Z(()=>fe(V(4)));let xn,Tn=!1;const An=se((e,t,n,o,r)=>{switch(ce(e),!0){case!0===Ue:if(!0===Tn)break;Tn=!0,kn=!1,cancelAnimationFrame(xn);break;case!0===kn&&e!==A:ue();break;case!Se&&!(e in j):oe("Resizing disabled");break;default:Tn=!1,kn=!0,performance.now(),xn=requestAnimationFrame(()=>{kn=!1,ce("requestAnimationFrame")}),function(e,t,n,o,r){const a=n??Mn(Sn,We),i=o??Mn(On,ft);switch(Ie&&En(De,a)||Ce&&En(mt,i)?E:e){case l:case O:case E:De=a,mt=i;case x:Nn(De,mt,e,r);break;case A:case I:case T:case N:ue();break;default:ue(),oe("No change in content size detected")}}(e,0,n,o,r)}ae()});function In(e){De=Sn[We](),mt=On[ft](),Cn(De,mt,e)}function Nn(e,t,o,a,i){_e<-1||(void 0!==i||(i=lt),function(){const s=`${et}:${e}:${t}:${o}${void 0===a?"":`:${a}`}`;if(nt)try{window.parent.iframeParentListener(C+s)}catch(e){if(1!==_e)throw e;return void jn()}else ct.postMessage(C+s,i);oe(`Sending message to parent page via ${nt?"sameOrigin":"postMessage"}: %c%c${s}`,r,n)}())}const Cn=se((e,t,n,o,r)=>{ce(n),Nn(e,t,n,o,r),ae()}),Pn=se(function(e){ce("onMessage");const{freeze:t}=Object,{parse:n}=JSON,o=e=>Cn(0,0,`${e}Stop`),r={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(":");ct=e.source,be=e.origin,St(t),Pe=!1,setTimeout(()=>{Ve=!1},128)},reset(){Ve||In("resetPage")},resize(){An(k,"Parent window requested size check")},moveToAnchor(){He.findTarget(i())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=i();zt?U(zt,n(e)):o(d)},parentInfo(){const e=(r=i(),t(n(r)));var r;$t?U($t,e):o(m)},message(){const e=i();U(yt,n(e))}},a=()=>e.data.split("]")[1].split(":")[0],i=()=>e.data.slice(e.data.indexOf(":")+1),s=()=>e.data.split(":")[2]in{true:1,false:1};function c(){const t=a();ce(t),t in r?r[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||s()||de(`Unexpected message (${e.data})`)}C===`${e.data}`.slice(0,13)&&function(){if(!1!==Pe)return s()?(le(a()),ce(l),void r.init()):void 0;c()}()});let Rn=!1;const Bn=e=>e.postMessage("[iFrameResizerChild]Ready",window?.iframeResizer?.targetOrigin||"*");function qn(){if("loading"===document.readyState||!Pe||Rn)return;const{parent:e,top:t}=window;ce("ready"),Bn(e),e!==t&&Bn(t),Rn=!0}"iframeChildListener"in window?de("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>Pn({data:e,sameOrigin:!0})),R(window,u,Pn),R(document,w,qn),qn())}();