@iframe-resizer/child 5.5.9 → 6.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +1 -1
- package/index.cjs.js +52 -20
- package/index.cjs.js.map +1 -0
- package/index.esm.js +1454 -20
- package/index.esm.js.map +1 -0
- package/index.umd.js +54 -20
- package/index.umd.js.map +1 -0
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Iframe Resizer Version
|
|
1
|
+
Iframe Resizer Version 6
|
|
2
2
|
|
|
3
|
-
This JavaScript library is Copyright © 2013-
|
|
3
|
+
This JavaScript library is Copyright © 2013-2026 David J. Bradshaw and is dual-licensed, either under GPL V3 for compliant sites (Fully published front and backend source code). Or alternatively it is available under a commercial license for sites that do not wish to use the GPL.
|
|
4
4
|
|
|
5
5
|
For more information on commercial licensing see https://iframe-resizer.com/pricing/
|
|
6
6
|
|
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,20 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"use strict";const e=require("auto-console-group"),t="5.5.9",n="iframeResizer",o=":",r="init",i="message",a="pageHide",s="pageInfo",c="parentInfo",l="scrollToOffset",d="title",u=10,m="data-iframe-size",f="data-iframe-overflowed",p="data-iframe-ignore",h="height",y="width",g="offset",b="offsetSize",v="string",z="number",w="object",$="function",O="auto",I="readystatechange",S="bottom",T="right",E="autoResizeEnabled",M=Symbol("sizeChanged"),H="manualResize",j="parentResize",k={[H]:1,[j]:1},N="setOffsetSize",R="resizeObserver",x="overflowObserver",A="mutationObserver",L="visibilityObserver",C="[iFrameSizer]",G=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),P=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},D=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),B=["spjluzl","rlf","clyzpvu"],q=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."],F=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],W=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,t)=>[e,Math.max(0,t-1)])),U=e=>D(q[e]),V=e=>{const t=e[D(B[0])]||e[D(B[1])]||e[D(B[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=P(D(e));return n in W&&(t=W[n]),t>4?t-4:t}(n[0]);return 0===o||(e=>e[2]===P(e[0]+e[1]))(n)||(o=-2),o},Z=(e,...t)=>setTimeout(()=>e(...t),0),J=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},_=e=>e,Q=e=>Math.round(1e3*e)/1e3,Y=e=>e.charAt(0).toUpperCase()+e.slice(1),X=e=>""!=`${e}`&&void 0!==e,K=e=>e();const ee=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${Y(t)}`)},te={br:"\n",rb:"[31;1m",bb:"[34;1m",b:"[1m",i:"[3m",u:"[4m","/":"[m"},ne=Object.keys(te),oe=new RegExp(`<(${ne.join("|")})>`,"gi"),re=(e,t)=>te[t]??"";let ie=!0,ae=n;var se;const ce=(se=e,se?.__esModule?se.default:se)({label:`${n}(child)`,expand:!1});var le;const de=(le="log",(...e)=>!ie||ce[le](...e));const{assert:ue,endAutoGroup:me,error:fe,errorBoundary:pe,event:he,label:ye,purge:ge,warn:be}=ce,ve=(ze=_,e=>ze(typeof e===v?window.chrome?e.replace(oe,re):(e=>e.replaceAll("<br>","\n").replaceAll(/<\/?[^>]+>/gi,""))(e):e));var ze;const we=(...e)=>ce.warn(...e.map(ve)),$e=(e=>(t,n="renamed to")=>(o,r,i="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${i}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>we(t)),Oe=$e("Method"),Ie=$e("Method","replaced with"),Se=$e("Option"),Te=["min-height","min-width","max-height","max-width"],Ee=new Set,Me=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),He=(e,t)=>{return(n=Me(e,t))&&"0px"!==n&&n!==O&&"none"!==n;var n};function je({href:e}){Ee.has(e)||Ee.add(e)}const ke=(e,t)=>function(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const e=o.style[t];if(e)return{source:"STYLE"===n.ownerNode.tagName?"an inline <style> block":`stylesheet (${n.href})`,value:e}}}catch(e){je(n)}return{source:"cross-origin stylesheet",value:Me(e,t)}}(e,t),Ne=(e,t)=>{const{source:n,value:o}=ke(e,t),r=(e=>e.tagName?e.tagName.toLowerCase():"unknown")(e);we(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.\n\nIf you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function Re(){for(const e of[document.documentElement,document.body])for(const t of Te)He(e,t)&&Ne(e,t)}const xe=e=>t=>void 0===t?void 0:e(t),Ae=xe(e=>"true"===e),Le=xe(Number),Ce=[],Ge=(e,t,n,o)=>{e.removeEventListener(t,n,o)},Pe=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),Ce.push(()=>Ge(e,t,n,o))},De=e=>e=>{e.size},Be=((e="")=>t=>n=>{n.size>0&&fe(`${t}Observer ${e}:`,...Array.from(n).flatMap(e=>["\n",e]))})("already attached"),qe=e=>e=>{e.size},Fe=(t,n=!0)=>o=>{o>0&&de(`${n?"At":"De"}tached %c${t}Observer%c ${n?"to":"from"} %c${o}%c element${1===o?"":"s"}`,e.HIGHLIGHT,e.NORMAL,e.HIGHLIGHT,e.NORMAL)},We=(e,t,n,o)=>{const r=qe(e);return e=>{const i=new Set;let a=0;for(const o of e)n.has(o)&&(t.unobserve(o),n.delete(o),i.add(o),a+=1);r(i),o(a),i.clear()}},Ue=new Set,Ve=new Set,Ze=new Set,Je=[],_e={attributes:!0,attributeFilter:[p,m],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let Qe,Ye=1,Xe=!1,Ke=0;const et=e=>{e.size},tt=e=>{e.size},nt=e=>{e.size},ot=e=>e.nodeType!==Node.ELEMENT_NODE||G.has(e.tagName.toLowerCase());function rt(e){const t=e.addedNodes;for(const e of t)ot(e)||Ue.add(e)}function it(e){const t=e.removedNodes;for(const e of t)ot(e)||(Ue.has(e)?(Ue.delete(e),Ze.add(e)):Ve.add(e))}const at=e=>{de("Mutations:",e);for(const t of e)rt(t),it(t);et(Ue),tt(Ve),nt(Ze),Ze.clear()};const st=t=>()=>{const n=performance.now(),o=n-Ke,r=16*Ye+++2;if(o>r&&o<200)return he("mutationThrottled"),de("Update delayed due to heavy workload on the callStack"),de(`EventLoop busy time: %c${Q(o)}ms %c> Max wait: %c${r-2}ms`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),setTimeout(Qe,16*Ye),void(Ke=n);Ye=1,Je.forEach(at),Je.length=0,Xe=!1,Ve.size,Ue.size,t({addedNodes:Ue,removedNodes:Ve}),Ue.clear(),Ve.clear()};function ct(e){Je.push(e),Xe||(Ke=performance.now(),Xe=!0,requestAnimationFrame(Qe))}function lt(t){const n=new window.MutationObserver(ct),o=document.body||document.documentElement;return Qe=st(t),n.observe(o,_e),de("Attached%c MutationObserver%c to body",e.HIGHLIGHT,e.FOREGROUND),{...n,disconnect:()=>{Ue.clear(),Ve.clear(),Je.length=0,n.disconnect(),de("Detached%c MutationObserver",e.HIGHLIGHT)}}}const dt="Overflow",ut=Fe(dt),mt=Fe(dt,!1),ft=De(dt),pt=Be(dt),ht=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,yt=(t,n)=>{const o=n.side,r={root:n.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||_,a=(e=!1)=>t(e),s=(e,t)=>0===e||e>t[o],c=(e,t)=>e.toggleAttribute(f,t);const l=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:n,target:r}=t;if(!n)continue;const i=e[o],a=s(i,n)&&!ht(r);c(r,a)}i(a)},r),d=new WeakSet;return{attachObservers:function(e){const t=new Set,n=new Set;let o=0;for(const r of e)r.nodeType===Node.ELEMENT_NODE&&(d.has(r)?t.add(r):(l.observe(r),d.add(r),n.add(r),o+=1));pt(t),ft(n),ut(o),n.clear(),t.clear()},detachObservers:We(dt,l,d,mt),disconnect:()=>{l.disconnect(),de("Detached%c OverflowObserver",e.HIGHLIGHT)}}},gt="--ifr-start",bt="--ifr-end",vt="--ifr-measure",zt=[];let wt,$t={},Ot=0;function It(){try{performance.clearMarks(gt),performance.clearMarks(bt),performance.clearMeasures(vt)}catch{}}function St(e){e.getEntries().forEach(e=>{if(e.name===bt)try{const{duration:t}=performance.measure(vt,gt,bt);$t=e.detail,zt.push(t),zt.length>100&&zt.shift()}catch{}})}function Tt(){de("Attached%c PerformanceObserver%c to page",e.HIGHLIGHT,e.FOREGROUND);const t=new PerformanceObserver(St);return t.observe({entryTypes:["mark"]}),wt=setInterval(()=>{if(zt.length<10)return;if($t.hasTags&&$t.len<25)return;zt.sort();const e=Math.min(zt.reduce((e,t)=>e+t,0)/zt.length,zt[Math.floor(zt.length/2)]),t=Q(e);t>Ot&&(Ot=t,he("performanceObserver")),It(),e<=4||(clearInterval(wt),we(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${Q(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${$t.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3),{disconnect:()=>{It(),clearInterval(wt),t.disconnect(),de("Detached%c PerformanceObserver",e.HIGHLIGHT)}}}const Et="Resize",Mt=Fe(Et),Ht=Fe(Et,!1),jt=De(Et),kt=Be(Et),Nt=new WeakSet,Rt=new Set,xt=new Set;let At;function Lt(e){let t=0;for(const n of e){if(n.nodeType!==Node.ELEMENT_NODE)continue;const e=getComputedStyle(n)?.position;""!==e&&"static"!==e&&(Nt.has(n)?Rt.add(n):(At.observe(n),Nt.add(n),xt.add(n),t+=1))}kt(Rt),jt(xt),Mt(t),xt.clear(),Rt.clear()}function Ct(t){const n=new IntersectionObserver(e=>t(e.at(-1).isIntersecting),{threshold:0}),o=document.documentElement;return n.observe(o),de("Attached%c VisibilityObserver%c to page",e.HIGHLIGHT,e.FOREGROUND),{disconnect:()=>{n.disconnect(),de("Detached%c VisibilityObserver",e.HIGHLIGHT)}}}const Gt=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Pt=Gt($),Dt=Gt(z),Bt=Gt(v);"undefined"!=typeof window&&function(){const P={height:()=>(be("Custom height calculation function not defined"),Hn.auto()),width:()=>(be("Custom width calculation function not defined"),jn.auto())},q={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},W={},Q=O,te="scroll";let ne,oe,re,se,le,ve,ze,$e=!0,Te="",Ee=0,Me="",He="",je=!1,ke=!0,Ne=!1,xe=!0,De=!1,Be=!1,qe=!0,Fe=!1,Ue=1,Ve=Q,Ze="",Je=!0,_e={},Qe=!1,Ye=!1,Xe=!1,Ke=0,et=!1,tt=0,nt=0,ot=new Set,rt="",it="child",at=!1,st="",ct=[],dt=window.parent,ut="*",mt=0,ft=!1,pt=1,ht=te,vt=window,zt=()=>{be("onMessage function not defined")},wt=()=>{},$t=null,Ot=null;function It(o){var i;!function(e){rt=e[0]??rt,Ee=Le(e[1])??Ee,Ne=Ae(e[2])??Ne,Xe=Ae(e[3])??Xe,$e=Ae(e[6])??$e,Me=e[7]??Me,Ve=e[8]??Ve,Te=e[9]??Te,He=e[10]??He,mt=Le(e[11])??mt,_e.enable=Ae(e[12])??!1,it=e[13]??it,ht=e[14]??ht,et=Ae(e[15])??et,tt=Le(e[16])??tt,nt=Le(e[17])??nt,ke=Ae(e[18])??ke,ne=e[19]??ne,ve=e[20]??ve,Ke=Le(e[21])??Ke,Ye=Ae(e[23])??Ye}(o),ae=(i={id:rt,enabled:Xe,expand:Ye}).id||n,ce.label(`${ae}`),ce.expand(i.expand),ie=i.enabled,he("initReceived"),function(){function t(e){ze=Pt(e,"onBeforeResize")??ze,zt=Pt(e,"onMessage")??zt,wt=Pt(e,"onReady")??wt,typeof e?.offset===z&&(Se(g,b),ke&&(tt=Dt(e,g)??tt),Ne&&(nt=Dt(e,g)??nt)),typeof e?.offsetSize===z&&(ke&&(tt=Dt(e,b)??tt),Ne&&(nt=Dt(e,b)??nt)),oe=Bt(e,D(B[0]))??oe,Ze=Bt(e,"ignoreSelector")??Ze,st=Bt(e,"sizeSelector")??st,ut=Bt(e,"targetOrigin")??ut,Ve=e?.heightCalculationMethod||Ve,ht=e?.widthCalculationMethod||ht}function n(e,t){return typeof e===$&&(we(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.\n\nSee <u>https://iframe-resizer.com/api/child</> for more details.`),P[t]=e,e="custom"),e}if(1===Ke)return;const o=window.iframeResizer||window.iFrameResizer;typeof o===w&&(t(o),Ve=n(Ve,h),ht=n(ht,y),de(`Set targetOrigin for parent: %c${ut}`,e.HIGHLIGHT))}(),[Ft,Ut,nn,Gt,Wt,en,tn,Xt,qt,Rt,je?_:Re,_t,()=>Vt("background",Te),()=>Vt("padding",He),je?_:Qt,rn,Jt,zn,an,on,sn,Mt,cn].forEach(e=>{try{e()}catch(e){if(Ke<0)throw e;we("<rb>Error in setup function</>\n<i>iframe-resizer</> detected an error during setup.\n\nPlease report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>"),fe(e)}}),kt(J(wt)),me(),Cn(r,"Init message from host page",void 0,void 0,`${t}:${Ke}`),document.title&&""!==document.title&&Dn(0,0,d,document.title)}function St({persisted:e}){e||Dn(0,0,"beforeUnload"),he(a),de("Page persisted:",e),e||Ce.forEach(K)}const Mt=()=>Pe(window,a.toLowerCase(),St);let jt=!1;function kt(e){"complete"===document.readyState?Z(e):jt||Pe(document,I,()=>kt(e)),jt=!0}function Rt(){ct=document.querySelectorAll(`[${m}]`),Fe=ct.length>0}let xt=0;function Gt(){const t=document.querySelectorAll(`*[${p}]`);return De=t.length>0,De&&t.length!==xt&&(function(t){const n=1===t.length?"":"s";be(`%c[${p}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),xt=t.length),De}function qt(){"BackCompat"===document.compatMode&&we("<rb>Quirks Mode Detected</>\n\nThis iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.\n\nFor more information see <u>https://iframe-resizer.com/quirks-mode</>.\n")}function Ft(){ve&&""!==ve&&"false"!==ve?ve!==t&&we(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${ve} - Child page: ${t}.\n`):we("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/</> for more details.\n")}function Wt(){try{at=1===Ke||"iframeParentListener"in window.parent}catch(e){}}function Ut(){Ne===ke&&(je=!0)}function Vt(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),de(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function Zt(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function Jt(){Zt(0,m,st),Zt(0,p,Ze)}function _t(){var e,t;void 0===Me&&(Me=`${Ee}px`),Vt("margin",(e="margin",(t=Me).includes("-")&&(be(`Negative CSS value ignored for ${e}`),t=""),t))}function Qt(){const e=e=>e.style.setProperty(h,O,"important");e(document.documentElement),e(document.body)}function Yt(e){({add(t){function n(){Cn(e.eventName,e.eventType)}W[t]=n,Pe(window,t,n,{passive:!0})},remove(e){const t=W[e];delete W[e],Ge(window,e,t)}})[e.method](e.eventName)}function Xt(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(m,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&we("<rb>Deprecated Attributes</>\n\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}function Kt(e,t,n){const{label:o}=n;return t!==e&&(e in n||(be(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in q)&&we(`<rb>Deprecated ${o}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you ${ve?"remove this option.":`set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page. This can be done on the child page by adding the following code:\n\nwindow.iframeResizer = {\n license: 'xxxx',\n ${o}CalculationMethod: '${O}',\n}\n`}\n`),e}function en(){Ve=Kt(Ve,Q,Hn)}function tn(){ht=Kt(ht,te,jn)}function nn(){const n=Ke,o=V({key:ne}),r=V({key:oe});if(Ke=Math.max(o,r),Ke<0){if(Ke=Math.min(o,r),ge(),we(`${U(Ke+2)}${U(2)}`),X(ve))throw U(Ke+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!X(ve)||n>-1&&Ke>n)&&(sessionStorage.getItem("ifr")!==t&&function(t,n){console.info(`${ae} %ciframe-resizer ${t}`,ie||n<1?"font-weight: bold;":e.NORMAL)}(`v${t} (${(e=>D(F[e]))(Ke)})`,Ke),Ke<2&&we(U(3)),sessionStorage.setItem("ifr",t))}function on(){!function(e){Yt({method:e,eventType:"After Print",eventName:"afterprint"}),Yt({method:e,eventType:"Before Print",eventName:"beforeprint"})}("add")}function rn(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function an(){function e(e){const t=e.getBoundingClientRect(),n={x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};return{x:parseInt(t.left,u)+parseInt(n.x,u),y:parseInt(t.top,u)+parseInt(n.y,u)}}function t(t){const n=t.split("#")[1]||t,o=decodeURIComponent(n),r=document.getElementById(o)||document.getElementsByName(o)[0];void 0===r?Dn(0,0,"inPageLink",`#${n}`):function(t){const n=e(t);Dn(n.y,n.x,l)}(r)}function n(){const{hash:e,href:n}=window.location;""!==e&&"#"!==e&&t(n)}const{enable:o}=_e;o&&(1===Ke?we(U(5)):(function(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&Pe(e,"click",n=>{n.preventDefault(),t(e.getAttribute("href"))})}(),Pe(window,"hashchange",n),setTimeout(n,128))),_e={..._e,findTarget:t}}function sn(){function e(e){Dn(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){Pe(window.document,t,e)}!0===et&&(t("mouseenter"),t("mouseleave"))}function cn(){1!==Ke&&(vt.parentIframe=Object.freeze({autoResize:e=>(ee(e,"boolean","parentIframe.autoResize(enable) enable"),!1===Ne&&!1===ke?(he(E),we("Auto Resize can not be changed when <b>direction</> is set to 'none'."),!1):(!0===e&&!1===$e?($e=!0,queueMicrotask(()=>Cn(E,"Auto Resize enabled"))):!1===e&&!0===$e&&($e=!1),Dn(0,0,"autoResize",JSON.stringify($e)),$e)),close(){Dn(0,0,"close")},getId:()=>rt,getOrigin:()=>(he("getOrigin"),Oe("getOrigin()","getParentOrigin()"),re),getParentOrigin:()=>re,getPageInfo(e){if(typeof e===$)return $t=e,Dn(0,0,s),void Ie("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");$t=null,Dn(0,0,"pageInfoStop")},getParentProps:e=>(ee(e,$,"parentIframe.getParentProps(callback) callback"),Ot=e,Dn(0,0,c),()=>{Ot=null,Dn(0,0,"parentInfoStop")}),getParentProperties(e){Oe("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){ee(e,v,"parentIframe.moveToAnchor(anchor) anchor"),_e.findTarget(e)},reset(){!function(){const e=Ve;Ve=Q,ft||(ft=!0,requestAnimationFrame(()=>{ft=!1})),Gn("reset"),Ve=e}()},setOffsetSize(e){ee(e,z,"parentIframe.setOffsetSize(offset) offset"),tt=e,nt=e,Cn(N,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){ee(e,z,"parentIframe.scrollBy(x, y) x"),ee(t,z,"parentIframe.scrollBy(x, y) y"),Dn(t,e,"scrollBy")},scrollTo(e,t){ee(e,z,"parentIframe.scrollTo(x, y) x"),ee(t,z,"parentIframe.scrollTo(x, y) y"),Dn(t,e,"scrollTo")},scrollToOffset(e,t){ee(e,z,"parentIframe.scrollToOffset(x, y) x"),ee(t,z,"parentIframe.scrollToOffset(x, y) y"),Dn(t,e,l)},sendMessage(e,t){t&&ee(t,v,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Dn(0,0,i,JSON.stringify(e),t)},setHeightCalculationMethod(e){Ve=e,en()},setWidthCalculationMethod(e){ht=e,tn()},setTargetOrigin(e){ee(e,v,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),ut=e},resize(e,t){void 0!==e&&ee(e,z,"parentIframe.resize(customHeight, customWidth) customHeight"),void 0!==t&&ee(t,z,"parentIframe.resize(customHeight, customWidth) customWidth"),Cn(H,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){Oe("size()","resize()"),this.resize(e,t)}}),vt.parentIFrame=vt.parentIframe)}let ln=new Set;function dn(){const e=document.querySelectorAll(`[${f}]`);ot=function(e){const t=new Set,n=new Set;for(const o of e)o.closest(`[${p}]`)?n.add(o):t.add(o);return n.size>0&&queueMicrotask(()=>{he("overflowIgnored"),de("Ignoring elements with [data-iframe-ignore] > *:\n",n),me()}),t}(e),Be=ot.size>0,typeof Set.prototype.symmetricDifference===$&&(qe=ot.symmetricDifference(ln).size>0),ln=ot}function un(){switch(dn(),!0){case!qe:return;case ot.size>1:de("Overflowed Elements:",ot);break;case Be:break;default:de("No overflow detected")}Cn(x,"Overflow updated")}function mn(e){const t={root:document.documentElement,side:ke?S:T};return se=yt(un,t),se.attachObservers(e),se}function fn(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Cn(R,`Element resized <${function(e){switch(!0){case!X(e):return"";case X(e.id):return`${e.nodeName}#${e.id}`;case X(e.name):return`${e.nodeName} (${e.name}`;case X(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function pn(t){return At=new ResizeObserver(fn),At.observe(document.body),Nt.add(document.body),de("Attached%c ResizeObserver%c to body",e.HIGHLIGHT,e.FOREGROUND),le={attachObserverToNonStaticElements:Lt,detachObservers:We(Et,At,Nt,Ht),disconnect:()=>{At.disconnect(),de("Detached%c ResizeObserver",e.HIGHLIGHT)}},le.attachObserverToNonStaticElements(t),le}function hn(e){Qe=!e,Cn(L,"Visibility changed")}const yn=e=>{const t=new Set;for(const n of e){t.add(n);for(const e of In(n))t.add(e)}return de("Inspecting:\n",t),t},gn=e=>{if(0===e.size)return;he("addObservers");const t=yn(e);se.attachObservers(t),le.attachObserverToNonStaticElements(t),me()},bn=e=>{if(0===e.size)return;he("removeObservers");const t=yn(e);se.detachObservers(t),le.detachObservers(t),me()};function vn(e){!function({addedNodes:e,removedNodes:t}){he("contentMutated"),Jt(),Rt(),dn(),me(),bn(t),gn(e)}(e),Cn(A,"Mutation Observed")}function zn(){const e=In(document.documentElement);var t;t=[lt(vn),mn(e),Tt(),pn(e),Ct(hn)],Ce.push(...t.map(e=>e.disconnect))}function wn(t){performance.mark(gt);const n=Y(t);let o=1,r=document.documentElement,i=Fe?0:document.documentElement.getBoundingClientRect().bottom;const a=Fe?ct:Be?Array.from(ot):In(document.documentElement);for(const e of a)o=e.getBoundingClientRect()[t]+parseFloat(getComputedStyle(e).getPropertyValue(`margin-${t}`)),o>i&&(i=o,r=e);return de(`${n} position calculated from:`,r),de(`Checked %c${a.length}%c elements`,e.HIGHLIGHT,e.FOREGROUND),performance.mark(bt,{detail:{hasTags:Fe,len:a.length,logging:Xe,Side:n}}),i}const $n=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],On=`* ${Array.from(G).map(e=>`:not(${e})`).join("")}`,In=e=>e.querySelectorAll(On),Sn={height:0,width:0},Tn={height:0,width:0},En=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function Mn(t){function n(){return Tn[r]=i,Sn[r]=c,Math.max(i,1)}const o=t===Hn,r=t.label,i=t.boundingClientRect(),a=Math.ceil(i),s=Math.floor(i),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),l=`HTML: %c${i}px %cPage: %c${c}px`;let d=1;switch(!0){case!t.enabled():return Math.max(c,1);case Fe:de("Found element with data-iframe-size attribute"),d=t.taggedElement();break;case!Be&&xe&&0===Tn[r]&&0===Sn[r]:de(`Initial page size values: ${l}`,...En),d=n();break;case ft&&i===Tn[r]&&c===Sn[r]:de(`Size unchanged: ${l}`,...En),d=Math.max(i,c);break;case 0===i&&0!==c:de(`Page is hidden: ${l}`,...En),d=c;break;case!Be&&i!==Tn[r]&&c<=Sn[r]:de(`New <html> size: ${l} `,...En),de(`Previous <html> size: %c${Tn[r]}px`,e.HIGHLIGHT),d=n();break;case!o:d=t.taggedElement();break;case!Be&&i<Tn[r]:de(`<html> size decreased: ${l}`,...En),d=n();break;case c===s||c===a:de(`<html> size equals page size: ${l}`,...En),d=n();break;case i>c:de(`Page size < <html> size: ${l}`,...En),d=n();break;case Be:de("Found elements possibly overflowing <html> "),d=t.taggedElement();break;default:de(`Using <html> size: ${l}`,...En),d=n()}return de(`Content ${r}: %c${d}px`,e.HIGHLIGHT),d+=function(t){const n=t.getOffset();return 0!==n&&de(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),Math.max(d,1)}const Hn={label:h,enabled:()=>ke,getOffset:()=>tt,auto:()=>Mn(Hn),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,u)+parseInt(t.marginBottom,u)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Hn.bodyOffset(),custom:()=>P.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...$n(Hn)),min:()=>Math.min(...$n(Hn)),grow:()=>Hn.max(),lowestElement:()=>wn(S),taggedElement:()=>wn(S)},jn={label:y,enabled:()=>Ne,getOffset:()=>nt,auto:()=>Mn(jn),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>P.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...$n(jn)),min:()=>Math.min(...$n(jn)),rightMostElement:()=>wn(T),scroll:()=>Math.max(jn.bodyScroll(),jn.documentElementScroll()),taggedElement:()=>wn(T)},kn=(e,t)=>!(Math.abs(e-t)<=mt);function Nn(e,t){const n=e[t](),o=e.enabled()&&void 0!==ze?function(e){const t=ze(e);if(void 0===t)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);if(t<1)throw new RangeError(`Out of range value returned from onBeforeResize(): ${t}, must be at least 1`);return t}(n):n;return ue(o>=1,`New iframe ${e.label} is too small: ${o}, must be at least 1`),o}let Rn=!1;const xn=J(()=>we(U(4)));let An,Ln=!1;const Cn=pe((e,t,n,o,i)=>{switch(he(e),!0){case!0===Qe:if(!0===Ln)break;Ln=!0,Rn=!1,cancelAnimationFrame(An),An=null;break;case!0===Rn&&e!==x:ge();break;case!$e&&!(e in k):de("Resizing disabled");break;default:Ln=!1,Rn=!0,performance.now(),An||(An=requestAnimationFrame(()=>{Rn=!1,An=null,he("requestAnimationFrame")})),function(e,t,n,o,i){const a=n??Nn(Hn,Ve),s=o??Nn(jn,ht);switch(ke&&kn(Ue,a)||Ne&&kn(pt,s)?M:e){case r:case E:case M:Ue=a,pt=s;case N:Pn(Ue,pt,e,i);break;case x:case A:case R:case L:ge();break;default:ge(),de("No change in content size detected")}}(e,0,n,o,i)}me()});function Gn(e){Ue=Hn[Ve](),pt=jn[ht](),Dn(Ue,pt,e)}function Pn(t,n,o,r,i){Ke<-1||(void 0!==i||(i=ut),function(){const a=`${rt}:${t}:${n}:${o}${void 0===r?"":`:${r}`}`;if(at)try{window.parent.iframeParentListener(C+a)}catch(e){if(1!==Ke)throw e;return void xn()}else dt.postMessage(C+a,i);de(`Sending message to parent page via ${at?"sameOrigin":"postMessage"}: %c%c${a}`,e.ITALIC,e.HIGHLIGHT)}())}const Dn=pe((e,t,n,o,r)=>{he(n),Pn(e,t,n,o,r),me()}),Bn=pe(function(e){he("onMessage");const{freeze:t}=Object,{parse:n}=JSON,i=e=>Dn(0,0,`${e}Stop`),a={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(o);dt=e.source,re=e.origin,It(t),xe=!1,setTimeout(()=>{Je=!1},128)},reset(){Je||Gn("resetPage")},resize(){Cn(j,"Parent window requested size check")},moveToAnchor(){_e.findTarget(d())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=d();$t?Z($t,n(e)):i(s)},parentInfo(){const e=(o=d(),t(n(o)));var o;Ot?Z(Ot,e):i(c)},message(){const e=d();Z(zt,n(e))}},l=()=>e.data.split("]")[1].split(o)[0],d=()=>e.data.slice(e.data.indexOf(o)+1),u=()=>e.data.split(o)[2]in{true:1,false:1};function m(){const t=l();he(t),t in a?a[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||u()||be(`Unexpected message (${e.data})`)}C===`${e.data}`.slice(0,13)&&function(){if(!1!==xe)return u()?(ye(l()),he(r),void a.init()):void 0;m()}()});let qn=!1;const Fn=e=>e.postMessage("[iFrameResizerChild]Ready",window?.iframeResizer?.targetOrigin||"*");function Wn(){if("loading"===document.readyState||!xe||qn)return;const{parent:e,top:t}=window;he("ready"),Fn(e),e!==t&&Fn(t),qn=!0}"iframeChildListener"in window?be("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>Bn({data:e,sameOrigin:!0})),he("listen"),Pe(window,i,Bn),Pe(document,I,Wn),Wn())}();
|
|
1
|
+
"use strict";const s=require("auto-console-group"),D="6.0.0-beta.0",Ue="iframeResizer",we=":",An="[iFrameResizerChild]Ready",Nn="autoResize",Cn="beforeUnload",Gn="close",kn="inPageLink",ze="init",Ce="message",Pn="mouseenter",Dn="mouseleave",Pt="pageHide",Dt="pageInfo",jt="parentInfo",jn="pageInfoStop",xn="parentInfoStop",_n="scrollBy",Bn="scrollTo",xt="scrollToOffset",Fn="title",B=10,J=1,Oe="data-iframe-size",_t="data-iframe-overflowed",X="data-iframe-ignore",ee="height",Bt="width",Re="offset",He="offsetSize",Un="scroll",We=`
|
|
2
|
+
`,te="string",C="number",Wn="boolean",Vn="object",ne="function",qn="undefined",Zn="false",Yn="null",Ee="auto",Ft="readystatechange",Ge="bottom",ke="right",Pe="autoResizeEnabled",dt=Symbol("sizeChanged"),Ve="manualResize",qe="parentResize",ut={[Ve]:1,[qe]:1},Ut="setOffsetSize",Wt="resizeObserver",Ze="overflowObserver",Vt="mutationObserver",qt="visibilityObserver",Qn="font-weight: bold;",Ye="none",ft="No change in content size detected",fe="[iFrameSizer]",Zt=fe.length,Qe=Ee,Yt=Un,Qt=128,Jt=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),Jn=e=>(t,n="renamed to")=>(o,r,u="",l="")=>e(l,`<rb>Deprecated ${t}(${o.replace("()","")})</>
|
|
3
|
+
|
|
4
|
+
The <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${u}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`),Kn=e=>typeof e===te,Ie=(e,...t)=>setTimeout(()=>e(...t),0),Kt=e=>{let t=!1;return function(...n){return t?void 0:(t=!0,e.apply(this,n))}},me=e=>e,mt=1e3,P=e=>Math.round(e*mt)/mt,Xt=e=>e.charAt(0).toUpperCase()+e.slice(1),F=e=>`${e}`!=""&&e!==void 0,Xn=e=>e(),eo=e=>e.toLowerCase();function to(e){switch(!0){case!F(e):return"";case F(e.id):return`${e.nodeName}#${e.id}`;case F(e.name):return`${e.nodeName} (${e.name}`;case F(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const no=e=>e?.__esModule?e.default:e,T=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${Xt(t)}`)},en={br:`
|
|
5
|
+
`,rb:"\x1B[31;1m",bb:"\x1B[34;1m",b:"\x1B[1m",i:"\x1B[3m",u:"\x1B[4m","/":"\x1B[m"},oo=Object.keys(en),ro=new RegExp(`<(${oo.join("|")})>`,"gi"),so=(e,t)=>en[t]??"",io=e=>e.replace(ro,so),co=e=>e.replaceAll("<br>",We).replaceAll(/<\/?[^>]+>/gi,""),ao=e=>t=>e(Kn(t)?window.chrome?io(t):co(t):t);let Je=!0,De=Ue;const lo=no(s),K=lo({label:`${Ue}(child)`,expand:!1});function uo(e){De=e.id||Ue,K.label(`${De}`),K.expand(e.expand),Je=e.enabled}const tn=e=>(...t)=>Je?K[e](...t):!0,a=tn("log"),d=a,he=tn("debug");function fo(e,t){console.info(`${De} %ciframe-resizer ${e}`,Je||t<1?Qn:s.NORMAL)}const{assert:Ii,endAutoGroup:j,error:nn,errorBoundary:Ke,event:m,label:Si,purge:Ti,warn:R}=K,mo=ao(me),g=(...e)=>K.warn(...e.map(mo)),Xe=Jn((e,t)=>g(t)),on=Xe("Method"),ho=Xe("Method","replaced with"),go=Xe("Option"),et=[];function rn(e,t){a(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const sn=(e,t,n,o)=>{e.removeEventListener(t,n,o),rn("Removed",t)},G=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),et.push(()=>sn(e,t,n,o)),rn("Added",t)},c={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let ht=!1;const gt=e=>e.postMessage(An,window?.iframeResizer?.targetOrigin||"*");function pt(){if(document.readyState==="loading"||!c.firstRun||ht)return;const{parent:e,top:t}=window;m("ready"),a("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),gt(e),e!==t&>(t),ht=!0}const yt="iframeResize",po=e=>fe===`${e.data}`.slice(0,Zt),yo=()=>yt in window||window.jQuery!==void 0&&yt in window.jQuery.prototype,bo=e=>e.data.split(we)[2]in{true:1,false:1},vo=()=>[document.documentElement,document.body],wo=["min-height","min-width","max-height","max-width"],bt=new Set,zo=e=>!!e&&e!=="0px"&&e!==Ee&&e!==Ye,cn=e=>e.tagName?e.tagName.toLowerCase():"unknown",an=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Oo=(e,t)=>zo(an(e,t));function Eo(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}function Io({href:e}){bt.has(e)||(a("Unable to access stylesheet:",e),bt.add(e))}function So(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const r=o.style[t];if(r)return{source:n.ownerNode.tagName==="STYLE"?"an inline <style> block":`stylesheet (${n.href})`,value:r}}}catch{Io(n)}return{source:"cross-origin stylesheet",value:an(e,t)}}const To=(e,t)=>Eo(e,t)||So(e,t),Ro=(e,t)=>{const{source:n,value:o}=To(e,t),r=cn(e);g(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
6
|
+
|
|
7
|
+
If you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function Ho(){for(const e of vo())for(const t of wo)a(`Checking <${cn(e)}> for blocking CSS: ${t}`),Oo(e,t)&&Ro(e,t)}const Mo=({calculateWidth:e,calculateHeight:t})=>e===t,i={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:Qe,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:Yt,onBeforeResize:void 0,onMessage:()=>{R("onMessage function not defined")},onReady:()=>{}},$o=e=>`:not(${e})`,Lo=`* ${Array.from(Jt).map($o).join("")}`,tt=e=>e.querySelectorAll(Lo),ge=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],L=[s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT],de={height:0,width:0},_={height:0,width:0};function x(e,t,n){return _[e]=t,de[e]=n,t}function Ao(e){const t=e.getOffset();return t!==0&&d(`Page offsetSize: %c${t}px`,s.HIGHLIGHT),t}const No=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function ln(e){const{hasOverflow:t,hasTags:n,triggerLocked:o}=c,r=e.label,u=r===ee,l=e.boundingClientRect(),p=Math.ceil(l),v=Math.floor(l),f=No(e),w=`HTML: %c${l}px %cPage: %c${f}px`;let h;switch(!0){case!e.enabled():return Math.max(f,J);case n:d("Found element with data-iframe-size attribute"),h=e.taggedElement();break;case(!t&&c.firstRun&&_[r]===0&&de[r]===0):d(`Initial page size values: ${w}`,...L),h=x(r,l,f);break;case(o&&l===_[r]&&f===de[r]):d(`Size unchanged: ${w}`,...L),h=Math.max(l,f);break;case(l===0&&f!==0):d(`Page is hidden: ${w}`,...L),h=f;break;case(!t&&l!==_[r]&&f<=de[r]):d(`New <html> size: ${w} `,...L),d(`Previous <html> size: %c${_[r]}px`,s.HIGHLIGHT),h=x(r,l,f);break;case!u:h=e.taggedElement();break;case(!t&&l<_[r]):d(`<html> size decreased: ${w}`,...L),h=x(r,l,f);break;case(f===v||f===p):d(`<html> size equals page size: ${w}`,...L),h=x(r,l,f);break;case l>f:d(`Page size < <html> size: ${w}`,...L),h=x(r,l,f);break;case t:d("Found elements possibly overflowing <html> "),h=e.taggedElement();break;default:d(`Using <html> size: ${w}`,...L),h=x(r,l,f)}return d(`Content ${r}: %c${h}px`,s.HIGHLIGHT),h+=Ao(e),Math.max(h,J)}const Co=()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,B)+parseInt(t.marginBottom,B)},Go=1e3,ko=5*Go,Po=4,Do=10,jo=100,nt="--ifr-start",pe="--ifr-end",dn="--ifr-measure",b=[];let ue={},vt=0,je;function un(){try{performance.clearMarks(nt),performance.clearMarks(pe),performance.clearMeasures(dn)}catch{}}function xo(){je=setInterval(()=>{if(b.length<Do||ue.hasTags&&ue.len<25)return;b.sort();const e=Math.min(b.reduce((n,o)=>n+o,0)/b.length,b[Math.floor(b.length/2)]),t=P(e);t>vt&&(vt=t,m("performanceObserver"),a("Mean time:",P(b[Math.floor(b.length/2)])),a("Median time:",P(b.reduce((n,o)=>n+o,0)/b.length)),a("Average time:",t),a("Max time:",P(Math.max(...b)))),un(),!(e<=Po)&&(clearInterval(je),g(`<rb>Performance Warning</>
|
|
8
|
+
|
|
9
|
+
Calculating the page size is taking an excessive amount of time (${P(e)}ms).
|
|
10
|
+
|
|
11
|
+
To improve performance add the <b>data-iframe-size</> attribute to the ${ue.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},ko)}function _o(e){e.getEntries().forEach(t=>{if(t.name===pe)try{const{duration:n}=performance.measure(dn,nt,pe);ue=t.detail,b.push(n),b.length>jo&&b.shift()}catch{}})}function Bo(){d("Attached%c PerformanceObserver%c to page",s.HIGHLIGHT,s.FOREGROUND);const e=new PerformanceObserver(_o);return e.observe({entryTypes:["mark"]}),xo(),{disconnect:()=>{un(),clearInterval(je),e.disconnect(),d("Detached%c PerformanceObserver",s.HIGHLIGHT)}}}function Fo(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:n,taggedElements:o}=c;return t?o:e?Array.from(n):tt(document.documentElement)}function Uo(e,t){const n=`margin-${t}`;let o,r=document.documentElement,u=c.hasTags?J:document.documentElement.getBoundingClientRect().bottom;for(const l of e)o=l.getBoundingClientRect()[t]+parseFloat(getComputedStyle(l).getPropertyValue(n)),o>u&&(u=o,r=l);return{maxEl:r,maxVal:u}}function ye(e){performance.mark(nt);const t=Xt(e),{logging:n}=i,{hasTags:o}=c,r=Fo(),{maxEl:u,maxVal:l}=Uo(r,e);return d(`${t} position calculated from:`,u),d(`Checked %c${r.length}%c elements`,s.HIGHLIGHT,s.FOREGROUND),performance.mark(pe,{detail:{hasTags:o,len:r.length,logging:n,Side:t}}),l}const O={label:ee,enabled:()=>i.calculateHeight,getOffset:()=>i.offsetHeight,auto:()=>ln(O),bodyOffset:Co,bodyScroll:()=>document.body.scrollHeight,offset:()=>O.bodyOffset(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...ge(O)),min:()=>Math.min(...ge(O)),grow:()=>O.max(),lowestElement:()=>ye(Ge),taggedElement:()=>ye(Ge),custom:()=>(R("Custom height calculation function not defined"),O.auto())},E={label:Bt,enabled:()=>i.calculateWidth,getOffset:()=>i.offsetWidth,auto:()=>ln(E),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...ge(E)),min:()=>Math.min(...ge(E)),rightMostElement:()=>ye(ke),scroll:()=>Math.max(E.bodyScroll(),E.documentElementScroll()),taggedElement:()=>ye(ke),custom:()=>(R("Custom width calculation function not defined"),E.auto())},Wo={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},Vo=e=>`set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page. This can be done on the child page by adding the following code:
|
|
12
|
+
|
|
13
|
+
window.iframeResizer = {
|
|
14
|
+
license: 'xxxx',
|
|
15
|
+
${e}CalculationMethod: '${Ee}',
|
|
16
|
+
}
|
|
17
|
+
`;function qo(e,t){const n=i.version?"remove this option.":Vo(e);g(`<rb>Deprecated ${e}CalculationMethod (${t})</>
|
|
18
|
+
|
|
19
|
+
This version of <i>iframe-resizer</> can auto detect the most suitable ${e} calculation method. It is recommended that you ${n}
|
|
20
|
+
`)}function fn(e,t,n){const{label:o}=n;return t!==e&&(e in n||(R(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in Wo&&qo(o,e)),a(`Set ${o} calculation method: %c${e}`,s.HIGHLIGHT),e}function mn(){i.heightCalcMode=fn(i.heightCalcMode,Qe,O)}function hn(){i.widthCalcMode=fn(i.widthCalcMode,Yt,E)}function Zo(){try{c.sameOrigin=i.mode===1||"iframeParentListener"in window.parent}catch{a("Cross domain iframe detected")}}const Yo=`<rb>Deprecated Attributes</>
|
|
21
|
+
|
|
22
|
+
The <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.`;function Qo(){let e=!1;const t=n=>document.querySelectorAll(`[${n}]`).forEach(o=>{o.toggleAttribute(Oe,!0),o.removeAttribute(n),e=!0});t("data-iframe-height"),t("data-iframe-width"),e&&g(Yo)}let wt=0;function Jo(e){const t=e.length===1?"":"s";R(`%c[${X}]%c found on %c${e.length}%c element${t}`,s.BOLD,s.NORMAL,s.BOLD,s.NORMAL)}function Ko(){const e=document.querySelectorAll(`*[${X}]`),t=e.length>0;return t&&e.length!==wt&&(Jo(e),wt=e.length),t}const zt=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},A=e=>e.replace(/[A-Za-z]/g,t=>String.fromCodePoint((t<="Z"?90:122)>=(t=t.codePointAt(0)+19)?t:t-26)),Y=["spjluzl","rlf","clyzpvu","rlf2"],Xo=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."],er=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],Ot=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,t)=>[e,Math.max(0,t-1)])),U=e=>A(Xo[e]),tr=e=>A(er[e]),nr=e=>A(Y[e]),Et=e=>{const t=e[A(Y[0])]||e[A(Y[1])]||e[A(Y[2])]||e[A(Y[3])];if(!t)return-1;const n=t.split("-");let o=(function(r=""){let u=-2;const l=zt(A(r));return l in Ot&&(u=Ot[l]),u>4?u-4:u})(n[0]);return o===0||(r=>r[2]===zt(r[0]+r[1]))(n)||(o=-2),o};function or({key:e,key2:t,mode:n,version:o}){const r=n,u=Et({key:e}),l=Et({key2:t});if(i.mode=n=Math.max(u,l),n<0){if(n=Math.min(u,l),g(`${U(n+2)}${U(2)}`),F(o))throw c.firstRun=!1,U(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!F(o)||r>-1&&n>r)&&(sessionStorage.getItem("ifr")!==D&&fo(`v${D} (${tr(n)})`,n),n<2&&g(U(3)),sessionStorage.setItem("ifr",D))}const rr="BackCompat",sr=`<rb>Quirks Mode Detected</>
|
|
23
|
+
|
|
24
|
+
This iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.
|
|
25
|
+
|
|
26
|
+
For more information see <u>https://iframe-resizer.com/quirks-mode</>.
|
|
27
|
+
`;function ir(){document.compatMode===rr&&g(sr)}const cr="complete";let It=!1;function gn(e){document.readyState===cr?Ie(e):It||G(document,Ft,()=>gn(e)),It=!0}const ar=()=>{d(`Set targetOrigin for parent: %c${i.targetOrigin}`,s.HIGHLIGHT),i.autoResize!==!0&&a("Auto Resize disabled")};function pn(){c.taggedElements=document.querySelectorAll(`[${Oe}]`),c.hasTags=c.taggedElements.length>0,a(`Tagged elements found: %c${c.hasTags}`,s.HIGHLIGHT)}const lr=`<rb>Legacy version detected on parent page</>
|
|
28
|
+
|
|
29
|
+
Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
|
|
30
|
+
|
|
31
|
+
See <u>https://iframe-resizer.com/setup/</> for more details.
|
|
32
|
+
`,dr=e=>`<b>Version mismatch</>
|
|
33
|
+
|
|
34
|
+
The parent and child pages are running different versions of <i>iframe resizer</>.
|
|
35
|
+
|
|
36
|
+
Parent page: ${e} - Child page: ${D}.
|
|
37
|
+
`;function ur({version:e}){!e||e===""||e===Zn?g(lr):e!==D&&g(dr(e))}const fr=Kt(()=>g(U(4)));function mr(e){if(!c.timerActive)return;const t=P(performance.now()-c.totalTime),n=e===ze?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`;a(n,s.HIGHLIGHT)}function hr(e){return e===void 0?e=i.targetOrigin:a(`Message targetOrigin: %c${e}`,s.HIGHLIGHT),e}function gr(e,t){const{mode:n}=i,{sameOrigin:o,target:r}=c;if(o)try{window.parent.iframeParentListener(fe+e)}catch(u){if(n===1)fr();else throw u;return!1}else r.postMessage(fe+e,hr(t));return!0}function yn(e,t,n,o,r){const{parentId:u}=i,{sameOrigin:l}=c,p=`${e}:${t}`,v=`${u}:${p}:${n}${o===void 0?"":`:${o}`}`;i.mode<-1||!gr(v,r)||(mr(n),d(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${v}`,s.ITALIC,s.HIGHLIGHT))}const y=Ke((e,t,n,o,r)=>{m(n),yn(e,t,n,o,r),j()}),pr=e=>y(0,0,e.type,`${e.screenY}:${e.screenX}`);function St(e,t){a(`Add event listener: %c${t}`,s.HIGHLIGHT),G(window.document,e,pr)}function yr({mouseEvents:e}){e===!0&&(St(Pn,"Mouse Enter"),St(Dn,"Mouse Leave"))}const br=()=>y(0,0,Cn);function vr({persisted:e}){e||br(),m(Pt),d("Page persisted:",e),!e&&et.forEach(Xn)}const wr=()=>G(window,eo(Pt),vr),Tt=(e,t)=>!(Math.abs(e-t)<=i.tolerance);function zr(e,t){const{calculateHeight:n,calculateWidth:o}=i,{height:r,width:u}=c;return n&&Tt(r,e)||o&&Tt(u,t)}function Or(e){const t=i.onBeforeResize(e);if(t===void 0)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);if(t<J)throw new RangeError(`Out of range value returned from onBeforeResize(): ${t}, must be at least ${J}`);return t}const bn=e=>t=>{const n=e[t]();return e.enabled()&&i.onBeforeResize!==void 0?Or(n):n},Er=bn(O),Ir=bn(E);function Sr(e,t,n,o){const{heightCalcMode:r,widthCalcMode:u}=i,l=n??Er(r),p=o??Ir(u),v=zr(l,p)?dt:e;switch(a(`Resize event: %c${t}`,s.HIGHLIGHT),v){case ze:case Pe:case dt:case Ve:case qe:c.height=l,c.width=p;case Ut:return c;case Ze:case Vt:case Wt:case qt:{a(ft);break}default:d(ft)}return null}let ie=!1,Me=!1,q=null;function Tr(e,t,n,o,r){const{autoResize:u}=i,{isHidden:l}=c;switch(m(e),!0){case l===!0:{if(Me===!0)break;a("Iframe hidden - Ignored resize request"),Me=!0,ie=!1,cancelAnimationFrame(q),q=null;break}case(ie===!0&&e!==Ze&&!(e in ut)):{a("Resize already pending - Ignored resize request");break}case(!u&&!(e in ut)):{d("Resizing disabled");break}default:{Me=!1,ie=!0,c.totalTime=performance.now(),c.timerActive=!0;const p=Sr(e,t,n,o);p&&yn(p.height,p.width,e,r),q||(q=requestAnimationFrame(()=>{ie=!1,q=null,m("requestAnimationFrame"),he(`Reset sendPending: %c${e}`,s.HIGHLIGHT)})),c.timerActive=!1}}j()}const H=Ke(Tr);function Rt({eventType:e,eventName:t}){G(window,t,()=>H(t,e),{passive:!0})}function Rr(){Rt({eventType:"After Print",eventName:"afterprint"}),Rt({eventType:"Before Print",eventName:"beforeprint"})}function Hr(){if(c.triggerLocked){a("TriggerLock blocked calculation");return}c.triggerLocked=!0,he("Trigger event lock on"),requestAnimationFrame(()=>{c.triggerLocked=!1,he("Trigger event lock off")})}function vn(e){const{heightCalcMode:t,widthCalcMode:n}=i,o=O[t](),r=E[n]();a(`Reset trigger event: %c${e}`,s.HIGHLIGHT),y(o,r,e)}function Mr(e){const t=i.heightCalcMode;a(`Reset trigger event: %c${e}`,s.HIGHLIGHT),i.heightCalcMode=Qe,Hr(),vn("reset"),i.heightCalcMode=t}const $r=`Auto Resize can not be changed when <b>direction</> is set to '${Ye}'.`;function Lr(e){T(e,Wn,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:n,calculateWidth:o}=i;return o===!1&&n===!1?(m(Pe),g($r),!1):(e===!0&&t===!1?(i.autoResize=!0,queueMicrotask(()=>H(Pe,"Auto Resize enabled"))):e===!1&&t===!0&&(i.autoResize=!1),y(0,0,Nn,JSON.stringify(i.autoResize)),i.autoResize)}function Ar(e){i.heightCalcMode=e,mn()}function Nr(e){i.widthCalcMode=e,hn()}function Cr(e){T(e,te,"parentIframe.moveToAnchor(anchor) anchor"),c.inPageLinks.findTarget(e)}function Gr(e){T(e,C,"parentIframe.setOffsetSize(offset) offset"),i.offsetHeight=e,i.offsetWidth=e,H(Ut,`parentIframe.setOffsetSize(${e})`)}function kr(){return m("getOrigin"),on("getOrigin()","getParentOrigin()"),c.origin}const Pr=()=>c.origin;function Dr(e){T(e,te,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),a(`Set targetOrigin: %c${e}`,s.HIGHLIGHT),i.targetOrigin=e}function jr(e){if(typeof e===ne){c.onPageInfo=e,y(0,0,Dt),ho("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");return}c.onPageInfo=null,y(0,0,jn)}function wn(e){return T(e,ne,"parentIframe.getParentProps(callback) callback"),c.onParentInfo=e,y(0,0,jt),()=>{c.onParentInfo=null,y(0,0,xn)}}function xr(e){on("getParentProperties()","getParentProps()"),wn(e)}const _r=e=>`<rb>Deprecated API object name</>
|
|
38
|
+
The <b>window.parentIFrame</> object has been renamed to <b>window.parentIframe</>. Please update your code as the old object will be removed in a future version.
|
|
39
|
+
|
|
40
|
+
Called property: '${String(e)}'
|
|
41
|
+
`;function Br(e){const t=new Set;return new Proxy(e,{get(n,o){t.has(o)||(g(_r(o)),t.add(o));const r=n[o],u=Object.getOwnPropertyDescriptor(n,o);return u&&!u.configurable&&!u.writable?r:typeof r=="function"?r.bind(n):r}})}function Fr(e,t){e!==void 0&&T(e,C,"parentIframe.resize(customHeight, customWidth) customHeight"),t!==void 0&&T(t,C,"parentIframe.resize(customHeight, customWidth) customWidth");const n=`${e||""}${t?`,${t}`:""}`;H(Ve,`parentIframe.resize(${n})`,e,t)}const ot=e=>(t,n)=>{T(t,C,`parentIframe.${e}(x, y) x`),T(n,C,`parentIframe.${e}(x, y) y`),y(n,t,e)},Ur=ot(_n),Wr=ot(Bn),Vr=ot(xt);function qr(e,t){t&&T(t,te,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),y(0,0,Ce,JSON.stringify(e),t)}const Zr=()=>y(0,0,Gn),Yr=()=>i.parentId,Qr=()=>Mr("parentIframe.reset"),Jr=()=>R("parentIframe.size() has been renamed parentIframe.resize()");function Kr(){const{win:e}=c;i.mode!==1&&(e.parentIframe=Object.freeze({autoResize:Lr,close:Zr,getId:Yr,getOrigin:kr,getParentOrigin:Pr,getPageInfo:jr,getParentProps:wn,getParentProperties:xr,moveToAnchor:Cr,reset:Qr,setOffsetSize:Gr,scrollBy:Ur,scrollTo:Wr,scrollToOffset:Vr,sendMessage:qr,setHeightCalculationMethod:Ar,setWidthCalculationMethod:Nr,setTargetOrigin:Dr,resize:Fr,size:Jr}),e.parentIFrame=Br(e.parentIframe))}const oe=(e="")=>t=>n=>{n.size>0&&he(`${t}Observer ${e}:`,...Array.from(n).flatMap(o=>[We,o]))},Xr=(e="")=>t=>n=>{n.size>0&&nn(`${t}Observer ${e}:`,...Array.from(n).flatMap(o=>[We,o]))},zn=oe("attached to"),On=Xr("already attached"),es=oe("detached from"),Se=(e,t=!0)=>n=>{n>0&&d(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${n}%c element${n===1?"":"s"}`,s.HIGHLIGHT,s.NORMAL,s.HIGHLIGHT,s.NORMAL)},En=(e,t,n,o)=>{const r=es(e);return u=>{const l=new Set;let p=0;for(const v of u)n.has(v)&&(t.unobserve(v),n.delete(v),l.add(v),p+=1);r(l),o(p),l.clear()}},Ht=16,Mt=2,ts=200,rt="Mutation",I=new Set,N=new Set,xe=new Set,be=[],ns={attributes:!0,attributeFilter:[X,Oe],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let $e=1,st,_e=!1,Be=0;const os=oe("added")(rt),rs=oe("removed (page)")(rt),ss=oe("removed (added)")(rt),In=e=>e.nodeType!==Node.ELEMENT_NODE||Jt.has(e.tagName.toLowerCase());function is(e){const t=e.addedNodes;for(const n of t)In(n)||I.add(n)}function cs(e){const t=e.removedNodes;for(const n of t)In(n)||(I.has(n)?(I.delete(n),xe.add(n)):N.add(n))}const as=e=>{d("Mutations:",e);for(const t of e)is(t),cs(t);os(I),rs(N),ss(xe),xe.clear()};function ls(){N.size>0&&a(`Detected %c${N.size} %cremoved element${N.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND),I.size>0&&a(`Found %c${I.size} %cnew element${I.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND)}const ds=e=>()=>{const t=performance.now(),n=t-Be,o=Ht*$e+++Mt;if(n>o&&n<ts){m("mutationThrottled"),d("Update delayed due to heavy workload on the callStack"),d(`EventLoop busy time: %c${P(n)}ms %c> Max wait: %c${o-Mt}ms`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),setTimeout(st,Ht*$e),Be=t;return}$e=1,be.forEach(as),be.length=0,_e=!1,ls(),e({addedNodes:I,removedNodes:N}),I.clear(),N.clear()};function us(e){be.push(e),!_e&&(Be=performance.now(),_e=!0,requestAnimationFrame(st))}function fs(e){const t=new window.MutationObserver(us),n=document.body||document.documentElement;return st=ds(e),t.observe(n,ns),d("Attached%c MutationObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{...t,disconnect:()=>{I.clear(),N.clear(),be.length=0,t.disconnect(),d("Detached%c MutationObserver",s.HIGHLIGHT)}}}const ms={characterData:!0,childList:!0,subtree:!0};function hs(e){const t=document.querySelector("title")??document.head??document.documentElement,n=new MutationObserver(e);return n.observe(t,ms),d("Attached%c TitleObserver%c to head",s.HIGHLIGHT,s.FOREGROUND),setTimeout(e),{disconnect:()=>{n.disconnect(),d("Detached%c TitleObserver",s.HIGHLIGHT)}}}function gs(e){const t=new IntersectionObserver(o=>e(o.at(-1)?.isIntersecting??!1),{threshold:0}),n=document.documentElement;return t.observe(n),d("Attached%c VisibilityObserver%c to page",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{t.disconnect(),d("Detached%c VisibilityObserver",s.HIGHLIGHT)}}}let $t=new Set;function ps(e){const t=new Set,n=new Set;for(const o of e)o.closest(`[${X}]`)?n.add(o):t.add(o);return n.size>0&&queueMicrotask(()=>{m("overflowIgnored"),d(`Ignoring elements with [data-iframe-ignore] > *:
|
|
42
|
+
`,n),j()}),t}function Sn(){const e=document.querySelectorAll(`[${_t}]`),t=ps(e);let n=!1;return typeof Set.prototype.symmetricDifference===ne&&(n=t.symmetricDifference($t).size>0),$t=t,c.overflowedNodeSet=t,c.hasOverflow=t.size>0,{hasOverflowUpdated:n,overflowedNodeSet:t}}const S={},Tn=e=>{const t=new Set;for(const n of e){t.add(n);for(const o of tt(n))t.add(o)}return d(`Inspecting:
|
|
43
|
+
`,t),t},ys=e=>{if(e.size===0)return;m("addObservers");const t=Tn(e);S.overflow.attachObservers(t),S.resize.attachObserverToNonStaticElements(t),j()},bs=e=>{if(e.size===0)return;m("removeObservers");const t=Tn(e);S.overflow.detachObservers(t),S.resize.detachObservers(t),j()};function vs({addedNodes:e,removedNodes:t}){m("contentMutated"),c.applySelectors(),pn(),Sn(),j(),bs(t),ys(e)}function ws(e){vs(e),H(Vt,"Mutation Observed")}const re="Overflow",zs=Se(re),Os=Se(re,!1),Es=zn(re),Is=On(re),Ss=e=>e.hidden||e.offsetParent===null||e.style.display===Ye,Ts=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||me,u=(z=!1)=>e(z),l=(z,M)=>z===0||z>M[n],p=(z,M)=>z.toggleAttribute(_t,M);function v(z){for(const M of z){const{boundingClientRect:W,rootBounds:V,target:$}=M;if(!V)continue;const $n=W[n],Ln=l($n,V)&&!Ss($);p($,Ln)}r(u)}const f=new IntersectionObserver(v,o),w=new WeakSet;function h(z){const M=new Set,W=new Set;let V=0;for(const $ of z)if($.nodeType===Node.ELEMENT_NODE){if(w.has($)){M.add($);continue}f.observe($),w.add($),W.add($),V+=1}Is(M),Es(W),zs(V),W.clear(),M.clear()}return{attachObservers:h,detachObservers:En(re,f,w,Os),disconnect:()=>{f.disconnect(),d("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function Rs(){const{hasOverflow:e}=c,{hasOverflowUpdated:t,overflowedNodeSet:n}=Sn();switch(!0){case!t:return;case n.size>1:d("Overflowed Elements:",n);break;case e:break;default:d("No overflow detected")}H(Ze,"Overflow updated")}function Hs(e){const t={root:document.documentElement,side:i.calculateHeight?Ge:ke};return S.overflow=Ts(Rs,t),S.overflow.attachObservers(e),S.overflow}const se="Resize",Ms=Se(se),$s=Se(se,!1),Ls=zn(se),As=On(se),ve=new WeakSet,Le=new Set,Ae=new Set;let Q;function Ns(e){let t=0;for(const n of e){if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=getComputedStyle(n)?.position;if(!(o===""||o==="static")){if(ve.has(n)){Le.add(n);continue}Q.observe(n),ve.add(n),Ae.add(n),t+=1}}As(Le),Ls(Ae),Ms(t),Ae.clear(),Le.clear()}const Cs=e=>(Q=new ResizeObserver(e),Q.observe(document.body),ve.add(document.body),d("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:Ns,detachObservers:En(se,Q,ve,$s),disconnect:()=>{Q.disconnect(),d("Detached%c ResizeObserver",s.HIGHLIGHT)}});function Gs(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;H(Wt,`Element resized <${to(t)}>`)}function ks(e){return S.resize=Cs(Gs),S.resize.attachObserverToNonStaticElements(e),S.resize}let Lt;function Ps(){const e=document.title;e!==Lt&&(Lt=e,a(`Title: %c${e}`,s.HIGHLIGHT),e&&y(0,0,Fn,e))}function Ds(e){a(`Visible: %c${e}`,s.HIGHLIGHT),c.isHidden=!e,H(qt,"Visibility changed")}function js(e){et.push(...e.map(t=>t.disconnect))}function xs(){m("attachObservers");const e=tt(document.documentElement),t=[fs(ws),Hs(e),Bo(),ks(e),hs(Ps),gs(Ds)];js(t)}const At=(e,t,n)=>{if(n!==""){a(`${e}: %c${n}`,s.HIGHLIGHT);for(const o of document.querySelectorAll(n))a(`Applying ${t} to:`,o),o.toggleAttribute(t,!0)}};function _s({sizeSelector:e,ignoreSelector:t}){return()=>{At("sizeSelector",Oe,e),At("ignoreSelector",X,t)}}function Bs(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Fs(e,t){return t.includes("-")&&(R(`Negative CSS value ignored for ${e}`),t=""),t}function Fe(e,t){t===void 0||t===""||t===Yn||(document.body.style.setProperty(e,t),d(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Us({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),Fe("margin",Fs("margin",e))}const Ws=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function Vs(e){const t=e.getBoundingClientRect(),n=Ws();return{x:parseInt(t.left,B)+parseInt(n.x,B),y:parseInt(t.top,B)+parseInt(n.y,B)}}function qs(e,t){const n=Vs(t);a(`Moving to in page link (%c#${e}%c) at x: %c${n.x}%c y: %c${n.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),y(n.y,n.x,xt)}function it(e){const t=e.split("#")[1]||e,n=decodeURIComponent(t),o=document.getElementById(n)||document.getElementsByName(n)[0];if(o!==void 0){qs(t,o);return}a(`In page link (#${t}) not found in iframe, so sending to parent`),y(0,0,kn,`#${t}`)}function Rn(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&it(t)}function Zs(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&G(e,"click",t=>{t.preventDefault(),it(e.getAttribute("href"))})}function Ys(){G(window,"hashchange",Rn)}function Qs(){setTimeout(Rn,Qt)}function Js(){a("Setting up location.hash handlers"),Zs(),Ys(),Qs(),c.inPageLinks={findTarget:it}}function Ks(e){const{mode:t}=i;e?t===1?g(U(5)):Js():a("In page linking not enabled")}const Xs="important";function ei(){const e=t=>t.style.setProperty(ee,Ee,Xs);e(document.documentElement),e(document.body),a("Set HTML & body height: %cauto !important",s.HIGHLIGHT)}const ti="custom",ni=e=>`<rb>Deprecated Option(${e}CalculationMethod)</>
|
|
44
|
+
|
|
45
|
+
The use of <b>${e}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.
|
|
46
|
+
|
|
47
|
+
See <u>https://iframe-resizer.com/api/child</> for more details.
|
|
48
|
+
`;function Nt(e,t){return typeof e!==ne?e:(g(ni(t)),t===ee?O.custom=e:E.custom=e,ti)}const ct=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Ne=ct(ne),ce=ct(C),ae=ct(te),oi=e=>e!==null&&typeof e===Vn&&!Array.isArray(e);function ri(e){const{calculateHeight:t,calculateWidth:n}=i;let o,r;return typeof e?.offset===C&&(go(Re,He),t&&(o=ce(e,Re)),n&&(r=ce(e,Re))),typeof e?.offsetSize===C&&(t&&(o=ce(e,He)),n&&(r=ce(e,He))),{offsetHeight:o,offsetWidth:r}}function si(e){a("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:n}=ri(e);return{offsetHeight:t,offsetWidth:n,ignoreSelector:ae(e,"ignoreSelector"),key2:ae(e,nr(0)),sizeSelector:ae(e,"sizeSelector"),targetOrigin:ae(e,"targetOrigin"),heightCalcMode:Nt(e?.heightCalculationMethod,ee),widthCalcMode:Nt(e?.widthCalculationMethod,Bt),onBeforeResize:Ne(e,"onBeforeResize"),onMessage:Ne(e,"onMessage"),onReady:Ne(e,"onReady")}}function ii(){const{mode:e}=i;if(e===1)return{};const t=window.iframeResizer||window.iFrameResizer;return oi(t)?si(t):{}}const ci=e=>e==="true",Hn=e=>t=>t===void 0?void 0:e(t),k=Hn(ci),Z=Hn(Number),ai=e=>({parentId:e[0],bodyMargin:Z(e[1]),calculateWidth:k(e[2]),logging:k(e[3]),autoResize:k(e[6]),bodyMarginStr:e[7],heightCalcMode:e[8],bodyBackground:e[9],bodyPadding:e[10],tolerance:Z(e[11]),inPageLinks:k(e[12]),widthCalcMode:e[14],mouseEvents:k(e[15]),offsetHeight:Z(e[16]),offsetWidth:Z(e[17]),calculateHeight:k(e[18]),key:e[19],version:e[20],mode:Z(e[21]),logExpand:k(e[23])});function li(e){const{mode:t}=i;e.forEach(n=>{try{n()}catch(o){if(t<0)throw o;g(`<rb>Error in setup function</>
|
|
49
|
+
<i>iframe-resizer</> detected an error during setup.
|
|
50
|
+
|
|
51
|
+
Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),nn(o)}})}function Ct(e){for(const[t,n]of Object.entries(e))n!==void 0&&(i[t]=n)}function di({logExpand:e,logging:t,parentId:n}){uo({id:n,enabled:t,expand:e}),m("initReceived"),a(`Initialising iframe v${D} ${window.location.href}`)}function ui(e){m("ready"),gn(Kt(e)),a("Initialization complete",(({key:t,key2:n,...o})=>o)(i))}function fi({bodyBackground:e,bodyPadding:t,inPageLinks:n,onReady:o}){const r=Mo(i),u=[()=>ur(i),()=>or(i),Ko,Zo,mn,hn,Qo,ir,pn,ar,r?me:Ho,()=>Us(i),()=>Fe("background",e),()=>Fe("padding",t),r?me:ei,Bs,c.applySelectors,()=>Ks(n),Rr,()=>yr(i),wr,()=>Kr(),()=>H(ze,"Init message from host page",void 0,void 0,`${D}:${i.mode}`),xs,j];li(u),ui(o)}function mi(e){c.firstRun&&(Ct(ai(e)),di(i),Ct(ii()),c.applySelectors=_s(i),fi(i))}function hi(e){if(document.readyState==="loading"){a("Page not ready, ignoring init message");return}const t=e.data.slice(Zt).split(we);c.target=e.source,c.origin=e.origin,mi(t),c.firstRun=!1,setTimeout(()=>{c.initLock=!1},Qt)}const{freeze:gi}=Object,{parse:at}=JSON,lt=e=>gi(at(e)),Mn=e=>y(0,0,`${e}Stop`),Te=e=>e.data.slice(e.data.indexOf(we)+1),pi=e=>bo(e)?ze:e.data.split("]")[1].split(we)[0];function yi(e){const t=Te(e);a("onMessage called from parent:%c",s.HIGHLIGHT,lt(t)),Ie(i.onMessage,at(t))}function bi(e){const{onPageInfo:t}=c,n=Te(e);a("PageInfo received from parent:",lt(n)),t?Ie(t,at(n)):Mn(Dt)}function vi(e){const{onParentInfo:t}=c,n=lt(Te(e));a("ParentInfo received from parent:",n),t?Ie(t,n):Mn(jt)}function wi(){if(c.initLock){a("Page reset ignored by init");return}a("Page size reset by host page"),vn("resetPage")}function zi(){a("Resize requested by host page"),H(qe,"Parent window requested size check")}const Gt=e=>c.inPageLinks.findTarget(Te(e)),kt={init:hi,reset:wi,resize:zi,moveToAnchor:Gt,inPageLink:Gt,pageInfo:bi,parentInfo:vi,message:yi};function Oi(e){const{firstRun:t}=c,n=pi(e);switch(m(n),!0){case n in kt:kt[n](e);break;case(t&&yo()):R(`Ignored message of type "${n}". Received before initialization.`);break;default:R(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const le=Ke(e=>{po(e)&&Oi(e)});function Ei(){if("iframeChildListener"in window){R("Already setup");return}window.iframeChildListener=t=>setTimeout(()=>le({data:t,sameOrigin:!0})),m("listen"),G(window,Ce,le),G(document,Ft,pt),pt();function e(t){return le(t),c.win}try{top?.document?.getElementById("banner")&&(c.win={},window.mockMsgListener=e,sn(window,Ce,le),typeof window.define=="function"&&window.define([],()=>e))}catch{}}typeof window!==qn&&Ei();
|
|
52
|
+
//# sourceMappingURL=index.cjs.js.map
|