@iframe-resizer/child 6.0.0-beta.5 → 6.0.0-beta.6

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/README.md CHANGED
@@ -25,4 +25,4 @@ yarn add @iframe-resizer/child
25
25
 
26
26
  ---
27
27
 
28
- _iframe-resizer version 6.0.0-beta.5 2026-04-10 - 15:33:04.965Z_
28
+ _iframe-resizer version 6.0.0-beta.6 2026-04-10 - 16:39:21.189Z_
package/index.cjs.js CHANGED
@@ -1,28 +1,21 @@
1
- "use strict";const n=require("@iframe-resizer/common"),s=require("auto-console-group");let ue=!0,He=n.LABEL;const Rt=n.esModuleInterop(s),F=Rt({label:`${n.LABEL}(child)`,expand:!1});function Tt(e){He=e.id||n.LABEL,F.label(`${He}`),F.expand(e.expand),ue=e.enabled}const Ye=e=>(...t)=>ue?F[e](...t):!0,d=Ye("log"),f=d,Q=Ye("debug");function bt(e,t){console.info(`%ciframe-resizer ${e}`,ue||t<1?n.BOLD:s.NORMAL)}const{assert:wt,endAutoGroup:G,error:je,errorBoundary:ge,event:h,label:Or,purge:Sr,warn:_}=F,Qe=n.createFormatAdvise(n.id),R=(...e)=>F.warn(...e.map(Qe)),vt=(...e)=>console.warn(...e.map(Qe)),me=n.deprecate((e,t)=>R(t));me("Method");me("Method","replaced with");me("Option");const he=[];function Ke(e,t){d(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const Je=(e,t,o,r)=>{e.removeEventListener(t,o,r),Ke("Removed",t)},N=(e,t,o,r=!1)=>{e.addEventListener(t,o,r),he.push(()=>Je(e,t,o,r)),Ke("Added",t)},c={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let Ae=!1;function Me(e){const t=window?.iframeResizer?.targetOrigin||"*",o=Array.isArray(t)?t:[t];for(const r of o)e.postMessage(n.CHILD_READY_MESSAGE,r)}function Ne(){if(document.readyState==="loading"||!c.firstRun||Ae)return;const{parent:e,top:t}=window;h("ready"),d("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),Me(e),e!==t&&Me(t),Ae=!0}const Le="iframeResize",yt=e=>n.MESSAGE_ID===`${e.data}`.slice(0,n.MESSAGE_ID_LENGTH),Ht=()=>Le in window||window.jQuery!==void 0&&Le in window.jQuery.prototype,At=e=>e.data.split(n.SEPARATOR)[2]in{true:1,false:1},Mt=()=>[document.documentElement,document.body],Nt=["min-height","min-width","max-height","max-width"],Ge=new Set,Lt=e=>!!e&&e!=="0px"&&e!==n.AUTO&&e!==n.NONE,Xe=e=>e.tagName?e.tagName.toLowerCase():"unknown",et=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Gt=(e,t)=>Lt(et(e,t));function zt(e,t){const o=e.style.getPropertyValue(t);return o?{source:"an inline style attribute",value:o}:null}function $t({href:e}){Ge.has(e)||(d("Unable to access stylesheet:",e),Ge.add(e))}function _t(e,t){for(const o of document.styleSheets)try{for(const r of o.cssRules||[]){if(!("selectorText"in r))continue;const i=r;if(!e.matches(i.selectorText))continue;const u=i.style.getPropertyValue(t);if(!u)continue;const{ownerNode:l}=o;return{source:l instanceof Element&&l.tagName==="STYLE"?"an inline <style> block":`stylesheet (${o.href})`,value:u}}}catch{$t(o)}return{source:"cross-origin stylesheet",value:et(e,t)}}const kt=(e,t)=>zt(e,t)||_t(e,t),Ct=(e,t)=>{const{source:o,value:r}=kt(e,t),i=Xe(e);R(`The <b>${t}</> CSS property is set to <b>${r}</> on the <b><${i}></> element via ${o}. This may cause issues with the correct operation of <i>iframe-resizer</>.
2
-
3
- If 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 Dt(){for(const e of Mt())for(const t of Nt)d(`Checking <${Xe(e)}> for blocking CSS: ${t}`),Gt(e,t)&&Ct(e,t)}const Pt=({calculateWidth:e,calculateHeight:t})=>e===t,a={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:n.AUTO,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:n.AUTO,onBeforeResize:void 0,onMessage:()=>{_("onMessage function not defined")},onReady:()=>{}};function Bt(){try{c.sameOrigin=a.mode===1||"iframeParentListener"in window.parent}catch{d("Cross domain iframe detected")}}let ze=0;function Ft(e){const t=e.length===1?"":"s";_(`%c[${n.IGNORE_ATTR}]%c found on %c${e.length}%c element${t}`,s.BOLD,s.NORMAL,s.BOLD,s.NORMAL)}function Ut(){const e=document.querySelectorAll(`*[${n.IGNORE_ATTR}]`),t=e.length>0;return t&&e.length!==ze&&(Ft(e),ze=e.length),t}function xt(e,t,o){(!n.isDef(o)||t>-1&&e>t)&&(bt(`v${n.VERSION} (${n.getModeLabel(e)})`,e),e===0&&vt(n.getModeData(3)))}function Vt({key:e,key2:t,mode:o,version:r}){const i=o,u=n.isDef(e)?n.setMode({key:e}):-1,l=n.isDef(t)?n.setMode({key:t}):-1;let g;switch(o=Math.max(u,l),o){case-2:case-1:g=`${n.getModeData(Math.min(u,l)+2)}${n.getModeData(2)}`,c.firstRun=!1;break;case 1:case 2:case 3:g=n.getModeData(6);break;case 4:g=n.getModeData(7);break;case 5:g=n.getModeData(8);break}if(o>=0&&xt(o,i,r),(!n.isDef(r)||!c.firstRun)&&(g&&R(g),o<0))throw R(n.getModeData(9)),g.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");a.mode=o}const Wt="BackCompat",Zt=`<rb>Quirks Mode Detected</>
4
-
5
- This 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</>.
6
-
7
- For more information see <u>https://iframe-resizer.com/quirks-mode</>.
8
- `;function qt(){document.compatMode===Wt&&R(Zt)}const Yt="complete";let $e=!1;function tt(e){document.readyState===Yt?n.isolateUserCode(e):$e||N(document,n.READY_STATE_CHANGE,()=>tt(e)),$e=!0}const jt=()=>{f(`Set targetOrigin for parent: %c${a.targetOrigin}`,s.HIGHLIGHT),a.autoResize!==!0&&d("Auto Resize disabled")};function nt(){c.taggedElements=document.querySelectorAll(`[${n.SIZE_ATTR}]`),c.hasTags=c.taggedElements.length>0,d(`Tagged elements found: %c${c.hasTags}`,s.HIGHLIGHT)}const Qt=`<rb>Legacy version detected on parent page</>
9
-
10
- Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
11
-
12
- See <u>https://iframe-resizer.com/setup/</> for more details.
13
- `,Kt=e=>`<b>Version mismatch</>
14
-
15
- The parent and child pages are running different versions of <i>iframe resizer</>.
16
-
17
- Parent page: ${e} - Child page: ${n.VERSION}.
18
- `;function Jt({version:e}){!e||e===""||e===n.FALSE?R(Qt):e!==n.VERSION&&R(Kt(e))}const Xt=n.once(()=>R(n.getModeData(4)));function en(e){if(!c.timerActive)return;const t=n.round(performance.now()-c.totalTime),o=e===n.INIT?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`;d(o,s.HIGHLIGHT)}function tn(e){return e===void 0?e=a.targetOrigin:d(`Message targetOrigin: %c${e}`,s.HIGHLIGHT),e}function nn(e,t){const{mode:o}=a,{sameOrigin:r,target:i}=c;if(r)try{window.parent.iframeParentListener(n.MESSAGE_ID+e)}catch(u){if(n.checkMode(o))Xt();else throw new Error(u);return!1}else{wt(i,"Internal error: postMessage target is undefined");const u=tn(t),l=Array.isArray(u)?u:[u];for(const g of l)i.postMessage(n.MESSAGE_ID+e,g)}return!0}function ot(e,t,o,r,i){const{parentId:u}=a,{sameOrigin:l}=c,g=`${e}:${t}`,p=`${u}:${g}:${o}${r===void 0?"":`:${r}`}`;a.mode<-1||!nn(p,i)||(en(o),f(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${p}`,s.ITALIC,s.HIGHLIGHT))}const O=ge((e,t,o,r,i)=>{h(o),ot(e,t,o,r,i),G()}),on=e=>O(0,0,e.type,`${e.screenY}:${e.screenX}`);function _e(e,t){d(`Add event listener: %c${t}`,s.HIGHLIGHT),N(window.document,e,on)}function rn({mouseEvents:e}){e===!0&&(_e(n.MOUSE_ENTER,"Mouse Enter"),_e(n.MOUSE_LEAVE,"Mouse Leave"))}const sn=()=>O(0,0,n.BEFORE_UNLOAD);function cn({persisted:e}){e||sn(),h(n.PAGE_HIDE),f("Page persisted:",e),!e&&he.forEach(n.invoke)}const an=()=>N(window,n.lower(n.PAGE_HIDE),cn),ke=(e,t)=>!(Math.abs(e-t)<=a.tolerance);function dn(e,t){const{calculateHeight:o,calculateWidth:r}=a,{height:i,width:u}=c;return o&&ke(i,e)||r&&ke(u,t)}const A=[s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT],Y={height:0,width:0},$={height:0,width:0};function z(e,t,o){return $[e]=t,Y[e]=o,t}function ln(e){const t=e.getOffset();return t!==0&&f(`Page offsetSize: %c${t}px`,s.HIGHLIGHT),t}const fn=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function rt(e){const{hasOverflow:t,hasTags:o,triggerLocked:r}=c,i=e.label,u=i===n.HEIGHT,l=e.boundingClientRect(),g=Math.ceil(l),p=Math.floor(l),m=fn(e),S=`HTML: %c${l}px %cPage: %c${m}px`;let E;switch(!0){case!e.enabled():return Math.max(m,n.MIN_SIZE);case o:f("Found element with data-iframe-size attribute"),E=e.taggedElement();break;case(!t&&c.firstRun&&$[i]===0&&Y[i]===0):f(`Initial page size values: ${S}`,...A),E=z(i,l,m);break;case(r&&l===$[i]&&m===Y[i]):f(`Size unchanged: ${S}`,...A),E=Math.max(l,m);break;case(l===0&&m!==0):f(`Page is hidden: ${S}`,...A),E=m;break;case(!t&&l!==$[i]&&m<=Y[i]):f(`New <html> size: ${S} `,...A),f(`Previous <html> size: %c${$[i]}px`,s.HIGHLIGHT),E=z(i,l,m);break;case!u:E=e.taggedElement();break;case(!t&&l<$[i]):f(`<html> size decreased: ${S}`,...A),E=z(i,l,m);break;case(m===p||m===g):f(`<html> size equals page size: ${S}`,...A),E=z(i,l,m);break;case l>m:f(`Page size < <html> size: ${S}`,...A),E=z(i,l,m);break;case t:f("Found elements possibly overflowing <html> "),E=e.taggedElement();break;default:f(`Using <html> size: ${S}`,...A),E=z(i,l,m)}return f(`Content ${i}: %c${E}px`,s.HIGHLIGHT),E+=ln(e),Math.max(E,n.MIN_SIZE)}const un=1e3,gn=5*un,mn=4,hn=10,En=100,Ee="--ifr-start",K="--ifr-end",st="--ifr-measure",I=[];let j={},Ce=0,ce;function it(){try{performance.clearMarks(Ee),performance.clearMarks(K),performance.clearMeasures(st)}catch{}}function In(){ce=setInterval(()=>{if(I.length<hn||j.hasTags&&j.len<25)return;I.sort();const e=Math.min(I.reduce((o,r)=>o+r,0)/I.length,I[Math.floor(I.length/2)]),t=n.round(e);t>Ce&&(Ce=t,h("performanceObserver"),d("Mean time:",n.round(I[Math.floor(I.length/2)])),d("Median time:",n.round(I.reduce((o,r)=>o+r,0)/I.length)),d("Average time:",t),d("Max time:",n.round(Math.max(...I)))),it(),!(e<=mn)&&(clearInterval(ce),R(`<rb>Performance Warning</>
19
-
20
- Calculating the page size is taking an excessive amount of time (${n.round(e)}ms).
21
-
22
- To improve performance add the <b>data-iframe-size</> attribute to the ${j.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},gn)}function pn(e){e.getEntries().forEach(t=>{if(t.name===K)try{const{duration:o}=performance.measure(st,Ee,K);j=t.detail,I.push(o),I.length>En&&I.shift()}catch{}})}function On(){f("Attached%c PerformanceObserver%c to page",s.HIGHLIGHT,s.FOREGROUND);const e=new PerformanceObserver(pn);return e.observe({entryTypes:["mark"]}),In(),{disconnect:()=>{it(),clearInterval(ce),e.disconnect(),f("Detached%c PerformanceObserver",s.HIGHLIGHT)}}}const Sn=e=>`:not(${e})`,Rn=`* ${Array.from(n.IGNORE_TAGS).map(Sn).join("")}`,Ie=e=>e.querySelectorAll(Rn);function Tn(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:o,taggedElements:r}=c;return t?r:e?Array.from(o):Ie(document.documentElement)}function bn(e,t){const o=`margin-${t}`;let r,i=document.documentElement,u=c.hasTags?n.MIN_SIZE:document.documentElement.getBoundingClientRect().bottom;for(const l of e)r=l.getBoundingClientRect()[t]+parseFloat(getComputedStyle(l).getPropertyValue(o)),r>u&&(u=r,i=l);return{maxEl:i,maxVal:u}}function ct(e){performance.mark(Ee);const t=n.capitalizeFirstLetter(e),{logging:o}=a,{hasTags:r}=c,i=Tn(),{maxEl:u,maxVal:l}=bn(i,e);return f(`${t} position calculated from:`,u),f(`Checked %c${i.length}%c elements`,s.HIGHLIGHT,s.FOREGROUND),performance.mark(K,{detail:{hasTags:r,len:i.length,logging:o,Side:t}}),l}const pe={label:n.HEIGHT,enabled:()=>a.calculateHeight,getOffset:()=>a.offsetHeight,auto:()=>rt(pe),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>ct(n.HEIGHT_EDGE)},Oe={label:n.WIDTH,enabled:()=>a.calculateWidth,getOffset:()=>a.offsetWidth,auto:()=>rt(Oe),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>ct(n.WIDTH_EDGE)};function wn(e,t,o){const r=a.onBeforeResize(e,t,o);if(r===void 0)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(r))throw new TypeError(`Invalid value returned from onBeforeResize(): ${r}, expected Number`);if(r<n.MIN_SIZE)throw new RangeError(`Out of range value returned from onBeforeResize(): ${r}, must be at least ${n.MIN_SIZE}`);return r}const at=(e,t)=>(o,r)=>{const i=e[o]();return e.enabled()&&a.onBeforeResize!==void 0?wn(i,r,t):i},vn=at(pe,n.HEIGHT),yn=at(Oe,n.WIDTH);function Hn(){(window.scrollY!==0||window.scrollX!==0)&&(f("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0))}function An(e,t,o,r){const{heightCalcMode:i,widthCalcMode:u}=a;Hn();const l=o??vn(i,e),g=r??yn(u,e),p=dn(l,g)?n.SIZE_CHANGE_DETECTED:e;switch(d(`Resize event: %c${t}`,s.HIGHLIGHT),p){case n.INIT:case n.ENABLE:case n.SIZE_CHANGE_DETECTED:case n.MANUAL_RESIZE_REQUEST:case n.PARENT_RESIZE_REQUEST:c.height=l,c.width=g;case n.SET_OFFSET_SIZE:return c;case n.OVERFLOW_OBSERVER:case n.MUTATION_OBSERVER:case n.RESIZE_OBSERVER:case n.VISIBILITY_OBSERVER:{d(n.NO_CHANGE);break}default:f(n.NO_CHANGE)}return null}let W=!1,ne=!1,D=null;function Mn(e,t,o,r,i){const{autoResize:u}=a,{isHidden:l}=c;switch(h(e),!0){case(l===!0&&!(e in n.IGNORE_DISABLE_RESIZE)):{if(ne===!0)break;d("Iframe hidden - Ignored resize request"),ne=!0,W=!1,cancelAnimationFrame(D),D=null;break}case(W===!0&&e!==n.OVERFLOW_OBSERVER&&!(e in n.IGNORE_DISABLE_RESIZE)):{d("Resize already pending - Ignored resize request");break}case(!u&&!(e in n.IGNORE_DISABLE_RESIZE)):{f("Resizing disabled");break}default:{ne=!1,W=!0,c.totalTime=performance.now(),c.timerActive=!0;const g=An(e,t,o,r);g&&ot(g.height,g.width,e,i),D||(D=requestAnimationFrame(()=>{W=!1,D=null,h("requestAnimationFrame"),Q(`Reset sendPending: %c${e}`,s.HIGHLIGHT)})),c.timerActive=!1}}G()}const y=ge(Mn);function De({eventType:e,eventName:t}){N(window,t,()=>y(t,e),{passive:!0})}function Nn(){De({eventType:"After Print",eventName:"afterprint"}),De({eventType:"Before Print",eventName:"beforeprint"})}function Ln(){if(c.triggerLocked){d("TriggerLock blocked calculation");return}c.triggerLocked=!0,Q("Trigger event lock on"),requestAnimationFrame(()=>{c.triggerLocked=!1,Q("Trigger event lock off")})}function dt(e){const{heightCalcMode:t,widthCalcMode:o}=a,r=pe[t](),i=Oe[o]();d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),O(r,i,e)}function Gn(e){const t=a.heightCalcMode;d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),a.heightCalcMode=n.HEIGHT_CALC_MODE_DEFAULT,Ln(),dt("reset"),a.heightCalcMode=t}const zn=`Auto Resize can not be changed when <b>direction</> is set to '${n.NONE}'.`;function $n(e){n.typeAssert(e,n.BOOLEAN,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:o,calculateWidth:r}=a;return r===!1&&o===!1?(h(n.ENABLE),R(zn),!1):(e===!0&&t===!1?(a.autoResize=!0,queueMicrotask(()=>y(n.ENABLE,"Auto Resize enabled"))):e===!1&&t===!0&&(a.autoResize=!1),O(0,0,n.AUTO_RESIZE,JSON.stringify(a.autoResize)),a.autoResize)}function _n(e){n.typeAssert(e,n.STRING,"parentIframe.moveToAnchor(anchor) anchor"),c.inPageLinks.findTarget(e)}function kn(e){n.typeAssert(e,n.NUMBER,"parentIframe.setOffsetSize(offset) offset"),a.offsetHeight=e,a.offsetWidth=e,y(n.SET_OFFSET_SIZE,`parentIframe.setOffsetSize(${e})`)}const Cn=()=>c.origin;function Dn(e){n.typeAssert(e,n.STRING,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),d(`Set targetOrigin: %c${e}`,s.HIGHLIGHT),a.targetOrigin=e}function Pn(e){return n.typeAssert(e,n.FUNCTION,"parentIframe.getParentProps(callback) callback"),c.onParentInfo=e,O(0,0,n.PARENT_INFO),()=>{c.onParentInfo=null,O(0,0,n.PARENT_INFO_STOP)}}function Bn(e,t){e!==void 0&&n.typeAssert(e,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customHeight"),t!==void 0&&n.typeAssert(t,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customWidth");const o=e===void 0?"":e,r=t===void 0?"":`,${t}`,i=`${o}${r}`;y(n.MANUAL_RESIZE_REQUEST,`parentIframe.resize(${i})`,e,t)}const Se=e=>(t,o)=>{n.typeAssert(t,n.NUMBER,`parentIframe.${e}(x, y) x`),n.typeAssert(o,n.NUMBER,`parentIframe.${e}(x, y) y`),O(o,t,e)},Fn=Se(n.SCROLL_BY),Un=Se(n.SCROLL_TO),xn=Se(n.SCROLL_TO_OFFSET);function Vn(e,t){t&&n.typeAssert(t,n.STRING,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),O(0,0,n.MESSAGE,JSON.stringify(e),t)}const Wn=()=>O(0,0,n.CLOSE),Zn=()=>a.parentId,qn=()=>Gn("parentIframe.reset");function Yn(){const{win:e}=c;a.mode!==1&&(e.parentIframe=Object.freeze({autoResize:$n,close:Wn,getId:Zn,getParentOrigin:Cn,getParentProps:Pn,moveToAnchor:_n,reset:qn,setOffsetSize:kn,scrollBy:Fn,scrollTo:Un,scrollToOffset:xn,sendMessage:Vn,setTargetOrigin:Dn,resize:Bn}))}const U=(e="")=>t=>o=>{o.size>0&&Q(`${t}Observer ${e}:`,...Array.from(o).flatMap(r=>[n.NEW_LINE,r]))},jn=(e="")=>t=>o=>{o.size>0&&je(`${t}Observer ${e}:`,...Array.from(o).flatMap(r=>[n.NEW_LINE,r]))},lt=U("attached to"),ft=jn("already attached"),Qn=U("detached from"),ee=(e,t=!0)=>o=>{o>0&&f(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${o}%c element${o===1?"":"s"}`,s.HIGHLIGHT,s.NORMAL,s.HIGHLIGHT,s.NORMAL)},ut=(e,t,o,r)=>{const i=Qn(e);return u=>{const l=new Set;let g=0;for(const p of u)o.has(p)&&(t.unobserve(p),o.delete(p),l.add(p),g+=1);i(l),r(g),l.clear()}},Pe=16,Be=2,Kn=200,Re="Mutation",w=new Set,M=new Set,ae=new Set,J=[],Jn={attributes:!0,attributeFilter:[n.IGNORE_ATTR,n.SIZE_ATTR],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let oe=1,Te,de=!1,le=0;const Xn=U("added")(Re),eo=U("removed (page)")(Re),to=U("removed (added)")(Re),gt=e=>e.nodeType!==Node.ELEMENT_NODE||n.IGNORE_TAGS.has(e.tagName.toLowerCase());function no(e){const t=e.addedNodes;for(const o of t)gt(o)||w.add(o)}function oo(e){const t=e.removedNodes;for(const o of t)gt(o)||(w.has(o)?(w.delete(o),ae.add(o)):M.add(o))}const ro=e=>{f("Mutations:",e);for(const t of e)no(t),oo(t);Xn(w),eo(M),to(ae),ae.clear()};function so(){M.size>0&&d(`Detected %c${M.size} %cremoved element${M.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND),w.size>0&&d(`Found %c${w.size} %cnew element${w.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND)}const io=e=>()=>{const t=performance.now(),o=t-le,r=Pe*oe+++Be;if(o>r&&o<Kn){h("mutationThrottled"),f("Update delayed due to heavy workload on the callStack"),f(`EventLoop busy time: %c${n.round(o)}ms %c> Max wait: %c${r-Be}ms`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),setTimeout(Te,Pe*oe),le=t;return}oe=1,J.forEach(ro),J.length=0,de=!1,so(),e({addedNodes:w,removedNodes:M}),w.clear(),M.clear()};function co(e){J.push(e),!de&&(le=performance.now(),de=!0,requestAnimationFrame(Te))}function ao(e){const t=new window.MutationObserver(co),o=document.body||document.documentElement;return Te=io(e),t.observe(o,Jn),f("Attached%c MutationObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{w.clear(),M.clear(),J.length=0,t.disconnect(),f("Detached%c MutationObserver",s.HIGHLIGHT)}}}const lo={characterData:!0,childList:!0,subtree:!0};function fo(e){const t=document.querySelector("title")??document.head??document.documentElement,o=new MutationObserver(e);return o.observe(t,lo),f("Attached%c TitleObserver%c to head",s.HIGHLIGHT,s.FOREGROUND),setTimeout(e),{disconnect:()=>{o.disconnect(),f("Detached%c TitleObserver",s.HIGHLIGHT)}}}function uo(e){const t=new IntersectionObserver(r=>e(r.at(-1)?.isIntersecting??!1),{threshold:0}),o=document.documentElement;return t.observe(o),f("Attached%c VisibilityObserver%c to page",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{t.disconnect(),f("Detached%c VisibilityObserver",s.HIGHLIGHT)}}}let Fe=new Set;function go(e){const t=new Set,o=new Set;for(const r of e)r.closest(`[${n.IGNORE_ATTR}]`)?o.add(r):t.add(r);return o.size>0&&queueMicrotask(()=>{h("overflowIgnored"),f(`Ignoring elements with [data-iframe-ignore] > *:
23
- `,o),G()}),t}function mt(){const e=document.querySelectorAll(`[${n.OVERFLOW_ATTR}]`),t=go(e);let o=!0;return typeof Set.prototype.symmetricDifference===n.FUNCTION&&(o=t.symmetricDifference(Fe).size>0),Fe=t,c.overflowedNodeSet=t,c.hasOverflow=t.size>0,{hasOverflowUpdated:o,overflowedNodeSet:t}}const v={},ht=e=>{const t=new Set;for(const o of e)if(o instanceof Element){t.add(o);for(const r of Ie(o))t.add(r)}return f(`Inspecting:
24
- `,t),t},mo=e=>{if(e.size===0)return;h("addObservers");const t=ht(e);v.overflow.attachObservers(t),v.resize.attachObserverToNonStaticElements(t),G()},ho=e=>{if(e.size===0)return;h("removeObservers");const t=ht(e);v.overflow.detachObservers(t),v.resize.detachObservers(t),G()};function Eo({addedNodes:e,removedNodes:t}){h("contentMutated"),c.applySelectors(),nt(),mt(),G(),ho(t),mo(e)}function Io(e){Eo(e),y(n.MUTATION_OBSERVER,"Mutation Observed")}const x="Overflow",po=ee(x),Oo=ee(x,!1),So=lt(x),Ro=ft(x),To=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===n.NONE),bo=(e,t)=>{const o=t.side||n.HEIGHT_EDGE,r={root:t.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||n.id,u=(T=!1)=>e(T),l=(T,H)=>T===0||T>H[o],g=(T,H)=>{T.toggleAttribute(n.OVERFLOW_ATTR,H)};function p(T){for(const H of T){const{boundingClientRect:k,rootBounds:C,target:b}=H;if(!C)continue;const Ot=k[o],St=l(Ot,C)&&!(b instanceof HTMLElement&&To(b));g(b,St)}i(u)}const m=new IntersectionObserver(p,r),S=new WeakSet;function E(T){const H=new Set,k=new Set;let C=0;for(const b of T)if(b instanceof Element){if(S.has(b)){H.add(b);continue}m.observe(b),S.add(b),k.add(b),C+=1}Ro(H),So(k),po(C),k.clear(),H.clear()}return{attachObservers:E,detachObservers:ut(x,m,S,Oo),disconnect:()=>{m.disconnect(),f("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function wo(){const{hasOverflow:e}=c,{hasOverflowUpdated:t,overflowedNodeSet:o}=mt();switch(!0){case!t:return;case o.size>1:f("Overflowed Elements:",o);break;case e:break;default:f("No overflow detected")}y(n.OVERFLOW_OBSERVER,"Overflow updated")}function vo(e){const t={root:document.documentElement,side:a.calculateHeight?n.HEIGHT_EDGE:n.WIDTH_EDGE};return v.overflow=bo(wo,t),v.overflow.attachObservers(e),v.overflow}const V="Resize",yo=ee(V),Ho=ee(V,!1),Ao=lt(V),Mo=ft(V),X=new WeakSet,re=new Set,se=new Set;let B;function No(e){let t=0;for(const o of e){if(!(o instanceof Element))continue;const r=getComputedStyle(o)?.position;if(!(r===""||r==="static")){if(X.has(o)){re.add(o);continue}B.observe(o),X.add(o),se.add(o),t+=1}}Mo(re),Ao(se),yo(t),se.clear(),re.clear()}const Lo=e=>(B=new ResizeObserver(e),B.observe(document.body),X.add(document.body),f("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:No,detachObservers:ut(V,B,X,Ho),disconnect:()=>{B.disconnect(),f("Detached%c ResizeObserver",s.HIGHLIGHT)}});function Go(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;y(n.RESIZE_OBSERVER,`Element resized <${n.getElementName(t)}>`)}function zo(e){return v.resize=Lo(Go),v.resize.attachObserverToNonStaticElements(e),v.resize}let Ue;function $o(){const e=document.title;e!==Ue&&(Ue=e,d(`Title: %c${e}`,s.HIGHLIGHT),e&&O(0,0,n.TITLE,e))}function _o(e){d(`Visible: %c${e}`,s.HIGHLIGHT),c.isHidden=!e,y(n.VISIBILITY_OBSERVER,"Visibility changed")}function ko(e){he.push(...e.map(t=>t.disconnect))}function Co(){h("attachObservers");const e=Ie(document.documentElement),t=[ao(Io),vo(e),On(),zo(e),fo($o),uo(_o)];ko(t)}const xe=(e,t,o)=>{if(o!==""){d(`${e}: %c${o}`,s.HIGHLIGHT);for(const r of document.querySelectorAll(o))d(`Applying ${t} to:`,r),r.toggleAttribute(t,!0)}};function Do({sizeSelector:e,ignoreSelector:t}){return()=>{xe("sizeSelector",n.SIZE_ATTR,e),xe("ignoreSelector",n.IGNORE_ATTR,t)}}function Po(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Bo(e,t){return t.includes("-")&&(_(`Negative CSS value ignored for ${e}`),t=""),t}function fe(e,t){t===void 0||t===""||t===n.NULL||(document.body.style.setProperty(e,t),f(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Fo({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),fe("margin",Bo("margin",e))}const Uo=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function xo(e){const t=e.getBoundingClientRect(),o=Uo();return{x:Math.round(t.left+o.x),y:Math.round(t.top+o.y)}}function Vo(e,t){const o=xo(t);d(`Moving to in page link (%c#${e}%c) at x: %c${o.x}%c y: %c${o.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),O(o.y,o.x,n.SCROLL_TO_OFFSET)}function be(e){const t=e.split("#")[1]||e,o=decodeURIComponent(t),r=document.getElementById(o)||document.getElementsByName(o)[0];if(r!==void 0){Vo(t,r);return}d(`In page link (#${t}) not found in iframe, so sending to parent`),O(0,0,n.IN_PAGE_LINK,`#${t}`)}function Et(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&be(t)}function Wo(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&N(e,"click",t=>{t.preventDefault(),be(e.getAttribute("href"))})}function Zo(){N(window,"hashchange",Et)}function qo(){setTimeout(Et,n.EVENT_CANCEL_TIMER)}function Yo(){d("Setting up location.hash handlers"),Wo(),Zo(),qo(),c.inPageLinks={findTarget:be}}function jo(e){const{mode:t}=a;e?n.checkMode(t)?R(n.getModeData(5)):Yo():d("In page linking not enabled")}const Qo="important";function Ko(){const e=t=>t.style.setProperty(n.HEIGHT,n.AUTO,Qo);e(document.documentElement),e(document.body),d("Set HTML & body height: %cauto !important",s.HIGHLIGHT)}const we=e=>(t,o)=>{if(o in t){if(typeof t[o]===e)return t[o];throw new TypeError(`${o} is not a ${e}.`)}},ie=we(n.FUNCTION),Ve=we(n.NUMBER),Z=we(n.STRING),Jo=e=>e!==null&&typeof e===n.OBJECT&&!Array.isArray(e);function Xo(e){const{calculateHeight:t,calculateWidth:o}=a;let r,i;return typeof e?.offsetSize===n.NUMBER&&(t&&(r=Ve(e,n.OFFSET_SIZE)),o&&(i=Ve(e,n.OFFSET_SIZE))),{offsetHeight:r,offsetWidth:i}}function er(e){d("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:o}=Xo(e);return{offsetHeight:t,offsetWidth:o,ignoreSelector:Z(e,"ignoreSelector"),[n.getKey(3)]:Z(e,n.getKey(0)),sizeSelector:Z(e,"sizeSelector"),targetOrigin:Z(e,"targetOrigin"),onBeforeResize:ie(e,"onBeforeResize"),onMessage:ie(e,"onMessage"),onReady:ie(e,"onReady")}}function tr(){const{mode:e}=a;if(n.checkMode(e))return{};const t=window.iframeResizer||window.iFrameResizer;return Jo(t)?er(t):{}}const nr=e=>e==="true",It=e=>t=>t===void 0?void 0:e(t),L=It(nr),P=It(Number),or=e=>({parentId:e[0],bodyMargin:P(e[1]),calculateWidth:L(e[2]),logging:L(e[3]),autoResize:L(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:P(e[11]),inPageLinks:L(e[12]),mouseEvents:L(e[15]),offsetHeight:P(e[16]),offsetWidth:P(e[17]),calculateHeight:L(e[18]),key:e[19],version:e[20],mode:P(e[21]),logExpand:L(e[23])});function rr(e){const{mode:t}=a;e.forEach(o=>{try{o()}catch(r){if(t<0)throw r;R(`<rb>Error in setup function</>
25
- <i>iframe-resizer</> detected an error during setup.
26
-
27
- Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),je(r)}})}function We(e){for(const[t,o]of Object.entries(e))o!==void 0&&(a[t]=o)}function sr({logExpand:e,logging:t,parentId:o=""}){Tt({id:o,enabled:t,expand:e}),h("initReceived"),d(`Initialising iframe v${n.VERSION} ${window.location.href}`)}function ir(e){h("ready"),tt(n.once(e)),d("Initialization complete",(({key:t,key2:o,...r})=>r)(a))}function cr({bodyBackground:e,bodyPadding:t,inPageLinks:o,onReady:r}){const i=Pt(a),u=[Ut,Bt,qt,nt,jt,i?n.id:Dt,()=>Fo(a),()=>fe("background",e),()=>fe("padding",t),i?n.id:Ko,Po,c.applySelectors,()=>jo(o),Nn,()=>rn(a),an,()=>Yn(),()=>y(n.INIT,"Init message from host page",void 0,void 0,`${n.VERSION}:${a.mode}`),Co,G];Jt(a),Vt(a),rr(u),ir(r)}function ar(e){c.firstRun&&(We(or(e)),sr(a),We(tr()),c.applySelectors=Do(a),cr(a))}function dr(e){if(document.readyState==="loading"){d("Page not ready, ignoring init message");return}const t=e.data.slice(n.MESSAGE_ID_LENGTH).split(n.SEPARATOR);c.target=e.source,c.origin=e.origin,ar(t),c.firstRun=!1,setTimeout(()=>{c.initLock=!1},n.EVENT_CANCEL_TIMER)}const{freeze:lr}=Object,{parse:ve}=JSON,ye=e=>lr(ve(e)),pt=e=>O(0,0,`${e}Stop`),te=e=>e.data.slice(e.data.indexOf(n.SEPARATOR)+1),fr=e=>At(e)?n.INIT:e.data.split("]")[1].split(n.SEPARATOR)[0];function ur(e){const t=te(e);d("onMessage called from parent:%c",s.HIGHLIGHT,ye(t)),n.isolateUserCode(a.onMessage,ve(t))}function gr(e){const{onPageInfo:t}=c,o=te(e);d("PageInfo received from parent:",ye(o)),t?n.isolateUserCode(t,ve(o)):pt(n.PAGE_INFO)}function mr(e){const{onParentInfo:t}=c,o=ye(te(e));d("ParentInfo received from parent:",o),t?n.isolateUserCode(t,o):pt(n.PARENT_INFO)}function hr(){if(c.initLock){d("Page reset ignored by init");return}d("Page size reset by host page"),dt("resetPage")}function Er(){d("Resize requested by host page"),y(n.PARENT_RESIZE_REQUEST,"Parent window requested size check")}const Ze=e=>c.inPageLinks.findTarget(te(e)),qe={init:dr,reset:hr,resize:Er,moveToAnchor:Ze,inPageLink:Ze,pageInfo:gr,parentInfo:mr,message:ur};function Ir(e){const{firstRun:t}=c,o=fr(e);switch(h(o),!0){case o in qe:qe[o](e);break;case(t&&Ht()):_(`Ignored message of type "${o}". Received before initialization.`);break;default:_(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const q=ge(e=>{yt(e)&&Ir(e)});function pr(){if("iframeChildListener"in window){_("Already setup");return}window.iframeChildListener=(t=>{setTimeout(()=>q({data:t,sameOrigin:!0}))}),h("listen"),N(window,n.MESSAGE,q),N(document,n.READY_STATE_CHANGE,Ne),Ne();function e(t){return q(t),c.win}try{top?.document?.getElementById("banner")&&(c.win={},window.mockMsgListener=e,Je(window,n.MESSAGE,q),typeof window.define=="function"&&window.define([],()=>e))}catch{}}typeof window!==n.UNDEFINED&&pr();
1
+ /*!
2
+ * @preserve
3
+ *
4
+ * @module iframe-resizer/child 6.0.0-beta.6 (esm) - 2026-04-10
5
+ *
6
+ * @license GPL-3.0 For use with GPL compliant sites (fully published front & backend source code)
7
+ * Alternatively for commercial use, you can purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
+ *
10
+ * @description Keep same and cross domain iframes sized to their content
11
+ *
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
+ *
14
+ * @see {@link https://iframe-resizer.com}
15
+ *
16
+ * @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
17
+ */
18
+
19
+
20
+ "use strict";const e=require("@iframe-resizer/common"),t=require("auto-console-group");let n=!0,o=e.LABEL;const r=e.esModuleInterop(t)({label:`${e.LABEL}(child)`,expand:!1});const i=e=>(...t)=>!n||r[e](...t),a=i("log"),s=a,c=i("debug");const{assert:d,endAutoGroup:l,error:u,errorBoundary:f,event:g,label:m,purge:h,warn:E}=r,I=e.createFormatAdvise(e.id),p=(...e)=>r.warn(...e.map(I)),T=e.deprecate((e,t)=>p(t));T("Method"),T("Method","replaced with"),T("Option");const O=[];function R(e,n){a(`${e} event listener: %c${n}`,t.HIGHLIGHT)}const H=(e,t,n,o)=>{e.removeEventListener(t,n,o),R("Removed",t)},S=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),O.push(()=>H(e,t,n,o)),R("Added",t)},b={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let w=!1;function y(t){const n=window?.iframeResizer?.targetOrigin||"*",o=Array.isArray(n)?n:[n];for(const r of o)t.postMessage(e.CHILD_READY_MESSAGE,r)}function v(){if("loading"===document.readyState||!b.firstRun||w)return;const{parent:e,top:n}=window;g("ready"),a("Sending%c ready%c to parent from",t.HIGHLIGHT,t.FOREGROUND,window.location.href),y(e),e!==n&&y(n),w=!0}const G="iframeResize",N=["min-height","min-width","max-height","max-width"],A=new Set,L=e=>e.tagName?e.tagName.toLowerCase():"unknown",M=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),$=(t,n)=>{return!!(o=M(t,n))&&"0px"!==o&&o!==e.AUTO&&o!==e.NONE;var o};function z({href:e}){A.has(e)||(a("Unable to access stylesheet:",e),A.add(e))}const _=(e,t)=>function(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const o of document.styleSheets)try{for(const n of o.cssRules||[]){if(!("selectorText"in n))continue;const r=n;if(!e.matches(r.selectorText))continue;const i=r.style.getPropertyValue(t);if(!i)continue;const{ownerNode:a}=o;return{source:a instanceof Element&&"STYLE"===a.tagName?"an inline <style> block":`stylesheet (${o.href})`,value:i}}}catch(n){z(o)}return{source:"cross-origin stylesheet",value:M(e,t)}}(e,t),k=(e,t)=>{const{source:n,value:o}=_(e,t),r=L(e);p(`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 D(){for(const e of[document.documentElement,document.body])for(const t of N)a(`Checking <${L(e)}> for blocking CSS: ${t}`),$(e,t)&&k(e,t)}const C={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:e.AUTO,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:e.AUTO,onBeforeResize:void 0,onMessage:()=>{E("onMessage function not defined")},onReady:()=>{}};function P(){try{b.sameOrigin=1===C.mode||"iframeParentListener"in window.parent}catch(e){a("Cross domain iframe detected")}}let B=0;function F(){const n=document.querySelectorAll(`*[${e.IGNORE_ATTR}]`),o=n.length>0;return o&&n.length!==B&&(!function(n){const o=1===n.length?"":"s";E(`%c[${e.IGNORE_ATTR}]%c found on %c${n.length}%c element${o}`,t.BOLD,t.NORMAL,t.BOLD,t.NORMAL)}(n),B=n.length),o}function U(o,r,i){(!e.isDef(i)||r>-1&&o>r)&&(function(o,r){console.info(`%ciframe-resizer ${o}`,n||r<1?e.BOLD:t.NORMAL)}(`v${e.VERSION} (${e.getModeLabel(o)})`,o),0===o&&((...e)=>{console.warn(...e.map(I))})(e.getModeData(3)))}function x(){"BackCompat"===document.compatMode&&p("<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")}let V=!1;function W(t){"complete"===document.readyState?e.isolateUserCode(t):V||S(document,e.READY_STATE_CHANGE,()=>W(t)),V=!0}const Z=()=>{s(`Set targetOrigin for parent: %c${C.targetOrigin}`,t.HIGHLIGHT),!0!==C.autoResize&&a("Auto Resize disabled")};function q(){b.taggedElements=document.querySelectorAll(`[${e.SIZE_ATTR}]`),b.hasTags=b.taggedElements.length>0,a(`Tagged elements found: %c${b.hasTags}`,t.HIGHLIGHT)}function Y({version:t}){t&&""!==t&&t!==e.FALSE?t!==e.VERSION&&p((t=>`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${t} - Child page: ${e.VERSION}.\n`)(t)):p("<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")}const j=e.once(()=>p(e.getModeData(4)));function Q(n,o){const{mode:r}=C,{sameOrigin:i,target:s}=b;if(i)try{window.parent.iframeParentListener(e.MESSAGE_ID+n)}catch(c){if(!e.checkMode(r))throw new Error(c);return j(),!1}else{d(s,"Internal error: postMessage target is undefined");const r=function(e){return void 0===e?e=C.targetOrigin:a(`Message targetOrigin: %c${e}`,t.HIGHLIGHT),e}(o),i=Array.isArray(r)?r:[r];for(const t of i)s.postMessage(e.MESSAGE_ID+n,t)}return!0}function J(n,o,r,i,c){const{parentId:d}=C,{sameOrigin:l}=b,u=`${d}:${`${n}:${o}`}:${r}${void 0===i?"":`:${i}`}`;if(C.mode<-1)return;Q(u,c)&&(!function(n){if(!b.timerActive)return;const o=e.round(performance.now()-b.totalTime),r=n===e.INIT?`Initialised iframe in %c${o}ms`:`Size calculated in %c${o}ms`;a(r,t.HIGHLIGHT)}(r),s(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${u}`,t.ITALIC,t.HIGHLIGHT))}const K=f((e,t,n,o,r)=>{g(n),J(e,t,n,o,r),l()}),X=e=>K(0,0,e.type,`${e.screenY}:${e.screenX}`);function ee(e,n){a(`Add event listener: %c${n}`,t.HIGHLIGHT),S(window.document,e,X)}function te({persisted:t}){t||K(0,0,e.BEFORE_UNLOAD),g(e.PAGE_HIDE),s("Page persisted:",t),t||O.forEach(e.invoke)}const ne=()=>S(window,e.lower(e.PAGE_HIDE),te),oe=(e,t)=>!(Math.abs(e-t)<=C.tolerance);const re=[t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT],ie={height:0,width:0},ae={height:0,width:0};function se(e,t,n){return ae[e]=t,ie[e]=n,t}function ce(n){const{hasOverflow:o,hasTags:r,triggerLocked:i}=b,a=n.label,c=a===e.HEIGHT,d=n.boundingClientRect(),l=Math.ceil(d),u=Math.floor(d),f=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(n),g=`HTML: %c${d}px %cPage: %c${f}px`;let m;switch(!0){case!n.enabled():return Math.max(f,e.MIN_SIZE);case r:s("Found element with data-iframe-size attribute"),m=n.taggedElement();break;case!o&&b.firstRun&&0===ae[a]&&0===ie[a]:s(`Initial page size values: ${g}`,...re),m=se(a,d,f);break;case i&&d===ae[a]&&f===ie[a]:s(`Size unchanged: ${g}`,...re),m=Math.max(d,f);break;case 0===d&&0!==f:s(`Page is hidden: ${g}`,...re),m=f;break;case!o&&d!==ae[a]&&f<=ie[a]:s(`New <html> size: ${g} `,...re),s(`Previous <html> size: %c${ae[a]}px`,t.HIGHLIGHT),m=se(a,d,f);break;case!c:m=n.taggedElement();break;case!o&&d<ae[a]:s(`<html> size decreased: ${g}`,...re),m=se(a,d,f);break;case f===u||f===l:s(`<html> size equals page size: ${g}`,...re),m=se(a,d,f);break;case d>f:s(`Page size < <html> size: ${g}`,...re),m=se(a,d,f);break;case o:s("Found elements possibly overflowing <html> "),m=n.taggedElement();break;default:s(`Using <html> size: ${g}`,...re),m=se(a,d,f)}return s(`Content ${a}: %c${m}px`,t.HIGHLIGHT),m+=function(e){const n=e.getOffset();return 0!==n&&s(`Page offsetSize: %c${n}px`,t.HIGHLIGHT),n}(n),Math.max(m,e.MIN_SIZE)}const de="--ifr-start",le="--ifr-end",ue="--ifr-measure",fe=[];let ge,me={},he=0;function Ee(){try{performance.clearMarks(de),performance.clearMarks(le),performance.clearMeasures(ue)}catch{}}function Ie(e){e.getEntries().forEach(e=>{if(e.name===le)try{const{duration:t}=performance.measure(ue,de,le);me=e.detail,fe.push(t),fe.length>100&&fe.shift()}catch{}})}function pe(){s("Attached%c PerformanceObserver%c to page",t.HIGHLIGHT,t.FOREGROUND);const n=new PerformanceObserver(Ie);return n.observe({entryTypes:["mark"]}),ge=setInterval(()=>{if(fe.length<10)return;if(me.hasTags&&me.len<25)return;fe.sort();const t=Math.min(fe.reduce((e,t)=>e+t,0)/fe.length,fe[Math.floor(fe.length/2)]),n=e.round(t);n>he&&(he=n,g("performanceObserver"),a("Mean time:",e.round(fe[Math.floor(fe.length/2)])),a("Median time:",e.round(fe.reduce((e,t)=>e+t,0)/fe.length)),a("Average time:",n),a("Max time:",e.round(Math.max(...fe)))),Ee(),t<=4||(clearInterval(ge),p(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${e.round(t)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${me.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3),{disconnect:()=>{Ee(),clearInterval(ge),n.disconnect(),s("Detached%c PerformanceObserver",t.HIGHLIGHT)}}}const Te=`* ${Array.from(e.IGNORE_TAGS).map(e=>`:not(${e})`).join("")}`,Oe=e=>e.querySelectorAll(Te);function Re(n){performance.mark(de);const o=e.capitalizeFirstLetter(n),{logging:r}=C,{hasTags:i}=b,a=function(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:n,taggedElements:o}=b;return t?o:e?Array.from(n):Oe(document.documentElement)}(),{maxEl:c,maxVal:d}=function(t,n){const o=`margin-${n}`;let r,i=document.documentElement,a=b.hasTags?e.MIN_SIZE:document.documentElement.getBoundingClientRect().bottom;for(const e of t)r=e.getBoundingClientRect()[n]+parseFloat(getComputedStyle(e).getPropertyValue(o)),r>a&&(a=r,i=e);return{maxEl:i,maxVal:a}}(a,n);return s(`${o} position calculated from:`,c),s(`Checked %c${a.length}%c elements`,t.HIGHLIGHT,t.FOREGROUND),performance.mark(le,{detail:{hasTags:i,len:a.length,logging:r,Side:o}}),d}const He={label:e.HEIGHT,enabled:()=>C.calculateHeight,getOffset:()=>C.offsetHeight,auto:()=>ce(He),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>Re(e.HEIGHT_EDGE)},Se={label:e.WIDTH,enabled:()=>C.calculateWidth,getOffset:()=>C.offsetWidth,auto:()=>ce(Se),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>Re(e.WIDTH_EDGE)};const be=(t,n)=>(o,r)=>{const i=t[o]();return t.enabled()&&void 0!==C.onBeforeResize?function(t,n,o){const r=C.onBeforeResize(t,n,o);if(void 0===r)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(r))throw new TypeError(`Invalid value returned from onBeforeResize(): ${r}, expected Number`);if(r<e.MIN_SIZE)throw new RangeError(`Out of range value returned from onBeforeResize(): ${r}, must be at least ${e.MIN_SIZE}`);return r}(i,r,n):i},we=be(He,e.HEIGHT),ye=be(Se,e.WIDTH);function ve(n,o,r,i){const{heightCalcMode:c,widthCalcMode:d}=C;0===window.scrollY&&0===window.scrollX||(s("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0));const l=r??we(c,n),u=i??ye(d,n),f=function(e,t){const{calculateHeight:n,calculateWidth:o}=C,{height:r,width:i}=b;return n&&oe(r,e)||o&&oe(i,t)}(l,u)?e.SIZE_CHANGE_DETECTED:n;switch(a(`Resize event: %c${o}`,t.HIGHLIGHT),f){case e.INIT:case e.ENABLE:case e.SIZE_CHANGE_DETECTED:case e.MANUAL_RESIZE_REQUEST:case e.PARENT_RESIZE_REQUEST:b.height=l,b.width=u;case e.SET_OFFSET_SIZE:return b;case e.OVERFLOW_OBSERVER:case e.MUTATION_OBSERVER:case e.RESIZE_OBSERVER:case e.VISIBILITY_OBSERVER:a(e.NO_CHANGE);break;default:s(e.NO_CHANGE)}return null}let Ge=!1,Ne=!1,Ae=null;const Le=f(function(n,o,r,i,d){const{autoResize:u}=C,{isHidden:f}=b;switch(g(n),!0){case!0===f&&!(n in e.IGNORE_DISABLE_RESIZE):if(!0===Ne)break;a("Iframe hidden - Ignored resize request"),Ne=!0,Ge=!1,cancelAnimationFrame(Ae),Ae=null;break;case!0===Ge&&n!==e.OVERFLOW_OBSERVER&&!(n in e.IGNORE_DISABLE_RESIZE):a("Resize already pending - Ignored resize request");break;case!u&&!(n in e.IGNORE_DISABLE_RESIZE):s("Resizing disabled");break;default:{Ne=!1,Ge=!0,b.totalTime=performance.now(),b.timerActive=!0;const e=ve(n,o,r,i);e&&J(e.height,e.width,n,d),Ae||(Ae=requestAnimationFrame(()=>{Ge=!1,Ae=null,g("requestAnimationFrame"),c(`Reset sendPending: %c${n}`,t.HIGHLIGHT)})),b.timerActive=!1}}l()});function Me({eventType:e,eventName:t}){S(window,t,()=>Le(t,e),{passive:!0})}function $e(){Me({eventType:"After Print",eventName:"afterprint"}),Me({eventType:"Before Print",eventName:"beforeprint"})}function ze(e){const{heightCalcMode:n,widthCalcMode:o}=C,r=He[n](),i=Se[o]();a(`Reset trigger event: %c${e}`,t.HIGHLIGHT),K(r,i,e)}function _e(n){const o=C.heightCalcMode;a(`Reset trigger event: %c${n}`,t.HIGHLIGHT),C.heightCalcMode=e.HEIGHT_CALC_MODE_DEFAULT,b.triggerLocked?a("TriggerLock blocked calculation"):(b.triggerLocked=!0,c("Trigger event lock on"),requestAnimationFrame(()=>{b.triggerLocked=!1,c("Trigger event lock off")})),ze("reset"),C.heightCalcMode=o}const ke=`Auto Resize can not be changed when <b>direction</> is set to '${e.NONE}'.`;function De(t){e.typeAssert(t,e.BOOLEAN,"parentIframe.autoResize(enable) enable");const{autoResize:n,calculateHeight:o,calculateWidth:r}=C;return!1===r&&!1===o?(g(e.ENABLE),p(ke),!1):(!0===t&&!1===n?(C.autoResize=!0,queueMicrotask(()=>Le(e.ENABLE,"Auto Resize enabled"))):!1===t&&!0===n&&(C.autoResize=!1),K(0,0,e.AUTO_RESIZE,JSON.stringify(C.autoResize)),C.autoResize)}function Ce(t){e.typeAssert(t,e.STRING,"parentIframe.moveToAnchor(anchor) anchor"),b.inPageLinks.findTarget(t)}function Pe(t){e.typeAssert(t,e.NUMBER,"parentIframe.setOffsetSize(offset) offset"),C.offsetHeight=t,C.offsetWidth=t,Le(e.SET_OFFSET_SIZE,`parentIframe.setOffsetSize(${t})`)}const Be=()=>b.origin;function Fe(n){e.typeAssert(n,e.STRING,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),a(`Set targetOrigin: %c${n}`,t.HIGHLIGHT),C.targetOrigin=n}function Ue(t){return e.typeAssert(t,e.FUNCTION,"parentIframe.getParentProps(callback) callback"),b.onParentInfo=t,K(0,0,e.PARENT_INFO),()=>{b.onParentInfo=null,K(0,0,e.PARENT_INFO_STOP)}}function xe(t,n){void 0!==t&&e.typeAssert(t,e.NUMBER,"parentIframe.resize(customHeight, customWidth) customHeight"),void 0!==n&&e.typeAssert(n,e.NUMBER,"parentIframe.resize(customHeight, customWidth) customWidth");const o=`${void 0===t?"":t}${void 0===n?"":`,${n}`}`;Le(e.MANUAL_RESIZE_REQUEST,`parentIframe.resize(${o})`,t,n)}const Ve=t=>(n,o)=>{e.typeAssert(n,e.NUMBER,`parentIframe.${t}(x, y) x`),e.typeAssert(o,e.NUMBER,`parentIframe.${t}(x, y) y`),K(o,n,t)},We=Ve(e.SCROLL_BY),Ze=Ve(e.SCROLL_TO),qe=Ve(e.SCROLL_TO_OFFSET);function Ye(t,n){n&&e.typeAssert(n,e.STRING,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),K(0,0,e.MESSAGE,JSON.stringify(t),n)}const je=()=>K(0,0,e.CLOSE),Qe=()=>C.parentId,Je=()=>_e("parentIframe.reset");const Ke=(t="")=>n=>o=>{o.size>0&&c(`${n}Observer ${t}:`,...Array.from(o).flatMap(t=>[e.NEW_LINE,t]))},Xe=Ke("attached to"),et=((t="")=>n=>o=>{o.size>0&&u(`${n}Observer ${t}:`,...Array.from(o).flatMap(t=>[e.NEW_LINE,t]))})("already attached"),tt=Ke("detached from"),nt=(e,n=!0)=>o=>{o>0&&s(`${n?"At":"De"}tached %c${e}Observer%c ${n?"to":"from"} %c${o}%c element${1===o?"":"s"}`,t.HIGHLIGHT,t.NORMAL,t.HIGHLIGHT,t.NORMAL)},ot=(e,t,n,o)=>{const r=tt(e);return e=>{const i=new Set;let a=0;for(const o of e)n.has(o)&&(t.unobserve(o),n.delete(o),i.add(o),a+=1);r(i),o(a),i.clear()}},rt="Mutation",it=new Set,at=new Set,st=new Set,ct=[],dt={attributes:!0,attributeFilter:[e.IGNORE_ATTR,e.SIZE_ATTR],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let lt,ut=1,ft=!1,gt=0;const mt=Ke("added")(rt),ht=Ke("removed (page)")(rt),Et=Ke("removed (added)")(rt),It=t=>t.nodeType!==Node.ELEMENT_NODE||e.IGNORE_TAGS.has(t.tagName.toLowerCase());function pt(e){const t=e.addedNodes;for(const n of t)It(n)||it.add(n)}function Tt(e){const t=e.removedNodes;for(const n of t)It(n)||(it.has(n)?(it.delete(n),st.add(n)):at.add(n))}const Ot=e=>{s("Mutations:",e);for(const t of e)pt(t),Tt(t);mt(it),ht(at),Et(st),st.clear()};const Rt=n=>()=>{const o=performance.now(),r=o-gt,i=16*ut+++2;if(r>i&&r<200)return g("mutationThrottled"),s("Update delayed due to heavy workload on the callStack"),s(`EventLoop busy time: %c${e.round(r)}ms %c> Max wait: %c${i-2}ms`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),setTimeout(lt,16*ut),void(gt=o);ut=1,ct.forEach(Ot),ct.length=0,ft=!1,at.size>0&&a(`Detected %c${at.size} %cremoved element${at.size>1?"s":""}`,t.HIGHLIGHT,t.FOREGROUND),it.size>0&&a(`Found %c${it.size} %cnew element${it.size>1?"s":""}`,t.HIGHLIGHT,t.FOREGROUND),n({addedNodes:it,removedNodes:at}),it.clear(),at.clear()};function Ht(e){ct.push(e),ft||(gt=performance.now(),ft=!0,requestAnimationFrame(lt))}function St(e){const n=new window.MutationObserver(Ht),o=document.body||document.documentElement;return lt=Rt(e),n.observe(o,dt),s("Attached%c MutationObserver%c to body",t.HIGHLIGHT,t.FOREGROUND),{disconnect:()=>{it.clear(),at.clear(),ct.length=0,n.disconnect(),s("Detached%c MutationObserver",t.HIGHLIGHT)}}}const bt={characterData:!0,childList:!0,subtree:!0};function wt(e){const n=document.querySelector("title")??document.head??document.documentElement,o=new MutationObserver(e);return o.observe(n,bt),s("Attached%c TitleObserver%c to head",t.HIGHLIGHT,t.FOREGROUND),setTimeout(e),{disconnect:()=>{o.disconnect(),s("Detached%c TitleObserver",t.HIGHLIGHT)}}}function yt(e){const n=new IntersectionObserver(t=>e(t.at(-1)?.isIntersecting??!1),{threshold:0}),o=document.documentElement;return n.observe(o),s("Attached%c VisibilityObserver%c to page",t.HIGHLIGHT,t.FOREGROUND),{disconnect:()=>{n.disconnect(),s("Detached%c VisibilityObserver",t.HIGHLIGHT)}}}let vt=new Set;function Gt(){const t=function(t){const n=new Set,o=new Set;for(const r of t)r.closest(`[${e.IGNORE_ATTR}]`)?o.add(r):n.add(r);return o.size>0&&queueMicrotask(()=>{g("overflowIgnored"),s("Ignoring elements with [data-iframe-ignore] > *:\n",o),l()}),n}(document.querySelectorAll(`[${e.OVERFLOW_ATTR}]`));let n=!0;return typeof Set.prototype.symmetricDifference===e.FUNCTION&&(n=t.symmetricDifference(vt).size>0),vt=t,b.overflowedNodeSet=t,b.hasOverflow=t.size>0,{hasOverflowUpdated:n,overflowedNodeSet:t}}const Nt={},At=e=>{const t=new Set;for(const n of e)if(n instanceof Element){t.add(n);for(const e of Oe(n))t.add(e)}return s("Inspecting:\n",t),t};function Lt({addedNodes:e,removedNodes:t}){g("contentMutated"),b.applySelectors(),q(),Gt(),l(),(e=>{if(0===e.size)return;g("removeObservers");const t=At(e);Nt.overflow.detachObservers(t),Nt.resize.detachObservers(t),l()})(t),(e=>{if(0===e.size)return;g("addObservers");const t=At(e);Nt.overflow.attachObservers(t),Nt.resize.attachObserverToNonStaticElements(t),l()})(e)}function Mt(t){Lt(t),Le(e.MUTATION_OBSERVER,"Mutation Observed")}const $t="Overflow",zt=nt($t),_t=nt($t,!1),kt=Xe($t),Dt=et($t),Ct=t=>t instanceof HTMLElement&&(!!t.hidden||null===t.offsetParent||t.style.display===e.NONE);function Pt(){const{hasOverflow:t}=b,{hasOverflowUpdated:n,overflowedNodeSet:o}=Gt();switch(!0){case!n:return;case o.size>1:s("Overflowed Elements:",o);break;case t:break;default:s("No overflow detected")}Le(e.OVERFLOW_OBSERVER,"Overflow updated")}function Bt(n){const o={root:document.documentElement,side:C.calculateHeight?e.HEIGHT_EDGE:e.WIDTH_EDGE};return Nt.overflow=((n,o)=>{const r=o.side||e.HEIGHT_EDGE,i={root:o.root,rootMargin:"0px",threshold:1},a=window?.requestAnimationFrame||e.id,c=(e=!1)=>n(e),d=(e,t)=>0===e||e>t[r],l=(t,n)=>{t.toggleAttribute(e.OVERFLOW_ATTR,n)},u=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:n,target:o}=t;if(!n)continue;const i=e[r],a=d(i,n)&&!(o instanceof HTMLElement&&Ct(o));l(o,a)}a(c)},i),f=new WeakSet;return{attachObservers:function(e){const t=new Set,n=new Set;let o=0;for(const r of e)r instanceof Element&&(f.has(r)?t.add(r):(u.observe(r),f.add(r),n.add(r),o+=1));Dt(t),kt(n),zt(o),n.clear(),t.clear()},detachObservers:ot($t,u,f,_t),disconnect:()=>{u.disconnect(),s("Detached%c OverflowObserver",t.HIGHLIGHT)}}})(Pt,o),Nt.overflow.attachObservers(n),Nt.overflow}const Ft="Resize",Ut=nt(Ft),xt=nt(Ft,!1),Vt=Xe(Ft),Wt=et(Ft),Zt=new WeakSet,qt=new Set,Yt=new Set;let jt;function Qt(e){let t=0;for(const n of e){if(!(n instanceof Element))continue;const e=getComputedStyle(n)?.position;""!==e&&"static"!==e&&(Zt.has(n)?qt.add(n):(jt.observe(n),Zt.add(n),Yt.add(n),t+=1))}Wt(qt),Vt(Yt),Ut(t),Yt.clear(),qt.clear()}function Jt(t){if(!Array.isArray(t)||0===t.length)return;const n=t[0].target;Le(e.RESIZE_OBSERVER,`Element resized <${e.getElementName(n)}>`)}function Kt(e){return Nt.resize=(jt=new ResizeObserver(Jt),jt.observe(document.body),Zt.add(document.body),s("Attached%c ResizeObserver%c to body",t.HIGHLIGHT,t.FOREGROUND),{attachObserverToNonStaticElements:Qt,detachObservers:ot(Ft,jt,Zt,xt),disconnect:()=>{jt.disconnect(),s("Detached%c ResizeObserver",t.HIGHLIGHT)}}),Nt.resize.attachObserverToNonStaticElements(e),Nt.resize}let Xt;function en(){const n=document.title;n!==Xt&&(Xt=n,a(`Title: %c${n}`,t.HIGHLIGHT),n&&K(0,0,e.TITLE,n))}function tn(n){a(`Visible: %c${n}`,t.HIGHLIGHT),b.isHidden=!n,Le(e.VISIBILITY_OBSERVER,"Visibility changed")}function nn(){g("attachObservers");const e=Oe(document.documentElement);!function(e){O.push(...e.map(e=>e.disconnect))}([St(Mt),Bt(e),pe(),Kt(e),wt(en),yt(tn)])}const on=(e,n,o)=>{if(""!==o){a(`${e}: %c${o}`,t.HIGHLIGHT);for(const e of document.querySelectorAll(o))a(`Applying ${n} to:`,e),e.toggleAttribute(n,!0)}};function rn(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function an(n,o){void 0!==o&&""!==o&&o!==e.NULL&&(document.body.style.setProperty(n,o),s(`Set body ${n}: %c${o}`,t.HIGHLIGHT))}function sn({bodyMarginStr:e,bodyMargin:t}){var n,o;void 0===e&&(e=`${t}px`),an("margin",(n="margin",(o=e).includes("-")&&(E(`Negative CSS value ignored for ${n}`),o=""),o))}function cn(e){const t=e.getBoundingClientRect(),n={x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};return{x:Math.round(t.left+n.x),y:Math.round(t.top+n.y)}}function dn(n){const o=n.split("#")[1]||n,r=decodeURIComponent(o),i=document.getElementById(r)||document.getElementsByName(r)[0];void 0===i?(a(`In page link (#${o}) not found in iframe, so sending to parent`),K(0,0,e.IN_PAGE_LINK,`#${o}`)):function(n,o){const r=cn(o);a(`Moving to in page link (%c#${n}%c) at x: %c${r.x}%c y: %c${r.y}`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),K(r.y,r.x,e.SCROLL_TO_OFFSET)}(o,i)}function ln(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&dn(t)}function un(){a("Setting up location.hash handlers"),function(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&S(e,"click",t=>{t.preventDefault(),dn(e.getAttribute("href"))})}(),S(window,"hashchange",ln),setTimeout(ln,e.EVENT_CANCEL_TIMER),b.inPageLinks={findTarget:dn}}function fn(){const n=t=>t.style.setProperty(e.HEIGHT,e.AUTO,"important");n(document.documentElement),n(document.body),a("Set HTML & body height: %cauto !important",t.HIGHLIGHT)}const gn=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},mn=gn(e.FUNCTION),hn=gn(e.NUMBER),En=gn(e.STRING);function In(t){a("Reading data from page:",Object.keys(t));const{offsetHeight:n,offsetWidth:o}=function(t){const{calculateHeight:n,calculateWidth:o}=C;let r,i;return typeof t?.offsetSize===e.NUMBER&&(n&&(r=hn(t,e.OFFSET_SIZE)),o&&(i=hn(t,e.OFFSET_SIZE))),{offsetHeight:r,offsetWidth:i}}(t);return{offsetHeight:n,offsetWidth:o,ignoreSelector:En(t,"ignoreSelector"),[e.getKey(3)]:En(t,e.getKey(0)),sizeSelector:En(t,"sizeSelector"),targetOrigin:En(t,"targetOrigin"),onBeforeResize:mn(t,"onBeforeResize"),onMessage:mn(t,"onMessage"),onReady:mn(t,"onReady")}}function pn(){const{mode:t}=C;if(e.checkMode(t))return{};const n=window.iframeResizer||window.iFrameResizer;return null===(o=n)||typeof o!==e.OBJECT||Array.isArray(o)?{}:In(n);var o}const Tn=e=>t=>void 0===t?void 0:e(t),On=Tn(e=>"true"===e),Rn=Tn(Number);function Hn(e){for(const[t,n]of Object.entries(e))void 0!==n&&(C[t]=n)}function Sn({logExpand:t,logging:i,parentId:s=""}){var c;o=(c={id:s,enabled:i,expand:t}).id||e.LABEL,r.label(`${o}`),r.expand(c.expand),n=c.enabled,g("initReceived"),a(`Initialising iframe v${e.VERSION} ${window.location.href}`)}function bn(t){g("ready"),W(e.once(t)),a("Initialization complete",(({key:e,key2:t,...n})=>n)(C))}function wn({bodyBackground:t,bodyPadding:n,inPageLinks:o,onReady:r}){const i=(({calculateWidth:e,calculateHeight:t})=>e===t)(C),s=[F,P,x,q,Z,i?e.id:D,()=>sn(C),()=>an("background",t),()=>an("padding",n),i?e.id:fn,rn,b.applySelectors,()=>function(t){const{mode:n}=C;t?e.checkMode(n)?p(e.getModeData(5)):un():a("In page linking not enabled")}(o),$e,()=>function({mouseEvents:t}){!0===t&&(ee(e.MOUSE_ENTER,"Mouse Enter"),ee(e.MOUSE_LEAVE,"Mouse Leave"))}(C),ne,()=>function(){const{win:e}=b;1!==C.mode&&(e.parentIframe=Object.freeze({autoResize:De,close:je,getId:Qe,getParentOrigin:Be,getParentProps:Ue,moveToAnchor:Ce,reset:Je,setOffsetSize:Pe,scrollBy:We,scrollTo:Ze,scrollToOffset:qe,sendMessage:Ye,setTargetOrigin:Fe,resize:xe}))}(),()=>Le(e.INIT,"Init message from host page",void 0,void 0,`${e.VERSION}:${C.mode}`),nn,l];Y(C),function({key:t,key2:n,mode:o,version:r}){const i=o,a=e.isDef(t)?e.setMode({key:t}):-1,s=e.isDef(n)?e.setMode({key:n}):-1;let c;switch(o=Math.max(a,s)){case-2:case-1:c=`${e.getModeData(Math.min(a,s)+2)}${e.getModeData(2)}`,b.firstRun=!1;break;case 1:case 2:case 3:c=e.getModeData(6);break;case 4:c=e.getModeData(7);break;case 5:c=e.getModeData(8)}if(o>=0&&U(o,i,r),(!e.isDef(r)||!b.firstRun)&&(c&&p(c),o<0))throw p(e.getModeData(9)),c.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");C.mode=o}(C),function(e){const{mode:t}=C;e.forEach(e=>{try{e()}catch(n){if(t<0)throw n;p("<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</>"),u(n)}})}(s),bn(r)}function yn(t){b.firstRun&&(Hn((e=>({parentId:e[0],bodyMargin:Rn(e[1]),calculateWidth:On(e[2]),logging:On(e[3]),autoResize:On(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:Rn(e[11]),inPageLinks:On(e[12]),mouseEvents:On(e[15]),offsetHeight:Rn(e[16]),offsetWidth:Rn(e[17]),calculateHeight:On(e[18]),key:e[19],version:e[20],mode:Rn(e[21]),logExpand:On(e[23])}))(t)),Sn(C),Hn(pn()),b.applySelectors=function({sizeSelector:t,ignoreSelector:n}){return()=>{on("sizeSelector",e.SIZE_ATTR,t),on("ignoreSelector",e.IGNORE_ATTR,n)}}(C),wn(C))}const{freeze:vn}=Object,{parse:Gn}=JSON,Nn=e=>vn(Gn(e)),An=e=>K(0,0,`${e}Stop`),Ln=t=>t.data.slice(t.data.indexOf(e.SEPARATOR)+1),Mn=t=>(t=>t.data.split(e.SEPARATOR)[2]in{true:1,false:1})(t)?e.INIT:t.data.split("]")[1].split(e.SEPARATOR)[0];const $n=e=>b.inPageLinks.findTarget(Ln(e)),zn={init:function(t){if("loading"===document.readyState)return void a("Page not ready, ignoring init message");const n=t.data.slice(e.MESSAGE_ID_LENGTH).split(e.SEPARATOR);b.target=t.source,b.origin=t.origin,yn(n),b.firstRun=!1,setTimeout(()=>{b.initLock=!1},e.EVENT_CANCEL_TIMER)},reset:function(){b.initLock?a("Page reset ignored by init"):(a("Page size reset by host page"),ze("resetPage"))},resize:function(){a("Resize requested by host page"),Le(e.PARENT_RESIZE_REQUEST,"Parent window requested size check")},moveToAnchor:$n,inPageLink:$n,pageInfo:function(t){const{onPageInfo:n}=b,o=Ln(t);a("PageInfo received from parent:",Nn(o)),n?e.isolateUserCode(n,Gn(o)):An(e.PAGE_INFO)},parentInfo:function(t){const{onParentInfo:n}=b,o=Nn(Ln(t));a("ParentInfo received from parent:",o),n?e.isolateUserCode(n,o):An(e.PARENT_INFO)},message:function(n){const o=Ln(n);a("onMessage called from parent:%c",t.HIGHLIGHT,Nn(o)),e.isolateUserCode(C.onMessage,Gn(o))}};function _n(e){const{firstRun:t}=b,n=Mn(e);switch(g(n),!0){case n in zn:zn[n](e);break;case t&&(G in window||void 0!==window.jQuery&&G in window.jQuery.prototype):E(`Ignored message of type "${n}". Received before initialization.`);break;default:E(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const kn=f(t=>{(t=>e.MESSAGE_ID===`${t.data}`.slice(0,e.MESSAGE_ID_LENGTH))(t)&&_n(t)});typeof window!==e.UNDEFINED&&function(){if("iframeChildListener"in window)E("Already setup");else{window.iframeChildListener=e=>{setTimeout(()=>kn({data:e,sameOrigin:!0}))},g("listen"),S(window,e.MESSAGE,kn),S(document,e.READY_STATE_CHANGE,v),v();try{top?.document?.getElementById("banner")&&(b.win={},window.mockMsgListener=t,H(window,e.MESSAGE,kn),"function"==typeof window.define&&window.define([],()=>t))}catch(n){}}function t(e){return kn(e),b.win}}();
28
21
  //# sourceMappingURL=index.cjs.js.map