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