(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=0;i--){if(this.eventListeners.hasOwnProperty(haltEventListeners[i])){delete this.eventListeners[haltEventListeners[i]];}}}} for(var event in this.eventListeners){(this.options.eventsListenerElement||this.svg).addEventListener(event,this.eventListeners[event],!this.options.preventMouseEventsDefault?passiveListenerOption:false);} if(this.options.mouseWheelZoomEnabled){this.options.mouseWheelZoomEnabled=false;this.enableMouseWheelZoom();}};SvgPanZoom.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var that=this;this.wheelListener=function(evt){return that.handleMouseWheel(evt);};var isPassiveListener=!this.options.preventMouseEventsDefault;Wheel.on(this.options.eventsListenerElement||this.svg,this.wheelListener,isPassiveListener);this.options.mouseWheelZoomEnabled=true;}};SvgPanZoom.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var isPassiveListener=!this.options.preventMouseEventsDefault;Wheel.off(this.options.eventsListenerElement||this.svg,this.wheelListener,isPassiveListener);this.options.mouseWheelZoomEnabled=false;}};SvgPanZoom.prototype.handleMouseWheel=function(evt){if(!this.options.zoomEnabled||this.state!=="none"){return;} if(this.options.preventMouseEventsDefault){if(evt.preventDefault){evt.preventDefault();}else{evt.returnValue=false;}} var delta=evt.deltaY||1,timeDelta=Date.now()-this.lastMouseWheelEventTime,divider=3+Math.max(0,30-timeDelta);this.lastMouseWheelEventTime=Date.now();if("deltaMode"in evt&&evt.deltaMode===0&&evt.wheelDelta){delta=evt.deltaY===0?0:Math.abs(evt.wheelDelta)/evt.deltaY;} delta=-0.30?1:-1)*Math.log(Math.abs(delta)+10))/divider;var inversedScreenCTM=this.svg.getScreenCTM().inverse(),relativeMousePoint=SvgUtils.getEventPoint(evt,this.svg).matrixTransform(inversedScreenCTM),zoom=Math.pow(1+this.options.zoomScaleSensitivity,-1*delta);this.zoomAtPoint(zoom,relativeMousePoint);};SvgPanZoom.prototype.zoomAtPoint=function(zoomScale,point,zoomAbsolute){var originalState=this.viewport.getOriginalState();if(!zoomAbsolute){if(this.getZoom()*zoomScalethis.options.maxZoom*originalState.zoom){zoomScale=(this.options.maxZoom*originalState.zoom)/this.getZoom();}}else{zoomScale=Math.max(this.options.minZoom*originalState.zoom,Math.min(this.options.maxZoom*originalState.zoom,zoomScale));zoomScale=zoomScale/this.getZoom();} var oldCTM=this.viewport.getCTM(),relativePoint=point.matrixTransform(oldCTM.inverse()),modifier=this.svg.createSVGMatrix().translate(relativePoint.x,relativePoint.y).scale(zoomScale).translate(-relativePoint.x,-relativePoint.y),newCTM=oldCTM.multiply(modifier);if(newCTM.a!==oldCTM.a){this.viewport.setCTM(newCTM);}};SvgPanZoom.prototype.zoom=function(scale,absolute){this.zoomAtPoint(scale,SvgUtils.getSvgCenterPoint(this.svg,this.width,this.height),absolute);};SvgPanZoom.prototype.publicZoom=function(scale,absolute){if(absolute){scale=this.computeFromRelativeZoom(scale);} this.zoom(scale,absolute);};SvgPanZoom.prototype.publicZoomAtPoint=function(scale,point,absolute){if(absolute){scale=this.computeFromRelativeZoom(scale);} if(Utils.getType(point)!=="SVGPoint"){if("x"in point&&"y"in point){point=SvgUtils.createSVGPoint(this.svg,point.x,point.y);}else{throw new Error("Given point is invalid");}} this.zoomAtPoint(scale,point,absolute);};SvgPanZoom.prototype.getZoom=function(){return this.viewport.getZoom();};SvgPanZoom.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom();};SvgPanZoom.prototype.computeFromRelativeZoom=function(zoom){return zoom*this.viewport.getOriginalState().zoom;};SvgPanZoom.prototype.resetZoom=function(){var originalState=this.viewport.getOriginalState();this.zoom(originalState.zoom,true);};SvgPanZoom.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState());};SvgPanZoom.prototype.reset=function(){this.resetZoom();this.resetPan();};SvgPanZoom.prototype.handleDblClick=function(evt){if(this.options.preventMouseEventsDefault){if(evt.preventDefault){evt.preventDefault();}else{evt.returnValue=false;}} if(this.options.controlIconsEnabled){var targetClass=evt.target.getAttribute("class")||"";if(targetClass.indexOf("svg-pan-zoom-control")>-1){return false;}} var zoomFactor;if(evt.shiftKey){zoomFactor=1/((1+this.options.zoomScaleSensitivity)*2);}else{zoomFactor=(1+this.options.zoomScaleSensitivity)*2;} var point=SvgUtils.getEventPoint(evt,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(zoomFactor,point);};SvgPanZoom.prototype.handleMouseDown=function(evt,prevEvt){if(this.options.preventMouseEventsDefault){if(evt.preventDefault){evt.preventDefault();}else{evt.returnValue=false;}} Utils.mouseAndTouchNormalize(evt,this.svg);if(this.options.dblClickZoomEnabled&&Utils.isDblClick(evt,prevEvt)){this.handleDblClick(evt);}else{this.state="pan";this.firstEventCTM=this.viewport.getCTM();this.stateOrigin=SvgUtils.getEventPoint(evt,this.svg).matrixTransform(this.firstEventCTM.inverse());}};SvgPanZoom.prototype.handleMouseMove=function(evt){if(this.options.preventMouseEventsDefault){if(evt.preventDefault){evt.preventDefault();}else{evt.returnValue=false;}} if(this.state==="pan"&&this.options.panEnabled){var point=SvgUtils.getEventPoint(evt,this.svg).matrixTransform(this.firstEventCTM.inverse()),viewportCTM=this.firstEventCTM.translate(point.x-this.stateOrigin.x,point.y-this.stateOrigin.y);this.viewport.setCTM(viewportCTM);}};SvgPanZoom.prototype.handleMouseUp=function(evt){if(this.options.preventMouseEventsDefault){if(evt.preventDefault){evt.preventDefault();}else{evt.returnValue=false;}} if(this.state==="pan"){this.state="none";}};SvgPanZoom.prototype.fit=function(){var viewBox=this.viewport.getViewBox(),newScale=Math.min(this.width/viewBox.width,this.height/viewBox.height);this.zoom(newScale,true);};SvgPanZoom.prototype.contain=function(){var viewBox=this.viewport.getViewBox(),newScale=Math.max(this.width/viewBox.width,this.height/viewBox.height);this.zoom(newScale,true);};SvgPanZoom.prototype.center=function(){var viewBox=this.viewport.getViewBox(),offsetX=(this.width-(viewBox.width+viewBox.x*2)*this.getZoom())*0.5,offsetY=(this.height-(viewBox.height+viewBox.y*2)*this.getZoom())*0.5;this.getPublicInstance().pan({x:offsetX,y:offsetY});};SvgPanZoom.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache();};SvgPanZoom.prototype.pan=function(point){var viewportCTM=this.viewport.getCTM();viewportCTM.e=point.x;viewportCTM.f=point.y;this.viewport.setCTM(viewportCTM);};SvgPanZoom.prototype.panBy=function(point){var viewportCTM=this.viewport.getCTM();viewportCTM.e+=point.x;viewportCTM.f+=point.y;this.viewport.setCTM(viewportCTM);};SvgPanZoom.prototype.getPan=function(){var state=this.viewport.getState();return{x:state.x,y:state.y};};SvgPanZoom.prototype.resize=function(){var boundingClientRectNormalized=SvgUtils.getBoundingClientRectNormalized(this.svg);this.width=boundingClientRectNormalized.width;this.height=boundingClientRectNormalized.height;var viewport=this.viewport;viewport.options.width=this.width;viewport.options.height=this.height;viewport.processCTM();if(this.options.controlIconsEnabled){this.getPublicInstance().disableControlIcons();this.getPublicInstance().enableControlIcons();}};SvgPanZoom.prototype.destroy=function(){var that=this;this.beforeZoom=null;this.onZoom=null;this.beforePan=null;this.onPan=null;this.onUpdatedCTM=null;if(this.options.customEventsHandler!=null){this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});} for(var event in this.eventListeners){(this.options.eventsListenerElement||this.svg).removeEventListener(event,this.eventListeners[event],!this.options.preventMouseEventsDefault?passiveListenerOption:false);} this.disableMouseWheelZoom();this.getPublicInstance().disableControlIcons();this.reset();instancesStore=instancesStore.filter(function(instance){return instance.svg!==that.svg;});delete this.options;delete this.viewport;delete this.publicInstance;delete this.pi;this.getPublicInstance=function(){return null;};};SvgPanZoom.prototype.getPublicInstance=function(){var that=this;if(!this.publicInstance){this.publicInstance=this.pi={enablePan:function(){that.options.panEnabled=true;return that.pi;},disablePan:function(){that.options.panEnabled=false;return that.pi;},isPanEnabled:function(){return!!that.options.panEnabled;},pan:function(point){that.pan(point);return that.pi;},panBy:function(point){that.panBy(point);return that.pi;},getPan:function(){return that.getPan();},setBeforePan:function(fn){that.options.beforePan=fn===null?null:Utils.proxy(fn,that.publicInstance);return that.pi;},setOnPan:function(fn){that.options.onPan=fn===null?null:Utils.proxy(fn,that.publicInstance);return that.pi;},enableZoom:function(){that.options.zoomEnabled=true;return that.pi;},disableZoom:function(){that.options.zoomEnabled=false;return that.pi;},isZoomEnabled:function(){return!!that.options.zoomEnabled;},enableControlIcons:function(){if(!that.options.controlIconsEnabled){that.options.controlIconsEnabled=true;ControlIcons.enable(that);} return that.pi;},disableControlIcons:function(){if(that.options.controlIconsEnabled){that.options.controlIconsEnabled=false;ControlIcons.disable(that);} return that.pi;},isControlIconsEnabled:function(){return!!that.options.controlIconsEnabled;},enableDblClickZoom:function(){that.options.dblClickZoomEnabled=true;return that.pi;},disableDblClickZoom:function(){that.options.dblClickZoomEnabled=false;return that.pi;},isDblClickZoomEnabled:function(){return!!that.options.dblClickZoomEnabled;},enableMouseWheelZoom:function(){that.enableMouseWheelZoom();return that.pi;},disableMouseWheelZoom:function(){that.disableMouseWheelZoom();return that.pi;},isMouseWheelZoomEnabled:function(){return!!that.options.mouseWheelZoomEnabled;},setZoomScaleSensitivity:function(scale){that.options.zoomScaleSensitivity=scale;return that.pi;},setMinZoom:function(zoom){that.options.minZoom=zoom;return that.pi;},setMaxZoom:function(zoom){that.options.maxZoom=zoom;return that.pi;},setBeforeZoom:function(fn){that.options.beforeZoom=fn===null?null:Utils.proxy(fn,that.publicInstance);return that.pi;},setOnZoom:function(fn){that.options.onZoom=fn===null?null:Utils.proxy(fn,that.publicInstance);return that.pi;},zoom:function(scale){that.publicZoom(scale,true);return that.pi;},zoomBy:function(scale){that.publicZoom(scale,false);return that.pi;},zoomAtPoint:function(scale,point){that.publicZoomAtPoint(scale,point,true);return that.pi;},zoomAtPointBy:function(scale,point){that.publicZoomAtPoint(scale,point,false);return that.pi;},zoomIn:function(){this.zoomBy(1+that.options.zoomScaleSensitivity);return that.pi;},zoomOut:function(){this.zoomBy(1/(1+that.options.zoomScaleSensitivity));return that.pi;},getZoom:function(){return that.getRelativeZoom();},setOnUpdatedCTM:function(fn){that.options.onUpdatedCTM=fn===null?null:Utils.proxy(fn,that.publicInstance);return that.pi;},resetZoom:function(){that.resetZoom();return that.pi;},resetPan:function(){that.resetPan();return that.pi;},reset:function(){that.reset();return that.pi;},fit:function(){that.fit();return that.pi;},contain:function(){that.contain();return that.pi;},center:function(){that.center();return that.pi;},updateBBox:function(){that.updateBBox();return that.pi;},resize:function(){that.resize();return that.pi;},getSizes:function(){return{width:that.width,height:that.height,realZoom:that.getZoom(),viewBox:that.viewport.getViewBox()};},destroy:function(){that.destroy();return that.pi;}};} return this.publicInstance;};var instancesStore=[];var svgPanZoom=function(elementOrSelector,options){var svg=Utils.getSvg(elementOrSelector);if(svg===null){return null;}else{for(var i=instancesStore.length-1;i>=0;i--){if(instancesStore[i].svg===svg){return instancesStore[i].instance.getPublicInstance();}} instancesStore.push({svg:svg,instance:new SvgPanZoom(svg,options)});return instancesStore[instancesStore.length-1].instance.getPublicInstance();}};module.exports=svgPanZoom;},{"./control-icons":1,"./shadow-viewport":2,"./svg-utilities":5,"./uniwheel":6,"./utilities":7}],5:[function(require,module,exports){var Utils=require("./utilities"),_browser="unknown";if(/*@cc_on!@*/false||!!document.documentMode){_browser="ie";} module.exports={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(svg){if(svg.clientWidth&&svg.clientHeight){return{width:svg.clientWidth,height:svg.clientHeight};}else if(!!svg.getBoundingClientRect()){return svg.getBoundingClientRect();}else{throw new Error("Cannot get BoundingClientRect for SVG.");}},getOrCreateViewport:function(svg,selector){var viewport=null;if(Utils.isElement(selector)){viewport=selector;}else{viewport=svg.querySelector(selector);} if(!viewport){var childNodes=Array.prototype.slice.call(svg.childNodes||svg.children).filter(function(el){return el.nodeName!=="defs"&&el.nodeName!=="#text";});if(childNodes.length===1&&childNodes[0].nodeName==="g"&&childNodes[0].getAttribute("transform")===null){viewport=childNodes[0];}} if(!viewport){var viewportId="viewport-"+new Date().toISOString().replace(/\D/g,"");viewport=document.createElementNS(this.svgNS,"g");viewport.setAttribute("id",viewportId);var svgChildren=svg.childNodes||svg.children;if(!!svgChildren&&svgChildren.length>0){for(var i=svgChildren.length;i>0;i--){if(svgChildren[svgChildren.length-i].nodeName!=="defs"){viewport.appendChild(svgChildren[svgChildren.length-i]);}}} svg.appendChild(viewport);} var classNames=[];if(viewport.getAttribute("class")){classNames=viewport.getAttribute("class").split(" ");} if(!~classNames.indexOf("svg-pan-zoom_viewport")){classNames.push("svg-pan-zoom_viewport");viewport.setAttribute("class",classNames.join(" "));} return viewport;},setupSvgAttributes:function(svg){svg.setAttribute("xmlns",this.svgNS);svg.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS);svg.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS);if(svg.parentNode!==null){var style=svg.getAttribute("style")||"";if(style.toLowerCase().indexOf("overflow")===-1){svg.setAttribute("style","overflow: hidden; "+style);}}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:Utils.throttle(function(){var allDefs=document.querySelectorAll("defs");var allDefsCount=allDefs.length;for(var i=0;iwait){clearTimeout(timeout);timeout=null;previous=now;result=func.apply(context,args);if(!timeout){context=args=null;}}else if(!timeout&&options.trailing!==false){timeout=setTimeout(later,remaining);} return result;};},createRequestAnimationFrame:function(refreshRate){var timeout=null;if(refreshRate!=="auto"&&refreshRate<60&&refreshRate>1){timeout=Math.floor(1000/refreshRate);} if(timeout===null){return window.requestAnimationFrame||requestTimeout(33);}else{return requestTimeout(timeout);}}};function requestTimeout(timeout){return function(callback){window.setTimeout(callback,timeout);};}},{}]},{},[3]);