@iframe-resizer/child 6.0.0-beta.4 → 6.0.0-beta.6

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.esm.js CHANGED
@@ -1,1275 +1,21 @@
1
- import { LABEL as Ne, BOLD as vn, CHILD_READY_MESSAGE as En, MESSAGE_ID as Re, MESSAGE_ID_LENGTH as zt, SEPARATOR as fe, AUTO as se, NONE as Le, IGNORE_ATTR as j, VERSION as Y, READY_STATE_CHANGE as $t, SIZE_ATTR as Ce, FALSE as On, INIT as ue, MOUSE_ENTER as yn, MOUSE_LEAVE as Sn, PAGE_HIDE as It, BEFORE_UNLOAD as Rn, MIN_SIZE as W, HEIGHT as me, IGNORE_TAGS as At, HEIGHT_EDGE as Pe, WIDTH as kt, WIDTH_EDGE as Nt, NO_CHANGE as et, VISIBILITY_OBSERVER as Lt, RESIZE_OBSERVER as Ct, MUTATION_OBSERVER as Pt, OVERFLOW_OBSERVER as _e, SET_OFFSET_SIZE as _t, PARENT_RESIZE_REQUEST as Dt, MANUAL_RESIZE_REQUEST as Bt, SIZE_CHANGE_DETECTED as tt, ENABLE as Me, IGNORE_DISABLE_RESIZE as we, HEIGHT_CALC_MODE_DEFAULT as Mn, BOOLEAN as Tn, AUTO_RESIZE as zn, STRING as ge, NUMBER as P, FUNCTION as De, PARENT_INFO as xt, PARENT_INFO_STOP as $n, SCROLL_BY as In, SCROLL_TO as An, SCROLL_TO_OFFSET as Ft, MESSAGE as Te, CLOSE as kn, NEW_LINE as Ht, OVERFLOW_ATTR as Vt, TITLE as Nn, NULL as Ln, EVENT_CANCEL_TIMER as Gt, IN_PAGE_LINK as Cn, OBJECT as Pn, OFFSET_SIZE as nt, PAGE_INFO as _n, UNDEFINED as Dn } from "@iframe-resizer/common/consts";
2
- import Bn from "@iframe-resizer/common/deprecate";
3
- import xn from "@iframe-resizer/common/format-advise";
4
- import { esModuleInterop as Fn, id as ie, isDef as ne, isolateUserCode as he, once as Ut, round as C, lower as Hn, invoke as Vn, capitalizeFirstLetter as Gn, typeAssert as T, getElementName as Un } from "@iframe-resizer/common/utils";
5
- import Wn, { NORMAL as q, HIGHLIGHT as c, FOREGROUND as w, BOLD as ot, ITALIC as qn } from "auto-console-group";
6
- import rt, { getModeData as I, getModeLabel as Zn, checkMode as Be, getKey as st } from "@iframe-resizer/common/mode";
7
- let xe = !0, it = Ne;
8
- const jn = Fn(Wn), Z = jn({
9
- label: `${Ne}(child)`,
10
- expand: !1
11
- });
12
- function Yn(e) {
13
- it = e.id || Ne, Z.label(`${it}`), Z.expand(e.expand), xe = e.enabled;
14
- }
15
- const Wt = (e) => (...t) => xe ? Z[e](...t) : !0, a = Wt("log"), l = a, ce = Wt("debug");
16
- function Qn(e, t) {
17
- console.info(`%ciframe-resizer ${e}`, xe || t < 1 ? vn : q);
18
- }
19
- const {
20
- assert: Jn,
21
- endAutoGroup: _,
22
- error: qt,
23
- errorBoundary: Fe,
24
- event: g,
25
- label: Js,
26
- purge: Ks,
27
- warn: x
28
- } = Z, Zt = xn(ie), O = (...e) => Z.warn(...e.map(Zt)), Kn = (...e) => (
29
- // eslint-disable-next-line no-console
30
- console.warn(...e.map(Zt))
31
- ), He = Bn((e, t) => O(t));
32
- He("Method");
33
- He("Method", "replaced with");
34
- He("Option");
35
- const Ve = [];
36
- function jt(e, t) {
37
- a(`${e} event listener: %c${t}`, c);
38
- }
39
- const Yt = (e, t, n, o) => {
40
- e.removeEventListener(t, n, o), jt("Removed", t);
41
- }, N = (e, t, n, o = !1) => {
42
- e.addEventListener(t, n, o), Ve.push(() => Yt(e, t, n, o)), jt("Added", t);
43
- }, s = {
44
- applySelectors: null,
45
- firstRun: !0,
46
- hasTags: !1,
47
- hasOverflow: !1,
48
- height: 0,
49
- isHidden: !1,
50
- initLock: !0,
51
- inPageLinks: {},
52
- origin: void 0,
53
- hasOverflowUpdated: !0,
54
- overflowedNodeSet: /* @__PURE__ */ new Set(),
55
- sameOrigin: !1,
56
- taggedElements: [],
57
- target: window?.parent,
58
- timerActive: !1,
59
- totalTime: 0,
60
- triggerLocked: !1,
61
- width: 0,
62
- win: window,
63
- onPageInfo: null,
64
- onParentInfo: null
65
- };
66
- let ct = !1;
67
- function at(e) {
68
- const t = window?.iframeResizer?.targetOrigin || "*", n = Array.isArray(t) ? t : [t];
69
- for (const o of n)
70
- e.postMessage(En, o);
71
- }
72
- function dt() {
73
- if (document.readyState === "loading" || !s.firstRun || ct) return;
74
- const { parent: e, top: t } = window;
75
- g("ready"), a(
76
- "Sending%c ready%c to parent from",
77
- c,
78
- w,
79
- window.location.href
80
- ), at(e), e !== t && at(t), ct = !0;
81
- }
82
- const lt = "iframeResize", Xn = (e) => Re === `${e.data}`.slice(0, zt), eo = () => lt in window || // @ts-ignore
83
- window.jQuery !== void 0 && lt in window.jQuery.prototype, to = (e) => e.data.split(fe)[2] in { true: 1, false: 1 }, no = () => [document.documentElement, document.body], oo = ["min-height", "min-width", "max-height", "max-width"], ft = /* @__PURE__ */ new Set(), ro = (e) => !!e && e !== "0px" && e !== se && e !== Le, Qt = (e) => e.tagName ? e.tagName.toLowerCase() : "unknown", Jt = (e, t) => window.getComputedStyle(e).getPropertyValue(t), so = (e, t) => ro(Jt(e, t));
84
- function io(e, t) {
85
- const n = e.style.getPropertyValue(t);
86
- return n ? { source: "an inline style attribute", value: n } : null;
87
- }
88
- function co({
89
- href: e
90
- }) {
91
- ft.has(e) || (a("Unable to access stylesheet:", e), ft.add(e));
92
- }
93
- function ao(e, t) {
94
- for (const n of document.styleSheets)
95
- try {
96
- for (const o of n.cssRules || []) {
97
- if (!("selectorText" in o)) continue;
98
- const r = o;
99
- if (!e.matches(r.selectorText)) continue;
100
- const f = r.style.getPropertyValue(t);
101
- if (!f) continue;
102
- const { ownerNode: d } = n;
103
- return {
104
- source: d instanceof Element && d.tagName === "STYLE" ? "an inline <style> block" : `stylesheet (${n.href})`,
105
- value: f
106
- };
107
- }
108
- } catch {
109
- co(n);
110
- }
111
- return {
112
- source: "cross-origin stylesheet",
113
- value: Jt(e, t)
114
- };
115
- }
116
- const lo = (e, t) => io(e, t) || ao(e, t), fo = (e, t) => {
117
- const { source: n, value: o } = lo(e, t), r = Qt(e);
118
- O(
119
- `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</>.
120
-
121
- 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.`
122
- );
123
- };
124
- function uo() {
125
- for (const e of no())
126
- for (const t of oo)
127
- a(`Checking <${Qt(e)}> for blocking CSS: ${t}`), so(e, t) && fo(e, t);
128
- }
129
- const mo = ({
130
- calculateWidth: e,
131
- calculateHeight: t
132
- }) => e === t, i = {
133
- autoResize: !0,
134
- bodyBackground: "",
135
- bodyMargin: 0,
136
- // For V1 compatibility
137
- bodyMarginStr: "",
138
- bodyPadding: "",
139
- calculateHeight: !0,
140
- calculateWidth: !1,
141
- heightCalcMode: se,
142
- ignoreSelector: "",
143
- inPageLinks: !1,
144
- logging: !1,
145
- logExpand: !1,
146
- mode: 0,
147
- mouseEvents: !1,
148
- offsetHeight: 0,
149
- offsetWidth: 0,
150
- parentId: void 0,
151
- sizeSelector: "",
152
- targetOrigin: "*",
153
- tolerance: 0,
154
- widthCalcMode: se,
155
- onBeforeResize: void 0,
156
- onMessage: () => {
157
- x("onMessage function not defined");
158
- },
159
- onReady: () => {
160
- }
161
- };
162
- function go() {
163
- try {
164
- s.sameOrigin = i.mode === 1 || "iframeParentListener" in window.parent;
165
- } catch {
166
- a("Cross domain iframe detected");
167
- }
168
- }
169
- let ut = 0;
170
- function ho(e) {
171
- const t = e.length === 1 ? "" : "s";
172
- x(
173
- `%c[${j}]%c found on %c${e.length}%c element${t}`,
174
- ot,
175
- q,
176
- ot,
177
- q
178
- );
179
- }
180
- function po() {
181
- const e = document.querySelectorAll(`*[${j}]`), t = e.length > 0;
182
- return t && e.length !== ut && (ho(e), ut = e.length), t;
183
- }
184
- function bo(e, t, n) {
185
- (!ne(n) || t > -1 && e > t) && (Qn(`v${Y} (${Zn(e)})`, e), e === 0 && Kn(I(3)));
186
- }
187
- function wo({
188
- key: e,
189
- key2: t,
190
- mode: n,
191
- version: o
192
- }) {
193
- const r = n, f = ne(e) ? rt({ key: e }) : -1, d = ne(t) ? rt({ key: t }) : -1;
194
- let u;
195
- switch (n = Math.max(f, d), n) {
196
- case -2:
197
- case -1:
198
- u = `${I(Math.min(f, d) + 2)}${I(2)}`, s.firstRun = !1;
199
- break;
200
- case 1:
201
- case 2:
202
- case 3:
203
- u = I(6);
204
- break;
205
- case 4:
206
- u = I(7);
207
- break;
208
- case 5:
209
- u = I(8);
210
- break;
211
- }
212
- if (n >= 0 && bo(n, r, o), (!ne(o) || !s.firstRun) && (u && O(u), n < 0))
213
- throw O(I(9)), u.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi, "");
214
- i.mode = n;
215
- }
216
- const vo = "BackCompat", Eo = `<rb>Quirks Mode Detected</>
217
-
218
- 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</>.
219
-
220
- For more information see <u>https://iframe-resizer.com/quirks-mode</>.
221
- `;
222
- function Oo() {
223
- document.compatMode === vo && O(Eo);
224
- }
225
- const yo = "complete";
226
- let mt = !1;
227
- function Kt(e) {
228
- document.readyState === yo ? he(e) : mt || N(
229
- document,
230
- $t,
231
- () => Kt(e)
232
- ), mt = !0;
233
- }
234
- const So = () => {
235
- l(`Set targetOrigin for parent: %c${i.targetOrigin}`, c), i.autoResize !== !0 && a("Auto Resize disabled");
236
- };
237
- function Xt() {
238
- s.taggedElements = document.querySelectorAll(`[${Ce}]`), s.hasTags = s.taggedElements.length > 0, a(`Tagged elements found: %c${s.hasTags}`, c);
239
- }
240
- const Ro = `<rb>Legacy version detected on parent page</>
241
-
242
- Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
243
-
244
- See <u>https://iframe-resizer.com/setup/</> for more details.
245
- `, Mo = (e) => `<b>Version mismatch</>
246
-
247
- The parent and child pages are running different versions of <i>iframe resizer</>.
248
-
249
- Parent page: ${e} - Child page: ${Y}.
250
- `;
251
- function To({ version: e }) {
252
- !e || e === "" || e === On ? O(Ro) : e !== Y && O(Mo(e));
253
- }
254
- const zo = Ut(() => O(I(4)));
255
- function $o(e) {
256
- if (!s.timerActive) return;
257
- const t = C(performance.now() - s.totalTime), n = e === ue ? `Initialised iframe in %c${t}ms` : `Size calculated in %c${t}ms`;
258
- a(n, c);
259
- }
260
- function Io(e) {
261
- return e === void 0 ? e = i.targetOrigin : a(`Message targetOrigin: %c${e}`, c), e;
262
- }
263
- function Ao(e, t) {
264
- const { mode: n } = i, { sameOrigin: o, target: r } = s;
265
- if (o)
266
- try {
267
- window.parent.iframeParentListener(Re + e);
268
- } catch (f) {
269
- if (Be(n)) zo();
270
- else throw new Error(f);
271
- return !1;
272
- }
273
- else {
274
- Jn(r, "Internal error: postMessage target is undefined");
275
- const f = Io(t), d = Array.isArray(f) ? f : [f];
276
- for (const u of d)
277
- r.postMessage(Re + e, u);
278
- }
279
- return !0;
280
- }
281
- function en(e, t, n, o, r) {
282
- const { parentId: f } = i, { sameOrigin: d } = s, u = `${e}:${t}`, b = `${f}:${u}:${n}${o === void 0 ? "" : `:${o}`}`;
283
- i.mode < -1 || !Ao(b, r) || ($o(n), l(
284
- `Sending message to parent page via ${d ? "sameOrigin" : "postMessage"}: %c%c${b}`,
285
- qn,
286
- c
287
- ));
288
- }
289
- const v = Fe(
290
- (e, t, n, o, r) => {
291
- g(n), en(e, t, n, o, r), _();
292
- }
293
- ), ko = (e) => v(0, 0, e.type, `${e.screenY}:${e.screenX}`);
294
- function gt(e, t) {
295
- a(`Add event listener: %c${t}`, c), N(window.document, e, ko);
296
- }
297
- function No({
298
- mouseEvents: e
299
- }) {
300
- e === !0 && (gt(yn, "Mouse Enter"), gt(Sn, "Mouse Leave"));
301
- }
302
- const Lo = () => v(0, 0, Rn);
303
- function Co({ persisted: e }) {
304
- e || Lo(), g(It), l("Page persisted:", e), !e && Ve.forEach(Vn);
305
- }
306
- const Po = () => N(window, Hn(It), Co), ht = (e, t) => !(Math.abs(e - t) <= i.tolerance);
307
- function _o(e, t) {
308
- const { calculateHeight: n, calculateWidth: o } = i, { height: r, width: f } = s;
309
- return n && ht(r, e) || o && ht(f, t);
310
- }
311
- const A = [c, w, c], oe = {
312
- height: 0,
313
- width: 0
314
- }, B = {
315
- height: 0,
316
- width: 0
317
- };
318
- function D(e, t, n) {
319
- return B[e] = t, oe[e] = n, t;
320
- }
321
- function Do(e) {
322
- const t = e.getOffset();
323
- return t !== 0 && l(`Page offsetSize: %c${t}px`, c), t;
324
- }
325
- const Bo = (e) => e.documentElementScroll() + Math.max(0, e.getOffset());
326
- function tn(e) {
327
- const { hasOverflow: t, hasTags: n, triggerLocked: o } = s, r = e.label, f = r === me, d = e.boundingClientRect(), u = Math.ceil(d), b = Math.floor(d), m = Bo(e), E = `HTML: %c${d}px %cPage: %c${m}px`;
328
- let h;
329
- switch (!0) {
330
- case !e.enabled():
331
- return Math.max(m, W);
332
- case n:
333
- l("Found element with data-iframe-size attribute"), h = e.taggedElement();
334
- break;
335
- case (!t && s.firstRun && B[r] === 0 && oe[r] === 0):
336
- l(`Initial page size values: ${E}`, ...A), h = D(
337
- r,
338
- d,
339
- m
340
- );
341
- break;
342
- case (o && d === B[r] && m === oe[r]):
343
- l(`Size unchanged: ${E}`, ...A), h = Math.max(d, m);
344
- break;
345
- case (d === 0 && m !== 0):
346
- l(`Page is hidden: ${E}`, ...A), h = m;
347
- break;
348
- case (!t && d !== B[r] && m <= oe[r]):
349
- l(`New <html> size: ${E} `, ...A), l(
350
- `Previous <html> size: %c${B[r]}px`,
351
- c
352
- ), h = D(
353
- r,
354
- d,
355
- m
356
- );
357
- break;
358
- case !f:
359
- h = e.taggedElement();
360
- break;
361
- case (!t && d < B[r]):
362
- l(`<html> size decreased: ${E}`, ...A), h = D(
363
- r,
364
- d,
365
- m
366
- );
367
- break;
368
- case (m === b || m === u):
369
- l(`<html> size equals page size: ${E}`, ...A), h = D(
370
- r,
371
- d,
372
- m
373
- );
374
- break;
375
- case d > m:
376
- l(`Page size < <html> size: ${E}`, ...A), h = D(
377
- r,
378
- d,
379
- m
380
- );
381
- break;
382
- case t:
383
- l("Found elements possibly overflowing <html> "), h = e.taggedElement();
384
- break;
385
- default:
386
- l(`Using <html> size: ${E}`, ...A), h = D(
387
- r,
388
- d,
389
- m
390
- );
391
- }
392
- return l(`Content ${r}: %c${h}px`, c), h += Do(e), Math.max(h, W);
393
- }
394
- const xo = 1e3, Fo = 5 * xo, Ho = 4, Vo = 10, Go = 100, Ge = "--ifr-start", ae = "--ifr-end", nn = "--ifr-measure", p = [];
395
- let re = {}, pt = 0, ze;
396
- function on() {
397
- try {
398
- performance.clearMarks(Ge), performance.clearMarks(ae), performance.clearMeasures(nn);
399
- } catch {
400
- }
401
- }
402
- function Uo() {
403
- ze = setInterval(() => {
404
- if (p.length < Vo || re.hasTags && re.len < 25) return;
405
- p.sort();
406
- const e = Math.min(
407
- p.reduce((n, o) => n + o, 0) / p.length,
408
- p[Math.floor(p.length / 2)]
409
- ), t = C(e);
410
- t > pt && (pt = t, g("performanceObserver"), a("Mean time:", C(p[Math.floor(p.length / 2)])), a(
411
- "Median time:",
412
- C(p.reduce((n, o) => n + o, 0) / p.length)
413
- ), a("Average time:", t), a("Max time:", C(Math.max(...p)))), on(), !(e <= Ho) && (clearInterval(ze), O(
414
- `<rb>Performance Warning</>
415
-
416
- Calculating the page size is taking an excessive amount of time (${C(e)}ms).
417
-
418
- To improve performance add the <b>data-iframe-size</> attribute to the ${re.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`
419
- ));
420
- }, Fo);
421
- }
422
- function Wo(e) {
423
- e.getEntries().forEach((t) => {
424
- if (t.name === ae)
425
- try {
426
- const { duration: n } = performance.measure(
427
- nn,
428
- Ge,
429
- ae
430
- );
431
- re = t.detail, p.push(n), p.length > Go && p.shift();
432
- } catch {
433
- }
434
- });
435
- }
436
- function qo() {
437
- l("Attached%c PerformanceObserver%c to page", c, w);
438
- const e = new PerformanceObserver(Wo);
439
- return e.observe({ entryTypes: ["mark"] }), Uo(), {
440
- disconnect: () => {
441
- on(), clearInterval(ze), e.disconnect(), l("Detached%c PerformanceObserver", c);
442
- }
443
- };
444
- }
445
- const Zo = (e) => `:not(${e})`, jo = `* ${Array.from(At).map(Zo).join("")}`, Ue = (e) => e.querySelectorAll(jo);
446
- function Yo() {
447
- const { hasOverflow: e, hasTags: t, overflowedNodeSet: n, taggedElements: o } = s;
448
- return t ? o : e ? Array.from(n) : Ue(document.documentElement);
449
- }
450
- function Qo(e, t) {
451
- const n = `margin-${t}`;
452
- let o, r = document.documentElement, f = s.hasTags ? W : document.documentElement.getBoundingClientRect().bottom;
453
- for (const d of e)
454
- o = d.getBoundingClientRect()[t] + parseFloat(getComputedStyle(d).getPropertyValue(n)), o > f && (f = o, r = d);
455
- return { maxEl: r, maxVal: f };
456
- }
457
- function rn(e) {
458
- performance.mark(Ge);
459
- const t = Gn(e), { logging: n } = i, { hasTags: o } = s, r = Yo(), { maxEl: f, maxVal: d } = Qo(r, e);
460
- return l(`${t} position calculated from:`, f), l(`Checked %c${r.length}%c elements`, c, w), performance.mark(ae, {
461
- detail: {
462
- hasTags: o,
463
- len: r.length,
464
- logging: n,
465
- Side: t
466
- }
467
- }), d;
468
- }
469
- const We = {
470
- label: me,
471
- enabled: () => i.calculateHeight,
472
- getOffset: () => i.offsetHeight,
473
- auto: () => tn(We),
474
- boundingClientRect: () => Math.max(
475
- document.documentElement.getBoundingClientRect().bottom,
476
- document.body.getBoundingClientRect().bottom
477
- ),
478
- documentElementScroll: () => document.documentElement.scrollHeight,
479
- taggedElement: () => rn(Pe)
480
- }, qe = {
481
- label: kt,
482
- enabled: () => i.calculateWidth,
483
- getOffset: () => i.offsetWidth,
484
- auto: () => tn(qe),
485
- boundingClientRect: () => Math.max(
486
- document.documentElement.getBoundingClientRect().right,
487
- document.body.getBoundingClientRect().right
488
- ),
489
- documentElementScroll: () => document.documentElement.scrollWidth,
490
- taggedElement: () => rn(Nt)
491
- };
492
- function Jo(e, t, n) {
493
- const o = i.onBeforeResize(e, t, n);
494
- if (o === void 0)
495
- throw new TypeError(
496
- "No value returned from onBeforeResize(), expected a numeric value"
497
- );
498
- if (Number.isNaN(o))
499
- throw new TypeError(
500
- `Invalid value returned from onBeforeResize(): ${o}, expected Number`
501
- );
502
- if (o < W)
503
- throw new RangeError(
504
- `Out of range value returned from onBeforeResize(): ${o}, must be at least ${W}`
505
- );
506
- return o;
507
- }
508
- const sn = (e, t) => (n, o) => {
509
- const r = e[n]();
510
- return e.enabled() && i.onBeforeResize !== void 0 ? Jo(r, o, t) : r;
511
- }, Ko = sn(We, me), Xo = sn(qe, kt);
512
- function er() {
513
- (window.scrollY !== 0 || window.scrollX !== 0) && (l("Reset iframe scroll position to (0, 0)"), window.scrollTo(0, 0));
514
- }
515
- function tr(e, t, n, o) {
516
- const { heightCalcMode: r, widthCalcMode: f } = i;
517
- er();
518
- const d = n ?? Ko(r, e), u = o ?? Xo(f, e), b = _o(d, u) ? tt : e;
519
- switch (a(`Resize event: %c${t}`, c), b) {
520
- case ue:
521
- case Me:
522
- case tt:
523
- case Bt:
524
- case Dt:
525
- s.height = d, s.width = u;
526
- // eslint-disable-next-line no-fallthrough
527
- case _t:
528
- return s;
529
- // the following case needs {} to prevent a compile error on Next.js
530
- case _e:
531
- case Pt:
532
- case Ct:
533
- case Lt: {
534
- a(et);
535
- break;
536
- }
537
- default:
538
- l(et);
539
- }
540
- return null;
541
- }
542
- let X = !1, ve = !1, V = null;
543
- function nr(e, t, n, o, r) {
544
- const { autoResize: f } = i, { isHidden: d } = s;
545
- switch (g(e), !0) {
546
- // Allow manual and parent resize requests to bypass the hidden check
547
- case (d === !0 && !(e in we)): {
548
- if (ve === !0) break;
549
- a("Iframe hidden - Ignored resize request"), ve = !0, X = !1, cancelAnimationFrame(V), V = null;
550
- break;
551
- }
552
- // Ignore overflowObserver here, as more efficient than using
553
- // mutationObserver to detect OVERFLOW_ATTR changes
554
- // Also allow manual and parent resize requests to bypass the pending check
555
- case (X === !0 && e !== _e && !(e in we)): {
556
- a("Resize already pending - Ignored resize request");
557
- break;
558
- }
559
- case (!f && !(e in we)): {
560
- l("Resizing disabled");
561
- break;
562
- }
563
- default: {
564
- ve = !1, X = !0, s.totalTime = performance.now(), s.timerActive = !0;
565
- const u = tr(
566
- e,
567
- t,
568
- n,
569
- o
570
- );
571
- u && en(u.height, u.width, e, r), V || (V = requestAnimationFrame(() => {
572
- X = !1, V = null, g("requestAnimationFrame"), ce(`Reset sendPending: %c${e}`, c);
573
- })), s.timerActive = !1;
574
- }
575
- }
576
- _();
577
- }
578
- const z = Fe(nr);
579
- function bt({
580
- eventType: e,
581
- eventName: t
582
- }) {
583
- N(window, t, () => z(t, e), { passive: !0 });
584
- }
585
- function or() {
586
- bt({
587
- eventType: "After Print",
588
- eventName: "afterprint"
589
- }), bt({
590
- eventType: "Before Print",
591
- eventName: "beforeprint"
592
- });
593
- }
594
- function rr() {
595
- if (s.triggerLocked) {
596
- a("TriggerLock blocked calculation");
597
- return;
598
- }
599
- s.triggerLocked = !0, ce("Trigger event lock on"), requestAnimationFrame(() => {
600
- s.triggerLocked = !1, ce("Trigger event lock off");
601
- });
602
- }
603
- function cn(e) {
604
- const { heightCalcMode: t, widthCalcMode: n } = i, o = We[t](), r = qe[n]();
605
- a(`Reset trigger event: %c${e}`, c), v(o, r, e);
606
- }
607
- function sr(e) {
608
- const t = i.heightCalcMode;
609
- a(`Reset trigger event: %c${e}`, c), i.heightCalcMode = Mn, rr(), cn("reset"), i.heightCalcMode = t;
610
- }
611
- const ir = `Auto Resize can not be changed when <b>direction</> is set to '${Le}'.`;
612
- function cr(e) {
613
- T(e, Tn, "parentIframe.autoResize(enable) enable");
614
- const {
615
- autoResize: t,
616
- calculateHeight: n,
617
- calculateWidth: o
618
- } = i;
619
- return o === !1 && n === !1 ? (g(Me), O(ir), !1) : (e === !0 && t === !1 ? (i.autoResize = !0, queueMicrotask(() => z(Me, "Auto Resize enabled"))) : e === !1 && t === !0 && (i.autoResize = !1), v(0, 0, zn, JSON.stringify(i.autoResize)), i.autoResize);
620
- }
621
- function ar(e) {
622
- T(e, ge, "parentIframe.moveToAnchor(anchor) anchor"), s.inPageLinks.findTarget(e);
623
- }
624
- function dr(e) {
625
- T(e, P, "parentIframe.setOffsetSize(offset) offset"), i.offsetHeight = e, i.offsetWidth = e, z(_t, `parentIframe.setOffsetSize(${e})`);
626
- }
627
- const lr = () => s.origin;
628
- function fr(e) {
629
- T(
630
- e,
631
- ge,
632
- "parentIframe.setTargetOrigin(targetOrigin) targetOrigin"
633
- ), a(`Set targetOrigin: %c${e}`, c), i.targetOrigin = e;
634
- }
635
- function ur(e) {
636
- return T(
637
- e,
638
- De,
639
- "parentIframe.getParentProps(callback) callback"
640
- ), s.onParentInfo = e, v(0, 0, xt), () => {
641
- s.onParentInfo = null, v(0, 0, $n);
642
- };
643
- }
644
- function mr(e, t) {
645
- e !== void 0 && T(
646
- e,
647
- P,
648
- "parentIframe.resize(customHeight, customWidth) customHeight"
649
- ), t !== void 0 && T(
650
- t,
651
- P,
652
- "parentIframe.resize(customHeight, customWidth) customWidth"
653
- );
654
- const n = e === void 0 ? "" : e, o = t === void 0 ? "" : `,${t}`, r = `${n}${o}`;
655
- z(
656
- Bt,
657
- `parentIframe.resize(${r})`,
658
- e,
659
- t
660
- );
661
- }
662
- const Ze = (e) => (t, n) => {
663
- T(t, P, `parentIframe.${e}(x, y) x`), T(n, P, `parentIframe.${e}(x, y) y`), v(n, t, e);
664
- }, gr = Ze(In), hr = Ze(An), pr = Ze(Ft);
665
- function br(e, t) {
666
- t && T(
667
- t,
668
- ge,
669
- "parentIframe.sendMessage(msg, targetOrigin) targetOrigin"
670
- ), v(0, 0, Te, JSON.stringify(e), t);
671
- }
672
- const wr = () => v(0, 0, kn), vr = () => i.parentId, Er = () => sr("parentIframe.reset");
673
- function Or() {
674
- const { win: e } = s;
675
- i.mode !== 1 && (e.parentIframe = Object.freeze({
676
- autoResize: cr,
677
- close: wr,
678
- getId: vr,
679
- getParentOrigin: lr,
680
- getParentProps: ur,
681
- moveToAnchor: ar,
682
- reset: Er,
683
- setOffsetSize: dr,
684
- scrollBy: gr,
685
- scrollTo: hr,
686
- scrollToOffset: pr,
687
- sendMessage: br,
688
- setTargetOrigin: fr,
689
- resize: mr
690
- }));
691
- }
692
- const Q = (e = "") => (t) => (n) => {
693
- n.size > 0 && ce(
694
- `${t}Observer ${e}:`,
695
- ...Array.from(n).flatMap((o) => [Ht, o])
696
- );
697
- }, yr = (e = "") => (t) => (n) => {
698
- n.size > 0 && qt(
699
- `${t}Observer ${e}:`,
700
- ...Array.from(n).flatMap((o) => [Ht, o])
701
- );
702
- }, an = Q("attached to"), dn = yr("already attached"), Sr = Q("detached from"), pe = (e, t = !0) => (n) => {
703
- n > 0 && l(
704
- `${t ? "At" : "De"}tached %c${e}Observer%c ${t ? "to" : "from"} %c${n}%c element${n === 1 ? "" : "s"}`,
705
- c,
706
- q,
707
- c,
708
- q
709
- );
710
- }, ln = (e, t, n, o) => {
711
- const r = Sr(e);
712
- return (f) => {
713
- const d = /* @__PURE__ */ new Set();
714
- let u = 0;
715
- for (const b of f)
716
- n.has(b) && (t.unobserve(b), n.delete(b), d.add(b), u += 1);
717
- r(d), o(u), d.clear();
718
- };
719
- }, wt = 16, vt = 2, Rr = 200, je = "Mutation", R = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set(), $e = /* @__PURE__ */ new Set(), de = [], Mr = {
720
- attributes: !0,
721
- attributeFilter: [j, Ce],
722
- attributeOldValue: !1,
723
- characterData: !1,
724
- characterDataOldValue: !1,
725
- childList: !0,
726
- subtree: !0
727
- };
728
- let Ee = 1, Ye, Ie = !1, Ae = 0;
729
- const Tr = Q("added")(je), zr = Q("removed (page)")(je), $r = Q("removed (added)")(je), fn = (e) => e.nodeType !== Node.ELEMENT_NODE || At.has(e.tagName.toLowerCase());
730
- function Ir(e) {
731
- const t = e.addedNodes;
732
- for (const n of t)
733
- fn(n) || R.add(n);
734
- }
735
- function Ar(e) {
736
- const t = e.removedNodes;
737
- for (const n of t)
738
- fn(n) || (R.has(n) ? (R.delete(n), $e.add(n)) : k.add(n));
739
- }
740
- const kr = (e) => {
741
- l("Mutations:", e);
742
- for (const t of e)
743
- Ir(t), Ar(t);
744
- Tr(R), zr(k), $r($e), $e.clear();
745
- };
746
- function Nr() {
747
- k.size > 0 && a(
748
- `Detected %c${k.size} %cremoved element${k.size > 1 ? "s" : ""}`,
749
- c,
750
- w
751
- ), R.size > 0 && a(
752
- `Found %c${R.size} %cnew element${R.size > 1 ? "s" : ""}`,
753
- c,
754
- w
755
- );
756
- }
757
- const Lr = (e) => () => {
758
- const t = performance.now(), n = t - Ae, o = wt * Ee++ + vt;
759
- if (n > o && n < Rr) {
760
- g("mutationThrottled"), l("Update delayed due to heavy workload on the callStack"), l(
761
- `EventLoop busy time: %c${C(n)}ms %c> Max wait: %c${o - vt}ms`,
762
- c,
763
- w,
764
- c
765
- ), setTimeout(Ye, wt * Ee), Ae = t;
766
- return;
767
- }
768
- Ee = 1, de.forEach(kr), de.length = 0, Ie = !1, Nr(), e({ addedNodes: R, removedNodes: k }), R.clear(), k.clear();
769
- };
770
- function Cr(e) {
771
- de.push(e), !Ie && (Ae = performance.now(), Ie = !0, requestAnimationFrame(Ye));
772
- }
773
- function Pr(e) {
774
- const t = new window.MutationObserver(Cr), n = document.body || document.documentElement;
775
- return Ye = Lr(e), t.observe(n, Mr), l("Attached%c MutationObserver%c to body", c, w), {
776
- disconnect: () => {
777
- R.clear(), k.clear(), de.length = 0, t.disconnect(), l("Detached%c MutationObserver", c);
778
- }
779
- };
780
- }
781
- const _r = {
782
- characterData: !0,
783
- childList: !0,
784
- subtree: !0
785
- };
786
- function Dr(e) {
787
- const t = document.querySelector("title") ?? document.head ?? document.documentElement, n = new MutationObserver(e);
788
- return n.observe(t, _r), l("Attached%c TitleObserver%c to head", c, w), setTimeout(e), {
789
- disconnect: () => {
790
- n.disconnect(), l("Detached%c TitleObserver", c);
791
- }
792
- };
793
- }
794
- function Br(e) {
795
- const t = new IntersectionObserver(
796
- (o) => e(o.at(-1)?.isIntersecting ?? !1),
797
- {
798
- threshold: 0
799
- }
800
- ), n = document.documentElement;
801
- return t.observe(n), l("Attached%c VisibilityObserver%c to page", c, w), {
802
- disconnect: () => {
803
- t.disconnect(), l("Detached%c VisibilityObserver", c);
804
- }
805
- };
806
- }
807
- let Et = /* @__PURE__ */ new Set();
808
- function xr(e) {
809
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
810
- for (const o of e)
811
- o.closest(`[${j}]`) ? n.add(o) : t.add(o);
812
- return n.size > 0 && queueMicrotask(() => {
813
- g("overflowIgnored"), l(`Ignoring elements with [data-iframe-ignore] > *:
814
- `, n), _();
815
- }), t;
816
- }
817
- function un() {
818
- const e = document.querySelectorAll(`[${Vt}]`), t = xr(e);
819
- let n = !0;
820
- return typeof Set.prototype.symmetricDifference === De && (n = t.symmetricDifference(Et).size > 0), Et = t, s.overflowedNodeSet = t, s.hasOverflow = t.size > 0, { hasOverflowUpdated: n, overflowedNodeSet: t };
821
- }
822
- const M = {}, mn = (e) => {
823
- const t = /* @__PURE__ */ new Set();
824
- for (const n of e)
825
- if (n instanceof Element) {
826
- t.add(n);
827
- for (const o of Ue(n)) t.add(o);
828
- }
829
- return l(`Inspecting:
830
- `, t), t;
831
- }, Fr = (e) => {
832
- if (e.size === 0) return;
833
- g("addObservers");
834
- const t = mn(e);
835
- M.overflow.attachObservers(t), M.resize.attachObserverToNonStaticElements(t), _();
836
- }, Hr = (e) => {
837
- if (e.size === 0) return;
838
- g("removeObservers");
839
- const t = mn(e);
840
- M.overflow.detachObservers(t), M.resize.detachObservers(t), _();
841
- };
842
- function Vr({
843
- addedNodes: e,
844
- removedNodes: t
845
- }) {
846
- g("contentMutated"), s.applySelectors(), Xt(), un(), _(), Hr(t), Fr(e);
847
- }
848
- function Gr(e) {
849
- Vr(e), z(Pt, "Mutation Observed");
850
- }
851
- const J = "Overflow", Ur = pe(J), Wr = pe(J, !1), qr = an(J), Zr = dn(J), jr = (e) => e instanceof HTMLElement && (!!e.hidden || e.offsetParent === null || e.style.display === Le), Yr = (e, t) => {
852
- const n = t.side || Pe, o = {
853
- root: t.root,
854
- rootMargin: "0px",
855
- threshold: 1
856
- }, r = window?.requestAnimationFrame || ie, f = (y = !1) => e(y), d = (y, $) => y === 0 || y > $[n], u = (y, $) => {
857
- y.toggleAttribute(Vt, $);
858
- };
859
- function b(y) {
860
- for (const $ of y) {
861
- const { boundingClientRect: F, rootBounds: H, target: S } = $;
862
- if (!H) continue;
863
- const bn = F[n], wn = d(bn, H) && !(S instanceof HTMLElement && jr(S));
864
- u(S, wn);
865
- }
866
- r(f);
867
- }
868
- const m = new IntersectionObserver(b, o), E = /* @__PURE__ */ new WeakSet();
869
- function h(y) {
870
- const $ = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set();
871
- let H = 0;
872
- for (const S of y)
873
- if (S instanceof Element) {
874
- if (E.has(S)) {
875
- $.add(S);
876
- continue;
877
- }
878
- m.observe(S), E.add(S), F.add(S), H += 1;
879
- }
880
- Zr($), qr(F), Ur(H), F.clear(), $.clear();
881
- }
882
- return {
883
- attachObservers: h,
884
- detachObservers: ln(
885
- J,
886
- m,
887
- E,
888
- Wr
889
- ),
890
- disconnect: () => {
891
- m.disconnect(), l("Detached%c OverflowObserver", c);
892
- }
893
- };
894
- };
895
- function Qr() {
896
- const { hasOverflow: e } = s, { hasOverflowUpdated: t, overflowedNodeSet: n } = un();
897
- switch (!0) {
898
- case !t:
899
- return;
900
- case n.size > 1:
901
- l("Overflowed Elements:", n);
902
- break;
903
- case e:
904
- break;
905
- default:
906
- l("No overflow detected");
907
- }
908
- z(_e, "Overflow updated");
909
- }
910
- function Jr(e) {
911
- const t = {
912
- root: document.documentElement,
913
- side: i.calculateHeight ? Pe : Nt
914
- };
915
- return M.overflow = Yr(Qr, t), M.overflow.attachObservers(e), M.overflow;
916
- }
917
- const K = "Resize", Kr = pe(K), Xr = pe(K, !1), es = an(K), ts = dn(K), le = /* @__PURE__ */ new WeakSet(), Oe = /* @__PURE__ */ new Set(), ye = /* @__PURE__ */ new Set();
918
- let U;
919
- function ns(e) {
920
- let t = 0;
921
- for (const n of e) {
922
- if (!(n instanceof Element)) continue;
923
- const o = getComputedStyle(n)?.position;
924
- if (!(o === "" || o === "static")) {
925
- if (le.has(n)) {
926
- Oe.add(n);
927
- continue;
928
- }
929
- U.observe(n), le.add(n), ye.add(n), t += 1;
930
- }
931
- }
932
- ts(Oe), es(ye), Kr(t), ye.clear(), Oe.clear();
933
- }
934
- const os = (e) => (U = new ResizeObserver(e), U.observe(document.body), le.add(document.body), l("Attached%c ResizeObserver%c to body", c, w), {
935
- attachObserverToNonStaticElements: ns,
936
- detachObservers: ln(
937
- K,
938
- U,
939
- le,
940
- Xr
941
- ),
942
- disconnect: () => {
943
- U.disconnect(), l("Detached%c ResizeObserver", c);
944
- }
945
- });
946
- function rs(e) {
947
- if (!Array.isArray(e) || e.length === 0) return;
948
- const t = e[0].target;
949
- z(Ct, `Element resized <${Un(t)}>`);
950
- }
951
- function ss(e) {
952
- return M.resize = os(rs), M.resize.attachObserverToNonStaticElements(e), M.resize;
953
- }
954
- let Ot;
955
- function is() {
956
- const e = document.title;
957
- e !== Ot && (Ot = e, a(`Title: %c${e}`, c), e && v(0, 0, Nn, e));
958
- }
959
- function cs(e) {
960
- a(`Visible: %c${e}`, c), s.isHidden = !e, z(Lt, "Visibility changed");
961
- }
962
- function as(e) {
963
- Ve.push(...e.map((t) => t.disconnect));
964
- }
965
- function ds() {
966
- g("attachObservers");
967
- const e = Ue(document.documentElement), t = [
968
- Pr(Gr),
969
- Jr(e),
970
- qo(),
971
- ss(e),
972
- Dr(is),
973
- Br(cs)
974
- ];
975
- as(t);
976
- }
977
- const yt = (e, t, n) => {
978
- if (n !== "") {
979
- a(`${e}: %c${n}`, c);
980
- for (const o of document.querySelectorAll(n))
981
- a(`Applying ${t} to:`, o), o.toggleAttribute(t, !0);
982
- }
983
- };
984
- function ls({
985
- sizeSelector: e,
986
- ignoreSelector: t
987
- }) {
988
- return () => {
989
- yt("sizeSelector", Ce, e), yt("ignoreSelector", j, t);
990
- };
991
- }
992
- function fs() {
993
- const e = document.createElement("div");
994
- e.style.clear = "both", e.style.display = "block", e.style.height = "0", document.body.append(e);
995
- }
996
- function us(e, t) {
997
- return t.includes("-") && (x(`Negative CSS value ignored for ${e}`), t = ""), t;
998
- }
999
- function ke(e, t) {
1000
- t === void 0 || t === "" || t === Ln || (document.body.style.setProperty(e, t), l(`Set body ${e}: %c${t}`, c));
1001
- }
1002
- function ms({
1003
- bodyMarginStr: e,
1004
- bodyMargin: t
1005
- }) {
1006
- e === void 0 && (e = `${t}px`), ke("margin", us("margin", e));
1007
- }
1008
- const gs = () => ({
1009
- x: document.documentElement.scrollLeft,
1010
- y: document.documentElement.scrollTop
1011
- });
1012
- function hs(e) {
1013
- const t = e.getBoundingClientRect(), n = gs();
1014
- return {
1015
- x: Math.round(t.left + n.x),
1016
- y: Math.round(t.top + n.y)
1017
- };
1018
- }
1019
- function ps(e, t) {
1020
- const n = hs(t);
1021
- a(
1022
- `Moving to in page link (%c#${e}%c) at x: %c${n.x}%c y: %c${n.y}`,
1023
- c,
1024
- w,
1025
- c,
1026
- w,
1027
- c
1028
- ), v(n.y, n.x, Ft);
1029
- }
1030
- function Qe(e) {
1031
- const t = e.split("#")[1] || e, n = decodeURIComponent(t), o = document.getElementById(n) || document.getElementsByName(n)[0];
1032
- if (o !== void 0) {
1033
- ps(t, o);
1034
- return;
1035
- }
1036
- a(`In page link (#${t}) not found in iframe, so sending to parent`), v(0, 0, Cn, `#${t}`);
1037
- }
1038
- function gn() {
1039
- const { hash: e, href: t } = window.location;
1040
- e !== "" && e !== "#" && Qe(t);
1041
- }
1042
- function bs() {
1043
- for (const e of document.querySelectorAll('a[href^="#"]'))
1044
- e.getAttribute("href") !== "#" && N(e, "click", (t) => {
1045
- t.preventDefault(), Qe(e.getAttribute("href"));
1046
- });
1047
- }
1048
- function ws() {
1049
- N(window, "hashchange", gn);
1050
- }
1051
- function vs() {
1052
- setTimeout(gn, Gt);
1053
- }
1054
- function Es() {
1055
- a("Setting up location.hash handlers"), bs(), ws(), vs(), s.inPageLinks = {
1056
- findTarget: Qe
1057
- };
1058
- }
1059
- function Os(e) {
1060
- const { mode: t } = i;
1061
- e ? Be(t) ? O(I(5)) : Es() : a("In page linking not enabled");
1062
- }
1063
- const ys = "important";
1064
- function Ss() {
1065
- const e = (t) => t.style.setProperty(me, se, ys);
1066
- e(document.documentElement), e(document.body), a("Set HTML & body height: %cauto !important", c);
1067
- }
1068
- const Je = (e) => (t, n) => {
1069
- if (n in t) {
1070
- if (typeof t[n] === e) return t[n];
1071
- throw new TypeError(`${n} is not a ${e}.`);
1072
- }
1073
- }, Se = Je(De), St = Je(P), ee = Je(ge), Rs = (e) => e !== null && typeof e === Pn && !Array.isArray(e);
1074
- function Ms(e) {
1075
- const { calculateHeight: t, calculateWidth: n } = i;
1076
- let o, r;
1077
- return typeof e?.offsetSize === P && (t && (o = St(e, nt)), n && (r = St(e, nt))), { offsetHeight: o, offsetWidth: r };
1078
- }
1079
- function Ts(e) {
1080
- a("Reading data from page:", Object.keys(e));
1081
- const { offsetHeight: t, offsetWidth: n } = Ms(e);
1082
- return {
1083
- offsetHeight: t,
1084
- offsetWidth: n,
1085
- ignoreSelector: ee(e, "ignoreSelector"),
1086
- [st(3)]: ee(e, st(0)),
1087
- sizeSelector: ee(e, "sizeSelector"),
1088
- targetOrigin: ee(e, "targetOrigin"),
1089
- onBeforeResize: Se(e, "onBeforeResize"),
1090
- onMessage: Se(e, "onMessage"),
1091
- onReady: Se(e, "onReady")
1092
- };
1093
- }
1094
- function zs() {
1095
- const { mode: e } = i;
1096
- if (Be(e)) return {};
1097
- const t = window.iframeResizer || window.iFrameResizer;
1098
- return Rs(t) ? Ts(t) : {};
1099
- }
1100
- const $s = (e) => e === "true", hn = (e) => (t) => t === void 0 ? void 0 : e(t), L = hn($s), G = hn(Number), Is = (e) => ({
1101
- parentId: e[0],
1102
- bodyMargin: G(e[1]),
1103
- calculateWidth: L(e[2]),
1104
- logging: L(e[3]),
1105
- // data[4] no longer used (was intervalTimer)
1106
- autoResize: L(e[6]),
1107
- bodyMarginStr: e[7],
1108
- // data[8] no longer used (was heightCalcMode)
1109
- bodyBackground: e[9],
1110
- bodyPadding: e[10],
1111
- tolerance: G(e[11]),
1112
- inPageLinks: L(e[12]),
1113
- // data[13] no longer used (was resizeFrom)
1114
- // data[14] no longer used (was widthCalcMode)
1115
- mouseEvents: L(e[15]),
1116
- offsetHeight: G(e[16]),
1117
- offsetWidth: G(e[17]),
1118
- calculateHeight: L(e[18]),
1119
- key: e[19],
1120
- version: e[20],
1121
- mode: G(e[21]),
1122
- // sizeSelector: data[22] // Now only available via page settings
1123
- logExpand: L(e[23])
1124
- });
1125
- function As(e) {
1126
- const { mode: t } = i;
1127
- e.forEach((n) => {
1128
- try {
1129
- n();
1130
- } catch (o) {
1131
- if (t < 0) throw o;
1132
- O(
1133
- `<rb>Error in setup function</>
1134
- <i>iframe-resizer</> detected an error during setup.
1135
-
1136
- Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`
1137
- ), qt(o);
1138
- }
1139
- });
1140
- }
1141
- function Rt(e) {
1142
- for (const [t, n] of Object.entries(e))
1143
- n !== void 0 && (i[t] = n);
1144
- }
1145
- function ks({
1146
- logExpand: e,
1147
- logging: t,
1148
- parentId: n = ""
1149
- }) {
1150
- Yn({ id: n, enabled: t, expand: e }), g("initReceived"), a(`Initialising iframe v${Y} ${window.location.href}`);
1151
- }
1152
- function Ns(e) {
1153
- g("ready"), Kt(Ut(e)), a("Initialization complete", (({ key: t, key2: n, ...o }) => o)(i));
1154
- }
1155
- function Ls({
1156
- bodyBackground: e,
1157
- bodyPadding: t,
1158
- inPageLinks: n,
1159
- onReady: o
1160
- }) {
1161
- const r = mo(i), f = [
1162
- po,
1163
- go,
1164
- Oo,
1165
- Xt,
1166
- So,
1167
- r ? ie : uo,
1168
- () => ms(i),
1169
- () => ke("background", e),
1170
- () => ke("padding", t),
1171
- r ? ie : Ss,
1172
- fs,
1173
- s.applySelectors,
1174
- () => Os(n),
1175
- or,
1176
- () => No(i),
1177
- Po,
1178
- () => Or(),
1179
- () => z(
1180
- ue,
1181
- "Init message from host page",
1182
- void 0,
1183
- void 0,
1184
- `${Y}:${i.mode}`
1185
- ),
1186
- ds,
1187
- _
1188
- ];
1189
- To(i), wo(i), As(f), Ns(o);
1190
- }
1191
- function Cs(e) {
1192
- s.firstRun && (Rt(Is(e)), ks(i), Rt(zs()), s.applySelectors = ls(i), Ls(i));
1193
- }
1194
- function Ps(e) {
1195
- if (document.readyState === "loading") {
1196
- a("Page not ready, ignoring init message");
1197
- return;
1198
- }
1199
- const t = e.data.slice(zt).split(fe);
1200
- s.target = e.source, s.origin = e.origin, Cs(t), s.firstRun = !1, setTimeout(() => {
1201
- s.initLock = !1;
1202
- }, Gt);
1203
- }
1204
- const { freeze: _s } = Object, { parse: Ke } = JSON, Xe = (e) => _s(Ke(e)), pn = (e) => v(0, 0, `${e}Stop`), be = (e) => e.data.slice(e.data.indexOf(fe) + 1), Ds = (e) => to(e) ? ue : e.data.split("]")[1].split(fe)[0];
1205
- function Bs(e) {
1206
- const t = be(e);
1207
- a("onMessage called from parent:%c", c, Xe(t)), he(i.onMessage, Ke(t));
1208
- }
1209
- function xs(e) {
1210
- const { onPageInfo: t } = s, n = be(e);
1211
- a("PageInfo received from parent:", Xe(n)), t ? he(t, Ke(n)) : pn(_n);
1212
- }
1213
- function Fs(e) {
1214
- const { onParentInfo: t } = s, n = Xe(be(e));
1215
- a("ParentInfo received from parent:", n), t ? he(t, n) : pn(xt);
1216
- }
1217
- function Hs() {
1218
- if (s.initLock) {
1219
- a("Page reset ignored by init");
1220
- return;
1221
- }
1222
- a("Page size reset by host page"), cn("resetPage");
1223
- }
1224
- function Vs() {
1225
- a("Resize requested by host page"), z(Dt, "Parent window requested size check");
1226
- }
1227
- const Mt = (e) => s.inPageLinks.findTarget(be(e)), Tt = {
1228
- init: Ps,
1229
- reset: Hs,
1230
- resize: Vs,
1231
- moveToAnchor: Mt,
1232
- inPageLink: Mt,
1233
- // Backward compatibility
1234
- pageInfo: xs,
1235
- parentInfo: Fs,
1236
- message: Bs
1237
- };
1238
- function Gs(e) {
1239
- const { firstRun: t } = s, n = Ds(e);
1240
- switch (g(n), !0) {
1241
- case n in Tt:
1242
- Tt[n](e);
1243
- break;
1244
- case (t && eo()):
1245
- x(
1246
- `Ignored message of type "${n}". Received before initialization.`
1247
- );
1248
- break;
1249
- default:
1250
- x(
1251
- `Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`
1252
- );
1253
- }
1254
- }
1255
- const te = Fe((e) => {
1256
- Xn(e) && Gs(e);
1257
- });
1258
- function Us() {
1259
- if ("iframeChildListener" in window) {
1260
- x("Already setup");
1261
- return;
1262
- }
1263
- window.iframeChildListener = ((t) => {
1264
- setTimeout(() => te({ data: t, sameOrigin: !0 }));
1265
- }), g("listen"), N(window, Te, te), N(document, $t, dt), dt();
1266
- function e(t) {
1267
- return te(t), s.win;
1268
- }
1269
- try {
1270
- top?.document?.getElementById("banner") && (s.win = {}, window.mockMsgListener = e, Yt(window, Te, te), typeof window.define == "function" && window.define([], () => e));
1271
- } catch {
1272
- }
1273
- }
1274
- typeof window !== Dn && Us();
1
+ /*!
2
+ * @preserve
3
+ *
4
+ * @module iframe-resizer/child 6.0.0-beta.6 (esm) - 2026-04-10
5
+ *
6
+ * @license GPL-3.0 For use with GPL compliant sites (fully published front & backend source code)
7
+ * Alternatively for commercial use, you can purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
+ *
10
+ * @description Keep same and cross domain iframes sized to their content
11
+ *
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
+ *
14
+ * @see {@link https://iframe-resizer.com}
15
+ *
16
+ * @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
17
+ */
18
+
19
+
20
+ import{esModuleInterop as e,LABEL as t,createFormatAdvise as n,id as o,deprecate as r,BOLD as i,CHILD_READY_MESSAGE as a,MESSAGE_ID as s,MESSAGE_ID_LENGTH as c,SEPARATOR as d,AUTO as l,NONE as u,IGNORE_ATTR as f,isDef as m,setMode as g,getModeData as h,VERSION as p,getModeLabel as b,isolateUserCode as w,READY_STATE_CHANGE as v,SIZE_ATTR as y,FALSE as $,once as z,checkMode as O,round as S,INIT as k,MOUSE_ENTER as M,MOUSE_LEAVE as E,lower as R,PAGE_HIDE as T,invoke as I,BEFORE_UNLOAD as P,MIN_SIZE as A,HEIGHT as x,IGNORE_TAGS as L,capitalizeFirstLetter as C,HEIGHT_EDGE as N,WIDTH as B,WIDTH_EDGE as H,NO_CHANGE as W,VISIBILITY_OBSERVER as q,RESIZE_OBSERVER as D,MUTATION_OBSERVER as F,OVERFLOW_OBSERVER as V,SET_OFFSET_SIZE as j,PARENT_RESIZE_REQUEST as U,MANUAL_RESIZE_REQUEST as Q,SIZE_CHANGE_DETECTED as J,ENABLE as Y,IGNORE_DISABLE_RESIZE as X,HEIGHT_CALC_MODE_DEFAULT as G,typeAssert as _,BOOLEAN as K,AUTO_RESIZE as Z,STRING as ee,NUMBER as te,FUNCTION as ne,PARENT_INFO as oe,PARENT_INFO_STOP as re,SCROLL_BY as ie,SCROLL_TO as ae,SCROLL_TO_OFFSET as se,MESSAGE as ce,CLOSE as de,NEW_LINE as le,OVERFLOW_ATTR as ue,getElementName as fe,TITLE as me,NULL as ge,EVENT_CANCEL_TIMER as he,IN_PAGE_LINK as pe,OBJECT as be,getKey as we,OFFSET_SIZE as ve,PAGE_INFO as ye,UNDEFINED as $e}from"@iframe-resizer/common";import ze,{NORMAL as Oe,HIGHLIGHT as Se,FOREGROUND as ke,BOLD as Me,ITALIC as Ee}from"auto-console-group";let Re=!0,Te=t;const Ie=e(ze)({label:`${t}(child)`,expand:!1});const Pe=e=>(...t)=>!Re||Ie[e](...t),Ae=Pe("log"),xe=Ae,Le=Pe("debug");const{assert:Ce,endAutoGroup:Ne,error:Be,errorBoundary:He,event:We,label:qe,purge:De,warn:Fe}=Ie,Ve=n(o),je=(...e)=>Ie.warn(...e.map(Ve)),Ue=r((e,t)=>je(t));Ue("Method"),Ue("Method","replaced with"),Ue("Option");const Qe=[];function Je(e,t){Ae(`${e} event listener: %c${t}`,Se)}const Ye=(e,t,n,o)=>{e.removeEventListener(t,n,o),Je("Removed",t)},Xe=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),Qe.push(()=>Ye(e,t,n,o)),Je("Added",t)},Ge={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:/* @__PURE__ */new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let _e=!1;function Ke(e){const t=window?.iframeResizer?.targetOrigin||"*",n=Array.isArray(t)?t:[t];for(const o of n)e.postMessage(a,o)}function Ze(){if("loading"===document.readyState||!Ge.firstRun||_e)return;const{parent:e,top:t}=window;We("ready"),Ae("Sending%c ready%c to parent from",Se,ke,window.location.href),Ke(e),e!==t&&Ke(t),_e=!0}const et="iframeResize",tt=["min-height","min-width","max-height","max-width"],nt=/* @__PURE__ */new Set,ot=e=>e.tagName?e.tagName.toLowerCase():"unknown",rt=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),it=(e,t)=>{return!!(n=rt(e,t))&&"0px"!==n&&n!==l&&n!==u;var n};function at({href:e}){nt.has(e)||(Ae("Unable to access stylesheet:",e),nt.add(e))}const st=(e,t)=>function(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const o of document.styleSheets)try{for(const n of o.cssRules||[]){if(!("selectorText"in n))continue;const r=n;if(!e.matches(r.selectorText))continue;const i=r.style.getPropertyValue(t);if(!i)continue;const{ownerNode:a}=o;return{source:a instanceof Element&&"STYLE"===a.tagName?"an inline <style> block":`stylesheet (${o.href})`,value:i}}}catch(n){at(o)}return{source:"cross-origin stylesheet",value:rt(e,t)}}(e,t),ct=(e,t)=>{const{source:n,value:o}=st(e,t),r=ot(e);je(`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 dt(){for(const e of[document.documentElement,document.body])for(const t of tt)Ae(`Checking <${ot(e)}> for blocking CSS: ${t}`),it(e,t)&&ct(e,t)}const lt={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:l,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:l,onBeforeResize:void 0,onMessage:()=>{Fe("onMessage function not defined")},onReady:()=>{}};function ut(){try{Ge.sameOrigin=1===lt.mode||"iframeParentListener"in window.parent}catch(e){Ae("Cross domain iframe detected")}}let ft=0;function mt(){const e=document.querySelectorAll(`*[${f}]`),t=e.length>0;return t&&e.length!==ft&&(!function(e){const t=1===e.length?"":"s";Fe(`%c[${f}]%c found on %c${e.length}%c element${t}`,Me,Oe,Me,Oe)}(e),ft=e.length),t}function gt(e,t,n){(!m(n)||t>-1&&e>t)&&(function(e,t){console.info(`%ciframe-resizer ${e}`,Re||t<1?i:Oe)}(`v${p} (${b(e)})`,e),0===e&&((...e)=>{console.warn(...e.map(Ve))})(h(3)))}function ht(){"BackCompat"===document.compatMode&&je("<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")}let pt=!1;function bt(e){"complete"===document.readyState?w(e):pt||Xe(document,v,()=>bt(e)),pt=!0}const wt=()=>{xe(`Set targetOrigin for parent: %c${lt.targetOrigin}`,Se),!0!==lt.autoResize&&Ae("Auto Resize disabled")};function vt(){Ge.taggedElements=document.querySelectorAll(`[${y}]`),Ge.hasTags=Ge.taggedElements.length>0,Ae(`Tagged elements found: %c${Ge.hasTags}`,Se)}function yt({version:e}){e&&""!==e&&e!==$?e!==p&&je((e=>`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${e} - Child page: ${p}.\n`)(e)):je("<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")}const $t=z(()=>je(h(4)));function zt(e,t){const{mode:n}=lt,{sameOrigin:o,target:r}=Ge;if(o)try{window.parent.iframeParentListener(s+e)}catch(i){if(!O(n))throw new Error(i);return $t(),!1}else{Ce(r,"Internal error: postMessage target is undefined");const n=function(e){return void 0===e?e=lt.targetOrigin:Ae(`Message targetOrigin: %c${e}`,Se),e}(t),o=Array.isArray(n)?n:[n];for(const t of o)r.postMessage(s+e,t)}return!0}function Ot(e,t,n,o,r){const{parentId:i}=lt,{sameOrigin:a}=Ge,s=`${i}:${`${e}:${t}`}:${n}${void 0===o?"":`:${o}`}`;if(lt.mode<-1)return;zt(s,r)&&(!function(e){if(!Ge.timerActive)return;const t=S(performance.now()-Ge.totalTime);Ae(e===k?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`,Se)}(n),xe(`Sending message to parent page via ${a?"sameOrigin":"postMessage"}: %c%c${s}`,Ee,Se))}const St=He((e,t,n,o,r)=>{We(n),Ot(e,t,n,o,r),Ne()}),kt=e=>St(0,0,e.type,`${e.screenY}:${e.screenX}`);function Mt(e,t){Ae(`Add event listener: %c${t}`,Se),Xe(window.document,e,kt)}function Et({persisted:e}){e||St(0,0,P),We(T),xe("Page persisted:",e),e||Qe.forEach(I)}const Rt=()=>Xe(window,R(T),Et),Tt=(e,t)=>!(Math.abs(e-t)<=lt.tolerance);const It=[Se,ke,Se],Pt={height:0,width:0},At={height:0,width:0};function xt(e,t,n){return At[e]=t,Pt[e]=n,t}function Lt(e){const{hasOverflow:t,hasTags:n,triggerLocked:o}=Ge,r=e.label,i=r===x,a=e.boundingClientRect(),s=Math.ceil(a),c=Math.floor(a),d=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e),l=`HTML: %c${a}px %cPage: %c${d}px`;let u;switch(!0){case!e.enabled():return Math.max(d,A);case n:xe("Found element with data-iframe-size attribute"),u=e.taggedElement();break;case!t&&Ge.firstRun&&0===At[r]&&0===Pt[r]:xe(`Initial page size values: ${l}`,...It),u=xt(r,a,d);break;case o&&a===At[r]&&d===Pt[r]:xe(`Size unchanged: ${l}`,...It),u=Math.max(a,d);break;case 0===a&&0!==d:xe(`Page is hidden: ${l}`,...It),u=d;break;case!t&&a!==At[r]&&d<=Pt[r]:xe(`New <html> size: ${l} `,...It),xe(`Previous <html> size: %c${At[r]}px`,Se),u=xt(r,a,d);break;case!i:u=e.taggedElement();break;case!t&&a<At[r]:xe(`<html> size decreased: ${l}`,...It),u=xt(r,a,d);break;case d===c||d===s:xe(`<html> size equals page size: ${l}`,...It),u=xt(r,a,d);break;case a>d:xe(`Page size < <html> size: ${l}`,...It),u=xt(r,a,d);break;case t:xe("Found elements possibly overflowing <html> "),u=e.taggedElement();break;default:xe(`Using <html> size: ${l}`,...It),u=xt(r,a,d)}return xe(`Content ${r}: %c${u}px`,Se),u+=function(e){const t=e.getOffset();return 0!==t&&xe(`Page offsetSize: %c${t}px`,Se),t}(e),Math.max(u,A)}const Ct="--ifr-start",Nt="--ifr-end",Bt="--ifr-measure",Ht=[];let Wt,qt={},Dt=0;function Ft(){try{performance.clearMarks(Ct),performance.clearMarks(Nt),performance.clearMeasures(Bt)}catch{}}function Vt(e){e.getEntries().forEach(e=>{if(e.name===Nt)try{const{duration:t}=performance.measure(Bt,Ct,Nt);qt=e.detail,Ht.push(t),Ht.length>100&&Ht.shift()}catch{}})}function jt(){xe("Attached%c PerformanceObserver%c to page",Se,ke);const e=new PerformanceObserver(Vt);return e.observe({entryTypes:["mark"]}),Wt=setInterval(()=>{if(Ht.length<10)return;if(qt.hasTags&&qt.len<25)return;Ht.sort();const e=Math.min(Ht.reduce((e,t)=>e+t,0)/Ht.length,Ht[Math.floor(Ht.length/2)]),t=S(e);t>Dt&&(Dt=t,We("performanceObserver"),Ae("Mean time:",S(Ht[Math.floor(Ht.length/2)])),Ae("Median time:",S(Ht.reduce((e,t)=>e+t,0)/Ht.length)),Ae("Average time:",t),Ae("Max time:",S(Math.max(...Ht)))),Ft(),e<=4||(clearInterval(Wt),je(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${S(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${qt.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3),{disconnect:()=>{Ft(),clearInterval(Wt),e.disconnect(),xe("Detached%c PerformanceObserver",Se)}}}const Ut=`* ${Array.from(L).map(e=>`:not(${e})`).join("")}`,Qt=e=>e.querySelectorAll(Ut);function Jt(e){performance.mark(Ct);const t=C(e),{logging:n}=lt,{hasTags:o}=Ge,r=function(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:n,taggedElements:o}=Ge;return t?o:e?Array.from(n):Qt(document.documentElement)}(),{maxEl:i,maxVal:a}=function(e,t){const n=`margin-${t}`;let o,r=document.documentElement,i=Ge.hasTags?A:document.documentElement.getBoundingClientRect().bottom;for(const a of e)o=a.getBoundingClientRect()[t]+parseFloat(getComputedStyle(a).getPropertyValue(n)),o>i&&(i=o,r=a);return{maxEl:r,maxVal:i}}(r,e);return xe(`${t} position calculated from:`,i),xe(`Checked %c${r.length}%c elements`,Se,ke),performance.mark(Nt,{detail:{hasTags:o,len:r.length,logging:n,Side:t}}),a}const Yt={label:x,enabled:()=>lt.calculateHeight,getOffset:()=>lt.offsetHeight,auto:()=>Lt(Yt),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>Jt(N)},Xt={label:B,enabled:()=>lt.calculateWidth,getOffset:()=>lt.offsetWidth,auto:()=>Lt(Xt),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>Jt(H)};const Gt=(e,t)=>(n,o)=>{const r=e[n]();return e.enabled()&&void 0!==lt.onBeforeResize?function(e,t,n){const o=lt.onBeforeResize(e,t,n);if(void 0===o)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(o))throw new TypeError(`Invalid value returned from onBeforeResize(): ${o}, expected Number`);if(o<A)throw new RangeError(`Out of range value returned from onBeforeResize(): ${o}, must be at least ${A}`);return o}(r,o,t):r},_t=Gt(Yt,x),Kt=Gt(Xt,B);function Zt(e,t,n,o){const{heightCalcMode:r,widthCalcMode:i}=lt;0===window.scrollY&&0===window.scrollX||(xe("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0));const a=n??_t(r,e),s=o??Kt(i,e),c=function(e,t){const{calculateHeight:n,calculateWidth:o}=lt,{height:r,width:i}=Ge;return n&&Tt(r,e)||o&&Tt(i,t)}(a,s)?J:e;switch(Ae(`Resize event: %c${t}`,Se),c){case k:case Y:case J:case Q:case U:Ge.height=a,Ge.width=s;case j:return Ge;case V:case F:case D:case q:Ae(W);break;default:xe(W)}return null}let en=!1,tn=!1,nn=null;const on=He(function(e,t,n,o,r){const{autoResize:i}=lt,{isHidden:a}=Ge;switch(We(e),!0){case!0===a&&!(e in X):if(!0===tn)break;Ae("Iframe hidden - Ignored resize request"),tn=!0,en=!1,cancelAnimationFrame(nn),nn=null;break;case!0===en&&e!==V&&!(e in X):Ae("Resize already pending - Ignored resize request");break;case!i&&!(e in X):xe("Resizing disabled");break;default:{tn=!1,en=!0,Ge.totalTime=performance.now(),Ge.timerActive=!0;const i=Zt(e,t,n,o);i&&Ot(i.height,i.width,e,r),nn||(nn=requestAnimationFrame(()=>{en=!1,nn=null,We("requestAnimationFrame"),Le(`Reset sendPending: %c${e}`,Se)})),Ge.timerActive=!1}}Ne()});function rn({eventType:e,eventName:t}){Xe(window,t,()=>on(t,e),{passive:!0})}function an(){rn({eventType:"After Print",eventName:"afterprint"}),rn({eventType:"Before Print",eventName:"beforeprint"})}function sn(e){const{heightCalcMode:t,widthCalcMode:n}=lt,o=Yt[t](),r=Xt[n]();Ae(`Reset trigger event: %c${e}`,Se),St(o,r,e)}function cn(e){const t=lt.heightCalcMode;Ae(`Reset trigger event: %c${e}`,Se),lt.heightCalcMode=G,Ge.triggerLocked?Ae("TriggerLock blocked calculation"):(Ge.triggerLocked=!0,Le("Trigger event lock on"),requestAnimationFrame(()=>{Ge.triggerLocked=!1,Le("Trigger event lock off")})),sn("reset"),lt.heightCalcMode=t}const dn=`Auto Resize can not be changed when <b>direction</> is set to '${u}'.`;function ln(e){_(e,K,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:n,calculateWidth:o}=lt;return!1===o&&!1===n?(We(Y),je(dn),!1):(!0===e&&!1===t?(lt.autoResize=!0,queueMicrotask(()=>on(Y,"Auto Resize enabled"))):!1===e&&!0===t&&(lt.autoResize=!1),St(0,0,Z,JSON.stringify(lt.autoResize)),lt.autoResize)}function un(e){_(e,ee,"parentIframe.moveToAnchor(anchor) anchor"),Ge.inPageLinks.findTarget(e)}function fn(e){_(e,te,"parentIframe.setOffsetSize(offset) offset"),lt.offsetHeight=e,lt.offsetWidth=e,on(j,`parentIframe.setOffsetSize(${e})`)}const mn=()=>Ge.origin;function gn(e){_(e,ee,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),Ae(`Set targetOrigin: %c${e}`,Se),lt.targetOrigin=e}function hn(e){return _(e,ne,"parentIframe.getParentProps(callback) callback"),Ge.onParentInfo=e,St(0,0,oe),()=>{Ge.onParentInfo=null,St(0,0,re)}}function pn(e,t){void 0!==e&&_(e,te,"parentIframe.resize(customHeight, customWidth) customHeight"),void 0!==t&&_(t,te,"parentIframe.resize(customHeight, customWidth) customWidth");on(Q,`parentIframe.resize(${`${void 0===e?"":e}${void 0===t?"":`,${t}`}`})`,e,t)}const bn=e=>(t,n)=>{_(t,te,`parentIframe.${e}(x, y) x`),_(n,te,`parentIframe.${e}(x, y) y`),St(n,t,e)},wn=bn(ie),vn=bn(ae),yn=bn(se);function $n(e,t){t&&_(t,ee,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),St(0,0,ce,JSON.stringify(e),t)}const zn=()=>St(0,0,de),On=()=>lt.parentId,Sn=()=>cn("parentIframe.reset");const kn=(e="")=>t=>n=>{n.size>0&&Le(`${t}Observer ${e}:`,...Array.from(n).flatMap(e=>[le,e]))},Mn=kn("attached to"),En=((e="")=>t=>n=>{n.size>0&&Be(`${t}Observer ${e}:`,...Array.from(n).flatMap(e=>[le,e]))})("already attached"),Rn=kn("detached from"),Tn=(e,t=!0)=>n=>{n>0&&xe(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${n}%c element${1===n?"":"s"}`,Se,Oe,Se,Oe)},In=(e,t,n,o)=>{const r=Rn(e);return e=>{const i=/* @__PURE__ */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()}},Pn="Mutation",An=/* @__PURE__ */new Set,xn=/* @__PURE__ */new Set,Ln=/* @__PURE__ */new Set,Cn=[],Nn={attributes:!0,attributeFilter:[f,y],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let Bn,Hn=1,Wn=!1,qn=0;const Dn=kn("added")(Pn),Fn=kn("removed (page)")(Pn),Vn=kn("removed (added)")(Pn),jn=e=>e.nodeType!==Node.ELEMENT_NODE||L.has(e.tagName.toLowerCase());function Un(e){const t=e.addedNodes;for(const n of t)jn(n)||An.add(n)}function Qn(e){const t=e.removedNodes;for(const n of t)jn(n)||(An.has(n)?(An.delete(n),Ln.add(n)):xn.add(n))}const Jn=e=>{xe("Mutations:",e);for(const t of e)Un(t),Qn(t);Dn(An),Fn(xn),Vn(Ln),Ln.clear()};const Yn=e=>()=>{const t=performance.now(),n=t-qn,o=16*Hn+++2;if(n>o&&n<200)return We("mutationThrottled"),xe("Update delayed due to heavy workload on the callStack"),xe(`EventLoop busy time: %c${S(n)}ms %c> Max wait: %c${o-2}ms`,Se,ke,Se),setTimeout(Bn,16*Hn),void(qn=t);Hn=1,Cn.forEach(Jn),Cn.length=0,Wn=!1,xn.size>0&&Ae(`Detected %c${xn.size} %cremoved element${xn.size>1?"s":""}`,Se,ke),An.size>0&&Ae(`Found %c${An.size} %cnew element${An.size>1?"s":""}`,Se,ke),e({addedNodes:An,removedNodes:xn}),An.clear(),xn.clear()};function Xn(e){Cn.push(e),Wn||(qn=performance.now(),Wn=!0,requestAnimationFrame(Bn))}function Gn(e){const t=new window.MutationObserver(Xn),n=document.body||document.documentElement;return Bn=Yn(e),t.observe(n,Nn),xe("Attached%c MutationObserver%c to body",Se,ke),{disconnect:()=>{An.clear(),xn.clear(),Cn.length=0,t.disconnect(),xe("Detached%c MutationObserver",Se)}}}const _n={characterData:!0,childList:!0,subtree:!0};function Kn(e){const t=document.querySelector("title")??document.head??document.documentElement,n=new MutationObserver(e);return n.observe(t,_n),xe("Attached%c TitleObserver%c to head",Se,ke),setTimeout(e),{disconnect:()=>{n.disconnect(),xe("Detached%c TitleObserver",Se)}}}function Zn(e){const t=new IntersectionObserver(t=>e(t.at(-1)?.isIntersecting??!1),{threshold:0}),n=document.documentElement;return t.observe(n),xe("Attached%c VisibilityObserver%c to page",Se,ke),{disconnect:()=>{t.disconnect(),xe("Detached%c VisibilityObserver",Se)}}}let eo=/* @__PURE__ */new Set;function to(){const e=function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const o of e)o.closest(`[${f}]`)?n.add(o):t.add(o);return n.size>0&&queueMicrotask(()=>{We("overflowIgnored"),xe("Ignoring elements with [data-iframe-ignore] > *:\n",n),Ne()}),t}(document.querySelectorAll(`[${ue}]`));let t=!0;return typeof Set.prototype.symmetricDifference===ne&&(t=e.symmetricDifference(eo).size>0),eo=e,Ge.overflowedNodeSet=e,Ge.hasOverflow=e.size>0,{hasOverflowUpdated:t,overflowedNodeSet:e}}const no={},oo=e=>{const t=/* @__PURE__ */new Set;for(const n of e)if(n instanceof Element){t.add(n);for(const e of Qt(n))t.add(e)}return xe("Inspecting:\n",t),t};function ro({addedNodes:e,removedNodes:t}){We("contentMutated"),Ge.applySelectors(),vt(),to(),Ne(),(e=>{if(0===e.size)return;We("removeObservers");const t=oo(e);no.overflow.detachObservers(t),no.resize.detachObservers(t),Ne()})(t),(e=>{if(0===e.size)return;We("addObservers");const t=oo(e);no.overflow.attachObservers(t),no.resize.attachObserverToNonStaticElements(t),Ne()})(e)}function io(e){ro(e),on(F,"Mutation Observed")}const ao="Overflow",so=Tn(ao),co=Tn(ao,!1),lo=Mn(ao),uo=En(ao),fo=e=>e instanceof HTMLElement&&(!!e.hidden||null===e.offsetParent||e.style.display===u);function mo(){const{hasOverflow:e}=Ge,{hasOverflowUpdated:t,overflowedNodeSet:n}=to();switch(!0){case!t:return;case n.size>1:xe("Overflowed Elements:",n);break;case e:break;default:xe("No overflow detected")}on(V,"Overflow updated")}function go(e){const t={root:document.documentElement,side:lt.calculateHeight?N:H};return no.overflow=((e,t)=>{const n=t.side||N,r={root:t.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||o,a=(t=!1)=>e(t),s=(e,t)=>0===e||e>t[n],c=(e,t)=>{e.toggleAttribute(ue,t)},d=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t;if(!o)continue;const i=e[n],a=s(i,o)&&!(r instanceof HTMLElement&&fo(r));c(r,a)}i(a)},r),l=/* @__PURE__ */new WeakSet;return{attachObservers:function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;let o=0;for(const r of e)r instanceof Element&&(l.has(r)?t.add(r):(d.observe(r),l.add(r),n.add(r),o+=1));uo(t),lo(n),so(o),n.clear(),t.clear()},detachObservers:In(ao,d,l,co),disconnect:()=>{d.disconnect(),xe("Detached%c OverflowObserver",Se)}}})(mo,t),no.overflow.attachObservers(e),no.overflow}const ho="Resize",po=Tn(ho),bo=Tn(ho,!1),wo=Mn(ho),vo=En(ho),yo=/* @__PURE__ */new WeakSet,$o=/* @__PURE__ */new Set,zo=/* @__PURE__ */new Set;let Oo;function So(e){let t=0;for(const n of e){if(!(n instanceof Element))continue;const e=getComputedStyle(n)?.position;""!==e&&"static"!==e&&(yo.has(n)?$o.add(n):(Oo.observe(n),yo.add(n),zo.add(n),t+=1))}vo($o),wo(zo),po(t),zo.clear(),$o.clear()}function ko(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;on(D,`Element resized <${fe(t)}>`)}function Mo(e){return no.resize=(Oo=new ResizeObserver(ko),Oo.observe(document.body),yo.add(document.body),xe("Attached%c ResizeObserver%c to body",Se,ke),{attachObserverToNonStaticElements:So,detachObservers:In(ho,Oo,yo,bo),disconnect:()=>{Oo.disconnect(),xe("Detached%c ResizeObserver",Se)}}),no.resize.attachObserverToNonStaticElements(e),no.resize}let Eo;function Ro(){const e=document.title;e!==Eo&&(Eo=e,Ae(`Title: %c${e}`,Se),e&&St(0,0,me,e))}function To(e){Ae(`Visible: %c${e}`,Se),Ge.isHidden=!e,on(q,"Visibility changed")}function Io(){We("attachObservers");const e=Qt(document.documentElement);!function(e){Qe.push(...e.map(e=>e.disconnect))}([Gn(io),go(e),jt(),Mo(e),Kn(Ro),Zn(To)])}const Po=(e,t,n)=>{if(""!==n){Ae(`${e}: %c${n}`,Se);for(const e of document.querySelectorAll(n))Ae(`Applying ${t} to:`,e),e.toggleAttribute(t,!0)}};function Ao(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function xo(e,t){void 0!==t&&""!==t&&t!==ge&&(document.body.style.setProperty(e,t),xe(`Set body ${e}: %c${t}`,Se))}function Lo({bodyMarginStr:e,bodyMargin:t}){var n,o;void 0===e&&(e=`${t}px`),xo("margin",(n="margin",(o=e).includes("-")&&(Fe(`Negative CSS value ignored for ${n}`),o=""),o))}function Co(e){const t=e.getBoundingClientRect(),n={x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};return{x:Math.round(t.left+n.x),y:Math.round(t.top+n.y)}}function No(e){const t=e.split("#")[1]||e,n=decodeURIComponent(t),o=document.getElementById(n)||document.getElementsByName(n)[0];void 0===o?(Ae(`In page link (#${t}) not found in iframe, so sending to parent`),St(0,0,pe,`#${t}`)):function(e,t){const n=Co(t);Ae(`Moving to in page link (%c#${e}%c) at x: %c${n.x}%c y: %c${n.y}`,Se,ke,Se,ke,Se),St(n.y,n.x,se)}(t,o)}function Bo(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&No(t)}function Ho(){Ae("Setting up location.hash handlers"),function(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&Xe(e,"click",t=>{t.preventDefault(),No(e.getAttribute("href"))})}(),Xe(window,"hashchange",Bo),setTimeout(Bo,he),Ge.inPageLinks={findTarget:No}}function Wo(){const e=e=>e.style.setProperty(x,l,"important");e(document.documentElement),e(document.body),Ae("Set HTML & body height: %cauto !important",Se)}const qo=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Do=qo(ne),Fo=qo(te),Vo=qo(ee);function jo(e){Ae("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:n}=function(e){const{calculateHeight:t,calculateWidth:n}=lt;let o,r;return typeof e?.offsetSize===te&&(t&&(o=Fo(e,ve)),n&&(r=Fo(e,ve))),{offsetHeight:o,offsetWidth:r}}(e);return{offsetHeight:t,offsetWidth:n,ignoreSelector:Vo(e,"ignoreSelector"),[we(3)]:Vo(e,we(0)),sizeSelector:Vo(e,"sizeSelector"),targetOrigin:Vo(e,"targetOrigin"),onBeforeResize:Do(e,"onBeforeResize"),onMessage:Do(e,"onMessage"),onReady:Do(e,"onReady")}}function Uo(){const{mode:e}=lt;if(O(e))return{};const t=window.iframeResizer||window.iFrameResizer;return null===(n=t)||typeof n!==be||Array.isArray(n)?{}:jo(t);var n}const Qo=e=>t=>void 0===t?void 0:e(t),Jo=Qo(e=>"true"===e),Yo=Qo(Number);function Xo(e){for(const[t,n]of Object.entries(e))void 0!==n&&(lt[t]=n)}function Go({logExpand:e,logging:n,parentId:o=""}){var r;Te=(r={id:o,enabled:n,expand:e}).id||t,Ie.label(`${Te}`),Ie.expand(r.expand),Re=r.enabled,We("initReceived"),Ae(`Initialising iframe v${p} ${window.location.href}`)}function _o(e){We("ready"),bt(z(e)),Ae("Initialization complete",(({key:e,key2:t,...n})=>n)(lt))}function Ko({bodyBackground:e,bodyPadding:t,inPageLinks:n,onReady:r}){const i=(({calculateWidth:e,calculateHeight:t})=>e===t)(lt),a=[mt,ut,ht,vt,wt,i?o:dt,()=>Lo(lt),()=>xo("background",e),()=>xo("padding",t),i?o:Wo,Ao,Ge.applySelectors,()=>function(e){const{mode:t}=lt;e?O(t)?je(h(5)):Ho():Ae("In page linking not enabled")}(n),an,()=>function({mouseEvents:e}){!0===e&&(Mt(M,"Mouse Enter"),Mt(E,"Mouse Leave"))}(lt),Rt,()=>function(){const{win:e}=Ge;1!==lt.mode&&(e.parentIframe=Object.freeze({autoResize:ln,close:zn,getId:On,getParentOrigin:mn,getParentProps:hn,moveToAnchor:un,reset:Sn,setOffsetSize:fn,scrollBy:wn,scrollTo:vn,scrollToOffset:yn,sendMessage:$n,setTargetOrigin:gn,resize:pn}))}(),()=>on(k,"Init message from host page",void 0,void 0,`${p}:${lt.mode}`),Io,Ne];yt(lt),function({key:e,key2:t,mode:n,version:o}){const r=n,i=m(e)?g({key:e}):-1,a=m(t)?g({key:t}):-1;let s;switch(n=Math.max(i,a)){case-2:case-1:s=`${h(Math.min(i,a)+2)}${h(2)}`,Ge.firstRun=!1;break;case 1:case 2:case 3:s=h(6);break;case 4:s=h(7);break;case 5:s=h(8)}if(n>=0&&gt(n,r,o),(!m(o)||!Ge.firstRun)&&(s&&je(s),n<0))throw je(h(9)),s.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");lt.mode=n}(lt),function(e){const{mode:t}=lt;e.forEach(e=>{try{e()}catch(n){if(t<0)throw n;je("<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</>"),Be(n)}})}(a),_o(r)}function Zo(e){Ge.firstRun&&(Xo((e=>({parentId:e[0],bodyMargin:Yo(e[1]),calculateWidth:Jo(e[2]),logging:Jo(e[3]),autoResize:Jo(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:Yo(e[11]),inPageLinks:Jo(e[12]),mouseEvents:Jo(e[15]),offsetHeight:Yo(e[16]),offsetWidth:Yo(e[17]),calculateHeight:Jo(e[18]),key:e[19],version:e[20],mode:Yo(e[21]),logExpand:Jo(e[23])}))(e)),Go(lt),Xo(Uo()),Ge.applySelectors=function({sizeSelector:e,ignoreSelector:t}){return()=>{Po("sizeSelector",y,e),Po("ignoreSelector",f,t)}}(lt),Ko(lt))}const{freeze:er}=Object,{parse:tr}=JSON,nr=e=>er(tr(e)),or=e=>St(0,0,`${e}Stop`),rr=e=>e.data.slice(e.data.indexOf(d)+1),ir=e=>(e=>e.data.split(d)[2]in{true:1,false:1})(e)?k:e.data.split("]")[1].split(d)[0];const ar=e=>Ge.inPageLinks.findTarget(rr(e)),sr={init:function(e){if("loading"===document.readyState)return void Ae("Page not ready, ignoring init message");const t=e.data.slice(c).split(d);Ge.target=e.source,Ge.origin=e.origin,Zo(t),Ge.firstRun=!1,setTimeout(()=>{Ge.initLock=!1},he)},reset:function(){Ge.initLock?Ae("Page reset ignored by init"):(Ae("Page size reset by host page"),sn("resetPage"))},resize:function(){Ae("Resize requested by host page"),on(U,"Parent window requested size check")},moveToAnchor:ar,inPageLink:ar,pageInfo:function(e){const{onPageInfo:t}=Ge,n=rr(e);Ae("PageInfo received from parent:",nr(n)),t?w(t,tr(n)):or(ye)},parentInfo:function(e){const{onParentInfo:t}=Ge,n=nr(rr(e));Ae("ParentInfo received from parent:",n),t?w(t,n):or(oe)},message:function(e){const t=rr(e);Ae("onMessage called from parent:%c",Se,nr(t)),w(lt.onMessage,tr(t))}};function cr(e){const{firstRun:t}=Ge,n=ir(e);switch(We(n),!0){case n in sr:sr[n](e);break;case t&&(et in window||void 0!==window.jQuery&&et in window.jQuery.prototype):Fe(`Ignored message of type "${n}". Received before initialization.`);break;default:Fe(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const dr=He(e=>{(e=>s===`${e.data}`.slice(0,c))(e)&&cr(e)});typeof window!==$e&&function(){if("iframeChildListener"in window)Fe("Already setup");else{window.iframeChildListener=e=>{setTimeout(()=>dr({data:e,sameOrigin:!0}))},We("listen"),Xe(window,ce,dr),Xe(document,v,Ze),Ze();try{top?.document?.getElementById("banner")&&(Ge.win={},window.mockMsgListener=e,Ye(window,ce,dr),"function"==typeof window.define&&window.define([],()=>e))}catch(t){}}function e(e){return dr(e),Ge.win}}();
1275
21
  //# sourceMappingURL=index.esm.js.map