@iframe-resizer/core 5.2.2-beta.3 → 5.2.2

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