@iframe-resizer/core 6.0.0-beta.0 → 6.0.0-beta.10

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,38 +1,21 @@
1
- (function(r,v){typeof exports=="object"&&typeof module<"u"?module.exports=v(require("auto-console-group")):typeof define=="function"&&define.amd?define(["auto-console-group"],v):(r=typeof globalThis<"u"?globalThis:r||self,r.connectResizer=v(r.acg))})(this,(function(r){"use strict";const v="6.0.0-beta.0",Y="iframeResizer",_e="[iFrameResizerChild]Ready",X="autoResize",We="beforeUnload",Be="close",De="inPageLink",R="init",K="iframeReady",Ue="lazy",P="load",L="message",Ve="mouseenter",qe="mouseleave",Q="onload",ee="pageInfo",te="parentInfo",Ze="pageInfoStop",Je="parentInfoStop",x="reset",C="resize",Ye="scrollBy",Xe="scrollTo",Ke="scrollToOffset",Qe="title",et="height",tt="width",nt="offset",ot="offsetSize",ne="scroll",it="hidden",st="child",F="parent",_="string",rt="number",oe="object",ie="function",W="auto",ct="font-weight: bold;",se="none",re="both",$="vertical",ce="horizontal",at=L.length,k="[iFrameSizer]",B=k.length,lt=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),ae=Object.freeze({[Q]:1,[R]:1,[K]:1}),D="expanded",U="collapsed",ut=Object.freeze({[D]:1,[U]:1}),le="Use of the old name will be removed in a future version of <i>iframe-resizer</>.",ue=e=>typeof e===oe&&e!==null,V=e=>typeof e===_;function ft(e){if(!ue(e))return!1;try{return e.tagName==="IFRAME"||e instanceof HTMLIFrameElement}catch{return!1}}const dt=(e,...t)=>setTimeout(()=>e(...t),0),pt=e=>{let t=!1;return function(...n){return t?void 0:(t=!0,e.apply(this,n))}},ht=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),M=(e,t)=>Object.hasOwn?Object.hasOwn(e,t):ht(e,t),gt=e=>e,mt=e=>e.charAt(0).toUpperCase()+e.slice(1),bt=e=>e?.__esModule?e.default:e,yt=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${mt(t)}`)},vt=e=>(t,n="renamed to")=>(o,s,c="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>
2
-
3
- The <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${s}</>. ${c}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`),fe={br:`
4
- `,rb:"\x1B[31;1m",bb:"\x1B[34;1m",b:"\x1B[1m",i:"\x1B[3m",u:"\x1B[4m","/":"\x1B[m"},wt=Object.keys(fe),zt=new RegExp(`<(${wt.join("|")})>`,"gi"),It=(e,t)=>fe[t]??"",Et=e=>e.replace(zt,It),Tt=e=>e.replaceAll("<br>",`
5
- `).replaceAll(/<\/?[^>]+>/gi,""),de=e=>t=>e(V(t)?window.chrome?Et(t):Tt(t):t),i={},pe=bt(r);let q=!0;const Ot=pe({expand:!1,label:F}),Ht=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`,Rt=e=>i[e]?i[e].log:q;function Lt({enabled:e,expand:t,iframeId:n}){const o=pe({expand:t,label:Ht(n)});q=e,i[n]||(i[n]={console:o})}const w=e=>(t,...n)=>i[t]?i[t].console[e](...n):Ot[e](...n),he=e=>(t,...n)=>Rt(t)===!0?w(e)(t,...n):null,u=he("log"),m=u,Mt=he("debug"),z=w("warn"),St=w("error"),y=w("event"),$t=w("purge"),kt=w("endAutoGroup"),ge=w("errorBoundary");function At(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,q||t<1?ct:r.NORMAL))}const Gt=e=>(...t)=>[`${Y}(${e})`,...t].join(" "),jt=de(gt),b=(e,...t)=>i[e]?i[e].console.warn(...t.map(jt)):queueMicrotask(()=>{const n=de(Gt(e));console?.warn(...t.map(n))}),Nt=vt(b)("Option"),A=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:$,firstRun:!0,inPageLinks:!1,heightCalculationMethod:W,id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:W,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof i[e.id].onInit===ie&&(Nt("init()","onReady()","",e.id),i[e.id].onInit(e))},onResized(){},onScroll:()=>!0});let me=0;function Pt(e){const t=e?.id||A.id+me++;return document.getElementById(t)===null?t:`${t}${me++}`}function xt(e,t){let{id:n}=e;if(n&&!V(n))throw new TypeError("Invalid id for iFrame. Expected String");return(!n||n==="")&&(n=Pt(t),e.id=n,y(n,"assignId"),u(n,`Added missing iframe ID: ${n} (${e.src})`)),n}function Ct(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=U,e.logExpand=t.includes("ifrlog=expanded"))}const S=(e,t,n,o)=>e.addEventListener(t,n,o||!1),be=(e,t,n)=>e.removeEventListener(t,n,!1),Ft=e=>e.split(":").filter((t,n)=>n!==19).join(":");function _t(e,t,n){function o(f){const d=e in ae?Ft(t):t;m(n,f,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),m(n,`Message data: %c${d}`,r.HIGHLIGHT)}const{iframe:s,postMessageTarget:c,sameOrigin:a,targetOrigin:l}=i[n];if(a)try{s.contentWindow.iframeChildListener(k+t),o(`Sending message to iframe %c${n}%c via same origin%c`);return}catch{e in ae?(i[n].sameOrigin=!1,u(n,"New iframe does not support same origin")):z(n,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${l}`),c.postMessage(k+t,l)}function I(e,t,n){if(y(n,e),!i[n]?.postMessageTarget){z(n,"Iframe not found");return}_t(e,t,n)}const Wt=(e,t)=>Object.values(i).filter(({autoResize:n,firstRun:o})=>n&&!o).forEach(({iframe:n})=>I(e,t,n.id));function Bt(){document.hidden!==!0&&Wt("tabVisible",C)}function Dt(e){if(e.boxSizing!=="border-box")return 0;const t=e.paddingTop?parseInt(e.paddingTop,10):0,n=e.paddingBottom?parseInt(e.paddingBottom,10):0;return t+n}function Ut(e){if(e.boxSizing!=="border-box")return 0;const t=e.borderTopWidth?parseInt(e.borderTopWidth,10):0,n=e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0;return t+n}function Vt(e){const t=e.slice(B).split(":"),n=t[1]?Number(t[1]):0,o=i[t[0]]?.iframe,s=getComputedStyle(o),c={iframe:o,id:t[0],height:n+Dt(s)+Ut(s),width:Number(t[2]),type:t[3],msg:t[4],message:t[4]};return t[5]&&(c.mode=t[5]),c}const qt={true:1,false:1,undefined:1};function Zt(e){const{id:t,msg:n,iframe:o}=e,s=ft(o);return s||(u(t,`Received: %c${n}`,r.HIGHLIGHT),z(t,"The target iframe was not found.")),s}function Jt(e,t){function n(){function f(){u(o,`Checking connection is from allowed list of origins: %c${l}`,r.HIGHLIGHT);for(const g of l)if(g===c)return!0;return!1}function d(){const g=i[o]?.remoteHost;return u(o,`Checking connection is from: %c${g}`,r.HIGHLIGHT),c===g}return l.constructor===Array?f():d()}const{id:o}=e,{data:s,origin:c}=t;if("sameOrigin"in t&&t.sameOrigin)return!0;let l=i[o]?.checkOrigin;if(l&&`${c}`!="null"&&!n())throw new Error(`Unexpected message received from: ${c} for ${o}. Message was: ${s}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}const Yt=e=>k===`${e}`.slice(0,B)&&e.slice(B).split(":")[0]in i;function Xt(e){const{id:t,type:n}=e,o=n in qt;return o&&u(t,"Ignoring init message from meta parent page"),o}function Kt(e){try{i[e].sameOrigin=!!i[e]?.iframe?.contentWindow?.iframeChildListener}catch{i[e].sameOrigin=!1}u(e,`sameOrigin: %c${i[e].sameOrigin}`,r.HIGHLIGHT)}function Qt(e,t){if(t!==v){if(t===void 0){b(e,`<rb>Legacy version detected in iframe</>
6
-
7
- Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
8
-
9
- See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
10
- `);return}u(e,`Version mismatch (Child: %c${t}%c !== Parent: %c${v})`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT)}}function E(e,t,n){if(!i[e])return null;const o=i[e][t];if(typeof o!==ie)throw new TypeError(`${t} on iframe[${e}] is not a function`);if(t!=="onBeforeClose"&&t!=="onScroll")return dt(o,n);try{return o(n)}catch(s){return console.error(s),z(e,`Error in ${t} callback`),null}}function en(e,t){const{id:n,iframe:o}=e;u(n,`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT,r.FOREGROUND),E(n,"onMessage",{iframe:o,message:JSON.parse(t)})}function G(e,t){const{lastMessage:n}=i[e];return n.slice(n.indexOf(":")+at+t)}function ye(e,t){const{id:n,iframe:o,height:s,type:c,width:a}=t;let l={x:0,y:0};if(a===0&&s===0){const f=G(n,9).split(":");l={x:f[1],y:f[0]}}else l={x:a,y:s};E(n,e,{iframe:o,screenX:Number(l.x),screenY:Number(l.y),type:c})}const p={position:null,version:v};function ve(){p.position=null}const tn=()=>p.position;function nn(e){p.position=e}function we(e){return p.position===null&&(p.position={x:window.scrollX,y:window.scrollY}),u(e,`Get page position: %c${p.position.x}%c, %c${p.position.y}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),p.position}function ze(e){p.position!==null&&(window.scrollTo(p.position.x,p.position.y),m(e,`Set page position: %c${p.position.x}%c, %c${p.position.y}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),ve())}function Ie(e,t){const{id:n}=t,o=`${t[e]}px`;i[n].iframe.style[e]=o,m(n,`Set ${e}: %c${o}`,r.HIGHLIGHT)}function Ee(e){const{id:t}=e,{sizeHeight:n,sizeWidth:o}=i[t];n&&Ie(et,e),o&&Ie(tt,e)}function Te(e){const{id:t}=e;Ee(e),ze(t),E(t,"onResized",e)}function Oe(e){const{id:t}=e;u(t,"Disconnected from iframe"),delete i[t],delete e.iframeResizer}function He(e){const{id:t}=e;if(E(t,"onBeforeClose",t)===!1){u(t,"Close iframe cancelled by onBeforeClose");return}u(t,`Removing iFrame: %c${t}`,r.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(n){z(t,n)}E(t,"onAfterClose",t),Oe(e)}function Re(e){const{id:t,type:n}=e;u(t,`Size reset requested by ${n===R?"parent page":"child page"}`),we(t),Ee(e),I(x,x,t)}const Le=(e,t)=>{const n={};return(o,s)=>{const{iframe:c}=i[s];function a(f,d){n[d]||(f(),n[d]=requestAnimationFrame(()=>{n[d]=null}))}function l(){I(`${o} (${e})`,`${e}:${t(c)}`,s)}a(l,s)}},Me=e=>t=>{e in i[t]&&(i[t][e](),delete i[t][e])},Se=(e,t)=>n=>{let o=!1;const s=h=>()=>{i[n]?(!o||o===h)&&(e(h,n),o=h,requestAnimationFrame(()=>{o=!1})):f()},c=s(ne),a=s("resize window");function l(h,H){u(n,`${h}listeners for send${t}`),H(window,ne,c),H(window,C,a)}function f(){y(n,`stop${t}`),l("Remove ",be),g.disconnect(),O.disconnect(),i[n]&&be(i[n].iframe,P,f)}function d(){l("Add ",S),g.observe(document.body),O.observe(i[n].iframe)}const g=new ResizeObserver(s("pageObserver")),O=new ResizeObserver(s("iframeObserver"));i[n]&&(i[n][`stop${t}`]=f,S(i[n].iframe,P,f),d())};function on(e){const t=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),{scrollY:o,scrollX:s,innerHeight:c,innerWidth:a}=window,{clientHeight:l,clientWidth:f}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(l,c||0),clientWidth:Math.max(f,a||0),offsetTop:Math.trunc(n.top-t.top),offsetLeft:Math.trunc(n.left-t.left),scrollTop:o,scrollLeft:s,documentHeight:l,documentWidth:f,windowHeight:c,windowWidth:a})}const sn=Le(ee,on),rn=Se(sn,"PageInfo"),cn=Me("stopPageInfo");function an(e){const{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:o,height:s,offsetLeft:c,offsetTop:a,pageLeft:l,pageTop:f,scale:d}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:s,offsetLeft:c,offsetTop:a,pageLeft:l,pageTop:f,scale:d}})}const ln=Le(te,an),un=Se(ln,"ParentInfo"),fn=Me("stopParentInfo");function $e(e){const t=e.getBoundingClientRect(),n=we(e.id);return{x:Number(t.left)+Number(n.x),y:Number(t.top)+Number(n.y)}}function ke(e){const{x:t,y:n}=tn(),o=i[e]?.iframe;if(E(e,"onScroll",{iframe:o,top:n,left:t,x:t,y:n})===!1){ve();return}ze(e)}function dn(e){const{id:t,height:n,width:o}=e,s=window.parentIframe||window.parentIFrame||window;m(t,`scrollBy: x: %c${o}%c y: %c${n}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),s.scrollBy(o,n)}const Ae=e=>t=>{function n(h){nn(h),ke(c)}function o(h,H){h[`scrollTo${e?"Offset":""}`](H.x,H.y)}const s=h=>({x:f+h.x,y:l+h.y}),{id:c,iframe:a,height:l,width:f}=t,d=e?$e(a):{x:0,y:0},g=s(d),O=window.parentIframe||window.parentIFrame;m(c,`Reposition requested (offset x:%c${d.x}%c y:%c${d.y})`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),O?o(O,g):n(g)},pn=Ae(!1),hn=Ae(!0);function gn(e,t,n){const{x:o,y:s}=$e(n);m(e,`Moving to in page link: %c#${t}`,r.HIGHLIGHT),p.position={x:o,y:s},ke(e),window.location.hash=t}function mn(e,t){const n=window.parentIframe||window.parentIFrame;if(!n){u(e,`In page link #${t} not found`);return}n.moveToAnchor(t)}function bn(e,t){const n=t.split("#")[1]||"",o=decodeURIComponent(n),s=document.getElementById(o)||document.getElementsByName(o)[0];if(s){gn(e,n,s);return}if(window.top===window.self){u(e,`In page link #${n} not found`);return}mn(e,n)}function yn(e){const t=i[e]?.iframe?.title;return t===""||t===void 0}function vn(e,t){i[e]?.syncTitle&&(i[e].iframe.title=t,m(e,`Set iframe title attribute: %c${t}`,r.HIGHLIGHT))}const Ge=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,s=0;s<e.length;s++)o=e.codePointAt(s),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},T=e=>e.replace(/[A-Za-z]/g,t=>String.fromCodePoint((t<="Z"?90:122)>=(t=t.codePointAt(0)+19)?t:t-26)),j=["spjluzl","rlf","clyzpvu","rlf2"],wn=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."],zn=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],je=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,t)=>[e,Math.max(0,t-1)])),N=e=>T(wn[e]),In=e=>T(zn[e]),En=e=>{const t=e[T(j[0])]||e[T(j[1])]||e[T(j[2])]||e[T(j[3])];if(!t)return-1;const n=t.split("-");let o=(function(s=""){let c=-2;const a=Ge(T(s));return a in je&&(c=je[a]),c>4?c-4:c})(n[0]);return o===0||(s=>s[2]===Ge(s[0]+s[1]))(n)||(o=-2),o};let Z=!1,Ne=!1;function Pe(e,t=-3){if(Z)return;const n=Math.max(i[e].mode,t);if(n>i[e].mode&&(i[e].mode=n),n<0)throw $t(e),i[e].vAdvised||b(e||"Parent",`${N(n+2)}${N(2)}`),i[e].vAdvised=!0,N(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&Ne||At(`v${v} (${In(n)})`,n),n<1&&b("Parent",N(3)),Z=!0}function Tn(e){if(Z)return;const{mode:t}=i[e];t!==-1&&Pe(e,t)}function On(e){e?.log===-1&&(e.log=!1,Ne=!0)}function Hn(e,t){i[e]&&(u(e,`First run for ${e}`),Pe(e,t!==void 0?Number(t):void 0),i[e].firstRun=!1)}function Rn(e){const{height:t,id:n,iframe:o,mode:s,message:c,type:a,width:l}=e,{lastMessage:f}=i[n];switch(i[n]?.firstRun&&Hn(n,s),u(n,`Received: %c${f}`,r.HIGHLIGHT),a){case X:i[n].autoResize=JSON.parse(G(n,9));break;case We:m(n,"Ready state reset"),i[n].initialised=!1;break;case Be:He(o);break;case De:bn(n,G(n,9));break;case R:Te(e),Kt(n),Qt(n,c),i[n].initialised=!0,E(n,"onReady",o);break;case L:en(e,G(n,6));break;case Ve:ye("onMouseEnter",e);break;case qe:ye("onMouseLeave",e);break;case ee:rn(n);break;case te:un(n);break;case Ze:cn(n);break;case Je:fn(n);break;case x:Re(e);break;case Ye:dn(e);break;case Xe:pn(e);break;case Ke:hn(e);break;case Qe:vn(n,c);break;default:if(l===0&&t===0){z(n,`Unsupported message received (${a}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);return}if(l===0||t===0){u(n,"Ignoring message with 0 height or width");return}if(document.hidden){u(n,"Page hidden - ignored resize request");return}Te(e)}}const Ln=e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()},Mn=e=>Object.values(i).forEach(Ln(e));function xe(e){const t=e.data;if(t===_e){Mn(e.source);return}if(!Yt(t)){if(typeof t!==_)return;y(F,"ignoredMessage"),Mt(F,t);return}const n=Vt(t),{id:o,type:s}=n;switch(y(o,s),!0){case!i[o]:throw new Error(`${s} No settings for ${o}. Message was: ${t}`);case!Zt(n):case Xt(n):case!Jt(n,e):return;default:i[o].lastMessage=e.data,ge(o,Rn)(n)}}const Sn=pt(()=>{S(window,L,xe),S(document,"visibilitychange",Bt),window.iframeParentListener=e=>setTimeout(()=>xe({data:e,sameOrigin:!0}))}),Ce={};function $n(e){if(Ce[e]===!0)return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;Ce[e]=!0;const n=Array.from(t).flatMap(o=>[`
11
- `,o,`
12
- `]);return b(e,`<rb>Duplicate ID attributes detected</>
13
-
14
- The <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.
15
-
16
- Found <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...n,`
17
- `),!1}const kn=`<rb>Deprecated Method Name</>
18
-
19
- The <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${le}`,An=`<rb>Deprecated Method</>
20
-
21
- Use of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As there are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code.`;function Gn(e){if(i[e]){const{iframe:t}=i[e],n={close:He.bind(null,t),disconnect:Oe.bind(null,t),moveToAnchor(o){yt(o,_,"moveToAnchor(anchor) anchor"),I("Move to anchor",`moveToAnchor:${o}`,e)},removeListeners(){b(e,kn),this.disconnect()},resize(){b(e,An),I("Window resize",C,e)},sendMessage(o){o=JSON.stringify(o),I(L,`${L}:${o}`,e)}};t.iframeResizer=n,t.iFrameResizer=n}}const jn="8",Nn="32",Pn=st,xn=!0;function Cn(e){const{autoResize:t,bodyBackground:n,bodyMargin:o,bodyPadding:s,heightCalculationMethod:c,inPageLinks:a,license:l,log:f,logExpand:d,mouseEvents:g,offsetHeight:O,offsetWidth:h,mode:H,sizeHeight:yo,sizeWidth:vo,tolerance:wo,widthCalculationMethod:zo}=i[e];return[e,jn,vo,f,Nn,xn,t,o,c,n,s,wo,a,Pn,zo,g,O,h,yo,l,p.version,H,"",d].join(":")}const Fn="0";function _n(e){const{bodyMargin:t}=i[e];(typeof t===rt||t===Fn)&&(i[e].bodyMargin=`${t}px`)}const Wn=e=>{try{return new URL(e).origin}catch{return null}},Bn=e=>typeof e===oe&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin"));function Dn(e,t){const{checkOrigin:n,iframe:{src:o,sandbox:s},initialisedFirstPage:c,waitForLoad:a}=t[e],l=Wn(o);y(e,"noResponse"),b(e,`<rb>No response from iframe</>
22
-
23
- The iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
24
- ${n&&l?`
25
- The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${l}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.
26
- `:""}${a&&!c?`
27
- The <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.
28
- `:""}${Bn(s)?`
29
- The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
30
- `:""}
31
- This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
32
- `)}function Un(e,t){function n(){if(t[e]===void 0)return;const{initialised:c,loadErrorShown:a}=t[e];if(t[e].msgTimeout=void 0,c){t[e].initialisedFirstPage=!0;return}a||(t[e].loadErrorShown=!0,Dn(e,t))}const{msgTimeout:o,warningTimeout:s}=t[e];s&&(o&&clearTimeout(o),t[e].msgTimeout=setTimeout(n,s))}const Vn=1,qn=e=>e.loading===Ue,Zn=e=>e===R;function Jn(e){i[e]?.heightCalculationMethod in lt&&Re({id:e,iframe:i[e].iframe,height:1,width:1,type:R})}function Yn(e,t){S(e,P,()=>setTimeout(t,Vn))}const Xn=e=>{const{src:t,srcdoc:n}=e;return!n&&(t==null||t===""||t==="about:blank")};function Kn(e,t){const{iframe:n,waitForLoad:o}=i[e];if(o!==!0){if(Xn(n)){setTimeout(()=>{y(e,"noContent"),m(e,"No content detected in the iframe, delaying initialisation")});return}setTimeout(t)}}function Qn(e,t){const n=s=>()=>{if(!i[e])return;const{firstRun:c,iframe:a}=i[e];I(s,t,e),Zn(s)&&qn(a)||Un(e,i),c||Jn(e)},{iframe:o}=i[e];i[e].initChild=n(K),Yn(o,n(Q)),Kn(e,n(R))}function eo(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||X in t)&&b(e,`<rb>Deprecated Option</>
33
-
34
- The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${$}</>, <bb>${ce}</>, <bb>${re}</> or <bb>${se}</>.
35
- `),t):{}}function to(e){i[e].warningTimeout||m(e,"warningTimeout:%c disabled",r.HIGHLIGHT)}function no(e,{offset:t,offsetSize:n}){const o=n||t;o&&(i[e].direction===$?(i[e].offsetHeight=o,u(e,`Offset height: %c${o}`,r.HIGHLIGHT)):(i[e].offsetWidth=o,u(e,`Offset width: %c${o}`,r.HIGHLIGHT)))}function oo(e){const{direction:t}=i[e];switch(t){case $:break;case ce:i[e].sizeHeight=!1;case re:i[e].sizeWidth=!0;break;case se:i[e].sizeWidth=!1,i[e].sizeHeight=!1,i[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${t}" is not valid`)}u(e,`direction: %c${t}`,r.HIGHLIGHT)}const io=e=>e===""||e.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":e;function so(e){i[e].targetOrigin=i[e].checkOrigin===!0?io(i[e].remoteHost):"*"}function ro(e){const{id:t}=e;i[t].postMessageTarget===null&&(i[t].postMessageTarget=e.contentWindow)}function J(e,t,n){M(i[e],t)&&(b(e,`<rb>Deprecated option</>
36
-
37
- The <b>${t}</> option has been renamed to <b>${n}</>. ${le}`),i[e][n]=i[e][t],delete i[e][t])}function co(e){J(e,nt,ot),J(e,"onClose","onBeforeClose"),J(e,"onClosed","onAfterClose")}const ao=e=>M(e,"onMouseEnter")||M(e,"onMouseLeave");function lo(e,t){const{id:n}=e;i[n]={...i[n],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...A,...eo(n,t),mouseEvents:ao(t),mode:En(t),syncTitle:yn(n)},co(n),oo(n),no(n,t),to(n),ro(e),so(n)}const uo="yes",Fe="no",fo="omit";function po(e){const{id:t}=e;switch(u(t,`Iframe scrolling ${i[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=i[t]?.scrolling===!1?it:W,i[t]?.scrolling){case fo:break;case!0:e.scrolling=uo;break;case!1:e.scrolling=Fe;break;default:e.scrolling=i[t]?.scrolling||Fe}}function ho(e,t,n){lo(t,n),u(e,`src: %c${t.srcdoc||t.src}`,r.HIGHLIGHT),Tn(e),po(t),_n(e),Qn(e,Cn(e)),Gn(e),u(e,"Setup complete")}function go(e,t){const{id:n}=e;y(n,"setup"),$n(n)&&ho(n,e,t),kt(n)}function mo(e,t){const n=M(t,"log"),o=V(t.log),s=n?o?!0:t.log:A.log;M(t,"logExpand")||(t.logExpand=n&&o?t.log===D:A.logExpand),On(t),Lt({enabled:s,expand:t.logExpand,iframeId:e}),o&&!(t.log in ut)&&St(e,`Invalid value for options.log: Accepted values are "${D}" and "${U}"`),t.log=s}function bo(e){if(!ue(e))throw new TypeError("Options is not an object");return Sn(),Ct(e),t=>{const n=xt(t,e);return Y in t?(y(n,"alreadySetup"),z(n,`Ignored iframe (${n}), already setup.`)):(mo(n,e),ge(n,go)(t,e)),t?.iframeResizer}}return bo}));
1
+ /*!
2
+ * @preserve
3
+ *
4
+ * @module iframe-resizer/core 6.0.0-beta.10 (esm) - 2026-04-16
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(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).connectResizer={})}(this,function(e){"use strict";const t=e=>"object"==typeof e&&null!==e,n=e=>"string"==typeof e;const o=(e,t)=>Object.hasOwn?Object.hasOwn(e,t):((e,t)=>Object.prototype.hasOwnProperty.call(e,t))(e,t),i={br:"\n",rb:"",bb:"",b:"",i:"",u:"","/":""},r=Object.keys(i),a=new RegExp(`<(${r.join("|")})>`,"gi"),l=(e,t)=>i[t]??"",s=e=>t=>e(n(t)?window.chrome?t.replace(a,l):(e=>e.replaceAll("<br>","\n").replaceAll(/<\/?[^>]+>/gi,""))(t):t),c=(e,t,n,o)=>e.addEventListener(t,n,o||!1),u=(e,t,n)=>e.removeEventListener(t,n,!1),f=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,i=0;i<e.length;i++)o=e.codePointAt(i),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},d=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),p=new Date,h=e=>new Set(Array.from({length:9},e)),y=" - lewpylk",m=["spjluzl","rlf","clyzpvu","rlf2","nlaMbssFlhy"],g=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>. Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Fvb hyl jbyyluasf bzpun h spjluzl rlf mvy aol wylcpvbz clyzpvu vm <p>pmyhtl-ylzpgly</>.</><iy><iy>Av bwnyhkl av <i>Clyzpvu 6</> fvb jhu bzl aol <i>mpyza 11 johyhjalyz vm fvb spjluzl rlf</> av nla h 60% kpzjvbua ha oaawz://pmyhtl-ylzpgly.jvt/wypjpun.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Fvb hyl jbyyluasf bzpun h spjluzl rlf mvy aol wylcpvbz clyzpvu vm <p>pmyhtl-ylzpgly</>.<iy><iy>Av bwnyhkl av <i>Clyzpvu 6</> vm <p>pmyhtl-ylzpgly</> wslhzl kvdusvhk aol shalza rlf myvt:<iy><iy>oaawz://pmyhtl-ylzpgly.jvt/tf-vyklyz","<yi> VLT rlf lewpylk</><iy><iy>Aol spjluzl rlf fvb hyl bzpun mvy <p>pmyhtl-ylzpgly</> pz myvt h wypvy flhy huk ohz lewpylk. Hu bwkhalk rlf pz ylslhzlk vu aol mpyza vm Uvcltily lhjo flhy.<iy><iy>Wslhzl kvdusvhk aol shalza rlf myvt:<iy><iy>oaawz://pmyhtl-ylzpgly.jvt/tf-vyklyz","<yi>Bzl dpao slnhjf jspluaz</><iy><iy>Dolu bzpun <p>pmyhtl-ylzpgly</> jopsk whjrhnl dpao hu vskly clyzpvu vm aol whylua, fvb jhu zla aol spjluzl rlf pu aol pmyhtl. Mvy klahpsz vu ovd av zla aopz bw, wslhzl zll aol kvjbtluahapvu ha:<iy><iy>oaawz://pmyhtl-ylzpgly.jvt/zlabw/jopsk/#spjluzl"],b=[(j=["NWSc3","zvsv","wyv","ibzpulzz","VLT"])[0],...j.slice(1).map(e=>`${e}${y}`),`${j[4]}${y}`,...j.slice(1)],v=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","1foobarqaz","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl","igb1wzrjqr"].map((e,t)=>[e,Math.max(0,t-1)])),z=p[d(m[4])](),w=h((e,t)=>f(`${z+t}`)),$=h((e,t)=>f(""+(z-++t)));var j;const k=e=>d(g[e]),M=e=>{const t=e[d(m[0])]||e[d(m[1])]||e[d(m[2])]||e[d(m[3])];if(!t)return-1;const n=t.split("-");let o=function(e="",t=""){let n=-2;const o=f(d(e));return o in v&&(n=v[o]),9===n?(i=t,w.has(i)?9:$.has(i)?5:-2):n;var i}(...n);return 0===o||(i=n)[2]===f(i[0]+i[1])||(o=-2),o;var i},T="6.0.0-beta.10",x="iframeResizer",S=":",O="autoResize",E="init",C="iframeReady",I="load",R="message",A="onload",L="pageInfo",W="parentInfo",P="reset",N="resize",B="scroll",F="parent",H="string",D="auto",q="none",U="both",V="vertical",G="horizontal",J="[iFrameSizer]",_=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),Z=Object.freeze({[A]:1,[E]:1,[C]:1}),X="expanded",Y="collapsed",K=Object.freeze({[X]:1,[Y]:1}),Q="font-weight: normal;",ee=Q+"font-style: italic;",te="default",ne=Object.freeze({assert:!0,error:!0,warn:!0}),oe={expand:!1,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},ie={profile:0,profileEnd:0,timeStamp:0,trace:0},re=Object.assign(console);const{fromEntries:ae,keys:le}=Object,se=e=>[e,re[e]],ce=e=>t=>[t,function(n){e[t]=n}],ue=(e,t)=>ae(le(e).map(t));const fe=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,de=fe?"color: #A9C7FB;":"color: #135CD2;",pe=fe?"color: #E3E3E3;":"color: #1F1F1F;",he={},ye=(me=function(e={}){const t={},n={},o=[],i={...oe,expand:!e.collapsed||oe.expanded,...e};let r="";function a(){o.length=0,r=""}function l(){delete i.event,a()}const s=()=>!!o.some(([e])=>e in ne)||!!i.expand;function c(){if(0!==o.length){re[s()?"group":"groupCollapsed"](`%c${i.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(i)} %c${i.showTime?r:""}`,Q,"font-weight: bold;",ee);for(const[e,...t]of o)re.assert(e in re,`Unknown console method: ${e}`),e in re&&re[e](...t);re.groupEnd(),l()}else l()}function u(){""===r&&(r=function(){const e=new Date,t=(t,n)=>e[t]().toString().padStart(n,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}(),queueMicrotask(()=>queueMicrotask(c)))}function f(e,...t){0===o.length&&u(),o.push([e,...t])}function d(e=te,...n){t[e]?f("log",`${e}: ${performance.now()-t[e]} ms`,...n):f("timeLog",e,...n)}return{...ue(i,ce(i)),...ue(console,e=>[e,(...t)=>f(e,...t)]),...ue(ie,se),assert:function(e,...t){!0!==e&&f("assert",e,...t)},count:function(e=te){n[e]?n[e]+=1:n[e]=1,f("log",`${e}: ${n[e]}`)},countReset:function(e=te){delete n[e]},endAutoGroup:c,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(o){if(!Error.prototype.isPrototypeOf(o))throw o;f("error",o),c()}return n},event:function(e){u(),i.event=e},purge:a,time:function(e=te){u(),t[e]=performance.now()},timeEnd:function(e=te){d(e),delete t[e]},timeLog:d,touch:u}},me?.__esModule?me.default:me);var me;let ge=!0;const be=ye({expand:!1,label:F}),ve=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const ze=e=>(t,...n)=>he[t]?he[t].console[e](...n):be[e](...n),we=e=>(t,...n)=>!0===(e=>he[e]?he[e].log:ge)(t)?ze(e)(t,...n):null,$e=we("log"),je=$e,ke=we("debug"),Me=ze("warn"),Te=ze("error"),xe=ze("event"),Se=ze("purge"),Oe=ze("endAutoGroup"),Ee=ze("errorBoundary");const Ce=s(e=>e),Ie=(e,...t)=>he[e]?he[e].console.warn(...t.map(Ce)):queueMicrotask(()=>{const n=s((e=>(...t)=>[`${x}(${e})`,...t].join(" "))(e));console?.warn(...t.map(n))}),Re=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:V,firstRun:!0,inPageLinks:!1,heightCalculationMethod:D,id:"iframeResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:D,onBeforeClose:()=>!0,onAfterClose(){},onMessage(){console.warn("","onMessage function not defined")},onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let Ae=0;function Le(e,t){let{id:o}=e;if(o&&!n(o))throw new TypeError("Invalid id for iframe. Expected String");return o&&""!==o||(o=function(e){const t=e?.id||Re.id+Ae++;return null===document.getElementById(t)?t:`${t}${Ae++}`}(t),e.id=o,xe(o,"assignId"),$e(o,`Added missing iframe ID: ${o} (${e.src})`)),o}function We(e,t,n){function o(o){const i=e in Z?(e=>e.split(S).filter((e,t)=>19!==t).join(S))(t):t;je(n,o,de,pe,de),je(n,`Message data: %c${i}`,de)}const{iframe:i,postMessageTarget:r,sameOrigin:a,targetOrigin:l}=he[n];if(a)try{return i.contentWindow.iframeChildListener(J+t),void o(`Sending message to iframe %c${n}%c via same origin%c`)}catch(s){e in Z?(he[n].sameOrigin=!1,$e(n,"New iframe does not support same origin")):Me(n,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${l.join(", ")}`);for(const c of l)r.postMessage(J+t,c)}function Pe(e,t,n){xe(n,e),he[n]?.postMessageTarget?We(e,t,n):Me(n,"Iframe not found")}function Ne(){var e,t;!0!==document.hidden&&(e="tabVisible",t=N,Object.values(he).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:n})=>Pe(e,t,n.id)))}function Be(e){const t=e.slice(13).split(":"),n=t[1]?Number(t[1]):0,o=he[t[0]]?.iframe,i=o?getComputedStyle(o):null,r=i?function(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}(i)+function(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}(i):0,a={iframe:o,id:t[0],height:n+r,width:Number(t[2]),type:t[3],message:t[4]};return t[5]&&(a.mode=t[5]),a}const Fe={true:1,false:1,undefined:1};function He(e){const{id:n,message:o,iframe:i}=e,r=function(e){if(!t(e))return!1;try{return"IFRAME"===e.tagName||e instanceof HTMLIFrameElement}catch(n){return!1}}(i);return r||($e(n,`Received: %c${o}`,de),Me(n,"The target iframe was not found.")),r}function De(e,t,n){if(!he[e])return null;const o=he[e][t];if("function"!=typeof o)throw new TypeError(`${t} on iframe[${e}] is not a function`);if("onBeforeClose"!==t&&"onScroll"!==t)return((e,...t)=>setTimeout(()=>e(...t),0))(o,n);try{return o(n)}catch(i){return console.error(i),Me(e,`Error in ${t} callback`),null}}function qe(e,t){const{lastMessage:n}=he[e];return n.slice(n.indexOf(S)+7+t)}function Ue(e,t){const{id:n,iframe:o,height:i,type:r,width:a}=t;let l={x:0,y:0};if(0===a&&0===i){const e=qe(n,9).split(S);l={x:e[1],y:e[0]}}else l={x:a,y:i};De(n,e,{iframe:o,screenX:Number(l.x),screenY:Number(l.y),type:r})}const Ve={position:null,version:T};function Ge(){Ve.position=null}function Je(e){return null===Ve.position&&(Ve.position={x:window.scrollX,y:window.scrollY}),$e(e,`Get page position: %c${Ve.position.x}%c, %c${Ve.position.y}`,de,pe,de),Ve.position}function _e(e){null!==Ve.position&&(window.scrollTo(Ve.position.x,Ve.position.y),je(e,`Set page position: %c${Ve.position.x}%c, %c${Ve.position.y}`,de,pe,de),Ge())}function Ze(e,t){const{id:n}=t,o=`${t[e]}px`;he[n].iframe.style[e]=o,je(n,`Set ${e}: %c${o}`,de)}function Xe(e){const{id:t}=e,{sizeHeight:n,sizeWidth:o}=he[t];n&&Ze("height",e),o&&Ze("width",e)}function Ye(e){const{id:t}=e;Xe(e),_e(t),De(t,"onResized",e)}function Ke(e){const{id:t}=e;$e(t,"Disconnected from iframe"),delete he[t],delete e.iframeResizer}function Qe(e){const{id:t}=e;if(!1!==De(t,"onBeforeClose",t)){$e(t,`Removing iframe: %c${t}`,de);try{e.parentNode&&e.remove()}catch(n){Me(t,n)}De(t,"onAfterClose",t),Ke(e)}else $e(t,"Close iframe cancelled by onBeforeClose")}function et(e){const{id:t,type:n}=e;$e(t,"Size reset requested by "+(n===E?"parent page":"child page")),Je(t),Xe(e),Pe(P,P,t)}const tt=(e,t)=>{const n={};return(o,i)=>{const{iframe:r}=he[i];var a,l;a=function(){Pe(`${o} (${e})`,`${e}:${t(r)}`,i)},n[l=i]||(a(),n[l]=requestAnimationFrame(()=>{n[l]=null}))}},nt=e=>t=>{e in he[t]&&(he[t][e](),delete he[t][e])},ot=(e,t)=>n=>{let o=!1;const i=t=>()=>{he[n]?o&&o!==t||(e(t,n),o=t,requestAnimationFrame(()=>{o=!1})):d()},r=i(B),a=i("resize window"),l=new ResizeObserver(i("pageObserver")),s=new ResizeObserver(i("iframeObserver"));function f(e,o){$e(n,`${e}listeners for send${t}`),o(window,B,r),o(window,N,a)}function d(){xe(n,`stop${t}`),f("Remove ",u),l.disconnect(),s.disconnect(),he[n]&&u(he[n].iframe,I,d)}he[n]&&(he[n][`stop${t}`]=d,c(he[n].iframe,I,d),f("Add ",c),l.observe(document.body),s.observe(he[n].iframe))};const it=ot(tt(L,function(e){const t=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),{scrollY:o,scrollX:i,innerHeight:r,innerWidth:a}=window,{clientHeight:l,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(l,r||0),clientWidth:Math.max(s,a||0),offsetTop:Math.trunc(n.top-t.top),offsetLeft:Math.trunc(n.left-t.left),scrollTop:o,scrollLeft:i,documentHeight:l,documentWidth:s,windowHeight:r,windowWidth:a})}),"PageInfo"),rt=nt("stopPageInfo");const at=ot(tt(W,function(e){const{scrollWidth:t,scrollHeight:n}=document.documentElement,o="undefined"!=typeof window&&window.visualViewport?window.visualViewport:{},{width:i=0,height:r=0,offsetLeft:a=0,offsetTop:l=0,pageLeft:s=0,pageTop:c=0,scale:u=1}=o;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:i,height:r,offsetLeft:a,offsetTop:l,pageLeft:s,pageTop:c,scale:u}})}),"ParentInfo"),lt=nt("stopParentInfo");function st(e){const t=e.getBoundingClientRect(),n=Je(e.id);return{x:Number(t.left)+Number(n.x),y:Number(t.top)+Number(n.y)}}function ct(e){const{x:t,y:n}=Ve.position,o=he[e]?.iframe;!1!==De(e,"onScroll",{iframe:o,top:n,left:t,x:t,y:n})?_e(e):Ge()}const ut=e=>t=>{const{id:n,iframe:o,height:i,width:r}=t;const a=e?st(o):{x:0,y:0},l={x:r+(s=a).x,y:i+s.y};var s;const c=window.parentIframe||window.parentIFrame;var u;je(n,`Reposition requested (offset x:%c${a.x}%c y:%c${a.y})`,de,pe,de),c?(u=l,c["scrollTo"+(e?"Offset":"")](u.x,u.y)):function(e){var t;t=e,Ve.position=t,ct(n)}(l)},ft=ut(!1),dt=ut(!0);function pt(e,t){const n=t.split("#")[1]||"",o=decodeURIComponent(n),i=document.getElementById(o)||document.getElementsByName(o)[0];i?function(e,t,n){const{x:o,y:i}=st(n);je(e,`Moving to in page link: %c#${t}`,de),Ve.position={x:o,y:i},ct(e),window.location.hash=t}(e,n,i):window.top!==window.self?function(e,t){const n=window.parentIframe||window.parentIFrame;n?n.moveToAnchor(t):$e(e,`In page link #${t} not found`)}(e,n):$e(e,`In page link #${n} not found`)}function ht(e){const t=he[e]?.iframe?.title;return""===t||void 0===t}let yt=!1,mt=!1;function gt(e,t=-3){if(yt)return;const n=Math.max(he[e].mode,t);if(n>he[e].mode&&(he[e].mode=n),n<0)throw Se(e),he[e].vAdvised||Ie(e||"Parent",`${k(n+2)}${k(2)}`),he[e].vAdvised=!0,k(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");var o;switch(n>5&&mt||function(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,ge||t<1?"font-weight: bold;":Q))}(`v${T} (${o=n,d(b[o])})`,n),n){case 1:case 2:case 3:Ie("Parent",k(6));break;case 4:Ie("Parent",k(7));break;case 5:Ie("Parent",k(8));break;default:n<1&&Ie("Parent",k(3))}yt=!0}function bt(e){const{height:t,id:n,iframe:o,mode:i,message:r,type:a,width:l}=e,{lastMessage:s}=he[n];switch(he[n]?.firstRun&&function(e,t){he[e]&&($e(e,`First run for ${e}`),gt(e,void 0===t?void 0:Number(t)),he[e].firstRun=!1)}(n,i),$e(n,`Received: %c${s}`,de),a){case O:he[n].autoResize=JSON.parse(qe(n,9));break;case"beforeUnload":je(n,"Ready state reset"),he[n].initialised=!1;break;case"close":Qe(o);break;case"inPageLink":pt(n,qe(n,9));break;case E:Ye(e),function(e){try{he[e].sameOrigin=!!he[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){he[e].sameOrigin=!1}$e(e,`sameOrigin: %c${he[e].sameOrigin}`,de)}(n),function(e,t){t!==T&&(void 0!==t?$e(e,`Version mismatch (Child: %c${t}%c !== Parent: %c${T})`,de,pe,de):Ie(e,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n"))}(n,r),he[n].initialised=!0,De(n,"onReady",o);break;case R:!function(e,t){const{id:n,iframe:o}=e;$e(n,`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,de,pe,de,pe),De(n,"onMessage",{iframe:o,message:JSON.parse(t)})}(e,qe(n,6));break;case"mouseenter":Ue("onMouseEnter",e);break;case"mouseleave":Ue("onMouseLeave",e);break;case L:it(n);break;case W:at(n);break;case"pageInfoStop":rt(n);break;case"parentInfoStop":lt(n);break;case P:et(e);break;case"scrollBy":!function(e){const{id:t,height:n,width:o}=e,i=window.parentIframe||window.parentIFrame||window;je(t,`scrollBy: x: %c${o}%c y: %c${n}`,de,pe,de),i.scrollBy(o,n)}(e);break;case"scrollTo":ft(e);break;case"scrollToOffset":dt(e);break;case"title":!function(e,t){he[e]?.syncTitle&&(he[e].iframe.title=t,je(e,`Set iframe title attribute: %c${t}`,de))}(n,r);break;default:if(0===l&&0===t)return void Me(n,`Unsupported message received (${a}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===t)return void $e(n,"Ignoring message with 0 height or width");if(document.hidden)return void $e(n,"Page hidden - ignored resize request");Ye(e)}}function vt(e){const t=e.data;if("[iFrameResizerChild]Ready"===t)return n=e.source,void Object.values(he).forEach((e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()})(n));var n,o;if(J!==`${o=t}`.slice(0,13)||!(o.slice(13).split(":")[0]in he)){if(typeof t!==H)return;return xe(F,"ignoredMessage"),void ke(F,t)}const i=Be(t),{id:r,type:a}=i;switch(xe(r,a),!0){case!he[r]:throw new Error(`${a} No settings for ${r}. Message was: ${t}`);case!He(i):case function(e){const{id:t,type:n}=e,o=n in Fe;return o&&$e(t,"Ignoring init message from meta parent page"),o}(i):case!function(e,t){const{id:n}=e,{data:o,origin:i}=t;if("sameOrigin"in t&&t.sameOrigin)return!0;const r=he[n]?.checkOrigin;if(r&&"null"!=`${i}`&&!(r.constructor===Array?function(){$e(n,`Checking connection is from allowed list of origins: %c${r}`,de);for(const e of r)if(e===i)return!0;return!1}():function(){const e=he[n]?.remoteHost;return $e(n,`Checking connection is from: %c${e}`,de),i===e}()))throw new Error(`Unexpected message received from: ${i} for ${n}. Message was: ${o}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}(i,e):return;default:he[r].lastMessage=e.data,Ee(r,bt)(i)}}const zt=(e=>{let t=!1;return function(...n){return t?void 0:(t=!0,e.apply(this,n))}})(()=>{c(window,R,vt),c(document,"visibilitychange",Ne),window.iframeParentListener=e=>setTimeout(()=>vt({data:e,sameOrigin:!0}))}),wt={};function $t(e){if(he[e]){const{iframe:t}=he[e];t.iframeResizer={close:Qe.bind(null,t),disconnect:Ke.bind(null,t),moveToAnchor(t){((e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(t,H,"moveToAnchor(anchor) anchor"),Pe("Move to anchor",`moveToAnchor:${t}`,e)},sendMessage(t){t=JSON.stringify(t),Pe(R,`${R}:${t}`,e)}}}}const jt="8",kt="32",Mt="child",Tt=!0;function xt(e,t){const{checkOrigin:n,iframe:{src:o,sandbox:i},initialisedFirstPage:r,waitForLoad:a}=t[e],l=(e=>{try{return new URL(e).origin}catch(t){return null}})(o);xe(e,"noResponse"),Ie(e,`<rb>No response from iframe</>\n\nThe iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${n&&l?`\nThe <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${l}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.\n`:""}${a&&!r?"\nThe <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.\n":""}${(e=>"object"==typeof e&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(i)?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}function St(e,t){const n=n=>()=>{if(!he[e])return;const{firstRun:o,iframe:i}=he[e];Pe(n,t,e),(e=>e===E)(n)&&(e=>"lazy"===e.loading)(i)||function(e,t){const{msgTimeout:n,warningTimeout:o}=t[e];o&&(n&&clearTimeout(n),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:n,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,n?t[e].initialisedFirstPage=!0:o||(t[e].loadErrorShown=!0,xt(e,t))},o))}(e,he),o||function(e){he[e]?.heightCalculationMethod in _&&et({id:e,iframe:he[e].iframe,height:1,width:1,type:E})}(e)},{iframe:o}=he[e];he[e].initChild=n(C),function(e,t){c(e,I,()=>setTimeout(t,1))}(o,n(A)),function(e,t){const{iframe:n,waitForLoad:o}=he[e];!0!==o&&((e=>{const{src:t,srcdoc:n}=e;return!n&&(null==t||""===t||"about:blank"===t)})(n)?setTimeout(()=>{xe(e,"noContent"),je(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,n(E))}function Ot(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||O in t)&&Ie(e,`<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${V}</>, <bb>${G}</>, <bb>${U}</> or <bb>${q}</>.\n`),t):{}}const Et=e=>""===e||null!==e.match(/^(about:blank|javascript:|file:\/\/)/)?"*":e;function Ct(e,t,n){o(he[e],t)&&(Ie(e,`<rb>Deprecated option</>\n\nThe <b>${t}</> option has been renamed to <b>${n}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),he[e][n]=he[e][t],delete he[e][t])}const It=e=>o(e,"onMouseEnter")||o(e,"onMouseLeave");function Rt(e,t){const{id:n}=e;he[n]={...he[n],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...Re,...Ot(n,t),mouseEvents:It(t),mode:M(t),syncTitle:ht(n)},function(e){Ct(e,"offset","offsetSize"),Ct(e,"onClose","onBeforeClose"),Ct(e,"onClosed","onAfterClose")}(n),function(e){const{direction:t}=he[e];switch(t){case V:break;case G:he[e].sizeHeight=!1;case U:he[e].sizeWidth=!0;break;case q:he[e].sizeWidth=!1,he[e].sizeHeight=!1,he[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${t}" is not valid`)}$e(e,`direction: %c${t}`,de)}(n),function(e,{offset:t,offsetSize:n}){const o=n||t;o&&(he[e].direction===V?(he[e].offsetHeight=o,$e(e,`Offset height: %c${o}`,de)):(he[e].offsetWidth=o,$e(e,`Offset width: %c${o}`,de)))}(n,t),function(e){he[e].warningTimeout||je(e,"warningTimeout:%c disabled",de)}(n),function(e){const{id:t}=e;null===he[t].postMessageTarget&&(he[t].postMessageTarget=e.contentWindow)}(e),function(e){const{checkOrigin:t,remoteHost:n}=he[e];Array.isArray(t)&&0===t.length&&Me(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),he[e].targetOrigin=Array.isArray(t)?t.map(Et):[!1===t?"*":Et(n)]}(n)}function At(e,t,n){Rt(t,n),$e(e,`src: %c${t.srcdoc||t.src}`,de),function(e){if(yt)return;const{mode:t}=he[e];t>5&&gt(e,t)}(e),function(e){const{id:t}=e;switch($e(t,`Iframe scrolling ${he[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=!1===he[t]?.scrolling?"hidden":D,he[t]?.scrolling){case"omit":break;case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=he[t]?.scrolling||"no"}}(t),function(e){const{bodyMargin:t}=he[e];"number"!=typeof t&&"0"!==t||(he[e].bodyMargin=`${t}px`)}(e),St(e,function(e){const{autoResize:t,bodyBackground:n,bodyMargin:o,bodyPadding:i,heightCalculationMethod:r,inPageLinks:a,license:l,log:s,logExpand:c,mouseEvents:u,offsetHeight:f,offsetWidth:d,mode:p,sizeHeight:h,sizeWidth:y,tolerance:m,widthCalculationMethod:g}=he[e];return[e,jt,y,s,kt,Tt,t,o,r,n,i,m,a,Mt,g,u,f,d,h,l,Ve.version,p,"",c].join(S)}(e)),$t(e),$e(e,"Setup complete")}function Lt(e,t){const{id:n}=e;xe(n,"setup"),function(e){if(!0===wt[e])return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;wt[e]=!0;const n=Array.from(t).flatMap(e=>["\n",e,"\n"]);return Ie(e,`<rb>Duplicate ID attributes detected</>\n\nThe <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.\n\nFound <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...n,"\n"),!1}(n)&&At(n,e,t),Oe(n)}function Wt(e,t){0===t.log?t.log=!1:1===t.log?t.log=Y:2===t.log&&(t.log=X);const i=o(t,"log"),r=n(t.log),a=i?!!r||t.log:Re.log;o(t,"logExpand")||(t.logExpand=i&&r?t.log===X:Re.logExpand),function(e){-1===e?.log&&(e.log=!1,mt=!0)}(t),function({enabled:e,expand:t,iframeId:n}){const o=ye({expand:t,label:ve(n)});ge=e,he[n]||(he[n]={console:o})}({enabled:a,expand:t.logExpand,iframeId:e}),r&&!(t.log in K)&&Te(e,`Invalid value for options.log: Accepted values are "${X}" and "${Y}"`),t.log=a}e.LOG_COLLAPSED=1,e.LOG_DISABLED=0,e.LOG_EXPANDED=2,e.default=function(e){if(!t(e))throw new TypeError("Options is not an object");return zt(),function(e){const{search:t}=window.location;if(t.includes("ifrlog"))switch(new URLSearchParams(t).get("ifrlog")){case String(0):e.log=!1;break;case X:case String(2):e.log=X;break;case Y:case String(1):default:e.log=Y}}(e),t=>{const n=Le(t,e);return x in t?(xe(n,"alreadySetup"),Me(n,`Ignored iframe (${n}), already setup.`)):(Wt(n,e),Ee(n,Lt)(t,e)),t.iframeResizer}},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
38
21
  //# sourceMappingURL=index.umd.js.map