PageSourceSearch

https://www.fhi360.org/wp-content/themes/gesso/build/js/interactive-map.es6.js?ver=d7b6c90bc25428549bcb

js fhi360.org collected 2026-09-24 08:48:47 UTC 43,332 bytes, 1,133 lines download raw bytes

1/******/ (function() { // webpackBootstrap
2/******/ 	"use strict";
3/******/ 	var __webpack_modules__ = ({
4
vendor: 29,590 bytes, lines 5-801
5/***/ "./node_modules/@panzoom/panzoom/dist/panzoom.es.js":
6/*!**********************************************************!*\
7  !*** ./node_modules/@panzoom/panzoom/dist/panzoom.es.js ***!
8  \**********************************************************/
9/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10
11__webpack_require__.r(__webpack_exports__);
12/* harmony export */ __webpack_require__.d(__webpack_exports__, {
13/* harmony export */   "default": function() { return /* binding */ Panzoom; }
14/* harmony export */ });
15/**
16* Panzoom for panning and zooming elements using CSS transforms
17* Copyright Timmy Willison and other contributors
18* https://github.com/timmywil/panzoom/blob/main/MIT-License.txt
19*/
20/******************************************************************************
21Copyright (c) Microsoft Corporation.
22
23Permission to use, copy, modify, and/or distribute this software for any
24purpose with or without fee is hereby granted.
25
26THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
27REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
28AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
29INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
30LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
31OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
32PERFORMANCE OF THIS SOFTWARE.
33***************************************************************************** */
34
35var __assign = function() {
36    __assign = Object.assign || function __assign(t) {
37        for (var s, i = 1, n = arguments.length; i < n; i++) {
38            s = arguments[i];
39            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40        }
41        return t;
42    };
43    return __assign.apply(this, arguments);
44};
45
46/* eslint-disable no-var */
47if (typeof window !== 'undefined') {
48  // Support: IE11 only
49  if (window.NodeList && !NodeList.prototype.forEach) {
50    NodeList.prototype.forEach = Array.prototype.forEach;
51  }
52  // Support: IE11 only
53  // CustomEvent is an object instead of a constructor
54  if (typeof window.CustomEvent !== 'function') {
55    window.CustomEvent = function CustomEvent(event, params) {
56      params = params || { bubbles: false, cancelable: false, detail: null };
57      var evt = document.createEvent('CustomEvent');
58      evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
59      return evt
60    };
61  }
62}
63
64/**
65 * Utilites for working with multiple pointer events
66 */
67function findEventIndex(pointers, event) {
68    var i = pointers.length;
69    while (i--) {
70        if (pointers[i].pointerId === event.pointerId) {
71            return i;
72        }
73    }
74    return -1;
75}
76function addPointer(pointers, event) {
77    var i;
78    // Add touches if applicable
79    if (event.touches) {
80        i = 0;
81        for (var _i = 0, _a = event.touches; _i < _a.length; _i++) {
82            var touch = _a[_i];
83            touch.pointerId = i++;
84            addPointer(pointers, touch);
85        }
86        return;
87    }
88    i = findEventIndex(pointers, event);
89    // Update if already present
90    if (i > -1) {
91        pointers.splice(i, 1);
92    }
93    pointers.push(event);
94}
95function removePointer(pointers, event) {
96    // Add touches if applicable
97    if (event.touches) {
98        // Remove all touches
99        while (pointers.length) {
100            pointers.pop();
101        }
102        return;
103    }
104    var i = findEventIndex(pointers, event);
105    if (i > -1) {
106        pointers.splice(i, 1);
107    }
108}
109/**
110 * Calculates a center point between
111 * the given pointer events, for panning
112 * with multiple pointers.
113 */
114function getMiddle(pointers) {
115    // Copy to avoid changing by reference
116    pointers = pointers.slice(0);
117    var event1 = pointers.pop();
118    var event2;
119    while ((event2 = pointers.pop())) {
120        event1 = {
121            clientX: (event2.clientX - event1.clientX) / 2 + event1.clientX,
122            clientY: (event2.clientY - event1.clientY) / 2 + event1.clientY
123        };
124    }
125    return event1;
126}
127/**
128 * Calculates the distance between two points
129 * for pinch zooming.
130 * Limits to the first 2
131 */
132function getDistance(pointers) {
133    if (pointers.length < 2) {
134        return 0;
135    }
136    var event1 = pointers[0];
137    var event2 = pointers[1];
138    return Math.sqrt(Math.pow(Math.abs(event2.clientX - event1.clientX), 2) +
139        Math.pow(Math.abs(event2.clientY - event1.clientY), 2));
140}
141
142var events = {
143    down: 'mousedown',
144    move: 'mousemove',
145    up: 'mouseup mouseleave'
146};
147if (typeof window !== 'undefined') {
148    if (typeof window.PointerEvent === 'function') {
149        events = {
150            down: 'pointerdown',
151            move: 'pointermove',
152            up: 'pointerup pointerleave pointercancel'
153        };
154    }
155    else if (typeof window.TouchEvent === 'function') {
156        events = {
157            down: 'touchstart',
158            move: 'touchmove',
159            up: 'touchend touchcancel'
160        };
161    }
162}
163function onPointer(event, elem, handler, eventOpts) {
164    events[event].split(' ').forEach(function (name) {
165        elem.addEventListener(name, handler, eventOpts);
166    });
167}
168function destroyPointer(event, elem, handler) {
169    events[event].split(' ').forEach(function (name) {
170        elem.removeEventListener(name, handler);
171    });
172}
173
174var isIE = typeof document !== 'undefined' && !!document.documentMode;
175/**
176 * Lazy creation of a CSS style declaration
177 */
178var divStyle;
179function createStyle() {
180    if (divStyle) {
181        return divStyle;
182    }
183    return (divStyle = document.createElement('div').style);
184}
185/**
186 * Proper prefixing for cross-browser compatibility
187 */
188var prefixes = ['webkit', 'moz', 'ms'];
189var prefixCache = {};
190function getPrefixedName(name) {
191    if (prefixCache[name]) {
192        return prefixCache[name];
193    }
194    var divStyle = createStyle();
195    if (name in divStyle) {
196        return (prefixCache[name] = name);
197    }
198    var capName = name[0].toUpperCase() + name.slice(1);
199    var i = prefixes.length;
200    while (i--) {
201        var prefixedName = "".concat(prefixes[i]).concat(capName);
202        if (prefixedName in divStyle) {
203            return (prefixCache[name] = prefixedName);
204        }
205    }
206}
207/**
208 * Gets a style value expected to be a number
209 */
210function getCSSNum(name, style) {
211    return parseFloat(style[getPrefixedName(name)]) || 0;
212}
213function getBoxStyle(elem, name, style) {
214    if (style === void 0) { style = window.getComputedStyle(elem); }
215    // Support: FF 68+
216    // Firefox requires specificity for border
217    var suffix = name === 'border' ? 'Width' : '';
218    return {
219        left: getCSSNum("".concat(name, "Left").concat(suffix), style),
220        right: getCSSNum("".concat(name, "Right").concat(suffix), style),
221        top: getCSSNum("".concat(name, "Top").concat(suffix), style),
222        bottom: getCSSNum("".concat(name, "Bottom").concat(suffix), style)
223    };
224}
225/**
226 * Set a style using the properly prefixed name
227 */
228function setStyle(elem, name, value) {
229    // eslint-disable-next-line @typescript-eslint/no-explicit-any
230    elem.style[getPrefixedName(name)] = value;
231}
232/**
233 * Constructs the transition from panzoom options
234 * and takes care of prefixing the transition and transform
235 */
236function setTransition(elem, options) {
237    var transform = getPrefixedName('transform');
238    setStyle(elem, 'transition', "".concat(transform, " ").concat(options.duration, "ms ").concat(options.easing));
239}
240/**
241 * Set the transform using the proper prefix
242 *
243 * Override the transform setter.
244 * This is exposed mostly so the user could
245 * set other parts of a transform
246 * aside from scale and translate.
247 * Default is defined in src/css.ts.
248 *
249 * ```js
250 * // This example always sets a rotation
251 * // when setting the scale and translation
252 * const panzoom = Panzoom(elem, {
253 *   setTransform: (elem, { scale, x, y }) => {
254 *     panzoom.setStyle('transform', `rotate(0.5turn) scale(${scale}) translate(${x}px, ${y}px)`)
255 *   }
256 * })
257 * ```
258 */
259function setTransform(elem, _a, _options) {
260    var x = _a.x, y = _a.y, scale = _a.scale, isSVG = _a.isSVG;
261    setStyle(elem, 'transform', "scale(".concat(scale, ") translate(").concat(x, "px, ").concat(y, "px)"));
262    if (isSVG && isIE) {
263        var matrixValue = window.getComputedStyle(elem).getPropertyValue('transform');
264        elem.setAttribute('transform', matrixValue);
265    }
266}
267/**
268 * Dimensions used in containment and focal point zooming
269 */
270function getDimensions(elem) {
271    var parent = elem.parentNode;
272    var style = window.getComputedStyle(elem);
273    var parentStyle = window.getComputedStyle(parent);
274    var rectElem = elem.getBoundingClientRect();
275    var rectParent = parent.getBoundingClientRect();
276    return {
277        elem: {
278            style: style,
279            width: rectElem.width,
280            height: rectElem.height,
281            top: rectElem.top,
282            bottom: rectElem.bottom,
283            left: rectElem.left,
284            right: rectElem.right,
285            margin: getBoxStyle(elem, 'margin', style),
286            border: getBoxStyle(elem, 'border', style)
287        },
288        parent: {
289            style: parentStyle,
290            width: rectParent.width,
291            height: rectParent.height,
292            top: rectParent.top,
293            bottom: rectParent.bottom,
294            left: rectParent.left,
295            right: rectParent.right,
296            padding: getBoxStyle(parent, 'padding', parentStyle),
297            border: getBoxStyle(parent, 'border', parentStyle)
298        }
299    };
300}
301
302/**
303 * Determine if an element is attached to the DOM
304 * Panzoom requires this so events work properly
305 */
306function isAttached(elem) {
307    var doc = elem.ownerDocument;
308    var parent = elem.parentNode;
309    return (doc &&
310        parent &&
311        doc.nodeType === 9 &&
312        parent.nodeType === 1 &&
313        doc.documentElement.contains(parent));
314}
315
316function getClass(elem) {
317    return (elem.getAttribute('class') || '').trim();
318}
319function hasClass(elem, className) {
320    return elem.nodeType === 1 && " ".concat(getClass(elem), " ").indexOf(" ".concat(className, " ")) > -1;
321}
322function isExcluded(elem, options) {
323    for (var cur = elem; cur != null; cur = cur.parentNode) {
324        if (hasClass(cur, options.excludeClass) || options.exclude.indexOf(cur) > -1) {
325            return true;
326        }
327    }
328    return false;
329}
330
331/**
332 * Determine if an element is SVG by checking the namespace
333 * Exception: the <svg> element itself should be treated like HTML
334 */
335var rsvg = /^http:[\w\.\/]+svg$/;
336function isSVGElement(elem) {
337    return rsvg.test(elem.namespaceURI) && elem.nodeName.toLowerCase() !== 'svg';
338}
339
340function shallowClone(obj) {
341    var clone = {};
342    for (var key in obj) {
343        if (obj.hasOwnProperty(key)) {
344            clone[key] = obj[key];
345        }
346    }
347    return clone;
348}
349
350var defaultOptions = {
351    animate: false,
352    canvas: false,
353    cursor: 'move',
354    disablePan: false,
355    disableZoom: false,
356    disableXAxis: false,
357    disableYAxis: false,
358    duration: 200,
359    easing: 'ease-in-out',
360    exclude: [],
361    excludeClass: 'panzoom-exclude',
362    handleStartEvent: function (e) {
363        e.preventDefault();
364        e.stopPropagation();
365    },
366    maxScale: 4,
367    minScale: 0.125,
368    overflow: 'hidden',
369    panOnlyWhenZoomed: false,
370    pinchAndPan: false,
371    relative: false,
372    setTransform: setTransform,
373    startX: 0,
374    startY: 0,
375    startScale: 1,
376    step: 0.3,
377    touchAction: 'none'
378};
379function Panzoom(elem, options) {
380    if (!elem) {
381        throw new Error('Panzoom requires an element as an argument');
382    }
383    if (elem.nodeType !== 1) {
384        throw new Error('Panzoom requires an element with a nodeType of 1');
385    }
386    if (!isAttached(elem)) {
387        throw new Error('Panzoom should be called on elements that have been attached to the DOM');
388    }
389    options = __assign(__assign({}, defaultOptions), options);
390    var isSVG = isSVGElement(elem);
391    var parent = elem.parentNode;
392    // Set parent styles
393    parent.style.overflow = options.overflow;
394    parent.style.userSelect = 'none';
395    // This is important for mobile to
396    // prevent scrolling while panning
397    parent.style.touchAction = options.touchAction;
398    (options.canvas ? parent : elem).style.cursor = options.cursor;
399    // Set element styles
400    elem.style.userSelect = 'none';
401    elem.style.touchAction = options.touchAction;
402    // The default for HTML is '50% 50%'
403    // The default for SVG is '0 0'
404    // SVG can't be changed in IE
405    setStyle(elem, 'transformOrigin', typeof options.origin === 'string' ? options.origin : isSVG ? '0 0' : '50% 50%');
406    function resetStyle() {
407        parent.style.overflow = '';
408        parent.style.userSelect = '';
409        parent.style.touchAction = '';
410        parent.style.cursor = '';
411        elem.style.cursor = '';
412        elem.style.userSelect = '';
413        elem.style.touchAction = '';
414        setStyle(elem, 'transformOrigin', '');
415    }
416    function setOptions(opts) {
417        if (opts === void 0) { opts = {}; }
418        for (var key in opts) {
419            if (opts.hasOwnProperty(key)) {
420                options[key] = opts[key];
421            }
422        }
423        // Handle option side-effects
424        if (opts.hasOwnProperty('cursor') || opts.hasOwnProperty('canvas')) {
425            parent.style.cursor = elem.style.cursor = '';
426            (options.canvas ? parent : elem).style.cursor = options.cursor;
427        }
428        if (opts.hasOwnProperty('overflow')) {
429            parent.style.overflow = opts.overflow;
430        }
431        if (opts.hasOwnProperty('touchAction')) {
432            parent.style.touchAction = opts.touchAction;
433            elem.style.touchAction = opts.touchAction;
434        }
435    }
436    var x = 0;
437    var y = 0;
438    var scale = 1;
439    var isPanning = false;
440    zoom(options.startScale, { animate: false, force: true });
441    // Wait for scale to update
442    // for accurate dimensions
443    // to constrain initial values
444    setTimeout(function () {
445        pan(options.startX, options.startY, { animate: false, force: true });
446    });
447    function trigger(eventName, detail, opts) {
448        if (opts.silent) {
449            return;
450        }
451        var event = new CustomEvent(eventName, { detail: detail });
452        elem.dispatchEvent(event);
453    }
454    function setTransformWithEvent(eventName, opts, originalEvent) {
455        var value = { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: originalEvent };
456        requestAnimationFrame(function () {
457            if (typeof opts.animate === 'boolean') {
458                if (opts.animate) {
459                    setTransition(elem, opts);
460                }
461                else {
462                    setStyle(elem, 'transition', 'none');
463                }
464            }
465            opts.setTransform(elem, value, opts);
466            trigger(eventName, value, opts);
467            trigger('panzoomchange', value, opts);
468        });
469        return value;
470    }
471    function constrainXY(toX, toY, toScale, panOptions) {
472        var opts = __assign(__assign({}, options), panOptions);
473        var result = { x: x, y: y, opts: opts };
474        if (!opts.force && (opts.disablePan || (opts.panOnlyWhenZoomed && scale === opts.startScale))) {
475            return result;
476        }
477        toX = parseFloat(toX);
478        toY = parseFloat(toY);
479        if (!opts.disableXAxis) {
480            result.x = (opts.relative ? x : 0) + toX;
481        }
482        if (!opts.disableYAxis) {
483            result.y = (opts.relative ? y : 0) + toY;
484        }
485        if (opts.contain) {
486            var dims = getDimensions(elem);
487            var realWidth = dims.elem.width / scale;
488            var realHeight = dims.elem.height / scale;
489            var scaledWidth = realWidth * toScale;
490            var scaledHeight = realHeight * toScale;
491            var diffHorizontal = (scaledWidth - realWidth) / 2;
492            var diffVertical = (scaledHeight - realHeight) / 2;
493            if (opts.contain === 'inside') {
494                var minX = (-dims.elem.margin.left - dims.parent.padding.left + diffHorizontal) / toScale;
495                var maxX = (dims.parent.width -
496                    scaledWidth -
497                    dims.parent.padding.left -
498                    dims.elem.margin.left -
499                    dims.parent.border.left -
500                    dims.parent.border.right +
501                    diffHorizontal) /
502                    toScale;
503                result.x = Math.max(Math.min(result.x, maxX), minX);
504                var minY = (-dims.elem.margin.top - dims.parent.padding.top + diffVertical) / toScale;
505                var maxY = (dims.parent.height -
506                    scaledHeight -
507                    dims.parent.padding.top -
508                    dims.elem.margin.top -
509                    dims.parent.border.top -
510                    dims.parent.border.bottom +
511                    diffVertical) /
512                    toScale;
513                result.y = Math.max(Math.min(result.y, maxY), minY);
514            }
515            else if (opts.contain === 'outside') {
516                var minX = (-(scaledWidth - dims.parent.width) -
517                    dims.parent.padding.left -
518                    dims.parent.border.left -
519                    dims.parent.border.right +
520                    diffHorizontal) /
521                    toScale;
522                var maxX = (diffHorizontal - dims.parent.padding.left) / toScale;
523                result.x = Math.max(Math.min(result.x, maxX), minX);
524                var minY = (-(scaledHeight - dims.parent.height) -
525                    dims.parent.padding.top -
526                    dims.parent.border.top -
527                    dims.parent.border.bottom +
528                    diffVertical) /
529                    toScale;
530                var maxY = (diffVertical - dims.parent.padding.top) / toScale;
531                result.y = Math.max(Math.min(result.y, maxY), minY);
532            }
533        }
534        if (opts.roundPixels) {
535            result.x = Math.round(result.x);
536            result.y = Math.round(result.y);
537        }
538        return result;
539    }
540    function constrainScale(toScale, zoomOptions) {
541        var opts = __assign(__assign({}, options), zoomOptions);
542        var result = { scale: scale, opts: opts };
543        if (!opts.force && opts.disableZoom) {
544            return result;
545        }
546        var minScale = options.minScale;
547        var maxScale = options.maxScale;
548        if (opts.contain) {
549            var dims = getDimensions(elem);
550            var elemWidth = dims.elem.width / scale;
551            var elemHeight = dims.elem.height / scale;
552            if (elemWidth > 1 && elemHeight > 1) {
553                var parentWidth = dims.parent.width - dims.parent.border.left - dims.parent.border.right;
554                var parentHeight = dims.parent.height - dims.parent.border.top - dims.parent.border.bottom;
555                var elemScaledWidth = parentWidth / elemWidth;
556                var elemScaledHeight = parentHeight / elemHeight;
557                if (options.contain === 'inside') {
558                    maxScale = Math.min(maxScale, elemScaledWidth, elemScaledHeight);
559                }
560                else if (options.contain === 'outside') {
561                    minScale = Math.max(minScale, elemScaledWidth, elemScaledHeight);
562                }
563            }
564        }
565        result.scale = Math.min(Math.max(toScale, minScale), maxScale);
566        return result;
567    }
568    function pan(toX, toY, panOptions, originalEvent) {
569        var result = constrainXY(toX, toY, scale, panOptions);
570        // Only try to set if the result is somehow different
571        if (x !== result.x || y !== result.y) {
572            x = result.x;
573            y = result.y;
574            return setTransformWithEvent('panzoompan', result.opts, originalEvent);
575        }
576        return { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: originalEvent };
577    }
578    function zoom(toScale, zoomOptions, originalEvent) {
579        var result = constrainScale(toScale, zoomOptions);
580        var opts = result.opts;
581        if (!opts.force && opts.disableZoom) {
582            return;
583        }
584        toScale = result.scale;
585        var toX = x;
586        var toY = y;
587        if (opts.focal) {
588            // The difference between the point after the scale and the point before the scale
589            // plus the current translation after the scale
590            // neutralized to no scale (as the transform scale will apply to the translation)
591            var focal = opts.focal;
592            toX = (focal.x / toScale - focal.x / scale + x * toScale) / toScale;
593            toY = (focal.y / toScale - focal.y / scale + y * toScale) / toScale;
594        }
595        var panResult = constrainXY(toX, toY, toScale, { relative: false, force: true });
596        x = panResult.x;
597        y = panResult.y;
598        scale = toScale;
599        return setTransformWithEvent('panzoomzoom', opts, originalEvent);
600    }
601    function zoomInOut(isIn, zoomOptions) {
602        var opts = __assign(__assign(__assign({}, options), { animate: true }), zoomOptions);
603        return zoom(scale * Math.exp((isIn ? 1 : -1) * opts.step), opts);
604    }
605    function zoomIn(zoomOptions) {
606        return zoomInOut(true, zoomOptions);
607    }
608    function zoomOut(zoomOptions) {
609        return zoomInOut(false, zoomOptions);
610    }
611    function zoomToPoint(toScale, point, zoomOptions, originalEvent) {
612        var dims = getDimensions(elem);
613        // Instead of thinking of operating on the panzoom element,
614        // think of operating on the area inside the panzoom
615        // element's parent
616        // Subtract padding and border
617        var effectiveArea = {
618            width: dims.parent.width -
619                dims.parent.padding.left -
620                dims.parent.padding.right -
621                dims.parent.border.left -
622                dims.parent.border.right,
623            height: dims.parent.height -
624                dims.parent.padding.top -
625                dims.parent.padding.bottom -
626                dims.parent.border.top -
627                dims.parent.border.bottom
628        };
629        // Adjust the clientX/clientY to ignore the area
630        // outside the effective area
631        var clientX = point.clientX -
632            dims.parent.left -
633            dims.parent.padding.left -
634            dims.parent.border.left -
635            dims.elem.margin.left;
636        var clientY = point.clientY -
637            dims.parent.top -
638            dims.parent.padding.top -
639            dims.parent.border.top -
640            dims.elem.margin.top;
641        // Adjust the clientX/clientY for HTML elements,
642        // because they have a transform-origin of 50% 50%
643        if (!isSVG) {
644            clientX -= dims.elem.width / scale / 2;
645            clientY -= dims.elem.height / scale / 2;
646        }
647        // Convert the mouse point from it's position over the
648        // effective area before the scale to the position
649        // over the effective area after the scale.
650        var focal = {
651            x: (clientX / effectiveArea.width) * (effectiveArea.width * toScale),
652            y: (clientY / effectiveArea.height) * (effectiveArea.height * toScale)
653        };
654        return zoom(toScale, __assign(__assign({}, zoomOptions), { animate: false, focal: focal }), originalEvent);
655    }
656    function zoomWithWheel(event, zoomOptions) {
657        // Need to prevent the default here
658        // or it conflicts with regular page scroll
659        event.preventDefault();
660        var opts = __assign(__assign(__assign({}, options), zoomOptions), { animate: false });
661        // Normalize to deltaX in case shift modifier is used on Mac
662        var delta = event.deltaY === 0 && event.deltaX ? event.deltaX : event.deltaY;
663        var wheel = delta < 0 ? 1 : -1;
664        var toScale = constrainScale(scale * Math.exp((wheel * opts.step) / 3), opts).scale;
665        return zoomToPoint(toScale, event, opts, event);
666    }
667    function reset(resetOptions) {
668        var opts = __assign(__assign(__assign({}, options), { animate: true, force: true }), resetOptions);
669        scale = constrainScale(opts.startScale, opts).scale;
670        var panResult = constrainXY(opts.startX, opts.startY, scale, opts);
671        x = panResult.x;
672        y = panResult.y;
673        return setTransformWithEvent('panzoomreset', opts);
674    }
675    var origX;
676    var origY;
677    var startClientX;
678    var startClientY;
679    var startScale;
680    var startDistance;
681    var pointers = [];
682    function handleDown(event) {
683        // Don't handle this event if the target is excluded
684        if (isExcluded(event.target, options)) {
685            return;
686        }
687        addPointer(pointers, event);
688        isPanning = true;
689        options.handleStartEvent(event);
690        origX = x;
691        origY = y;
692        trigger('panzoomstart', { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: event }, options);
693        // This works whether there are multiple
694        // pointers or not
695        var point = getMiddle(pointers);
696        startClientX = point.clientX;
697        startClientY = point.clientY;
698        startScale = scale;
699        startDistance = getDistance(pointers);
700    }
701    function handleMove(event) {
702        if (!isPanning ||
703            origX === undefined ||
704            origY === undefined ||
705            startClientX === undefined ||
706            startClientY === undefined) {
707            return;
708        }
709        addPointer(pointers, event);
710        var current = getMiddle(pointers);
711        var hasMultiple = pointers.length > 1;
712        var toScale = scale;
713        if (hasMultiple) {
714            // A startDistance of 0 means
715            // that there weren't 2 pointers
716            // handled on start
717            if (startDistance === 0) {
718                startDistance = getDistance(pointers);
719            }
720            // Use the distance between the first 2 pointers
721            // to determine the current scale
722            var diff = getDistance(pointers) - startDistance;
723            toScale = constrainScale((diff * options.step) / 80 + startScale).scale;
724            zoomToPoint(toScale, current, { animate: false }, event);
725        }
726        // Pan during pinch if pinchAndPan is true.
727        // Note: some calculations may be off because the zoom
728        // above has not yet rendered. However, the behavior
729        // was removed before the new scale was used in the following
730        // pan calculation.
731        // See https://github.com/timmywil/panzoom/issues/512
732        // and https://github.com/timmywil/panzoom/issues/606
733        if (!hasMultiple || options.pinchAndPan) {
734            pan(origX + (current.clientX - startClientX) / toScale, origY + (current.clientY - startClientY) / toScale, {
735                animate: false
736            }, event);
737        }
738    }
739    function handleUp(event) {
740        // Don't call panzoomend when panning with 2 touches
741        // until both touches end
742        if (pointers.length === 1) {
743            trigger('panzoomend', { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: event }, options);
744        }
745        // Note: don't remove all pointers
746        // Can restart without having to reinitiate all of them
747        // Remove the pointer regardless of the isPanning state
748        removePointer(pointers, event);
749        if (!isPanning) {
750            return;
751        }
752        isPanning = false;
753        origX = origY = startClientX = startClientY = undefined;
754    }
755    var bound = false;
756    function bind() {
757        if (bound) {
758            return;
759        }
760        bound = true;
761        onPointer('down', options.canvas ? parent : elem, handleDown);
762        onPointer('move', document, handleMove, { passive: true });
763        onPointer('up', document, handleUp, { passive: true });
764    }
765    function destroy() {
766        bound = false;
767        destroyPointer('down', options.canvas ? parent : elem, handleDown);
768        destroyPointer('move', document, handleMove);
769        destroyPointer('up', document, handleUp);
770    }
771    if (!options.noBind) {
772        bind();
773    }
774    return {
775        bind: bind,
776        destroy: destroy,
777        eventNames: events,
778        getPan: function () { return ({ x: x, y: y }); },
779        getScale: function () { return scale; },
780        getOptions: function () { return shallowClone(options); },
781        handleDown: handleDown,
782        handleMove: handleMove,
783        handleUp: handleUp,
784        pan: pan,
785        reset: reset,
786        resetStyle: resetStyle,
787        setOptions: setOptions,
788        setStyle: function (name, value) { return setStyle(elem, name, value); },
789        zoom: zoom,
790        zoomIn: zoomIn,
791        zoomOut: zoomOut,
792        zoomToPoint: zoomToPoint,
793        zoomWithWheel: zoomWithWheel
794    };
795}
796Panzoom.defaultOptions = defaultOptions;
797
798
799
800
801/***/ })
801,
802
803/***/ "@wordpress/dom-ready":
804/*!**********************************!*\
805  !*** external ["wp","domReady"] ***!
806  \**********************************/
807/***/ (function(module) {
808
809module.exports = window["wp"]["domReady"];
810
811/***/ })
812
813/******/ 	});
814/************************************************************************/
815/******/ 	// The module cache
816/******/ 	var __webpack_module_cache__ = {};
817/******/ 	
818/******/ 	// The require function
819/******/ 	function __webpack_require__(moduleId) {
820/******/ 		// Check if module is in cache
821/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
822/******/ 		if (cachedModule !== undefined) {
823/******/ 			return cachedModule.exports;
824/******/ 		}
825/******/ 		// Create a new module (and put it into the cache)
826/******/ 		var module = __webpack_module_cache__[moduleId] = {
827/******/ 			// no module.id needed
828/******/ 			// no module.loaded needed
829/******/ 			exports: {}
830/******/ 		};
831/******/ 	
832/******/ 		// Execute the module function
833/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
834/******/ 	
835/******/ 		// Return the exports of the module
836/******/ 		return module.exports;
837/******/ 	}
838/******/ 	
839/************************************************************************/
840/******/ 	/* webpack/runtime/compat get default export */
841/******/ 	!function() {
842/******/ 		// getDefaultExport function for compatibility with non-harmony modules
843/******/ 		__webpack_require__.n = function(module) {
844/******/ 			var getter = module && module.__esModule ?
845/******/ 				function() { return module['default']; } :
846/******/ 				function() { return module; };
847/******/ 			__webpack_require__.d(getter, { a: getter });
848/******/ 			return getter;
849/******/ 		};
850/******/ 	}();
851/******/ 	
852/******/ 	/* webpack/runtime/define property getters */
853/******/ 	!function() {
854/******/ 		// define getter functions for harmony exports
855/******/ 		__webpack_require__.d = function(exports, definition) {
856/******/ 			for(var key in definition) {
857/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
858/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
859/******/ 				}
860/******/ 			}
861/******/ 		};
862/******/ 	}();
863/******/ 	
864/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
865/******/ 	!function() {
866/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
867/******/ 	}();
868/******/ 	
869/******/ 	/* webpack/runtime/make namespace object */
870/******/ 	!function() {
871/******/ 		// define __esModule on exports
872/******/ 		__webpack_require__.r = function(exports) {
873/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
874/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
875/******/ 			}
876/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
877/******/ 		};
878/******/ 	}();
879/******/ 	
880/************************************************************************/
881var __webpack_exports__ = {};
882// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
883!function() {
884/*!*****************************************************************!*\
885  !*** ./source/03-blocks/interactive-map/interactive-map.es6.js ***!
886  \*****************************************************************/
887__webpack_require__.r(__webpack_exports__);
888/* harmony import */ var _panzoom_panzoom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @panzoom/panzoom */ "./node_modules/@panzoom/panzoom/dist/panzoom.es.js");
889/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/dom-ready */ "@wordpress/dom-ready");
890/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_1__);
891
892
893_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_1___default()(() => {
894  if (document.body.contains(document.querySelector('.interactive-map'))) {
895    // loading animations
896    mapInView();
897    window.addEventListener('scroll', () => {
898      mapInView();
899    });
900
901    // panzoom settings
902    const map = document.querySelector('.interactive-map__image');
903    const minZoom = 1.2;
904    const maxZoom = 3;
905    const panzoom = (0,_panzoom_panzoom__WEBPACK_IMPORTED_MODULE_0__["default"])(map, {
906      minScale: minZoom,
907      maxScale: maxZoom,
908      startScale: minZoom,
909      step: maxZoom,
910      cursor: 'default',
911      animate: true,
912      panOnlyWhenZoomed: true,
913      // contain: 'outside',
914      origin: '50% 50%',
915      focal: {
916        x: 0,
917        y: 0
918      }
919    });
920
921    // need to turn pan feature on at below 1401
922    smallerDesktopOptions();
923    window.addEventListener('resize', () => {
924      smallerDesktopOptions();
925    });
926    let currentPan = panzoom.getPan();
927    const populations = document.querySelectorAll('.map-tool-tip__population.count');
928    const cursorFollower = document.getElementById('countryToolTip');
929    const activeCountries = document.querySelectorAll('[data-country]');
930
931    // handle population numbers
932    populations.forEach(population => {
933      const populationString = population.innerHTML;
934      const number = populationString.replace(/[^0-9\.]+/g, '');
935      if (number.length >= 6) {
936        population.innerHTML = number.substring(0, 3) + 'k';
937      } else if (population.closest('.map-tool-tip__content').getAttribute('data-country') === 'China' || population.closest('.map-tool-tip__content').getAttribute('data-country') === 'India') {
938        population.innerHTML = number + 'b';
939      } else {
940        population.innerHTML = number + 'm';
941      }
942    });
943    map.addEventListener('panzoompan', () => {
944      map.classList.add('grabbing');
945      removeFocusedStates();
946    });
947    map.addEventListener('panzoomend', () => {
948      setTimeout(() => {
949        map.classList.remove('grabbing');
950      }, 100);
951    });
952    map.addEventListener('pointerup', event => {
953      map.classList.remove('grabbing');
954      const currentScale = panzoom.getScale();
955      let targetObject = event.target;
956      if (targetObject.parentNode.getAttribute('data-name')) {
957        targetObject = targetObject.parentNode;
958      }
959      if (JSON.stringify(currentPan) === JSON.stringify(panzoom.getPan())) {
960        if (map.classList.contains('zoomed') && !map.classList.contains('grabbing')) {
961          if (targetObject.classList.contains('active-country')) {
962            let centerX = targetObject.getAttribute('data-center-x');
963            let centerY = targetObject.getAttribute('data-center-y');
964            centerX = Number(centerX);
965            centerY = Number(centerY) + 52;
966            if (centerX && centerY) {
967              panzoom.pan(centerX, centerY);
968            }
969            setTimeout(() => {
970              let toolTipContent = document.querySelector('[data-country="' + targetObject.getAttribute('data-name') + '"]');
971              if (targetObject.tagName === 'g') {
972                toolTipContent = document.querySelector('[data-country="' + targetObject.getAttribute('data-name') + '"]');
973              }
974              removeFocusedStates();
975              if (toolTipContent) {
976                // const x = event.clientX;
977                // const y = event.clientY;
978                // cursorFollower.style.left = `${x}px`;
979                // cursorFollower.style.top = `${y}px`;
980                cursorFollower.firstElementChild.innerHTML = toolTipContent.innerHTML;
981                cursorFollower.classList.add('map-tool-tip--active');
982              }
983              targetObject.closest('g.interactive-map__svg-countries').appendChild(targetObject);
984              map.classList.add('interactive-map--country-focus');
985              document.querySelector('.interactive-map').classList.add('interactive-map--country-focus');
986              targetObject.classList.add('focused-country');
987              setTimeout(() => {
988                document.querySelector('.map-tool-tip--active').animate({
989                  duration: 1500,
990                  easing: 'linear',
991                  step(now) {
992                    this.text(Math.ceil(now));
993                  }
994                });
995              });
996            }, 300);
997          } else {
998            removeFocusedStates();
999            panzoom.pan(0, 0);
1000            panzoom.zoomOut();
1001            setTimeout(() => {
1002              map.classList.remove('zoomed');
1003              document.querySelector('.interactive-map__mobile').classList.remove('zoomed');
1004            }, 800);
1005          }
1006        } else if (targetObject.classList.contains('interactive-map__region')) {
1007          const region = targetObject.getAttribute('data-region');
1008          let regionZoomOffset = 50;
1009          if (region === 'united-states' || region === 'europe') {
1010            regionZoomOffset = 100;
1011          }
1012          panzoom.zoomToPoint(currentScale + maxZoom, {
1013            clientX: event.clientX,
1014            clientY: event.clientY - regionZoomOffset
1015          });
1016          map.classList.add('zoomed');
1017          document.querySelector('.interactive-map__mobile').classList.add('zoomed');
1018        }
1019      }
1020      document.querySelector('.interactive-map__image svg').style.pointerEvents = '';
1021      currentPan = panzoom.getPan();
1022    });
1023
1024    // cursor following
1025    activeCountries.forEach(e => {
1026      const path = document.querySelector('svg [data-name="' + e.getAttribute('data-country') + '"]');
1027      const countryUrl = e.getAttribute('data-country-link');
1028      if (path) {
1029        path.classList.add('active-country');
1030        path.setAttribute('data-link', countryUrl);
1031      }
1032    });
1033    document.addEventListener('click', closeToolTip);
1034    map.parentElement.appendChild(cursorFollower);
1035    window.addEventListener('scroll', () => {
1036      const focusedCountries = document.querySelectorAll('.focused-country');
1037      focusedCountries.forEach(country => {
1038        country.classList.remove('focused-country');
1039      });
1040      document.querySelector('.map-tool-tip').classList.remove('map-tool-tip--active');
1041      document.querySelector('.interactive-map__image').classList.remove('interactive-map--country-focus');
1042      document.querySelector('.interactive-map').classList.remove('interactive-map--country-focus');
1043    });
1044    function removeFocusedStates() {
1045      const focusedCountries = document.querySelectorAll('.focused-country');
1046      focusedCountries.forEach(country => {
1047        country.classList.remove('focused-country');
1048      });
1049      document.querySelector('.map-tool-tip').classList.remove('map-tool-tip--active');
1050      document.querySelector('.interactive-map__image').classList.remove('interactive-map--country-focus');
1051      document.querySelector('.interactive-map').classList.remove('interactive-map--country-focus');
1052    }
1053    function elementInViewport(el) {
1054      let top = el.offsetTop + 400;
1055      let left = el.offsetLeft;
1056      const width = el.offsetWidth;
1057      const height = el.offsetHeight;
1058      while (el.offsetParent) {
1059        el = el.offsetParent;
1060        top += el.offsetTop;
1061        left += el.offsetLeft;
1062      }
1063      return top < window.scrollY + window.innerHeight && left < window.scrollX + window.innerWidth && top + height > window.pageYOffset && left + width > window.pageXOffset;
1064    }
1065    function mapInView() {
1066      const mapComponent = document.querySelector('.interactive-map');
1067      if (elementInViewport(mapComponent)) {
1068        mapComponent.classList.add('interactive-map--in-view');
1069      }
1070    }
1071    function closeToolTip(event) {
1072      const element = event.target;
1073      map.classList.remove('grabbing');
1074      if (element.classList.contains('map-tool-tip__close')) {
1075        removeFocusedStates();
1076      }
1077    }
1078    function smallerDesktopOptions() {
1079      if (window.innerWidth <= 1400) {
1080        panzoom.setOptions({
1081          panOnlyWhenZoomed: false
1082        });
1083        setTimeout(() => {
1084          panzoom.pan(-110, 0);
1085        }, 300);
1086      }
1087    }
1088
1089    // Labels
1090    const world = document.querySelector('#interactive-map svg');
1091    const polygons = world.getElementsByTagName("polygon");
1092    const paths = world.getElementsByTagName("path");
1093    const shapes = [];
1094    for (let i = 0; i < polygons.length; i++) {
1095      shapes.push(polygons[i]);
1096    }
1097    for (let i = 0; i < paths.length; i++) {
1098      shapes.push(paths[i]);
1099    }
1100    for (let i = 0; i < shapes.length; i++) {
1101      if (shapes[i].classList.contains("active-country")) {
1102        const country = shapes[i].getAttribute('data-name');
1103        let label = document.querySelector('.map-label[data-label="' + country + '"]');
1104        let width = shapes[i].getBoundingClientRect().width;
1105        let height = shapes[i].getBoundingClientRect().height;
1106        let centerY = shapes[i].getAttribute('data-center-y');
1107
1108        // Get svg path position
1109        const parent = world.getBoundingClientRect();
1110        const child = shapes[i].getBoundingClientRect();
1111        let x = child.left - parent.left + child.width / 2;
1112        let y = child.top - parent.top + child.height / 2;
1113
1114        // Set label position
1115        label.style.left = x + 'px';
1116        label.style.top = y + 'px';
1117
1118        // Activate label
1119        label.classList.add('map-label-active');
1120        shapes[i].onmouseover = function () {
1121          label.classList.add('map-label-hover');
1122        };
1123        shapes[i].onmouseout = function () {
1124          label.classList.remove('map-label-hover');
1125        };
1126      }
1127    }
1128  }
1129});
1130}();
1131/******/ })()
1132;
1133//# sourceMappingURL=interactive-map.es6.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.