!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).jsVectorMap=e()}(this,(function(){"use strict";Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),i=e.length;--i>=0&&e.item(i)!==this;);return i>-1}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(null==t)throw new TypeError("Cannot convert first argument to object");for(var e=Object(t),i=1;ithis.max&&(this.max=e),e>10||1,e*=75;var s=i.container.getBoundingClientRect(),n=t.pageX-s.left-window.pageXOffset,r=t.pageY-s.top-window.pageYOffset,o=Math.pow(1+a.params.zoomOnScrollSpeed/1e3,-1.5*e);a.tooltip&&a.tooltip.hide(),a.setScale(a.scale*o,n,r),t.preventDefault()}))},handleElementEvents:function(){var t=this,e=this,i=this.container;w.delegate(i,"mousedown",".jvm-element",(function(){t.isBeingDragged=!1})),w.delegate(i,"mouseover mouseout",".jvm-element",(function(t){var i=x(e,this,!0),s=e.params.showTooltip;"mouseover"===t.type?t.defaultPrevented||(i.element.hover(!0),s&&(e.tooltip.text(i.tooltipText),e.tooltip.show(),e.emit(i.event,[e.tooltip,i.code]))):(i.element.hover(!1),s&&e.tooltip.hide())})),w.delegate(i,"mouseup",".jvm-element",(function(t){var i=x(e,this);if(!e.isBeingDragged&&!t.defaultPrevented&&("region"===i.type&&e.params.regionsSelectable||"marker"===i.type&&e.params.markersSelectable)){var s=i.element;e.params[i.type+"sSelectableOne"]&&e.clearSelected(i.type+"s"),i.element.isSelected?s.select(!1):s.select(!0),e.emit(i.event,[i.code,s.isSelected,e.getSelected(i.type+"s")])}}))},handleZoomButtons:function(){var t=this,e=this,i=l("div","jvm-zoom-btn jvm-zoomin","+",!0),s=l("div","jvm-zoom-btn jvm-zoomout","−",!0);this.container.appendChild(i),this.container.appendChild(s),w.on(i,"click",(function(){t.setScale(e.scale*e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)})),w.on(s,"click",(function(){t.setScale(e.scale/e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)}))},bindContainerTouchEvents:function(){var t,e,i,s,a,n,r,o=this,h=function(h){var l,c,u,p,d=h.touches;if("touchstart"==h.type&&(r=0),1==d.length)1==r&&(u=o.transX,p=o.transY,o.transX-=(i-d[0].pageX)/o.scale,o.transY-=(s-d[0].pageY)/o.scale,o.tooltip.hide(),o.applyTransform(),u==o.transX&&p==o.transY||h.preventDefault()),i=d[0].pageX,s=d[0].pageY;else if(2==d.length)if(2==r)c=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2))/e,o.setScale(t*c,a,n),o.tooltip.hide(),h.preventDefault();else{var f=o.container.selector.getBoundingClientRect();l={top:f.top+window.scrollY,left:f.left+window.scrollX},a=d[0].pageX>d[1].pageX?d[1].pageX+(d[0].pageX-d[1].pageX)/2:d[0].pageX+(d[1].pageX-d[0].pageX)/2,n=d[0].pageY>d[1].pageY?d[1].pageY+(d[0].pageY-d[1].pageY)/2:d[0].pageY+(d[1].pageY-d[0].pageY)/2,a-=l.left,n-=l.top,t=o.scale,e=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2))}r=d.length};this.container.on("touchstart",h).on("touchmove",h)},createRegions:function(){var t,e;for(t in this.regionLabelsGroup=this.regionLabelsGroup||this.canvas.createGroup("jvm-regions-labels-group"),this.mapData.paths)e=new M({map:this,code:t,path:this.mapData.paths[t].path,style:u({},this.params.regionStyle),labelStyle:this.params.regionLabelStyle,labelsGroup:this.regionLabelsGroup,label:this.params.labels&&this.params.labels.regions}),this.regions[t]={config:this.mapData.paths[t],element:e}},createLines:function(t,e,i){var s=this;void 0===i&&(i=!1);var a,n=!1,r=!1;for(var o in this.linesGroup=this.linesGroup||this.canvas.createGroup("jvm-lines-group"),t){var h=t[o];for(var l in e){var c=i?e[l].config:e[l];c.name===h.from&&(n=this.getMarkerPosition(c)),c.name===h.to&&(r=this.getMarkerPosition(c))}!1!==n&&!1!==r&&(a=new _({index:o,map:this,style:u({initial:this.params.lineStyle},{initial:h.style||{}},!0),x1:n.x,y1:n.y,x2:r.x,y2:r.y,group:this.linesGroup}),i&&Object.keys(this.lines).forEach((function(e){e===j(t[0].from,t[0].to)&&s.lines[e].element.remove()})),this.lines[j(h.from,h.to)]={element:a,config:h})}},createMarkers:function(t,e){var i,s,a,n,r=this;for(var o in void 0===t&&(t={}),void 0===e&&(e=!1),this.markersGroup=this.markersGroup||this.canvas.createGroup("jvm-markers-group"),this.markerLabelsGroup=this.markerLabelsGroup||this.canvas.createGroup("jvm-markers-labels-group"),t){if(i=t[o],a=this.getMarkerPosition(i),n=i.coords.join(":"),e){if(Object.keys(this.markers).filter((function(t){return r.markers[t]._uid===n})).length)continue;o=Object.keys(this.markers).length}!1!==a&&(s=new C({index:o,map:this,style:u(this.params.markerStyle,{initial:i.style||{}},!0),label:this.params.labels&&this.params.labels.markers,labelsGroup:this.markerLabelsGroup,cx:a.x,cy:a.y,group:this.markersGroup,marker:i,isRecentlyCreated:e}),this.markers[o]&&this.removeMarkers([o]),this.markers[o]={_uid:n,config:i,element:s})}},createSeries:function(){for(var t in this.series={markers:[],regions:[]},this.params.series)for(var e=0;ee?this.transY=e:this.transYt?this.transX=t:this.transXthis.defaultWidth/this.defaultHeight?(this.baseScale=this.height/this.defaultHeight,this.baseTransX=Math.abs(this.width-this.defaultWidth*this.baseScale)/(2*this.baseScale)):(this.baseScale=this.width/this.defaultWidth,this.baseTransY=Math.abs(this.height-this.defaultHeight*this.baseScale)/(2*this.baseScale)),this.scale*=this.baseScale/t,this.transX*=this.baseScale/t,this.transY*=this.baseScale/t},setScale:function(t,e,i,s,a){var n,r,o,h,l,c,u,p,d,f,m=this,g=0,v=Math.abs(Math.round(60*(t-this.scale)/Math.max(t,this.scale)));t>this.params.zoomMax*this.baseScale?t=this.params.zoomMax*this.baseScale:t0?(o=this.scale,h=(t-o)/v,l=this.transX*this.scale,u=this.transY*this.scale,c=(d*t-l)/v,p=(f*t-u)/v,r=setInterval((function(){g+=1,m.scale=o+h*g,m.transX=(l+c*g)/m.scale,m.transY=(u+p*g)/m.scale,m.applyTransform(),g==v&&(clearInterval(r),m.emit("viewport:changed",[m.scale,m.transX,m.transY]))}),10)):(this.transX=d,this.transY=f,this.scale=t,this.applyTransform(),this.emit("viewport:changed",[this.scale,this.transX,this.transY]))},updateSize:function(){this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.resize(),this.canvas.setSize(this.width,this.height),this.applyTransform()},coordsToPoint:function(t,e){var i,s,a,n=D.maps[this.params.map].projection,r=n.centralMeridian;return i=O[n.type](t,e,r),!!(s=this.getInsetForPoint(i.x,i.y))&&(a=s.bbox,i.x=(i.x-a[0].x)/(a[1].x-a[0].x)*s.width*this.scale,i.y=(i.y-a[0].y)/(a[1].y-a[0].y)*s.height*this.scale,{x:i.x+this.transX*this.scale+s.left*this.scale,y:i.y+this.transY*this.scale+s.top*this.scale})},getInsetForPoint:function(t,e){var i,s,a=D.maps[this.params.map].insets;for(i=0;i(s=a[i].bbox)[0].x&&ts[0].y&&e