@iframe-resizer/core 6.0.0-beta.4 → 6.0.0-beta.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/index.umd.js CHANGED
@@ -1,27 +1,27 @@
1
- (function(m,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@iframe-resizer/common/consts"),require("@iframe-resizer/common/utils"),require("@iframe-resizer/common/deprecate"),require("@iframe-resizer/common/format-advise"),require("auto-console-group"),require("@iframe-resizer/common/listeners"),require("@iframe-resizer/common/mode")):typeof define=="function"&&define.amd?define(["exports","@iframe-resizer/common/consts","@iframe-resizer/common/utils","@iframe-resizer/common/deprecate","@iframe-resizer/common/format-advise","auto-console-group","@iframe-resizer/common/listeners","@iframe-resizer/common/mode"],i):(m=typeof globalThis<"u"?globalThis:m||self,i(m.connectResizer={},m.consts,m.utils,m.deprecate,m.createFormatAdvise,m.acg,m.listeners,m.setMode))})(this,(function(m,i,p,fe,D,s,H,T){"use strict";const r={},_=p.esModuleInterop(s);let P=!0;const ue=_({expand:!1,label:i.PARENT}),le=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`,de=e=>r[e]?r[e].log:P;function ge({enabled:e,expand:n,iframeId:t}){const o=_({expand:n,label:le(t)});P=e,r[t]||(r[t]={console:o})}const S=e=>(n,...t)=>r[n]?r[n].console[e](...t):ue[e](...t),z=e=>(n,...t)=>de(n)===!0?S(e)(n,...t):null,u=z("log"),O=u,me=z("debug"),L=S("warn"),he=S("error"),w=S("event"),Ee=S("purge"),pe=S("endAutoGroup"),C=S("errorBoundary");function Ie(e,n){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,P||n<1?i.BOLD:s.NORMAL))}const Oe=e=>(...n)=>[`${i.LABEL}(${e})`,...n].join(" "),be=D(p.id),b=(e,...n)=>r[e]?r[e].console.warn(...n.map(be)):queueMicrotask(()=>{const t=D(Oe(e));console?.warn(...n.map(t))}),$=fe(b);$("Function"),$("Method"),$("Option");const y=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:i.VERTICAL,firstRun:!0,inPageLinks:!1,heightCalculationMethod:i.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:i.AUTO,onBeforeClose:()=>!0,onAfterClose(){},onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let F=0;function Te(e){const n=e?.id||y.id+F++;return document.getElementById(n)===null?n:`${n}${F++}`}function we(e,n){let{id:t}=e;if(t&&!p.isString(t))throw new TypeError("Invalid id for iframe. Expected String");return(!t||t==="")&&(t=Te(n),e.id=t,w(t,"assignId"),u(t,`Added missing iframe ID: ${t} (${e.src})`)),t}function Le(e){const{search:n}=window.location;if(n.includes("ifrlog"))switch(new URLSearchParams(n).get("ifrlog")){case String(i.LOG_DISABLED):{e.log=!1;break}case i.EXPAND:case String(i.LOG_EXPANDED):{e.log=i.EXPAND;break}case i.COLLAPSE:case String(i.LOG_COLLAPSED):{e.log=i.COLLAPSE;break}default:e.log=i.COLLAPSE}}const He=e=>e.split(i.SEPARATOR).filter((n,t)=>t!==19).join(i.SEPARATOR);function Se(e,n,t){function o(d){const g=e in i.INIT_EVENTS?He(n):n;O(t,d,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),O(t,`Message data: %c${g}`,s.HIGHLIGHT)}const{iframe:a,postMessageTarget:l,sameOrigin:c,targetOrigin:f}=r[t];if(c)try{a.contentWindow.iframeChildListener(i.MESSAGE_ID+n),o(`Sending message to iframe %c${t}%c via same origin%c`);return}catch{e in i.INIT_EVENTS?(r[t].sameOrigin=!1,u(t,"New iframe does not support same origin")):L(t,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${t}%c targetOrigin: %c${f.join(", ")}`);for(const d of f)l.postMessage(i.MESSAGE_ID+n,d)}function G(e,n,t){if(w(t,e),!r[t]?.postMessageTarget){L(t,"Iframe not found");return}Se(e,n,t)}const Re=(e,n)=>Object.values(r).filter(({autoResize:t,firstRun:o})=>t&&!o).forEach(({iframe:t})=>G(e,n,t.id));function Ae(){document.hidden!==!0&&Re("tabVisible",i.RESIZE)}function Ge(e){if(e.boxSizing!=="border-box")return 0;const n=e.paddingTop?parseInt(e.paddingTop,10):0,t=e.paddingBottom?parseInt(e.paddingBottom,10):0;return n+t}function Me(e){if(e.boxSizing!=="border-box")return 0;const n=e.borderTopWidth?parseInt(e.borderTopWidth,10):0,t=e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0;return n+t}function ye(e){const n=e.slice(i.MESSAGE_ID_LENGTH).split(":"),t=n[1]?Number(n[1]):0,o=r[n[0]]?.iframe,a=o?getComputedStyle(o):null,l=a?Ge(a)+Me(a):0,c={iframe:o,id:n[0],height:t+l,width:Number(n[2]),type:n[3],msg:n[4],message:n[4]};return n[5]&&(c.mode=n[5]),c}const Ne={true:1,false:1,undefined:1};function Pe(e){const{id:n,msg:t,iframe:o}=e,a=p.isIframe(o);return a||(u(n,`Received: %c${t}`,s.HIGHLIGHT),L(n,"The target iframe was not found.")),a}function $e(e,n){const{id:t}=e,{data:o,origin:a}=n;if("sameOrigin"in n&&n.sameOrigin)return!0;const c=r[t]?.checkOrigin;function f(){function d(){u(t,`Checking connection is from allowed list of origins: %c${c}`,s.HIGHLIGHT);for(const h of c)if(h===a)return!0;return!1}function g(){const h=r[t]?.remoteHost;return u(t,`Checking connection is from: %c${h}`,s.HIGHLIGHT),a===h}return c.constructor===Array?d():g()}if(c&&`${a}`!="null"&&!f())throw new Error(`Unexpected message received from: ${a} for ${t}. Message was: ${o}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}const ve=e=>i.MESSAGE_ID===`${e}`.slice(0,i.MESSAGE_ID_LENGTH)&&e.slice(i.MESSAGE_ID_LENGTH).split(":")[0]in r;function ke(e){const{id:n,type:t}=e,o=t in Ne;return o&&u(n,"Ignoring init message from meta parent page"),o}function De(e){try{r[e].sameOrigin=!!r[e]?.iframe?.contentWindow?.iframeChildListener}catch{r[e].sameOrigin=!1}u(e,`sameOrigin: %c${r[e].sameOrigin}`,s.HIGHLIGHT)}function _e(e,n){if(n!==i.VERSION){if(n===void 0){b(e,`<rb>Legacy version detected in iframe</>
1
+ (function(p,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@iframe-resizer/common"),require("auto-console-group")):typeof define=="function"&&define.amd?define(["exports","@iframe-resizer/common","auto-console-group"],i):(p=typeof globalThis<"u"?globalThis:p||self,i(p.connectResizer={},p.common,p.acg))})(this,(function(p,i,a){"use strict";const r={},v=i.esModuleInterop(a);let y=!0;const se=v({expand:!1,label:i.PARENT}),oe=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`,ae=e=>r[e]?r[e].log:y;function ce({enabled:e,expand:t,iframeId:n}){const s=v({expand:t,label:oe(n)});y=e,r[n]||(r[n]={console:s})}const L=e=>(t,...n)=>r[t]?r[t].console[e](...n):se[e](...n),k=e=>(t,...n)=>ae(t)===!0?L(e)(t,...n):null,l=k("log"),O=l,fe=k("debug"),w=L("warn"),le=L("error"),T=L("event"),ue=L("purge"),de=L("endAutoGroup"),D=L("errorBoundary");function ge(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,y||t<1?i.BOLD:a.NORMAL))}const he=e=>(...t)=>[`${i.LABEL}(${e})`,...t].join(" "),Ee=i.createFormatAdvise(i.id),b=(e,...t)=>r[e]?r[e].console.warn(...t.map(Ee)):queueMicrotask(()=>{const n=i.createFormatAdvise(he(e));console?.warn(...t.map(n))}),N=i.deprecate(b);N("Function"),N("Method"),N("Option");const G=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:i.VERTICAL,firstRun:!0,inPageLinks:!1,heightCalculationMethod:i.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:i.AUTO,onBeforeClose:()=>!0,onAfterClose(){},onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let _=0;function Ie(e){const t=e?.id||G.id+_++;return document.getElementById(t)===null?t:`${t}${_++}`}function pe(e,t){let{id:n}=e;if(n&&!i.isString(n))throw new TypeError("Invalid id for iframe. Expected String");return(!n||n==="")&&(n=Ie(t),e.id=n,T(n,"assignId"),l(n,`Added missing iframe ID: ${n} (${e.src})`)),n}function Oe(e){const{search:t}=window.location;if(t.includes("ifrlog"))switch(new URLSearchParams(t).get("ifrlog")){case String(i.LOG_DISABLED):{e.log=!1;break}case i.EXPAND:case String(i.LOG_EXPANDED):{e.log=i.EXPAND;break}case i.COLLAPSE:case String(i.LOG_COLLAPSED):{e.log=i.COLLAPSE;break}default:e.log=i.COLLAPSE}}const be=e=>e.split(i.SEPARATOR).filter((t,n)=>n!==19).join(i.SEPARATOR);function Te(e,t,n){function s(d){const g=e in i.INIT_EVENTS?be(t):t;O(n,d,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),O(n,`Message data: %c${g}`,a.HIGHLIGHT)}const{iframe:o,postMessageTarget:u,sameOrigin:c,targetOrigin:f}=r[n];if(c)try{o.contentWindow.iframeChildListener(i.MESSAGE_ID+t),s(`Sending message to iframe %c${n}%c via same origin%c`);return}catch{e in i.INIT_EVENTS?(r[n].sameOrigin=!1,l(n,"New iframe does not support same origin")):w(n,"Same origin messaging failed, falling back to postMessage")}s(`Sending message to iframe: %c${n}%c targetOrigin: %c${f.join(", ")}`);for(const d of f)u.postMessage(i.MESSAGE_ID+t,d)}function A(e,t,n){if(T(n,e),!r[n]?.postMessageTarget){w(n,"Iframe not found");return}Te(e,t,n)}const we=(e,t)=>Object.values(r).filter(({autoResize:n,firstRun:s})=>n&&!s).forEach(({iframe:n})=>A(e,t,n.id));function Le(){document.hidden!==!0&&we("tabVisible",i.RESIZE)}function He(e){if(e.boxSizing!=="border-box")return 0;const t=e.paddingTop?parseInt(e.paddingTop,10):0,n=e.paddingBottom?parseInt(e.paddingBottom,10):0;return t+n}function Se(e){if(e.boxSizing!=="border-box")return 0;const t=e.borderTopWidth?parseInt(e.borderTopWidth,10):0,n=e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0;return t+n}function Ae(e){const t=e.slice(i.MESSAGE_ID_LENGTH).split(":"),n=t[1]?Number(t[1]):0,s=r[t[0]]?.iframe,o=s?getComputedStyle(s):null,u=o?He(o)+Se(o):0,c={iframe:s,id:t[0],height:n+u,width:Number(t[2]),type:t[3],msg:t[4],message:t[4]};return t[5]&&(c.mode=t[5]),c}const Re={true:1,false:1,undefined:1};function Ge(e){const{id:t,msg:n,iframe:s}=e,o=i.isIframe(s);return o||(l(t,`Received: %c${n}`,a.HIGHLIGHT),w(t,"The target iframe was not found.")),o}function Me(e,t){const{id:n}=e,{data:s,origin:o}=t;if("sameOrigin"in t&&t.sameOrigin)return!0;const c=r[n]?.checkOrigin;function f(){function d(){l(n,`Checking connection is from allowed list of origins: %c${c}`,a.HIGHLIGHT);for(const h of c)if(h===o)return!0;return!1}function g(){const h=r[n]?.remoteHost;return l(n,`Checking connection is from: %c${h}`,a.HIGHLIGHT),o===h}return c.constructor===Array?d():g()}if(c&&`${o}`!="null"&&!f())throw new Error(`Unexpected message received from: ${o} for ${n}. Message was: ${s}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}const ye=e=>i.MESSAGE_ID===`${e}`.slice(0,i.MESSAGE_ID_LENGTH)&&e.slice(i.MESSAGE_ID_LENGTH).split(":")[0]in r;function Ne(e){const{id:t,type:n}=e,s=n in Re;return s&&l(t,"Ignoring init message from meta parent page"),s}function Pe(e){try{r[e].sameOrigin=!!r[e]?.iframe?.contentWindow?.iframeChildListener}catch{r[e].sameOrigin=!1}l(e,`sameOrigin: %c${r[e].sameOrigin}`,a.HIGHLIGHT)}function $e(e,t){if(t!==i.VERSION){if(t===void 0){b(e,`<rb>Legacy version detected in iframe</>
2
2
 
3
3
  Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
4
4
 
5
5
  See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
6
- `);return}u(e,`Version mismatch (Child: %c${n}%c !== Parent: %c${i.VERSION})`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT)}}function R(e,n,t){if(!r[e])return null;const o=r[e][n];if(typeof o!==i.FUNCTION)throw new TypeError(`${n} on iframe[${e}] is not a function`);if(n!=="onBeforeClose"&&n!=="onScroll")return p.isolateUserCode(o,t);try{return o(t)}catch(a){return console.error(a),L(e,`Error in ${n} callback`),null}}function ze(e,n){const{id:t,iframe:o}=e;u(t,`onMessage passed: {iframe: %c${t}%c, message: %c${n}%c}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND),R(t,"onMessage",{iframe:o,message:JSON.parse(n)})}function N(e,n){const{lastMessage:t}=r[e];return t.slice(t.indexOf(i.SEPARATOR)+i.MESSAGE_HEADER_LENGTH+n)}function B(e,n){const{id:t,iframe:o,height:a,type:l,width:c}=n;let f={x:0,y:0};if(c===0&&a===0){const d=N(t,9).split(i.SEPARATOR);f={x:d[1],y:d[0]}}else f={x:c,y:a};R(t,e,{iframe:o,screenX:Number(f.x),screenY:Number(f.y),type:l})}const E={position:null,version:i.VERSION};function x(){E.position=null}const Ce=()=>E.position;function Fe(e){E.position=e}function W(e){return E.position===null&&(E.position={x:window.scrollX,y:window.scrollY}),u(e,`Get page position: %c${E.position.x}%c, %c${E.position.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),E.position}function U(e){E.position!==null&&(window.scrollTo(E.position.x,E.position.y),O(e,`Set page position: %c${E.position.x}%c, %c${E.position.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),x())}function V(e,n){const{id:t}=n,o=`${n[e]}px`;r[t].iframe.style[e]=o,O(t,`Set ${e}: %c${o}`,s.HIGHLIGHT)}function j(e){const{id:n}=e,{sizeHeight:t,sizeWidth:o}=r[n];t&&V(i.HEIGHT,e),o&&V(i.WIDTH,e)}function q(e){const{id:n}=e;j(e),U(n),R(n,"onResized",e)}function X(e){const{id:n}=e;u(n,"Disconnected from iframe"),delete r[n],delete e.iframeResizer}function Z(e){const{id:n}=e;if(R(n,"onBeforeClose",n)===!1){u(n,"Close iframe cancelled by onBeforeClose");return}u(n,`Removing iframe: %c${n}`,s.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(t){L(n,t)}R(n,"onAfterClose",n),X(e)}function Y(e){const{id:n,type:t}=e;u(n,`Size reset requested by ${t===i.INIT?"parent page":"child page"}`),W(n),j(e),G(i.RESET,i.RESET,n)}const J=(e,n)=>{const t={};return(o,a)=>{const{iframe:l}=r[a];function c(d,g){t[g]||(d(),t[g]=requestAnimationFrame(()=>{t[g]=null}))}function f(){G(`${o} (${e})`,`${e}:${n(l)}`,a)}c(f,a)}},K=e=>n=>{e in r[n]&&(r[n][e](),delete r[n][e])},Q=((e,n)=>t=>{let o=!1;const a=I=>()=>{r[t]?(!o||o===I)&&(e(I,t),o=I,requestAnimationFrame(()=>{o=!1})):h()},l=a(i.SCROLL),c=a("resize window"),f=new ResizeObserver(a("pageObserver")),d=new ResizeObserver(a("iframeObserver"));function g(I,A){u(t,`${I}listeners for send${n}`),A(window,i.SCROLL,l),A(window,i.RESIZE,c)}function h(){w(t,`stop${n}`),g("Remove ",H.removeEventListener),f.disconnect(),d.disconnect(),r[t]&&H.removeEventListener(r[t].iframe,i.LOAD,h)}function M(){g("Add ",H.addEventListener),f.observe(document.body),d.observe(r[t].iframe)}r[t]&&(r[t][`stop${n}`]=h,H.addEventListener(r[t].iframe,i.LOAD,h),M())});function Be(e){const n=document.body.getBoundingClientRect(),t=e.getBoundingClientRect(),{scrollY:o,scrollX:a,innerHeight:l,innerWidth:c}=window,{clientHeight:f,clientWidth:d}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(f,l||0),clientWidth:Math.max(d,c||0),offsetTop:Math.trunc(t.top-n.top),offsetLeft:Math.trunc(t.left-n.left),scrollTop:o,scrollLeft:a,documentHeight:f,documentWidth:d,windowHeight:l,windowWidth:c})}const xe=J(i.PAGE_INFO,Be),We=Q(xe,"PageInfo"),Ue=K("stopPageInfo");function Ve(e){const{scrollWidth:n,scrollHeight:t}=document.documentElement,o=typeof window<"u"&&window.visualViewport?window.visualViewport:{},{width:a=0,height:l=0,offsetLeft:c=0,offsetTop:f=0,pageLeft:d=0,pageTop:g=0,scale:h=1}=o;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:t},viewport:{width:a,height:l,offsetLeft:c,offsetTop:f,pageLeft:d,pageTop:g,scale:h}})}const je=J(i.PARENT_INFO,Ve),qe=Q(je,"ParentInfo"),Xe=K("stopParentInfo");function ee(e){const n=e.getBoundingClientRect(),t=W(e.id);return{x:Number(n.left)+Number(t.x),y:Number(n.top)+Number(t.y)}}function ne(e){const{x:n,y:t}=Ce(),o=r[e]?.iframe;if(R(e,"onScroll",{iframe:o,top:t,left:n,x:n,y:t})===!1){x();return}U(e)}function Ze(e){const{id:n,height:t,width:o}=e,a=window.parentIframe||window.parentIFrame||window;O(n,`scrollBy: x: %c${o}%c y: %c${t}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),a.scrollBy(o,t)}const te=e=>n=>{const{id:t,iframe:o,height:a,width:l}=n;function c(I){Fe(I),ne(t)}function f(I,A){I[`scrollTo${e?"Offset":""}`](A.x,A.y)}const d=I=>({x:l+I.x,y:a+I.y}),g=e?ee(o):{x:0,y:0},h=d(g),M=window.parentIframe||window.parentIFrame;O(t,`Reposition requested (offset x:%c${g.x}%c y:%c${g.y})`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),M?f(M,h):c(h)},Ye=te(!1),Je=te(!0);function Ke(e,n,t){const{x:o,y:a}=ee(t);O(e,`Moving to in page link: %c#${n}`,s.HIGHLIGHT),E.position={x:o,y:a},ne(e),window.location.hash=n}function Qe(e,n){const t=window.parentIframe||window.parentIFrame;if(!t){u(e,`In page link #${n} not found`);return}t.moveToAnchor(n)}function en(e,n){const t=n.split("#")[1]||"",o=decodeURIComponent(t),a=document.getElementById(o)||document.getElementsByName(o)[0];if(a){Ke(e,t,a);return}if(window.top===window.self){u(e,`In page link #${t} not found`);return}Qe(e,t)}function nn(e){const n=r[e]?.iframe?.title;return n===""||n===void 0}function tn(e,n){r[e]?.syncTitle&&(r[e].iframe.title=n,O(e,`Set iframe title attribute: %c${n}`,s.HIGHLIGHT))}let v=!1,ie=!1;function re(e,n=-3){if(v)return;const t=Math.max(r[e].mode,n);if(t>r[e].mode&&(r[e].mode=t),t<0)throw Ee(e),r[e].vAdvised||b(e||"Parent",`${T.getModeData(t+2)}${T.getModeData(2)}`),r[e].vAdvised=!0,T.getModeData(t+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(t>5&&ie||Ie(`v${i.VERSION} (${T.getModeLabel(t)})`,t),t){case 1:case 2:case 3:b("Parent",T.getModeData(6));break;case 4:b("Parent",T.getModeData(7));break;case 5:b("Parent",T.getModeData(8));break;default:t<1&&b("Parent",T.getModeData(3))}v=!0}function rn(e){if(v)return;const{mode:n}=r[e];n>5&&re(e,n)}function on(e){e?.log===-1&&(e.log=!1,ie=!0)}function an(e,n){r[e]&&(u(e,`First run for ${e}`),re(e,n===void 0?void 0:Number(n)),r[e].firstRun=!1)}function sn(e){const{height:n,id:t,iframe:o,mode:a,message:l,type:c,width:f}=e,{lastMessage:d}=r[t];switch(r[t]?.firstRun&&an(t,a),u(t,`Received: %c${d}`,s.HIGHLIGHT),c){case i.AUTO_RESIZE:r[t].autoResize=JSON.parse(N(t,9));break;case i.BEFORE_UNLOAD:O(t,"Ready state reset"),r[t].initialised=!1;break;case i.CLOSE:Z(o);break;case i.IN_PAGE_LINK:en(t,N(t,9));break;case i.INIT:q(e),De(t),_e(t,l),r[t].initialised=!0,R(t,"onReady",o);break;case i.MESSAGE:ze(e,N(t,6));break;case i.MOUSE_ENTER:B("onMouseEnter",e);break;case i.MOUSE_LEAVE:B("onMouseLeave",e);break;case i.PAGE_INFO:We(t);break;case i.PARENT_INFO:qe(t);break;case i.PAGE_INFO_STOP:Ue(t);break;case i.PARENT_INFO_STOP:Xe(t);break;case i.RESET:Y(e);break;case i.SCROLL_BY:Ze(e);break;case i.SCROLL_TO:Ye(e);break;case i.SCROLL_TO_OFFSET:Je(e);break;case i.TITLE:tn(t,l);break;default:if(f===0&&n===0){L(t,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);return}if(f===0||n===0){u(t,"Ignoring message with 0 height or width");return}if(document.hidden){u(t,"Page hidden - ignored resize request");return}q(e)}}const cn=e=>({initChild:n,postMessageTarget:t})=>{e===t&&n()},fn=e=>Object.values(r).forEach(cn(e));function oe(e){const n=e.data;if(n===i.CHILD_READY_MESSAGE){fn(e.source);return}if(!ve(n)){if(typeof n!==i.STRING)return;w(i.PARENT,"ignoredMessage"),me(i.PARENT,n);return}const t=ye(n),{id:o,type:a}=t;switch(w(o,a),!0){case!r[o]:throw new Error(`${a} No settings for ${o}. Message was: ${n}`);case!Pe(t):case ke(t):case!$e(t,e):return;default:r[o].lastMessage=e.data,C(o,sn)(t)}}const un=p.once(()=>{H.addEventListener(window,i.MESSAGE,oe),H.addEventListener(document,"visibilitychange",Ae),window.iframeParentListener=e=>setTimeout(()=>oe({data:e,sameOrigin:!0}))}),ae={};function ln(e){if(ae[e]===!0)return!1;const n=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(n.length<=1)return!0;ae[e]=!0;const t=Array.from(n).flatMap(o=>[i.NEW_LINE,o,i.NEW_LINE]);return b(e,`<rb>Duplicate ID attributes detected</>
6
+ `);return}l(e,`Version mismatch (Child: %c${t}%c !== Parent: %c${i.VERSION})`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT)}}function H(e,t,n){if(!r[e])return null;const s=r[e][t];if(typeof s!==i.FUNCTION)throw new TypeError(`${t} on iframe[${e}] is not a function`);if(t!=="onBeforeClose"&&t!=="onScroll")return i.isolateUserCode(s,n);try{return s(n)}catch(o){return console.error(o),w(e,`Error in ${t} callback`),null}}function ve(e,t){const{id:n,iframe:s}=e;l(n,`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT,a.FOREGROUND),H(n,"onMessage",{iframe:s,message:JSON.parse(t)})}function M(e,t){const{lastMessage:n}=r[e];return n.slice(n.indexOf(i.SEPARATOR)+i.MESSAGE_HEADER_LENGTH+t)}function C(e,t){const{id:n,iframe:s,height:o,type:u,width:c}=t;let f={x:0,y:0};if(c===0&&o===0){const d=M(n,9).split(i.SEPARATOR);f={x:d[1],y:d[0]}}else f={x:c,y:o};H(n,e,{iframe:s,screenX:Number(f.x),screenY:Number(f.y),type:u})}const E={position:null,version:i.VERSION};function z(){E.position=null}const ke=()=>E.position;function De(e){E.position=e}function F(e){return E.position===null&&(E.position={x:window.scrollX,y:window.scrollY}),l(e,`Get page position: %c${E.position.x}%c, %c${E.position.y}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),E.position}function B(e){E.position!==null&&(window.scrollTo(E.position.x,E.position.y),O(e,`Set page position: %c${E.position.x}%c, %c${E.position.y}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),z())}function x(e,t){const{id:n}=t,s=`${t[e]}px`;r[n].iframe.style[e]=s,O(n,`Set ${e}: %c${s}`,a.HIGHLIGHT)}function W(e){const{id:t}=e,{sizeHeight:n,sizeWidth:s}=r[t];n&&x(i.HEIGHT,e),s&&x(i.WIDTH,e)}function U(e){const{id:t}=e;W(e),B(t),H(t,"onResized",e)}function V(e){const{id:t}=e;l(t,"Disconnected from iframe"),delete r[t],delete e.iframeResizer}function j(e){const{id:t}=e;if(H(t,"onBeforeClose",t)===!1){l(t,"Close iframe cancelled by onBeforeClose");return}l(t,`Removing iframe: %c${t}`,a.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(n){w(t,n)}H(t,"onAfterClose",t),V(e)}function X(e){const{id:t,type:n}=e;l(t,`Size reset requested by ${n===i.INIT?"parent page":"child page"}`),F(t),W(e),A(i.RESET,i.RESET,t)}const q=(e,t)=>{const n={};return(s,o)=>{const{iframe:u}=r[o];function c(d,g){n[g]||(d(),n[g]=requestAnimationFrame(()=>{n[g]=null}))}function f(){A(`${s} (${e})`,`${e}:${t(u)}`,o)}c(f,o)}},Z=e=>t=>{e in r[t]&&(r[t][e](),delete r[t][e])},Y=((e,t)=>n=>{let s=!1;const o=I=>()=>{r[n]?(!s||s===I)&&(e(I,n),s=I,requestAnimationFrame(()=>{s=!1})):h()},u=o(i.SCROLL),c=o("resize window"),f=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));function g(I,S){l(n,`${I}listeners for send${t}`),S(window,i.SCROLL,u),S(window,i.RESIZE,c)}function h(){T(n,`stop${t}`),g("Remove ",i.removeEventListener),f.disconnect(),d.disconnect(),r[n]&&i.removeEventListener(r[n].iframe,i.LOAD,h)}function R(){g("Add ",i.addEventListener),f.observe(document.body),d.observe(r[n].iframe)}r[n]&&(r[n][`stop${t}`]=h,i.addEventListener(r[n].iframe,i.LOAD,h),R())});function _e(e){const t=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),{scrollY:s,scrollX:o,innerHeight:u,innerWidth:c}=window,{clientHeight:f,clientWidth:d}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(f,u||0),clientWidth:Math.max(d,c||0),offsetTop:Math.trunc(n.top-t.top),offsetLeft:Math.trunc(n.left-t.left),scrollTop:s,scrollLeft:o,documentHeight:f,documentWidth:d,windowHeight:u,windowWidth:c})}const Ce=q(i.PAGE_INFO,_e),ze=Y(Ce,"PageInfo"),Fe=Z("stopPageInfo");function Be(e){const{scrollWidth:t,scrollHeight:n}=document.documentElement,s=typeof window<"u"&&window.visualViewport?window.visualViewport:{},{width:o=0,height:u=0,offsetLeft:c=0,offsetTop:f=0,pageLeft:d=0,pageTop:g=0,scale:h=1}=s;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:u,offsetLeft:c,offsetTop:f,pageLeft:d,pageTop:g,scale:h}})}const xe=q(i.PARENT_INFO,Be),We=Y(xe,"ParentInfo"),Ue=Z("stopParentInfo");function J(e){const t=e.getBoundingClientRect(),n=F(e.id);return{x:Number(t.left)+Number(n.x),y:Number(t.top)+Number(n.y)}}function K(e){const{x:t,y:n}=ke(),s=r[e]?.iframe;if(H(e,"onScroll",{iframe:s,top:n,left:t,x:t,y:n})===!1){z();return}B(e)}function Ve(e){const{id:t,height:n,width:s}=e,o=window.parentIframe||window.parentIFrame||window;O(t,`scrollBy: x: %c${s}%c y: %c${n}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),o.scrollBy(s,n)}const Q=e=>t=>{const{id:n,iframe:s,height:o,width:u}=t;function c(I){De(I),K(n)}function f(I,S){I[`scrollTo${e?"Offset":""}`](S.x,S.y)}const d=I=>({x:u+I.x,y:o+I.y}),g=e?J(s):{x:0,y:0},h=d(g),R=window.parentIframe||window.parentIFrame;O(n,`Reposition requested (offset x:%c${g.x}%c y:%c${g.y})`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),R?f(R,h):c(h)},je=Q(!1),Xe=Q(!0);function qe(e,t,n){const{x:s,y:o}=J(n);O(e,`Moving to in page link: %c#${t}`,a.HIGHLIGHT),E.position={x:s,y:o},K(e),window.location.hash=t}function Ze(e,t){const n=window.parentIframe||window.parentIFrame;if(!n){l(e,`In page link #${t} not found`);return}n.moveToAnchor(t)}function Ye(e,t){const n=t.split("#")[1]||"",s=decodeURIComponent(n),o=document.getElementById(s)||document.getElementsByName(s)[0];if(o){qe(e,n,o);return}if(window.top===window.self){l(e,`In page link #${n} not found`);return}Ze(e,n)}function Je(e){const t=r[e]?.iframe?.title;return t===""||t===void 0}function Ke(e,t){r[e]?.syncTitle&&(r[e].iframe.title=t,O(e,`Set iframe title attribute: %c${t}`,a.HIGHLIGHT))}let P=!1,m=!1;function ee(e,t=-3){if(P)return;const n=Math.max(r[e].mode,t);if(n>r[e].mode&&(r[e].mode=n),n<0)throw ue(e),r[e].vAdvised||b(e||"Parent",`${i.getModeData(n+2)}${i.getModeData(2)}`),r[e].vAdvised=!0,i.getModeData(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(n>5&&m||ge(`v${i.VERSION} (${i.getModeLabel(n)})`,n),n){case 1:case 2:case 3:b("Parent",i.getModeData(6));break;case 4:b("Parent",i.getModeData(7));break;case 5:b("Parent",i.getModeData(8));break;default:n<1&&b("Parent",i.getModeData(3))}P=!0}function Qe(e){if(P)return;const{mode:t}=r[e];t>5&&ee(e,t)}function me(e){e?.log===-1&&(e.log=!1,m=!0)}function et(e,t){r[e]&&(l(e,`First run for ${e}`),ee(e,t===void 0?void 0:Number(t)),r[e].firstRun=!1)}function tt(e){const{height:t,id:n,iframe:s,mode:o,message:u,type:c,width:f}=e,{lastMessage:d}=r[n];switch(r[n]?.firstRun&&et(n,o),l(n,`Received: %c${d}`,a.HIGHLIGHT),c){case i.AUTO_RESIZE:r[n].autoResize=JSON.parse(M(n,9));break;case i.BEFORE_UNLOAD:O(n,"Ready state reset"),r[n].initialised=!1;break;case i.CLOSE:j(s);break;case i.IN_PAGE_LINK:Ye(n,M(n,9));break;case i.INIT:U(e),Pe(n),$e(n,u),r[n].initialised=!0,H(n,"onReady",s);break;case i.MESSAGE:ve(e,M(n,6));break;case i.MOUSE_ENTER:C("onMouseEnter",e);break;case i.MOUSE_LEAVE:C("onMouseLeave",e);break;case i.PAGE_INFO:ze(n);break;case i.PARENT_INFO:We(n);break;case i.PAGE_INFO_STOP:Fe(n);break;case i.PARENT_INFO_STOP:Ue(n);break;case i.RESET:X(e);break;case i.SCROLL_BY:Ve(e);break;case i.SCROLL_TO:je(e);break;case i.SCROLL_TO_OFFSET:Xe(e);break;case i.TITLE:Ke(n,u);break;default:if(f===0&&t===0){w(n,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);return}if(f===0||t===0){l(n,"Ignoring message with 0 height or width");return}if(document.hidden){l(n,"Page hidden - ignored resize request");return}U(e)}}const nt=e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()},it=e=>Object.values(r).forEach(nt(e));function te(e){const t=e.data;if(t===i.CHILD_READY_MESSAGE){it(e.source);return}if(!ye(t)){if(typeof t!==i.STRING)return;T(i.PARENT,"ignoredMessage"),fe(i.PARENT,t);return}const n=Ae(t),{id:s,type:o}=n;switch(T(s,o),!0){case!r[s]:throw new Error(`${o} No settings for ${s}. Message was: ${t}`);case!Ge(n):case Ne(n):case!Me(n,e):return;default:r[s].lastMessage=e.data,D(s,tt)(n)}}const rt=i.once(()=>{i.addEventListener(window,i.MESSAGE,te),i.addEventListener(document,"visibilitychange",Le),window.iframeParentListener=e=>setTimeout(()=>te({data:e,sameOrigin:!0}))}),ne={};function st(e){if(ne[e]===!0)return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;ne[e]=!0;const n=Array.from(t).flatMap(s=>[i.NEW_LINE,s,i.NEW_LINE]);return b(e,`<rb>Duplicate ID attributes detected</>
7
7
 
8
8
  The <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.
9
9
 
10
- Found <bb>${n.length}</> iframes with the <b>${e}</> ID:`,...t,i.NEW_LINE),!1}function dn(e){if(r[e]){const{iframe:n}=r[e];n.iframeResizer={close:Z.bind(null,n),disconnect:X.bind(null,n),moveToAnchor(t){p.typeAssert(t,i.STRING,"moveToAnchor(anchor) anchor"),G("Move to anchor",`moveToAnchor:${t}`,e)},sendMessage(t){t=JSON.stringify(t),G(i.MESSAGE,`${i.MESSAGE}:${t}`,e)}}}}const gn="8",mn="32",hn=i.CHILD,En=!0;function pn(e){const{autoResize:n,bodyBackground:t,bodyMargin:o,bodyPadding:a,heightCalculationMethod:l,inPageLinks:c,license:f,log:d,logExpand:g,mouseEvents:h,offsetHeight:M,offsetWidth:I,mode:A,sizeHeight:qn,sizeWidth:Xn,tolerance:Zn,widthCalculationMethod:Yn}=r[e];return[e,gn,Xn,d,mn,En,n,o,l,t,a,Zn,c,hn,Yn,h,M,I,qn,f,E.version,A,"",g].join(i.SEPARATOR)}const In="0";function On(e){const{bodyMargin:n}=r[e];(typeof n===i.NUMBER||n===In)&&(r[e].bodyMargin=`${n}px`)}const bn=e=>{try{return new URL(e).origin}catch{return null}},Tn=e=>typeof e===i.OBJECT&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin"));function wn(e,n){const{checkOrigin:t,iframe:{src:o,sandbox:a},initialisedFirstPage:l,waitForLoad:c}=n[e],f=bn(o);w(e,"noResponse"),b(e,`<rb>No response from iframe</>
10
+ Found <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...n,i.NEW_LINE),!1}function ot(e){if(r[e]){const{iframe:t}=r[e];t.iframeResizer={close:j.bind(null,t),disconnect:V.bind(null,t),moveToAnchor(n){i.typeAssert(n,i.STRING,"moveToAnchor(anchor) anchor"),A("Move to anchor",`moveToAnchor:${n}`,e)},sendMessage(n){n=JSON.stringify(n),A(i.MESSAGE,`${i.MESSAGE}:${n}`,e)}}}}const at="8",ct="32",ft=i.CHILD,lt=!0;function ut(e){const{autoResize:t,bodyBackground:n,bodyMargin:s,bodyPadding:o,heightCalculationMethod:u,inPageLinks:c,license:f,log:d,logExpand:g,mouseEvents:h,offsetHeight:R,offsetWidth:I,mode:S,sizeHeight:xt,sizeWidth:Wt,tolerance:Ut,widthCalculationMethod:Vt}=r[e];return[e,at,Wt,d,ct,lt,t,s,u,n,o,Ut,c,ft,Vt,h,R,I,xt,f,E.version,S,"",g].join(i.SEPARATOR)}const dt="0";function gt(e){const{bodyMargin:t}=r[e];(typeof t===i.NUMBER||t===dt)&&(r[e].bodyMargin=`${t}px`)}const ht=e=>{try{return new URL(e).origin}catch{return null}},Et=e=>typeof e===i.OBJECT&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin"));function It(e,t){const{checkOrigin:n,iframe:{src:s,sandbox:o},initialisedFirstPage:u,waitForLoad:c}=t[e],f=ht(s);T(e,"noResponse"),b(e,`<rb>No response from iframe</>
11
11
 
