@iframe-resizer/core 5.5.9-beta.1 → 6.0.0-beta.0

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,21 +1,38 @@
1
- /*!
2
- * @preserve
3
- *
4
- * @module iframe-resizer/core 5.5.9-beta.1 (umd) - 2026-02-05
5
- *
6
- * @license GPL-3.0 for non-commercial use only.
7
- * For commercial use, you must 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,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],i):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=i(e.acg)}(this,function(e){"use strict";const i="5.5.9-beta.1",t="iframeResizer",n=":",o="autoResize",r="init",s="iframeReady",a="load",l="message",c="onload",u="pageInfo",d="parentInfo",f="reset",p="resize",m="scroll",h="\n",g="child",y="parent",b="string",v="object",w="function",z="auto",H="none",I="both",$="vertical",T="horizontal",j="[iFrameSizer]",k=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),G=Object.freeze({[c]:1,[r]:1,[s]:1}),O="expanded",R="collapsed",x=Object.freeze({[O]:1,[R]:1}),L="Use of the old name will be removed in a future version of <i>iframe-resizer</>.",M=(e,i,t,n)=>e.addEventListener(i,t,n||!1),S=(e,i,t)=>e.removeEventListener(i,t,!1),E=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),i=Math.imul(i^n,2246822519),t=Math.imul(t^n,3266489917);return i^=Math.imul(i^t>>>15,1935289751),t^=Math.imul(t^i>>>15,3405138345),i^=t>>>16,t^=i>>>16,(2097152*(t>>>0)+(i>>>11)).toString(36)},C=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),N=["spjluzl","rlf","clyzpvu"],W=["<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."],A=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],F=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,i)=>[e,Math.max(0,i-1)])),D=e=>C(W[e]),P=e=>{const i=e[C(N[0])]||e[C(N[1])]||e[C(N[2])];if(!i)return-1;const t=i.split("-");let n=function(e=""){let i=-2;const t=E(C(e));return t in F&&(i=F[t]),i>4?i-4:i}(t[0]);return 0===n||(e=>e[2]===E(e[0]+e[1]))(t)||(n=-2),n},B=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),q={br:"\n",rb:"",bb:"",b:"",i:"",u:"","/":""},U=Object.keys(q),J=new RegExp(`<(${U.join("|")})>`,"gi"),V=(e,i)=>q[i]??"",Z=e=>i=>e(typeof i===b?window.chrome?i.replace(J,V):(e=>e.replaceAll("<br>",h).replaceAll(/<\/?[^>]+>/gi,""))(i):i),X={},Y=(_=e,_?.__esModule?_.default:_);var _;let K=!0;const Q=Y({expand:!1,label:y}),ee=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const ie=e=>(i,...t)=>X[i]?X[i].console[e](...t):Q[e](...t),te=e=>(i,...t)=>!0===(e=>X[e]?X[e].log:K)(i)?ie(e)(i,...t):null,ne=te("log"),oe=ne,re=te("debug"),se=ie("warn"),ae=ie("error"),le=ie("event"),ce=ie("purge"),ue=ie("endAutoGroup"),de=ie("errorBoundary");const fe=Z(e=>e),pe=(e,...i)=>X[e]?X[e].console.warn(...i.map(fe)):queueMicrotask(()=>{const n=Z((e=>(...i)=>[`${t}(${e})`,...i].join(" "))(e));console?.warn(...i.map(n))}),me=(e=>(i,t="renamed to")=>(n,o,r="",s="")=>e(s,`<rb>Deprecated ${i}(${n.replace("()","")})</>\n\nThe <b>${n}</> ${i.toLowerCase()} has been ${t} <b>${o}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(pe),he=me("Option");function ge(e){const{checkOrigin:i,iframe:{id:t,src:n,sandbox:o},initialisedFirstPage:r,waitForLoad:s,warningTimeout:a}=e,l=(e=>{try{return new URL(e).origin}catch(e){return null}})(n);le(t,"noResponse"),pe(t,`<rb>No response from iframe</>\n\nThe iframe (<i>${t}</>) has not responded within ${a/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${i&&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`:""}${s&&!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=>typeof e===v&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(o)?"\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`)}const ye={};const be=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:$,firstRun:!0,inPageLinks:!1,heightCalculationMethod:z,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:z,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof X[e.id].onInit===w&&(he("init()","onReady()","",e.id),X[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),ve={position:null,version:i};function we(t){function s(){Ge(F),je(B),E("onResized",F)}function c(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function h(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const g=e=>W.slice(W.indexOf(n)+7+e);const v=(e,i)=>(t,n)=>{const o={};var r,s;r=function(){Re(`${t} (${e})`,`${e}:${i()}`,n)},o[s=n]||(r(),o[s]=requestAnimationFrame(()=>{o[s]=null}))},w=(e,i)=>()=>{let t=!1;const n=i=>()=>{X[c]?t&&t!==i||(e(i,c),t=i,requestAnimationFrame(()=>{t=!1})):l()},o=n(m),r=n("resize window");function s(e,t){ne(c,`${e}listeners for send${i}`),t(window,m,o),t(window,p,r)}function l(){le(c,`stop${i}`),s("Remove ",S),u.disconnect(),d.disconnect(),S(X[c].iframe,a,l)}const c=B,u=new ResizeObserver(n("pageObserver")),d=new ResizeObserver(n("iframeObserver"));X[c]&&(X[c][`stop${i}`]=l,M(X[c].iframe,a,l),s("Add ",M),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(X[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},z=e=>()=>{e in X[B]&&(X[B][e](),delete X[B][e])},H=v(u,function(){const e=document.body.getBoundingClientRect(),i=F.iframe.getBoundingClientRect(),{scrollY:t,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,o||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:n,documentHeight:s,documentWidth:a,windowHeight:o,windowWidth:r})}),I=v(d,function(){const{iframe:e}=F,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:n,height:o,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),$=w(H,"PageInfo"),T=w(I,"ParentInfo"),k=z("stopPageInfo"),G=z("stopParentInfo");function O(e){const i=e.getBoundingClientRect();return $e(B),{x:Number(i.left)+Number(ve.position.x),y:Number(i.top)+Number(ve.position.y)}}function R(i){const t=i?O(F.iframe):{x:0,y:0};oe(B,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const n=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(F,t),o=window.parentIframe||window.parentIFrame;o?function(e,t){setTimeout(()=>e["scrollTo"+(i?"Offset":"")](t.x,t.y))}(o,n):function(e){ve.position=e,x(B)}(n)}function x(e){const{x:i,y:t}=ve.position,n=X[e]?.iframe;!1!==E("onScroll",{iframe:n,top:t,left:i,x:i,y:t})?je(e):Te()}function L(e){let i={};if(0===F.width&&0===F.height){const e=g(9).split(n);i={x:e[1],y:e[0]}}else i={x:F.width,y:F.height};E(e,{iframe:F.iframe,screenX:Number(i.x),screenY:Number(i.y),type:F.type})}const E=(e,i)=>ze(B,e,i);function C(){const{height:t,iframe:n,msg:a,type:c,width:p}=F;switch(X[B]?.firstRun&&function(){if(!X[B])return;ne(B,`First run for ${B}`),Se(B,F.mode),X[B].firstRun=!1}(),c){case"close":Ie(n);break;case l:h=g(6),ne(B,`onMessage passed: {iframe: %c${F.iframe.id}%c, message: %c${h}%c}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND),E("onMessage",{iframe:F.iframe,message:JSON.parse(h)});break;case"mouseenter":L("onMouseEnter");break;case"mouseleave":L("onMouseLeave");break;case"beforeUnload":oe(B,"Ready state reset"),X[B].initialised=!1;break;case o:X[B].autoResize=JSON.parse(g(9));break;case"scrollBy":!function(){const i=F.width,t=F.height,n=window.parentIframe||window.parentIFrame||window;oe(B,`scrollBy: x: %c${i}%c y: %c${t}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),n.scrollBy(i,t)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case u:$();break;case d:T();break;case"pageInfoStop":k();break;case"parentInfoStop":G();break;case"inPageLink":!function(i){const t=i.split("#")[1]||"",n=decodeURIComponent(t);let o=document.getElementById(n)||document.getElementsByName(n)[0];o?function(){const i=O(o);oe(B,`Moving to in page link: %c#${t}`,e.HIGHLIGHT),ve.position={x:i.x,y:i.y},x(B),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):ne(B,`In page link #${t} not found`)}():ne(B,`In page link #${t} not found`)}(g(9));break;case"title":!function(i,t){X[t]?.syncTitle&&(X[t].iframe.title=i,oe(t,`Set iframe title attribute: %c${i}`,e.HIGHLIGHT))}(a,B);break;case f:ke(F);break;case r:s(),function(i){try{X[i].sameOrigin=!!X[i]?.iframe?.contentWindow?.iframeChildListener}catch(e){X[i].sameOrigin=!1}ne(i,`sameOrigin: %c${X[i].sameOrigin}`,e.HIGHLIGHT)}(B),(m=a)!==i&&(void 0!==m?ne(B,`Version mismatch (Child: %c${m}%c !== Parent: %c${i})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT):pe(B,"<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")),X[B].initialised=!0,E("onReady",n);break;default:if(0===p&&0===t)return void se(B,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===p||0===t)return void ne(B,"Ignoring message with 0 height or width");if(document.hidden)return void ne(B,"Page hidden - ignored resize request");s()}var m,h}function N(e){if(!X[e])throw new Error(`${F.type} No settings for ${e}. Message was: ${W}`)}let W=t.data;if("[iFrameResizerChild]Ready"===W)return A=t.source,void Object.values(X).forEach((e=>({initChild:i,postMessageTarget:t})=>{e===t&&i()})(A));var A;if(!(e=>j===`${e}`.slice(0,13)&&e.slice(13).split(n)[0]in X)(W)){if(typeof W!==b)return;return le(y,"ignoredMessage"),void re(y,W)}const F=function(e){const i=e.slice(13).split(n),t=i[1]?Number(i[1]):0,o=X[i[0]]?.iframe,r=getComputedStyle(o),s={iframe:o,id:i[0],height:t+c(r)+h(r),width:Number(i[2]),type:i[3],msg:i[4]};return i[5]&&(s.mode=i[5]),s}(W),{id:D,type:P}=F,B=D;B?(le(B,P),de(B,function(i){N(B),function(){const e=F.type in{true:1,false:1,undefined:1};return e&&ne(B,"Ignoring init message from meta parent page"),e}()||(ne(B,`Received: %c${i}`,e.HIGHLIGHT),(null!==F.iframe||(se(B,`The iframe (${F.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:n}=t;if(n)return!0;let o=X[B]?.checkOrigin;if(o&&"null"!=`${i}`&&!(o.constructor===Array?function(){let t=0,n=!1;for(ne(B,`Checking connection is from allowed list of origins: %c${o}`,e.HIGHLIGHT);t<o.length;t++)if(o[t]===i){n=!0;break}return n}():function(){const t=X[B]?.remoteHost;return ne(B,`Checking connection is from: %c${t}`,e.HIGHLIGHT),i===t}()))throw new Error(`Unexpected message received from: ${i} for ${F.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C())})(W)):se("","iframeResizer received messageData without id, message was: ",W)}function ze(e,i,t){let n=null,o=null;if(X[e]){if(n=X[e][i],typeof n!==w)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{o=n(t)}catch(t){console.error(t),se(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(n,t)}return o}function He(e){const{id:i}=e;ne(i,"Disconnected from iframe"),delete X[i],delete e.iframeResizer}function Ie(i){const{id:t}=i;if(!1!==ze(t,"onBeforeClose",t)){ne(t,`Removing iFrame: %c${t}`,e.HIGHLIGHT);try{i.parentNode&&i.remove()}catch(e){se(t,e)}ze(t,"onAfterClose",t),He(i)}else ne(t,"Close iframe cancelled by onBeforeClose")}function $e(i){null===ve.position&&(ve.position={x:window.scrollX,y:window.scrollY},ne(i,`Get page position: %c${ve.position.x}%c, %c${ve.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT))}function Te(){ve.position=null}function je(i){null!==ve.position&&(window.scrollTo(ve.position.x,ve.position.y),oe(i,`Set page position: %c${ve.position.x}%c, %c${ve.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),Te())}function ke(e){ne(e.id,"Size reset requested by "+(e.type===r?"parent page":"child page")),$e(e.id),Ge(e),Re(f,f,e.id)}function Ge(i){function t(t){const o=`${i[t]}px`;i.iframe.style[t]=o,oe(n,`Set ${t}: %c${o}`,e.HIGHLIGHT)}const{id:n}=i,{sizeHeight:o,sizeWidth:r}=X[n];o&&t("height"),r&&t("width")}const Oe=e=>e.split(n).filter((e,i)=>19!==i).join(n);function Re(i,t,n){function o(o){const r=i in G?Oe(t):t;oe(n,o,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),oe(n,`Message data: %c${r}`,e.HIGHLIGHT)}le(n,i),X[n]&&(X[n]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=X[n];if(s)try{return e.contentWindow.iframeChildListener(j+t),void o(`Sending message to iframe %c${n}%c via same origin%c`)}catch(e){i in G?(X[n].sameOrigin=!1,ne(n,"New iframe does not support same origin")):se(n,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${a}`),r.postMessage(j+t,a)}():se(n,`Iframe(${n}) not found`))}let xe=0,Le=!1,Me=!1;function Se(t,n=-3){if(Le)return;const o=Math.max(X[t].mode,n);if(o>X[t].mode&&(X[t].mode=o),o<0)throw ce(t),X[t].vAdvised||pe(t||"Parent",`${D(o+2)}${D(2)}`),X[t].vAdvised=!0,D(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>0&&Me||function(i,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${i}`,K||t<1?"font-weight: bold;":e.NORMAL))}(`v${i} (${(e=>C(A[e]))(o)})`,o),o<1&&pe("Parent",D(3)),Le=!0}function Ee(){!0!==document.hidden&&((e,i)=>{Object.values(X).filter(({autoResize:e,firstRun:i})=>e&&!i).forEach(({iframe:t})=>Re(e,i,t.id))})("tabVisible",p)}const Ce=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{M(window,l,we),M(document,"visibilitychange",Ee),window.iframeParentListener=e=>setTimeout(()=>we({data:e,sameOrigin:!0}))});return i=>u=>{function d(){X[C]?.heightCalculationMethod in k&&ke({iframe:u,height:1,width:1,type:r})}function f(){if(X[C]){const{iframe:e}=X[C],i={close:Ie.bind(null,e),disconnect:He.bind(null,e),removeListeners(){pe(C,`<rb>Deprecated Method Name</>\n\nThe <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${L}\n`),this.disconnect()},resize(){pe(C,"<rb>Deprecated Method</>\n\nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their 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."),Re.bind(null,"Window resize",p,C)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${n=i,n.charAt(0).toUpperCase()+n.slice(1)}`);var n})(e,b,"moveToAnchor(anchor) anchor"),Re("Move to anchor",`moveToAnchor:${e}`,C)},sendMessage(e){e=JSON.stringify(e),Re(l,`${l}:${e}`,C)}};e.iframeResizer=i,e.iFrameResizer=i}}function m(e,i){const t=t=>()=>{if(!X[e])return;const{firstRun:n,iframe:o}=X[e];Re(t,i,e),(e=>e===r)(t)&&(e=>"lazy"===e.loading)(o)||function(e,i){const t=i[e],{msgTimeout:n,warningTimeout:o}=t;o&&(n&&clearTimeout(n),t.msgTimeout=setTimeout(function(){const t=i[e];void 0!==t&&((e=>{e.msgTimeout=void 0})(t),function(e){const{initialised:i}=e;return i&&(e.initialisedFirstPage=!0),i}(t)||ge(t))},o))}(e,X),n||d()},{iframe:n}=X[e];X[e].initChild=t(s),function(e,i){M(e,a,()=>setTimeout(i,1))}(n,t(c)),function(e,i){const{iframe:t,waitForLoad:n}=X[e];!0!==n&&((e=>{const{src:i,srcdoc:t}=e;return!t&&(null==i||""===i||"about:blank"===i)})(t)?setTimeout(()=>{le(e,"noContent"),oe(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(i))}(e,t(r))}function y(e){return e?(("sizeWidth"in e||"sizeHeight"in e||o in e)&&pe(C,`<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>${$}</>, <bb>${T}</>, <bb>${I}</> or <bb>${H}</>.\n`),e):{}}function w(e){const i=X[e]?.iframe?.title;return""===i||void 0===i}function j(e,i){B(X[C],e)&&(pe(C,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. ${L}`),X[C][i]=X[C][e],delete X[C][e])}const G=e=>B(e,"onMouseEnter")||B(e,"onMouseLeave");function S(i){var t,n;X[C]={...X[C],iframe:u,remoteHost:u?.src.split("/").slice(0,3).join("/"),...be,...y(i),mouseEvents:G(i),mode:P(i),syncTitle:w(C)},j("offset","offsetSize"),j("onClose","onBeforeClose"),j("onClosed","onAfterClose"),le(C,"setup"),function(){const{direction:i}=X[C];switch(i){case $:break;case T:X[C].sizeHeight=!1;case I:X[C].sizeWidth=!0;break;case H:X[C].sizeWidth=!1,X[C].sizeHeight=!1,X[C].autoResize=!1;break;default:throw new TypeError(C,`Direction value of "${i}" is not valid`)}ne(C,`direction: %c${i}`,e.HIGHLIGHT)}(),(t=i?.offsetSize||i?.offset)&&(X[C].direction===$?(X[C].offsetHeight=t,ne(C,`Offset height: %c${t}`,e.HIGHLIGHT)):(X[C].offsetWidth=t,ne(C,`Offset width: %c${t}`,e.HIGHLIGHT))),X[C].warningTimeout||oe(C,"warningTimeout:%c disabled",e.HIGHLIGHT),null===X[C].postMessageTarget&&(X[C].postMessageTarget=u.contentWindow),X[C].targetOrigin=!0===X[C].checkOrigin?""===(n=X[C].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const E=()=>t in u,C=function(e){if(e&&typeof e!==b)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=i?.id||be.id+xe++;return null!==document.getElementById(e)&&(e+=xe++),e}(),u.id=e,le(e,"assignId"),ne(e,`Added missing iframe ID: ${e} (${u.src})`)),e}(u.id);if(typeof i!==v)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=R,e.logExpand=i.includes("ifrlog=expanded"))}(i),function(e,i){const t=B(i,"log"),n=typeof i.log===b,o=t?!!n||i.log:be.log;B(i,"logExpand")||(i.logExpand=t&&n?i.log===O:be.logExpand),function(e){-1===e?.log&&(e.log=!1,Me=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const n=Y({expand:i,label:ee(t)});K=e,X[t]||(X[t]={console:n})}({enabled:o,expand:i.logExpand,iframeId:e}),n&&!(i.log in x)&&ae(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=o}(C,i),de(C,function(i){E()?se(C,`Ignored iframe (${C}), already setup.`):(S(i),function(e){if(!0===ye[e])return!1;const i=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(i.length<=1)return!0;ye[e]=!0;const t=Array.from(i).flatMap(e=>[h,e,h]);pe(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>${i.length}</> iframes with the <b>${e}</> ID:`,...t,h)}(C),ne(C,`src: %c${u.srcdoc||u.src}`,e.HIGHLIGHT),function(){if(Le)return;const{mode:e}=X[C];-1!==e&&Se(C,e)}(),Ce(),function(){switch(ne(C,`Iframe scrolling ${X[C]?.scrolling?"enabled":"disabled"} for ${C}`),u.style.overflow=!1===X[C]?.scrolling?"hidden":z,X[C]?.scrolling){case"omit":break;case!0:u.scrolling="yes";break;case!1:u.scrolling="no";break;default:u.scrolling=X[C]?X[C].scrolling:"no"}}(),function(){const{bodyMargin:e}=X[C];"number"!=typeof e&&"0"!==e||(X[C].bodyMargin=`${e}px`)}(),m(C,function(e){const{autoResize:i,bodyBackground:t,bodyMargin:o,bodyPadding:r,heightCalculationMethod:s,inPageLinks:a,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:m,sizeHeight:h,sizeWidth:y,tolerance:b,widthCalculationMethod:v}=X[e];return[e,"8",y,c,"32",!0,i,o,s,t,r,b,a,g,v,d,f,p,h,l,ve.version,m,"",u].join(n)}(C)),f(),ne(C,"Setup complete"),ue(C))})(i),u?.iframeResizer}});
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}));
21
38
  //# sourceMappingURL=index.umd.js.map