@iframe-resizer/core 5.5.4 → 5.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,4 +25,4 @@ yarn add @iframe-resizer/core
25
25
 
26
26
  ---
27
27
 
28
- _iframe-resizer version 5.5.4 2025-08-27 - 10:39:21.596Z_
28
+ _iframe-resizer version 5.5.5 2025-09-01 - 11:10:13.679Z_
package/index.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.4 (cjs) - 2025-08-27
4
+ * @module iframe-resizer/core 5.5.5 (cjs) - 2025-09-01
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- "use strict";const e=require("auto-console-group"),t="5.5.4",i="none",o="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),u="expanded",d="collapsed",f=Object.freeze({[u]:1,[d]:1}),p=(e,t,i,o)=>e.addEventListener(t,i,o||!1),h=(e,t,i)=>e.removeEventListener(t,i,!1),m=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<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."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),z=e=>g(b[e]),j=e=>{const t=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=m(g(e));return i in w&&(t=w[i]),t}(i[0]);return 0===o||(e=>e[2]===m(e[0]+e[1]))(i)||(o=-2),o},$=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),T=e=>e,I=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),k=(H=e,H?.__esModule?H.default:H);var H;let x={},R=!1;const M=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const O=e=>(t,...i)=>x[t]?.console[e](...i);var L;const S=(L="log",(e,...t)=>!0===(e=>x[e]?x[e].log:R)(e)?O(L)(e,...t):null),E=O("warn"),W=O("error"),A=O("event"),C=O("purge"),G=O("errorBoundary");const N=(e,...t)=>x[e]?x[e].console.warn(I(T)(...t)):queueMicrotask(()=>console?.warn(I((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),B=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(N),F=B("Option");function P(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),N(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${o?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},o))}const q={},D=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:o,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof q[e.id].onInit&&(F("init()","onReady()","",e.id),q[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),U={position:null,version:t};function J(i){function o(){ee(H),K(x),$("onResized",H)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>k.slice(k.indexOf(":")+7+e);const l=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){ie(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,t)=>()=>{let i=!1;const o=t=>()=>{q[l]?i&&i!==t||(e(t,l),i=t,requestAnimationFrame(()=>{i=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${t}`),s(0,h),c.disconnect(),u.disconnect(),h(q[l].iframe,"load",a)}const l=x,c=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));q[l]&&(q[l][`stop${t}`]=a,p(q[l].iframe,"load",a),s(0,p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(q[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},u=e=>()=>{e in q[x]&&(q[x][e](),delete q[x][e])},d=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),t=H.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=H,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),m=c(d,"PageInfo"),g=c(f,"ParentInfo"),y=u("stopPageInfo"),b=u("stopParentInfo");function v(e){const t=e.getBoundingClientRect();return Y(),{x:Number(t.left)+Number(U.position.x),y:Number(t.top)+Number(U.position.y)}}function w(t){const i=t?v(H.iframe):{x:0,y:0};S(x,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(H,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){e["scrollTo"+(t?"Offset":"")](i.x,i.y)}(n,o):function(e){U.position=e,z(x)}(o)}function z(e){const{x:t,y:i}=U.position,o=q[e]?.iframe;!1!==$("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?K(e):_()}function j(e){let t={};if(0===H.width&&0===H.height){const e=a(9).split(":");t={x:e[1],y:e[0]}}else t={x:H.width,y:H.height};$(e,{iframe:H.iframe,screenX:Number(t.x),screenY:Number(t.y),type:H.type})}const $=(e,t)=>Z(x,e,t);function T(){const{height:i,iframe:n,msg:r,type:s,width:l}=H;switch(q[x]?.firstRun&&function(){if(!q[x])return;le(x,H.mode),q[x].firstRun=!1}(),s){case"close":X(n);break;case"message":u=a(6),$("onMessage",{iframe:H.iframe,message:JSON.parse(u)});break;case"mouseenter":j("onMouseEnter");break;case"mouseleave":j("onMouseLeave");break;case"beforeUnload":S(x,"Ready state reset"),q[x].ready=!1;break;case"autoResize":q[x].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const t=H.width,i=H.height,o=window.parentIframe||window.parentIFrame||window;S(x,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":m();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=v(n);S(x,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),U.position={x:t.x,y:t.y},z(x),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(a(9));break;case"title":!function(t,i){q[i]?.syncTitle&&(q[i].iframe.title=t,S(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(r,x);break;case"reset":Q(H);break;case"init":o(),function(e){try{q[e].sameOrigin=!!q[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){q[e].sameOrigin=!1}}(x),(c=r)!==t&&(void 0!==c||N(x,"<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")),re=!0,$("onReady",n);break;default:if(0===l&&0===i)return void E(x,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===i)return;if(document.hidden)return;o()}var c,u}function I(e){q[e].ready||(ie("iframe requested init",oe(e),e),P(e,q))}let k=i.data,H={},x=null;"[iFrameResizerChild]Ready"!==k?r===`${k}`.slice(0,13)&&k.slice(13).split(":")[0]in q&&(H=function(){const e=k.slice(13).split(":"),t=e[1]?Number(e[1]):0,i=q[e[0]]?.iframe,o=getComputedStyle(i),r={iframe:i,id:e[0],height:t+n(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),x=H.id,x?(A(x,H.type),G(x,function(){!function(e){if(!q[e])throw new Error(`${H.type} No settings for ${e}. Message was: ${k}`)}(x),H.type in{true:1,false:1,undefined:1}||(q[x].ready=!0,(null!==H.iframe||(E(x,`The iframe (${H.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=i;if(t)return!0;let o=q[x]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,i=!1;for(;t<o.length;t++)if(o[t]===e){i=!0;break}return i}():function(){const t=q[x]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${H.iframe.id}. Message was: ${i.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&T())})()):E("","iframeResizer received messageData without id, message was: ",k)):Object.keys(q).forEach(I)}function Z(e,t,i){let o=null,n=null;if(q[e]){if(o=q[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),E(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function V(e){const{id:t}=e;delete q[t],delete e.iframeResizer}function X(e){const{id:t}=e;if(!1!==Z(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),V(e)}}function Y(e){null===U.position&&(U.position={x:window.scrollX,y:window.scrollY})}function _(){U.position=null}function K(t){null!==U.position&&(window.scrollTo(U.position.x,U.position.y),S(t,`Set page position: %c${U.position.x}%c, %c${U.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),_())}function Q(e){Y(e.id),ee(e),ie("reset","reset",e.id)}function ee(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,S(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=q[o];n&&i("height"),r&&i("width")}x=q;const te=e=>e.split(":").filter((e,t)=>19!==t).join(":");function ie(t,i,o){function n(n){const r=t in c?te(i):i;S(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(o,`Message data: %c${r}`,e.HIGHLIGHT)}A(o,t),q[o]&&(q[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:t,sameOrigin:s,targetOrigin:a}=q[o];if(s)try{return e.contentWindow.iframeChildListener(r+i),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),t.postMessage(r+i,a)}():E(o,`Iframe(${o}) not found`))}function oe(e){const t=q[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,U.version,t.mode,"",t.logExpand].join(":")}let ne=0,re=!1,se=!1,ae=!1;function le(i,o=-3){if(se)return;const n=Math.max(q[i].mode,o);if(n>q[i].mode&&(q[i].mode=n),n<0)throw C(i),q[i].vAdvised||N(i||"Parent",`${z(n+2)}${z(2)}`),q[i].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&ae||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,R||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>g(v[e]))(n)})`,n),n<1&&N("Parent",z(3)),se=!0}function ce(){!1===document.hidden&&function(e,t){const i=e=>q[e]?.autoResize&&!q[e]?.firstRun;Object.keys(q).forEach(function(o){i(o)&&ie(e,t,o)})}("tabVisible","resize")}const ue=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",J),p(document,"visibilitychange",ce),window.iframeParentListener=e=>setTimeout(()=>J({data:e,sameOrigin:!0}))});module.exports=t=>r=>{function c(){if(q[z]){const{iframe:e}=q[z],t={close:X.bind(null,e),disconnect:V.bind(null,e),removeListeners(){N(z,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){N(z,"<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."),ie.bind(null,"Window resize","resize",z)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),ie("Move to anchor",`moveToAnchor:${e}`,z)},sendMessage(e){ie("message",`message:${e=JSON.stringify(e)}`,z)}};e.iframeResizer=t,e.iFrameResizer=t}}function h(e){const{id:t}=r,{waitForLoad:i}=q[t];p(r,"load",()=>{ie(a,`${e}:${re}`,t),P(t,q),function(){const e=q[z]?.firstRun,t=q[z]?.heightCalculationMethod in s;!e&&t&&Q({iframe:r,height:0,width:0,type:"init"})}()}),!0!==i&&(ie(l,`${e}:${re}`,t),P(t,q))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&N(z,`<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 <i>"${o}"</>, <i>"${n}"</> or <i>"${i}"</>.\n`),e):{}}function g(e){const t=q[e]?.iframe?.title;return""===t||void 0===t}function y(e,t){$(q[z],e)&&(N(z,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),q[z][t]=q[z][e],delete q[z][e])}const b=e=>$(e,"onMouseEnter")||$(e,"onMouseLeave");function v(t){var s,a;q[z]={...q[z],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...D,...m(t),mouseEvents:b(t),mode:j(t),syncTitle:g(z)},y("offset","offsetSize"),y("onClose","onBeforeClose"),y("onClosed","onAfterClose"),A(z,"setup"),function(){const{direction:e}=q[z];switch(e){case o:break;case n:q[z].sizeHeight=!1;case"both":q[z].sizeWidth=!0;break;case i:q[z].sizeWidth=!1,q[z].sizeHeight=!1,q[z].autoResize=!1;break;default:throw new TypeError(z,`Direction value of "${e}" is not valid`)}}(),(s=t?.offsetSize||t?.offset)&&(q[z].direction===o?q[z].offsetHeight=s:q[z].offsetWidth=s),function(e){e?.offset&&N(z,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(t),q[z].warningTimeout||S(z,"warningTimeout:%c disabled",e.HIGHLIGHT),null===q[z].postMessageTarget&&(q[z].postMessageTarget=r.contentWindow),q[z].targetOrigin=!0===q[z].checkOrigin?""===(a=q[z].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const w=()=>"iframeResizer"in r,z=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||D.id+ne++;return null!==document.getElementById(e)&&(e+=ne++),e}(),r.id=e),e}(r.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=d,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const i=$(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:D.log;$(t,"logExpand")||(t.logExpand=i&&o?t.log===u:D.logExpand),function(e){-1===e?.log&&(e.log=!1,ae=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=k({expand:t,label:M(i)});R=e,x[i]||(x[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in f)&&W(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(z,t),G(z,function(e){w()?E(z,`Ignored iframe (${z}), already setup.`):(v(e),function(){if(se)return;const{mode:e}=q[z];-1!==e&&le(z,e)}(),ue(),function(){switch(r.style.overflow=!1===q[z]?.scrolling?"hidden":"auto",q[z]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=q[z]?q[z].scrolling:"no"}}(),function(){const{bodyMargin:e}=q[z];"number"!=typeof e&&"0"!==e||(q[z].bodyMargin=`${e}px`)}(),h(oe(z)),c())})(t),r?.iframeResizer};
20
+ "use strict";const e=require("auto-console-group"),t="5.5.5",i="autoResize",o="init",n="iframe requested init",r="load",s="message",a="onload",l="pageInfo",c="parentInfo",u="reset",d="resize",f="scroll",p="none",h="vertical",m="horizontal",g="[iFrameSizer]",y=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),b=Object.freeze({[a]:1,[o]:1,[n]:1}),v="expanded",w="collapsed",z=Object.freeze({[v]:1,[w]:1}),j=(e,t,i,o)=>e.addEventListener(t,i,o||!1),$=(e,t,i)=>e.removeEventListener(t,i,!1),T=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},k=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),I=["spjluzl","rlf","clyzpvu"],H=["<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."],x=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],M=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),R=e=>k(H[e]),O=e=>{const t=e[k(I[0])]||e[k(I[1])]||e[k(I[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=T(k(e));return i in M&&(t=M[i]),t}(i[0]);return 0===o||(e=>e[2]===T(e[0]+e[1]))(i)||(o=-2),o},L=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),S=e=>e,E=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),W={},A=(C=e,C?.__esModule?C.default:C);var C;let G=!0;const N=A({expand:!1,label:"parent"}),B=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const F=e=>(t,...i)=>W[t]?W[t].console[e](...i):N[e](...i);var P;const q=(P="log",(e,...t)=>!0===(e=>W[e]?W[e].log:G)(e)?F(P)(e,...t):null),D=F("warn"),U=F("error"),J=F("event"),Z=F("purge"),V=F("errorBoundary");const X=(e,...t)=>W[e]?W[e].console.warn(E(S)(...t)):queueMicrotask(()=>console?.warn(E((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),Y=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(X),_=Y("Option");function K(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));J(e,"noResponse"),X(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${o?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},o))}const Q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:h,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof W[e.id].onInit&&(_("init()","onReady()","",e.id),W[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),ee={position:null,version:t};function te(a){function p(){ce(N),ae(P),S("onResized",N)}function h(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function m(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const y=e=>G.slice(G.indexOf(":")+7+e);const b=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){de(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},v=(e,t)=>()=>{let i=!1;const o=t=>()=>{W[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(f),s=o("resize window");function a(e,t){t(window,f,n),t(window,d,s)}function l(){J(c,`stop${t}`),a(0,$),u.disconnect(),p.disconnect(),$(W[c].iframe,r,l)}const c=P,u=new ResizeObserver(o("pageObserver")),p=new ResizeObserver(o("iframeObserver"));W[c]&&(W[c][`stop${t}`]=l,j(W[c].iframe,r,l),a(0,j),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),p.observe(W[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},w=e=>()=>{e in W[P]&&(W[P][e](),delete W[P][e])},z=b(l,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),T=b(c,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),k=v(z,"PageInfo"),I=v(T,"ParentInfo"),H=w("stopPageInfo"),x=w("stopParentInfo");function M(e){const t=e.getBoundingClientRect();return re(),{x:Number(t.left)+Number(ee.position.x),y:Number(t.top)+Number(ee.position.y)}}function R(t){const i=t?M(N.iframe):{x:0,y:0};q(P,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){ee.position=e,O(P)}(o)}function O(e){const{x:t,y:i}=ee.position,o=W[e]?.iframe;!1!==S("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?ae(e):se()}function L(e){let t={};if(0===N.width&&0===N.height){const e=y(9).split(":");t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};S(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const S=(e,t)=>ie(P,e,t);function E(){const{height:n,iframe:r,msg:a,type:d,width:f}=N;switch(W[P]?.firstRun&&function(){if(!W[P])return;ye(P,N.mode),W[P].firstRun=!1}(),d){case"close":ne(r);break;case s:m=y(6),S("onMessage",{iframe:N.iframe,message:JSON.parse(m)});break;case"mouseenter":L("onMouseEnter");break;case"mouseleave":L("onMouseLeave");break;case"beforeUnload":q(P,"Ready state reset"),W[P].ready=!1;break;case i:W[P].autoResize=JSON.parse(y(9));break;case"scrollBy":!function(){const t=N.width,i=N.height,o=window.parentIframe||window.parentIFrame||window;q(P,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case l:k();break;case c:I();break;case"pageInfoStop":H();break;case"parentInfoStop":x();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=M(n);q(P,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),ee.position={x:t.x,y:t.y},O(P),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(y(9));break;case"title":!function(t,i){W[i]?.syncTitle&&(W[i].iframe.title=t,q(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(a,P);break;case u:le(N);break;case o:p(),function(e){try{W[e].sameOrigin=!!W[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){W[e].sameOrigin=!1}}(P),(h=a)!==t&&(void 0!==h||X(P,"<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")),he=!0,S("onReady",r);break;default:if(0===f&&0===n)return void D(P,`Unsupported message received (${d}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===f||0===n)return;if(document.hidden)return;p()}var h,m}function A(e){if(!W[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${G}`)}const C=e=>Object.keys(W).forEach((e=>t=>{const{ready:i,postMessageTarget:o}=W[t];i||e!==o||(de(n,fe(t),t),K(t,W))})(e));let G=a.data;if("[iFrameResizerChild]Ready"===G)return void C(a.source);if(!(e=>g===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in W)(G)){if("string"!=typeof G)return;return void J("parent","ignoredMessage")}const N=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=W[t[0]]?.iframe,n=getComputedStyle(o),r={iframe:o,id:t[0],height:i+h(n)+m(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(r.mode=t[5]),r}(G),{id:B,type:F}=N,P=B;P?(J(P,F),V(P,function(e){A(P),N.type in{true:1,false:1,undefined:1}||(W[P].ready=!0,(null!==N.iframe||(D(P,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=a;if(t)return!0;let i=W[P]?.checkOrigin;if(i&&"null"!=`${e}`&&!(i.constructor===Array?function(){let t=0,o=!1;for(;t<i.length;t++)if(i[t]===e){o=!0;break}return o}():function(){const t=W[P]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${N.iframe.id}. Message was: ${a.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&E())})(G)):D("","iframeResizer received messageData without id, message was: ",G)}function ie(e,t,i){let o=null,n=null;if(W[e]){if(o=W[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),D(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function oe(e){const{id:t}=e;delete W[t],delete e.iframeResizer}function ne(e){const{id:t}=e;if(!1!==ie(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){D(t,e)}ie(t,"onAfterClose",t),oe(e)}}function re(e){null===ee.position&&(ee.position={x:window.scrollX,y:window.scrollY})}function se(){ee.position=null}function ae(t){null!==ee.position&&(window.scrollTo(ee.position.x,ee.position.y),q(t,`Set page position: %c${ee.position.x}%c, %c${ee.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),se())}function le(e){re(e.id),ce(e),de(u,u,e.id)}function ce(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,q(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=W[o];n&&i("height"),r&&i("width")}const ue=e=>e.split(":").filter((e,t)=>19!==t).join(":");function de(t,i,o){function n(n){const r=t in b?ue(i):i;q(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),q(o,`Message data: %c${r}`,e.HIGHLIGHT)}J(o,t),W[o]&&(W[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=W[o];if(s)try{return e.contentWindow.iframeChildListener(g+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in b?W[o].sameOrigin=!1:D(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage(g+i,a)}():D(o,`Iframe(${o}) not found`))}function fe(e){const t=W[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,ee.version,t.mode,"",t.logExpand].join(":")}let pe=0,he=!1,me=!1,ge=!1;function ye(i,o=-3){if(me)return;const n=Math.max(W[i].mode,o);if(n>W[i].mode&&(W[i].mode=n),n<0)throw Z(i),W[i].vAdvised||X(i||"Parent",`${R(n+2)}${R(2)}`),W[i].vAdvised=!0,R(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&ge||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,G||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>k(x[e]))(n)})`,n),n<1&&X("Parent",R(3)),me=!0}function be(){!1===document.hidden&&function(e,t){const i=e=>W[e]?.autoResize&&!W[e]?.firstRun;Object.keys(W).forEach(function(o){i(o)&&de(e,t,o)})}("tabVisible",d)}const ve=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{j(window,s,te),j(document,"visibilitychange",be),window.iframeParentListener=e=>setTimeout(()=>te({data:e,sameOrigin:!0}))});module.exports=t=>n=>{function l(){if(W[k]){const{iframe:e}=W[k],t={close:ne.bind(null,e),disconnect:oe.bind(null,e),removeListeners(){X(k,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){X(k,"<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."),de.bind(null,"Window resize",d,k)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),de("Move to anchor",`moveToAnchor:${e}`,k)},sendMessage(e){e=JSON.stringify(e),de(s,`${s}:${e}`,k)}};e.iframeResizer=t,e.iFrameResizer=t}}function c(e){const{id:t}=n,{waitForLoad:i}=W[t];j(n,r,()=>{de(a,`${e}:${he}`,t),K(t,W),function(){const e=W[k]?.firstRun,t=W[k]?.heightCalculationMethod in y;!e&&t&&le({iframe:n,height:0,width:0,type:o})}()}),!0!==i&&(de(o,`${e}:${he}`,t),K(t,W))}function u(e){return e?(("sizeWidth"in e||"sizeHeight"in e||i in e)&&X(k,`<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 <i>"${h}"</>, <i>"${m}"</> or <i>"${p}"</>.\n`),e):{}}function f(e){const t=W[e]?.iframe?.title;return""===t||void 0===t}function g(e,t){L(W[k],e)&&(X(k,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),W[k][t]=W[k][e],delete W[k][e])}const b=e=>L(e,"onMouseEnter")||L(e,"onMouseLeave");function $(t){var i,o;W[k]={...W[k],iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...Q,...u(t),mouseEvents:b(t),mode:O(t),syncTitle:f(k)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),J(k,"setup"),function(){const{direction:e}=W[k];switch(e){case h:break;case m:W[k].sizeHeight=!1;case"both":W[k].sizeWidth=!0;break;case p:W[k].sizeWidth=!1,W[k].sizeHeight=!1,W[k].autoResize=!1;break;default:throw new TypeError(k,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(W[k].direction===h?W[k].offsetHeight=i:W[k].offsetWidth=i),function(e){e?.offset&&X(k,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(t),W[k].warningTimeout||q(k,"warningTimeout:%c disabled",e.HIGHLIGHT),null===W[k].postMessageTarget&&(W[k].postMessageTarget=n.contentWindow),W[k].targetOrigin=!0===W[k].checkOrigin?""===(o=W[k].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const T=()=>"iframeResizer"in n,k=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||Q.id+pe++;return null!==document.getElementById(e)&&(e+=pe++),e}(),n.id=e),e}(n.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=w,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const i=L(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:Q.log;L(t,"logExpand")||(t.logExpand=i&&o?t.log===v:Q.logExpand),function(e){-1===e?.log&&(e.log=!1,ge=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=A({expand:t,label:B(i)});G=e,W[i]||(W[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in z)&&U(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(k,t),V(k,function(e){T()?D(k,`Ignored iframe (${k}), already setup.`):($(e),function(){if(me)return;const{mode:e}=W[k];-1!==e&&ye(k,e)}(),ve(),function(){switch(n.style.overflow=!1===W[k]?.scrolling?"hidden":"auto",W[k]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=W[k]?W[k].scrolling:"no"}}(),function(){const{bodyMargin:e}=W[k];"number"!=typeof e&&"0"!==e||(W[k].bodyMargin=`${e}px`)}(),c(fe(k)),l())})(t),n?.iframeResizer};
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.4 (esm) - 2025-08-27
4
+ * @module iframe-resizer/core 5.5.5 (esm) - 2025-09-01
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- import e,{NORMAL as t,HIGHLIGHT as i,FOREGROUND as o}from"auto-console-group";const n="5.5.4",r="none",s="vertical",a="horizontal",l="[iFrameSizer]",c=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),u="onload",d="init",f=Object.freeze({[u]:1,[d]:1}),p="expanded",h="collapsed",m=Object.freeze({[p]:1,[h]:1}),g=(e,t,i,o)=>e.addEventListener(t,i,o||!1),y=(e,t,i)=>e.removeEventListener(t,i,!1),b=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},v=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),w=["spjluzl","rlf","clyzpvu"],z=["<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."],j=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],$=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),k=e=>v(z[e]),T=e=>{const t=e[v(w[0])]||e[v(w[1])]||e[v(w[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=b(v(e));return i in $&&(t=$[i]),t}(i[0]);return 0===o||(e=>e[2]===b(e[0]+e[1]))(i)||(o=-2),o},x=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),M=e=>e,S=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),R=(O=e,O?.__esModule?O.default:O);var O;let I={},E=!1;const W=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const A=e=>(t,...i)=>I[t]?.console[e](...i);var C;const L=(C="log",(e,...t)=>!0===(e=>I[e]?I[e].log:E)(e)?A(C)(e,...t):null),N=A("warn"),B=A("error"),H=A("event"),P=A("purge"),F=A("errorBoundary");const q=(e,...t)=>I[e]?I[e].console.warn(S(M)(...t)):queueMicrotask(()=>console?.warn(S((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),D=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(q),U=D("Option");function J(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));H(e,"noResponse"),q(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${o?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},o))}const Z={},V=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:s,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof Z[e.id].onInit&&(U("init()","onReady()","",e.id),Z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),X={position:null,version:n};function Y(e){function t(){oe(S),te(R),k("onResized",S)}function r(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>M.slice(M.indexOf(":")+7+e);const c=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){re(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},u=(e,t)=>()=>{let i=!1;const o=t=>()=>{Z[l]?i&&i!==t||(e(t,l),i=t,requestAnimationFrame(()=>{i=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){t(window,"scroll",n),t(window,"resize",r)}function a(){H(l,`stop${t}`),s(0,y),c.disconnect(),u.disconnect(),y(Z[l].iframe,"load",a)}const l=R,c=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));Z[l]&&(Z[l][`stop${t}`]=a,g(Z[l].iframe,"load",a),s(0,g),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(Z[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},d=e=>()=>{e in Z[R]&&(Z[R][e](),delete Z[R][e])},f=c("pageInfo",function(){const e=document.body.getBoundingClientRect(),t=S.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),p=c("parentInfo",function(){const{iframe:e}=S,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),h=u(f,"PageInfo"),m=u(p,"ParentInfo"),b=d("stopPageInfo"),v=d("stopParentInfo");function w(e){const t=e.getBoundingClientRect();return Q(),{x:Number(t.left)+Number(X.position.x),y:Number(t.top)+Number(X.position.y)}}function z(e){const t=e?w(S.iframe):{x:0,y:0};L(R,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,i,o,i);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(S,t),r=window.parentIframe||window.parentIFrame;r?function(t,i){t["scrollTo"+(e?"Offset":"")](i.x,i.y)}(r,n):function(e){X.position=e,j(R)}(n)}function j(e){const{x:t,y:i}=X.position,o=Z[e]?.iframe;!1!==k("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?te(e):ee()}function $(e){let t={};if(0===S.width&&0===S.height){const e=a(9).split(":");t={x:e[1],y:e[0]}}else t={x:S.width,y:S.height};k(e,{iframe:S.iframe,screenX:Number(t.x),screenY:Number(t.y),type:S.type})}const k=(e,t)=>_(R,e,t);function T(){const{height:e,iframe:r,msg:s,type:l,width:c}=S;switch(Z[R]?.firstRun&&function(){if(!Z[R])return;de(R,S.mode),Z[R].firstRun=!1}(),l){case"close":K(r);break;case"message":d=a(6),k("onMessage",{iframe:S.iframe,message:JSON.parse(d)});break;case"mouseenter":$("onMouseEnter");break;case"mouseleave":$("onMouseLeave");break;case"beforeUnload":L(R,"Ready state reset"),Z[R].ready=!1;break;case"autoResize":Z[R].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const e=S.width,t=S.height,n=window.parentIframe||window.parentIFrame||window;L(R,`scrollBy: x: %c${e}%c y: %c${t}`,i,o,i),n.scrollBy(e,t)}();break;case"scrollTo":z(!1);break;case"scrollToOffset":z(!0);break;case"pageInfo":h();break;case"parentInfo":m();break;case"pageInfoStop":b();break;case"parentInfoStop":v();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const e=w(n);L(R,`Moving to in page link: %c#${t}`,i),X.position={x:e.x,y:e.y},j(R),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(a(9));break;case"title":!function(e,t){Z[t]?.syncTitle&&(Z[t].iframe.title=e,L(t,`Set iframe title attribute: %c${e}`,i))}(s,R);break;case"reset":ie(S);break;case"init":t(),function(e){try{Z[e].sameOrigin=!!Z[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){Z[e].sameOrigin=!1}}(R),(u=s)!==n&&(void 0!==u||q(R,"<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")),le=!0,k("onReady",r);break;default:if(0===c&&0===e)return void N(R,`Unsupported message received (${l}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===c||0===e)return;if(document.hidden)return;t()}var u,d}function x(e){Z[e].ready||(re("iframe requested init",se(e),e),J(e,Z))}let M=e.data,S={},R=null;"[iFrameResizerChild]Ready"!==M?l===`${M}`.slice(0,13)&&M.slice(13).split(":")[0]in Z&&(S=function(){const e=M.slice(13).split(":"),t=e[1]?Number(e[1]):0,i=Z[e[0]]?.iframe,o=getComputedStyle(i),n={iframe:i,id:e[0],height:t+r(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(n.mode=e[5]),n}(),R=S.id,R?(H(R,S.type),F(R,function(){!function(e){if(!Z[e])throw new Error(`${S.type} No settings for ${e}. Message was: ${M}`)}(R),S.type in{true:1,false:1,undefined:1}||(Z[R].ready=!0,(null!==S.iframe||(N(R,`The iframe (${S.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:i}=e;if(i)return!0;let o=Z[R]?.checkOrigin;if(o&&"null"!=`${t}`&&!(o.constructor===Array?function(){let e=0,i=!1;for(;e<o.length;e++)if(o[e]===t){i=!0;break}return i}():function(){const e=Z[R]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${S.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&T())})()):N("","iframeResizer received messageData without id, message was: ",M)):Object.keys(Z).forEach(x)}function _(e,t,i){let o=null,n=null;if(Z[e]){if(o=Z[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),N(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function G(e){const{id:t}=e;delete Z[t],delete e.iframeResizer}function K(e){const{id:t}=e;if(!1!==_(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){N(t,e)}_(t,"onAfterClose",t),G(e)}}function Q(e){null===X.position&&(X.position={x:window.scrollX,y:window.scrollY})}function ee(){X.position=null}function te(e){null!==X.position&&(window.scrollTo(X.position.x,X.position.y),L(e,`Set page position: %c${X.position.x}%c, %c${X.position.y}`,i,o,i),ee())}function ie(e){Q(e.id),oe(e),re("reset","reset",e.id)}function oe(e){function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,L(o,`Set ${t}: %c${n}`,i)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=Z[o];n&&t("height"),r&&t("width")}I=Z;const ne=e=>e.split(":").filter((e,t)=>19!==t).join(":");function re(e,t,n){function r(r){const s=e in f?ne(t):t;L(n,r,i,o,i),L(n,`Message data: %c${s}`,i)}H(n,e),Z[n]&&(Z[n]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:o,targetOrigin:s}=Z[n];if(o)try{return e.contentWindow.iframeChildListener(l+t),void r(`Sending message to iframe %c${n}%c via sameOrigin`)}catch(e){}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),i.postMessage(l+t,s)}():N(n,`Iframe(${n}) not found`))}function se(e){const t=Z[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,X.version,t.mode,"",t.logExpand].join(":")}let ae=0,le=!1,ce=!1,ue=!1;function de(e,i=-3){if(ce)return;const o=Math.max(Z[e].mode,i);if(o>Z[e].mode&&(Z[e].mode=o),o<0)throw P(e),Z[e].vAdvised||q(e||"Parent",`${k(o+2)}${k(2)}`),Z[e].vAdvised=!0,k(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>-1&&ue||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,E||i<1?"font-weight: bold;":t))}(`v${n} (${(e=>v(j[e]))(o)})`,o),o<1&&q("Parent",k(3)),ce=!0}const fe=e=>t=>{function o(){if(Z[z]){const{iframe:e}=Z[z],t={close:K.bind(null,e),disconnect:G.bind(null,e),removeListeners(){q(z,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){q(z,"<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","resize",z)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),re("Move to anchor",`moveToAnchor:${e}`,z)},sendMessage(e){re("message",`message:${e=JSON.stringify(e)}`,z)}};e.iframeResizer=t,e.iFrameResizer=t}}function n(e){const{id:i}=t,{waitForLoad:o}=Z[i];g(t,"load",()=>{re(u,`${e}:${le}`,i),J(i,Z),function(){const e=Z[z]?.firstRun,i=Z[z]?.heightCalculationMethod in c;!e&&i&&ie({iframe:t,height:0,width:0,type:"init"})}()}),!0!==o&&(re(d,`${e}:${le}`,i),J(i,Z))}function l(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&q(z,`<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 <i>"${s}"</>, <i>"${a}"</> or <i>"${r}"</>.\n`),e):{}}function f(e){const t=Z[e]?.iframe?.title;return""===t||void 0===t}function y(e,t){x(Z[z],e)&&(q(z,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),Z[z][t]=Z[z][e],delete Z[z][e])}const b=e=>x(e,"onMouseEnter")||x(e,"onMouseLeave");function v(e){var o,n;Z[z]={...Z[z],iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...V,...l(e),mouseEvents:b(e),mode:T(e),syncTitle:f(z)},y("offset","offsetSize"),y("onClose","onBeforeClose"),y("onClosed","onAfterClose"),H(z,"setup"),function(){const{direction:e}=Z[z];switch(e){case s:break;case a:Z[z].sizeHeight=!1;case"both":Z[z].sizeWidth=!0;break;case r:Z[z].sizeWidth=!1,Z[z].sizeHeight=!1,Z[z].autoResize=!1;break;default:throw new TypeError(z,`Direction value of "${e}" is not valid`)}}(),(o=e?.offsetSize||e?.offset)&&(Z[z].direction===s?Z[z].offsetHeight=o:Z[z].offsetWidth=o),function(e){e?.offset&&q(z,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),Z[z].warningTimeout||L(z,"warningTimeout:%c disabled",i),null===Z[z].postMessageTarget&&(Z[z].postMessageTarget=t.contentWindow),Z[z].targetOrigin=!0===Z[z].checkOrigin?""===(n=Z[z].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const w=()=>"iframeResizer"in t,z=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(i=function(){let t=e?.id||V.id+ae++;return null!==document.getElementById(t)&&(t+=ae++),t}(),t.id=i),i}(t.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=h,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const i=x(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:V.log;x(t,"logExpand")||(t.logExpand=i&&o?t.log===p:V.logExpand),function(e){-1===e?.log&&(e.log=!1,ue=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=R({expand:t,label:W(i)});E=e,I[i]||(I[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in m)&&B(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(z,e),F(z,function(e){w()?N(z,`Ignored iframe (${z}), already setup.`):(v(e),function(){if(ce)return;const{mode:e}=Z[z];-1!==e&&de(z,e)}(),he(),function(){switch(t.style.overflow=!1===Z[z]?.scrolling?"hidden":"auto",Z[z]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=Z[z]?Z[z].scrolling:"no"}}(),function(){const{bodyMargin:e}=Z[z];"number"!=typeof e&&"0"!==e||(Z[z].bodyMargin=`${e}px`)}(),n(se(z)),o())})(e),t?.iframeResizer};function pe(){!1===document.hidden&&function(e,t){const i=e=>Z[e]?.autoResize&&!Z[e]?.firstRun;Object.keys(Z).forEach(function(o){i(o)&&re(e,t,o)})}("tabVisible","resize")}const he=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{g(window,"message",Y),g(document,"visibilitychange",pe),window.iframeParentListener=e=>setTimeout(()=>Y({data:e,sameOrigin:!0}))});export{fe as default};
20
+ import e,{NORMAL as t,HIGHLIGHT as i,FOREGROUND as o}from"auto-console-group";const n="5.5.5",r="autoResize",s="init",a="iframe requested init",l="load",c="message",u="onload",d="pageInfo",f="parentInfo",p="reset",h="resize",m="scroll",g="none",y="vertical",b="horizontal",v="[iFrameSizer]",w=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),z=Object.freeze({[u]:1,[s]:1,[a]:1}),j="expanded",$="collapsed",k=Object.freeze({[j]:1,[$]:1}),T=(e,t,i,o)=>e.addEventListener(t,i,o||!1),x=(e,t,i)=>e.removeEventListener(t,i,!1),M=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},S=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),R=["spjluzl","rlf","clyzpvu"],O=["<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."],E=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],I=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),W=e=>S(O[e]),A=e=>{const t=e[S(R[0])]||e[S(R[1])]||e[S(R[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=M(S(e));return i in I&&(t=I[i]),t}(i[0]);return 0===o||(e=>e[2]===M(e[0]+e[1]))(i)||(o=-2),o},C=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),L=e=>e,N=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),B={},H=(P=e,P?.__esModule?P.default:P);var P;let F=!0;const q=H({expand:!1,label:"parent"}),D=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const U=e=>(t,...i)=>B[t]?B[t].console[e](...i):q[e](...i);var J;const Z=(J="log",(e,...t)=>!0===(e=>B[e]?B[e].log:F)(e)?U(J)(e,...t):null),V=U("warn"),X=U("error"),Y=U("event"),_=U("purge"),G=U("errorBoundary");const K=(e,...t)=>B[e]?B[e].console.warn(N(L)(...t)):queueMicrotask(()=>console?.warn(N((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),Q=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(K),ee=Q("Option");function te(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));Y(e,"noResponse"),K(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${o?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},o))}const ie=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:y,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof B[e.id].onInit&&(ee("init()","onReady()","",e.id),B[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),oe={position:null,version:n};function ne(e){function t(){fe(P),ue(D),A("onResized",P)}function u(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function g(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const y=e=>H.slice(H.indexOf(":")+7+e);const b=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){he(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},w=(e,t)=>()=>{let i=!1;const o=t=>()=>{B[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):a()},n=o(m),r=o("resize window");function s(e,t){t(window,m,n),t(window,h,r)}function a(){Y(c,`stop${t}`),s(0,x),u.disconnect(),d.disconnect(),x(B[c].iframe,l,a)}const c=D,u=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));B[c]&&(B[c][`stop${t}`]=a,T(B[c].iframe,l,a),s(0,T),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(B[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},z=e=>()=>{e in B[D]&&(B[D][e](),delete B[D][e])},j=b(d,function(){const e=document.body.getBoundingClientRect(),t=P.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),$=b(f,function(){const{iframe:e}=P,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),k=w(j,"PageInfo"),M=w($,"ParentInfo"),S=z("stopPageInfo"),R=z("stopParentInfo");function O(e){const t=e.getBoundingClientRect();return le(),{x:Number(t.left)+Number(oe.position.x),y:Number(t.top)+Number(oe.position.y)}}function E(e){const t=e?O(P.iframe):{x:0,y:0};Z(D,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,i,o,i);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(P,t),r=window.parentIframe||window.parentIFrame;r?function(t,i){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](i.x,i.y))}(r,n):function(e){oe.position=e,I(D)}(n)}function I(e){const{x:t,y:i}=oe.position,o=B[e]?.iframe;!1!==A("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?ue(e):ce()}function W(e){let t={};if(0===P.width&&0===P.height){const e=y(9).split(":");t={x:e[1],y:e[0]}}else t={x:P.width,y:P.height};A(e,{iframe:P.iframe,screenX:Number(t.x),screenY:Number(t.y),type:P.type})}const A=(e,t)=>re(D,e,t);function C(){const{height:e,iframe:a,msg:l,type:u,width:h}=P;switch(B[D]?.firstRun&&function(){if(!B[D])return;we(D,P.mode),B[D].firstRun=!1}(),u){case"close":ae(a);break;case c:g=y(6),A("onMessage",{iframe:P.iframe,message:JSON.parse(g)});break;case"mouseenter":W("onMouseEnter");break;case"mouseleave":W("onMouseLeave");break;case"beforeUnload":Z(D,"Ready state reset"),B[D].ready=!1;break;case r:B[D].autoResize=JSON.parse(y(9));break;case"scrollBy":!function(){const e=P.width,t=P.height,n=window.parentIframe||window.parentIFrame||window;Z(D,`scrollBy: x: %c${e}%c y: %c${t}`,i,o,i),n.scrollBy(e,t)}();break;case"scrollTo":E(!1);break;case"scrollToOffset":E(!0);break;case d:k();break;case f:M();break;case"pageInfoStop":S();break;case"parentInfoStop":R();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const e=O(n);Z(D,`Moving to in page link: %c#${t}`,i),oe.position={x:e.x,y:e.y},I(D),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(y(9));break;case"title":!function(e,t){B[t]?.syncTitle&&(B[t].iframe.title=e,Z(t,`Set iframe title attribute: %c${e}`,i))}(l,D);break;case p:de(P);break;case s:t(),function(e){try{B[e].sameOrigin=!!B[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){B[e].sameOrigin=!1}}(D),(m=l)!==n&&(void 0!==m||K(D,"<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")),ye=!0,A("onReady",a);break;default:if(0===h&&0===e)return void V(D,`Unsupported message received (${u}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===h||0===e)return;if(document.hidden)return;t()}var m,g}function L(e){if(!B[e])throw new Error(`${P.type} No settings for ${e}. Message was: ${H}`)}const N=e=>Object.keys(B).forEach((e=>t=>{const{ready:i,postMessageTarget:o}=B[t];i||e!==o||(he(a,me(t),t),te(t,B))})(e));let H=e.data;if("[iFrameResizerChild]Ready"===H)return void N(e.source);if(!(e=>v===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in B)(H)){if("string"!=typeof H)return;return void Y("parent","ignoredMessage")}const P=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=B[t[0]]?.iframe,n=getComputedStyle(o),r={iframe:o,id:t[0],height:i+u(n)+g(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(r.mode=t[5]),r}(H),{id:F,type:q}=P,D=F;D?(Y(D,q),G(D,function(t){L(D),P.type in{true:1,false:1,undefined:1}||(B[D].ready=!0,(null!==P.iframe||(V(D,`The iframe (${P.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:i}=e;if(i)return!0;let o=B[D]?.checkOrigin;if(o&&"null"!=`${t}`&&!(o.constructor===Array?function(){let e=0,i=!1;for(;e<o.length;e++)if(o[e]===t){i=!0;break}return i}():function(){const e=B[D]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${P.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C())})(H)):V("","iframeResizer received messageData without id, message was: ",H)}function re(e,t,i){let o=null,n=null;if(B[e]){if(o=B[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),V(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function se(e){const{id:t}=e;delete B[t],delete e.iframeResizer}function ae(e){const{id:t}=e;if(!1!==re(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){V(t,e)}re(t,"onAfterClose",t),se(e)}}function le(e){null===oe.position&&(oe.position={x:window.scrollX,y:window.scrollY})}function ce(){oe.position=null}function ue(e){null!==oe.position&&(window.scrollTo(oe.position.x,oe.position.y),Z(e,`Set page position: %c${oe.position.x}%c, %c${oe.position.y}`,i,o,i),ce())}function de(e){le(e.id),fe(e),he(p,p,e.id)}function fe(e){function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,Z(o,`Set ${t}: %c${n}`,i)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=B[o];n&&t("height"),r&&t("width")}const pe=e=>e.split(":").filter((e,t)=>19!==t).join(":");function he(e,t,n){function r(r){const s=e in z?pe(t):t;Z(n,r,i,o,i),Z(n,`Message data: %c${s}`,i)}Y(n,e),B[n]&&(B[n]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:o,sameOrigin:s,targetOrigin:a}=B[n];if(s)try{return i.contentWindow.iframeChildListener(v+t),void r(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in z?B[n].sameOrigin=!1:V(n,"Same origin messaging failed, falling back to postMessage")}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${a}`),o.postMessage(v+t,a)}():V(n,`Iframe(${n}) not found`))}function me(e){const t=B[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,oe.version,t.mode,"",t.logExpand].join(":")}let ge=0,ye=!1,be=!1,ve=!1;function we(e,i=-3){if(be)return;const o=Math.max(B[e].mode,i);if(o>B[e].mode&&(B[e].mode=o),o<0)throw _(e),B[e].vAdvised||K(e||"Parent",`${W(o+2)}${W(2)}`),B[e].vAdvised=!0,W(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>-1&&ve||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,F||i<1?"font-weight: bold;":t))}(`v${n} (${(e=>S(E[e]))(o)})`,o),o<1&&K("Parent",W(3)),be=!0}const ze=e=>t=>{function o(){if(B[z]){const{iframe:e}=B[z],t={close:ae.bind(null,e),disconnect:se.bind(null,e),removeListeners(){K(z,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){K(z,"<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."),he.bind(null,"Window resize",h,z)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),he("Move to anchor",`moveToAnchor:${e}`,z)},sendMessage(e){e=JSON.stringify(e),he(c,`${c}:${e}`,z)}};e.iframeResizer=t,e.iFrameResizer=t}}function n(e){const{id:i}=t,{waitForLoad:o}=B[i];T(t,l,()=>{he(u,`${e}:${ye}`,i),te(i,B),function(){const e=B[z]?.firstRun,i=B[z]?.heightCalculationMethod in w;!e&&i&&de({iframe:t,height:0,width:0,type:s})}()}),!0!==o&&(he(s,`${e}:${ye}`,i),te(i,B))}function a(e){return e?(("sizeWidth"in e||"sizeHeight"in e||r in e)&&K(z,`<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 <i>"${y}"</>, <i>"${b}"</> or <i>"${g}"</>.\n`),e):{}}function d(e){const t=B[e]?.iframe?.title;return""===t||void 0===t}function f(e,t){C(B[z],e)&&(K(z,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),B[z][t]=B[z][e],delete B[z][e])}const p=e=>C(e,"onMouseEnter")||C(e,"onMouseLeave");function m(e){var o,n;B[z]={...B[z],iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...ie,...a(e),mouseEvents:p(e),mode:A(e),syncTitle:d(z)},f("offset","offsetSize"),f("onClose","onBeforeClose"),f("onClosed","onAfterClose"),Y(z,"setup"),function(){const{direction:e}=B[z];switch(e){case y:break;case b:B[z].sizeHeight=!1;case"both":B[z].sizeWidth=!0;break;case g:B[z].sizeWidth=!1,B[z].sizeHeight=!1,B[z].autoResize=!1;break;default:throw new TypeError(z,`Direction value of "${e}" is not valid`)}}(),(o=e?.offsetSize||e?.offset)&&(B[z].direction===y?B[z].offsetHeight=o:B[z].offsetWidth=o),function(e){e?.offset&&K(z,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),B[z].warningTimeout||Z(z,"warningTimeout:%c disabled",i),null===B[z].postMessageTarget&&(B[z].postMessageTarget=t.contentWindow),B[z].targetOrigin=!0===B[z].checkOrigin?""===(n=B[z].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const v=()=>"iframeResizer"in t,z=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(i=function(){let t=e?.id||ie.id+ge++;return null!==document.getElementById(t)&&(t+=ge++),t}(),t.id=i),i}(t.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=$,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const i=C(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:ie.log;C(t,"logExpand")||(t.logExpand=i&&o?t.log===j:ie.logExpand),function(e){-1===e?.log&&(e.log=!1,ve=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=H({expand:t,label:D(i)});F=e,B[i]||(B[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in k)&&X(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(z,e),G(z,function(e){v()?V(z,`Ignored iframe (${z}), already setup.`):(m(e),function(){if(be)return;const{mode:e}=B[z];-1!==e&&we(z,e)}(),$e(),function(){switch(t.style.overflow=!1===B[z]?.scrolling?"hidden":"auto",B[z]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=B[z]?B[z].scrolling:"no"}}(),function(){const{bodyMargin:e}=B[z];"number"!=typeof e&&"0"!==e||(B[z].bodyMargin=`${e}px`)}(),n(me(z)),o())})(e),t?.iframeResizer};function je(){!1===document.hidden&&function(e,t){const i=e=>B[e]?.autoResize&&!B[e]?.firstRun;Object.keys(B).forEach(function(o){i(o)&&he(e,t,o)})}("tabVisible",h)}const $e=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{T(window,c,ne),T(document,"visibilitychange",je),window.iframeParentListener=e=>setTimeout(()=>ne({data:e,sameOrigin:!0}))});export{ze as default};
package/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.4 (umd) - 2025-08-27
4
+ * @module iframe-resizer/core 5.5.5 (umd) - 2025-09-01
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=t(e.acg)}(this,function(e){"use strict";const t="5.5.4",o="none",i="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),u="expanded",d="collapsed",f=Object.freeze({[u]:1,[d]:1}),p=(e,t,o,i)=>e.addEventListener(t,o,i||!1),h=(e,t,o)=>e.removeEventListener(t,o,!1),m=e=>{if(!e)return"";let t=-559038744,o=1103547984;for(let i,n=0;n<e.length;n++)i=e.codePointAt(n),t=Math.imul(t^i,2246822519),o=Math.imul(o^i,3266489917);return t^=Math.imul(t^o>>>15,1935289751),o^=Math.imul(o^t>>>15,3405138345),t^=o>>>16,o^=t>>>16,(2097152*(o>>>0)+(t>>>11)).toString(36)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<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."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),z=e=>g(b[e]),j=e=>{const t=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!t)return-1;const o=t.split("-");let i=function(e=""){let t=-2;const o=m(g(e));return o in w&&(t=w[o]),t}(o[0]);return 0===i||(e=>e[2]===m(e[0]+e[1]))(o)||(i=-2),i},T=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),$=e=>e,I=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),k=(H=e,H?.__esModule?H.default:H);var H;let x={},R=!1;const M=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const O=e=>(t,...o)=>x[t]?.console[e](...o);var L;const S=(L="log",(e,...t)=>!0===(e=>x[e]?x[e].log:R)(e)?O(L)(e,...t):null),E=O("warn"),W=O("error"),A=O("event"),C=O("purge"),G=O("errorBoundary");const N=(e,...t)=>x[e]?x[e].console.warn(I($)(...t)):queueMicrotask(()=>console?.warn(I((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),B=(e=>(t,o="renamed to")=>(i,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${i.replace("()","")})</>\n\nThe <b>${i}</> ${t.toLowerCase()} has been ${o} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(N),F=B("Option");function P(e,t){const{msgTimeout:o,warningTimeout:i}=t[e];i&&(o&&clearTimeout(o),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:o,loadErrorShown:i}=t[e];t[e].msgTimeout=void 0,o||i||(t[e].loadErrorShown=!0,function(e,t){const{iframe:o,waitForLoad:i}=t[e],{sandbox:n}=o,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),N(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${i?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},i))}const q={},D=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:i,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof q[e.id].onInit&&(F("init()","onReady()","",e.id),q[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),U={position:null,version:t};function J(o){function i(){ee(H),K(x),T("onResized",H)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>k.slice(k.indexOf(":")+7+e);const l=(e,t)=>(o,i)=>{const n={};var r,s;r=function(){oe(`${o} (${e})`,`${e}:${t()}`,i)},n[s=i]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,t)=>()=>{let o=!1;const i=t=>()=>{q[l]?o&&o!==t||(e(t,l),o=t,requestAnimationFrame(()=>{o=!1})):a()},n=i("scroll"),r=i("resize window");function s(e,t){t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${t}`),s(0,h),c.disconnect(),u.disconnect(),h(q[l].iframe,"load",a)}const l=x,c=new ResizeObserver(i("pageObserver")),u=new ResizeObserver(i("iframeObserver"));q[l]&&(q[l][`stop${t}`]=a,p(q[l].iframe,"load",a),s(0,p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(q[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},u=e=>()=>{e in q[x]&&(q[x][e](),delete q[x][e])},d=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),t=H.iframe.getBoundingClientRect(),{scrollY:o,scrollX:i,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:o,scrollLeft:i,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=H,{scrollWidth:t,scrollHeight:o}=document.documentElement,{width:i,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:o},viewport:{width:i,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),m=c(d,"PageInfo"),g=c(f,"ParentInfo"),y=u("stopPageInfo"),b=u("stopParentInfo");function v(e){const t=e.getBoundingClientRect();return Y(),{x:Number(t.left)+Number(U.position.x),y:Number(t.top)+Number(U.position.y)}}function w(t){const o=t?v(H.iframe):{x:0,y:0};S(x,`Reposition requested (offset x:%c${o.x}%c y:%c${o.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const i=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(H,o),n=window.parentIframe||window.parentIFrame;n?function(e,o){e["scrollTo"+(t?"Offset":"")](o.x,o.y)}(n,i):function(e){U.position=e,z(x)}(i)}function z(e){const{x:t,y:o}=U.position,i=q[e]?.iframe;!1!==T("onScroll",{iframe:i,top:o,left:t,x:t,y:o})?K(e):_()}function j(e){let t={};if(0===H.width&&0===H.height){const e=a(9).split(":");t={x:e[1],y:e[0]}}else t={x:H.width,y:H.height};T(e,{iframe:H.iframe,screenX:Number(t.x),screenY:Number(t.y),type:H.type})}const T=(e,t)=>Z(x,e,t);function $(){const{height:o,iframe:n,msg:r,type:s,width:l}=H;switch(q[x]?.firstRun&&function(){if(!q[x])return;le(x,H.mode),q[x].firstRun=!1}(),s){case"close":X(n);break;case"message":u=a(6),T("onMessage",{iframe:H.iframe,message:JSON.parse(u)});break;case"mouseenter":j("onMouseEnter");break;case"mouseleave":j("onMouseLeave");break;case"beforeUnload":S(x,"Ready state reset"),q[x].ready=!1;break;case"autoResize":q[x].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const t=H.width,o=H.height,i=window.parentIframe||window.parentIFrame||window;S(x,`scrollBy: x: %c${t}%c y: %c${o}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),i.scrollBy(t,o)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":m();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(t){const o=t.split("#")[1]||"",i=decodeURIComponent(o);let n=document.getElementById(i)||document.getElementsByName(i)[0];n?function(){const t=v(n);S(x,`Moving to in page link: %c#${o}`,e.HIGHLIGHT),U.position={x:t.x,y:t.y},z(x),window.location.hash=o}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(o)}()}(a(9));break;case"title":!function(t,o){q[o]?.syncTitle&&(q[o].iframe.title=t,S(o,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(r,x);break;case"reset":Q(H);break;case"init":i(),function(e){try{q[e].sameOrigin=!!q[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){q[e].sameOrigin=!1}}(x),(c=r)!==t&&(void 0!==c||N(x,"<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")),re=!0,T("onReady",n);break;default:if(0===l&&0===o)return void E(x,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===o)return;if(document.hidden)return;i()}var c,u}function I(e){q[e].ready||(oe("iframe requested init",ie(e),e),P(e,q))}let k=o.data,H={},x=null;"[iFrameResizerChild]Ready"!==k?r===`${k}`.slice(0,13)&&k.slice(13).split(":")[0]in q&&(H=function(){const e=k.slice(13).split(":"),t=e[1]?Number(e[1]):0,o=q[e[0]]?.iframe,i=getComputedStyle(o),r={iframe:o,id:e[0],height:t+n(i)+s(i),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),x=H.id,x?(A(x,H.type),G(x,function(){!function(e){if(!q[e])throw new Error(`${H.type} No settings for ${e}. Message was: ${k}`)}(x),H.type in{true:1,false:1,undefined:1}||(q[x].ready=!0,(null!==H.iframe||(E(x,`The iframe (${H.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=o;if(t)return!0;let i=q[x]?.checkOrigin;if(i&&"null"!=`${e}`&&!(i.constructor===Array?function(){let t=0,o=!1;for(;t<i.length;t++)if(i[t]===e){o=!0;break}return o}():function(){const t=q[x]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${H.iframe.id}. Message was: ${o.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&$())})()):E("","iframeResizer received messageData without id, message was: ",k)):Object.keys(q).forEach(I)}function Z(e,t,o){let i=null,n=null;if(q[e]){if(i=q[e][t],"function"!=typeof i)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=i(o)}catch(o){console.error(o),E(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(i,o)}return n}function V(e){const{id:t}=e;delete q[t],delete e.iframeResizer}function X(e){const{id:t}=e;if(!1!==Z(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),V(e)}}function Y(e){null===U.position&&(U.position={x:window.scrollX,y:window.scrollY})}function _(){U.position=null}function K(t){null!==U.position&&(window.scrollTo(U.position.x,U.position.y),S(t,`Set page position: %c${U.position.x}%c, %c${U.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),_())}function Q(e){Y(e.id),ee(e),oe("reset","reset",e.id)}function ee(t){function o(o){const n=`${t[o]}px`;t.iframe.style[o]=n,S(i,`Set ${o}: %c${n}`,e.HIGHLIGHT)}const{id:i}=t,{sizeHeight:n,sizeWidth:r}=q[i];n&&o("height"),r&&o("width")}x=q;const te=e=>e.split(":").filter((e,t)=>19!==t).join(":");function oe(t,o,i){function n(n){const r=t in c?te(o):o;S(i,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(i,`Message data: %c${r}`,e.HIGHLIGHT)}A(i,t),q[i]&&(q[i]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:t,sameOrigin:s,targetOrigin:a}=q[i];if(s)try{return e.contentWindow.iframeChildListener(r+o),void n(`Sending message to iframe %c${i}%c via sameOrigin`)}catch(e){}n(`Sending message to iframe: %c${i}%c targetOrigin: %c${a}`),t.postMessage(r+o,a)}():E(i,`Iframe(${i}) not found`))}function ie(e){const t=q[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,U.version,t.mode,"",t.logExpand].join(":")}let ne=0,re=!1,se=!1,ae=!1;function le(o,i=-3){if(se)return;const n=Math.max(q[o].mode,i);if(n>q[o].mode&&(q[o].mode=n),n<0)throw C(o),q[o].vAdvised||N(o||"Parent",`${z(n+2)}${z(2)}`),q[o].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&ae||function(t,o){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,R||o<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>g(v[e]))(n)})`,n),n<1&&N("Parent",z(3)),se=!0}function ce(){!1===document.hidden&&function(e,t){const o=e=>q[e]?.autoResize&&!q[e]?.firstRun;Object.keys(q).forEach(function(i){o(i)&&oe(e,t,i)})}("tabVisible","resize")}const ue=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",J),p(document,"visibilitychange",ce),window.iframeParentListener=e=>setTimeout(()=>J({data:e,sameOrigin:!0}))});return t=>r=>{function c(){if(q[z]){const{iframe:e}=q[z],t={close:X.bind(null,e),disconnect:V.bind(null,e),removeListeners(){N(z,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){N(z,"<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."),oe.bind(null,"Window resize","resize",z)},moveToAnchor(e){((e,t,o)=>{if(typeof e!==t)throw new TypeError(`${o} is not a ${i=t,i.charAt(0).toUpperCase()+i.slice(1)}`);var i})(e,"string","moveToAnchor(anchor) anchor"),oe("Move to anchor",`moveToAnchor:${e}`,z)},sendMessage(e){oe("message",`message:${e=JSON.stringify(e)}`,z)}};e.iframeResizer=t,e.iFrameResizer=t}}function h(e){const{id:t}=r,{waitForLoad:o}=q[t];p(r,"load",()=>{oe(a,`${e}:${re}`,t),P(t,q),function(){const e=q[z]?.firstRun,t=q[z]?.heightCalculationMethod in s;!e&&t&&Q({iframe:r,height:0,width:0,type:"init"})}()}),!0!==o&&(oe(l,`${e}:${re}`,t),P(t,q))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&N(z,`<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 <i>"${i}"</>, <i>"${n}"</> or <i>"${o}"</>.\n`),e):{}}function g(e){const t=q[e]?.iframe?.title;return""===t||void 0===t}function y(e,t){T(q[z],e)&&(N(z,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),q[z][t]=q[z][e],delete q[z][e])}const b=e=>T(e,"onMouseEnter")||T(e,"onMouseLeave");function v(t){var s,a;q[z]={...q[z],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...D,...m(t),mouseEvents:b(t),mode:j(t),syncTitle:g(z)},y("offset","offsetSize"),y("onClose","onBeforeClose"),y("onClosed","onAfterClose"),A(z,"setup"),function(){const{direction:e}=q[z];switch(e){case i:break;case n:q[z].sizeHeight=!1;case"both":q[z].sizeWidth=!0;break;case o:q[z].sizeWidth=!1,q[z].sizeHeight=!1,q[z].autoResize=!1;break;default:throw new TypeError(z,`Direction value of "${e}" is not valid`)}}(),(s=t?.offsetSize||t?.offset)&&(q[z].direction===i?q[z].offsetHeight=s:q[z].offsetWidth=s),function(e){e?.offset&&N(z,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(t),q[z].warningTimeout||S(z,"warningTimeout:%c disabled",e.HIGHLIGHT),null===q[z].postMessageTarget&&(q[z].postMessageTarget=r.contentWindow),q[z].targetOrigin=!0===q[z].checkOrigin?""===(a=q[z].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const w=()=>"iframeResizer"in r,z=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||D.id+ne++;return null!==document.getElementById(e)&&(e+=ne++),e}(),r.id=e),e}(r.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=d,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const o=T(t,"log"),i="string"==typeof t.log,n=o?!!i||t.log:D.log;T(t,"logExpand")||(t.logExpand=o&&i?t.log===u:D.logExpand),function(e){-1===e?.log&&(e.log=!1,ae=!0)}(t),function({enabled:e,expand:t,iframeId:o}){const i=k({expand:t,label:M(o)});R=e,x[o]||(x[o]={console:i})}({enabled:n,expand:t.logExpand,iframeId:e}),i&&!(t.log in f)&&W(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(z,t),G(z,function(e){w()?E(z,`Ignored iframe (${z}), already setup.`):(v(e),function(){if(se)return;const{mode:e}=q[z];-1!==e&&le(z,e)}(),ue(),function(){switch(r.style.overflow=!1===q[z]?.scrolling?"hidden":"auto",q[z]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=q[z]?q[z].scrolling:"no"}}(),function(){const{bodyMargin:e}=q[z];"number"!=typeof e&&"0"!==e||(q[z].bodyMargin=`${e}px`)}(),h(ie(z)),c())})(t),r?.iframeResizer}});
20
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=t(e.acg)}(this,function(e){"use strict";const t="5.5.5",i="autoResize",o="init",n="iframe requested init",r="load",s="message",a="onload",l="pageInfo",c="parentInfo",u="reset",d="resize",f="scroll",p="none",h="vertical",m="horizontal",g="[iFrameSizer]",y=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),b=Object.freeze({[a]:1,[o]:1,[n]:1}),v="expanded",w="collapsed",z=Object.freeze({[v]:1,[w]:1}),j=(e,t,i,o)=>e.addEventListener(t,i,o||!1),T=(e,t,i)=>e.removeEventListener(t,i,!1),$=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},k=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),I=["spjluzl","rlf","clyzpvu"],H=["<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."],x=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],M=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),R=e=>k(H[e]),O=e=>{const t=e[k(I[0])]||e[k(I[1])]||e[k(I[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=$(k(e));return i in M&&(t=M[i]),t}(i[0]);return 0===o||(e=>e[2]===$(e[0]+e[1]))(i)||(o=-2),o},L=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),S=e=>e,E=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),W={},A=(C=e,C?.__esModule?C.default:C);var C;let G=!0;const N=A({expand:!1,label:"parent"}),B=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const F=e=>(t,...i)=>W[t]?W[t].console[e](...i):N[e](...i);var P;const q=(P="log",(e,...t)=>!0===(e=>W[e]?W[e].log:G)(e)?F(P)(e,...t):null),D=F("warn"),U=F("error"),J=F("event"),Z=F("purge"),V=F("errorBoundary");const X=(e,...t)=>W[e]?W[e].console.warn(E(S)(...t)):queueMicrotask(()=>console?.warn(E((e=>(...t)=>[`iframeResizer(${e})`,...t].join(" "))(e))(...t))),Y=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(X),_=Y("Option");function K(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));J(e,"noResponse"),X(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${o?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},o))}const Q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:h,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof W[e.id].onInit&&(_("init()","onReady()","",e.id),W[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),ee={position:null,version:t};function te(a){function p(){ce(N),ae(P),S("onResized",N)}function h(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function m(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const y=e=>G.slice(G.indexOf(":")+7+e);const b=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){de(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},v=(e,t)=>()=>{let i=!1;const o=t=>()=>{W[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(f),s=o("resize window");function a(e,t){t(window,f,n),t(window,d,s)}function l(){J(c,`stop${t}`),a(0,T),u.disconnect(),p.disconnect(),T(W[c].iframe,r,l)}const c=P,u=new ResizeObserver(o("pageObserver")),p=new ResizeObserver(o("iframeObserver"));W[c]&&(W[c][`stop${t}`]=l,j(W[c].iframe,r,l),a(0,j),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),p.observe(W[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},w=e=>()=>{e in W[P]&&(W[P][e](),delete W[P][e])},z=b(l,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),$=b(c,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),k=v(z,"PageInfo"),I=v($,"ParentInfo"),H=w("stopPageInfo"),x=w("stopParentInfo");function M(e){const t=e.getBoundingClientRect();return re(),{x:Number(t.left)+Number(ee.position.x),y:Number(t.top)+Number(ee.position.y)}}function R(t){const i=t?M(N.iframe):{x:0,y:0};q(P,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){ee.position=e,O(P)}(o)}function O(e){const{x:t,y:i}=ee.position,o=W[e]?.iframe;!1!==S("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?ae(e):se()}function L(e){let t={};if(0===N.width&&0===N.height){const e=y(9).split(":");t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};S(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const S=(e,t)=>ie(P,e,t);function E(){const{height:n,iframe:r,msg:a,type:d,width:f}=N;switch(W[P]?.firstRun&&function(){if(!W[P])return;ye(P,N.mode),W[P].firstRun=!1}(),d){case"close":ne(r);break;case s:m=y(6),S("onMessage",{iframe:N.iframe,message:JSON.parse(m)});break;case"mouseenter":L("onMouseEnter");break;case"mouseleave":L("onMouseLeave");break;case"beforeUnload":q(P,"Ready state reset"),W[P].ready=!1;break;case i:W[P].autoResize=JSON.parse(y(9));break;case"scrollBy":!function(){const t=N.width,i=N.height,o=window.parentIframe||window.parentIFrame||window;q(P,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case l:k();break;case c:I();break;case"pageInfoStop":H();break;case"parentInfoStop":x();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=M(n);q(P,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),ee.position={x:t.x,y:t.y},O(P),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(y(9));break;case"title":!function(t,i){W[i]?.syncTitle&&(W[i].iframe.title=t,q(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(a,P);break;case u:le(N);break;case o:p(),function(e){try{W[e].sameOrigin=!!W[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){W[e].sameOrigin=!1}}(P),(h=a)!==t&&(void 0!==h||X(P,"<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")),he=!0,S("onReady",r);break;default:if(0===f&&0===n)return void D(P,`Unsupported message received (${d}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===f||0===n)return;if(document.hidden)return;p()}var h,m}function A(e){if(!W[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${G}`)}const C=e=>Object.keys(W).forEach((e=>t=>{const{ready:i,postMessageTarget:o}=W[t];i||e!==o||(de(n,fe(t),t),K(t,W))})(e));let G=a.data;if("[iFrameResizerChild]Ready"===G)return void C(a.source);if(!(e=>g===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in W)(G)){if("string"!=typeof G)return;return void J("parent","ignoredMessage")}const N=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=W[t[0]]?.iframe,n=getComputedStyle(o),r={iframe:o,id:t[0],height:i+h(n)+m(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(r.mode=t[5]),r}(G),{id:B,type:F}=N,P=B;P?(J(P,F),V(P,function(e){A(P),N.type in{true:1,false:1,undefined:1}||(W[P].ready=!0,(null!==N.iframe||(D(P,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=a;if(t)return!0;let i=W[P]?.checkOrigin;if(i&&"null"!=`${e}`&&!(i.constructor===Array?function(){let t=0,o=!1;for(;t<i.length;t++)if(i[t]===e){o=!0;break}return o}():function(){const t=W[P]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${N.iframe.id}. Message was: ${a.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&E())})(G)):D("","iframeResizer received messageData without id, message was: ",G)}function ie(e,t,i){let o=null,n=null;if(W[e]){if(o=W[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),D(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function oe(e){const{id:t}=e;delete W[t],delete e.iframeResizer}function ne(e){const{id:t}=e;if(!1!==ie(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){D(t,e)}ie(t,"onAfterClose",t),oe(e)}}function re(e){null===ee.position&&(ee.position={x:window.scrollX,y:window.scrollY})}function se(){ee.position=null}function ae(t){null!==ee.position&&(window.scrollTo(ee.position.x,ee.position.y),q(t,`Set page position: %c${ee.position.x}%c, %c${ee.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),se())}function le(e){re(e.id),ce(e),de(u,u,e.id)}function ce(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,q(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=W[o];n&&i("height"),r&&i("width")}const ue=e=>e.split(":").filter((e,t)=>19!==t).join(":");function de(t,i,o){function n(n){const r=t in b?ue(i):i;q(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),q(o,`Message data: %c${r}`,e.HIGHLIGHT)}J(o,t),W[o]&&(W[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=W[o];if(s)try{return e.contentWindow.iframeChildListener(g+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in b?W[o].sameOrigin=!1:D(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage(g+i,a)}():D(o,`Iframe(${o}) not found`))}function fe(e){const t=W[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,ee.version,t.mode,"",t.logExpand].join(":")}let pe=0,he=!1,me=!1,ge=!1;function ye(i,o=-3){if(me)return;const n=Math.max(W[i].mode,o);if(n>W[i].mode&&(W[i].mode=n),n<0)throw Z(i),W[i].vAdvised||X(i||"Parent",`${R(n+2)}${R(2)}`),W[i].vAdvised=!0,R(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&ge||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,G||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>k(x[e]))(n)})`,n),n<1&&X("Parent",R(3)),me=!0}function be(){!1===document.hidden&&function(e,t){const i=e=>W[e]?.autoResize&&!W[e]?.firstRun;Object.keys(W).forEach(function(o){i(o)&&de(e,t,o)})}("tabVisible",d)}const ve=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{j(window,s,te),j(document,"visibilitychange",be),window.iframeParentListener=e=>setTimeout(()=>te({data:e,sameOrigin:!0}))});return t=>n=>{function l(){if(W[k]){const{iframe:e}=W[k],t={close:ne.bind(null,e),disconnect:oe.bind(null,e),removeListeners(){X(k,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){X(k,"<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."),de.bind(null,"Window resize",d,k)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),de("Move to anchor",`moveToAnchor:${e}`,k)},sendMessage(e){e=JSON.stringify(e),de(s,`${s}:${e}`,k)}};e.iframeResizer=t,e.iFrameResizer=t}}function c(e){const{id:t}=n,{waitForLoad:i}=W[t];j(n,r,()=>{de(a,`${e}:${he}`,t),K(t,W),function(){const e=W[k]?.firstRun,t=W[k]?.heightCalculationMethod in y;!e&&t&&le({iframe:n,height:0,width:0,type:o})}()}),!0!==i&&(de(o,`${e}:${he}`,t),K(t,W))}function u(e){return e?(("sizeWidth"in e||"sizeHeight"in e||i in e)&&X(k,`<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 <i>"${h}"</>, <i>"${m}"</> or <i>"${p}"</>.\n`),e):{}}function f(e){const t=W[e]?.iframe?.title;return""===t||void 0===t}function g(e,t){L(W[k],e)&&(X(k,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),W[k][t]=W[k][e],delete W[k][e])}const b=e=>L(e,"onMouseEnter")||L(e,"onMouseLeave");function T(t){var i,o;W[k]={...W[k],iframe:n,firstRun:!0,remoteHost:n?.src.split("/").slice(0,3).join("/"),...Q,...u(t),mouseEvents:b(t),mode:O(t),syncTitle:f(k)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),J(k,"setup"),function(){const{direction:e}=W[k];switch(e){case h:break;case m:W[k].sizeHeight=!1;case"both":W[k].sizeWidth=!0;break;case p:W[k].sizeWidth=!1,W[k].sizeHeight=!1,W[k].autoResize=!1;break;default:throw new TypeError(k,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(W[k].direction===h?W[k].offsetHeight=i:W[k].offsetWidth=i),function(e){e?.offset&&X(k,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(t),W[k].warningTimeout||q(k,"warningTimeout:%c disabled",e.HIGHLIGHT),null===W[k].postMessageTarget&&(W[k].postMessageTarget=n.contentWindow),W[k].targetOrigin=!0===W[k].checkOrigin?""===(o=W[k].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const $=()=>"iframeResizer"in n,k=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||Q.id+pe++;return null!==document.getElementById(e)&&(e+=pe++),e}(),n.id=e),e}(n.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=w,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const i=L(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:Q.log;L(t,"logExpand")||(t.logExpand=i&&o?t.log===v:Q.logExpand),function(e){-1===e?.log&&(e.log=!1,ge=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=A({expand:t,label:B(i)});G=e,W[i]||(W[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in z)&&U(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(k,t),V(k,function(e){$()?D(k,`Ignored iframe (${k}), already setup.`):(T(e),function(){if(me)return;const{mode:e}=W[k];-1!==e&&ye(k,e)}(),ve(),function(){switch(n.style.overflow=!1===W[k]?.scrolling?"hidden":"auto",W[k]?.scrolling){case"omit":break;case!0:n.scrolling="yes";break;case!1:n.scrolling="no";break;default:n.scrolling=W[k]?W[k].scrolling:"no"}}(),function(){const{bodyMargin:e}=W[k];"number"!=typeof e&&"0"!==e||(W[k].bodyMargin=`${e}px`)}(),c(fe(k)),l())})(t),n?.iframeResizer}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iframe-resizer/core",
3
- "version": "5.5.4",
3
+ "version": "5.5.5",
4
4
  "license": "GPL-3.0",
5
5
  "homepage": "https://iframe-resizer.com",
6
6
  "author": {
@@ -34,6 +34,6 @@
34
34
  "core"
35
35
  ],
36
36
  "dependencies": {
37
- "auto-console-group": "1.2.10"
37
+ "auto-console-group": "1.2.11"
38
38
  }
39
39
  }