@iframe-resizer/child 5.4.6-beta.2 → 5.4.6-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/child 5.4.6-beta.2 (esm) - 2025-04-23
4
+ * @module iframe-resizer/child 5.4.6-beta.4 (esm) - 2025-04-24
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,5 +17,5 @@
17
17
  */
18
18
 
19
19
 
20
- import e,{HIGHLIGHT as t,ITALIC as n,FOREGROUND as o,BOLD as i,NORMAL as r}from"auto-console-group";const a="5.4.6-beta.2",s=10,l="data-iframe-size",c="data-iframe-overflowed",d="data-iframe-ignore",u="bottom",m="right",f="resizeParent",p="setOffsetSize",g="resizeObserver",h="overflowObserver",y="mutationObserver",b="No change in content size detected",v=(e,t,n,o)=>e.addEventListener(t,n,o||!1),z=["<iy><yi>Puchspk Spjluzl Rlf</><iy><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."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const w=e=>(e=>e.replace(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(z[e]),$=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},S=e=>e,O=e=>Math.round(1e3*e)/1e3,M=e=>e.charAt(0).toUpperCase()+e.slice(1),k=e=>""!=`${e}`&&void 0!==e;function E(e){switch(!0){case!k(e):return"";case k(e.id):return`${e.nodeName}#${e.id}`;case k(e.name):return`${e.nodeName} (${e.name}`;case k(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const j=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${M(t)}`)};let I=!0;var T;const P=(T=e,T?.__esModule?T.default:T)({label:"iframeResizer(child)"});const A=(x="log",(...e)=>!I||P[x](...e));var x;const C=A,{assert:N,debug:R,endAutoGroup:B,error:q,errorBoundary:L,event:W,label:F,purge:D,warn:H}=P,V=e=>{return P.warn((t=S,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},U=V,Z=(e=>(t,n="renamed to")=>(o,i,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${i}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(((e,t)=>V(t))),J=Z("Method"),_=Z("Method","replaced with"),Q=Z("Option"),G=e=>t=>void 0===t?void 0:e(t),X=G((e=>"true"===e)),Y=G(Number),K="--ifr-start",ee="--ifr-end",te=[],ne=new WeakSet,oe=e=>"object"==typeof e&&ne.add(e);let ie={},re=0;const ae=setInterval((()=>{if(te.length<10)return;if(ie.hasTags&&ie.len<25)return;te.sort();const e=Math.min(te.reduce(((e,t)=>e+t),0)/te.length,te[Math.floor(te.length/2)]),t=O(e);t>re&&(re=t,W("performanceObserver"),A("Mean time:",O(te[Math.floor(te.length/2)])),A("Median time:",O(te.reduce(((e,t)=>e+t),0)/te.length)),A("Average time:",t),A("Max time:",O(Math.max(...te)))),e<=4||(clearInterval(ae),V(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${O(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${ie.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))}),5e3);function se(e){e.getEntries().forEach((e=>{if(e.name===ee){const{duration:t}=performance.measure("--ifr-measure",K,ee);ie=e.detail,te.push(t),te.length>100&&te.shift()}}))}function le(){new PerformanceObserver(se).observe({entryTypes:["mark"]}),oe(document.documentElement),oe(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",le):le());const ce=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},de=ce("function"),ue=ce("number"),me=ce("string");"undefined"!=typeof window&&function(){const e={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},z={height:()=>(H("Custom height calculation function not defined"),wt.auto()),width:()=>(H("Custom width calculation function not defined"),$t.auto())},k={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},T={},x="checkVisibility"in window,q="auto",D="[iFrameSizer]",Z={max:1,min:1,bodyScroll:1,documentElementScroll:1},G="scroll";let te,ne,oe,ie,re,ae,se=!0,le="",ce=0,fe="",pe="",ge=!0,he=!1,ye=!0,be=!1,ve=!1,ze=!1,we=1,$e=q,Se="",Oe=!0,Me={},ke=!0,Ee=!1,je="",Ie=0,Te=!1,Pe="",Ae=S,xe=[],Ce="child",Ne=null,Re=!1,Be="",qe=[],Le=window.parent,We="*",Fe=0,De=!1,He="",Ve=1,Ue=G,Ze=window,Je=()=>{H("onMessage function not defined")},_e=()=>{},Qe=null,Ge=null;function Xe(e){var n,i,r;!function(e){Pe=e[0]??Pe,ce=Y(e[1])??ce,he=X(e[2])??he,Ee=X(e[3])??Ee,se=X(e[6])??se,fe=e[7]??fe,$e=e[8]??$e,le=e[9]??le,pe=e[10]??pe,Fe=Y(e[11])??Fe,Me.enable=X(e[12])??!1,Ce=e[13]??Ce,Ue=e[14]??Ue,Te=X(e[15])??Te,te=Y(e[16])??te,ne=Y(e[17])??ne,ge=X(e[18])??ge,je=e[19]??je,He=e[20]??He,Ie=Y(e[21])??Ie,ke=X(e[23])??ke}(e),n={id:Pe,enabled:Ee,expand:ke},P.label(`${n.id}`),P.expand(n.expand),I=n.enabled,A(`Initialising iframe v${a} ${window.location.href}`),function(){function e(e){A("Reading data from page:",e),ae=de(e,"onBeforeResize")??ae,Je=de(e,"onMessage")??Je,_e=de(e,"onReady")??_e,"number"==typeof e?.offset&&(Q("offset","offsetSize"),ge&&(te=ue(e,"offset")??te),he&&(ne=ue(e,"offset")??ne)),"number"==typeof e?.offsetSize&&(ge&&(te=ue(e,"offsetSize")??te),he&&(ne=ue(e,"offsetSize")??ne)),Se=me(e,"ignoreSelector")??Se,Be=me(e,"sizeSelector")??Be,We=me(e,"targetOrigin")??We,$e=e?.heightCalculationMethod||$e,Ue=e?.widthCalculationMethod||Ue}function n(e,t){return"function"==typeof e&&(V(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}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.`),z[t]=e,e="custom"),e}if(1===Ie)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(e(o),$e=n($e,"height"),Ue=n(Ue,"width"),C(`Set targetOrigin for parent: %c${We}`,t))}(),at(),function(){try{Re=1===Ie||"iframeParentListener"in window.parent}catch(e){A("Cross domain iframe detected")}}(),Ie<0?U(`${w(Ie+2)}${w(2)}`):He.codePointAt(0)>4||Ie<2&&U(w(3)),He&&""!==He&&"false"!==He?He!==a&&V(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${He} - Child page: ${a}.\n`):V("<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"),ct(),dt(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(l,!0)}));t("data-iframe-height"),t("data-iframe-width"),e&&V("<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&&V("<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"),et(),1!==Ie&&(Ze.parentIframe=Object.freeze({autoResize:e=>(j(e,"boolean","parentIframe.autoResize(enable) enable"),!0===e&&!1===se?(se=!0,jt("autoResizeEnabled","Auto Resize enabled")):!1===e&&!0===se&&(se=!1),Pt(0,0,"autoResize",JSON.stringify(se)),se),close(){Pt(0,0,"close")},getId:()=>Pe,getOrigin:()=>(J("getOrigin()","getParentOrigin()"),oe),getParentOrigin:()=>oe,getPageInfo(e){if("function"==typeof e)return Qe=e,Pt(0,0,"pageInfo"),void _("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");Qe=null,Pt(0,0,"pageInfoStop")},getParentProps:e=>(j(e,"function","parentIframe.getParentProps(callback) callback"),Ge=e,Pt(0,0,"parentInfo"),()=>{Ge=null,Pt(0,0,"parentInfoStop")}),getParentProperties(e){J("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){j(e,"string","parentIframe.moveToAnchor(anchor) anchor"),Me.findTarget(e)},reset(){Tt("parentIframe.reset")},setOffsetSize(e){j(e,"number","parentIframe.setOffsetSize(offset) offset"),te=e,ne=e,jt(p,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){j(e,"number","parentIframe.scrollBy(x, y) x"),j(t,"number","parentIframe.scrollBy(x, y) y"),Pt(t,e,"scrollBy")},scrollTo(e,t){j(e,"number","parentIframe.scrollTo(x, y) x"),j(t,"number","parentIframe.scrollTo(x, y) y"),Pt(t,e,"scrollTo")},scrollToOffset(e,t){j(e,"number","parentIframe.scrollToOffset(x, y) x"),j(t,"number","parentIframe.scrollToOffset(x, y) y"),Pt(t,e,"scrollToOffset")},sendMessage(e,t){t&&j(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Pt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){$e=e,ct()},setWidthCalculationMethod(e){Ue=e,dt()},setTargetOrigin(e){j(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),A(`Set targetOrigin: %c${e}`,t),We=e},resize(e,t){e&&j(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&j(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),jt("parentIframe.resize()",`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){J("size()","resize()"),this.resize(e,t)}}),Ze.parentIFrame=Ze.parentIframe),function(){function e(e){Pt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){A(`Add event listener: %c${o}`,t),v(window.document,n,e)}!0===Te&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),Me=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(t){const n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,s)+parseInt(o.x,s),y:parseInt(n.top,s)+parseInt(o.y,s)}}function i(e){function i(e){const i=n(e);A(`Moving to in page link (%c#${r}%c) at x: %c${i.x}%c y: %c${i.y}`,t,o,t,o,t),Pt(i.y,i.x,"scrollToOffset")}const r=e.split("#")[1]||e,a=decodeURIComponent(r),s=document.getElementById(a)||document.getElementsByName(a)[0];void 0===s?(A(`In page link (#${r}) not found in iFrame, so sending to parent`),Pt(0,0,"inPageLink",`#${r}`)):i(s)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&v(e,"click",(t=>{t.preventDefault(),i(e.getAttribute("href"))}))}function l(){v(window,"hashchange",r)}function c(){setTimeout(r,128)}function d(){A("Setting up location.hash handlers"),a(),l(),c()}return Me.enable?1===Ie?V("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):d():A("In page linking not enabled"),{findTarget:i}}(),void 0===fe&&(fe=`${ce}px`),it("margin",(i="margin",(r=fe).includes("-")&&(H(`Negative CSS value ignored for ${i}`),r=""),r)),it("background",le),it("padding",pe),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body),A("Set HTML & body height: %cauto !important",t)}(),!0!==se&&A("Auto Resize disabled"),function(e){st({method:e,eventType:"After Print",eventName:"afterprint"}),st({method:e,eventType:"Before Print",eventName:"beforeprint"}),st({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=new Set,n=[];let i=!1,r=0;const a=t=>{C("Mutations observed:",t);for(const n of t){const{addedNodes:t,removedNodes:o}=n;for(const n of t)e.add(n);for(const t of o)e.delete(t)}},s=16,c=2,u=200;let m=1;function f(e){at(),tt(e),e.forEach(ft),e.clear()}function p(){const l=performance.now(),d=l-r,g=s*m+++c;if(d>g&&d<u)return C("Backed off due to heavy workload on callStack"),A(`Delay: %c${O(d)}ms %c> Delay limit: %c${g}ms`,t,o,t),setTimeout(p,s*m),void(r=l);m=1,n.forEach(a),n.length=0,e.size>0&&f(e),et(),Ye(),i=!1,jt(y,"Mutation Observed")}function g(e){n.push(e),i||(r=performance.now(),i=!0,requestAnimationFrame(p))}function h(){const e=new window.MutationObserver(g),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[d,l],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return A("Setup <body> MutationObserver"),e.observe(t,n),e}h()}(),A("Setup ResizeObserver"),Ne=new ResizeObserver(ut),Ne.observe(document.body),mt.add(document.body),ft(document.body),ge!==he&&(A("Setup OverflowObserver"),Ae=(e=>{const t=e.side||u,n=e.onChange||S,o={root:e.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||S,r=(e=!1)=>n(e),a=(e,n)=>0===e||e>n[t],s=(e,t)=>e.toggleAttribute(c,t),l=new IntersectionObserver((function(e){W("observation");for(const o of e){const{boundingClientRect:e,rootBounds:i,target:r}=o,l=e[t],c=a(l,i)&&!((n=r).hidden||null===n.offsetParent||"none"===n.style.display);s(r,c),c&&A("Overflowed:",r)}var n;i(r)}),o),d=new WeakSet;return function(e){A("Attached overflowObservers");for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=d.has(t);!n&&e?(l.observe(t),d.add(t)):N(!n,"Node already observed",t)}}})({onChange:Ke,root:document.documentElement,side:ge?u:m})),tt(ht(document)()),queueMicrotask(_e),A("Initialization complete"),jt("init","Init message from host page",void 0,void 0,a),document.title&&""!==document.title&&Pt(0,0,"title",document.title)}function Ye(){xe=document.querySelectorAll(`[${c}]:not([${d}]):not([${d}] *)`),ve=xe.length>0}function Ke(e){Ye(),(ve||e)&&(A("Observed Elements:",xe.length),jt(h,"Overflow updated"))}function et(){qe=document.querySelectorAll(`[${l}]`),ze=qe.length>0,A(`Tagged elements found: %c${ze}`,t)}function tt(e){ze||Ae(e)}let nt=0;function ot(){const e=document.querySelectorAll(`*[${d}]`);be=e.length>0,be&&e.length!==nt&&(function(e){const t=1===e.length?"":"s";H(`%c[${d}]%c found on %c${e.length}%c element${t}`,i,r,i,r)}(e),nt=e.length)}function it(e,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(e,n),C(`Set body ${e}: %c${n}`,t))}function rt(e,n,o){if(""!==o){A(`${e}: %c${o}`,t);for(const e of document.querySelectorAll(o))A(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function at(){rt("sizeSelector",l,Be),rt("ignoreSelector",d,Se)}function st(e){({add(t){function n(){jt(e.eventName,e.eventType)}T[t]=n,v(window,t,n,{passive:!0})},remove(e){const t=T[e];var n,o;delete T[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName),A(`${M(e.method)} event listener: %c${e.eventType}`,t)}function lt(e,n,o,i){return n!==e&&(e in o||(H(`${e} is not a valid option for ${i}CalculationMethod.`),e=n),e in k&&V(`<rb>Deprecated ${i}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${i} calculation method. It is recommended that you remove this option.`),A(`Set ${i} calculation method: %c${e}`,t)),e}function ct(){$e=lt($e,q,wt,"height")}function dt(){Ue=lt(Ue,G,$t,"width")}function ut(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;jt(g,`Element resized <${E(t)}>`)}const mt=new WeakSet;function ft(e){if(e.nodeType!==Node.ELEMENT_NODE)return;if(!mt.has(e)){const n=getComputedStyle(e)?.position;""!==n&&"static"!==n&&(Ne.observe(e),mt.add(e),A(`Attached resizeObserver: %c${E(e)}`,t))}const n=ht(e)();for(const e of n){if(mt.has(e)||e?.nodeType!==Node.ELEMENT_NODE)continue;const n=getComputedStyle(e)?.position;""!==n&&"static"!==n&&(Ne.observe(e),mt.add(e),A(`Attached resizeObserver: %c${E(e)}`,t))}}function pt(t){performance.mark(K);const n=M(t);let o=0,i=document.documentElement,r=ze?0:document.documentElement.getBoundingClientRect().bottom;const a=ze?qe:ve?xe:ht(document)();let s=a.length;for(const n of a)ze||!x||n.checkVisibility(e)?(o=n.getBoundingClientRect()[t]+parseFloat(getComputedStyle(n).getPropertyValue(`margin-${t}`)),o>r&&(r=o,i=n)):s-=1;return C(`${n} position calculated from:`,i),performance.mark(ee,{detail:{Side:n,len:s,hasTags:ze,logging:Ee}}),r}const gt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],ht=e=>()=>{ot();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 be&&t.push(`not([${d}])`,`not([${d}] *)`),e.querySelectorAll(t.join(":"))},yt={height:0,width:0},bt={height:0,width:0},vt=[t,o,t];function zt(e){function n(){return bt[i]=r,yt[i]=l,r}const o=e===wt,i=o?"height":"width",r=e.boundingClientRect(),a=Math.ceil(r),s=Math.floor(r),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e),c=`HTML: %c${r}px %cPage: %c${l}px`;let d=0;switch(!0){case!e.enabled():return l;case ze:C("Found element with data-iframe-size attribute"),d=e.taggedElement();break;case!ve&&0===bt[i]&&0===yt[i]:C(`Initial page size values: ${c}`,...vt),d=n();break;case De&&r===bt[i]&&l===yt[i]:C(`Size unchanged: ${c}`,...vt),d=Math.max(r,l);break;case 0===r:C(`Page is hidden: ${c}`,...vt),d=l;break;case!ve&&r!==bt[i]&&l<=yt[i]:C(`New <html> size: ${c} `,...vt),C(`Previous <html> size: %c${bt[i]}px`,t),d=n();break;case!o:d=e.taggedElement();break;case!ve&&r<bt[i]:C(`<html> size decreased: ${c}`,...vt),d=n();break;case l===s||l===a:C(`<html> size equals page size: ${c}`,...vt),d=n();break;case r>l:C(`Page size < <html> size: ${c}`,...vt),d=n();break;case ve:C("Found element overflowing <html> "),d=e.taggedElement();break;default:C(`Using <html> size: ${c}`,...vt),d=n()}return C(`Content ${i}: %c${d}px`,t),d+=function(e){const n=e.getOffset();return 0!==n&&C(`Page offsetSize: %c${n}px`,t),n}(e),d}const wt={enabled:()=>ge,getOffset:()=>te,auto:()=>zt(wt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,s)+parseInt(t.marginBottom,s)},bodyScroll:()=>document.body.scrollHeight,offset:()=>wt.bodyOffset(),custom:()=>z.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...gt(wt)),min:()=>Math.min(...gt(wt)),grow:()=>wt.max(),lowestElement:()=>pt(u),taggedElement:()=>pt(u)},$t={enabled:()=>he,getOffset:()=>ne,auto:()=>zt($t),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>z.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...gt($t)),min:()=>Math.min(...gt($t)),rightMostElement:()=>pt(m),scroll:()=>Math.max($t.bodyScroll(),$t.documentElementScroll()),taggedElement:()=>pt(m)},St=(e,t)=>!(Math.abs(e-t)<=Fe);function Ot(e,t){const n=e[t]();return e.enabled()&&void 0!==ae?function(e){const t=ae(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}function Mt(e,n,o,i,r){const a=o??Ot(wt,$e),s=i??Ot($t,Ue);switch(A(`Resize event: %c${n}`,t),!0){case ge&&St(we,a)||he&&St(Ve,s)||"init"===e:we=a,Ve=s;case e===p:Pt(we,Ve,e,r);break;case!e!==f&&(ge&&$e in Z||he&&Ue in Z):Tt(n);break;case e===g:case e===h:case e===y:A(b);break;default:C(b)}ie=!1}let kt=!1;const Et=$((()=>U(w(4)))),jt=L(((e,t,n,o,i)=>{re=performance.now(),ie=!0,W(e),!0!==kt&&(se||e===f?document.hidden?A("Page hidden - Ignored resize request"):(kt=!0,requestAnimationFrame((()=>{kt=!1})),Mt(e,t,n,o,i)):C("Resizing disabled"))}));function It(e){we=wt[$e](),Ve=$t[Ue](),Pt(we,Ve,e)}function Tt(e){const n=$e;$e=q,A(`Reset trigger event: %c${e}`,t),De?A("TriggerLock blocked calculation"):(De=!0,R("Trigger event lock on"),requestAnimationFrame((()=>{De=!1,R("Trigger event lock off")}))),It("reset"),$e=n}const Pt=L((function(e,o,i,r,a){Ie<-1||(W(i),void 0!==a?A(`Message targetOrigin: %c${a}`,t):a=We,function(){const s=`${Pe}:${e}:${o}:${i}${void 0===r?"":`:${r}`}`;if(Re)try{window.parent.iframeParentListener(D+s)}catch(e){if(1!==Ie)throw e;return void Et()}else Le.postMessage(D+s,a);ie&&A(function(){const e=O(performance.now()-re);return"init"===i?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),t),C(`Sending message to parent page via ${Re?"sameOrigin":"postMessage"}: %c%c${s}`,n,t)}(),B())})),At=L((function(e){W("onMessage");const{freeze:n}=Object,{parse:o}=JSON,i=e=>n(o(e)),r=e=>Pt(0,0,`${e}Stop`),a={init:function(){if("loading"===document.readyState)return void A("Page not ready, ignoring init message");const t=e.data.slice(13).split(":");Le=e.source,oe=e.origin,Xe(t),ye=!1,setTimeout((()=>{Oe=!1}),128)},reset(){Oe?A("Page reset ignored by init"):(A("Page size reset by host page"),It("resetPage"))},resize(){jt(f,"Parent window requested size check")},moveToAnchor(){Me.findTarget(l())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=l();A("PageInfo received from parent:",i(e)),Qe?setTimeout((()=>Qe(o(e)))):r("pageInfo")},parentInfo(){const e=i(l());A("ParentInfo received from parent:",e),Ge?setTimeout((()=>Ge(e))):r("parentInfo")},message(){const e=l();A("onMessage called from parent:%c",t,i(e)),setTimeout((()=>Je(o(e))))}},s=()=>e.data.split("]")[1].split(":")[0],l=()=>e.data.slice(e.data.indexOf(":")+1),c=()=>e.data.split(":")[2]in{true:1,false:1};function d(){const t=s();W(t),t in a?a[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||c()||H(`Unexpected message (${e.data})`)}D===`${e.data}`.slice(0,13)&&function(){if(!1!==ye)return c()?(F(s()),W("init"),void a.init()):void A(`Ignored message of type "${s()}". Received before initialization.`);d()}()}));function xt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?H("Already setup"):(window.iframeChildListener=e=>setTimeout((()=>At({data:e,sameOrigin:!0}))),v(window,"message",At),v(window,"readystatechange",xt),xt())}();
20
+ import e,{HIGHLIGHT as t,ITALIC as n,FOREGROUND as o,BOLD as r,NORMAL as i}from"auto-console-group";const a="5.4.6-beta.4",s=10,l="data-iframe-size",c="data-iframe-overflowed",d="data-iframe-ignore",u="bottom",m="right",f="autoResizeEnabled",p=Symbol("sizeChanged"),h="manualResize",g="parentResize",y={[h]:1,[g]:1},b="setOffsetSize",v="resizeObserver",z="overflowObserver",w="mutationObserver",$="No change in content size detected",S="init",O=(e,t,n,o)=>e.addEventListener(t,n,o||!1),M=["<iy><yi>Puchspk Spjluzl Rlf</><iy><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."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const k=e=>(e=>e.replace(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(M[e]),E=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},j=e=>e,I=e=>Math.round(1e3*e)/1e3,T=e=>e.charAt(0).toUpperCase()+e.slice(1),P=e=>""!=`${e}`&&void 0!==e;function A(e){switch(!0){case!P(e):return"";case P(e.id):return`${e.nodeName}#${e.id}`;case P(e.name):return`${e.nodeName} (${e.name}`;case P(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const C=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${T(t)}`)};let x=!0;var R;const N=(R=e,R?.__esModule?R.default:R)({label:"iframeResizer(child)"});const q=(B="log",(...e)=>!x||N[B](...e));var B;const L=q,{assert:W,debug:D,endAutoGroup:F,error:H,errorBoundary:V,event:U,label:Z,purge:J,warn:_}=N,Q=e=>{return N.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},G=Q,X=(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)=>Q(t))),Y=X("Method"),K=X("Method","replaced with"),ee=X("Option"),te=e=>t=>void 0===t?void 0:e(t),ne=te((e=>"true"===e)),oe=te(Number),re="--ifr-start",ie="--ifr-end",ae=[],se=new WeakSet,le=e=>"object"==typeof e&&se.add(e);let ce={},de=0;const ue=setInterval((()=>{if(ae.length<10)return;if(ce.hasTags&&ce.len<25)return;ae.sort();const e=Math.min(ae.reduce(((e,t)=>e+t),0)/ae.length,ae[Math.floor(ae.length/2)]),t=I(e);t>de&&(de=t,U("performanceObserver"),q("Mean time:",I(ae[Math.floor(ae.length/2)])),q("Median time:",I(ae.reduce(((e,t)=>e+t),0)/ae.length)),q("Average time:",t),q("Max time:",I(Math.max(...ae)))),e<=4||(clearInterval(ue),Q(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${I(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${ce.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))}),5e3);function me(e){e.getEntries().forEach((e=>{if(e.name===ie){const{duration:t}=performance.measure("--ifr-measure",re,ie);ce=e.detail,ae.push(t),ae.length>100&&ae.shift()}}))}function fe(){new PerformanceObserver(me).observe({entryTypes:["mark"]}),le(document.documentElement),le(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",fe):fe());const pe=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},he=pe("function"),ge=pe("number"),ye=pe("string");"undefined"!=typeof window&&function(){const e={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},M={height:()=>(_("Custom height calculation function not defined"),Mt.auto()),width:()=>(_("Custom width calculation function not defined"),kt.auto())},P={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},R={},B="checkVisibility"in window,H="auto",J="[iFrameSizer]",X="scroll";let te,ae,se,le,ce,de,ue,me=!0,fe="",pe=0,be="",ve="",ze=!0,we=!1,$e=!0,Se=!1,Oe=!1,Me=!1,ke=1,Ee=H,je="",Ie=!0,Te={},Pe=!0,Ae=!1,Ce="",xe=0,Re=!1,Ne="",qe=j,Be=[],Le="child",We=null,De=!1,Fe="",He=[],Ve=window.parent,Ue="*",Ze=0,Je=!1,_e=1,Qe=X,Ge=window,Xe=()=>{_("onMessage function not defined")},Ye=()=>{},Ke=null,et=null;function tt(e){var n,r,i;!function(e){Ne=e[0]??Ne,pe=oe(e[1])??pe,we=ne(e[2])??we,Ae=ne(e[3])??Ae,me=ne(e[6])??me,be=e[7]??be,Ee=e[8]??Ee,fe=e[9]??fe,ve=e[10]??ve,Ze=oe(e[11])??Ze,Te.enable=ne(e[12])??!1,Le=e[13]??Le,Qe=e[14]??Qe,Re=ne(e[15])??Re,te=oe(e[16])??te,ae=oe(e[17])??ae,ze=ne(e[18])??ze,Ce=e[19]??Ce,de=e[20]??de,xe=oe(e[21])??xe,Pe=ne(e[23])??Pe}(e),n={id:Ne,enabled:Ae,expand:Pe},N.label(`${n.id}`),N.expand(n.expand),x=n.enabled,q(`Initialising iframe v${a} ${window.location.href}`),function(){function e(e){q("Reading data from page:",e),ue=he(e,"onBeforeResize")??ue,Xe=he(e,"onMessage")??Xe,Ye=he(e,"onReady")??Ye,"number"==typeof e?.offset&&(ee("offset","offsetSize"),ze&&(te=ge(e,"offset")??te),we&&(ae=ge(e,"offset")??ae)),"number"==typeof e?.offsetSize&&(ze&&(te=ge(e,"offsetSize")??te),we&&(ae=ge(e,"offsetSize")??ae)),je=ye(e,"ignoreSelector")??je,Fe=ye(e,"sizeSelector")??Fe,Ue=ye(e,"targetOrigin")??Ue,Ee=e?.heightCalculationMethod||Ee,Qe=e?.widthCalculationMethod||Qe}function n(e,t){return"function"==typeof e&&(Q(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}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.`),M[t]=e,e="custom"),e}if(1===xe)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(e(o),Ee=n(Ee,"height"),Qe=n(Qe,"width"),L(`Set targetOrigin for parent: %c${Ue}`,t))}(),dt(),function(){try{De=1===xe||"iframeParentListener"in window.parent}catch(e){q("Cross domain iframe detected")}}(),xe<0?G(`${k(xe+2)}${k(2)}`):de?.codePointAt(0)>4||xe<2&&G(k(3)),de&&""!==de&&"false"!==de?de!==a&&Q(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${de} - Child page: ${a}.\n`):Q("<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"),ft(),pt(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(l,!0)}));t("data-iframe-height"),t("data-iframe-width"),e&&Q("<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&&Q("<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"),rt(),1!==xe&&(Ge.parentIframe=Object.freeze({autoResize:e=>(C(e,"boolean","parentIframe.autoResize(enable) enable"),!1===we&&!1===ze?(U(f),Q("Auto Resize can not be changed when <b>direction</> is set to 'none'."),!1):(!0===e&&!1===me?(me=!0,queueMicrotask((()=>Pt(f,"Auto Resize enabled")))):!1===e&&!0===me&&(me=!1),Ct(0,0,"autoResize",JSON.stringify(me)),me)),close(){Ct(0,0,"close")},getId:()=>Ne,getOrigin:()=>(Y("getOrigin()","getParentOrigin()"),se),getParentOrigin:()=>se,getPageInfo(e){if("function"==typeof e)return Ke=e,Ct(0,0,"pageInfo"),void K("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");Ke=null,Ct(0,0,"pageInfoStop")},getParentProps:e=>(C(e,"function","parentIframe.getParentProps(callback) callback"),et=e,Ct(0,0,"parentInfo"),()=>{et=null,Ct(0,0,"parentInfoStop")}),getParentProperties(e){Y("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){C(e,"string","parentIframe.moveToAnchor(anchor) anchor"),Te.findTarget(e)},reset(){!function(){const e=Ee;Ee=H,q("Reset trigger event: %cparentIframe.reset",t),Je?q("TriggerLock blocked calculation"):(Je=!0,D("Trigger event lock on"),requestAnimationFrame((()=>{Je=!1,D("Trigger event lock off")}))),At("reset"),Ee=e}()},setOffsetSize(e){C(e,"number","parentIframe.setOffsetSize(offset) offset"),te=e,ae=e,Pt(b,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){C(e,"number","parentIframe.scrollBy(x, y) x"),C(t,"number","parentIframe.scrollBy(x, y) y"),Ct(t,e,"scrollBy")},scrollTo(e,t){C(e,"number","parentIframe.scrollTo(x, y) x"),C(t,"number","parentIframe.scrollTo(x, y) y"),Ct(t,e,"scrollTo")},scrollToOffset(e,t){C(e,"number","parentIframe.scrollToOffset(x, y) x"),C(t,"number","parentIframe.scrollToOffset(x, y) y"),Ct(t,e,"scrollToOffset")},sendMessage(e,t){t&&C(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Ct(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){Ee=e,ft()},setWidthCalculationMethod(e){Qe=e,pt()},setTargetOrigin(e){C(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),q(`Set targetOrigin: %c${e}`,t),Ue=e},resize(e,t){e&&C(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&C(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),Pt(h,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){Y("size()","resize()"),this.resize(e,t)}}),Ge.parentIFrame=Ge.parentIframe),function(){function e(e){Ct(0,0,e.type,`${e.screenY}:${e.screenX}`)}function n(n,o){q(`Add event listener: %c${o}`,t),O(window.document,n,e)}!0===Re&&(n("mouseenter","Mouse Enter"),n("mouseleave","Mouse Leave"))}(),Te=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(t){const n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,s)+parseInt(o.x,s),y:parseInt(n.top,s)+parseInt(o.y,s)}}function r(e){function r(e){const r=n(e);q(`Moving to in page link (%c#${i}%c) at x: %c${r.x}%c y: %c${r.y}`,t,o,t,o,t),Ct(r.y,r.x,"scrollToOffset")}const i=e.split("#")[1]||e,a=decodeURIComponent(i),s=document.getElementById(a)||document.getElementsByName(a)[0];void 0===s?(q(`In page link (#${i}) not found in iFrame, so sending to parent`),Ct(0,0,"inPageLink",`#${i}`)):r(s)}function i(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&r(t)}function a(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&O(e,"click",(t=>{t.preventDefault(),r(e.getAttribute("href"))}))}function l(){O(window,"hashchange",i)}function c(){setTimeout(i,128)}function d(){q("Setting up location.hash handlers"),a(),l(),c()}return Te.enable?1===xe?Q("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):d():q("In page linking not enabled"),{findTarget:r}}(),void 0===be&&(be=`${pe}px`),lt("margin",(r="margin",(i=be).includes("-")&&(_(`Negative CSS value ignored for ${r}`),i=""),i)),lt("background",fe),lt("padding",ve),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body),q("Set HTML & body height: %cauto !important",t)}(),!0!==me&&q("Auto Resize disabled"),function(e){ut({method:e,eventType:"After Print",eventName:"afterprint"}),ut({method:e,eventType:"Before Print",eventName:"beforeprint"}),ut({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=new Set,n=[];let r=!1,i=0;const a=t=>{L("Mutations observed:",t);for(const n of t){const{addedNodes:t,removedNodes:o}=n;for(const n of t)e.add(n);for(const t of o)e.delete(t)}},s=16,c=2,u=200;let m=1;function f(e){dt(),it(e),e.forEach(yt),e.clear()}function p(){const l=performance.now(),d=l-i,h=s*m+++c;if(d>h&&d<u)return L("Backed off due to heavy workload on callStack"),q(`Delay: %c${I(d)}ms %c> Delay limit: %c${h}ms`,t,o,t),setTimeout(p,s*m),void(i=l);m=1,n.forEach(a),n.length=0,e.size>0&&f(e),rt(),nt(),r=!1,Pt(w,"Mutation Observed")}function h(e){n.push(e),r||(i=performance.now(),r=!0,requestAnimationFrame(p))}function g(){const e=new window.MutationObserver(h),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[d,l],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return q("Setup <body> MutationObserver"),e.observe(t,n),e}g()}(),q("Setup ResizeObserver"),We=new ResizeObserver(ht),We.observe(document.body),gt.add(document.body),yt(document.body),ze!==we&&(q("Setup OverflowObserver"),qe=(e=>{const t=e.side||u,n=e.onChange||j,o={root:e.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||j,i=(e=!1)=>n(e),a=(e,n)=>0===e||e>n[t],s=(e,t)=>e.toggleAttribute(c,t),l=new IntersectionObserver((function(e){for(const o of e){const{boundingClientRect:e,rootBounds:r,target:i}=o,l=e[t],c=a(l,r)&&!((n=i).hidden||null===n.offsetParent||"none"===n.style.display);s(i,c)}var n;r(i)}),o),d=new WeakSet;return function(e){q("Attached overflowObservers");for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=d.has(t);!n&&e?(l.observe(t),d.add(t)):W(!n,"Node already observed",t)}}})({onChange:ot,root:document.documentElement,side:ze?u:m})),it(zt(document)()),queueMicrotask(Ye),q("Initialization complete"),Pt(S,"Init message from host page",void 0,void 0,a),document.title&&""!==document.title&&Ct(0,0,"title",document.title)}function nt(){Be=document.querySelectorAll(`[${c}]:not([${d}]):not([${d}] *)`),Oe=Be.length>0}function ot(e){nt(),(Oe||e)&&(Oe?L("Overflowed Elements:",...Be):L("Overflow removed"),Pt(z,"Overflow updated"))}function rt(){He=document.querySelectorAll(`[${l}]`),Me=He.length>0,q(`Tagged elements found: %c${Me}`,t)}function it(e){Me||qe(e)}let at=0;function st(){const e=document.querySelectorAll(`*[${d}]`);Se=e.length>0,Se&&e.length!==at&&(function(e){const t=1===e.length?"":"s";_(`%c[${d}]%c found on %c${e.length}%c element${t}`,r,i,r,i)}(e),at=e.length)}function lt(e,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(e,n),L(`Set body ${e}: %c${n}`,t))}function ct(e,n,o){if(""!==o){q(`${e}: %c${o}`,t);for(const e of document.querySelectorAll(o))q(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}}function dt(){ct("sizeSelector",l,Fe),ct("ignoreSelector",d,je)}function ut(e){({add(t){function n(){Pt(e.eventName,e.eventType)}R[t]=n,O(window,t,n,{passive:!0})},remove(e){const t=R[e];var n,o;delete R[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName),q(`${T(e.method)} event listener: %c${e.eventType}`,t)}function mt(e,n,o,r){return n!==e&&(e in o||(_(`${e} is not a valid option for ${r}CalculationMethod.`),e=n),e in P)&&Q(`<rb>Deprecated ${r}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${r} calculation method. It is recommended that you ${de?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),q(`Set ${r} calculation method: %c${e}`,t),e}function ft(){Ee=mt(Ee,H,Mt,"height")}function pt(){Qe=mt(Qe,X,kt,"width")}function ht(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Pt(v,`Element resized <${A(t)}>`)}const gt=new WeakSet;function yt(e){if(e.nodeType!==Node.ELEMENT_NODE)return;if(!gt.has(e)){const n=getComputedStyle(e)?.position;""!==n&&"static"!==n&&(We.observe(e),gt.add(e),q(`Attached resizeObserver: %c${A(e)}`,t))}const n=zt(e)();for(const e of n){if(gt.has(e)||e?.nodeType!==Node.ELEMENT_NODE)continue;const n=getComputedStyle(e)?.position;""!==n&&"static"!==n&&(We.observe(e),gt.add(e),q(`Attached resizeObserver: %c${A(e)}`,t))}}function bt(t){performance.mark(re);const n=T(t);let o=0,r=document.documentElement,i=Me?0:document.documentElement.getBoundingClientRect().bottom;const a=Me?He:Oe?Be:zt(document)();let s=a.length;for(const n of a)Me||!B||n.checkVisibility(e)?(o=n.getBoundingClientRect()[t]+parseFloat(getComputedStyle(n).getPropertyValue(`margin-${t}`)),o>i&&(i=o,r=n)):s-=1;return L(`${n} position calculated from:`,r),performance.mark(ie,{detail:{Side:n,len:s,hasTags:Me,logging:Ae}}),i}const vt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],zt=e=>()=>{st();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 Se&&t.push(`not([${d}])`,`not([${d}] *)`),e.querySelectorAll(t.join(":"))},wt={height:0,width:0},$t={height:0,width:0},St=[t,o,t];function Ot(e){function n(){return $t[r]=i,wt[r]=l,i}const o=e===Mt,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 d=0;switch(!0){case!e.enabled():return l;case Me:L("Found element with data-iframe-size attribute"),d=e.taggedElement();break;case!Oe&&0===$t[r]&&0===wt[r]:L(`Initial page size values: ${c}`,...St),d=n();break;case Je&&i===$t[r]&&l===wt[r]:L(`Size unchanged: ${c}`,...St),d=Math.max(i,l);break;case 0===i:L(`Page is hidden: ${c}`,...St),d=l;break;case!Oe&&i!==$t[r]&&l<=wt[r]:L(`New <html> size: ${c} `,...St),L(`Previous <html> size: %c${$t[r]}px`,t),d=n();break;case!o:d=e.taggedElement();break;case!Oe&&i<$t[r]:L(`<html> size decreased: ${c}`,...St),d=n();break;case l===s||l===a:L(`<html> size equals page size: ${c}`,...St),d=n();break;case i>l:L(`Page size < <html> size: ${c}`,...St),d=n();break;case Oe:L("Found element overflowing <html> "),d=e.taggedElement();break;default:L(`Using <html> size: ${c}`,...St),d=n()}return L(`Content ${r}: %c${d}px`,t),d+=function(e){const n=e.getOffset();return 0!==n&&L(`Page offsetSize: %c${n}px`,t),n}(e),d}const Mt={enabled:()=>ze,getOffset:()=>te,auto:()=>Ot(Mt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,s)+parseInt(t.marginBottom,s)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Mt.bodyOffset(),custom:()=>M.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...vt(Mt)),min:()=>Math.min(...vt(Mt)),grow:()=>Mt.max(),lowestElement:()=>bt(u),taggedElement:()=>bt(u)},kt={enabled:()=>we,getOffset:()=>ae,auto:()=>Ot(kt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>M.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...vt(kt)),min:()=>Math.min(...vt(kt)),rightMostElement:()=>bt(m),scroll:()=>Math.max(kt.bodyScroll(),kt.documentElementScroll()),taggedElement:()=>bt(m)},Et=(e,t)=>!(Math.abs(e-t)<=Ze);function jt(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 It=!1;const Tt=E((()=>G(k(4)))),Pt=V(((e,n,o,r,i)=>{if(ce=performance.now(),le=!0,U(e),!0!==It)return me||e in y?void(document.hidden?q("Page hidden - Ignored resize request"):(It=!0,requestAnimationFrame((()=>{It=!1})),function(e,n,o,r,i){const a=o??jt(Mt,Ee),s=r??jt(kt,Qe),l=ze&&Et(ke,a)||we&&Et(_e,s)?p:e;switch(q(`Resize event: %c${n}`,t),l){case S:case f:case p:ke=a,_e=s;case b:Ct(ke,_e,e,i);break;case v:case z:case w:q($);break;default:L($)}le=!1}(e,n,o,r,i))):(L("Resizing disabled"),void F())}));function At(e){ke=Mt[Ee](),_e=kt[Qe](),Ct(ke,_e,e)}const Ct=V((function(e,o,r,i,a){xe<-1||(U(r),void 0!==a?q(`Message targetOrigin: %c${a}`,t):a=Ue,function(){const s=`${Ne}:${e}:${o}:${r}${void 0===i?"":`:${i}`}`;if(De)try{window.parent.iframeParentListener(J+s)}catch(e){if(1!==xe)throw e;return void Tt()}else Ve.postMessage(J+s,a);le&&q(function(){const e=I(performance.now()-ce);return r===S?`Initialised iFrame in %c${e}ms`:`Size calculated in %c${e}ms`}(),t),L(`Sending message to parent page via ${De?"sameOrigin":"postMessage"}: %c%c${s}`,n,t)}(),F())})),xt=V((function(e){U("onMessage");const{freeze:n}=Object,{parse:o}=JSON,r=e=>n(o(e)),i=e=>Ct(0,0,`${e}Stop`),a={init:function(){if("loading"===document.readyState)return void q("Page not ready, ignoring init message");const t=e.data.slice(13).split(":");Ve=e.source,se=e.origin,tt(t),$e=!1,setTimeout((()=>{Ie=!1}),128)},reset(){Ie?q("Page reset ignored by init"):(q("Page size reset by host page"),At("resetPage"))},resize(){q("Resize requested by host page"),"auto"===Ee&&"auto"===Qe&&Q("<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As the size detection no longer requires a trigger event from the parent page."),Pt(g,"Parent window requested size check")},moveToAnchor(){Te.findTarget(l())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=l();q("PageInfo received from parent:",r(e)),Ke?setTimeout((()=>Ke(o(e)))):i("pageInfo")},parentInfo(){const e=r(l());q("ParentInfo received from parent:",e),et?setTimeout((()=>et(e))):i("parentInfo")},message(){const e=l();q("onMessage called from parent:%c",t,r(e)),setTimeout((()=>Xe(o(e))))}},s=()=>e.data.split("]")[1].split(":")[0],l=()=>e.data.slice(e.data.indexOf(":")+1),c=()=>e.data.split(":")[2]in{true:1,false:1};function d(){const t=s();U(t),t in a?a[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||c()||_(`Unexpected message (${e.data})`)}J===`${e.data}`.slice(0,13)&&function(){if(!1!==$e)return c()?(Z(s()),U(S),void a.init()):void q(`Ignored message of type "${s()}". Received before initialization.`);d()}()}));function Rt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?_("Already setup"):(window.iframeChildListener=e=>setTimeout((()=>xt({data:e,sameOrigin:!0}))),O(window,"message",xt),O(window,"readystatechange",Rt),Rt())}();
21
21
  //# sourceMappingURL=index.esm.js.map