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

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