12
- The iframe (<i>${e}</>) has not responded within ${n[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
13
- ${t&&f?`
12
+ The iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
13
+ ${n&&f?`
14
14
  The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${f}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.
15
- `:""}${c&&!l?`
15
+ `:""}${c&&!u?`
16
16
  The <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.
17
- `:""}${Tn(a)?`
17
+ `:""}${Et(o)?`
18
18
  The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
19
19
  `:""}
20
20
  This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
21
- `)}function Ln(e,n){function t(){if(n[e]===void 0)return;const{initialised:l,loadErrorShown:c}=n[e];if(n[e].msgTimeout=void 0,l){n[e].initialisedFirstPage=!0;return}c||(n[e].loadErrorShown=!0,wn(e,n))}const{msgTimeout:o,warningTimeout:a}=n[e];a&&(o&&clearTimeout(o),n[e].msgTimeout=setTimeout(t,a))}const Hn=1,Sn=e=>e.loading===i.LAZY,Rn=e=>e===i.INIT;function An(e){r[e]?.heightCalculationMethod in i.RESET_REQUIRED_METHODS&&Y({id:e,iframe:r[e].iframe,height:i.MIN_SIZE,width:i.MIN_SIZE,type:i.INIT})}function Gn(e,n){const t=()=>setTimeout(n,Hn);H.addEventListener(e,i.LOAD,t)}const Mn=e=>{const{src:n,srcdoc:t}=e;return!t&&(n==null||n===""||n==="about:blank")};function yn(e,n){const{iframe:t,waitForLoad:o}=r[e];if(o!==!0){if(Mn(t)){setTimeout(()=>{w(e,"noContent"),O(e,"No content detected in the iframe, delaying initialisation")});return}setTimeout(n)}}function Nn(e,n){const t=a=>()=>{if(!r[e])return;const{firstRun:l,iframe:c}=r[e];G(a,n,e),Rn(a)&&Sn(c)||Ln(e,r),l||An(e)},{iframe:o}=r[e];r[e].initChild=t(i.INIT_FROM_IFRAME),Gn(o,t(i.ONLOAD)),yn(e,t(i.INIT))}function Pn(e,n){return n?(("sizeWidth"in n||"sizeHeight"in n||i.AUTO_RESIZE in n)&&b(e,`<rb>Deprecated Option</>
21
+ `)}function pt(e,t){function n(){if(t[e]===void 0)return;const{initialised:u,loadErrorShown:c}=t[e];if(t[e].msgTimeout=void 0,u){t[e].initialisedFirstPage=!0;return}c||(t[e].loadErrorShown=!0,It(e,t))}const{msgTimeout:s,warningTimeout:o}=t[e];o&&(s&&clearTimeout(s),t[e].msgTimeout=setTimeout(n,o))}const Ot=1,bt=e=>e.loading===i.LAZY,Tt=e=>e===i.INIT;function wt(e){r[e]?.heightCalculationMethod in i.RESET_REQUIRED_METHODS&&X({id:e,iframe:r[e].iframe,height:i.MIN_SIZE,width:i.MIN_SIZE,type:i.INIT})}function Lt(e,t){const n=()=>setTimeout(t,Ot);i.addEventListener(e,i.LOAD,n)}const Ht=e=>{const{src:t,srcdoc:n}=e;return!n&&(t==null||t===""||t==="about:blank")};function St(e,t){const{iframe:n,waitForLoad:s}=r[e];if(s!==!0){if(Ht(n)){setTimeout(()=>{T(e,"noContent"),O(e,"No content detected in the iframe, delaying initialisation")});return}setTimeout(t)}}function At(e,t){const n=o=>()=>{if(!r[e])return;const{firstRun:u,iframe:c}=r[e];A(o,t,e),Tt(o)&&bt(c)||pt(e,r),u||wt(e)},{iframe:s}=r[e];r[e].initChild=n(i.INIT_FROM_IFRAME),Lt(s,n(i.ONLOAD)),St(e,n(i.INIT))}function Rt(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||i.AUTO_RESIZE in t)&&b(e,`<rb>Deprecated Option</>
22
22
 
23
23
  The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${i.VERTICAL}</>, <bb>${i.HORIZONTAL}</>, <bb>${i.BOTH}</> or <bb>${i.NONE}</>.
24
- `),n):{}}function $n(e){r[e].warningTimeout||O(e,"warningTimeout:%c disabled",s.HIGHLIGHT)}function vn(e,{offset:n,offsetSize:t}){const o=t||n;o&&(r[e].direction===i.VERTICAL?(r[e].offsetHeight=o,u(e,`Offset height: %c${o}`,s.HIGHLIGHT)):(r[e].offsetWidth=o,u(e,`Offset width: %c${o}`,s.HIGHLIGHT)))}function kn(e){const{direction:n}=r[e];switch(n){case i.VERTICAL:break;case i.HORIZONTAL:r[e].sizeHeight=!1;case i.BOTH:r[e].sizeWidth=!0;break;case i.NONE:r[e].sizeWidth=!1,r[e].sizeHeight=!1,r[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${n}" is not valid`)}u(e,`direction: %c${n}`,s.HIGHLIGHT)}const se=e=>e===""||e.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":e;function Dn(e){const{checkOrigin:n,remoteHost:t}=r[e];Array.isArray(n)&&n.length===0&&L(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),r[e].targetOrigin=Array.isArray(n)?n.map(se):[n===!1?"*":se(t)]}function _n(e){const{id:n}=e;r[n].postMessageTarget===null&&(r[n].postMessageTarget=e.contentWindow)}function k(e,n,t){p.hasOwn(r[e],n)&&(b(e,`<rb>Deprecated option</>
24
+ `),t):{}}function Gt(e){r[e].warningTimeout||O(e,"warningTimeout:%c disabled",a.HIGHLIGHT)}function Mt(e,{offset:t,offsetSize:n}){const s=n||t;s&&(r[e].direction===i.VERTICAL?(r[e].offsetHeight=s,l(e,`Offset height: %c${s}`,a.HIGHLIGHT)):(r[e].offsetWidth=s,l(e,`Offset width: %c${s}`,a.HIGHLIGHT)))}function yt(e){const{direction:t}=r[e];switch(t){case i.VERTICAL:break;case i.HORIZONTAL:r[e].sizeHeight=!1;case i.BOTH:r[e].sizeWidth=!0;break;case i.NONE:r[e].sizeWidth=!1,r[e].sizeHeight=!1,r[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${t}" is not valid`)}l(e,`direction: %c${t}`,a.HIGHLIGHT)}const ie=e=>e===""||e.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":e;function Nt(e){const{checkOrigin:t,remoteHost:n}=r[e];Array.isArray(t)&&t.length===0&&w(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),r[e].targetOrigin=Array.isArray(t)?t.map(ie):[t===!1?"*":ie(n)]}function Pt(e){const{id:t}=e;r[t].postMessageTarget===null&&(r[t].postMessageTarget=e.contentWindow)}function $(e,t,n){i.hasOwn(r[e],t)&&(b(e,`<rb>Deprecated option</>
25
25
 
26
- The <b>${n}</> option has been renamed to <b>${t}</>. ${i.REMOVED_NEXT_VERSION}`),r[e][t]=r[e][n],delete r[e][n])}function zn(e){k(e,i.OFFSET,i.OFFSET_SIZE),k(e,"onClose","onBeforeClose"),k(e,"onClosed","onAfterClose")}const Cn=e=>p.hasOwn(e,"onMouseEnter")||p.hasOwn(e,"onMouseLeave");function Fn(e,n){const{id:t}=e;r[t]={...r[t],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...y,...Pn(t,n),mouseEvents:Cn(n),mode:T(n),syncTitle:nn(t)},zn(t),kn(t),vn(t,n),$n(t),_n(e),Dn(t)}const Bn="yes",ce="no";function xn(e){const{id:n}=e;switch(u(n,`Iframe scrolling ${r[n]?.scrolling?"enabled":"disabled"} for ${n}`),e.style.overflow=r[n]?.scrolling===!1?i.HIDDEN:i.AUTO,r[n]?.scrolling){case i.OMIT:break;case!0:e.scrolling=Bn;break;case!1:e.scrolling=ce;break;default:e.scrolling=r[n]?.scrolling||ce}}function Wn(e,n,t){Fn(n,t),u(e,`src: %c${n.srcdoc||n.src}`,s.HIGHLIGHT),rn(e),xn(n),On(e),Nn(e,pn(e)),dn(e),u(e,"Setup complete")}function Un(e,n){const{id:t}=e;w(t,"setup"),ln(t)&&Wn(t,e,n),pe(t)}function Vn(e,n){n.log===i.LOG_DISABLED?n.log=!1:n.log===i.LOG_COLLAPSED?n.log=i.COLLAPSE:n.log===i.LOG_EXPANDED&&(n.log=i.EXPAND);const t=p.hasOwn(n,"log"),o=p.isString(n.log),a=t?o?!0:n.log:y.log;p.hasOwn(n,"logExpand")||(n.logExpand=t&&o?n.log===i.EXPAND:y.logExpand),on(n),ge({enabled:a,expand:n.logExpand,iframeId:e}),o&&!(n.log in i.LOG_OPTIONS)&&he(e,`Invalid value for options.log: Accepted values are "${i.EXPAND}" and "${i.COLLAPSE}"`),n.log=a}function jn(e){if(!p.isObject(e))throw new TypeError("Options is not an object");return un(),Le(e),n=>{const t=we(n,e);return i.LABEL in n?(w(t,"alreadySetup"),L(t,`Ignored iframe (${t}), already setup.`)):(Vn(t,e),C(t,Un)(n,e)),n?.iframeResizer}}Object.defineProperty(m,"LOG_COLLAPSED",{enumerable:!0,get:()=>i.LOG_COLLAPSED}),Object.defineProperty(m,"LOG_DISABLED",{enumerable:!0,get:()=>i.LOG_DISABLED}),Object.defineProperty(m,"LOG_EXPANDED",{enumerable:!0,get:()=>i.LOG_EXPANDED}),m.default=jn,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
26
+ The <b>${t}</> option has been renamed to <b>${n}</>. ${i.REMOVED_NEXT_VERSION}`),r[e][n]=r[e][t],delete r[e][t])}function $t(e){$(e,i.OFFSET,i.OFFSET_SIZE),$(e,"onClose","onBeforeClose"),$(e,"onClosed","onAfterClose")}const vt=e=>i.hasOwn(e,"onMouseEnter")||i.hasOwn(e,"onMouseLeave");function kt(e,t){const{id:n}=e;r[n]={...r[n],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...G,...Rt(n,t),mouseEvents:vt(t),mode:i.setMode(t),syncTitle:Je(n)},$t(n),yt(n),Mt(n,t),Gt(n),Pt(e),Nt(n)}const Dt="yes",re="no";function _t(e){const{id:t}=e;switch(l(t,`Iframe scrolling ${r[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=r[t]?.scrolling===!1?i.HIDDEN:i.AUTO,r[t]?.scrolling){case i.OMIT:break;case!0:e.scrolling=Dt;break;case!1:e.scrolling=re;break;default:e.scrolling=r[t]?.scrolling||re}}function Ct(e,t,n){kt(t,n),l(e,`src: %c${t.srcdoc||t.src}`,a.HIGHLIGHT),Qe(e),_t(t),gt(e),At(e,ut(e)),ot(e),l(e,"Setup complete")}function zt(e,t){const{id:n}=e;T(n,"setup"),st(n)&&Ct(n,e,t),de(n)}function Ft(e,t){t.log===i.LOG_DISABLED?t.log=!1:t.log===i.LOG_COLLAPSED?t.log=i.COLLAPSE:t.log===i.LOG_EXPANDED&&(t.log=i.EXPAND);const n=i.hasOwn(t,"log"),s=i.isString(t.log),o=n?s?!0:t.log:G.log;i.hasOwn(t,"logExpand")||(t.logExpand=n&&s?t.log===i.EXPAND:G.logExpand),me(t),ce({enabled:o,expand:t.logExpand,iframeId:e}),s&&!(t.log in i.LOG_OPTIONS)&&le(e,`Invalid value for options.log: Accepted values are "${i.EXPAND}" and "${i.COLLAPSE}"`),t.log=o}function Bt(e){if(!i.isObject(e))throw new TypeError("Options is not an object");return rt(),Oe(e),t=>{const n=pe(t,e);return i.LABEL in t?(T(n,"alreadySetup"),w(n,`Ignored iframe (${n}), already setup.`)):(Ft(n,e),D(n,zt)(t,e)),t?.iframeResizer}}Object.defineProperty(p,"LOG_COLLAPSED",{enumerable:!0,get:()=>i.LOG_COLLAPSED}),Object.defineProperty(p,"LOG_DISABLED",{enumerable:!0,get:()=>i.LOG_DISABLED}),Object.defineProperty(p,"LOG_EXPANDED",{enumerable:!0,get:()=>i.LOG_EXPANDED}),p.default=Bt,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
27
27
  //# sourceMappingURL=index.umd.js.map