@iframe-resizer/core 6.0.0-beta.6 → 6.0.0-beta.8

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