From 675916ccbd378d3b0334ffeb7ad0759538856ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 12 Jun 2024 12:24:28 +0900 Subject: [PATCH] perf(es/minifier): Do not visit var init multiple times (#9039) **Description:** I mistakenly introduced a performance regression with https://github.com/swc-project/swc/pull/9032. It makes the minifier visit the initializer of variables multiple times - once while normal visiting and once in `hoist_props_of_vars`. This PR fixes it. --- .../src/compress/optimize/mod.rs | 34 ++- .../src/compress/optimize/props.rs | 31 +- .../tests/benches-full/echarts.js | 30 +- .../tests/benches-full/jquery.js | 3 +- .../tests/benches-full/lodash.js | 9 +- .../tests/benches-full/victory.js | 30 +- .../tests/benches-full/vue.js | 4 +- .../tests/fixture/issues/8643/output.js | 4 +- .../fixture/issues/emotion/react/1/output.js | 4 +- .../d6e1aeb5-38a8d7ae57119c23/output.js | 30 +- .../tests/fixture/next/47005/output.js | 30 +- .../tests/fixture/next/chakra/output.js | 2 +- .../feedback-3/579-dcac359116b2707c/output.js | 12 +- .../pages/_app-72ad41192608e93a/output.js | 12 +- .../8a28b14e.d8fbda268ed281a1/output.js | 2 +- .../fixture/next/react-pdf-renderer/output.js | 58 ++-- .../syncfusion/933-e9f9a6bf671b96fc/output.js | 8 +- .../fixture/next/wrap-contracts/output.js | 4 +- .../785-e1932cc99ac3bb67/output.js | 2 +- .../tests/projects/output/angular-1.2.5.js | 42 +-- .../projects/output/jquery.mobile-1.4.2.js | 2 +- .../tests/projects/output/react-dom-17.0.2.js | 284 +++++++++--------- 22 files changed, 323 insertions(+), 314 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 09556b6c356d..b3e3a4c6556c 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2955,10 +2955,38 @@ impl VisitMut for Optimizer<'_> { return false; } - var.visit_mut_with(self); + true + }); + + { + // We loop with index to avoid borrow checker issue. + // We use splice so we cannot use for _ in vars + let mut idx = 0; + + while idx < vars.len() { + let var = &mut vars[idx]; + var.visit_mut_with(self); + + // The varaible is dropped. + if var.name.is_invalid() { + vars.remove(idx); + continue; + } + let new = self.hoist_props_of_var(var); + + if let Some(new) = new { + let len = new.len(); + vars.splice(idx..=idx, new); + idx += len; + } else { + idx += 1; + } + } + } + + vars.retain_mut(|var| { if var.name.is_invalid() { - // It will be inlined. self.changed = true; return false; } @@ -2968,8 +2996,6 @@ impl VisitMut for Optimizer<'_> { true }); - self.hoist_props_of_vars(vars); - let uses_eval = self.data.scopes.get(&self.ctx.scope).unwrap().has_eval_call; if !uses_eval && !self.ctx.dont_use_prepend_nor_append { diff --git a/crates/swc_ecma_minifier/src/compress/optimize/props.rs b/crates/swc_ecma_minifier/src/compress/optimize/props.rs index 8743dc925e38..17c261404bdc 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/props.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/props.rs @@ -1,46 +1,29 @@ use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{contains_this_expr, private_ident, prop_name_eq, ExprExt}; -use swc_ecma_visit::VisitMutWith; use super::{unused::PropertyAccessOpts, Optimizer}; use crate::util::deeply_contains_this_expr; /// Methods related to the option `hoist_props`. impl Optimizer<'_> { - pub(super) fn hoist_props_of_vars(&mut self, n: &mut Vec) { + pub(super) fn hoist_props_of_var( + &mut self, + n: &mut VarDeclarator, + ) -> Option> { if !self.options.hoist_props { log_abort!("hoist_props: option is disabled"); - return; + return None; } if self.ctx.is_exported { log_abort!("hoist_props: Exported variable is not hoisted"); - return; + return None; } if self.ctx.in_top_level() && !self.options.top_level() { log_abort!("hoist_props: Top-level variable is not hoisted"); - return; - } - - let mut new = Vec::with_capacity(n.len()); - for mut n in n.take() { - if let Some(init) = &mut n.init { - init.visit_mut_with(self); - } - - let new_vars = self.hoist_props_of_var(&mut n); - - if let Some(new_vars) = new_vars { - new.extend(new_vars); - } else { - new.push(n); - } + return None; } - *n = new; - } - - fn hoist_props_of_var(&mut self, n: &mut VarDeclarator) -> Option> { if let Pat::Ident(name) = &mut n.name { if name.id.span.ctxt == self.marks.top_level_ctxt && self.options.top_retain.contains(&name.id.sym) diff --git a/crates/swc_ecma_minifier/tests/benches-full/echarts.js b/crates/swc_ecma_minifier/tests/benches-full/echarts.js index 2fed74ff9569..b01c4a9b71fd 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/echarts.js +++ b/crates/swc_ecma_minifier/tests/benches-full/echarts.js @@ -9609,7 +9609,7 @@ ], upstreamSignList = []; assert(resultSourceList && upstreamSignList), this._setLocalSource(resultSourceList, upstreamSignList); }, SourceManager.prototype._applyTransform = function(upMgrList) { - var source, encodeDefine, sourceList, datasetModel = this._sourceHost, transformOption = datasetModel.get('transform', !0), fromTransformResult = datasetModel.get('fromTransformResult', !0); + var encodeDefine, source, sourceList, datasetModel = this._sourceHost, transformOption = datasetModel.get('transform', !0), fromTransformResult = datasetModel.get('fromTransformResult', !0); assert(null != fromTransformResult || null != transformOption), null != fromTransformResult && 1 !== upMgrList.length && doThrow('When using `fromTransformResult`, there should be only one upstream dataset'); var upSourceList = [], upstreamSignList = []; return (each(upMgrList, function(upMgr) { @@ -15070,10 +15070,10 @@ return null == precision ? precision = getPrecisionSafe(data.value) || 0 : 'auto' === precision && (precision = this._intervalPrecision), addCommas(round(data.value, precision, !0)); }, IntervalScale.prototype.niceTicks = function(splitNumber, minInterval, maxInterval) { splitNumber = splitNumber || 5; - var splitNumber1, result, span, interval, precision, niceTickExtent, extent = this._extent, span1 = extent[1] - extent[0]; + var splitNumber1, result, span, interval, precision, extent = this._extent, span1 = extent[1] - extent[0]; if (isFinite(span1)) { span1 < 0 && (span1 = -span1, extent.reverse()); - var result1 = (splitNumber1 = splitNumber, result = {}, span = extent[1] - extent[0], interval = result.interval = nice(span / splitNumber1, !0), null != minInterval && interval < minInterval && (interval = result.interval = minInterval), null != maxInterval && interval > maxInterval && (interval = result.interval = maxInterval), precision = result.intervalPrecision = getPrecisionSafe(interval) + 2, isFinite((niceTickExtent = result.niceTickExtent = [ + var niceTickExtent, result1 = (splitNumber1 = splitNumber, result = {}, span = extent[1] - extent[0], interval = result.interval = nice(span / splitNumber1, !0), null != minInterval && interval < minInterval && (interval = result.interval = minInterval), null != maxInterval && interval > maxInterval && (interval = result.interval = maxInterval), precision = result.intervalPrecision = getPrecisionSafe(interval) + 2, isFinite((niceTickExtent = result.niceTickExtent = [ round(Math.ceil(extent[0] / interval) * interval, precision), round(Math.floor(extent[1] / interval) * interval, precision) ])[0]) || (niceTickExtent[0] = extent[0]), isFinite(niceTickExtent[1]) || (niceTickExtent[1] = extent[1]), clamp(niceTickExtent, 0, extent), clamp(niceTickExtent, 1, extent), niceTickExtent[0] > niceTickExtent[1] && (niceTickExtent[0] = niceTickExtent[1]), result); @@ -16083,7 +16083,7 @@ return ('category' === this.type ? (result = makeCategoryLabelsActually(this, labelModel = this.getLabelModel()), !labelModel.get('show') || this.scale.isBlank() ? { labels: [], labelCategoryInterval: result.labelCategoryInterval - } : result) : (ticks = (axis = this).scale.getTicks(), labelFormatter = makeLabelFormatter(axis), { + } : result) : (axis = this, ticks = axis.scale.getTicks(), labelFormatter = makeLabelFormatter(axis), { labels: map(ticks, function(tick, idx) { return { formattedLabel: labelFormatter(tick, idx), @@ -19281,13 +19281,13 @@ this._ctx = null; for(var i = 0; i < points.length;){ var x = points[i++], y = points[i++]; - isNaN(x) || isNaN(y) || this.softClipShape && !this.softClipShape.contain(x, y) || (symbolProxyShape.x = x - size[0] / 2, symbolProxyShape.y = y - size[1] / 2, symbolProxyShape.width = size[0], symbolProxyShape.height = size[1], symbolProxy.buildPath(path, symbolProxyShape, !0)); + !(isNaN(x) || isNaN(y)) && (!this.softClipShape || this.softClipShape.contain(x, y)) && (symbolProxyShape.x = x - size[0] / 2, symbolProxyShape.y = y - size[1] / 2, symbolProxyShape.width = size[0], symbolProxyShape.height = size[1], symbolProxy.buildPath(path, symbolProxyShape, !0)); } }, LargeSymbolPath.prototype.afterBrush = function() { var shape = this.shape, points = shape.points, size = shape.size, ctx = this._ctx; if (ctx) for(var i = 0; i < points.length;){ var x = points[i++], y = points[i++]; - isNaN(x) || isNaN(y) || this.softClipShape && !this.softClipShape.contain(x, y) || ctx.fillRect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]); + !(isNaN(x) || isNaN(y)) && (!this.softClipShape || this.softClipShape.contain(x, y)) && ctx.fillRect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]); } }, LargeSymbolPath.prototype.findDataIndex = function(x, y) { for(var shape = this.shape, points = shape.points, size = shape.size, w = Math.max(size[0], 4), h = Math.max(size[1], 4), idx = points.length / 2 - 1; idx >= 0; idx--){ @@ -20188,11 +20188,11 @@ axisName: function(opt, axisModel, group, transformGroup) { var labelLayout, axisNameAvailableWidth, name = retrieve(opt.axisName, axisModel.get('name')); if (name) { - var textAlign, textVerticalAlign, rotationDiff, inverse, onLeft, nameLocation = axisModel.get('nameLocation'), nameDirection = opt.nameDirection, textStyleModel = axisModel.getModel('nameTextStyle'), gap = axisModel.get('nameGap') || 0, extent = axisModel.axis.getExtent(), gapSignal = extent[0] > extent[1] ? -1 : 1, pos = [ + var rotation, textAlign, textVerticalAlign, rotationDiff, inverse, onLeft, nameLocation = axisModel.get('nameLocation'), nameDirection = opt.nameDirection, textStyleModel = axisModel.getModel('nameTextStyle'), gap = axisModel.get('nameGap') || 0, extent = axisModel.axis.getExtent(), gapSignal = extent[0] > extent[1] ? -1 : 1, pos = [ 'start' === nameLocation ? extent[0] - gapSignal * gap : 'end' === nameLocation ? extent[1] + gapSignal * gap : (extent[0] + extent[1]) / 2, isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0 ], nameRotation = axisModel.get('nameRotate'); - null != nameRotation && (nameRotation = nameRotation * PI$5 / 180), isNameLocationCenter(nameLocation) ? labelLayout = AxisBuilder.innerTextLayout(opt.rotation, null != nameRotation ? nameRotation : opt.rotation, nameDirection) : (rotationDiff = remRadian((nameRotation || 0) - opt.rotation), inverse = extent[0] > extent[1], onLeft = 'start' === nameLocation && !inverse || 'start' !== nameLocation && inverse, isRadianAroundZero(rotationDiff - PI$5 / 2) ? (textVerticalAlign = onLeft ? 'bottom' : 'top', textAlign = 'center') : isRadianAroundZero(rotationDiff - 1.5 * PI$5) ? (textVerticalAlign = onLeft ? 'top' : 'bottom', textAlign = 'center') : (textVerticalAlign = 'middle', textAlign = rotationDiff < 1.5 * PI$5 && rotationDiff > PI$5 / 2 ? onLeft ? 'left' : 'right' : onLeft ? 'right' : 'left'), labelLayout = { + null != nameRotation && (nameRotation = nameRotation * PI$5 / 180), isNameLocationCenter(nameLocation) ? labelLayout = AxisBuilder.innerTextLayout(opt.rotation, null != nameRotation ? nameRotation : opt.rotation, nameDirection) : (rotation = opt.rotation, rotationDiff = remRadian((nameRotation || 0) - rotation), inverse = extent[0] > extent[1], onLeft = 'start' === nameLocation && !inverse || 'start' !== nameLocation && inverse, isRadianAroundZero(rotationDiff - PI$5 / 2) ? (textVerticalAlign = onLeft ? 'bottom' : 'top', textAlign = 'center') : isRadianAroundZero(rotationDiff - 1.5 * PI$5) ? (textVerticalAlign = onLeft ? 'top' : 'bottom', textAlign = 'center') : (textVerticalAlign = 'middle', textAlign = rotationDiff < 1.5 * PI$5 && rotationDiff > PI$5 / 2 ? onLeft ? 'left' : 'right' : onLeft ? 'right' : 'left'), labelLayout = { rotation: rotationDiff, textAlign: textAlign, textVerticalAlign: textVerticalAlign @@ -22924,19 +22924,19 @@ ], [ x + itemWidth, - 0 + itemHeight + y + itemHeight ], [ head ? x : x - 5, - 0 + itemHeight + y + itemHeight ] ]; return tail || points.splice(2, 0, [ x + itemWidth + 5, - 0 + itemHeight / 2 + y + itemHeight / 2 ]), head || points.push([ x, - 0 + itemHeight / 2 + y + itemHeight / 2 ]), points; }(lastX, 0, itemWidth, height, i === renderList.length - 1, 0 === i) }, @@ -28681,7 +28681,7 @@ ]); }, LinesView.prototype._clearLayer = function(api) { var zr = api.getZr(); - 'svg' === zr.painter.getType() || null == this._lastZlevel || zr.painter.getLayer(this._lastZlevel).clear(!0); + 'svg' !== zr.painter.getType() && null != this._lastZlevel && zr.painter.getLayer(this._lastZlevel).clear(!0); }, LinesView.prototype.remove = function(ecModel, api) { this._lineDraw && this._lineDraw.remove(), this._lineDraw = null, this._clearLayer(api); }, LinesView.type = 'lines', LinesView; @@ -34689,7 +34689,7 @@ return null !== _super && _super.apply(this, arguments) || this; } return __extends(DataView, _super), DataView.prototype.onclick = function(ecModel, api) { - var seriesGroupByCategoryAxis, otherSeries, meta, result, groups, tables, container = api.getDom(), model = this.model; + var seriesGroupByCategoryAxis, otherSeries, meta, groups, tables, result, container = api.getDom(), model = this.model; this._dom && container.removeChild(this._dom); var root = document.createElement('div'); root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;', root.style.backgroundColor = model.get('backgroundColor') || '#fff'; @@ -35481,7 +35481,7 @@ }, TooltipHTMLContent.prototype.show = function(tooltipModel, nearPointColor) { clearTimeout(this._hideTimeout), clearTimeout(this._longHideTimeout); var enableTransition, onlyFade, cssText, transitionDuration, backgroundColor, shadowBlur, shadowColor, shadowOffsetX, shadowOffsetY, textStyleModel, padding, transitionCurve, transitionOption, transitionText, cssText1, fontSize, color, shadowColor1, shadowBlur1, shadowOffsetX1, shadowOffsetY1, el = this.el, style = el.style, styleCoord = this._styleCoord; - el.innerHTML ? style.cssText = gCssText + (enableTransition = !this._firstShow, onlyFade = this._longHide, cssText = [], transitionDuration = tooltipModel.get('transitionDuration'), backgroundColor = tooltipModel.get('backgroundColor'), shadowBlur = tooltipModel.get('shadowBlur'), shadowColor = tooltipModel.get('shadowColor'), shadowOffsetX = tooltipModel.get('shadowOffsetX'), shadowOffsetY = tooltipModel.get('shadowOffsetY'), textStyleModel = tooltipModel.getModel('textStyle'), padding = getPaddingFromTooltipModel(tooltipModel, 'html'), cssText.push('box-shadow:' + shadowOffsetX + "px " + shadowOffsetY + "px " + shadowBlur + "px " + shadowColor), enableTransition && transitionDuration && cssText.push((transitionText = "opacity" + (transitionOption = " " + transitionDuration / 2 + "s " + (transitionCurve = 'cubic-bezier(0.23,1,0.32,1)')) + ",visibility" + transitionOption, onlyFade || (transitionOption = " " + transitionDuration + "s " + transitionCurve, transitionText += env.transformSupported ? "," + TRANSFORM_VENDOR + transitionOption : ",left" + transitionOption + ",top" + transitionOption), CSS_TRANSITION_VENDOR + ':' + transitionText)), backgroundColor && (env.canvasSupported ? cssText.push('background-color:' + backgroundColor) : (cssText.push('background-color:#' + toHex(backgroundColor)), cssText.push('filter:alpha(opacity=70)'))), each([ + el.innerHTML ? style.cssText = gCssText + (enableTransition = !this._firstShow, onlyFade = this._longHide, cssText = [], transitionDuration = tooltipModel.get('transitionDuration'), backgroundColor = tooltipModel.get('backgroundColor'), shadowBlur = tooltipModel.get('shadowBlur'), shadowColor = tooltipModel.get('shadowColor'), shadowOffsetX = tooltipModel.get('shadowOffsetX'), shadowOffsetY = tooltipModel.get('shadowOffsetY'), textStyleModel = tooltipModel.getModel('textStyle'), padding = getPaddingFromTooltipModel(tooltipModel, 'html'), cssText.push('box-shadow:' + (shadowOffsetX + "px " + shadowOffsetY + "px ") + shadowBlur + "px " + shadowColor), enableTransition && transitionDuration && cssText.push((transitionText = "opacity" + (transitionOption = " " + transitionDuration / 2 + "s " + (transitionCurve = 'cubic-bezier(0.23,1,0.32,1)')) + ",visibility" + transitionOption, onlyFade || (transitionOption = " " + transitionDuration + "s " + transitionCurve, transitionText += env.transformSupported ? "," + TRANSFORM_VENDOR + transitionOption : ",left" + transitionOption + ",top" + transitionOption), CSS_TRANSITION_VENDOR + ':' + transitionText)), backgroundColor && (env.canvasSupported ? cssText.push('background-color:' + backgroundColor) : (cssText.push('background-color:#' + toHex(backgroundColor)), cssText.push('filter:alpha(opacity=70)'))), each([ 'width', 'color', 'radius' diff --git a/crates/swc_ecma_minifier/tests/benches-full/jquery.js b/crates/swc_ecma_minifier/tests/benches-full/jquery.js index cbbe1cfc67fd..9030d0ce0dda 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/jquery.js +++ b/crates/swc_ecma_minifier/tests/benches-full/jquery.js @@ -248,7 +248,8 @@ } function createDisabledPseudo(disabled) { return function(elem) { - return "form" in elem ? elem.parentNode && !1 === elem.disabled ? "label" in elem ? "label" in elem.parentNode ? elem.parentNode.disabled === disabled : elem.disabled === disabled : elem.isDisabled === disabled || !disabled !== elem.isDisabled && inDisabledFieldset(elem) === disabled : elem.disabled === disabled : "label" in elem && elem.disabled === disabled; + if ("form" in elem) return elem.parentNode && !1 === elem.disabled ? "label" in elem ? "label" in elem.parentNode ? elem.parentNode.disabled === disabled : elem.disabled === disabled : elem.isDisabled === disabled || !disabled !== elem.isDisabled && inDisabledFieldset(elem) === disabled : elem.disabled === disabled; + return "label" in elem && elem.disabled === disabled; }; } function createPositionalPseudo(fn) { diff --git a/crates/swc_ecma_minifier/tests/benches-full/lodash.js b/crates/swc_ecma_minifier/tests/benches-full/lodash.js index edfc31da8443..6d3b60706526 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/lodash.js +++ b/crates/swc_ecma_minifier/tests/benches-full/lodash.js @@ -622,7 +622,7 @@ var length, result1, object1, object2, object3, tag = getTag(value), isFunc = tag == funcTag || tag == genTag; if (isBuffer(value)) return cloneBuffer(value, isDeep); if (tag == objectTag || tag == argsTag || isFunc && !object) { - if (result = isFlat || isFunc ? {} : initCloneObject(value), !isDeep) return isFlat ? (object2 = (object1 = result) && copyObject(value, keysIn(value), object1), copyObject(value, getSymbolsIn(value), object2)) : (object3 = baseAssign(result, value), copyObject(value, getSymbols(value), object3)); + if (result = isFlat || isFunc ? {} : initCloneObject(value), !isDeep) return isFlat ? (object1 = (object3 = result) && copyObject(value, keysIn(value), object3), copyObject(value, getSymbolsIn(value), object1)) : (object2 = baseAssign(result, value), copyObject(value, getSymbols(value), object2)); } else { if (!cloneableTags[tag]) return object ? value : {}; result = function(object, tag, isDeep) { @@ -976,7 +976,7 @@ return !0; } function baseIsNative(value) { - return !!isObject(value) && (!maskSrcKey || !(maskSrcKey in value)) && (isFunction(value) ? reIsNative : reIsHostCtor).test(toSource(value)); + return !(!isObject(value) || maskSrcKey && maskSrcKey in value) && (isFunction(value) ? reIsNative : reIsHostCtor).test(toSource(value)); } function baseIteratee(value) { return 'function' == typeof value ? value : null == value ? identity : 'object' == typeof value ? isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value) : property(value); @@ -1003,7 +1003,8 @@ }; } function baseMatchesProperty(path, srcValue) { - return isKey(path) && srcValue == srcValue && !isObject(srcValue) ? matchesStrictComparable(toKey(path), srcValue) : function(object) { + var value; + return isKey(path) && (value = srcValue) == value && !isObject(value) ? matchesStrictComparable(toKey(path), srcValue) : function(object) { var objValue = get(object, path); return undefined === objValue && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, 3); }; @@ -1729,7 +1730,7 @@ return root.setTimeout(func, wait); }, setToString = shortOut(baseSetToString); function setWrapToString(wrapper, reference, bitmask) { - var match, details, source = reference + ''; + var details, match, source = reference + ''; return setToString(wrapper, function(source, details) { var length = details.length; if (!length) return source; diff --git a/crates/swc_ecma_minifier/tests/benches-full/victory.js b/crates/swc_ecma_minifier/tests/benches-full/victory.js index 82b5e0ec0d8c..7ec31122d64a 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/victory.js +++ b/crates/swc_ecma_minifier/tests/benches-full/victory.js @@ -8437,7 +8437,7 @@ return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) { if ('function' != typeof typeChecker) return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); var propValue = props[propName]; - if (!Array.isArray(propValue)) return new PropTypeError('Invalid ' + location + ' `' + propFullName + "` of type `" + getPropType(propValue) + '` supplied to `' + componentName + '`, expected an array.'); + if (!Array.isArray(propValue)) return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + getPropType(propValue)) + '` supplied to `' + componentName + '`, expected an array.'); for(var i = 0; i < propValue.length; i++){ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); if (error instanceof Error) return error; @@ -8447,17 +8447,17 @@ }, element: createChainableTypeChecker(function(props, propName, componentName, location, propFullName) { var propValue = props[propName]; - return isValidElement(propValue) ? null : new PropTypeError('Invalid ' + location + ' `' + propFullName + "` of type `" + getPropType(propValue) + '` supplied to `' + componentName + '`, expected a single ReactElement.'); + return isValidElement(propValue) ? null : new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + getPropType(propValue)) + '` supplied to `' + componentName + '`, expected a single ReactElement.'); }), elementType: createChainableTypeChecker(function(props, propName, componentName, location, propFullName) { var propValue = props[propName]; - return ReactIs.isValidElementType(propValue) ? null : new PropTypeError('Invalid ' + location + ' `' + propFullName + "` of type `" + getPropType(propValue) + '` supplied to `' + componentName + '`, expected a single ReactElement type.'); + return ReactIs.isValidElementType(propValue) ? null : new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + getPropType(propValue)) + '` supplied to `' + componentName + '`, expected a single ReactElement type.'); }), instanceOf: function(expectedClass) { return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) { if (!(props[propName] instanceof expectedClass)) { var propValue, expectedClassName = expectedClass.name || ANONYMOUS; - return new PropTypeError('Invalid ' + location + ' `' + propFullName + "` of type `" + ((propValue = props[propName]).constructor && propValue.constructor.name ? propValue.constructor.name : ANONYMOUS) + '` supplied to `' + componentName + "`, expected instance of `" + expectedClassName + '`.'); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + ((propValue = props[propName]).constructor && propValue.constructor.name ? propValue.constructor.name : ANONYMOUS)) + '` supplied to `' + componentName + "`, expected instance of `" + expectedClassName + '`.'); } return null; }); @@ -8496,7 +8496,7 @@ return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) { if ('function' != typeof typeChecker) return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); var propValue = props[propName], propType = getPropType(propValue); - if ('object' !== propType) return new PropTypeError('Invalid ' + location + ' `' + propFullName + "` of type `" + propType + '` supplied to `' + componentName + '`, expected an object.'); + if ('object' !== propType) return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType) + '` supplied to `' + componentName + '`, expected an object.'); for(var key in propValue)if (has(propValue, key)) { var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error instanceof Error) return error; @@ -8510,7 +8510,7 @@ var valuesString = JSON.stringify(expectedValues, function(key, value) { return 'symbol' === getPreciseType(value) ? String(value) : value; }); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + "` supplied to `" + componentName + '`, expected one of ' + valuesString + '.'); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName) + '`, expected one of ' + valuesString + '.'); }) : (arguments.length > 1 ? printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).") : printWarning('Invalid argument supplied to oneOf, expected an array.'), emptyFunctionThatReturnsNull); }, oneOfType: function(arrayOfTypeCheckers) { @@ -13407,17 +13407,17 @@ childComponents = childComponents || getChildComponents(props); var baseStyle = (calculatedProps = calculatedProps || getCalculatedProps(props, childComponents)).style.parent, height = props.height, polar = props.polar, theme = props.theme, width = props.width, _calculatedProps = calculatedProps, origin = _calculatedProps.origin, horizontal = _calculatedProps.horizontal, parentName = props.name || "chart"; return childComponents.map(function(child, index) { - var calculatedProps1, domain, scale, stringMap, categories, axisChild, role = child.type && child.type.role, style = Array.isArray(child.props.style) ? child.props.style : lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, child.props.style, { + var child1, props1, calculatedProps1, domain, scale, stringMap, categories, axisChild, role = child.type && child.type.role, style = Array.isArray(child.props.style) ? child.props.style : lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, child.props.style, { parent: baseStyle - }), childProps = (calculatedProps1 = calculatedProps, (axisChild = victory_core__WEBPACK_IMPORTED_MODULE_3__.Axis.findAxisComponents([ - child + }), childProps = (child1 = child, props1 = props, calculatedProps1 = calculatedProps, (axisChild = victory_core__WEBPACK_IMPORTED_MODULE_3__.Axis.findAxisComponents([ + child1 ])).length > 0 ? (axisChild[0], domain = calculatedProps1.domain, scale = calculatedProps1.scale, stringMap = calculatedProps1.stringMap, categories = calculatedProps1.categories, { stringMap: stringMap, horizontal: calculatedProps1.horizontal, categories: categories, - startAngle: props.startAngle, - endAngle: props.endAngle, - innerRadius: props.innerRadius, + startAngle: props1.startAngle, + endAngle: props1.endAngle, + innerRadius: props1.innerRadius, domain: domain, scale: scale }) : { @@ -22976,7 +22976,7 @@ } } return _arr; - }(_ref, 0) || function() { + }(_ref, 2) || function() { throw TypeError("Invalid attempt to destructure non-iterable instance"); }(), target = _ref2[0], eventsArray = _ref2[1]; return eventsArray = eventsArray.filter(Boolean), lodash_isEmpty__WEBPACK_IMPORTED_MODULE_2___default()(eventsArray) ? null : { @@ -23973,7 +23973,7 @@ standalone: !1 }), parentName = props.name || "group"; return childComponents.map(function(child, index) { - var props1, calculatedProps1, props2, calculatedProps2, range, angularRange, r, role = child.type && child.type.role, xOffset = polar ? (props1 = props, calculatedProps1 = calculatedProps, (index - (("stack" === role ? calculatedProps1.datasets[0].length : calculatedProps1.datasets.length) - 1) / 2) * (angularRange = Math.abs((range = calculatedProps1.range).x[1] - range.x[0]), r = Math.max.apply(Math, _toConsumableArray(range.y)), props1.offset / (2 * Math.PI * r) * angularRange)) : (props2 = props, calculatedProps2 = calculatedProps, (index - (("stack" === role ? calculatedProps2.datasets[0].length : calculatedProps2.datasets.length) - 1) / 2) * function(props, axis, calculatedProps) { + var range, angularRange, r, props1, calculatedProps1, props2, calculatedProps2, role = child.type && child.type.role, xOffset = polar ? (props1 = props, calculatedProps1 = calculatedProps, (index - (("stack" === role ? calculatedProps1.datasets[0].length : calculatedProps1.datasets.length) - 1) / 2) * (angularRange = Math.abs((range = calculatedProps1.range).x[1] - range.x[0]), r = Math.max.apply(Math, _toConsumableArray(range.y)), props1.offset / (2 * Math.PI * r) * angularRange)) : (props2 = props, calculatedProps2 = calculatedProps, (index - (("stack" === role ? calculatedProps2.datasets[0].length : calculatedProps2.datasets.length) - 1) / 2) * function(props, axis, calculatedProps) { if (!props.offset) return 0; var currentAxis = victory_core__WEBPACK_IMPORTED_MODULE_2__.Helpers.getCurrentAxis("x", props.horizontal), domain = calculatedProps.domain.x, range = calculatedProps.range[currentAxis]; return (Math.max.apply(Math, _toConsumableArray(domain)) - Math.min.apply(Math, _toConsumableArray(domain))) / (Math.max.apply(Math, _toConsumableArray(range)) - Math.min.apply(Math, _toConsumableArray(range))) * props.offset; @@ -28201,7 +28201,7 @@ } } return _arr; - }(arr, 0) || function() { + }(arr, 2) || function() { throw TypeError("Invalid attempt to destructure non-iterable instance"); }(), sharedEvents = _ref2[0], prevCacheValues = _ref2[1]; if (sharedEvents && react_fast_compare__WEBPACK_IMPORTED_MODULE_10___default()(cacheValues, prevCacheValues)) return sharedEvents; diff --git a/crates/swc_ecma_minifier/tests/benches-full/vue.js b/crates/swc_ecma_minifier/tests/benches-full/vue.js index 0e91ec4ee428..eef7427c2866 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/vue.js +++ b/crates/swc_ecma_minifier/tests/benches-full/vue.js @@ -2919,7 +2919,7 @@ directives: { model: function(el, dir, _warn) { warn$1 = _warn; - var number, valueBinding, trueValueBinding, falseValueBinding, number1, valueBinding1, value = dir.value, modifiers = dir.modifiers, tag = el.tag, type = el.attrsMap.type; + var code, number, valueBinding, trueValueBinding, falseValueBinding, number1, valueBinding1, value = dir.value, modifiers = dir.modifiers, tag = el.tag, type = el.attrsMap.type; if ('input' === tag && 'file' === type && warn$1("<" + el.tag + " v-model=\"" + value + '" type="file">:\nFile inputs are read only. Use a v-on:change listener instead.', el.rawAttrsMap['v-model']), el.component) return genComponentModel(el, value, modifiers), !1; if ('select' === tag) addHandler(el, 'change', 'var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return ' + (modifiers && modifiers.number ? '_n(val)' : 'val') + "}); " + genAssignmentCode(value, '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'), null, !0); else if ('input' === tag && 'checkbox' === type) number = modifiers && modifiers.number, valueBinding = getBindingAttr(el, 'value') || 'null', trueValueBinding = getBindingAttr(el, 'true-value') || 'true', falseValueBinding = getBindingAttr(el, 'false-value') || 'false', addProp(el, 'checked', "Array.isArray(" + value + ")?_i(" + value + "," + valueBinding + ")>-1" + ('true' === trueValueBinding ? ":(" + value + ")" : ":_q(" + value + "," + trueValueBinding + ")")), addHandler(el, 'change', "var $$a=" + value + ",$$el=$event.target,$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");if(Array.isArray($$a)){var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + ",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&(" + genAssignmentCode(value, '$$a.concat([$$v])') + ")}else{$$i>-1&&(" + genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))') + ")}}else{" + genAssignmentCode(value, '$$c') + "}", null, !0); @@ -3513,7 +3513,7 @@ } }), root; }(template.trim(), options); - !1 === options.optimize || ast && (isStaticKey = genStaticKeysCached(options.staticKeys || ''), isPlatformReservedTag = options.isReservedTag || no, function markStatic$1(node) { + !1 !== options.optimize && ast && (isStaticKey = genStaticKeysCached(options.staticKeys || ''), isPlatformReservedTag = options.isReservedTag || no, function markStatic$1(node) { if (node.static = 2 !== node.type && (3 === node.type || !!(node.pre || !node.hasBindings && !node.if && !node.for && !isBuiltInTag(node.tag) && isPlatformReservedTag(node.tag) && !function(node) { for(; node.parent && 'template' === (node = node.parent).tag;)if (node.for) return !0; return !1; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/8643/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/8643/output.js index 9e12d13e3e97..4f161566e9ba 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/8643/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/8643/output.js @@ -77,7 +77,7 @@ export class FileLoader extends Loader { let loaded = 0; return new Response(new ReadableStream({ start (controller) { - !function readData() { + (function readData() { reader.read().then(({ done, value })=>{ if (done) controller.close(); else { @@ -93,7 +93,7 @@ export class FileLoader extends Loader { controller.enqueue(value), readData(); } }); - }(); + })(); } })); } diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js index bf06eedc5252..d89ebbbd6ade 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js @@ -491,7 +491,7 @@ }; Object.prototype.hasOwnProperty; var EmotionCacheContext = (0, react.createContext)("undefined" != typeof HTMLElement ? function(options) { - var callback, container, _insert, currentSheet, collection, length, key = options.key; + var collection, length, callback, container, _insert, currentSheet, key = options.key; if ("css" === key) { var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); Array.prototype.forEach.call(ssrStyles, function(node) { @@ -824,7 +824,7 @@ ref: setRef, onClick: function(e) { var scroll1, target; - child.props && "function" == typeof child.props.onClick && child.props.onClick(e), e.defaultPrevented || (scroll1 = scroll, "A" === e.currentTarget.nodeName && ((target = e.currentTarget.target) && "_self" !== target || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.nativeEvent && 2 === e.nativeEvent.which || !_router.isLocalURL(href)) || (e.preventDefault(), null == scroll1 && as.indexOf("#") >= 0 && (scroll1 = !1), router[replace ? "replace" : "push"](href, as, { + child.props && "function" == typeof child.props.onClick && child.props.onClick(e), e.defaultPrevented || (scroll1 = scroll, ("A" !== e.currentTarget.nodeName || (!(target = e.currentTarget.target) || "_self" === target) && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey && (!e.nativeEvent || 2 !== e.nativeEvent.which) && _router.isLocalURL(href)) && (e.preventDefault(), null == scroll1 && as.indexOf("#") >= 0 && (scroll1 = !1), router[replace ? "replace" : "push"](href, as, { shallow: shallow, locale: locale, scroll: scroll1 diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js index d839b421462e..5f6fddfe17e3 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js @@ -3428,7 +3428,7 @@ }, _proto.handleSubmenuKeyDown = function(event) { (keycode__WEBPACK_IMPORTED_MODULE_3___default().isEventKey(event, "Esc") || keycode__WEBPACK_IMPORTED_MODULE_3___default().isEventKey(event, "Tab")) && (this.buttonPressed_ && this.unpressButton(), keycode__WEBPACK_IMPORTED_MODULE_3___default().isEventKey(event, "Tab") || (event.preventDefault(), this.menuButton_.focus())); }, _proto.pressButton = function() { - this.enabled_ && (this.buttonPressed_ = !0, this.menu.show(), this.menu.lockShowing(), this.menuButton_.el_.setAttribute("aria-expanded", "true"), !(IS_IOS && isInFrame())) && this.menu.focus(); + this.enabled_ && (this.buttonPressed_ = !0, this.menu.show(), this.menu.lockShowing(), this.menuButton_.el_.setAttribute("aria-expanded", "true"), IS_IOS && isInFrame() || this.menu.focus()); }, _proto.unpressButton = function() { this.enabled_ && (this.buttonPressed_ = !1, this.menu.unlockShowing(), this.menu.hide(), this.menuButton_.el_.setAttribute("aria-expanded", "false")); }, _proto.disable = function() { @@ -5853,12 +5853,12 @@ }(src, middlewares[src.type], next, player); }, 1); }(this, sources[0], function(middlewareSource, mws) { - if (_this14.middleware_ = mws, isRetry || (_this14.cache_.sources = sources), _this14.updateSourceCaches_(middlewareSource), _this14.src_(middlewareSource)) return sources.length > 1 ? _this14.handleSrc_(sources.slice(1)) : void (_this14.changingSrc_ = !1, _this14.setTimeout(function() { + if (_this14.middleware_ = mws, isRetry || (_this14.cache_.sources = sources), _this14.updateSourceCaches_(middlewareSource), _this14.src_(middlewareSource)) return sources.length > 1 ? _this14.handleSrc_(sources.slice(1)) : (_this14.changingSrc_ = !1, _this14.setTimeout(function() { this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) }); - }, 0), _this14.triggerReady()); + }, 0), void _this14.triggerReady()); !function(middleware, tech) { middleware.forEach(function(mw) { return mw.setTech && mw.setTech(tech); @@ -7025,7 +7025,7 @@ media && !media.endList ? this.trigger("mediaupdatetimeout") : this.trigger("loadedplaylist"); }, _proto.updateMediaUpdateTimeout_ = function(delay) { var _this6 = this; - this.mediaUpdateTimeout && (global_window__WEBPACK_IMPORTED_MODULE_0___default().clearTimeout(this.mediaUpdateTimeout), this.mediaUpdateTimeout = null), !this.media() || this.media().endList || (this.mediaUpdateTimeout = global_window__WEBPACK_IMPORTED_MODULE_0___default().setTimeout(function() { + this.mediaUpdateTimeout && (global_window__WEBPACK_IMPORTED_MODULE_0___default().clearTimeout(this.mediaUpdateTimeout), this.mediaUpdateTimeout = null), this.media() && !this.media().endList && (this.mediaUpdateTimeout = global_window__WEBPACK_IMPORTED_MODULE_0___default().setTimeout(function() { _this6.mediaUpdateTimeout = null, _this6.trigger("mediaupdatetimeout"), _this6.updateMediaUpdateTimeout_(delay); }, delay)); }, _proto.start = function() { @@ -7225,7 +7225,7 @@ var segment = matchedSegment.segment, mediaOffset = getOffsetFromTimestamp(segment.dateTimeObject, programTime); if ("estimate" === matchedSegment.type) return 0 === retryCount ? callback({ message: programTime + " is not buffered yet. Try again" - }) : void (seekTo(matchedSegment.estimatedStart + mediaOffset), tech.one("seeked", function() { + }) : (seekTo(matchedSegment.estimatedStart + mediaOffset), void tech.one("seeked", function() { seekToProgramTime({ programTime: programTime, playlist: playlist, @@ -10867,12 +10867,12 @@ buffer: [] }, waitForEndedTimelineEvent = isEndOfTimeline; if (transmuxer.onmessage = function(event) { - transmuxer.currentTransmux !== options || ("data" === event.data.action && handleData_(event, transmuxedData, onData), "trackinfo" === event.data.action && onTrackInfo(event.data.trackInfo), "gopInfo" === event.data.action && handleGopInfo_(event, transmuxedData), "audioTimingInfo" === event.data.action && onAudioTimingInfo(event.data.audioTimingInfo), "videoTimingInfo" === event.data.action && onVideoTimingInfo(event.data.videoTimingInfo), "videoSegmentTimingInfo" === event.data.action && onVideoSegmentTimingInfo(event.data.videoSegmentTimingInfo), "audioSegmentTimingInfo" === event.data.action && onAudioSegmentTimingInfo(event.data.audioSegmentTimingInfo), "id3Frame" === event.data.action && onId3([ + transmuxer.currentTransmux === options && ("data" === event.data.action && handleData_(event, transmuxedData, onData), "trackinfo" === event.data.action && onTrackInfo(event.data.trackInfo), "gopInfo" === event.data.action && handleGopInfo_(event, transmuxedData), "audioTimingInfo" === event.data.action && onAudioTimingInfo(event.data.audioTimingInfo), "videoTimingInfo" === event.data.action && onVideoTimingInfo(event.data.videoTimingInfo), "videoSegmentTimingInfo" === event.data.action && onVideoSegmentTimingInfo(event.data.videoSegmentTimingInfo), "audioSegmentTimingInfo" === event.data.action && onAudioSegmentTimingInfo(event.data.audioSegmentTimingInfo), "id3Frame" === event.data.action && onId3([ event.data.id3Frame - ], event.data.id3Frame.dispatchType), "caption" === event.data.action && onCaptions(event.data.caption), "endedtimeline" === event.data.action && (waitForEndedTimelineEvent = !1, onEndedTimeline()), "log" === event.data.action && onTransmuxerLog(event.data.log), "transmuxed" !== event.data.type || waitForEndedTimelineEvent) || (transmuxer.onmessage = null, handleDone_({ + ], event.data.id3Frame.dispatchType), "caption" === event.data.action && onCaptions(event.data.caption), "endedtimeline" === event.data.action && (waitForEndedTimelineEvent = !1, onEndedTimeline()), "log" === event.data.action && onTransmuxerLog(event.data.log), "transmuxed" !== event.data.type || waitForEndedTimelineEvent || (transmuxer.onmessage = null, handleDone_({ transmuxedData: transmuxedData, callback: onDone - }), dequeue(transmuxer)); + }), dequeue(transmuxer))); }, audioAppendStart && transmuxer.postMessage({ action: "setAudioAppendStart", appendStart: audioAppendStart @@ -11963,7 +11963,7 @@ }); if (switchCandidate) { var timeSavedBySwitching = requestTimeRemaining - timeUntilRebuffer$1 - switchCandidate.rebufferingImpact, minimumTimeSaving = 0.5; - timeUntilRebuffer$1 <= TIME_FUDGE_FACTOR && (minimumTimeSaving = 1), !switchCandidate.playlist || switchCandidate.playlist.uri === this.playlist_.uri || timeSavedBySwitching < minimumTimeSaving || (this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config.BANDWIDTH_VARIANCE + 1, this.trigger("earlyabort")); + timeUntilRebuffer$1 <= TIME_FUDGE_FACTOR && (minimumTimeSaving = 1), switchCandidate.playlist && switchCandidate.playlist.uri !== this.playlist_.uri && !(timeSavedBySwitching < minimumTimeSaving) && (this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config.BANDWIDTH_VARIANCE + 1, this.trigger("earlyabort")); } } } @@ -11972,10 +11972,10 @@ }, _proto.handleProgress_ = function(event, simpleSegment) { this.earlyAbortWhenNeeded_(simpleSegment.stats), this.checkForAbort_(simpleSegment.requestId) || this.trigger("progress"); }, _proto.handleTrackInfo_ = function(simpleSegment, trackInfo) { - this.earlyAbortWhenNeeded_(simpleSegment.stats), !(this.checkForAbort_(simpleSegment.requestId) || this.checkForIllegalMediaSwitch(trackInfo) || (trackInfo = trackInfo || {}, shallowEqual(this.currentMediaInfo_, trackInfo) || (this.appendInitSegment_ = { + this.earlyAbortWhenNeeded_(simpleSegment.stats), this.checkForAbort_(simpleSegment.requestId) || this.checkForIllegalMediaSwitch(trackInfo) || (trackInfo = trackInfo || {}, shallowEqual(this.currentMediaInfo_, trackInfo) || (this.appendInitSegment_ = { audio: !0, video: !0 - }, this.startingMediaInfo_ = trackInfo, this.currentMediaInfo_ = trackInfo, this.logger_("trackinfo update", trackInfo), this.trigger("trackinfo")), this.checkForAbort_(simpleSegment.requestId))) && (this.pendingSegment_.trackInfo = trackInfo, this.hasEnoughInfoToAppend_() && this.processCallQueue_()); + }, this.startingMediaInfo_ = trackInfo, this.currentMediaInfo_ = trackInfo, this.logger_("trackinfo update", trackInfo), this.trigger("trackinfo")), !this.checkForAbort_(simpleSegment.requestId) && (this.pendingSegment_.trackInfo = trackInfo, this.hasEnoughInfoToAppend_() && this.processCallQueue_())); }, _proto.handleTimingInfo_ = function(simpleSegment, mediaType, timeType, time) { if (this.earlyAbortWhenNeeded_(simpleSegment.stats), !this.checkForAbort_(simpleSegment.requestId)) { var segmentInfo = this.pendingSegment_, timingInfoProperty = timingInfoPropertyForMedia(mediaType); @@ -14088,12 +14088,12 @@ var expired = this.syncController_.getExpiredTime(media, this.duration()); if (null !== expired) { var master = this.masterPlaylistLoader_.master, mainSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media)); - 0 === mainSeekable.length || this.mediaTypes_.AUDIO.activePlaylistLoader && (media = this.mediaTypes_.AUDIO.activePlaylistLoader.media(), null === (expired = this.syncController_.getExpiredTime(media, this.duration())) || 0 === (audioSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media))).length) || (this.seekable_ && this.seekable_.length && (oldEnd = this.seekable_.end(0), oldStart = this.seekable_.start(0)), audioSeekable ? audioSeekable.start(0) > mainSeekable.end(0) || mainSeekable.start(0) > audioSeekable.end(0) ? this.seekable_ = mainSeekable : this.seekable_ = videojs.createTimeRanges([ + 0 !== mainSeekable.length && (!this.mediaTypes_.AUDIO.activePlaylistLoader || (media = this.mediaTypes_.AUDIO.activePlaylistLoader.media(), null !== (expired = this.syncController_.getExpiredTime(media, this.duration())) && 0 !== (audioSeekable = Vhs$1.Playlist.seekable(media, expired, Vhs$1.Playlist.liveEdgeDelay(master, media))).length)) && (this.seekable_ && this.seekable_.length && (oldEnd = this.seekable_.end(0), oldStart = this.seekable_.start(0)), audioSeekable ? audioSeekable.start(0) > mainSeekable.end(0) || mainSeekable.start(0) > audioSeekable.end(0) ? this.seekable_ = mainSeekable : this.seekable_ = videojs.createTimeRanges([ [ audioSeekable.start(0) > mainSeekable.start(0) ? audioSeekable.start(0) : mainSeekable.start(0), audioSeekable.end(0) < mainSeekable.end(0) ? audioSeekable.end(0) : mainSeekable.end(0) ] - ]) : this.seekable_ = mainSeekable, this.seekable_ && this.seekable_.length && this.seekable_.end(0) === oldEnd && this.seekable_.start(0) === oldStart) || (this.logger_("seekable updated [" + printableRange(this.seekable_) + "]"), this.tech_.trigger("seekablechanged")); + ]) : this.seekable_ = mainSeekable, this.seekable_ && this.seekable_.length && this.seekable_.end(0) === oldEnd && this.seekable_.start(0) === oldStart || (this.logger_("seekable updated [" + printableRange(this.seekable_) + "]"), this.tech_.trigger("seekablechanged"))); } } } @@ -14336,9 +14336,9 @@ }), this[type + "StalledDownloads_"] < 10 || (this.logger_(type + " loader stalled download exclusion"), this.resetSegmentDownloads_(type), this.tech_.trigger({ type: "usage", name: "vhs-" + type + "-download-exclusion" - }), "subtitle" === type) || mpc.blacklistCurrentPlaylist({ + }), "subtitle" !== type && mpc.blacklistCurrentPlaylist({ message: "Excessive " + type + " segment downloading detected." - }, 1 / 0); + }, 1 / 0)); }, _proto.checkCurrentTime_ = function() { if (!(this.tech_.paused() || this.tech_.seeking())) { var currentTime = this.tech_.currentTime(), buffered = this.tech_.buffered(); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/47005/output.js b/crates/swc_ecma_minifier/tests/fixture/next/47005/output.js index bdee961b2284..300b588a94f3 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/47005/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/47005/output.js @@ -54,15 +54,15 @@ var S, h, E; let { element: k, boundary: A, rootBoundary: O, strategy: L } = m, j = [ ..."clippingAncestors" === A ? function(m, S) { - var h, E; - let k = S.get(m); - if (k) return k; - let A = (void 0).filter((m)=>{ + var h, E, k; + let A = S.get(m); + if (A) return A; + let O = (void (h = 0)).filter((m)=>{ var S; - return Z(m) && true; - }), O = null, L = "fixed" === Q(m).position, j = L ? ee(m) : m; - for(; Z(j);){ - let m = Q(j), S = function(m) { + return Z(m) && (S = 0, true); + }), L = null, j = "fixed" === Q(m).position, B = j ? ee(m) : m; + for(; Z(B) && (k = 0, true);){ + let m = Q(B), S = function(m) { let S = /firefox/i.test(function() { if (R) return R; let m = navigator.userAgentData; @@ -80,16 +80,16 @@ let S = h.contain; return null != S && S.includes(m); }); - }(j); - "fixed" === m.position ? O = null : (L ? S || O : S || "static" !== m.position || !O || ![ + }(B); + "fixed" === m.position ? L = null : (j ? S || L : S || "static" !== m.position || !L || ![ "absolute", "fixed" - ].includes(O.position)) ? O = m : A = A.filter((m)=>m !== j), j = ee(j); + ].includes(L.position)) ? L = m : O = O.filter((m)=>m !== B), B = ee(B); } - return S.set(m, A), A; + return S.set(m, O), O; }(k, this._c) : [].concat(A), O - ], B = j[0], C = j.reduce(()=>{}, void 0); + ], B = j[0], C = j.reduce(()=>{}, (S = 0, h = 0, void (E = 0))); return { width: C.right - C.left, height: C.bottom - C.top, @@ -101,7 +101,7 @@ isElement: Z, getDimensions: function(m) { var S, h; - return m.getBoundingClientRect(); + return (S = 0), m.getBoundingClientRect(); }, getOffsetParent: et, getDocumentElement: function(m) {}, @@ -110,7 +110,7 @@ var S, h, E; let { reference: k, floating: R, strategy: A } = m, O = this.getOffsetParent || et, L = this.getDimensions; return { - reference: void await O(R), + reference: (S = 0, h = await O(R), void (E = 0)), floating: { x: 0, y: 0, diff --git a/crates/swc_ecma_minifier/tests/fixture/next/chakra/output.js b/crates/swc_ecma_minifier/tests/fixture/next/chakra/output.js index 7e8d21273eec..2859b314dd69 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/chakra/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/chakra/output.js @@ -1582,7 +1582,7 @@ colorScheme: "blue" } }, baseStyleContainer$3 = function(props) { - var opts, fallback, list, name = props.name, theme = props.theme, bg = name ? (opts = { + var list, opts, fallback, name = props.name, theme = props.theme, bg = name ? (opts = { string: name }, fallback = (function random(options) { if (void 0 === options && (options = {}), void 0 !== options.count && null !== options.count) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js index 7048b9eb5996..a71b21e5c6c6 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js @@ -2071,9 +2071,9 @@ return m(e) ? t.stylize("" + e, "number") : g(e) ? t.stylize("" + e, "boolean") : h(e) ? t.stylize("null", "null") : void 0; }(t, r); if (f) return f; - var y = Object.keys(r), O = (n = {}, y.forEach(function(t, e) { - n[t] = !0; - }), n); + var y = Object.keys(r), O = (p = {}, y.forEach(function(t, e) { + p[t] = !0; + }), p); if (t.showHidden && (y = Object.getOwnPropertyNames(r)), P(r) && (y.indexOf("message") >= 0 || y.indexOf("description") >= 0)) return s(r); if (0 === y.length) { if (x(r)) { @@ -2098,9 +2098,9 @@ }), i; }(t, r, o, O, y) : y.map(function(e) { return d(t, r, o, O, e, F); - }), t.seen.pop(), i = E, a = k, p = 0, c.reduce(function(t, e) { - return p++, e.indexOf("\n") >= 0 && p++, t + e.replace(/\u001b\[\d\d?m/g, "").length + 1; - }, 0) > 60 ? a[0] + ("" === i ? "" : i + "\n ") + " " + c.join(",\n ") + " " + a[1] : a[0] + i + " " + c.join(", ") + " " + a[1]) : k[0] + E + k[1]; + }), t.seen.pop(), n = E, i = k, a = 0, c.reduce(function(t, e) { + return a++, e.indexOf("\n") >= 0 && a++, t + e.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60 ? i[0] + ("" === n ? "" : n + "\n ") + " " + c.join(",\n ") + " " + i[1] : i[0] + n + " " + c.join(", ") + " " + i[1]) : k[0] + E + k[1]; } function s(t) { return "[" + Error.prototype.toString.call(t) + "]"; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js index cc04432c4cd4..d43b797bbaf8 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/output.js @@ -1949,7 +1949,7 @@ } function formatValue(r, e, o) { if (r.customInspect && e && isFunction(e.inspect) && e.inspect !== t.inspect && !(e.constructor && e.constructor.prototype === e)) { - var t1, t2, e1, o1, l, n = e.inspect(o, r); + var t1, e1, o1, t2, l, n = e.inspect(o, r); return isString(n) || (n = formatValue(r, n, o)), n; } var i = function(r, t) { @@ -1961,9 +1961,9 @@ return isNumber(t) ? r.stylize("" + t, "number") : isBoolean(t) ? r.stylize("" + t, "boolean") : isNull(t) ? r.stylize("null", "null") : void 0; }(r, e); if (i) return i; - var a = Object.keys(e), y = (t1 = {}, a.forEach(function(r, e) { - t1[r] = !0; - }), t1); + var a = Object.keys(e), y = (t2 = {}, a.forEach(function(r, e) { + t2[r] = !0; + }), t2); if (r.showHidden && (a = Object.getOwnPropertyNames(e)), isError(e) && (a.indexOf("message") >= 0 || a.indexOf("description") >= 0)) return formatError(e); if (0 === a.length) { if (isFunction(e)) { @@ -1988,9 +1988,9 @@ }), i; }(r, e, o, y, a) : a.map(function(t) { return formatProperty(r, e, o, y, t, u); - }), r.seen.pop(), t2 = f, e1 = s, o1 = 0, l.reduce(function(r, t) { + }), r.seen.pop(), t1 = f, e1 = s, o1 = 0, l.reduce(function(r, t) { return o1++, t.indexOf("\n") >= 0 && o1++, r + t.replace(/\u001b\[\d\d?m/g, "").length + 1; - }, 0) > 60 ? e1[0] + ("" === t2 ? "" : t2 + "\n ") + " " + l.join(",\n ") + " " + e1[1] : e1[0] + t2 + " " + l.join(", ") + " " + e1[1]) : s[0] + f + s[1]; + }, 0) > 60 ? e1[0] + ("" === t1 ? "" : t1 + "\n ") + " " + l.join(",\n ") + " " + e1[1] : e1[0] + t1 + " " + l.join(", ") + " " + e1[1]) : s[0] + f + s[1]; } function formatError(r) { return "[" + Error.prototype.toString.call(r) + "]"; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js index fc743401b65c..d03c5ead9f3c 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js @@ -914,7 +914,7 @@ inComposition.useTextareaForIME ? host.onCompositionUpdate(text.value) : (sendText(text.value), inComposition.markerRange && (inComposition.context && (inComposition.markerRange.start.column = inComposition.selectionStart = inComposition.context.compositionStartOffset), inComposition.markerRange.end.column = inComposition.markerRange.start.column + lastSelectionEnd - inComposition.selectionStart + lastRestoreEnd)); } }, onCompositionEnd = function(e) { - !host.onCompositionEnd || host.$readOnly || (inComposition = !1, host.onCompositionEnd(), host.off("mousedown", cancelComposition), e && onInput()); + host.onCompositionEnd && !host.$readOnly && (inComposition = !1, host.onCompositionEnd(), host.off("mousedown", cancelComposition), e && onInput()); }; function cancelComposition() { ignoreFocusEvents = !0, text.blur(), text.focus(), ignoreFocusEvents = !1; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index fcb29a8bead0..7449e159f63d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -8781,7 +8781,7 @@ 4289: function(e, t, r) { "use strict"; var n = r(2215), i = "function" == typeof Symbol && "symbol" == typeof Symbol("foo"), o = Object.prototype.toString, a = Array.prototype.concat, u = Object.defineProperty, l = r(1044)(), s = u && l, c = function(e, t, r, n) { - t in e && (!("function" == typeof n && "[object Function]" === o.call(n)) || !n()) || (s ? u(e, t, { + (!(t in e) || "function" == typeof n && "[object Function]" === o.call(n) && n()) && (s ? u(e, t, { configurable: !0, enumerable: !1, value: r, @@ -16561,7 +16561,7 @@ return !1; } }(), s = function(e, t, r, n) { - t in e && (!("function" == typeof n && "[object Function]" === o.call(n)) || !n()) || (l ? u(e, t, { + (!(t in e) || "function" == typeof n && "[object Function]" === o.call(n) && n()) && (l ? u(e, t, { configurable: !0, enumerable: !1, value: r, @@ -17449,9 +17449,9 @@ return b(t) ? e.stylize("" + t, "number") : g(t) ? e.stylize("" + t, "boolean") : v(t) ? e.stylize("null", "null") : void 0; }(e, r); if (c) return c; - var f = Object.keys(r), E = (i = {}, f.forEach(function(e, t) { - i[e] = !0; - }), i); + var f = Object.keys(r), E = (u = {}, f.forEach(function(e, t) { + u[e] = !0; + }), u); if (e.showHidden && (f = Object.getOwnPropertyNames(r)), x(r) && (f.indexOf("message") >= 0 || f.indexOf("description") >= 0)) return p(r); if (0 === f.length) { if (S(r)) { @@ -17476,9 +17476,9 @@ }), o; }(e, r, n, E, f) : f.map(function(t) { return h(e, r, n, E, t, T); - }), e.seen.pop(), o = k, a = C, u = 0, l.reduce(function(e, t) { - return u++, t.indexOf("\n") >= 0 && u++, e + t.replace(/\u001b\[\d\d?m/g, "").length + 1; - }, 0) > 60 ? a[0] + ("" === o ? "" : o + "\n ") + " " + l.join(",\n ") + " " + a[1] : a[0] + o + " " + l.join(", ") + " " + a[1]) : C[0] + k + C[1]; + }), e.seen.pop(), i = k, o = C, a = 0, l.reduce(function(e, t) { + return a++, t.indexOf("\n") >= 0 && a++, e + t.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60 ? o[0] + ("" === i ? "" : i + "\n ") + " " + l.join(",\n ") + " " + o[1] : o[0] + i + " " + l.join(", ") + " " + o[1]) : C[0] + k + C[1]; } function p(e) { return "[" + Error.prototype.toString.call(e) + "]"; @@ -18467,7 +18467,7 @@ if ((0 === c || u._offset >= u._chunkSize) && (o = u._chunkSize, u._offset = 0, u._buffer = n.allocUnsafe(u._chunkSize)), 0 === c) { if (a += i - s, i = s, !f) return !0; var g = u._handle.write(t, e, a, i, u._buffer, u._offset, u._chunkSize); - return void (g.callback = b, g.buffer = e); + return g.callback = b, void (g.buffer = e); } if (!f) return !1; r(); @@ -20943,8 +20943,8 @@ } function k(e, t, r, n, i) { a("readableAddChunk", t); - var o, u, l, s, c, f = e._readableState; - if (null === t) f.reading = !1, function(e, t) { + var o, u, l, s, c = e._readableState; + if (null === t) c.reading = !1, function(e, t) { if (a("onEofChunk"), !t.ended) { if (t.decoder) { var r = t.decoder.end(); @@ -20952,21 +20952,21 @@ } t.ended = !0, t.sync ? C(e) : (t.needReadable = !1, t.emittedReadable || (t.emittedReadable = !0, P(e))); } - }(e, f); - else if (i || (l = o = t, d.isBuffer(l) || l instanceof p || "string" == typeof o || void 0 === o || f.objectMode || (u = new m("chunk", [ + }(e, c); + else if (i || (o = t, d.isBuffer(o) || o instanceof p || "string" == typeof o || void 0 === o || c.objectMode || (u = new m("chunk", [ "string", "Buffer", "Uint8Array" - ], o)), c = u), c) _(e, c); - else if (f.objectMode || t && t.length > 0) { - if ("string" == typeof t || f.objectMode || Object.getPrototypeOf(t) === d.prototype || (s = t, t = d.from(s)), n) f.endEmitted ? _(e, new E()) : T(e, f, t, !0); - else if (f.ended) _(e, new D()); + ], o)), s = u), s) _(e, s); + else if (c.objectMode || t && t.length > 0) { + if ("string" == typeof t || c.objectMode || Object.getPrototypeOf(t) === d.prototype || (l = t, t = d.from(l)), n) c.endEmitted ? _(e, new E()) : T(e, c, t, !0); + else if (c.ended) _(e, new D()); else { - if (f.destroyed) return !1; - f.reading = !1, f.decoder && !r ? (t = f.decoder.write(t), f.objectMode || 0 !== t.length ? T(e, f, t, !1) : F(e, f)) : T(e, f, t, !1); + if (c.destroyed) return !1; + c.reading = !1, c.decoder && !r ? (t = c.decoder.write(t), c.objectMode || 0 !== t.length ? T(e, c, t, !1) : F(e, c)) : T(e, c, t, !1); } - } else n || (f.reading = !1, F(e, f)); - return !f.ended && (f.length < f.highWaterMark || 0 === f.length); + } else n || (c.reading = !1, F(e, c)); + return !c.ended && (c.length < c.highWaterMark || 0 === c.length); } function T(e, t, r, n) { t.flowing && 0 === t.length && !t.sync ? (t.awaitDrain = 0, e.emit("data", r)) : (t.length += t.objectMode ? 1 : r.length, n ? t.buffer.unshift(r) : t.buffer.push(r), t.needReadable && C(e)), F(e, t); @@ -21155,7 +21155,7 @@ } t.push(null); }), e.on("data", function(i) { - a("wrapped data"), r.decoder && (i = r.decoder.write(i)), r.objectMode && null == i || !r.objectMode && (!i || !i.length) || t.push(i) || (n = !0, e.pause()); + a("wrapped data"), r.decoder && (i = r.decoder.write(i)), (!r.objectMode || null != i) && (r.objectMode || i && i.length) && (t.push(i) || (n = !0, e.pause())); }), e)void 0 === this[i] && "function" == typeof e[i] && (this[i] = function(t) { return function() { return e[t].apply(e, arguments); @@ -21683,7 +21683,7 @@ i(e, t), r(e); } function r(e) { - e._writableState && !e._writableState.emitClose || e._readableState && !e._readableState.emitClose || e.emit("close"); + (!e._writableState || e._writableState.emitClose) && (!e._readableState || e._readableState.emitClose) && e.emit("close"); } function i(e, t) { e.emit("error", t); @@ -23177,9 +23177,9 @@ return b(t) ? e.stylize("" + t, "number") : g(t) ? e.stylize("" + t, "boolean") : v(t) ? e.stylize("null", "null") : void 0; }(e, r); if (c) return c; - var f = Object.keys(r), E = (i = {}, f.forEach(function(e, t) { - i[e] = !0; - }), i); + var f = Object.keys(r), E = (u = {}, f.forEach(function(e, t) { + u[e] = !0; + }), u); if (e.showHidden && (f = Object.getOwnPropertyNames(r)), x(r) && (f.indexOf("message") >= 0 || f.indexOf("description") >= 0)) return p(r); if (0 === f.length) { if (S(r)) { @@ -23204,9 +23204,9 @@ }), o; }(e, r, n, E, f) : f.map(function(t) { return h(e, r, n, E, t, T); - }), e.seen.pop(), o = k, a = C, u = 0, l.reduce(function(e, t) { - return u++, t.indexOf("\n") >= 0 && u++, e + t.replace(/\u001b\[\d\d?m/g, "").length + 1; - }, 0) > 60 ? a[0] + ("" === o ? "" : o + "\n ") + " " + l.join(",\n ") + " " + a[1] : a[0] + o + " " + l.join(", ") + " " + a[1]) : C[0] + k + C[1]; + }), e.seen.pop(), i = k, o = C, a = 0, l.reduce(function(e, t) { + return a++, t.indexOf("\n") >= 0 && a++, e + t.replace(/\u001b\[\d\d?m/g, "").length + 1; + }, 0) > 60 ? o[0] + ("" === i ? "" : i + "\n ") + " " + l.join(",\n ") + " " + o[1] : o[0] + i + " " + l.join(", ") + " " + o[1]) : C[0] + k + C[1]; } function p(e) { return "[" + Error.prototype.toString.call(e) + "]"; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js index d105f746678b..9d1538617621 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js @@ -4623,13 +4623,13 @@ return component_extends(Component, _super), Component.prototype.requiredModules = function() { return []; }, Component.prototype.destroy = function() { - this.isDestroyed || (this.enablePersistence && this.setPersistData(), this.localObserver.destroy(), this.refreshing) || (removeClass([ + !this.isDestroyed && (this.enablePersistence && this.setPersistData(), this.localObserver.destroy(), this.refreshing || (removeClass([ this.element ], [ 'e-control' ]), this.trigger('destroyed', { cancel: !1 - }), _super.prototype.destroy.call(this), this.moduleLoader.clean(), onIntlChange.off('notifyExternalChange', this.detectFunction, this.randomId)); + }), _super.prototype.destroy.call(this), this.moduleLoader.clean(), onIntlChange.off('notifyExternalChange', this.detectFunction, this.randomId))); }, Component.prototype.refresh = function() { this.refreshing = !0, this.moduleLoader.clean(), this.destroy(), this.clearChanges(), this.localObserver = new Observer(this), this.preRender(), this.injectModules(), this.render(), this.refreshing = !1; }, Component.prototype.accessMount = function() { @@ -10658,7 +10658,7 @@ }, RichTextEditor.prototype.executeCommand = function(commandName, value, option) { if (value = this.htmlPurifier(commandName, value), 'HTML' === this.editorMode) { var range = this.getRange(); - this.iframeSettings.enable && this.formatter.editorManager.nodeSelection.Clear(this.element.ownerDocument), (!this.iframeSettings.enable || range.startContainer !== this.inputElement) && this.inputElement.contains(range.startContainer) || this.focusIn(); + this.iframeSettings.enable && this.formatter.editorManager.nodeSelection.Clear(this.element.ownerDocument), (this.iframeSettings.enable && range.startContainer === this.inputElement || !this.inputElement.contains(range.startContainer)) && this.focusIn(); } var tool = executeGroup[commandName]; if (option && option.undo && option.undo && 0 === this.formatter.getUndoRedoStack().length && this.formatter.saveData(), -1 !== this.maxLength && !(0, ej2_base.le)(tool.command)) { @@ -23380,7 +23380,7 @@ }, ToolbarRenderer.prototype.dropDownSelected = function(args) { this.parent.notify(constant.s7, args), this.onPopupOverlay(); }, ToolbarRenderer.prototype.beforeDropDownItemRender = function(args) { - this.parent.readonly || !this.parent.enabled || this.parent.notify(constant.nd, args); + !this.parent.readonly && this.parent.enabled && this.parent.notify(constant.nd, args); }, ToolbarRenderer.prototype.dropDownOpen = function(args) { if (args.element.parentElement.getAttribute('id').indexOf('TableCell') > -1 && !(0, ej2_base.le)(args.element.parentElement.querySelector('.e-cell-merge')) && (!(0, ej2_base.le)(args.element.parentElement.querySelector('.e-cell-horizontal-split')) || !(0, ej2_base.le)(args.element.parentElement.querySelector('.e-cell-vertical-split')))) { var listEle = args.element.querySelectorAll('li'); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js index 698a6cfe8345..e60d03232566 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js @@ -16434,7 +16434,7 @@ } t.push(null); }), e.on("data", function(i) { - u("wrapped data"), r.decoder && (i = r.decoder.write(i)), r.objectMode && null == i || !r.objectMode && (!i || !i.length) || t.push(i) || (n = !0, e.pause()); + u("wrapped data"), r.decoder && (i = r.decoder.write(i)), (!r.objectMode || null != i) && (r.objectMode || i && i.length) && (t.push(i) || (n = !0, e.pause())); }), e)void 0 === this[i] && "function" == typeof e[i] && (this[i] = function(t) { return function() { return e[t].apply(e, arguments); @@ -17017,7 +17017,7 @@ emitErrorNT(e, t), emitCloseNT(e); } function emitCloseNT(e) { - e._writableState && !e._writableState.emitClose || e._readableState && !e._readableState.emitClose || e.emit("close"); + (!e._writableState || e._writableState.emitClose) && (!e._readableState || e._readableState.emitClose) && e.emit("close"); } function undestroy() { this._readableState && (this._readableState.destroyed = !1, this._readableState.reading = !1, this._readableState.ended = !1, this._readableState.endEmitted = !1), this._writableState && (this._writableState.destroyed = !1, this._writableState.ended = !1, this._writableState.ending = !1, this._writableState.finalCalled = !1, this._writableState.prefinished = !1, this._writableState.finished = !1, this._writableState.errorEmitted = !1); diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js index d3a160f7191f..15b04cd03722 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{840:function(t,e,n){var r;!function(i,o,a,s){"use strict";var c,u=["","webkit","Moz","MS","ms","o"],l=o.createElement("div"),h=Math.round,p=Math.abs,f=Date.now;function d(t,e,n){return setTimeout(O(t,n),e)}function v(t,e,n){return!!Array.isArray(t)&&(g(t,n[e],n),!0)}function g(t,e,n){var r;if(t){if(t.forEach)t.forEach(e,n);else if(s!==t.length)for(r=0;r\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=i.console&&(i.console.warn||i.console.log);return o&&o.call(i.console,r,n),t.apply(this,arguments)}}c="function"!=typeof Object.assign?function(t){if(null==t)throw TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n-1}function S(t){return t.trim().split(/\s+/g)}function T(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var r=0;rT(i,a)&&r.push(t[o]),i[o]=a,o++}return n&&(r=e?r.sort(function(t,n){return t[e]>n[e]}):r.sort()),r}function D(t,e){for(var n,r,i=e[0].toUpperCase()+e.slice(1),o=0;o1&&!r.firstMultiple?r.firstMultiple=U(n):1===o&&(r.firstMultiple=!1),a=r.firstInput,u=(c=r.firstMultiple)?c.center:a.center,l=n.center=q(i),n.timeStamp=f(),n.deltaTime=n.timeStamp-a.timeStamp,n.angle=Y(u,l),n.distance=X(u,l),h=n.center,d=r.offsetDelta||{},v=r.prevDelta||{},g=r.prevInput||{},(1===n.eventType||4===g.eventType)&&(v=r.prevDelta={x:g.deltaX||0,y:g.deltaY||0},d=r.offsetDelta={x:h.x,y:h.y}),n.deltaX=v.x+(h.x-d.x),n.deltaY=v.y+(h.y-d.y),n.offsetDirection=H(n.deltaX,n.deltaY),m=W(n.deltaTime,n.deltaX,n.deltaY),n.overallVelocityX=m.x,n.overallVelocityY=m.y,n.overallVelocity=p(m.x)>p(m.y)?m.x:m.y,n.scale=c?(b=c.pointers,X(i[0],i[1],V)/X(b[0],b[1],V)):1,n.rotation=c?(y=c.pointers,Y(i[1],i[0],V)+Y(y[1],y[0],V)):0,n.maxPointers=r.prevInput?n.pointers.length>r.prevInput.maxPointers?n.pointers.length:r.prevInput.maxPointers:n.pointers.length,function(t,e){var n,r,i,o,a=t.lastInterval||e,c=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(c>25||s===a.velocity)){var u=e.deltaX-a.deltaX,l=e.deltaY-a.deltaY,h=W(c,u,l);r=h.x,i=h.y,n=p(h.x)>p(h.y)?h.x:h.y,o=H(u,l),t.lastInterval=e}else n=a.velocity,r=a.velocityX,i=a.velocityY,o=a.direction;e.velocity=n,e.velocityX=r,e.velocityY=i,e.direction=o}(r,n),w=t.element,M(n.srcEvent.target,w)&&(w=n.srcEvent.target),n.target=w,t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function U(t){for(var e=[],n=0;n=p(e)?t<0?2:4:e<0?8:16}function X(t,e,n){n||(n=F);var r=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(r*r+i*i)}function Y(t,e,n){n||(n=F);var r=e[n[0]]-t[n[0]];return 180*Math.atan2(e[n[1]]-t[n[1]],r)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&_(this.element,this.evEl,this.domHandler),this.evTarget&&_(this.target,this.evTarget,this.domHandler),this.evWin&&_(R(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(R(this.element),this.evWin,this.domHandler)}};var K={mousedown:1,mousemove:2,mouseup:4};function G(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,Z.apply(this,arguments)}w(G,Z,{handler:function(t){var e=K[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:z,srcEvent:t}))}});var $={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:N,3:"pen",4:z,5:"kinect"},Q="pointerdown",tt="pointermove pointerup pointercancel";function te(){this.evEl=Q,this.evWin=tt,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}i.MSPointerEvent&&!i.PointerEvent&&(Q="MSPointerDown",tt="MSPointerMove MSPointerUp MSPointerCancel"),w(te,Z,{handler:function(t){var e=this.store,n=!1,r=$[t.type.toLowerCase().replace("ms","")],i=J[t.pointerType]||t.pointerType,o=i==N,a=T(e,t.pointerId,"pointerId");1&r&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):12&r&&(n=!0),!(a<0)&&(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:i,srcEvent:t}),n&&e.splice(a,1))}});var tn={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function tr(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}function ti(t,e){var n=k(t.touches),r=k(t.changedTouches);return 12&e&&(n=x(n.concat(r),"identifier",!0)),[n,r]}w(tr,Z,{handler:function(t){var e=tn[t.type];if(1===e&&(this.started=!0),this.started){var n=ti.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:N,srcEvent:t})}}});var to={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ta(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},Z.apply(this,arguments)}function ts(t,e){var n=k(t.touches),r=this.targetIds;if(3&e&&1===n.length)return r[n[0].identifier]=!0,[n,n];var i,o,a=k(t.changedTouches),s=[],c=this.target;if(o=n.filter(function(t){return M(t.target,c)}),1===e)for(i=0;i-1&&r.splice(t,1)},2500)}}function th(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,r=0;r-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function r(n){e.manager.emit(n,t)}n<8&&r(e.options.event+t_(n)),r(e.options.event),t.additionalEvent&&r(t.additionalEvent),n>=8&&r(e.options.event+t_(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;te.threshold&&i&e.direction},attrTest:function(t){return tj.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=tP(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),w(tT,tj,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[tm]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),w(tk,tE,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[tv]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distancee.time;if(this._input=t,r&&n&&(!(12&t.eventType)||i)){if(1&t.eventType)this.reset(),this._timer=d(function(){this.state=8,this.tryEmit()},e.time,this);else if(4&t.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=f(),this.manager.emit(this.options.event,this._input)))}}),w(tx,tj,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[tm]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),w(tD,tj,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return tS.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:24&n&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&p(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=tP(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),w(tC,tE,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[tg]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distance1)for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n=-90&&e<=90,"invalid latitude");const n=512*(j+Math.log(Math.tan(S+e*T*.5)))/(2*j);return[512*(t*T+j)/(2*j),n]}function C([t,e]){const n=2*(Math.atan(Math.exp(e/512*(2*j)-j))-S);return[(t/512*(2*j)-j)*k,n*k]}function R(t){return 2*Math.atan(.5/t)*k}function A(t){return .5/Math.tan(.5*t*T)}function I(t,e,n=0){const[r,i,o]=t;if(M(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o))return g(e,[r,i,o,1]);const a=g(e,[r,i,0,1]),s=g(e,[r,i,1,1]),c=a[2],u=s[2];return P([],a,s,c===u?0:((n||0)-c)/(u-c))}const L=Math.PI/180;function N(t,e,n){const{pixelUnprojectionMatrix:r}=t,i=g(r,[e,0,1,1]),o=g(r,[e,t.height,1,1]),a=(n*t.distanceScales.unitsPerMeter[2]-i[2])/(o[2]-i[2]),s=C(P([],i,o,a));return s[2]=n,s}class z{constructor({width:t,height:e,latitude:n=0,longitude:r=0,zoom:i=0,pitch:o=0,bearing:a=0,altitude:s=null,fovy:c=null,position:u=null,nearZMultiplier:l=.02,farZMultiplier:h=1.01}={width:1,height:1}){t=t||1,e=e||1,null===c&&null===s?c=R(s=1.5):null===c?c=R(s):null===s&&(s=A(c));const p=x(i);s=Math.max(.75,s);const f=function({latitude:t,longitude:e,highPrecision:n=!1}){M(Number.isFinite(t)&&Number.isFinite(e));const r={},i=Math.cos(t*T),o=512/360,a=512/360/i,s=512/4003e4/i;if(r.unitsPerMeter=[s,s,s],r.metersPerUnit=[1/s,1/s,1/s],r.unitsPerDegree=[o,a,s],r.degreesPerUnit=[1/o,1/a,1/s],n){const e=T*Math.tan(t*T)/i,n=512/4003e4*e,c=n/a*s;r.unitsPerDegree2=[0,o*e/2,n],r.unitsPerMeter2=[c,0,c]}return r}({longitude:r,latitude:n}),d=D([r,n]);if(d[2]=0,u){var g,m;g=[],m=f.unitsPerMeter,g[0]=u[0]*m[0],g[1]=u[1]*m[1],g[2]=u[2]*m[2],d[0]=d[0]+g[0],d[1]=d[1]+g[1],d[2]=d[2]+g[2]}this.projectionMatrix=function({width:t,height:e,pitch:n,altitude:r,fovy:i,nearZMultiplier:o,farZMultiplier:a}){var s,c,u;const{fov:l,aspect:h,near:p,far:f}=function({width:t,height:e,fovy:n=R(1.5),altitude:r,pitch:i=0,nearZMultiplier:o=1,farZMultiplier:a=1}){void 0!==r&&(n=R(r));const s=.5*n*T,c=A(n),u=i*T,l=Math.sin(s)*c/Math.sin(Math.min(Math.max(Math.PI/2-u-s,.01),Math.PI-.01)),h=Math.sin(u)*l+c;return{fov:2*s,aspect:t/e,focalDistance:c,near:o,far:h*a}}({width:t,height:e,altitude:r,fovy:i,pitch:n,nearZMultiplier:o,farZMultiplier:a});return s=[],u=1/Math.tan(l/2),s[0]=u/h,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,null!=f&&f!==1/0?(c=1/(p-f),s[10]=(f+p)*c,s[14]=2*f*p*c):(s[10]=-1,s[14]=-2*p),s}({width:t,height:e,pitch:o,fovy:c,nearZMultiplier:l,farZMultiplier:h}),this.viewMatrix=function({height:t,pitch:e,bearing:n,altitude:r,scale:i,center:o=null}){var a,s,c,u,l,h,p,f,d,g,m,b,y,E,_,P,M,j,S,k,x,D,C;const R=v();return w(R,R,[0,0,-r]),s=Math.sin(a=-e*T),c=Math.cos(a),u=R[4],l=R[5],h=R[6],p=R[7],f=R[8],d=R[9],g=R[10],m=R[11],R!=R&&(R[0]=R[0],R[1]=R[1],R[2]=R[2],R[3]=R[3],R[12]=R[12],R[13]=R[13],R[14]=R[14],R[15]=R[15]),R[4]=u*c+f*s,R[5]=l*c+d*s,R[6]=h*c+g*s,R[7]=p*c+m*s,R[8]=f*c-u*s,R[9]=d*c-l*s,R[10]=g*c-h*s,R[11]=m*c-p*s,y=Math.sin(b=n*T),E=Math.cos(b),_=R[0],P=R[1],M=R[2],j=R[3],S=R[4],k=R[5],x=R[6],D=R[7],R!=R&&(R[8]=R[8],R[9]=R[9],R[10]=R[10],R[11]=R[11],R[12]=R[12],R[13]=R[13],R[14]=R[14],R[15]=R[15]),R[0]=_*E+S*y,R[1]=P*E+k*y,R[2]=M*E+x*y,R[3]=j*E+D*y,R[4]=S*E-_*y,R[5]=k*E-P*y,R[6]=x*E-M*y,R[7]=D*E-j*y,O(R,R,[i/=t,i,i]),o&&w(R,R,((C=[])[0]=-o[0],C[1]=-o[1],C[2]=-o[2],C)),R}({height:e,scale:p,center:d,pitch:o,bearing:a,altitude:s}),this.width=t,this.height=e,this.scale=p,this.latitude=n,this.longitude=r,this.zoom=i,this.pitch=o,this.bearing=a,this.altitude=s,this.fovy=c,this.center=d,this.meterOffset=u||[0,0,0],this.distanceScales=f,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var t,e,n,r,i,o,a,s,c,u,l,h,p,f,d,g,m,b,E,_,P,M,j,S,T,k,x,D,C,R;const{width:A,height:I,projectionMatrix:L,viewMatrix:N}=this,z=v();y(z,z,L),y(z,z,N),this.viewProjectionMatrix=z;const F=v();O(F,F,[A/2,-I/2,1]),w(F,F,[1,-1,0]),y(F,F,z);const V=(t=v(),e=F[0],n=F[1],r=F[2],i=F[3],o=F[4],a=F[5],s=F[6],c=F[7],u=F[8],l=F[9],h=F[10],p=F[11],f=F[12],d=F[13],g=F[14],m=F[15],b=e*a-n*o,E=e*s-r*o,_=e*c-i*o,P=n*s-r*a,M=n*c-i*a,j=r*c-i*s,S=u*d-l*f,T=u*g-h*f,k=u*m-p*f,x=l*g-h*d,D=l*m-p*d,(R=b*(C=h*m-p*g)-E*D+_*x+P*k-M*T+j*S)?(R=1/R,t[0]=(a*C-s*D+c*x)*R,t[1]=(r*D-n*C-i*x)*R,t[2]=(d*j-g*M+m*P)*R,t[3]=(h*M-l*j-p*P)*R,t[4]=(s*k-o*C-c*T)*R,t[5]=(e*C-r*k+i*T)*R,t[6]=(g*_-f*j-m*E)*R,t[7]=(u*j-h*_+p*E)*R,t[8]=(o*D-a*k+c*S)*R,t[9]=(n*k-e*D-i*S)*R,t[10]=(f*M-d*_+m*b)*R,t[11]=(l*_-u*M-p*b)*R,t[12]=(a*T-o*x-s*S)*R,t[13]=(e*x-n*T+r*S)*R,t[14]=(d*E-f*P-g*b)*R,t[15]=(u*P-l*E+h*b)*R,t):null);if(!V)throw Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=F,this.pixelUnprojectionMatrix=V}equals(t){return t instanceof z&&t.width===this.width&&t.height===this.height&&E(t.projectionMatrix,this.projectionMatrix)&&E(t.viewMatrix,this.viewMatrix)}project(t,{topLeft:e=!0}={}){const n=function(t,e){const[n,r,i=0]=t;return M(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),g(e,[n,r,i,1])}(this.projectPosition(t),this.pixelProjectionMatrix),[r,i]=n,o=e?i:this.height-i;return 2===t.length?[r,o]:[r,o,n[2]]}unproject(t,{topLeft:e=!0,targetZ:n}={}){const[r,i,o]=t,a=e?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=I([r,a,o],this.pixelUnprojectionMatrix,s),[u,l,h]=this.unprojectPosition(c);return Number.isFinite(o)?[u,l,h]:Number.isFinite(n)?[u,l,n]:[u,l]}projectPosition(t){const[e,n]=D(t);return[e,n,(t[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(t){const[e,n]=C(t);return[e,n,(t[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(t){return D(t)}unprojectFlat(t){return C(t)}getMapCenterByLngLatPosition({lngLat:t,pos:e}){var n;const r=I(e,this.pixelUnprojectionMatrix),i=_([],D(t),((n=[])[0]=-r[0],n[1]=-r[1],n));return C(_([],this.center,i))}getLocationAtPoint({lngLat:t,pos:e}){return this.getMapCenterByLngLatPosition({lngLat:t,pos:e})}fitBounds(t,e={}){const{width:n,height:r}=this,{longitude:i,latitude:o,zoom:a}=function({width:t,height:e,bounds:n,minExtent:r=0,maxZoom:i=24,padding:o=0,offset:a=[0,0]}){const[[s,c],[u,l]]=n;if(Number.isFinite(o)){const t=o;o={top:t,bottom:t,left:t,right:t}}else M(Number.isFinite(o.top)&&Number.isFinite(o.bottom)&&Number.isFinite(o.left)&&Number.isFinite(o.right));const h=D([s,l<-85.051129?-85.051129:l>85.051129?85.051129:l]),p=D([u,c<-85.051129?-85.051129:c>85.051129?85.051129:c]),f=[Math.max(Math.abs(p[0]-h[0]),r),Math.max(Math.abs(p[1]-h[1]),r)],d=[t-o.left-o.right-2*Math.abs(a[0]),e-o.top-o.bottom-2*Math.abs(a[1])];M(d[0]>0&&d[1]>0);const v=d[0]/f[0],g=d[1]/f[1],m=(o.right-o.left)/2/v,y=(o.bottom-o.top)/2/g,w=C([(p[0]+h[0])/2+m,(p[1]+h[1])/2+y]),O=Math.min(i,b(Math.abs(Math.min(v,g))));return M(Number.isFinite(O)),{longitude:w[0],latitude:w[1],zoom:O}}(Object.assign({width:n,height:r,bounds:t},e));return new z({width:n,height:r,longitude:i,latitude:o,zoom:a})}getBounds(t){const e=this.getBoundingRegion(t),n=Math.min(...e.map(t=>t[0])),r=Math.max(...e.map(t=>t[0]));return[[n,Math.min(...e.map(t=>t[1]))],[r,Math.max(...e.map(t=>t[1]))]]}getBoundingRegion(t={}){return function(t,e=0){let n,r;const{width:i,height:o,unproject:a}=t,s={targetZ:e},c=a([0,o],s),u=a([i,o],s);return(t.fovy?.5*t.fovy*L:Math.atan(.5/t.altitude))>(90-t.pitch)*L-.01?(n=N(t,0,e),r=N(t,i,e)):(n=a([0,0],s),r=a([i,0],s)),[c,u,r,n]}(this,t.z||0)}}const F=["longitude","latitude","zoom"],V={curve:1.414,speed:1.2};function Z(t,e,n){var r,i;const o=(n=Object.assign({},V,n)).curve,a=t.zoom,s=[t.longitude,t.latitude],c=x(a),u=e.zoom,l=[e.longitude,e.latitude],h=x(u-a),p=D(s),f=(r=[],i=D(l),r[0]=i[0]-p[0],r[1]=i[1]-p[1],r),d=Math.max(t.width,t.height),v=d/h,g=Math.hypot(f[0],f[1])*c,m=Math.max(g,.01),b=o*o,y=(v*v-d*d+b*b*m*m)/(2*d*b*m),w=(v*v-d*d-b*b*m*m)/(2*v*b*m),O=Math.log(Math.sqrt(y*y+1)-y),E=Math.log(Math.sqrt(w*w+1)-w);return{startZoom:a,startCenterXY:p,uDelta:f,w0:d,u1:g,S:(E-O)/o,rho:o,rho2:b,r0:O,r1:E}}var B=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,r){return t[0]===e&&(n=r,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n0},t.prototype.connect_=function(){!U||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),X?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){U&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;H.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),K=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),to="undefined"!=typeof WeakMap?new WeakMap:new B,ta=function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function.");if(!arguments.length)throw TypeError("1 argument required, but only 0 present.");var n=new ti(e,Y.getInstance(),this);to.set(this,n)};["observe","unobserve","disconnect"].forEach(function(t){ta.prototype[t]=function(){var e;return(e=to.get(this))[t].apply(e,arguments)}});var ts=void 0!==q.ResizeObserver?q.ResizeObserver:ta;function tc(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function tu(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function tv(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]?arguments[1]:"component";t.debug&&p.checkPropTypes(ty,t,"prop",e)}var tE=function(){function t(e){var n=this;if(tc(this,t),a(this,"props",tw),a(this,"width",0),a(this,"height",0),a(this,"_fireLoadEvent",function(){n.props.onLoad({type:"load",target:n._map})}),a(this,"_handleError",function(t){n.props.onError(t)}),!e.mapboxgl)throw Error("Mapbox not available");this.mapboxgl=e.mapboxgl,t.initialized||(t.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(e)}return tl(t,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(t){return this._update(this.props,t),this}},{key:"redraw",value:function(){var t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(e){this._map=t.savedMap;var n=this._map.getContainer(),r=e.container;for(r.classList.add("mapboxgl-map");n.childNodes.length>0;)r.appendChild(n.childNodes[0]);this._map._container=r,t.savedMap=null,e.mapStyle&&this._map.setStyle(tm(e.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(e){if(e.reuseMaps&&t.savedMap)this._reuse(e);else{if(e.gl){var n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=n,e.gl}}var r={container:e.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:tm(e.mapStyle),interactive:!1,trackResize:!1,attributionControl:e.attributionControl,preserveDrawingBuffer:e.preserveDrawingBuffer};e.transformRequest&&(r.transformRequest=e.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},r,e.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!t.savedMap?(t.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(t){var e=this;tO(t=Object.assign({},tw,t),"Mapbox"),this.mapboxgl.accessToken=t.mapboxApiAccessToken||tw.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=t.mapboxApiUrl,this._create(t);var n=t.container;Object.defineProperty(n,"offsetWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"clientWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"offsetHeight",{configurable:!0,get:function(){return e.height}}),Object.defineProperty(n,"clientHeight",{configurable:!0,get:function(){return e.height}});var r=this._map.getCanvas();r&&(r.style.outline="none"),this._updateMapViewport({},t),this._updateMapSize({},t),this.props=t}},{key:"_update",value:function(t,e){if(this._map){tO(e=Object.assign({},this.props,e),"Mapbox");var n=this._updateMapViewport(t,e),r=this._updateMapSize(t,e);this._updateMapStyle(t,e),!e.asyncRender&&(n||r)&&this.redraw(),this.props=e}}},{key:"_updateMapStyle",value:function(t,e){t.mapStyle!==e.mapStyle&&this._map.setStyle(tm(e.mapStyle),{diff:!e.preventStyleDiffing})}},{key:"_updateMapSize",value:function(t,e){var n=t.width!==e.width||t.height!==e.height;return n&&(this.width=e.width,this.height=e.height,this._map.resize()),n}},{key:"_updateMapViewport",value:function(t,e){var n=this._getViewState(t),r=this._getViewState(e),i=r.latitude!==n.latitude||r.longitude!==n.longitude||r.zoom!==n.zoom||r.pitch!==n.pitch||r.bearing!==n.bearing||r.altitude!==n.altitude;return i&&(this._map.jumpTo(this._viewStateToMapboxProps(r)),r.altitude!==n.altitude&&(this._map.transform.altitude=r.altitude)),i}},{key:"_getViewState",value:function(t){var e=t.viewState||t,n=e.longitude,r=e.latitude,i=e.zoom,o=e.pitch,a=e.bearing,s=e.altitude;return{longitude:n,latitude:r,zoom:i,pitch:void 0===o?0:o,bearing:void 0===a?0:a,altitude:void 0===s?1.5:s}}},{key:"_checkStyleSheet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==th)try{var e=th.createElement("div");if(e.className="mapboxgl-map",e.style.display="none",th.body.appendChild(e),!("static"!==window.getComputedStyle(e).position)){var n=th.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(t,"/mapbox-gl.css")),th.head.appendChild(n)}}catch(t){}}},{key:"_viewStateToMapboxProps",value:function(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}}}]),t}();a(tE,"initialized",!1),a(tE,"propTypes",ty),a(tE,"defaultProps",tw),a(tE,"savedMap",null);var t_=n(6158),tP=n.n(t_);function tM(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function tj(t,e,n){return Math.max(e,Math.min(n,t))}function tS(t,e,n){return tM(t)?t.map(function(t,r){return tS(t,e[r],n)}):n*e+(1-n)*t}function tT(t,e){if(!t)throw Error(e||"react-map-gl: assertion failed.")}function tk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tx(t){for(var e=1;e0,"`scale` must be a positive number");var i=this._state,o=i.startZoom,a=i.startZoomLngLat;Number.isFinite(o)||(o=this._viewportProps.zoom,a=this._unproject(n)||this._unproject(e)),tT(a,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var s=this._calculateNewZoom({scale:r,startZoom:o||0}),c=f(new z(Object.assign({},this._viewportProps,{zoom:s})).getMapCenterByLngLatPosition({lngLat:a,pos:e}),2),u=c[0],l=c[1];return this._getUpdatedMapState({zoom:s,longitude:u,latitude:l})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(e){return new t(Object.assign({},this._viewportProps,this._state,e))}},{key:"_applyConstraints",value:function(t){var e=t.maxZoom,n=t.minZoom,r=t.zoom;t.zoom=tj(r,n,e);var i=t.maxPitch,o=t.minPitch,a=t.pitch;return t.pitch=tj(a,o,i),Object.assign(t,function({width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o=0,bearing:a=0}){(n<-180||n>180)&&(n=m(n+180,360)-180),(a<-180||a>180)&&(a=m(a+180,360)-180);const s=b(e/512);if(i<=s)i=s,r=0;else{const t=e/2/Math.pow(2,i),n=C([0,t])[1];if(re&&(r=e)}}return{width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o,bearing:a}}(t)),t}},{key:"_unproject",value:function(t){var e=new z(this._viewportProps);return t&&e.unproject(t)}},{key:"_calculateNewLngLat",value:function(t){var e=t.startPanLngLat,n=t.pos;return new z(this._viewportProps).getMapCenterByLngLatPosition({lngLat:e,pos:n})}},{key:"_calculateNewZoom",value:function(t){var e=t.scale,n=t.startZoom,r=this._viewportProps,i=r.maxZoom;return tj(n+Math.log2(e),r.minZoom,i)}},{key:"_calculateNewPitchAndBearing",value:function(t){var e=t.deltaScaleX,n=t.deltaScaleY,r=t.startBearing,i=t.startPitch;n=tj(n,-1,1);var o=this._viewportProps,a=o.minPitch,s=o.maxPitch,c=i;return n>0?c=i+n*(s-i):n<0&&(c=i-n*(a-i)),{pitch:c,bearing:r+180*e}}},{key:"_getRotationParams",value:function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[1],o=e[1],a=this._viewportProps,s=a.width,c=a.height,u=0;return r>0?Math.abs(c-o)>5&&(u=r/(o-c)*1.2):r<0&&o>5&&(u=1-i/o),{deltaScaleX:n/s,deltaScaleY:u=Math.min(1,Math.max(-1,u))}}}]),t}();function tA(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tI(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=c.current&&c.current.getMap();return n&&n.queryRenderedFeatures(t,e)}}},[]);var g=(0,h.useCallback)(function(t){var e=t.target;e===p.current&&e.scrollTo(0,0)},[]),m=v&&h.createElement(tN,{value:tZ(tZ({},d),{},{viewport:d.viewport||tU(tZ({map:v,props:t},a)),map:v,container:d.container||l.current})},h.createElement("div",{key:"map-overlays",className:"overlays",ref:p,style:tq,onScroll:g},t.children)),b=t.className,y=t.width,w=t.height,O=t.style,E=t.visibilityConstraints,_=Object.assign({position:"relative"},O,{width:y,height:w}),P=Object.assign({},tq,{visibility:t.visible&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tD;for(var n in e){var r,i=n.slice(0,3),o=(r=n.slice(3))[0].toLowerCase()+r.slice(1);if("min"===i&&t[o]e[n])return!1}return!0}(t.viewState||t,E)?"inherit":"hidden"});return h.createElement("div",{key:"map-container",ref:l,style:_},h.createElement("div",{key:"map-mapbox",ref:u,style:P,className:b}),m,!r&&!t.disableTokenWarning&&h.createElement(tX,null))});function tK(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}(this.propNames||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!function t(e,n){if(e===n)return!0;if(tM(e)&&tM(n)){if(e.length!==n.length)return!1;for(var r=0;r=Math.abs(e-n)}(t[i],e[i]))return!1}}catch(t){r.e(t)}finally{r.f()}return!0}},{key:"initializeProps",value:function(t,e){return{start:t,end:e}}},{key:"interpolateProps",value:function(t,e,n){tT(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(t,e){return e.transitionDuration}}]),t}();function t$(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tJ(t,e){return(tJ=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function tQ(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tJ(t,e)}function t0(t){return(t0="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function t1(t,e){if(e&&("object"===t0(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return t$(t)}function t2(t){return(t2=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var t5={longitude:1,bearing:1};function t4(t){return Number.isFinite(t)||Array.isArray(t)}function t3(t,e,n){return t in t5&&Math.abs(n-e)>180&&(n=n<0?n+360:n-360),n}function t8(t,e){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return t6(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t6(t,void 0)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function t6(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function er(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:{};return tc(this,r),a(t$(t=n.call(this)),"propNames",t9),t.props=Object.assign({},ee,e),t}tl(r,[{key:"initializeProps",value:function(t,e){var n,r={},i={},o=t8(t7);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=t[a],c=e[a];tT(t4(s)&&t4(c),"".concat(a," must be supplied for transition")),r[a]=s,i[a]=t3(a,s,c)}}catch(t){o.e(t)}finally{o.f()}var u,l=t8(et);try{for(l.s();!(u=l.n()).done;){var h=u.value,p=t[h]||0,f=e[h]||0;r[h]=p,i[h]=t3(h,p,f)}}catch(t){l.e(t)}finally{l.f()}return{start:r,end:i}}},{key:"interpolateProps",value:function(t,e,n){var r,i=function(t,e,n,r={}){var i;const o={},{startZoom:a,startCenterXY:s,uDelta:c,w0:u,u1:l,S:h,rho:p,rho2:f,r0:d}=Z(t,e,r);if(l<.01){for(const r of F){const i=t[r],a=e[r];o[r]=n*a+(1-n)*i}return o}const v=n*h,g=Math.cosh(d)/Math.cosh(d+p*v),m=(Math.cosh(d)*Math.tanh(d+p*v)-Math.sinh(d))/f*u/l,y=a+b(1/g),w=((i=[])[0]=c[0]*m,i[1]=c[1]*m,i);_(w,w,s);const O=C(w);return o.longitude=O[0],o.latitude=O[1],o.zoom=y,o}(t,e,n,this.props),o=t8(et);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tS(t[a],e[a],n)}}catch(t){o.e(t)}finally{o.f()}return i}},{key:"getDuration",value:function(t,e){var n=e.transitionDuration;return"auto"===n&&(n=function(t,e,n={}){let r;const{screenSpeed:i,speed:o,maxDuration:a}=n=Object.assign({},V,n),{S:s,rho:c}=Z(t,e,n),u=1e3*s;return r=Number.isFinite(i)?u/(i/c):u/o,Number.isFinite(a)&&r>a?0:r}(t,e,this.props)),n}}])}(tG);var ei=["longitude","latitude","zoom","bearing","pitch"],eo=function(t){tQ(r,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t2(r);return t=e?Reflect.construct(n,arguments,t2(this).constructor):n.apply(this,arguments),t1(this,t)});function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return tc(this,r),t=n.call(this),Array.isArray(e)&&(e={transitionProps:e}),t.propNames=e.transitionProps||ei,e.around&&(t.around=e.around),t}return tl(r,[{key:"initializeProps",value:function(t,e){var n={},r={};if(this.around){n.around=this.around;var i=new z(t).unproject(this.around);Object.assign(r,e,{around:new z(e).project(i),aroundLngLat:i})}var o,a=en(this.propNames);try{for(a.s();!(o=a.n()).done;){var s=o.value,c=t[s],u=e[s];tT(t4(c)&&t4(u),"".concat(s," must be supplied for transition")),n[s]=c,r[s]=t3(s,c,u)}}catch(t){a.e(t)}finally{a.f()}return{start:n,end:r}}},{key:"interpolateProps",value:function(t,e,n){var r,i={},o=en(this.propNames);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tS(t[a],e[a],n)}}catch(t){o.e(t)}finally{o.f()}if(e.around){var s=f(new z(Object.assign({},e,i)).getMapCenterByLngLatPosition({lngLat:e.aroundLngLat,pos:tS(t.around,e.around,n)}),2),c=s[0],u=s[1];i.longitude=c,i.latitude=u}return i}}]),r}(tG),ea=function(){},es={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},ec={transitionDuration:0,transitionEasing:function(t){return t},transitionInterpolator:new eo,transitionInterruption:es.BREAK,onTransitionStart:ea,onTransitionInterrupt:ea,onTransitionEnd:ea},eu=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tc(this,t),a(this,"_animationFrame",null),a(this,"_onTransitionFrame",function(){e._animationFrame=requestAnimationFrame(e._onTransitionFrame),e._updateViewport()}),this.props=null,this.onViewportChange=n.onViewportChange||ea,this.onStateChange=n.onStateChange||ea,this.time=n.getTime||Date.now}return tl(t,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(t){var e=this.props;if(this.props=t,!e||this._shouldIgnoreViewportChange(e,t))return!1;if(this._isTransitionEnabled(t)){var n=Object.assign({},e),r=Object.assign({},t);if(this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this.state.interruption===es.SNAP_TO_END?Object.assign(n,this.state.endProps):Object.assign(n,this.state.propsInTransition),this.state.interruption===es.UPDATE)){var i,o,a=this.time(),s=(a-this.state.startTime)/this.state.duration;r.transitionDuration=this.state.duration-(a-this.state.startTime),r.transitionEasing=(o=(i=this.state.easing)(s),function(t){return 1/(1-o)*(i(t*(1-s)+s)-o)}),r.transitionInterpolator=n.transitionInterpolator}return r.onTransitionStart(),this._triggerTransition(n,r),!0}return this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return!!this._animationFrame}},{key:"_isTransitionEnabled",value:function(t){var e=t.transitionDuration,n=t.transitionInterpolator;return(e>0||"auto"===e)&&!!n}},{key:"_isUpdateDueToCurrentTransition",value:function(t){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(t,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(t,e){return!t||(this._isTransitionInProgress()?this.state.interruption===es.IGNORE||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e))}},{key:"_triggerTransition",value:function(t,e){tT(this._isTransitionEnabled(e)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var n=e.transitionInterpolator,r=n.getDuration?n.getDuration(t,e):e.transitionDuration;if(0!==r){var i=e.transitionInterpolator.initializeProps(t,e),o={inTransition:!0,isZooming:t.zoom!==e.zoom,isPanning:t.longitude!==e.longitude||t.latitude!==e.latitude,isRotating:t.bearing!==e.bearing||t.pitch!==e.pitch};this.state={duration:r,easing:e.transitionEasing,interpolator:e.transitionInterpolator,interruption:e.transitionInterruption,startTime:this.time(),startProps:i.start,endProps:i.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(o)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var t=this.time(),e=this.state,n=e.startTime,r=e.duration,i=e.easing,o=e.interpolator,a=e.startProps,s=e.endProps,c=!1,u=(t-n)/r;u>=1&&(u=1,c=!0),u=i(u);var l=o.interpolateProps(a,s,u),h=new tR(Object.assign({},this.props,l));this.state.propsInTransition=h.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),t}();a(eu,"defaultProps",ec);var el=n(840),eh=n.n(el);const ep={mousedown:1,mousemove:2,mouseup:4};!function(t){const e=t.prototype.handler;t.prototype.handler=function(t){const n=this.store;t.button>0&&"pointerdown"===t.type&&!function(t,e){for(let n=0;ne.pointerId===t.pointerId)&&n.push(t),e.call(this,t)}}(eh().PointerEventInput),eh().MouseInput.prototype.handler=function(t){let e=ep[t.type];1&e&&t.button>=0&&(this.pressed=!0),2&e&&0===t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))};const ef=eh().Manager;var ed=eh();const ev=ed?[[ed.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[ed.Rotate,{enable:!1}],[ed.Pinch,{enable:!1}],[ed.Swipe,{enable:!1}],[ed.Pan,{threshold:0,enable:!1}],[ed.Press,{enable:!1}],[ed.Tap,{event:"doubletap",taps:2,enable:!1}],[ed.Tap,{event:"anytap",enable:!1}],[ed.Tap,{enable:!1}]]:null,eg={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},em={doubletap:["tap"]},eb={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ey={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ew={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},eO={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},eE="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",e_="undefined"!=typeof window?window:n.g;void 0!==n.g?n.g:window;let eP=!1;try{const t={get passive(){return eP=!0,!0}};e_.addEventListener("test",t,t),e_.removeEventListener("test",t,t)}catch(t){}const eM=-1!==eE.indexOf("firefox"),{WHEEL_EVENTS:ej}=ey,eS="wheel";class eT{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.events=ej.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent,!!eP&&{passive:!1}))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eS&&(this.options.enable=e)}handleEvent(t){if(!this.options.enable)return;let e=t.deltaY;e_.WheelEvent&&(eM&&t.deltaMode===e_.WheelEvent.DOM_DELTA_PIXEL&&(e/=e_.devicePixelRatio),t.deltaMode===e_.WheelEvent.DOM_DELTA_LINE&&(e*=40));const n={x:t.clientX,y:t.clientY};0!==e&&e%4.000244140625==0&&(e=Math.floor(e/4.000244140625)),t.shiftKey&&e&&(e*=.25),this._onWheel(t,-e,n)}_onWheel(t,e,n){this.callback({type:eS,center:n,delta:e,srcEvent:t,pointerType:"mouse",target:t.target})}}const{MOUSE_EVENTS:ek}=ey,ex="pointermove",eD="pointerover",eC="pointerout",eR="pointerleave";class eA{constructor(t,e,n={}){this.element=t,this.callback=e,this.pressed=!1,this.options=Object.assign({enable:!0},n),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=ek.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===ex&&(this.enableMoveEvent=e),t===eD&&(this.enableOverEvent=e),t===eC&&(this.enableOutEvent=e),t===eR&&(this.enableLeaveEvent=e)}handleEvent(t){this.handleOverEvent(t),this.handleOutEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this.callback({type:eD,srcEvent:t,pointerType:"mouse",target:t.target})}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this.callback({type:eC,srcEvent:t,pointerType:"mouse",target:t.target})}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this.callback({type:eR,srcEvent:t,pointerType:"mouse",target:t.target})}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.which&&(this.pressed=!1),this.pressed||this.callback({type:ex,srcEvent:t,pointerType:"mouse",target:t.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:eI}=ey,eL="keydown",eN="keyup";class ez{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=eI.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),t.tabIndex=n.tabIndex||0,t.style.outline="none",this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eL&&(this.enableDownEvent=e),t===eN&&(this.enableUpEvent=e)}handleEvent(t){const e=t.target||t.srcElement;("INPUT"!==e.tagName||"text"!==e.type)&&"TEXTAREA"!==e.tagName&&(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:eL,srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:eN,srcEvent:t,key:t.key,target:t.target}))}}const eF="contextmenu";class eV{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.handleEvent=this.handleEvent.bind(this),t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){t===eF&&(this.options.enable=e)}handleEvent(t){this.options.enable&&this.callback({type:eF,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const eZ={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},eB={srcElement:"root",priority:0};class eU{constructor(t){this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(t,e,n,r=!1,i=!1){const{handlers:o,handlersByElement:a}=this;n&&("object"!=typeof n||n.addEventListener)&&(n={srcElement:n}),n=n?Object.assign({},eB,n):eB;let s=a.get(n.srcElement);s||(s=[],a.set(n.srcElement,s));const c={type:t,handler:e,srcElement:n.srcElement,priority:n.priority};r&&(c.once=!0),i&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=s.length-1;for(;u>=0&&!(s[u].priority>=c.priority);)u--;s.splice(u+1,0,c)}remove(t,e){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===t&&o.handler===e){n.splice(i,1);const t=r.get(o.srcElement);t.splice(t.indexOf(o),1),0===t.length&&r.delete(o.srcElement)}}this._active=n.some(t=>!t.passive)}handleEvent(t){if(this.isEmpty())return;const e=this._normalizeEvent(t);let n=t.srcEvent.target;for(;n&&n!==e.rootElement;){if(this._emit(e,n),e.handled)return;n=n.parentNode}this._emit(e,"root")}_emit(t,e){const n=this.handlersByElement.get(e);if(n){let e=!1;const r=()=>{t.handled=!0},i=()=>{t.handled=!0,e=!0},o=[];for(let a=0;a{const e=this.manager.get(t);e&&eg[t].forEach(t=>{e.recognizeWith(t)})}),e.recognizerOptions){const t=this.manager.get(r);if(t){const n=e.recognizerOptions[r];delete n.enable,t.set(n)}}for(const[n,r]of(this.wheelInput=new eT(t,this._onOtherEvent,{enable:!1}),this.moveInput=new eA(t,this._onOtherEvent,{enable:!1}),this.keyInput=new ez(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new eV(t,this._onOtherEvent,{enable:!1}),this.events))r.isEmpty()||(this._toggleRecognizer(r.recognizerName,!0),this.manager.on(n,r.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(t,e,n){this._addEventHandler(t,e,n,!1)}once(t,e,n){this._addEventHandler(t,e,n,!0)}watch(t,e,n){this._addEventHandler(t,e,n,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:n}=this;if(!n)return;const r=n.get(t);if(r&&r.options.enable!==e){r.set({enable:e});const i=em[t];i&&!this.options.recognizers&&i.forEach(i=>{const o=n.get(i);e?(o.requireFailure(t),r.dropRequireFailure(i)):o.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,n,r,i){if("string"!=typeof t){for(const o in n=e,t)this._addEventHandler(o,t[o],n,r,i);return}const{manager:o,events:a}=this,s=eO[t]||t;let c=a.get(s);!c&&(c=new eU(this),a.set(s,c),c.recognizerName=ew[s]||s,o&&o.on(s,c.handleEvent)),c.add(t,e,n,r,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const e in t)this._removeEventHandler(e,t[e]);return}const{events:n}=this,r=eO[t]||t,i=n.get(r);if(i&&(i.remove(t,e),i.isEmpty())){const{recognizerName:t}=i;let e=!1;for(const r of n.values())if(r.recognizerName===t&&!r.isEmpty()){e=!0;break}e||this._toggleRecognizer(t,!1)}}_onBasicInput(t){const{srcEvent:e}=t,n=eb[e.type];n&&this.manager.emit(n,t)}_onOtherEvent(t){this.manager.emit(t.type,t)}}function eH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function eX(t){for(var e=1;e0),a=o&&!this.state.isHovering,s=!o&&this.state.isHovering;(r||a)&&(t.features=e,r&&r(t)),a&&nt.call(this,"onMouseEnter",t),s&&nt.call(this,"onMouseLeave",t),(a||s)&&this.setState({isHovering:o})}}function ni(t){var e=this.props,n=e.onClick,r=e.onNativeClick,i=e.onDblClick,o=e.doubleClickZoom,a=[],s=i||o;switch(t.type){case"anyclick":a.push(r),s||a.push(n);break;case"click":s&&a.push(n)}(a=a.filter(Boolean)).length&&((t=e9.call(this,t)).features=e7.call(this,t.point),a.forEach(function(e){return e(t)}))}var no=(0,h.forwardRef)(function(t,e){var n,a,s=(0,h.useContext)(tL),c=(0,h.useMemo)(function(){return t.controller||new e5},[]),u=(0,h.useMemo)(function(){return new eW(null,{touchAction:t.touchAction,recognizerOptions:t.eventRecognizerOptions})},[]),l=(0,h.useRef)(null),p=(0,h.useRef)(null),f=(0,h.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;f.props=t,f.map=p.current&&p.current.getMap(),f.setState=function(e){f.state=e3(e3({},f.state),e),l.current.style.cursor=t.getCursor(f.state)};var d=!0,v=function(t,e,r){if(d){n=[t,e,r];return}var i=f.props,o=i.onViewStateChange,a=i.onViewportChange;Object.defineProperty(t,"position",{get:function(){return[0,0,tF(f.map,t)]}}),o&&o({viewState:t,interactionState:e,oldViewState:r}),a&&a(t,e,r)};(0,h.useImperativeHandle)(e,function(){return{getMap:p.current&&p.current.getMap,queryRenderedFeatures:p.current&&p.current.queryRenderedFeatures}},[]);var g=(0,h.useMemo)(function(){return e3(e3({},s),{},{eventManager:u,container:s.container||l.current})},[s,l.current]);g.onViewportChange=v,g.viewport=s.viewport||tU(f),f.viewport=g.viewport;var m=function(t){var e=t.isDragging,n=void 0!==e&&e;if(n!==f.state.isDragging&&f.setState({isDragging:n}),d){a=t;return}var r=f.props.onInteractionStateChange;r&&r(t)},b=function(){f.width&&f.height&&c.setOptions(e3(e3(e3({},f.props),f.props.viewState),{},{isInteractive:!!(f.props.onViewStateChange||f.props.onViewportChange),onViewportChange:v,onStateChange:m,eventManager:u,width:f.width,height:f.height}))};(0,h.useEffect)(function(){return u.setElement(l.current),u.on({pointerdown:ne.bind(f),pointermove:nr.bind(f),pointerup:nn.bind(f),pointerleave:nt.bind(f,"onMouseOut"),click:ni.bind(f),anyclick:ni.bind(f),dblclick:nt.bind(f,"onDblClick"),wheel:nt.bind(f,"onWheel"),contextmenu:nt.bind(f,"onContextMenu")}),function(){u.destroy()}},[]),tz(function(){if(n){var t;v.apply(void 0,function(t){if(Array.isArray(t))return i(t)}(t=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}a&&m(a)}),b();var y=t.width,w=t.height,O=t.style,E=t.getCursor,_=(0,h.useMemo)(function(){return e3(e3({position:"relative"},O),{},{width:y,height:w,cursor:E(f.state)})},[O,y,w,E,f.state]);return n&&f._child||(f._child=h.createElement(tN,{value:g},h.createElement("div",{key:"event-canvas",ref:l,style:_},h.createElement(tY,r({},t,{width:"100%",height:"100%",style:null,onResize:function(t){var e=t.width,n=t.height;f.width=e,f.height=n,b(),f.props.onResize({width:e,height:n})},ref:p}))))),d=!1,f._child});no.supported=tY.supported,no.propTypes=e8,no.defaultProps=e6;var na=no;p.string.isRequired,p.string,p.oneOf(["fill","line","symbol","circle","fill-extrusion","raster","background","heatmap","hillshade","sky"]).isRequired,p.string,p.string,p.string;var ns={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},nc={captureScroll:p.bool,captureDrag:p.bool,captureClick:p.bool,captureDoubleClick:p.bool,capturePointerMove:p.bool};function nu(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(0,h.useContext)(tL),n=(0,h.useRef)(null),r=(0,h.useRef)({props:t,state:{},context:e,containerRef:n}).current;return r.props=t,r.context=e,(0,h.useEffect)(function(){return function(t){var e=t.containerRef.current,n=t.context.eventManager;if(e&&n){var r={wheel:function(e){var n=t.props;n.captureScroll&&e.stopPropagation(),n.onScroll&&n.onScroll(e,t)},panstart:function(e){var n=t.props;n.captureDrag&&e.stopPropagation(),n.onDragStart&&n.onDragStart(e,t)},anyclick:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onNativeClick&&n.onNativeClick(e,t)},click:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onClick&&n.onClick(e,t)},dblclick:function(e){var n=t.props;n.captureDoubleClick&&e.stopPropagation(),n.onDoubleClick&&n.onDoubleClick(e,t)},pointermove:function(e){var n=t.props;n.capturePointerMove&&e.stopPropagation(),n.onPointerMove&&n.onPointerMove(e,t)}};return n.watch(r,e),function(){n.off(r)}}}(r)},[e.eventManager]),r}function nl(t){var e=t.instance,n=nu(t),r=n.context,i=n.containerRef;return e._context=r,e._containerRef=i,e._render()}var nh=function(t){tQ(i,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t2(i);return t=e?Reflect.construct(n,arguments,t2(this).constructor):n.apply(this,arguments),t1(this,t)});function i(){var t;tc(this,i);for(var e=arguments.length,r=Array(e),o=0;o2&&void 0!==arguments[2]?arguments[2]:"x";if(null===t)return e;var r="x"===n?t.offsetWidth:t.offsetHeight;return nw(e/100*r)/r*100};function nE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}var n_=Object.assign({},nd,{className:p.string,longitude:p.number.isRequired,latitude:p.number.isRequired,style:p.object}),nP=Object.assign({},nv,{className:""});function nM(t){var e,n,r,i,o,s,c,u=(n=(e=f((0,h.useState)(null),2))[0],r=e[1],o=(i=f((0,h.useState)(null),2))[0],s=i[1],(c=nu(nf(nf({},t),{},{onDragStart:nb}))).callbacks=t,c.state.dragPos=n,c.state.setDragPos=r,c.state.dragOffset=o,c.state.setDragOffset=s,(0,h.useEffect)(function(){return function(t){var e=t.context.eventManager;if(e&&t.state.dragPos){var n={panmove:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=ng(t);i.setDragPos(a);var s=i.dragOffset;if(r.onDrag&&s){var c=Object.assign({},t);c.lngLat=nm(a,s,n,o),r.onDrag(c)}}(e,t)},panend:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=i.dragPos,s=i.dragOffset;if(i.setDragPos(null),i.setDragOffset(null),r.onDragEnd&&a&&s){var c=Object.assign({},t);c.lngLat=nm(a,s,n,o),r.onDragEnd(c)}}(e,t)},pancancel:function(e){var n;return n=t.state,void(e.stopPropagation(),n.setDragPos(null),n.setDragOffset(null))}};return e.watch(n),function(){e.off(n)}}}(c)},[c.context.eventManager,!!n]),c),l=u.state,p=u.containerRef,d=t.children,v=t.className,g=t.draggable,m=t.style,b=l.dragPos,y=function(t){var e=t.props,n=t.state,r=t.context,i=e.longitude,o=e.latitude,a=e.offsetLeft,s=e.offsetTop,c=n.dragPos,u=n.dragOffset,l=r.viewport,h=r.map;if(c&&u)return[c[0]+u[0],c[1]+u[1]];var p=tF(h,{longitude:i,latitude:o}),d=f(l.project([i,o,p]),2),v=d[0],g=d[1];return[v+=a,g+=s]}(u),w=f(y,2),O=w[0],E=w[1],_="translate(".concat(nw(O),"px, ").concat(nw(E),"px)"),P=g?b?"grabbing":"grab":"auto",M=(0,h.useMemo)(function(){var t=function(t){for(var e=1;e0){var g=p,m=v;for(p=0;p<=1;p+=.5)d=(f=n-p*a)+a,(v=Math.max(0,u-f)+Math.max(0,d-i+u))0){var E=h,_=O;for(h=0;h<=1;h+=b)w=(y=e-h*o)+o,(O=Math.max(0,u-y)+Math.max(0,w-r+u))<_&&(_=O,E=h);h=E}return nS.find(function(t){var e=nj[t];return e.x===h&&e.y===p})||s}({x:r,y:i,anchor:o,padding:s,width:S.width,height:S.height,selfWidth:e.clientWidth,selfHeight:e.clientHeight}):o),z=(c=M.current,l=(u=f(L,3))[0],p=u[1],d=u[2],v=t.offsetLeft,g=t.offsetTop,m=t.sortByDepth,y=nO(c,-(100*(b=nj[N]).x)),w=nO(c,-(100*b.y),"y"),O={position:"absolute",transform:"\n translate(".concat(y,"%, ").concat(w,"%)\n translate(").concat(nw(l+v),"px, ").concat(nw(p+g),"px)\n "),display:void 0,zIndex:void 0},m&&(d>1||d<-1||l<0||l>S.width||p<0||p>S.height?O.display="none":O.zIndex=Math.floor((1-d)/2*1e5)),O),F=(0,h.useCallback)(function(t){_.props.onClose();var e=_.context.eventManager;e&&e.once("click",function(t){return t.stopPropagation()},t.target)},[]);return h.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(N," ").concat(k),style:z,ref:M},h.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:C}}),h.createElement("div",{key:"content",ref:E,className:"mapboxgl-popup-content"},R&&h.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:F},"×"),A))}function nD(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nx.propTypes=nT,nx.defaultProps=nk,h.memo(nx);var nC=Object.assign({},nc,{toggleLabel:p.string,className:p.string,style:p.object,compact:p.bool,customAttribution:p.oneOfType([p.string,p.arrayOf(p.string)])}),nR=Object.assign({},ns,{className:"",toggleLabel:"Toggle Attribution"});function nA(t){var e=nu(t),n=e.context,r=e.containerRef,i=(0,h.useRef)(null),o=f((0,h.useState)(!1),2),s=o[0],c=o[1];(0,h.useEffect)(function(){var e,o,a,s,c,u;return n.map&&(o={customAttribution:t.customAttribution},a=n.map,s=r.current,c=i.current,(u=new(tP()).AttributionControl(o))._map=a,u._container=s,u._innerContainer=c,u._updateAttributions(),u._updateEditLink(),a.on("styledata",u._updateData),a.on("sourcedata",u._updateData),e=u),function(){var t;return e&&void((t=e)._map.off("styledata",t._updateData),t._map.off("sourcedata",t._updateData))}},[n.map]);var u=void 0===t.compact?n.viewport.width<=640:t.compact;(0,h.useEffect)(function(){!u&&s&&c(!1)},[u]);var l=(0,h.useCallback)(function(){return c(function(t){return!t})},[]),p=(0,h.useMemo)(function(){return function(t){for(var e=1;ea)return 1}return 0}(o.map.version,"1.6.0")>=0?2:1:2},[o.map]),n=o.viewport.bearing,r={transform:"rotate(".concat(-n,"deg)")},2===e?h.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:r}):h.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:r})))))}function n$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nG.propTypes=nH,nG.defaultProps=nX,h.memo(nG);var nJ=Object.assign({},nc,{className:p.string,style:p.object,maxWidth:p.number,unit:p.oneOf(["imperial","metric","nautical"])}),nQ=Object.assign({},ns,{className:"",maxWidth:100,unit:"metric"});function n0(t){var e=nu(t),n=e.context,r=e.containerRef,i=f((0,h.useState)(null),2),o=i[0],s=i[1];(0,h.useEffect)(function(){if(n.map){var t=new(tP()).ScaleControl;t._map=n.map,t._container=r.current,s(t)}},[n.map]),o&&(o.options=t,o._onMove());var c=(0,h.useMemo)(function(){return function(t){for(var e=1;e\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=i.console&&(i.console.warn||i.console.log);return o&&o.call(i.console,r,n),t.apply(this,arguments)}}c="function"!=typeof Object.assign?function(t){if(null==t)throw TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n-1}function S(t){return t.trim().split(/\s+/g)}function T(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var r=0;rT(i,a)&&r.push(t[o]),i[o]=a,o++}return n&&(r=e?r.sort(function(t,n){return t[e]>n[e]}):r.sort()),r}function D(t,e){for(var n,r,i=e[0].toUpperCase()+e.slice(1),o=0;o1&&!r.firstMultiple?r.firstMultiple=U(n):1===o&&(r.firstMultiple=!1),a=r.firstInput,u=(c=r.firstMultiple)?c.center:a.center,l=n.center=q(i),n.timeStamp=f(),n.deltaTime=n.timeStamp-a.timeStamp,n.angle=Y(u,l),n.distance=X(u,l),h=n.center,d=r.offsetDelta||{},v=r.prevDelta||{},g=r.prevInput||{},(1===n.eventType||4===g.eventType)&&(v=r.prevDelta={x:g.deltaX||0,y:g.deltaY||0},d=r.offsetDelta={x:h.x,y:h.y}),n.deltaX=v.x+(h.x-d.x),n.deltaY=v.y+(h.y-d.y),n.offsetDirection=H(n.deltaX,n.deltaY),m=W(n.deltaTime,n.deltaX,n.deltaY),n.overallVelocityX=m.x,n.overallVelocityY=m.y,n.overallVelocity=p(m.x)>p(m.y)?m.x:m.y,n.scale=c?(b=c.pointers,X(i[0],i[1],V)/X(b[0],b[1],V)):1,n.rotation=c?(y=c.pointers,Y(i[1],i[0],V)+Y(y[1],y[0],V)):0,n.maxPointers=r.prevInput?n.pointers.length>r.prevInput.maxPointers?n.pointers.length:r.prevInput.maxPointers:n.pointers.length,function(t,e){var n,r,i,o,a=t.lastInterval||e,c=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(c>25||s===a.velocity)){var u=e.deltaX-a.deltaX,l=e.deltaY-a.deltaY,h=W(c,u,l);r=h.x,i=h.y,n=p(h.x)>p(h.y)?h.x:h.y,o=H(u,l),t.lastInterval=e}else n=a.velocity,r=a.velocityX,i=a.velocityY,o=a.direction;e.velocity=n,e.velocityX=r,e.velocityY=i,e.direction=o}(r,n),w=t.element,M(n.srcEvent.target,w)&&(w=n.srcEvent.target),n.target=w,t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function U(t){for(var e=[],n=0;n=p(e)?t<0?2:4:e<0?8:16}function X(t,e,n){n||(n=F);var r=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(r*r+i*i)}function Y(t,e,n){n||(n=F);var r=e[n[0]]-t[n[0]];return 180*Math.atan2(e[n[1]]-t[n[1]],r)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&_(this.element,this.evEl,this.domHandler),this.evTarget&&_(this.target,this.evTarget,this.domHandler),this.evWin&&_(R(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(R(this.element),this.evWin,this.domHandler)}};var K={mousedown:1,mousemove:2,mouseup:4};function G(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,Z.apply(this,arguments)}w(G,Z,{handler:function(t){var e=K[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:z,srcEvent:t}))}});var $={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:N,3:"pen",4:z,5:"kinect"},Q="pointerdown",tt="pointermove pointerup pointercancel";function te(){this.evEl=Q,this.evWin=tt,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}i.MSPointerEvent&&!i.PointerEvent&&(Q="MSPointerDown",tt="MSPointerMove MSPointerUp MSPointerCancel"),w(te,Z,{handler:function(t){var e=this.store,n=!1,r=$[t.type.toLowerCase().replace("ms","")],i=J[t.pointerType]||t.pointerType,o=i==N,a=T(e,t.pointerId,"pointerId");1&r&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):12&r&&(n=!0),!(a<0)&&(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:i,srcEvent:t}),n&&e.splice(a,1))}});var tn={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function tr(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}function ti(t,e){var n=k(t.touches),r=k(t.changedTouches);return 12&e&&(n=x(n.concat(r),"identifier",!0)),[n,r]}w(tr,Z,{handler:function(t){var e=tn[t.type];if(1===e&&(this.started=!0),this.started){var n=ti.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:N,srcEvent:t})}}});var to={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ta(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},Z.apply(this,arguments)}function ts(t,e){var n=k(t.touches),r=this.targetIds;if(3&e&&1===n.length)return r[n[0].identifier]=!0,[n,n];var i,o,a=k(t.changedTouches),s=[],c=this.target;if(o=n.filter(function(t){return M(t.target,c)}),1===e)for(i=0;i-1&&r.splice(t,1)},2500)}}function th(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,r=0;r-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function r(n){e.manager.emit(n,t)}n<8&&r(e.options.event+t_(n)),r(e.options.event),t.additionalEvent&&r(t.additionalEvent),n>=8&&r(e.options.event+t_(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;te.threshold&&i&e.direction},attrTest:function(t){return tj.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=tP(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),w(tT,tj,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[tm]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),w(tk,tE,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[tv]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distancee.time;if(this._input=t,r&&n&&(!(12&t.eventType)||i)){if(1&t.eventType)this.reset(),this._timer=d(function(){this.state=8,this.tryEmit()},e.time,this);else if(4&t.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=f(),this.manager.emit(this.options.event,this._input)))}}),w(tx,tj,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[tm]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),w(tD,tj,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return tS.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:24&n&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&p(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=tP(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),w(tC,tE,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[tg]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distance1)for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n=-90&&e<=90,"invalid latitude");const n=512*(j+Math.log(Math.tan(S+e*T*.5)))/(2*j);return[512*(t*T+j)/(2*j),n]}function C([t,e]){const n=2*(Math.atan(Math.exp(e/512*(2*j)-j))-S);return[(t/512*(2*j)-j)*k,n*k]}function R(t){return 2*Math.atan(.5/t)*k}function A(t){return .5/Math.tan(.5*t*T)}function I(t,e,n=0){const[r,i,o]=t;if(M(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o))return g(e,[r,i,o,1]);const a=g(e,[r,i,0,1]),s=g(e,[r,i,1,1]),c=a[2],u=s[2];return P([],a,s,c===u?0:((n||0)-c)/(u-c))}const L=Math.PI/180;function N(t,e,n){const{pixelUnprojectionMatrix:r}=t,i=g(r,[e,0,1,1]),o=g(r,[e,t.height,1,1]),a=(n*t.distanceScales.unitsPerMeter[2]-i[2])/(o[2]-i[2]),s=C(P([],i,o,a));return s[2]=n,s}class z{constructor({width:t,height:e,latitude:n=0,longitude:r=0,zoom:i=0,pitch:o=0,bearing:a=0,altitude:s=null,fovy:c=null,position:u=null,nearZMultiplier:l=.02,farZMultiplier:h=1.01}={width:1,height:1}){t=t||1,e=e||1,null===c&&null===s?c=R(s=1.5):null===c?c=R(s):null===s&&(s=A(c));const p=x(i);s=Math.max(.75,s);const f=function({latitude:t,longitude:e,highPrecision:n=!1}){M(Number.isFinite(t)&&Number.isFinite(e));const r={},i=Math.cos(t*T),o=512/360,a=512/360/i,s=512/4003e4/i;if(r.unitsPerMeter=[s,s,s],r.metersPerUnit=[1/s,1/s,1/s],r.unitsPerDegree=[o,a,s],r.degreesPerUnit=[1/o,1/a,1/s],n){const e=T*Math.tan(t*T)/i,n=512/4003e4*e,c=n/a*s;r.unitsPerDegree2=[0,o*e/2,n],r.unitsPerMeter2=[c,0,c]}return r}({longitude:r,latitude:n}),d=D([r,n]);if(d[2]=0,u){var g,m;g=[],m=f.unitsPerMeter,g[0]=u[0]*m[0],g[1]=u[1]*m[1],g[2]=u[2]*m[2],d[0]=d[0]+g[0],d[1]=d[1]+g[1],d[2]=d[2]+g[2]}this.projectionMatrix=function({width:t,height:e,pitch:n,altitude:r,fovy:i,nearZMultiplier:o,farZMultiplier:a}){var s,c,u;const{fov:l,aspect:h,near:p,far:f}=function({width:t,height:e,fovy:n=R(1.5),altitude:r,pitch:i=0,nearZMultiplier:o=1,farZMultiplier:a=1}){void 0!==r&&(n=R(r));const s=.5*n*T,c=A(n),u=i*T,l=Math.sin(s)*c/Math.sin(Math.min(Math.max(Math.PI/2-u-s,.01),Math.PI-.01)),h=Math.sin(u)*l+c;return{fov:2*s,aspect:t/e,focalDistance:c,near:o,far:h*a}}({width:t,height:e,altitude:r,fovy:i,pitch:n,nearZMultiplier:o,farZMultiplier:a});return s=[],u=1/Math.tan(l/2),s[0]=u/h,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,null!=f&&f!==1/0?(c=1/(p-f),s[10]=(f+p)*c,s[14]=2*f*p*c):(s[10]=-1,s[14]=-2*p),s}({width:t,height:e,pitch:o,fovy:c,nearZMultiplier:l,farZMultiplier:h}),this.viewMatrix=function({height:t,pitch:e,bearing:n,altitude:r,scale:i,center:o=null}){var a,s,c,u,l,h,p,f,d,g,m,b,y,E,_,P,M,j,S,k,x,D,C;const R=v();return w(R,R,[0,0,-r]),s=Math.sin(a=-e*T),c=Math.cos(a),u=R[4],l=R[5],h=R[6],p=R[7],f=R[8],d=R[9],g=R[10],m=R[11],R!=R&&(R[0]=R[0],R[1]=R[1],R[2]=R[2],R[3]=R[3],R[12]=R[12],R[13]=R[13],R[14]=R[14],R[15]=R[15]),R[4]=u*c+f*s,R[5]=l*c+d*s,R[6]=h*c+g*s,R[7]=p*c+m*s,R[8]=f*c-u*s,R[9]=d*c-l*s,R[10]=g*c-h*s,R[11]=m*c-p*s,y=Math.sin(b=n*T),E=Math.cos(b),_=R[0],P=R[1],M=R[2],j=R[3],S=R[4],k=R[5],x=R[6],D=R[7],R!=R&&(R[8]=R[8],R[9]=R[9],R[10]=R[10],R[11]=R[11],R[12]=R[12],R[13]=R[13],R[14]=R[14],R[15]=R[15]),R[0]=_*E+S*y,R[1]=P*E+k*y,R[2]=M*E+x*y,R[3]=j*E+D*y,R[4]=S*E-_*y,R[5]=k*E-P*y,R[6]=x*E-M*y,R[7]=D*E-j*y,O(R,R,[i/=t,i,i]),o&&w(R,R,((C=[])[0]=-o[0],C[1]=-o[1],C[2]=-o[2],C)),R}({height:e,scale:p,center:d,pitch:o,bearing:a,altitude:s}),this.width=t,this.height=e,this.scale=p,this.latitude=n,this.longitude=r,this.zoom=i,this.pitch=o,this.bearing=a,this.altitude=s,this.fovy=c,this.center=d,this.meterOffset=u||[0,0,0],this.distanceScales=f,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var t,e,n,r,i,o,a,s,c,u,l,h,p,f,d,g,m,b,E,_,P,M,j,S,T,k,x,D,C,R;const{width:A,height:I,projectionMatrix:L,viewMatrix:N}=this,z=v();y(z,z,L),y(z,z,N),this.viewProjectionMatrix=z;const F=v();O(F,F,[A/2,-I/2,1]),w(F,F,[1,-1,0]),y(F,F,z);const V=(t=v(),e=F[0],n=F[1],r=F[2],i=F[3],o=F[4],a=F[5],s=F[6],c=F[7],u=F[8],l=F[9],h=F[10],p=F[11],f=F[12],d=F[13],g=F[14],m=F[15],b=e*a-n*o,E=e*s-r*o,_=e*c-i*o,P=n*s-r*a,M=n*c-i*a,j=r*c-i*s,S=u*d-l*f,T=u*g-h*f,k=u*m-p*f,x=l*g-h*d,D=l*m-p*d,(R=b*(C=h*m-p*g)-E*D+_*x+P*k-M*T+j*S)?(R=1/R,t[0]=(a*C-s*D+c*x)*R,t[1]=(r*D-n*C-i*x)*R,t[2]=(d*j-g*M+m*P)*R,t[3]=(h*M-l*j-p*P)*R,t[4]=(s*k-o*C-c*T)*R,t[5]=(e*C-r*k+i*T)*R,t[6]=(g*_-f*j-m*E)*R,t[7]=(u*j-h*_+p*E)*R,t[8]=(o*D-a*k+c*S)*R,t[9]=(n*k-e*D-i*S)*R,t[10]=(f*M-d*_+m*b)*R,t[11]=(l*_-u*M-p*b)*R,t[12]=(a*T-o*x-s*S)*R,t[13]=(e*x-n*T+r*S)*R,t[14]=(d*E-f*P-g*b)*R,t[15]=(u*P-l*E+h*b)*R,t):null);if(!V)throw Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=F,this.pixelUnprojectionMatrix=V}equals(t){return t instanceof z&&t.width===this.width&&t.height===this.height&&E(t.projectionMatrix,this.projectionMatrix)&&E(t.viewMatrix,this.viewMatrix)}project(t,{topLeft:e=!0}={}){const n=function(t,e){const[n,r,i=0]=t;return M(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),g(e,[n,r,i,1])}(this.projectPosition(t),this.pixelProjectionMatrix),[r,i]=n,o=e?i:this.height-i;return 2===t.length?[r,o]:[r,o,n[2]]}unproject(t,{topLeft:e=!0,targetZ:n}={}){const[r,i,o]=t,a=e?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=I([r,a,o],this.pixelUnprojectionMatrix,s),[u,l,h]=this.unprojectPosition(c);return Number.isFinite(o)?[u,l,h]:Number.isFinite(n)?[u,l,n]:[u,l]}projectPosition(t){const[e,n]=D(t);return[e,n,(t[2]||0)*this.distanceScales.unitsPerMeter[2]]}unprojectPosition(t){const[e,n]=C(t);return[e,n,(t[2]||0)*this.distanceScales.metersPerUnit[2]]}projectFlat(t){return D(t)}unprojectFlat(t){return C(t)}getMapCenterByLngLatPosition({lngLat:t,pos:e}){var n;const r=I(e,this.pixelUnprojectionMatrix),i=_([],D(t),((n=[])[0]=-r[0],n[1]=-r[1],n));return C(_([],this.center,i))}getLocationAtPoint({lngLat:t,pos:e}){return this.getMapCenterByLngLatPosition({lngLat:t,pos:e})}fitBounds(t,e={}){const{width:n,height:r}=this,{longitude:i,latitude:o,zoom:a}=function({width:t,height:e,bounds:n,minExtent:r=0,maxZoom:i=24,padding:o=0,offset:a=[0,0]}){const[[s,c],[u,l]]=n;if(Number.isFinite(o)){const t=o;o={top:t,bottom:t,left:t,right:t}}else M(Number.isFinite(o.top)&&Number.isFinite(o.bottom)&&Number.isFinite(o.left)&&Number.isFinite(o.right));const h=D([s,l<-85.051129?-85.051129:l>85.051129?85.051129:l]),p=D([u,c<-85.051129?-85.051129:c>85.051129?85.051129:c]),f=[Math.max(Math.abs(p[0]-h[0]),r),Math.max(Math.abs(p[1]-h[1]),r)],d=[t-o.left-o.right-2*Math.abs(a[0]),e-o.top-o.bottom-2*Math.abs(a[1])];M(d[0]>0&&d[1]>0);const v=d[0]/f[0],g=d[1]/f[1],m=(o.right-o.left)/2/v,y=(o.bottom-o.top)/2/g,w=C([(p[0]+h[0])/2+m,(p[1]+h[1])/2+y]),O=Math.min(i,b(Math.abs(Math.min(v,g))));return M(Number.isFinite(O)),{longitude:w[0],latitude:w[1],zoom:O}}(Object.assign({width:n,height:r,bounds:t},e));return new z({width:n,height:r,longitude:i,latitude:o,zoom:a})}getBounds(t){const e=this.getBoundingRegion(t),n=Math.min(...e.map(t=>t[0])),r=Math.max(...e.map(t=>t[0]));return[[n,Math.min(...e.map(t=>t[1]))],[r,Math.max(...e.map(t=>t[1]))]]}getBoundingRegion(t={}){return function(t,e=0){let n,r;const{width:i,height:o,unproject:a}=t,s={targetZ:e},c=a([0,o],s),u=a([i,o],s);return(t.fovy?.5*t.fovy*L:Math.atan(.5/t.altitude))>(90-t.pitch)*L-.01?(n=N(t,0,e),r=N(t,i,e)):(n=a([0,0],s),r=a([i,0],s)),[c,u,r,n]}(this,t.z||0)}}const F=["longitude","latitude","zoom"],V={curve:1.414,speed:1.2};function Z(t,e,n){var r,i;const o=(n=Object.assign({},V,n)).curve,a=t.zoom,s=[t.longitude,t.latitude],c=x(a),u=e.zoom,l=[e.longitude,e.latitude],h=x(u-a),p=D(s),f=(r=[],i=D(l),r[0]=i[0]-p[0],r[1]=i[1]-p[1],r),d=Math.max(t.width,t.height),v=d/h,g=Math.hypot(f[0],f[1])*c,m=Math.max(g,.01),b=o*o,y=(v*v-d*d+b*b*m*m)/(2*d*b*m),w=(v*v-d*d-b*b*m*m)/(2*v*b*m),O=Math.log(Math.sqrt(y*y+1)-y),E=Math.log(Math.sqrt(w*w+1)-w);return{startZoom:a,startCenterXY:p,uDelta:f,w0:d,u1:g,S:(E-O)/o,rho:o,rho2:b,r0:O,r1:E}}var B=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,r){return t[0]===e&&(n=r,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n0},t.prototype.connect_=function(){U&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),X?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){U&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;H.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),K=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),to="undefined"!=typeof WeakMap?new WeakMap:new B,ta=function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function.");if(!arguments.length)throw TypeError("1 argument required, but only 0 present.");var n=new ti(e,Y.getInstance(),this);to.set(this,n)};["observe","unobserve","disconnect"].forEach(function(t){ta.prototype[t]=function(){var e;return(e=to.get(this))[t].apply(e,arguments)}});var ts=void 0!==q.ResizeObserver?q.ResizeObserver:ta;function tc(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function tu(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function tv(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]?arguments[1]:"component";t.debug&&p.checkPropTypes(ty,t,"prop",e)}var tE=function(){function t(e){var n=this;if(tc(this,t),a(this,"props",tw),a(this,"width",0),a(this,"height",0),a(this,"_fireLoadEvent",function(){n.props.onLoad({type:"load",target:n._map})}),a(this,"_handleError",function(t){n.props.onError(t)}),!e.mapboxgl)throw Error("Mapbox not available");this.mapboxgl=e.mapboxgl,t.initialized||(t.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(e)}return tl(t,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(t){return this._update(this.props,t),this}},{key:"redraw",value:function(){var t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(e){this._map=t.savedMap;var n=this._map.getContainer(),r=e.container;for(r.classList.add("mapboxgl-map");n.childNodes.length>0;)r.appendChild(n.childNodes[0]);this._map._container=r,t.savedMap=null,e.mapStyle&&this._map.setStyle(tm(e.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(e){if(e.reuseMaps&&t.savedMap)this._reuse(e);else{if(e.gl){var n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=n,e.gl}}var r={container:e.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:tm(e.mapStyle),interactive:!1,trackResize:!1,attributionControl:e.attributionControl,preserveDrawingBuffer:e.preserveDrawingBuffer};e.transformRequest&&(r.transformRequest=e.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},r,e.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!t.savedMap?(t.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(t){var e=this;tO(t=Object.assign({},tw,t),"Mapbox"),this.mapboxgl.accessToken=t.mapboxApiAccessToken||tw.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=t.mapboxApiUrl,this._create(t);var n=t.container;Object.defineProperty(n,"offsetWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"clientWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"offsetHeight",{configurable:!0,get:function(){return e.height}}),Object.defineProperty(n,"clientHeight",{configurable:!0,get:function(){return e.height}});var r=this._map.getCanvas();r&&(r.style.outline="none"),this._updateMapViewport({},t),this._updateMapSize({},t),this.props=t}},{key:"_update",value:function(t,e){if(this._map){tO(e=Object.assign({},this.props,e),"Mapbox");var n=this._updateMapViewport(t,e),r=this._updateMapSize(t,e);this._updateMapStyle(t,e),!e.asyncRender&&(n||r)&&this.redraw(),this.props=e}}},{key:"_updateMapStyle",value:function(t,e){t.mapStyle!==e.mapStyle&&this._map.setStyle(tm(e.mapStyle),{diff:!e.preventStyleDiffing})}},{key:"_updateMapSize",value:function(t,e){var n=t.width!==e.width||t.height!==e.height;return n&&(this.width=e.width,this.height=e.height,this._map.resize()),n}},{key:"_updateMapViewport",value:function(t,e){var n=this._getViewState(t),r=this._getViewState(e),i=r.latitude!==n.latitude||r.longitude!==n.longitude||r.zoom!==n.zoom||r.pitch!==n.pitch||r.bearing!==n.bearing||r.altitude!==n.altitude;return i&&(this._map.jumpTo(this._viewStateToMapboxProps(r)),r.altitude!==n.altitude&&(this._map.transform.altitude=r.altitude)),i}},{key:"_getViewState",value:function(t){var e=t.viewState||t,n=e.longitude,r=e.latitude,i=e.zoom,o=e.pitch,a=e.bearing,s=e.altitude;return{longitude:n,latitude:r,zoom:i,pitch:void 0===o?0:o,bearing:void 0===a?0:a,altitude:void 0===s?1.5:s}}},{key:"_checkStyleSheet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==th)try{var e=th.createElement("div");if(e.className="mapboxgl-map",e.style.display="none",th.body.appendChild(e),!("static"!==window.getComputedStyle(e).position)){var n=th.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(t,"/mapbox-gl.css")),th.head.appendChild(n)}}catch(t){}}},{key:"_viewStateToMapboxProps",value:function(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}}}]),t}();a(tE,"initialized",!1),a(tE,"propTypes",ty),a(tE,"defaultProps",tw),a(tE,"savedMap",null);var t_=n(6158),tP=n.n(t_);function tM(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function tj(t,e,n){return Math.max(e,Math.min(n,t))}function tS(t,e,n){return tM(t)?t.map(function(t,r){return tS(t,e[r],n)}):n*e+(1-n)*t}function tT(t,e){if(!t)throw Error(e||"react-map-gl: assertion failed.")}function tk(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tx(t){for(var e=1;e0,"`scale` must be a positive number");var i=this._state,o=i.startZoom,a=i.startZoomLngLat;Number.isFinite(o)||(o=this._viewportProps.zoom,a=this._unproject(n)||this._unproject(e)),tT(a,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var s=this._calculateNewZoom({scale:r,startZoom:o||0}),c=f(new z(Object.assign({},this._viewportProps,{zoom:s})).getMapCenterByLngLatPosition({lngLat:a,pos:e}),2),u=c[0],l=c[1];return this._getUpdatedMapState({zoom:s,longitude:u,latitude:l})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(e){return new t(Object.assign({},this._viewportProps,this._state,e))}},{key:"_applyConstraints",value:function(t){var e=t.maxZoom,n=t.minZoom,r=t.zoom;t.zoom=tj(r,n,e);var i=t.maxPitch,o=t.minPitch,a=t.pitch;return t.pitch=tj(a,o,i),Object.assign(t,function({width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o=0,bearing:a=0}){(n<-180||n>180)&&(n=m(n+180,360)-180),(a<-180||a>180)&&(a=m(a+180,360)-180);const s=b(e/512);if(i<=s)i=s,r=0;else{const t=e/2/Math.pow(2,i),n=C([0,t])[1];if(re&&(r=e)}}return{width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o,bearing:a}}(t)),t}},{key:"_unproject",value:function(t){var e=new z(this._viewportProps);return t&&e.unproject(t)}},{key:"_calculateNewLngLat",value:function(t){var e=t.startPanLngLat,n=t.pos;return new z(this._viewportProps).getMapCenterByLngLatPosition({lngLat:e,pos:n})}},{key:"_calculateNewZoom",value:function(t){var e=t.scale,n=t.startZoom,r=this._viewportProps,i=r.maxZoom;return tj(n+Math.log2(e),r.minZoom,i)}},{key:"_calculateNewPitchAndBearing",value:function(t){var e=t.deltaScaleX,n=t.deltaScaleY,r=t.startBearing,i=t.startPitch;n=tj(n,-1,1);var o=this._viewportProps,a=o.minPitch,s=o.maxPitch,c=i;return n>0?c=i+n*(s-i):n<0&&(c=i-n*(a-i)),{pitch:c,bearing:r+180*e}}},{key:"_getRotationParams",value:function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[1],o=e[1],a=this._viewportProps,s=a.width,c=a.height,u=0;return r>0?Math.abs(c-o)>5&&(u=r/(o-c)*1.2):r<0&&o>5&&(u=1-i/o),{deltaScaleX:n/s,deltaScaleY:u=Math.min(1,Math.max(-1,u))}}}]),t}();function tA(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tI(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=c.current&&c.current.getMap();return n&&n.queryRenderedFeatures(t,e)}}},[]);var g=(0,h.useCallback)(function(t){var e=t.target;e===p.current&&e.scrollTo(0,0)},[]),m=v&&h.createElement(tN,{value:tZ(tZ({},d),{},{viewport:d.viewport||tU(tZ({map:v,props:t},a)),map:v,container:d.container||l.current})},h.createElement("div",{key:"map-overlays",className:"overlays",ref:p,style:tq,onScroll:g},t.children)),b=t.className,y=t.width,w=t.height,O=t.style,E=t.visibilityConstraints,_=Object.assign({position:"relative"},O,{width:y,height:w}),P=Object.assign({},tq,{visibility:t.visible&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tD;for(var n in e){var r,i=n.slice(0,3),o=(r=n.slice(3))[0].toLowerCase()+r.slice(1);if("min"===i&&t[o]e[n])return!1}return!0}(t.viewState||t,E)?"inherit":"hidden"});return h.createElement("div",{key:"map-container",ref:l,style:_},h.createElement("div",{key:"map-mapbox",ref:u,style:P,className:b}),m,!r&&!t.disableTokenWarning&&h.createElement(tX,null))});function tK(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}(this.propNames||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!function t(e,n){if(e===n)return!0;if(tM(e)&&tM(n)){if(e.length!==n.length)return!1;for(var r=0;r=Math.abs(e-n)}(t[i],e[i]))return!1}}catch(t){r.e(t)}finally{r.f()}return!0}},{key:"initializeProps",value:function(t,e){return{start:t,end:e}}},{key:"interpolateProps",value:function(t,e,n){tT(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(t,e){return e.transitionDuration}}]),t}();function t$(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tJ(t,e){return(tJ=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function tQ(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tJ(t,e)}function t0(t){return(t0="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function t1(t,e){if(e&&("object"===t0(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return t$(t)}function t2(t){return(t2=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var t5={longitude:1,bearing:1};function t4(t){return Number.isFinite(t)||Array.isArray(t)}function t3(t,e,n){return t in t5&&Math.abs(n-e)>180&&(n=n<0?n+360:n-360),n}function t8(t,e){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return t6(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t6(t,void 0)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function t6(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function er(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:{};return tc(this,r),a(t$(t=n.call(this)),"propNames",t9),t.props=Object.assign({},ee,e),t}tl(r,[{key:"initializeProps",value:function(t,e){var n,r={},i={},o=t8(t7);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=t[a],c=e[a];tT(t4(s)&&t4(c),"".concat(a," must be supplied for transition")),r[a]=s,i[a]=t3(a,s,c)}}catch(t){o.e(t)}finally{o.f()}var u,l=t8(et);try{for(l.s();!(u=l.n()).done;){var h=u.value,p=t[h]||0,f=e[h]||0;r[h]=p,i[h]=t3(h,p,f)}}catch(t){l.e(t)}finally{l.f()}return{start:r,end:i}}},{key:"interpolateProps",value:function(t,e,n){var r,i=function(t,e,n,r={}){var i;const o={},{startZoom:a,startCenterXY:s,uDelta:c,w0:u,u1:l,S:h,rho:p,rho2:f,r0:d}=Z(t,e,r);if(l<.01){for(const r of F){const i=t[r],a=e[r];o[r]=n*a+(1-n)*i}return o}const v=n*h,g=Math.cosh(d)/Math.cosh(d+p*v),m=(Math.cosh(d)*Math.tanh(d+p*v)-Math.sinh(d))/f*u/l,y=a+b(1/g),w=((i=[])[0]=c[0]*m,i[1]=c[1]*m,i);_(w,w,s);const O=C(w);return o.longitude=O[0],o.latitude=O[1],o.zoom=y,o}(t,e,n,this.props),o=t8(et);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tS(t[a],e[a],n)}}catch(t){o.e(t)}finally{o.f()}return i}},{key:"getDuration",value:function(t,e){var n=e.transitionDuration;return"auto"===n&&(n=function(t,e,n={}){let r;const{screenSpeed:i,speed:o,maxDuration:a}=n=Object.assign({},V,n),{S:s,rho:c}=Z(t,e,n),u=1e3*s;return r=Number.isFinite(i)?u/(i/c):u/o,Number.isFinite(a)&&r>a?0:r}(t,e,this.props)),n}}])}(tG);var ei=["longitude","latitude","zoom","bearing","pitch"],eo=function(t){tQ(r,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t2(r);return t=e?Reflect.construct(n,arguments,t2(this).constructor):n.apply(this,arguments),t1(this,t)});function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return tc(this,r),t=n.call(this),Array.isArray(e)&&(e={transitionProps:e}),t.propNames=e.transitionProps||ei,e.around&&(t.around=e.around),t}return tl(r,[{key:"initializeProps",value:function(t,e){var n={},r={};if(this.around){n.around=this.around;var i=new z(t).unproject(this.around);Object.assign(r,e,{around:new z(e).project(i),aroundLngLat:i})}var o,a=en(this.propNames);try{for(a.s();!(o=a.n()).done;){var s=o.value,c=t[s],u=e[s];tT(t4(c)&&t4(u),"".concat(s," must be supplied for transition")),n[s]=c,r[s]=t3(s,c,u)}}catch(t){a.e(t)}finally{a.f()}return{start:n,end:r}}},{key:"interpolateProps",value:function(t,e,n){var r,i={},o=en(this.propNames);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tS(t[a],e[a],n)}}catch(t){o.e(t)}finally{o.f()}if(e.around){var s=f(new z(Object.assign({},e,i)).getMapCenterByLngLatPosition({lngLat:e.aroundLngLat,pos:tS(t.around,e.around,n)}),2),c=s[0],u=s[1];i.longitude=c,i.latitude=u}return i}}]),r}(tG),ea=function(){},es={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},ec={transitionDuration:0,transitionEasing:function(t){return t},transitionInterpolator:new eo,transitionInterruption:es.BREAK,onTransitionStart:ea,onTransitionInterrupt:ea,onTransitionEnd:ea},eu=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tc(this,t),a(this,"_animationFrame",null),a(this,"_onTransitionFrame",function(){e._animationFrame=requestAnimationFrame(e._onTransitionFrame),e._updateViewport()}),this.props=null,this.onViewportChange=n.onViewportChange||ea,this.onStateChange=n.onStateChange||ea,this.time=n.getTime||Date.now}return tl(t,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(t){var e=this.props;if(this.props=t,!e||this._shouldIgnoreViewportChange(e,t))return!1;if(this._isTransitionEnabled(t)){var n=Object.assign({},e),r=Object.assign({},t);if(this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this.state.interruption===es.SNAP_TO_END?Object.assign(n,this.state.endProps):Object.assign(n,this.state.propsInTransition),this.state.interruption===es.UPDATE)){var i,o,a=this.time(),s=(a-this.state.startTime)/this.state.duration;r.transitionDuration=this.state.duration-(a-this.state.startTime),r.transitionEasing=(o=(i=this.state.easing)(s),function(t){return 1/(1-o)*(i(t*(1-s)+s)-o)}),r.transitionInterpolator=n.transitionInterpolator}return r.onTransitionStart(),this._triggerTransition(n,r),!0}return this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return!!this._animationFrame}},{key:"_isTransitionEnabled",value:function(t){var e=t.transitionDuration,n=t.transitionInterpolator;return(e>0||"auto"===e)&&!!n}},{key:"_isUpdateDueToCurrentTransition",value:function(t){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(t,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(t,e){return!t||(this._isTransitionInProgress()?this.state.interruption===es.IGNORE||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e))}},{key:"_triggerTransition",value:function(t,e){tT(this._isTransitionEnabled(e)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var n=e.transitionInterpolator,r=n.getDuration?n.getDuration(t,e):e.transitionDuration;if(0!==r){var i=e.transitionInterpolator.initializeProps(t,e),o={inTransition:!0,isZooming:t.zoom!==e.zoom,isPanning:t.longitude!==e.longitude||t.latitude!==e.latitude,isRotating:t.bearing!==e.bearing||t.pitch!==e.pitch};this.state={duration:r,easing:e.transitionEasing,interpolator:e.transitionInterpolator,interruption:e.transitionInterruption,startTime:this.time(),startProps:i.start,endProps:i.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(o)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var t=this.time(),e=this.state,n=e.startTime,r=e.duration,i=e.easing,o=e.interpolator,a=e.startProps,s=e.endProps,c=!1,u=(t-n)/r;u>=1&&(u=1,c=!0),u=i(u);var l=o.interpolateProps(a,s,u),h=new tR(Object.assign({},this.props,l));this.state.propsInTransition=h.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),t}();a(eu,"defaultProps",ec);var el=n(840),eh=n.n(el);const ep={mousedown:1,mousemove:2,mouseup:4};!function(t){const e=t.prototype.handler;t.prototype.handler=function(t){const n=this.store;t.button>0&&"pointerdown"===t.type&&!function(t,e){for(let n=0;ne.pointerId===t.pointerId)&&n.push(t),e.call(this,t)}}(eh().PointerEventInput),eh().MouseInput.prototype.handler=function(t){let e=ep[t.type];1&e&&t.button>=0&&(this.pressed=!0),2&e&&0===t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))};const ef=eh().Manager;var ed=eh();const ev=ed?[[ed.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[ed.Rotate,{enable:!1}],[ed.Pinch,{enable:!1}],[ed.Swipe,{enable:!1}],[ed.Pan,{threshold:0,enable:!1}],[ed.Press,{enable:!1}],[ed.Tap,{event:"doubletap",taps:2,enable:!1}],[ed.Tap,{event:"anytap",enable:!1}],[ed.Tap,{enable:!1}]]:null,eg={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},em={doubletap:["tap"]},eb={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ey={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ew={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},eO={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},eE="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",e_="undefined"!=typeof window?window:n.g;void 0!==n.g?n.g:window;let eP=!1;try{const t={get passive(){return eP=!0,!0}};e_.addEventListener("test",t,t),e_.removeEventListener("test",t,t)}catch(t){}const eM=-1!==eE.indexOf("firefox"),{WHEEL_EVENTS:ej}=ey,eS="wheel";class eT{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.events=ej.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent,!!eP&&{passive:!1}))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eS&&(this.options.enable=e)}handleEvent(t){if(!this.options.enable)return;let e=t.deltaY;e_.WheelEvent&&(eM&&t.deltaMode===e_.WheelEvent.DOM_DELTA_PIXEL&&(e/=e_.devicePixelRatio),t.deltaMode===e_.WheelEvent.DOM_DELTA_LINE&&(e*=40));const n={x:t.clientX,y:t.clientY};0!==e&&e%4.000244140625==0&&(e=Math.floor(e/4.000244140625)),t.shiftKey&&e&&(e*=.25),this._onWheel(t,-e,n)}_onWheel(t,e,n){this.callback({type:eS,center:n,delta:e,srcEvent:t,pointerType:"mouse",target:t.target})}}const{MOUSE_EVENTS:ek}=ey,ex="pointermove",eD="pointerover",eC="pointerout",eR="pointerleave";class eA{constructor(t,e,n={}){this.element=t,this.callback=e,this.pressed=!1,this.options=Object.assign({enable:!0},n),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=ek.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===ex&&(this.enableMoveEvent=e),t===eD&&(this.enableOverEvent=e),t===eC&&(this.enableOutEvent=e),t===eR&&(this.enableLeaveEvent=e)}handleEvent(t){this.handleOverEvent(t),this.handleOutEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this.callback({type:eD,srcEvent:t,pointerType:"mouse",target:t.target})}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this.callback({type:eC,srcEvent:t,pointerType:"mouse",target:t.target})}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this.callback({type:eR,srcEvent:t,pointerType:"mouse",target:t.target})}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.which&&(this.pressed=!1),this.pressed||this.callback({type:ex,srcEvent:t,pointerType:"mouse",target:t.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:eI}=ey,eL="keydown",eN="keyup";class ez{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=eI.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),t.tabIndex=n.tabIndex||0,t.style.outline="none",this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eL&&(this.enableDownEvent=e),t===eN&&(this.enableUpEvent=e)}handleEvent(t){const e=t.target||t.srcElement;("INPUT"!==e.tagName||"text"!==e.type)&&"TEXTAREA"!==e.tagName&&(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:eL,srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:eN,srcEvent:t,key:t.key,target:t.target}))}}const eF="contextmenu";class eV{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.handleEvent=this.handleEvent.bind(this),t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){t===eF&&(this.options.enable=e)}handleEvent(t){this.options.enable&&this.callback({type:eF,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const eZ={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},eB={srcElement:"root",priority:0};class eU{constructor(t){this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(t,e,n,r=!1,i=!1){const{handlers:o,handlersByElement:a}=this;n&&("object"!=typeof n||n.addEventListener)&&(n={srcElement:n}),n=n?Object.assign({},eB,n):eB;let s=a.get(n.srcElement);s||(s=[],a.set(n.srcElement,s));const c={type:t,handler:e,srcElement:n.srcElement,priority:n.priority};r&&(c.once=!0),i&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=s.length-1;for(;u>=0&&!(s[u].priority>=c.priority);)u--;s.splice(u+1,0,c)}remove(t,e){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===t&&o.handler===e){n.splice(i,1);const t=r.get(o.srcElement);t.splice(t.indexOf(o),1),0===t.length&&r.delete(o.srcElement)}}this._active=n.some(t=>!t.passive)}handleEvent(t){if(this.isEmpty())return;const e=this._normalizeEvent(t);let n=t.srcEvent.target;for(;n&&n!==e.rootElement;){if(this._emit(e,n),e.handled)return;n=n.parentNode}this._emit(e,"root")}_emit(t,e){const n=this.handlersByElement.get(e);if(n){let e=!1;const r=()=>{t.handled=!0},i=()=>{t.handled=!0,e=!0},o=[];for(let a=0;a{const e=this.manager.get(t);e&&eg[t].forEach(t=>{e.recognizeWith(t)})}),e.recognizerOptions){const t=this.manager.get(r);if(t){const n=e.recognizerOptions[r];delete n.enable,t.set(n)}}for(const[n,r]of(this.wheelInput=new eT(t,this._onOtherEvent,{enable:!1}),this.moveInput=new eA(t,this._onOtherEvent,{enable:!1}),this.keyInput=new ez(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new eV(t,this._onOtherEvent,{enable:!1}),this.events))r.isEmpty()||(this._toggleRecognizer(r.recognizerName,!0),this.manager.on(n,r.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(t,e,n){this._addEventHandler(t,e,n,!1)}once(t,e,n){this._addEventHandler(t,e,n,!0)}watch(t,e,n){this._addEventHandler(t,e,n,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:n}=this;if(!n)return;const r=n.get(t);if(r&&r.options.enable!==e){r.set({enable:e});const i=em[t];i&&!this.options.recognizers&&i.forEach(i=>{const o=n.get(i);e?(o.requireFailure(t),r.dropRequireFailure(i)):o.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,n,r,i){if("string"!=typeof t){for(const o in n=e,t)this._addEventHandler(o,t[o],n,r,i);return}const{manager:o,events:a}=this,s=eO[t]||t;let c=a.get(s);!c&&(c=new eU(this),a.set(s,c),c.recognizerName=ew[s]||s,o&&o.on(s,c.handleEvent)),c.add(t,e,n,r,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const e in t)this._removeEventHandler(e,t[e]);return}const{events:n}=this,r=eO[t]||t,i=n.get(r);if(i&&(i.remove(t,e),i.isEmpty())){const{recognizerName:t}=i;let e=!1;for(const r of n.values())if(r.recognizerName===t&&!r.isEmpty()){e=!0;break}e||this._toggleRecognizer(t,!1)}}_onBasicInput(t){const{srcEvent:e}=t,n=eb[e.type];n&&this.manager.emit(n,t)}_onOtherEvent(t){this.manager.emit(t.type,t)}}function eH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function eX(t){for(var e=1;e0),a=o&&!this.state.isHovering,s=!o&&this.state.isHovering;(r||a)&&(t.features=e,r&&r(t)),a&&nt.call(this,"onMouseEnter",t),s&&nt.call(this,"onMouseLeave",t),(a||s)&&this.setState({isHovering:o})}}function ni(t){var e=this.props,n=e.onClick,r=e.onNativeClick,i=e.onDblClick,o=e.doubleClickZoom,a=[],s=i||o;switch(t.type){case"anyclick":a.push(r),s||a.push(n);break;case"click":s&&a.push(n)}(a=a.filter(Boolean)).length&&((t=e9.call(this,t)).features=e7.call(this,t.point),a.forEach(function(e){return e(t)}))}var no=(0,h.forwardRef)(function(t,e){var n,a,s=(0,h.useContext)(tL),c=(0,h.useMemo)(function(){return t.controller||new e5},[]),u=(0,h.useMemo)(function(){return new eW(null,{touchAction:t.touchAction,recognizerOptions:t.eventRecognizerOptions})},[]),l=(0,h.useRef)(null),p=(0,h.useRef)(null),f=(0,h.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;f.props=t,f.map=p.current&&p.current.getMap(),f.setState=function(e){f.state=e3(e3({},f.state),e),l.current.style.cursor=t.getCursor(f.state)};var d=!0,v=function(t,e,r){if(d){n=[t,e,r];return}var i=f.props,o=i.onViewStateChange,a=i.onViewportChange;Object.defineProperty(t,"position",{get:function(){return[0,0,tF(f.map,t)]}}),o&&o({viewState:t,interactionState:e,oldViewState:r}),a&&a(t,e,r)};(0,h.useImperativeHandle)(e,function(){return{getMap:p.current&&p.current.getMap,queryRenderedFeatures:p.current&&p.current.queryRenderedFeatures}},[]);var g=(0,h.useMemo)(function(){return e3(e3({},s),{},{eventManager:u,container:s.container||l.current})},[s,l.current]);g.onViewportChange=v,g.viewport=s.viewport||tU(f),f.viewport=g.viewport;var m=function(t){var e=t.isDragging,n=void 0!==e&&e;if(n!==f.state.isDragging&&f.setState({isDragging:n}),d){a=t;return}var r=f.props.onInteractionStateChange;r&&r(t)},b=function(){f.width&&f.height&&c.setOptions(e3(e3(e3({},f.props),f.props.viewState),{},{isInteractive:!!(f.props.onViewStateChange||f.props.onViewportChange),onViewportChange:v,onStateChange:m,eventManager:u,width:f.width,height:f.height}))};(0,h.useEffect)(function(){return u.setElement(l.current),u.on({pointerdown:ne.bind(f),pointermove:nr.bind(f),pointerup:nn.bind(f),pointerleave:nt.bind(f,"onMouseOut"),click:ni.bind(f),anyclick:ni.bind(f),dblclick:nt.bind(f,"onDblClick"),wheel:nt.bind(f,"onWheel"),contextmenu:nt.bind(f,"onContextMenu")}),function(){u.destroy()}},[]),tz(function(){if(n){var t;v.apply(void 0,function(t){if(Array.isArray(t))return i(t)}(t=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}a&&m(a)}),b();var y=t.width,w=t.height,O=t.style,E=t.getCursor,_=(0,h.useMemo)(function(){return e3(e3({position:"relative"},O),{},{width:y,height:w,cursor:E(f.state)})},[O,y,w,E,f.state]);return n&&f._child||(f._child=h.createElement(tN,{value:g},h.createElement("div",{key:"event-canvas",ref:l,style:_},h.createElement(tY,r({},t,{width:"100%",height:"100%",style:null,onResize:function(t){var e=t.width,n=t.height;f.width=e,f.height=n,b(),f.props.onResize({width:e,height:n})},ref:p}))))),d=!1,f._child});no.supported=tY.supported,no.propTypes=e8,no.defaultProps=e6;var na=no;p.string.isRequired,p.string,p.oneOf(["fill","line","symbol","circle","fill-extrusion","raster","background","heatmap","hillshade","sky"]).isRequired,p.string,p.string,p.string;var ns={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},nc={captureScroll:p.bool,captureDrag:p.bool,captureClick:p.bool,captureDoubleClick:p.bool,capturePointerMove:p.bool};function nu(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(0,h.useContext)(tL),n=(0,h.useRef)(null),r=(0,h.useRef)({props:t,state:{},context:e,containerRef:n}).current;return r.props=t,r.context=e,(0,h.useEffect)(function(){return function(t){var e=t.containerRef.current,n=t.context.eventManager;if(e&&n){var r={wheel:function(e){var n=t.props;n.captureScroll&&e.stopPropagation(),n.onScroll&&n.onScroll(e,t)},panstart:function(e){var n=t.props;n.captureDrag&&e.stopPropagation(),n.onDragStart&&n.onDragStart(e,t)},anyclick:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onNativeClick&&n.onNativeClick(e,t)},click:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onClick&&n.onClick(e,t)},dblclick:function(e){var n=t.props;n.captureDoubleClick&&e.stopPropagation(),n.onDoubleClick&&n.onDoubleClick(e,t)},pointermove:function(e){var n=t.props;n.capturePointerMove&&e.stopPropagation(),n.onPointerMove&&n.onPointerMove(e,t)}};return n.watch(r,e),function(){n.off(r)}}}(r)},[e.eventManager]),r}function nl(t){var e=t.instance,n=nu(t),r=n.context,i=n.containerRef;return e._context=r,e._containerRef=i,e._render()}var nh=function(t){tQ(i,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t2(i);return t=e?Reflect.construct(n,arguments,t2(this).constructor):n.apply(this,arguments),t1(this,t)});function i(){var t;tc(this,i);for(var e=arguments.length,r=Array(e),o=0;o2&&void 0!==arguments[2]?arguments[2]:"x";if(null===t)return e;var r="x"===n?t.offsetWidth:t.offsetHeight;return nw(e/100*r)/r*100};function nE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}var n_=Object.assign({},nd,{className:p.string,longitude:p.number.isRequired,latitude:p.number.isRequired,style:p.object}),nP=Object.assign({},nv,{className:""});function nM(t){var e,n,r,i,o,s,c,u=(n=(e=f((0,h.useState)(null),2))[0],r=e[1],o=(i=f((0,h.useState)(null),2))[0],s=i[1],(c=nu(nf(nf({},t),{},{onDragStart:nb}))).callbacks=t,c.state.dragPos=n,c.state.setDragPos=r,c.state.dragOffset=o,c.state.setDragOffset=s,(0,h.useEffect)(function(){return function(t){var e=t.context.eventManager;if(e&&t.state.dragPos){var n={panmove:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=ng(t);i.setDragPos(a);var s=i.dragOffset;if(r.onDrag&&s){var c=Object.assign({},t);c.lngLat=nm(a,s,n,o),r.onDrag(c)}}(e,t)},panend:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=i.dragPos,s=i.dragOffset;if(i.setDragPos(null),i.setDragOffset(null),r.onDragEnd&&a&&s){var c=Object.assign({},t);c.lngLat=nm(a,s,n,o),r.onDragEnd(c)}}(e,t)},pancancel:function(e){var n;return n=t.state,void(e.stopPropagation(),n.setDragPos(null),n.setDragOffset(null))}};return e.watch(n),function(){e.off(n)}}}(c)},[c.context.eventManager,!!n]),c),l=u.state,p=u.containerRef,d=t.children,v=t.className,g=t.draggable,m=t.style,b=l.dragPos,y=function(t){var e=t.props,n=t.state,r=t.context,i=e.longitude,o=e.latitude,a=e.offsetLeft,s=e.offsetTop,c=n.dragPos,u=n.dragOffset,l=r.viewport,h=r.map;if(c&&u)return[c[0]+u[0],c[1]+u[1]];var p=tF(h,{longitude:i,latitude:o}),d=f(l.project([i,o,p]),2),v=d[0],g=d[1];return[v+=a,g+=s]}(u),w=f(y,2),O=w[0],E=w[1],_="translate(".concat(nw(O),"px, ").concat(nw(E),"px)"),P=g?b?"grabbing":"grab":"auto",M=(0,h.useMemo)(function(){var t=function(t){for(var e=1;e0){var g=p,m=v;for(p=0;p<=1;p+=.5)d=(f=n-p*a)+a,(v=Math.max(0,u-f)+Math.max(0,d-i+u))0){var E=h,_=O;for(h=0;h<=1;h+=b)w=(y=e-h*o)+o,(O=Math.max(0,u-y)+Math.max(0,w-r+u))<_&&(_=O,E=h);h=E}return nS.find(function(t){var e=nj[t];return e.x===h&&e.y===p})||s}({x:r,y:i,anchor:o,padding:s,width:S.width,height:S.height,selfWidth:e.clientWidth,selfHeight:e.clientHeight}):o),z=(c=M.current,l=(u=f(L,3))[0],p=u[1],d=u[2],v=t.offsetLeft,g=t.offsetTop,m=t.sortByDepth,y=nO(c,-(100*(b=nj[N]).x)),w=nO(c,-(100*b.y),"y"),O={position:"absolute",transform:"\n translate(".concat(y,"%, ").concat(w,"%)\n translate(").concat(nw(l+v),"px, ").concat(nw(p+g),"px)\n "),display:void 0,zIndex:void 0},m&&(d>1||d<-1||l<0||l>S.width||p<0||p>S.height?O.display="none":O.zIndex=Math.floor((1-d)/2*1e5)),O),F=(0,h.useCallback)(function(t){_.props.onClose();var e=_.context.eventManager;e&&e.once("click",function(t){return t.stopPropagation()},t.target)},[]);return h.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(N," ").concat(k),style:z,ref:M},h.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:C}}),h.createElement("div",{key:"content",ref:E,className:"mapboxgl-popup-content"},R&&h.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:F},"×"),A))}function nD(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nx.propTypes=nT,nx.defaultProps=nk,h.memo(nx);var nC=Object.assign({},nc,{toggleLabel:p.string,className:p.string,style:p.object,compact:p.bool,customAttribution:p.oneOfType([p.string,p.arrayOf(p.string)])}),nR=Object.assign({},ns,{className:"",toggleLabel:"Toggle Attribution"});function nA(t){var e=nu(t),n=e.context,r=e.containerRef,i=(0,h.useRef)(null),o=f((0,h.useState)(!1),2),s=o[0],c=o[1];(0,h.useEffect)(function(){var e,o,a,s,c,u;return n.map&&(o={customAttribution:t.customAttribution},a=n.map,s=r.current,c=i.current,(u=new(tP()).AttributionControl(o))._map=a,u._container=s,u._innerContainer=c,u._updateAttributions(),u._updateEditLink(),a.on("styledata",u._updateData),a.on("sourcedata",u._updateData),e=u),function(){var t;return e&&void((t=e)._map.off("styledata",t._updateData),t._map.off("sourcedata",t._updateData))}},[n.map]);var u=void 0===t.compact?n.viewport.width<=640:t.compact;(0,h.useEffect)(function(){!u&&s&&c(!1)},[u]);var l=(0,h.useCallback)(function(){return c(function(t){return!t})},[]),p=(0,h.useMemo)(function(){return function(t){for(var e=1;ea)return 1}return 0}(o.map.version,"1.6.0")>=0?2:1:2},[o.map]),n=o.viewport.bearing,r={transform:"rotate(".concat(-n,"deg)")},2===e?h.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:r}):h.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:r})))))}function n$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nG.propTypes=nH,nG.defaultProps=nX,h.memo(nG);var nJ=Object.assign({},nc,{className:p.string,style:p.object,maxWidth:p.number,unit:p.oneOf(["imperial","metric","nautical"])}),nQ=Object.assign({},ns,{className:"",maxWidth:100,unit:"metric"});function n0(t){var e=nu(t),n=e.context,r=e.containerRef,i=f((0,h.useState)(null),2),o=i[0],s=i[1];(0,h.useEffect)(function(){if(n.map){var t=new(tP()).ScaleControl;t._map=n.map,t._container=r.current,s(t)}},[n.map]),o&&(o.options=t,o._onMove());var c=(0,h.useMemo)(function(){return function(t){for(var e=1;e date.getHours() ? formats.AMPMS[0] : formats.AMPMS[1]; }, Z: function(date) { - var zone = -1 * date.getTimezoneOffset(); - return (zone >= 0 ? "+" : "") + (padNumber(Math[zone > 0 ? "floor" : "ceil"](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2)); + var zone = -1 * date.getTimezoneOffset(), paddedZone = zone >= 0 ? "+" : ""; + return paddedZone + (padNumber(Math[zone > 0 ? "floor" : "ceil"](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2)); } }, DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/, NUMBER_STRING = /^\-?\d+$/; function dateFilter($locale) { @@ -4148,16 +4148,16 @@ ], link: function(scope, element, attr, ctrls) { if (ctrls[1]) { - for(var lastView, emptyOption, selectCtrl = ctrls[0], ngModelCtrl = ctrls[1], multiple = attr.multiple, optionsExp = attr.ngOptions, nullOption = !1, optionTemplate = jqLite(document1.createElement("option")), optGroupTemplate = jqLite(document1.createElement("optgroup")), unknownOption = optionTemplate.clone(), i = 0, children = element.children(), ii = children.length; i < ii; i++)if ("" === children[i].value) { + for(var scope1, selectElement, ctrl, lastView, scope2, selectElement1, ngModelCtrl, selectCtrl, emptyOption, selectCtrl1 = ctrls[0], ngModelCtrl1 = ctrls[1], multiple = attr.multiple, optionsExp = attr.ngOptions, nullOption = !1, optionTemplate = jqLite(document1.createElement("option")), optGroupTemplate = jqLite(document1.createElement("optgroup")), unknownOption = optionTemplate.clone(), i = 0, children = element.children(), ii = children.length; i < ii; i++)if ("" === children[i].value) { emptyOption = nullOption = children.eq(i); break; } - if (selectCtrl.init(ngModelCtrl, nullOption, unknownOption), multiple && (attr.required || attr.ngRequired)) { + if (selectCtrl1.init(ngModelCtrl1, nullOption, unknownOption), multiple && (attr.required || attr.ngRequired)) { var requiredValidator = function(value) { - return ngModelCtrl.$setValidity("required", !attr.required || value && value.length), value; + return ngModelCtrl1.$setValidity("required", !attr.required || value && value.length), value; }; - ngModelCtrl.$parsers.push(requiredValidator), ngModelCtrl.$formatters.unshift(requiredValidator), attr.$observe("required", function() { - requiredValidator(ngModelCtrl.$viewValue); + ngModelCtrl1.$parsers.push(requiredValidator), ngModelCtrl1.$formatters.unshift(requiredValidator), attr.$observe("required", function() { + requiredValidator(ngModelCtrl1.$viewValue); }); } optionsExp ? function(scope, selectElement, ctrl) { @@ -4245,26 +4245,26 @@ ctrl.$setViewValue(value); }); }), ctrl.$render = render, scope.$watch(render); - }(scope, element, ngModelCtrl) : multiple ? (ngModelCtrl.$render = function() { - var items = new HashMap(ngModelCtrl.$viewValue); - forEach(element.find("option"), function(option) { + }(scope, element, ngModelCtrl1) : multiple ? (scope1 = scope, selectElement = element, (ctrl = ngModelCtrl1).$render = function() { + var items = new HashMap(ctrl.$viewValue); + forEach(selectElement.find("option"), function(option) { option.selected = isDefined(items.get(option.value)); }); - }, scope.$watch(function() { - equals(lastView, ngModelCtrl.$viewValue) || (lastView = copy(ngModelCtrl.$viewValue), ngModelCtrl.$render()); - }), element.on("change", function() { - scope.$apply(function() { + }, scope1.$watch(function() { + equals(lastView, ctrl.$viewValue) || (lastView = copy(ctrl.$viewValue), ctrl.$render()); + }), selectElement.on("change", function() { + scope1.$apply(function() { var array = []; - forEach(element.find("option"), function(option) { + forEach(selectElement.find("option"), function(option) { option.selected && array.push(option.value); - }), ngModelCtrl.$setViewValue(array); + }), ctrl.$setViewValue(array); }); - })) : (ngModelCtrl.$render = function() { + })) : (scope2 = scope, selectElement1 = element, ngModelCtrl = ngModelCtrl1, selectCtrl = selectCtrl1, ngModelCtrl.$render = function() { var viewValue = ngModelCtrl.$viewValue; - selectCtrl.hasOption(viewValue) ? (unknownOption.parent() && unknownOption.remove(), element.val(viewValue), "" === viewValue && emptyOption.prop("selected", !0)) : isUndefined(viewValue) && emptyOption ? element.val("") : selectCtrl.renderUnknownOption(viewValue); - }, element.on("change", function() { - scope.$apply(function() { - unknownOption.parent() && unknownOption.remove(), ngModelCtrl.$setViewValue(element.val()); + selectCtrl.hasOption(viewValue) ? (unknownOption.parent() && unknownOption.remove(), selectElement1.val(viewValue), "" === viewValue && emptyOption.prop("selected", !0)) : isUndefined(viewValue) && emptyOption ? selectElement1.val("") : selectCtrl.renderUnknownOption(viewValue); + }, selectElement1.on("change", function() { + scope2.$apply(function() { + unknownOption.parent() && unknownOption.remove(), ngModelCtrl.$setViewValue(selectElement1.val()); }); })); } diff --git a/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js b/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js index b57a026409b8..e1551786d045 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/jquery.mobile-1.4.2.js @@ -3283,7 +3283,7 @@ this._ui.container.addClass("ui-popup-active"), this._isOpen = !0, this._resizeScreen(), this._ui.container.attr("tabindex", "0").focus(), this._ignoreResizeEvents(), id && this.document.find("[aria-haspopup='true'][aria-owns='" + id + "']").attr("aria-expanded", !0), this._trigger("afteropen"); }, _open: function(options) { - var ua, wkmatch, wkversion, androidmatch, andversion, chromematch, openOptions = $.extend({}, this.options, options), androidBlacklist = (wkversion = !!(wkmatch = (ua = navigator.userAgent).match(/AppleWebKit\/([0-9\.]+)/)) && wkmatch[1], andversion = !!(androidmatch = ua.match(/Android (\d+(?:\.\d+))/)) && androidmatch[1], chromematch = ua.indexOf("Chrome") > -1, null !== androidmatch && "4.0" === andversion && !!wkversion && wkversion > 534.13 && !chromematch); + var ua, wkmatch, wkversion, androidmatch, andversion, chromematch, openOptions = $.extend({}, this.options, options), androidBlacklist = (wkversion = !!(wkmatch = (ua = navigator.userAgent).match(/AppleWebKit\/([0-9\.]+)/)) && wkmatch[1], andversion = !!(androidmatch = ua.match(/Android (\d+(?:\.\d+))/)) && androidmatch[1], chromematch = ua.indexOf("Chrome") > -1, null !== androidmatch && "4.0" === andversion && !!wkversion && !!(wkversion > 534.13) && !chromematch); this._createPrerequisites($.noop, $.noop, $.proxy(this, "_openPrerequisitesComplete")), this._currentTransition = openOptions.transition, this._applyTransition(openOptions.transition), this._ui.screen.removeClass("ui-screen-hidden"), this._ui.container.removeClass("ui-popup-truncate"), this._reposition(openOptions), this._ui.container.removeClass("ui-popup-hidden"), this.options.overlayTheme && androidBlacklist && this.element.closest(".ui-page").addClass("ui-popup-open"), this._animate({ additionalCondition: !0, transition: openOptions.transition, diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js index c08cc737d573..28ba779d479c 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js @@ -1141,17 +1141,17 @@ }); }); var uppercasePattern = /([A-Z])/g, msPattern = /^ms-/, warnValidStyle = function() {}, badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/, msPattern$1 = /^-ms-/, hyphenPattern = /-(.)/g, badStyleValueWithSemicolonPattern = /;\s*$/, warnedStyleNames = {}, warnedStyleValues = {}, warnedForNaNValue = !1, warnedForInfinityValue = !1, warnHyphenatedStyleName = function(name) { - warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name] || (warnedStyleNames[name] = !0, error("Unsupported style property %s. Did you mean %s?", name, name.replace(msPattern$1, "ms-").replace(hyphenPattern, function(_, character) { + (!warnedStyleNames.hasOwnProperty(name) || !warnedStyleNames[name]) && (warnedStyleNames[name] = !0, error("Unsupported style property %s. Did you mean %s?", name, name.replace(msPattern$1, "ms-").replace(hyphenPattern, function(_, character) { return character.toUpperCase(); }))); }, warnBadVendoredStyleName = function(name) { - warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name] || (warnedStyleNames[name] = !0, error("Unsupported vendor-prefixed style property %s. Did you mean %s?", name, name.charAt(0).toUpperCase() + name.slice(1))); + (!warnedStyleNames.hasOwnProperty(name) || !warnedStyleNames[name]) && (warnedStyleNames[name] = !0, error("Unsupported vendor-prefixed style property %s. Did you mean %s?", name, name.charAt(0).toUpperCase() + name.slice(1))); }, warnStyleValueWithSemicolon = function(name, value) { - warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value] || (warnedStyleValues[value] = !0, error('Style property values shouldn\'t contain a semicolon. Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ""))); + (!warnedStyleValues.hasOwnProperty(value) || !warnedStyleValues[value]) && (warnedStyleValues[value] = !0, error('Style property values shouldn\'t contain a semicolon. Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ""))); }, warnStyleValueIsNaN = function(name, value) { - warnedForNaNValue || (warnedForNaNValue = !0, error("`NaN` is an invalid value for the `%s` css style property.", name)); + !warnedForNaNValue && (warnedForNaNValue = !0, error("`NaN` is an invalid value for the `%s` css style property.", name)); }, warnStyleValueIsInfinity = function(name, value) { - warnedForInfinityValue || (warnedForInfinityValue = !0, error("`Infinity` is an invalid value for the `%s` css style property.", name)); + !warnedForInfinityValue && (warnedForInfinityValue = !0, error("`Infinity` is an invalid value for the `%s` css style property.", name)); }, warnValidStyle$1 = function(name, value) { name.indexOf("-") > -1 ? warnHyphenatedStyleName(name) : badVendoredStyleNamePattern.test(name) ? warnBadVendoredStyleName(name) : badStyleValueWithSemicolonPattern.test(value) && warnStyleValueWithSemicolon(name, value), "number" != typeof value || (isNaN(value) ? warnStyleValueIsNaN(name, value) : isFinite(value) || warnStyleValueIsInfinity(name, value)); }; @@ -3914,10 +3914,7 @@ if (element) { var owner = element._owner, stack = function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { if (null == type) return ""; - if ("function" == typeof type) { - var prototype; - return describeNativeComponentFrame(type, !!((prototype = type.prototype) && prototype.isReactComponent)); - } + if ("function" == typeof type) return describeNativeComponentFrame(type, !!((prototype = type.prototype) && prototype.isReactComponent)); if ("string" == typeof type) return describeBuiltInComponentFrame(type); switch(type){ case REACT_SUSPENSE_TYPE: @@ -3933,7 +3930,7 @@ case REACT_BLOCK_TYPE: return describeNativeComponentFrame(type._render, !1); case REACT_LAZY_TYPE: - var payload = type._payload, init = type._init; + var prototype, payload = type._payload, init = type._init; try { return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); } catch (x) {} @@ -6764,143 +6761,144 @@ return null; } var currentHostContext = getHostContext(); - if (popHydrationState(workInProgress)) instance = workInProgress.stateNode, type1 = workInProgress.type, props = workInProgress.memoizedProps, instance[internalInstanceKey] = workInProgress, instance[internalPropsKey] = props, updatePayload = function(domElement, tag, rawProps, parentNamespace, rootContainerElement) { - switch(suppressHydrationWarning = !0 === rawProps[SUPPRESS_HYDRATION_WARNING], isCustomComponentTag = isCustomComponent(tag, rawProps), validatePropertiesInDevelopment(tag, rawProps), tag){ - case "dialog": - listenToNonDelegatedEvent("cancel", domElement), listenToNonDelegatedEvent("close", domElement); - break; - case "iframe": - case "object": - case "embed": - listenToNonDelegatedEvent("load", domElement); - break; - case "video": - case "audio": - for(var isCustomComponentTag, extraAttributeNames, i = 0; i < mediaEventTypes.length; i++)listenToNonDelegatedEvent(mediaEventTypes[i], domElement); - break; - case "source": - listenToNonDelegatedEvent("error", domElement); - break; - case "img": - case "image": - case "link": - listenToNonDelegatedEvent("error", domElement), listenToNonDelegatedEvent("load", domElement); - break; - case "details": - listenToNonDelegatedEvent("toggle", domElement); - break; - case "input": - initWrapperState(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); - break; - case "option": - validateProps(domElement, rawProps); - break; - case "select": - initWrapperState$1(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); - break; - case "textarea": - initWrapperState$2(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); - } - assertValidProps(tag, rawProps), extraAttributeNames = new Set(); - for(var attributes = domElement.attributes, _i = 0; _i < attributes.length; _i++)switch(attributes[_i].name.toLowerCase()){ - case "data-reactroot": - case "value": - case "checked": - case "selected": - break; - default: - extraAttributeNames.add(attributes[_i].name); - } - var updatePayload = null; - for(var propKey in rawProps)if (rawProps.hasOwnProperty(propKey)) { - var nextProp = rawProps[propKey]; - if (propKey === CHILDREN) "string" == typeof nextProp ? domElement.textContent !== nextProp && (suppressHydrationWarning || warnForTextDifference(domElement.textContent, nextProp), updatePayload = [ - CHILDREN, - nextProp - ]) : "number" == typeof nextProp && domElement.textContent !== "" + nextProp && (suppressHydrationWarning || warnForTextDifference(domElement.textContent, nextProp), updatePayload = [ - CHILDREN, - "" + nextProp - ]); - else if (registrationNameDependencies.hasOwnProperty(propKey)) null != nextProp && ("function" != typeof nextProp && warnForInvalidEventListener(propKey, nextProp), "onScroll" === propKey && listenToNonDelegatedEvent("scroll", domElement)); - else if ("boolean" == typeof isCustomComponentTag) { - var serverValue = void 0, propertyInfo = getPropertyInfo(propKey); - if (suppressHydrationWarning) ; - else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || "value" === propKey || "checked" === propKey || "selected" === propKey) ; - else if (propKey === DANGEROUSLY_SET_INNER_HTML) { - var serverHTML = domElement.innerHTML, nextHtml = nextProp ? nextProp[HTML$1] : void 0; - if (null != nextHtml) { - var expectedHTML = normalizeHTML(domElement, nextHtml); - expectedHTML !== serverHTML && warnForPropDifference(propKey, serverHTML, expectedHTML); - } - } else if (propKey === STYLE) { - if (extraAttributeNames.delete(propKey), canDiffStyleForHydrationWarning) { - var expectedStyle = function(styles) { - var serialized = "", delimiter = ""; - for(var styleName in styles)if (styles.hasOwnProperty(styleName)) { - var styleValue = styles[styleName]; - if (null != styleValue) { - var isCustomProperty = 0 === styleName.indexOf("--"); - serialized += delimiter + (isCustomProperty ? styleName : styleName.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-")) + ":" + dangerousStyleValue(styleName, styleValue, isCustomProperty), delimiter = ";"; + if (popHydrationState(workInProgress)) { + if (instance = workInProgress.stateNode, type1 = workInProgress.type, props = workInProgress.memoizedProps, rootContainerInstance1 = 0, hostContext = currentHostContext, hostInst = workInProgress, instance[internalInstanceKey] = hostInst, node = instance, props1 = props, node[internalPropsKey] = props1, updatePayload = function(domElement, tag, rawProps, parentNamespace, rootContainerElement) { + switch(suppressHydrationWarning = !0 === rawProps[SUPPRESS_HYDRATION_WARNING], isCustomComponentTag = isCustomComponent(tag, rawProps), validatePropertiesInDevelopment(tag, rawProps), tag){ + case "dialog": + listenToNonDelegatedEvent("cancel", domElement), listenToNonDelegatedEvent("close", domElement); + break; + case "iframe": + case "object": + case "embed": + listenToNonDelegatedEvent("load", domElement); + break; + case "video": + case "audio": + for(var isCustomComponentTag, extraAttributeNames, i = 0; i < mediaEventTypes.length; i++)listenToNonDelegatedEvent(mediaEventTypes[i], domElement); + break; + case "source": + listenToNonDelegatedEvent("error", domElement); + break; + case "img": + case "image": + case "link": + listenToNonDelegatedEvent("error", domElement), listenToNonDelegatedEvent("load", domElement); + break; + case "details": + listenToNonDelegatedEvent("toggle", domElement); + break; + case "input": + initWrapperState(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); + break; + case "option": + validateProps(domElement, rawProps); + break; + case "select": + initWrapperState$1(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); + break; + case "textarea": + initWrapperState$2(domElement, rawProps), listenToNonDelegatedEvent("invalid", domElement); + } + assertValidProps(tag, rawProps), extraAttributeNames = new Set(); + for(var attributes = domElement.attributes, _i = 0; _i < attributes.length; _i++)switch(attributes[_i].name.toLowerCase()){ + case "data-reactroot": + case "value": + case "checked": + case "selected": + break; + default: + extraAttributeNames.add(attributes[_i].name); + } + var updatePayload = null; + for(var propKey in rawProps)if (rawProps.hasOwnProperty(propKey)) { + var nextProp = rawProps[propKey]; + if (propKey === CHILDREN) "string" == typeof nextProp ? domElement.textContent !== nextProp && (suppressHydrationWarning || warnForTextDifference(domElement.textContent, nextProp), updatePayload = [ + CHILDREN, + nextProp + ]) : "number" == typeof nextProp && domElement.textContent !== "" + nextProp && (suppressHydrationWarning || warnForTextDifference(domElement.textContent, nextProp), updatePayload = [ + CHILDREN, + "" + nextProp + ]); + else if (registrationNameDependencies.hasOwnProperty(propKey)) null != nextProp && ("function" != typeof nextProp && warnForInvalidEventListener(propKey, nextProp), "onScroll" === propKey && listenToNonDelegatedEvent("scroll", domElement)); + else if ("boolean" == typeof isCustomComponentTag) { + var serverValue = void 0, propertyInfo = getPropertyInfo(propKey); + if (suppressHydrationWarning) ; + else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || "value" === propKey || "checked" === propKey || "selected" === propKey) ; + else if (propKey === DANGEROUSLY_SET_INNER_HTML) { + var serverHTML = domElement.innerHTML, nextHtml = nextProp ? nextProp[HTML$1] : void 0; + if (null != nextHtml) { + var expectedHTML = normalizeHTML(domElement, nextHtml); + expectedHTML !== serverHTML && warnForPropDifference(propKey, serverHTML, expectedHTML); + } + } else if (propKey === STYLE) { + if (extraAttributeNames.delete(propKey), canDiffStyleForHydrationWarning) { + var expectedStyle = function(styles) { + var serialized = "", delimiter = ""; + for(var styleName in styles)if (styles.hasOwnProperty(styleName)) { + var styleValue = styles[styleName]; + if (null != styleValue) { + var isCustomProperty = 0 === styleName.indexOf("--"); + serialized += delimiter + (isCustomProperty ? styleName : styleName.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-")) + ":" + dangerousStyleValue(styleName, styleValue, isCustomProperty), delimiter = ";"; + } } - } - return serialized || null; - }(nextProp); - expectedStyle !== (serverValue = domElement.getAttribute("style")) && warnForPropDifference(propKey, serverValue, expectedStyle); - } - } else if (isCustomComponentTag) extraAttributeNames.delete(propKey.toLowerCase()), serverValue = getValueForAttribute(domElement, propKey, nextProp), nextProp !== serverValue && warnForPropDifference(propKey, serverValue, nextProp); - else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { - var isMismatchDueToBadCasing = !1; - if (null !== propertyInfo) extraAttributeNames.delete(propertyInfo.attributeName), serverValue = function(node, name, expected, propertyInfo) { - if (propertyInfo.mustUseProperty) return node[propertyInfo.propertyName]; - propertyInfo.sanitizeURL && sanitizeURL("" + expected); - var attributeName = propertyInfo.attributeName, stringValue = null; - if (4 === propertyInfo.type) { - if (node.hasAttribute(attributeName)) { - var value = node.getAttribute(attributeName); - return "" === value || (shouldRemoveAttribute(name, expected, propertyInfo, !1) ? value : value === "" + expected ? expected : value); - } - } else if (node.hasAttribute(attributeName)) { - if (shouldRemoveAttribute(name, expected, propertyInfo, !1)) return node.getAttribute(attributeName); - if (3 === propertyInfo.type) return expected; - stringValue = node.getAttribute(attributeName); + return serialized || null; + }(nextProp); + expectedStyle !== (serverValue = domElement.getAttribute("style")) && warnForPropDifference(propKey, serverValue, expectedStyle); } - return shouldRemoveAttribute(name, expected, propertyInfo, !1) ? null === stringValue ? expected : stringValue : stringValue === "" + expected ? expected : stringValue; - }(domElement, propKey, nextProp, propertyInfo); - else { - var ownNamespace = parentNamespace; - if (ownNamespace === HTML_NAMESPACE && (ownNamespace = getIntrinsicNamespace(tag)), ownNamespace === HTML_NAMESPACE) extraAttributeNames.delete(propKey.toLowerCase()); + } else if (isCustomComponentTag) extraAttributeNames.delete(propKey.toLowerCase()), serverValue = getValueForAttribute(domElement, propKey, nextProp), nextProp !== serverValue && warnForPropDifference(propKey, serverValue, nextProp); + else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) { + var isMismatchDueToBadCasing = !1; + if (null !== propertyInfo) extraAttributeNames.delete(propertyInfo.attributeName), serverValue = function(node, name, expected, propertyInfo) { + if (propertyInfo.mustUseProperty) return node[propertyInfo.propertyName]; + propertyInfo.sanitizeURL && sanitizeURL("" + expected); + var attributeName = propertyInfo.attributeName, stringValue = null; + if (4 === propertyInfo.type) { + if (node.hasAttribute(attributeName)) { + var value = node.getAttribute(attributeName); + return "" === value || (shouldRemoveAttribute(name, expected, propertyInfo, !1) ? value : value === "" + expected ? expected : value); + } + } else if (node.hasAttribute(attributeName)) { + if (shouldRemoveAttribute(name, expected, propertyInfo, !1)) return node.getAttribute(attributeName); + if (3 === propertyInfo.type) return expected; + stringValue = node.getAttribute(attributeName); + } + return shouldRemoveAttribute(name, expected, propertyInfo, !1) ? null === stringValue ? expected : stringValue : stringValue === "" + expected ? expected : stringValue; + }(domElement, propKey, nextProp, propertyInfo); else { - var standardName = function(propName) { - var lowerCasedName = propName.toLowerCase(); - return possibleStandardNames.hasOwnProperty(lowerCasedName) && possibleStandardNames[lowerCasedName] || null; - }(propKey); - null !== standardName && standardName !== propKey && (isMismatchDueToBadCasing = !0, extraAttributeNames.delete(standardName)), extraAttributeNames.delete(propKey); + var ownNamespace = parentNamespace; + if (ownNamespace === HTML_NAMESPACE && (ownNamespace = getIntrinsicNamespace(tag)), ownNamespace === HTML_NAMESPACE) extraAttributeNames.delete(propKey.toLowerCase()); + else { + var standardName = function(propName) { + var lowerCasedName = propName.toLowerCase(); + return possibleStandardNames.hasOwnProperty(lowerCasedName) && possibleStandardNames[lowerCasedName] || null; + }(propKey); + null !== standardName && standardName !== propKey && (isMismatchDueToBadCasing = !0, extraAttributeNames.delete(standardName)), extraAttributeNames.delete(propKey); + } + serverValue = getValueForAttribute(domElement, propKey, nextProp); } - serverValue = getValueForAttribute(domElement, propKey, nextProp); + nextProp === serverValue || isMismatchDueToBadCasing || warnForPropDifference(propKey, serverValue, nextProp); } - nextProp === serverValue || isMismatchDueToBadCasing || warnForPropDifference(propKey, serverValue, nextProp); } } - } - switch(extraAttributeNames.size > 0 && !suppressHydrationWarning && warnForExtraAttributes(extraAttributeNames), tag){ - case "input": - track(domElement), postMountWrapper(domElement, rawProps, !0); - break; - case "textarea": - track(domElement), postMountWrapper$3(domElement); - break; - case "select": - case "option": - break; - default: - "function" == typeof rawProps.onClick && trapClickOnNonInteractiveElement(domElement); - } - return updatePayload; - }(instance, type1, props, currentHostContext.namespace), workInProgress.updateQueue = updatePayload, null !== updatePayload && markUpdate(workInProgress); - else { - var instance, type1, props, updatePayload, instance1 = function(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { + switch(extraAttributeNames.size > 0 && !suppressHydrationWarning && warnForExtraAttributes(extraAttributeNames), tag){ + case "input": + track(domElement), postMountWrapper(domElement, rawProps, !0); + break; + case "textarea": + track(domElement), postMountWrapper$3(domElement); + break; + case "select": + case "option": + break; + default: + "function" == typeof rawProps.onClick && trapClickOnNonInteractiveElement(domElement); + } + return updatePayload; + }(instance, type1, props, hostContext.namespace), workInProgress.updateQueue = updatePayload, null !== updatePayload) markUpdate(workInProgress); + } else { + var instance, type1, props, rootContainerInstance1, hostContext, hostInst, node, props1, updatePayload, instance1 = function(type, props, rootContainerInstance, hostContext, internalInstanceHandle) { if (validateDOMNesting(type, null, hostContext.ancestorInfo), "string" == typeof props.children || "number" == typeof props.children) { - var string = "" + props.children, ownAncestorInfo = updatedAncestorInfo(hostContext.ancestorInfo, type); + var hostInst, node, props1, string = "" + props.children, ownAncestorInfo = updatedAncestorInfo(hostContext.ancestorInfo, type); validateDOMNesting(null, string, ownAncestorInfo); } var domElement = function(type, props, rootContainerElement, parentNamespace) { @@ -6921,7 +6919,7 @@ } else domElement = ownerDocument.createElementNS(namespaceURI, type); return namespaceURI !== HTML_NAMESPACE || isCustomComponentTag || "[object HTMLUnknownElement]" !== Object.prototype.toString.call(domElement) || Object.prototype.hasOwnProperty.call(warnedUnknownTags, type) || (warnedUnknownTags[type] = !0, error("The tag <%s> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.", type)), domElement; }(type, props, rootContainerInstance, hostContext.namespace); - return domElement[internalInstanceKey] = internalInstanceHandle, domElement[internalPropsKey] = props, domElement; + return hostInst = internalInstanceHandle, domElement[internalInstanceKey] = hostInst, node = domElement, props1 = props, node[internalPropsKey] = props1, domElement; }(type, newProps, rootContainerInstance, currentHostContext, workInProgress); appendAllChildren(instance1, workInProgress, !1, !1), workInProgress.stateNode = instance1, !function(domElement, tag, rawProps, rootContainerElement) { var element, props, value, props1, isCustomComponentTag = isCustomComponent(tag, rawProps); @@ -7001,9 +6999,9 @@ updateHostText$1(current, workInProgress, oldText, newProps); } else { if ("string" != typeof newProps && !(null !== workInProgress.stateNode)) throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."); - var hostInst, textNode, _rootContainerInstance = getRootHostContainer(), _currentHostContext = getHostContext(); + var hostInst1, textNode, _rootContainerInstance = getRootHostContainer(), _currentHostContext = getHostContext(); if (popHydrationState(workInProgress)) (function(fiber) { - var textInstance = fiber.stateNode, textContent = fiber.memoizedProps, shouldUpdate = (textInstance[internalInstanceKey] = fiber, textInstance.nodeValue !== textContent); + var hostInst, textInstance = fiber.stateNode, textContent = fiber.memoizedProps, shouldUpdate = (hostInst = fiber, textInstance[internalInstanceKey] = hostInst, textInstance.nodeValue !== textContent); if (shouldUpdate) { var returnFiber = hydrationParentFiber; if (null !== returnFiber) switch(returnFiber.tag){ @@ -7019,7 +7017,7 @@ return shouldUpdate; })(workInProgress) && markUpdate(workInProgress); else { - workInProgress.stateNode = (validateDOMNesting(null, newProps, _currentHostContext.ancestorInfo), hostInst = workInProgress, (textNode = getOwnerDocumentFromRootContainer(_rootContainerInstance).createTextNode(newProps))[internalInstanceKey] = hostInst, textNode); + workInProgress.stateNode = (validateDOMNesting(null, newProps, _currentHostContext.ancestorInfo), hostInst1 = workInProgress, (textNode = getOwnerDocumentFromRootContainer(_rootContainerInstance).createTextNode(newProps))[internalInstanceKey] = hostInst1, textNode); } } return null;