iframe-resizer 5.1.5-beta.1 → 5.2.3

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.
@@ -1,1320 +1,20 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/legacy (parent) 5.1.5-beta.1 (umd) - 2024-07-10
4
+ * @module iframe-resizer/legacy (parent) 5.2.3 (umd) - 2024-08-05
5
5
  *
6
- * @license GPL-3.0 for non-commercial use only.
7
- * For commercial use, you must purchase a license from
8
- * https://iframe-resizer.com/pricing
6
+ * @license GPL-3.0 for non-commercial use only.
7
+ * For commercial use, you must purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
9
  *
10
- * @desciption Keep same and cross domain iFrames sized to their content
10
+ * @description Keep same and cross domain iFrames sized to their content
11
11
  *
12
- * @author David J. Bradshaw <info@iframe-resizer.com>
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
13
  *
14
- * @see {@link https://iframe-resizer.com}
14
+ * @see {@link https://iframe-resizer.com}
15
15
  *
16
16
  * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
17
17
  */
18
18
 
19
19
 
20
- (function (global, factory) {
21
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
22
- typeof define === 'function' && define.amd ? define(factory) :
23
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.iframeResize = factory());
24
- })(this, (function () { 'use strict';
25
-
26
- const msg = `IFRAME-RESIZER 5
27
-
28
- This package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.
29
-
30
- Version 5 of iframe-resizer has been extensively rewritten to use modern browser APIs, which has enabled significantly better performance and greater accuracy in the detection of content resizing events.
31
-
32
- Please see https://iframe-resizer.com/upgrade for more details.
33
- `;
34
-
35
- console.warn(msg);
36
-
37
- const encode = (s) =>
38
- s
39
- .replaceAll('<br>', '\n')
40
- .replaceAll('<rb>', '\u001B[31;1m')
41
- .replaceAll('</>', '\u001B[m')
42
- .replaceAll('<b>', '\u001B[1m')
43
- .replaceAll('<i>', '\u001B[3m')
44
- .replaceAll('<u>', '\u001B[4m');
45
-
46
- const remove = (s) => s.replaceAll('<br>', '\n').replaceAll(/<[/a-z]+>/gi, '');
47
-
48
- const formatAdvise = (formatLogMsg) => (msg) =>
49
- window.chrome // Only show formatting in Chrome as not supported in other browsers
50
- ? formatLogMsg(encode(msg))
51
- : formatLogMsg(remove(msg));
52
-
53
- const msgId$1 = '[iframe-resizer]';
54
-
55
- function setLogEnabled(enabled) {
56
- }
57
-
58
- function getMyID(iframeId) {
59
- if (window.top === window.self) {
60
- return `Parent page: ${iframeId}`
61
- }
62
-
63
- return window?.parentIFrame?.getId
64
- ? `${window.parentIFrame.getId()}: ${iframeId}`
65
- : `Nested parent page: ${iframeId}`
66
- }
67
-
68
- const formatLogHeader = (iframeId) => `${msgId$1}[${getMyID(iframeId)}]`;
69
-
70
- const formatLogMsg =
71
- (iframeId) =>
72
- (...msg) =>
73
- [`${msgId$1}[${iframeId}]`, ...msg].join(' ');
74
-
75
- const output = (type, iframeId, ...msg) =>
76
- // eslint-disable-next-line no-console
77
- window?.console[type](formatLogHeader(iframeId), ...msg);
78
-
79
- const info = (iframeId, ...msg) => output('info', iframeId, ...msg);
80
-
81
- const warn = (iframeId, ...msg) => output('warn', iframeId, ...msg);
82
-
83
- const advise = (iframeId, msg) =>
84
- // eslint-disable-next-line no-console
85
- console?.warn(formatAdvise(formatLogMsg(iframeId))(msg));
86
-
87
- const VERSION = '5.1.5-beta.1';
88
-
89
- const msgHeader = 'message';
90
- const msgHeaderLen = msgHeader.length;
91
- const msgId = '[iFrameSizer]'; // Must match iframe msg ID
92
- const msgIdLen = msgId.length;
93
- const resetRequiredMethods = Object.freeze({
94
- max: 1,
95
- scroll: 1,
96
- bodyScroll: 1,
97
- documentElementScroll: 1,
98
- });
99
-
100
- const addEventListener = (el, evt, func, options) =>
101
- el.addEventListener(evt, func, options || false);
102
-
103
- const removeEventListener = (el, evt, func) =>
104
- el.removeEventListener(evt, func, false);
105
-
106
- const l = (l) => {
107
- if (!l) return ''
108
- let p = -559038744,
109
- y = 1103547984;
110
- for (let z, t = 0; t < l.length; t++)
111
- (z = l.codePointAt(t)),
112
- (p = Math.imul(p ^ z, 2246822519)),
113
- (y = Math.imul(y ^ z, 3266489917));
114
- return (
115
- (p ^= Math.imul(p ^ (y >>> 15), 1935289751)),
116
- (y ^= Math.imul(y ^ (p >>> 15), 3405138345)),
117
- (p ^= y >>> 16),
118
- (y ^= p >>> 16),
119
- (2097152 * (y >>> 0) + (p >>> 11)).toString(36)
120
- )
121
- },
122
- p = (l) =>
123
- l.replaceAll(/[A-Za-z]/g, (l) =>
124
- String.fromCodePoint(
125
- (l <= 'Z' ? 90 : 122) >= (l = l.codePointAt(0) + 19) ? l : l - 26,
126
- ),
127
- ),
128
- y = [
129
- '<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>',
130
- '<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>',
131
- '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</>',
132
- '<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</>.',
133
- ],
134
- z = ['NWSc3', 'zvsv', 'wyv', 'ibzpulzz', 'vlt'],
135
- t = Object.fromEntries(
136
- [
137
- '2cgs7fdf4xb',
138
- '1c9ctcccr4z',
139
- '1q2pc4eebgb',
140
- 'ueokt0969w',
141
- 'w2zxchhgqz',
142
- '1umuxblj2e5',
143
- ].map((l, p) => [l, Math.max(0, p - 1)]),
144
- );
145
- const getModeData = (l) => p(y[l]);
146
- const getModeLabel = (l) => p(z[l]);
147
- const setMode = (y) => {
148
- const z = y[p('spjluzl')];
149
- if (!z) return -1
150
- const u = z.split('-');
151
- let v = (function (y = '') {
152
- let z = -2;
153
- const u = l(p(y));
154
- return u in t && (z = t[u]), z
155
- })(u[0]);
156
- return 0 === v || ((p) => p[2] === l(p[0] + p[1]))(u) || (v = -2), v
157
- };
158
-
159
- const once = (fn) => {
160
- let done = false;
161
-
162
- return function () {
163
- return done
164
- ? undefined
165
- : ((done = true), Reflect.apply(fn, this, arguments))
166
- }
167
- };
168
-
169
- const settings = {};
170
-
171
- const onReadyDeprecated = (messageData) => {
172
- if (typeof settings[messageData.id].onInit === 'function') {
173
- advise(
174
- messageData.id,
175
- `
176
- \u001B[31;1mDeprecated Option\u001B[m
177
-
178
- The \u001B[1monInit()\u001B[m function is deprecated and has been replaced with \u001B[1monReady()\u001B[m. It will be removed in a future version of iFrame Resizer.
179
- `,
180
- );
181
- settings[messageData.id].onInit(messageData);
182
- }
183
- };
184
-
185
- const defaults = Object.freeze({
186
- autoResize: true,
187
- bodyBackground: null,
188
- bodyMargin: null,
189
- bodyPadding: null,
190
- checkOrigin: true,
191
- direction: 'vertical',
192
- inPageLinks: false,
193
- heightCalculationMethod: 'auto',
194
- id: 'iFrameResizer',
195
- log: false,
196
- license: undefined,
197
- mouseEvents: true,
198
- offsetHeight: null,
199
- offsetWidth: null,
200
- postMessageTarget: null,
201
- sameDomain: false,
202
- scrolling: false,
203
- sizeHeight: true,
204
- // sizeSelector: '',
205
- sizeWidth: false,
206
- warningTimeout: 5000,
207
- tolerance: 0,
208
- waitForLoad: false,
209
- widthCalculationMethod: 'auto',
210
- onClose: () => true,
211
- onClosed() {},
212
- onInit: false,
213
- onMessage: null,
214
- onMouseEnter() {},
215
- onMouseLeave() {},
216
- onReady: onReadyDeprecated,
217
- onResized() {},
218
- onScroll: () => true,
219
- });
220
-
221
- const page = {
222
- position: null,
223
- version: VERSION,
224
- };
225
-
226
- function iframeListener(event) {
227
- function resizeIFrame() {
228
- setSize(messageData);
229
- setPagePosition();
230
-
231
- on('onResized', messageData);
232
- }
233
-
234
- function getPaddingEnds(compStyle) {
235
- if (compStyle.boxSizing !== 'border-box') {
236
- return 0
237
- }
238
-
239
- const top = compStyle.paddingTop ? parseInt(compStyle.paddingTop, 10) : 0;
240
- const bot = compStyle.paddingBottom
241
- ? parseInt(compStyle.paddingBottom, 10)
242
- : 0;
243
-
244
- return top + bot
245
- }
246
-
247
- function getBorderEnds(compStyle) {
248
- if (compStyle.boxSizing !== 'border-box') {
249
- return 0
250
- }
251
-
252
- const top = compStyle.borderTopWidth
253
- ? parseInt(compStyle.borderTopWidth, 10)
254
- : 0;
255
- const bot = compStyle.borderBottomWidth
256
- ? parseInt(compStyle.borderBottomWidth, 10)
257
- : 0;
258
-
259
- return top + bot
260
- }
261
-
262
- function processMsg() {
263
- const data = msg.slice(msgIdLen).split(':');
264
- const height = data[1] ? Number(data[1]) : 0;
265
- const iframe = settings[data[0]]?.iframe;
266
- const compStyle = getComputedStyle(iframe);
267
-
268
- return {
269
- iframe,
270
- id: data[0],
271
- height: height + getPaddingEnds(compStyle) + getBorderEnds(compStyle),
272
- width: Number(data[2]),
273
- type: data[3],
274
- msg: data[4],
275
- }
276
- }
277
-
278
- function isMessageFromIFrame() {
279
- function checkAllowedOrigin() {
280
- function checkList() {
281
- let i = 0;
282
- let retCode = false;
283
-
284
- for (; i < checkOrigin.length; i++) {
285
- if (checkOrigin[i] === origin) {
286
- retCode = true;
287
- break
288
- }
289
- }
290
-
291
- return retCode
292
- }
293
-
294
- function checkSingle() {
295
- const remoteHost = settings[iframeId]?.remoteHost;
296
- return origin === remoteHost
297
- }
298
-
299
- return checkOrigin.constructor === Array ? checkList() : checkSingle()
300
- }
301
-
302
- const { origin, sameDomain } = event;
303
-
304
- if (sameDomain) {
305
- return true
306
- }
307
-
308
- let checkOrigin = settings[iframeId]?.checkOrigin;
309
-
310
- if (checkOrigin && `${origin}` !== 'null' && !checkAllowedOrigin()) {
311
- throw new Error(
312
- `Unexpected message received from: ${origin} for ${messageData.iframe.id}. Message was: ${event.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`,
313
- )
314
- }
315
-
316
- return true
317
- }
318
-
319
- function isMessageForUs() {
320
- return (
321
- msgId === `${msg}`.slice(0, msgIdLen) &&
322
- msg.slice(msgIdLen).split(':')[0] in settings
323
- ) // ''+Protects against non-string msg
324
- }
325
-
326
- function isMessageFromMetaParent() {
327
- // Test if this message is from a parent above us. This is an ugly test, however, updating
328
- // the message format would break backwards compatibility.
329
- const retCode = messageData.type in { true: 1, false: 1, undefined: 1 };
330
-
331
- return retCode
332
- }
333
-
334
- function getMsgBody(offset) {
335
- return msg.slice(msg.indexOf(':') + msgHeaderLen + offset)
336
- }
337
-
338
- function forwardMsgFromIFrame(msgBody) {
339
-
340
- on('onMessage', {
341
- iframe: messageData.iframe,
342
- message: JSON.parse(msgBody),
343
- });
344
- }
345
-
346
- function getPageInfo() {
347
- const bodyPosition = document.body.getBoundingClientRect();
348
- const iFramePosition = messageData.iframe.getBoundingClientRect();
349
- const { scrollY, scrollX, innerHeight, innerWidth } = window;
350
- const { clientHeight, clientWidth } = document.documentElement;
351
-
352
- return JSON.stringify({
353
- iframeHeight: iFramePosition.height,
354
- iframeWidth: iFramePosition.width,
355
- clientHeight: Math.max(clientHeight, innerHeight || 0),
356
- clientWidth: Math.max(clientWidth, innerWidth || 0),
357
- offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
358
- offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
359
- scrollTop: scrollY,
360
- scrollLeft: scrollX,
361
- documentHeight: clientHeight,
362
- documentWidth: clientWidth,
363
- windowHeight: innerHeight,
364
- windowWidth: innerWidth,
365
- })
366
- }
367
-
368
- function getParentProps() {
369
- const { iframe } = messageData;
370
- const { scrollWidth, scrollHeight } = document.documentElement;
371
- const { width, height, offsetLeft, offsetTop, pageLeft, pageTop, scale } =
372
- window.visualViewport;
373
-
374
- return JSON.stringify({
375
- iframe: iframe.getBoundingClientRect(),
376
- document: {
377
- scrollWidth,
378
- scrollHeight,
379
- },
380
- viewport: {
381
- width,
382
- height,
383
- offsetLeft,
384
- offsetTop,
385
- pageLeft,
386
- pageTop,
387
- scale,
388
- },
389
- })
390
- }
391
-
392
- const sendInfoToIframe = (type, infoFunction) => (requestType, iframeId) => {
393
- const gate = {};
394
-
395
- function throttle(func, frameId) {
396
- if (!gate[frameId]) {
397
- func();
398
- gate[frameId] = requestAnimationFrame(() => {
399
- gate[frameId] = null;
400
- });
401
- }
402
- }
403
-
404
- function gatedTrigger() {
405
- trigger(
406
- `Send ${type} (${requestType})`,
407
- `${type}:${infoFunction()}`,
408
- iframeId,
409
- );
410
- }
411
-
412
- throttle(gatedTrigger, iframeId);
413
- };
414
-
415
- const startInfoMonitor = (sendInfoToIframe, type) => () => {
416
- const sendInfo = (requestType) => () => {
417
- if (settings[id]) {
418
- sendInfoToIframe(requestType, id);
419
- } else {
420
- stop();
421
- }
422
- };
423
-
424
- function setListener(requestType, listener) {
425
- listener(window, 'scroll', sendInfo('scroll'));
426
- listener(window, 'resize', sendInfo('resize window'));
427
- }
428
-
429
- function stop() {
430
- setListener('Remove ', removeEventListener);
431
- pageObserver.disconnect();
432
- iframeObserver.disconnect();
433
- }
434
-
435
- function start() {
436
- setListener('Add ', addEventListener);
437
- pageObserver.observe(document.body, {
438
- attributes: true,
439
- childList: true,
440
- subtree: true,
441
- });
442
- iframeObserver.observe(settings[id].iframe, {
443
- attributes: true,
444
- childList: false,
445
- subtree: false,
446
- });
447
- }
448
-
449
- const id = iframeId; // Create locally scoped copy of iFrame ID
450
-
451
- const pageObserver = new ResizeObserver(sendInfo('page observed'));
452
- const iframeObserver = new ResizeObserver(sendInfo('iframe observed'));
453
-
454
- start();
455
-
456
- if (settings[id]) {
457
- settings[id][`stop${type}`] = stop;
458
- }
459
- };
460
-
461
- const stopInfoMonitor = (stopFunction) => () => {
462
- if (stopFunction in settings[iframeId]) {
463
- settings[iframeId][stopFunction]();
464
- delete settings[iframeId][stopFunction];
465
- }
466
- };
467
-
468
- const sendPageInfoToIframe = sendInfoToIframe('pageInfo', getPageInfo);
469
- const sendParentInfoToIframe = sendInfoToIframe('parentInfo', getParentProps);
470
-
471
- const startPageInfoMonitor = startInfoMonitor(
472
- sendPageInfoToIframe,
473
- 'PageInfo',
474
- );
475
- const startParentInfoMonitor = startInfoMonitor(
476
- sendParentInfoToIframe,
477
- 'ParentInfo',
478
- );
479
-
480
- const stopPageInfoMonitor = stopInfoMonitor('stopPageInfo');
481
- const stopParentInfoMonitor = stopInfoMonitor('stopParentInfo');
482
-
483
- function checkIFrameExists() {
484
- let retBool = true;
485
-
486
- if (messageData.iframe === null) {
487
- warn(iframeId, `The iframe (${messageData.id}) was not found.`);
488
- retBool = false;
489
- }
490
-
491
- return retBool
492
- }
493
-
494
- function getElementPosition(target) {
495
- const iFramePosition = target.getBoundingClientRect();
496
-
497
- getPagePosition();
498
-
499
- return {
500
- x: Number(iFramePosition.left) + Number(page.position.x),
501
- y: Number(iFramePosition.top) + Number(page.position.y),
502
- }
503
- }
504
-
505
- function scrollBy() {
506
- const x = messageData.width;
507
- const y = messageData.height;
508
-
509
- const target = window.parentIframe || window;
510
-
511
- target.scrollBy(x, y);
512
- }
513
-
514
- function scrollRequestFromChild(addOffset) {
515
- /* istanbul ignore next */ // Not testable in Karma
516
- function reposition() {
517
- page.position = newPosition;
518
- scrollTo(iframeId);
519
- }
520
-
521
- function scrollParent() {
522
- if (window.parentIFrame) {
523
- window.parentIFrame[`scrollTo${addOffset ? 'Offset' : ''}`](
524
- newPosition.x,
525
- newPosition.y,
526
- );
527
- } else {
528
- warn(
529
- iframeId,
530
- 'Unable to scroll to requested position, window.parentIFrame not found',
531
- );
532
- }
533
- }
534
-
535
- const calcOffset = (messageData, offset) => ({
536
- x: messageData.width + offset.x,
537
- y: messageData.height + offset.y,
538
- });
539
-
540
- const offset = addOffset
541
- ? getElementPosition(messageData.iframe)
542
- : { x: 0, y: 0 };
543
-
544
- let newPosition = calcOffset(messageData, offset);
545
-
546
- if (window.top === window.self) {
547
- reposition();
548
- } else {
549
- scrollParent();
550
- }
551
- }
552
-
553
- function scrollTo(iframeId) {
554
- const { x, y } = page.position;
555
- const iframe = settings[iframeId]?.iframe;
556
- if (on('onScroll', { iframe, top: y, left: x, x, y }) === false) {
557
- unsetPagePosition();
558
- return
559
- }
560
- setPagePosition();
561
- }
562
-
563
- function findTarget(location) {
564
- function jumpToTarget() {
565
- const jumpPosition = getElementPosition(target);
566
-
567
- page.position = {
568
- x: jumpPosition.x,
569
- y: jumpPosition.y,
570
- };
571
-
572
- scrollTo(iframeId);
573
- }
574
-
575
- function jumpToParent() {
576
- if (window.parentIFrame) {
577
- window.parentIFrame.moveToAnchor(hash);
578
- return
579
- }
580
- }
581
-
582
- const hash = location.split('#')[1] || '';
583
- const hashData = decodeURIComponent(hash);
584
-
585
- let target =
586
- document.getElementById(hashData) ||
587
- document.getElementsByName(hashData)[0];
588
-
589
- if (target) {
590
- jumpToTarget();
591
- return
592
- }
593
-
594
- if (window.top === window.self) {
595
- return
596
- }
597
-
598
- jumpToParent();
599
- }
600
-
601
- function onMouse(event) {
602
- let mousePos = {};
603
-
604
- if (messageData.width === 0 && messageData.height === 0) {
605
- const data = getMsgBody(9).split(':');
606
- mousePos = {
607
- x: data[1],
608
- y: data[0],
609
- };
610
- } else {
611
- mousePos = {
612
- x: messageData.width,
613
- y: messageData.height,
614
- };
615
- }
616
-
617
- on(event, {
618
- iframe: messageData.iframe,
619
- screenX: Number(mousePos.x),
620
- screenY: Number(mousePos.y),
621
- type: messageData.type,
622
- });
623
- }
624
-
625
- const on = (funcName, val) => chkEvent(iframeId, funcName, val);
626
-
627
- function checkSameDomain(id) {
628
- try {
629
- settings[id].sameDomain =
630
- !!settings[id]?.iframe?.contentWindow?.iframeChildListener;
631
- } catch (error) {
632
- settings[id].sameDomain = false;
633
- }
634
- }
635
-
636
- function checkVersion(version) {
637
- if (version === VERSION) return
638
- if (version === undefined) {
639
- advise(
640
- iframeId,
641
- `<rb>Legacy version detected in iframe</>
642
-
643
- Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
644
-
645
- See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
646
- `,
647
- );
648
- return
649
- }
650
- }
651
-
652
- function setTitle(title, iframeId) {
653
- if (!settings[iframeId]?.syncTitle) return
654
- settings[iframeId].iframe.title = title;
655
- }
656
-
657
- function started() {
658
- setup = true;
659
- }
660
-
661
- function actionMsg() {
662
- if (settings[iframeId]?.firstRun) firstRun();
663
-
664
- switch (messageData.type) {
665
- case 'close':
666
- closeIFrame(messageData.iframe);
667
- break
668
-
669
- case 'message':
670
- forwardMsgFromIFrame(getMsgBody(6));
671
- break
672
-
673
- case 'mouseenter':
674
- onMouse('onMouseEnter');
675
- break
676
-
677
- case 'mouseleave':
678
- onMouse('onMouseLeave');
679
- break
680
-
681
- case 'autoResize':
682
- settings[iframeId].autoResize = JSON.parse(getMsgBody(9));
683
- break
684
-
685
- case 'scrollBy':
686
- scrollBy();
687
- break
688
-
689
- case 'scrollTo':
690
- scrollRequestFromChild(false);
691
- break
692
-
693
- case 'scrollToOffset':
694
- scrollRequestFromChild(true);
695
- break
696
-
697
- case 'pageInfo':
698
- sendPageInfoToIframe('start', iframeId);
699
- startPageInfoMonitor();
700
- break
701
-
702
- case 'parentInfo':
703
- sendParentInfoToIframe('start', iframeId);
704
- startParentInfoMonitor();
705
- break
706
-
707
- case 'pageInfoStop':
708
- stopPageInfoMonitor();
709
- break
710
-
711
- case 'parentInfoStop':
712
- stopParentInfoMonitor();
713
- break
714
-
715
- case 'inPageLink':
716
- findTarget(getMsgBody(9));
717
- break
718
-
719
- case 'title':
720
- setTitle(messageData.msg, iframeId);
721
- break
722
-
723
- case 'reset':
724
- resetIFrame(messageData);
725
- break
726
-
727
- case 'init':
728
- resizeIFrame();
729
- checkSameDomain(iframeId);
730
- checkVersion(messageData.msg);
731
- started();
732
- on('onReady', messageData.iframe);
733
- break
734
-
735
- default:
736
- if (messageData.width === 0 && messageData.height === 0) {
737
- warn(
738
- `Unsupported message received (${messageData.type}), this is likely due to the iframe containing a later ` +
739
- `version of iframe-resizer than the parent page`,
740
- );
741
- return
742
- }
743
-
744
- if (messageData.width === 0 || messageData.height === 0) {
745
- return
746
- }
747
-
748
- // Recheck document.hidden here, as only Firefox
749
- // correctly supports this in the iframe
750
- if (document.hidden) {
751
- return
752
- }
753
-
754
- resizeIFrame();
755
- }
756
- }
757
-
758
- function checkSettings(iframeId) {
759
- if (!settings[iframeId]) {
760
- throw new Error(
761
- `${messageData.type} No settings for ${iframeId}. Message was: ${msg}`,
762
- )
763
- }
764
- }
765
-
766
- function iFrameReadyMsgReceived() {
767
- Object.keys(settings).forEach((iframeId) => {
768
- if (settings[iframeId].mode >= 0)
769
- trigger('iFrame requested init', createOutgoingMsg(iframeId), iframeId);
770
- });
771
- }
772
-
773
- function firstRun() {
774
- if (settings[iframeId]) {
775
- settings[iframeId].firstRun = false;
776
- }
777
- }
778
-
779
- let msg = event.data;
780
- let messageData = {};
781
- let iframeId = null;
782
-
783
- if (msg === '[iFrameResizerChild]Ready') {
784
- iFrameReadyMsgReceived();
785
- return
786
- }
787
-
788
- if (!isMessageForUs()) {
789
- return
790
- }
791
-
792
- messageData = processMsg();
793
- iframeId = messageData.id;
794
-
795
- if (!iframeId) {
796
- warn('iframeResizer received messageData without id, message was: ', msg);
797
- return
798
- }
799
-
800
- checkSettings(iframeId);
801
-
802
- if (!isMessageFromMetaParent()) {
803
- settings[iframeId].loaded = true;
804
-
805
- if (checkIFrameExists() && isMessageFromIFrame()) {
806
- actionMsg();
807
- }
808
- }
809
- }
810
-
811
- function chkEvent(iframeId, funcName, val) {
812
- let func = null;
813
- let retVal = null;
814
-
815
- if (settings[iframeId]) {
816
- func = settings[iframeId][funcName];
817
-
818
- if (typeof func === 'function') {
819
- retVal = func(val);
820
- } else {
821
- throw new TypeError(
822
- `${funcName} on iFrame[${iframeId}] is not a function`,
823
- )
824
- }
825
- }
826
-
827
- return retVal
828
- }
829
-
830
- function removeIframeListeners(iframe) {
831
- const iframeId = iframe.id;
832
- delete settings[iframeId];
833
- }
834
-
835
- function closeIFrame(iframe) {
836
- const iframeId = iframe.id;
837
- if (chkEvent(iframeId, 'onClose', iframeId) === false) {
838
- return
839
- }
840
-
841
- try {
842
- // Catch race condition error with React
843
- if (iframe.parentNode) {
844
- iframe.remove();
845
- }
846
- } catch (error) {
847
- warn(error);
848
- }
849
-
850
- chkEvent(iframeId, 'onClosed', iframeId);
851
- removeIframeListeners(iframe);
852
- }
853
-
854
- function getPagePosition(iframeId) {
855
- if (page.position === null) {
856
- page.position = {
857
- x: window.scrollX,
858
- y: window.scrollY,
859
- };
860
- }
861
- }
862
-
863
- function unsetPagePosition() {
864
- page.position = null;
865
- }
866
-
867
- function setPagePosition(iframeId) {
868
- if (page.position !== null) {
869
- window.scrollTo(page.position.x, page.position.y);
870
- unsetPagePosition();
871
- }
872
- }
873
-
874
- function resetIFrame(messageData) {
875
-
876
- getPagePosition(messageData.id);
877
- setSize(messageData);
878
- trigger('reset', 'reset', messageData.id);
879
- }
880
-
881
- function setSize(messageData) {
882
- const iframeId = messageData.id;
883
-
884
- function setDimension(dimension) {
885
- const size = `${messageData[dimension]}px`;
886
- messageData.iframe.style[dimension] = size;
887
- }
888
-
889
- if (settings[iframeId].sizeHeight) {
890
- setDimension('height');
891
- }
892
- if (settings[iframeId].sizeWidth) {
893
- setDimension('width');
894
- }
895
- }
896
-
897
- function trigger(calleeMsg, msg, id, noResponseWarning) {
898
- function postMessageToIFrame() {
899
- const { postMessageTarget, targetOrigin } = settings[id];
900
-
901
- if (settings[id].sameDomain) {
902
- try {
903
- settings[id].iframe.contentWindow.iframeChildListener(msgId + msg);
904
- return
905
- } catch (error) {
906
- }
907
- }
908
- postMessageTarget.postMessage(msgId + msg, targetOrigin);
909
- }
910
-
911
- function iFrameNotFound() {
912
- warn(id, `[${calleeMsg}] IFrame(${id}) not found`);
913
- }
914
-
915
- function chkAndSend() {
916
- if (!settings[id]?.postMessageTarget) {
917
- iFrameNotFound();
918
- return
919
- }
920
- postMessageToIFrame();
921
- }
922
-
923
- function warnOnNoResponse() {
924
- function warning() {
925
- if (settings[id] === undefined) return // iframe has been closed while we where waiting
926
-
927
- if (!settings[id].loaded && !settings[id].loadErrorShown) {
928
- settings[id].loadErrorShown = true;
929
- advise(
930
- id,
931
- `
932
- <rb>No response from iFrame</>
933
-
934
- The iframe (<i>${id}</>) has not responded within ${settings[id].warningTimeout / 1000} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
935
-
936
- This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
937
- `,
938
- );
939
- }
940
- }
941
-
942
- if (!!noResponseWarning && !!settings[id]?.warningTimeout) {
943
- settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout);
944
- }
945
- }
946
-
947
- if (settings[id]) {
948
- chkAndSend();
949
- warnOnNoResponse();
950
- }
951
- }
952
-
953
- function createOutgoingMsg(iframeId) {
954
- const iframeSettings = settings[iframeId];
955
-
956
- return [
957
- iframeId,
958
- '8', // Backwards compatibility (PaddingV1)
959
- iframeSettings.sizeWidth,
960
- iframeSettings.log,
961
- '32', // Backwards compatibility (Interval)
962
- true, // Backwards compatibility (EnablePublicMethods)
963
- iframeSettings.autoResize,
964
- iframeSettings.bodyMargin,
965
- iframeSettings.heightCalculationMethod,
966
- iframeSettings.bodyBackground,
967
- iframeSettings.bodyPadding,
968
- iframeSettings.tolerance,
969
- iframeSettings.inPageLinks,
970
- 'child', // Backwards compatibility (resizeFrom)
971
- iframeSettings.widthCalculationMethod,
972
- iframeSettings.mouseEvents,
973
- iframeSettings.offsetHeight,
974
- iframeSettings.offsetWidth,
975
- iframeSettings.sizeHeight,
976
- iframeSettings.license,
977
- page.version,
978
- iframeSettings.mode,
979
- // iframeSettings.sizeSelector,
980
- ].join(':')
981
- }
982
-
983
- let count = 0;
984
- let setup = false;
985
- let vAdvised = false;
986
-
987
- const connectResizer = (options) => (iframe) => {
988
- function newId() {
989
- let id = options?.id || defaults.id + count++;
990
-
991
- if (document.getElementById(id) !== null) {
992
- id += count++;
993
- }
994
-
995
- return id
996
- }
997
-
998
- function ensureHasId(iframeId) {
999
- if (iframeId && typeof iframeId !== 'string') {
1000
- throw new TypeError('Invalid id for iFrame. Expected String')
1001
- }
1002
-
1003
- if (iframeId === '' || !iframeId) {
1004
- // eslint-disable-next-line no-multi-assign
1005
- iframe.id = iframeId = newId();
1006
- setLogEnabled((options || {}).log);
1007
- }
1008
-
1009
- return iframeId
1010
- }
1011
-
1012
- function setScrolling() {
1013
-
1014
- iframe.style.overflow =
1015
- settings[iframeId]?.scrolling === false ? 'hidden' : 'auto';
1016
-
1017
- switch (settings[iframeId]?.scrolling) {
1018
- case 'omit':
1019
- break
1020
-
1021
- case true:
1022
- iframe.scrolling = 'yes';
1023
- break
1024
-
1025
- case false:
1026
- iframe.scrolling = 'no';
1027
- break
1028
-
1029
- default:
1030
- iframe.scrolling = settings[iframeId]
1031
- ? settings[iframeId].scrolling
1032
- : 'no';
1033
- }
1034
- }
1035
-
1036
- function setupBodyMarginValues() {
1037
- const { bodyMargin } = settings[iframeId];
1038
-
1039
- if (typeof bodyMargin === 'number' || bodyMargin === '0') {
1040
- settings[iframeId].bodyMargin = `${bodyMargin}px`;
1041
- }
1042
- }
1043
-
1044
- function checkReset() {
1045
- const firstRun = settings[iframeId]?.firstRun;
1046
- const resetRequestMethod =
1047
- settings[iframeId]?.heightCalculationMethod in resetRequiredMethods;
1048
-
1049
- if (!firstRun && resetRequestMethod) {
1050
- resetIFrame({ iframe, height: 0, width: 0, type: 'init' });
1051
- }
1052
- }
1053
-
1054
- function setupIFrameObject() {
1055
- if (settings[iframeId]) {
1056
- const resizer = {
1057
- close: closeIFrame.bind(null, settings[iframeId].iframe),
1058
-
1059
- disconnect: removeIframeListeners.bind(null, settings[iframeId].iframe),
1060
-
1061
- removeListeners() {
1062
- advise(
1063
- iframeId,
1064
- `
1065
- <rb>Deprecated Method Name</>
1066
-
1067
- The \u001B[removeListeners()</> method has been renamed to \u001B[disconnect()</>.
1068
- `,
1069
- );
1070
- this.disconnect();
1071
- },
1072
-
1073
- resize: trigger.bind(null, 'Window resize', 'resize', iframeId),
1074
-
1075
- moveToAnchor(anchor) {
1076
- trigger('Move to anchor', `moveToAnchor:${anchor}`, iframeId);
1077
- },
1078
-
1079
- sendMessage(message) {
1080
- message = JSON.stringify(message);
1081
- trigger('Send Message', `message:${message}`, iframeId);
1082
- },
1083
- };
1084
-
1085
- settings[iframeId].iframe.iframeResizer = resizer;
1086
- settings[iframeId].iframe.iFrameResizer = resizer;
1087
- }
1088
- }
1089
-
1090
- // We have to call trigger twice, as we can not be sure if all
1091
- // iframes have completed loading when this code runs. The
1092
- // event listener also catches the page changing in the iFrame.
1093
- function init(msg) {
1094
- function iFrameLoaded() {
1095
- trigger('iFrame.onload', `${msg}:${setup}`, id, true);
1096
- checkReset();
1097
- }
1098
-
1099
- const { id } = iframe;
1100
-
1101
- if (settings[id].mode === -1) return // modal()
1102
- if (settings[id].mode === -2) return
1103
-
1104
- addEventListener(iframe, 'load', iFrameLoaded);
1105
- if (settings[id].waitForLoad === false)
1106
- trigger('init', `${msg}:${setup}`, id, true);
1107
- }
1108
-
1109
- function checkOptions(options) {
1110
- if (!options) return {}
1111
-
1112
- if (typeof options !== 'object') {
1113
- throw new TypeError('Options is not an object')
1114
- }
1115
-
1116
- if (
1117
- 'sizeWidth' in options ||
1118
- 'sizeHeight' in options ||
1119
- 'autoResize' in options
1120
- ) {
1121
- advise(
1122
- iframeId,
1123
- `<rb>Deprecated Option</>
1124
-
1125
- The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.
1126
- `,
1127
- );
1128
- }
1129
-
1130
- return options
1131
- }
1132
-
1133
- function checkMode() {
1134
- const { mode } = settings[iframeId];
1135
- if (mode < 0) advise('Parent', `${getModeData(mode + 2)}${getModeData(2)}`);
1136
- if (vAdvised || mode < 0) return
1137
- vAdvised = true;
1138
- info(`v${VERSION} (${getModeLabel(mode)})`);
1139
- if (mode < 1) advise('Parent', getModeData(3));
1140
- }
1141
-
1142
- function setDirection() {
1143
- if (settings[iframeId].direction === 'horizontal') {
1144
- settings[iframeId].sizeWidth = true;
1145
- settings[iframeId].sizeHeight = false;
1146
- return
1147
- }
1148
-
1149
- if (settings[iframeId].direction === 'none') {
1150
- settings[iframeId].sizeWidth = false;
1151
- settings[iframeId].sizeHeight = false;
1152
- settings[iframeId].autoResize = false;
1153
- return
1154
- }
1155
-
1156
- if (settings[iframeId].direction !== 'vertical') {
1157
- throw new TypeError(
1158
- iframeId,
1159
- `Direction value of "${settings[iframeId].direction}" is not valid`,
1160
- )
1161
- }
1162
- }
1163
-
1164
- function setOffset(offset) {
1165
- if (!offset) return
1166
- if (settings[iframeId].direction === 'vertical') {
1167
- settings[iframeId].offsetHeight = offset;
1168
- } else {
1169
- settings[iframeId].offsetWidth = offset;
1170
- }
1171
- }
1172
-
1173
- function getTargetOrigin(remoteHost) {
1174
- return remoteHost === '' ||
1175
- remoteHost.match(/^(about:blank|javascript:|file:\/\/)/) !== null
1176
- ? '*'
1177
- : remoteHost
1178
- }
1179
-
1180
- function getPostMessageTarget() {
1181
- if (settings[iframeId].postMessageTarget === null)
1182
- settings[iframeId].postMessageTarget = iframe.contentWindow;
1183
- }
1184
-
1185
- function chkTitle(iframeId) {
1186
- const title = settings[iframeId]?.iframe?.title;
1187
- return title === '' || title === undefined
1188
- }
1189
-
1190
- function processOptions(options) {
1191
- settings[iframeId] = {
1192
- iframe,
1193
- firstRun: true,
1194
- remoteHost: iframe?.src.split('/').slice(0, 3).join('/'),
1195
- ...defaults,
1196
- ...checkOptions(options),
1197
- mode: setMode(options),
1198
- syncTitle: chkTitle(iframeId),
1199
- };
1200
-
1201
- setDirection();
1202
- setOffset(options?.offset);
1203
- getPostMessageTarget();
1204
-
1205
- settings[iframeId].targetOrigin =
1206
- settings[iframeId].checkOrigin === true
1207
- ? getTargetOrigin(settings[iframeId].remoteHost)
1208
- : '*';
1209
- }
1210
-
1211
- function beenHere() {
1212
- return iframeId in settings && 'iFrameResizer' in iframe
1213
- }
1214
-
1215
- const iframeId = ensureHasId(iframe.id);
1216
-
1217
- if (beenHere()) {
1218
- warn(iframeId, 'Ignored iFrame, already setup.');
1219
- } else {
1220
- processOptions(options);
1221
- checkMode();
1222
- setupEventListenersOnce();
1223
- setScrolling();
1224
- setupBodyMarginValues();
1225
- init(createOutgoingMsg(iframeId));
1226
- setupIFrameObject();
1227
- }
1228
-
1229
- return iframe?.iFrameResizer
1230
- };
1231
-
1232
- function sendTriggerMsg(eventName, event) {
1233
- function triggerEnabledIframe(iframeId) {
1234
- if (isIFrameResizeEnabled(iframeId)) {
1235
- trigger(eventName, event, iframeId);
1236
- }
1237
- }
1238
-
1239
- const isIFrameResizeEnabled = (iframeId) =>
1240
- settings[iframeId]?.autoResize && !settings[iframeId]?.firstRun;
1241
-
1242
- Object.keys(settings).forEach(triggerEnabledIframe);
1243
- }
1244
-
1245
- function tabVisible() {
1246
- if (document.hidden === false) {
1247
- sendTriggerMsg('Tab Visible', 'resize');
1248
- }
1249
- }
1250
-
1251
- const setupEventListenersOnce = once(() => {
1252
- addEventListener(window, 'message', iframeListener);
1253
- addEventListener(document, 'visibilitychange', tabVisible);
1254
- window.iframeParentListener = (data) =>
1255
- iframeListener({ data, sameDomain: true });
1256
- });
1257
-
1258
- const id = '[iframeResizer] ';
1259
-
1260
- function createIframeResize() {
1261
- function setup(element) {
1262
- switch (true) {
1263
- case !element:
1264
- throw new TypeError(`${id}iframe is not defined`)
1265
-
1266
- case !element.tagName:
1267
- throw new TypeError(`${id}Not a valid DOM element`)
1268
-
1269
- case element.tagName.toUpperCase() !== 'IFRAME':
1270
- throw new TypeError(
1271
- `${id}Expected <IFRAME> tag, found <${element.tagName}>`,
1272
- )
1273
-
1274
- default:
1275
- connectWithOptions(element);
1276
- iFrames.push(element);
1277
- }
1278
- }
1279
-
1280
- let connectWithOptions;
1281
- let iFrames;
1282
-
1283
- return function (options, target) {
1284
- if (typeof window === 'undefined') return [] // don't run for server side render
1285
-
1286
- connectWithOptions = connectResizer(options);
1287
- iFrames = []; // Only return iFrames passed in on this call
1288
-
1289
- switch (typeof target) {
1290
- case 'undefined':
1291
- case 'string':
1292
- document.querySelectorAll(target || 'iframe').forEach(setup);
1293
- break
1294
-
1295
- case 'object':
1296
- setup(target);
1297
- break
1298
-
1299
- default:
1300
- throw new TypeError(`${id}Unexpected data type (${typeof target})`)
1301
- }
1302
-
1303
- return Object.freeze(iFrames)
1304
- }
1305
- }
1306
-
1307
- const iframeResize = createIframeResize();
1308
-
1309
- if (typeof window !== 'undefined') {
1310
- window.iFrameResize =
1311
- window.iFrameResize ||
1312
- function (...args) {
1313
- advise('', 'Deprecated: iFrameResize(), please use iframeResize()');
1314
- iframeResize(...args);
1315
- };
1316
- }
1317
-
1318
- return iframeResize;
1319
-
1320
- }));
20
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=t()}(this,(function(){"use strict";console.info("IFRAME-RESIZER 5\n\nThis package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.\n\nGoing forward you are advised to use the new separate packages for Parent and Child pages, rather than this combined package.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n");const e="[iframe-resizer]";const t=t=>`${e}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(t)}]`,i=(e,i,...n)=>window?.console[e](t(i),...n),n=(e,...t)=>i("warn",e,...t),o=(t,i)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(t.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((t=>(...i)=>[`${e}[${t}]`,...i].join(" "))(t))(i)),r="5.2.3",a="[iFrameSizer]",s=a.length,l=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),c=(e,t,i,n)=>e.addEventListener(t,i,n||!1),d=(e,t,i)=>e.removeEventListener(t,i,!1),u=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),t=Math.imul(t^n,2246822519),i=Math.imul(i^n,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},f=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),p=["<iy><yi>Puchspk Spjluzl Rlf</><iy><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</>."],h=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],m=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)]))),y=e=>f(p[e]),g=e=>{const t=e[f("spjluzl")];if(!t)return-1;const i=t.split("-");let n=function(e=""){let t=-2;const i=u(f(e));return i in m&&(t=m[i]),t}(i[0]);return 0===n||(e=>e[2]===u(e[0]+e[1]))(i)||(n=-2),n},w={},b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,waitForLoad:!1,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof w[e.id].onInit&&(o(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),w[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),v={position:null,version:r};function z(e){function t(){S(P),I(),L("onResized",P)}function i(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function u(e){return O.slice(O.indexOf(":")+7+e)}const f=(e,t)=>(i,n)=>{const o={};var r,a;r=function(){x(`Send ${e} (${i})`,`${e}:${t()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},p=(e,t)=>()=>{const i=t=>()=>{w[r]?e(t,r):o()};function n(e,t){t(window,"scroll",i("scroll")),t(window,"resize",i("resize window"))}function o(){n(0,d),a.disconnect(),s.disconnect()}const r=H,a=new ResizeObserver(i("page observed")),s=new ResizeObserver(i("iframe observed"));n(0,c),a.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),s.observe(w[r].iframe,{attributes:!0,childList:!1,subtree:!1}),w[r]&&(w[r][`stop${t}`]=o)},h=e=>()=>{e in w[H]&&(w[H][e](),delete w[H][e])},m=f("pageInfo",(function(){const e=document.body.getBoundingClientRect(),t=P.iframe.getBoundingClientRect(),{scrollY:i,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=f("parentInfo",(function(){const{iframe:e}=P,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),g=p(m,"PageInfo"),b=p(y,"ParentInfo"),z=h("stopPageInfo"),k=h("stopParentInfo");function F(e){const t=e.getBoundingClientRect();return R(),{x:Number(t.left)+Number(v.position.x),y:Number(t.top)+Number(v.position.y)}}function N(e){const t=e?F(P.iframe):{x:0,y:0};let i=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(P,t);window.top===window.self?(v.position=i,A(H)):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):n(H,"Unable to scroll to requested position, window.parentIFrame not found")}function A(e){const{x:t,y:i}=v.position,n=w[e]?.iframe;!1!==L("onScroll",{iframe:n,top:i,left:t,x:t,y:i})?I():$()}function C(e){let t={};if(0===P.width&&0===P.height){const e=u(9).split(":");t={x:e[1],y:e[0]}}else t={x:P.width,y:P.height};L(e,{iframe:P.iframe,screenX:Number(t.x),screenY:Number(t.y),type:P.type})}const L=(e,t)=>j(H,e,t);let O=e.data,P={},H=null;"[iFrameResizerChild]Ready"!==O?a===`${O}`.slice(0,s)&&O.slice(s).split(":")[0]in w&&(P=function(){const e=O.slice(s).split(":"),t=e[1]?Number(e[1]):0,n=w[e[0]]?.iframe,o=getComputedStyle(n);return{iframe:n,id:e[0],height:t+i(o)+l(o),width:Number(e[2]),type:e[3],msg:e[4]}}(),H=P.id,H?(function(e){if(!w[e])throw new Error(`${P.type} No settings for ${e}. Message was: ${O}`)}(H),P.type in{true:1,false:1,undefined:1}||(w[H].loaded=!0,function(){let e=!0;return null===P.iframe&&(n(H,`The iframe (${P.id}) was not found.`),e=!1),e}()&&function(){const{origin:t,sameDomain:i}=e;if(i)return!0;let n=w[H]?.checkOrigin;if(n&&"null"!=`${t}`&&!(n.constructor===Array?function(){let e=0,i=!1;for(;e<n.length;e++)if(n[e]===t){i=!0;break}return i}():function(){const e=w[H]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${P.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&function(){switch(w[H]?.firstRun&&w[H]&&(w[H].firstRun=!1),P.type){case"close":T(P.iframe);break;case"message":i=u(6),L("onMessage",{iframe:P.iframe,message:JSON.parse(i)});break;case"mouseenter":C("onMouseEnter");break;case"mouseleave":C("onMouseLeave");break;case"autoResize":w[H].autoResize=JSON.parse(u(9));break;case"scrollBy":!function(){const e=P.width,t=P.height;(window.parentIframe||window).scrollBy(e,t)}();break;case"scrollTo":N(!1);break;case"scrollToOffset":N(!0);break;case"pageInfo":m("start",H),g();break;case"parentInfo":y("start",H),b();break;case"pageInfoStop":z();break;case"parentInfoStop":k();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",i=decodeURIComponent(t);let n=document.getElementById(i)||document.getElementsByName(i)[0];n?function(){const e=F(n);v.position={x:e.x,y:e.y},A(H),window.location.hash=t}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(t)}(u(9));break;case"title":!function(e,t){w[t]?.syncTitle&&(w[t].iframe.title=e)}(P.msg,H);break;case"reset":M(P);break;case"init":t(),function(e){try{w[e].sameDomain=!!w[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){w[e].sameDomain=!1}}(H),(e=P.msg)!==r&&(void 0!==e||o(H,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),W=!0,L("onReady",P.iframe);break;default:if(0===P.width&&0===P.height)return void n(`Unsupported message received (${P.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===P.width||0===P.height)return;if(document.hidden)return;t()}var e,i}())):n("iframeResizer received messageData without id, message was: ",O)):Object.keys(w).forEach((e=>{w[e].mode>=0&&x("iFrame requested init",E(e),e)}))}function j(e,t,i){let n=null,o=null;if(w[e]){if(n=w[e][t],"function"!=typeof n)throw new TypeError(`${t} on iFrame[${e}] is not a function`);o=n(i)}return o}function k(e){const t=e.id;delete w[t]}function T(e){const t=e.id;if(!1!==j(t,"onClose",t)){try{e.parentNode&&e.remove()}catch(e){n(e)}j(t,"onClosed",t),k(e)}}function R(e){null===v.position&&(v.position={x:window.scrollX,y:window.scrollY})}function $(){v.position=null}function I(e){null!==v.position&&(window.scrollTo(v.position.x,v.position.y),$())}function M(e){R(e.id),S(e),x("reset","reset",e.id)}function S(e){const t=e.id;function i(t){const i=`${e[t]}px`;e.iframe.style[t]=i}w[t].sizeHeight&&i("height"),w[t].sizeWidth&&i("width")}function x(e,t,i,r){w[i]&&(w[i]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:n}=w[i];if(w[i].sameDomain)try{return void w[i].iframe.contentWindow.iframeChildListener(a+t)}catch(e){}e.postMessage(a+t,n)}():n(i,`[${e}] IFrame(${i}) not found`),r&&w[i]?.warningTimeout&&(w[i].msgTimeout=setTimeout((function(){if(void 0===w[i])return;const{waitForLoad:e}=w[i];w[i].loaded||w[i].loadErrorShown||(w[i].loadErrorShown=!0,o(i,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${i}</>) has not responded within ${w[i].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${e?"\nThe <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>. \n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`))}),w[i].warningTimeout)))}function E(e){const t=w[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,v.version,t.mode].join(":")}let F=0,W=!1,N=!1;const A=e=>t=>{function a(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&o(d,'<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}function s(e){const t=w[e]?.iframe?.title;return""===t||void 0===t}const d=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(t.id=i=function(){let t=e?.id||b.id+F++;return null!==document.getElementById(t)&&(t+=F++),t}(),(e||{}).log),i}(t.id);return d in w&&"iFrameResizer"in t?n(d,"Ignored iFrame, already setup."):(function(e){var i,n;w[d]={iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...b,...a(e),mode:g(e),syncTitle:s(d)},function(){if("horizontal"===w[d].direction)return w[d].sizeWidth=!0,void(w[d].sizeHeight=!1);if("none"===w[d].direction)return w[d].sizeWidth=!1,w[d].sizeHeight=!1,void(w[d].autoResize=!1);if("vertical"!==w[d].direction)throw new TypeError(d,`Direction value of "${w[d].direction}" is not valid`)}(),(i=e?.offsetSize||e?.offset)&&("vertical"===w[d].direction?w[d].offsetHeight=i:w[d].offsetWidth=i),e?.offset&&o(d,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>."),null===w[d].postMessageTarget&&(w[d].postMessageTarget=t.contentWindow),w[d].targetOrigin=!0===w[d].checkOrigin?""===(n=w[d].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(e),function(){const{mode:e}=w[d];e<0&&o("Parent",`${y(e+2)}${y(2)}`),N||e<0||(N=!0,((e,...t)=>{i("info",e,...t)})(`v${r} (${(e=>f(h[e]))(e)})`),e<1&&o("Parent",y(3)))}(),L(),function(){switch(t.style.overflow=!1===w[d]?.scrolling?"hidden":"auto",w[d]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=w[d]?w[d].scrolling:"no"}}(),function(){const{bodyMargin:e}=w[d];"number"!=typeof e&&"0"!==e||(w[d].bodyMargin=`${e}px`)}(),function(e){const{id:i}=t;-1!==w[i].mode&&-2!==w[i].mode&&(c(t,"load",(function(){x("iFrame.onload",`${e}:${W}`,i,!0),function(){const e=w[d]?.firstRun,i=w[d]?.heightCalculationMethod in l;!e&&i&&M({iframe:t,height:0,width:0,type:"init"})}()})),!1===w[i].waitForLoad&&x("init",`${e}:${W}`,i,!0))}(E(d)),function(){if(w[d]){const e={close:T.bind(null,w[d].iframe),disconnect:k.bind(null,w[d].iframe),removeListeners(){o(d,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:x.bind(null,"Window resize","resize",d),moveToAnchor(e){x("Move to anchor",`moveToAnchor:${e}`,d)},sendMessage(e){x("Send Message",`message:${e=JSON.stringify(e)}`,d)}};w[d].iframe.iframeResizer=e,w[d].iframe.iFrameResizer=e}}()),t?.iFrameResizer};function C(){!1===document.hidden&&function(e,t){const i=e=>w[e]?.autoResize&&!w[e]?.firstRun;Object.keys(w).forEach((function(n){i(n)&&x(e,t,n)}))}("Tab Visible","resize")}const L=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})((()=>{c(window,"message",z),c(document,"visibilitychange",C),window.iframeParentListener=e=>z({data:e,sameDomain:!0})})),O="[iframeResizer] ";const P=function(){function e(e){switch(!0){case!e:throw new TypeError(`${O}iframe is not defined`);case!e.tagName:throw new TypeError(`${O}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${O}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),i.push(e)}}let t,i;return function(n,o){if("undefined"==typeof window)return[];switch(t=A(n),i=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${O}Unexpected data type (${typeof o})`)}return Object.freeze(i)}}();return"undefined"!=typeof window&&(window.iFrameResize=window.iFrameResize||function(...e){o("","Deprecated: iFrameResize(), please use iframeResize()"),P(...e)}),P}));