-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvasmap.bundle.min.js
1 lines (1 loc) · 64.3 KB
/
canvasmap.bundle.min.js
1
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.canvasmap=f()}})(function(){var define,module,exports;return 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<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;runClearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(name){return[]};process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],2:[function(require,module,exports){(function(setImmediate,clearImmediate){var nextTick=require("process/browser.js").nextTick;var apply=Function.prototype.apply;var slice=Array.prototype.slice;var immediateIds={};var nextImmediateId=0;exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout)};exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval)};exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close()};function Timeout(id,clearFn){this._id=id;this._clearFn=clearFn}Timeout.prototype.unref=Timeout.prototype.ref=function(){};Timeout.prototype.close=function(){this._clearFn.call(window,this._id)};exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId);item._idleTimeout=msecs};exports.unenroll=function(item){clearTimeout(item._idleTimeoutId);item._idleTimeout=-1};exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;if(msecs>=0){item._idleTimeoutId=setTimeout(function onTimeout(){if(item._onTimeout)item._onTimeout()},msecs)}};exports.setImmediate=typeof setImmediate==="function"?setImmediate:function(fn){var id=nextImmediateId++;var args=arguments.length<2?false:slice.call(arguments,1);immediateIds[id]=true;nextTick(function onNextTick(){if(immediateIds[id]){if(args){fn.apply(null,args)}else{fn.call(null)}exports.clearImmediate(id)}});return id};exports.clearImmediate=typeof clearImmediate==="function"?clearImmediate:function(id){delete immediateIds[id]}}).call(this,require("timers").setImmediate,require("timers").clearImmediate)},{"process/browser.js":1,timers:2}],3:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();exports.__esModule=true;var canvas_settings_interface_1=require("../models/canvas-settings.interface");var CoordResolver_1=require("../interface/CoordResolver");var CartCoordResolver=function(_super){__extends(CartCoordResolver,_super);function CartCoordResolver(preloadedImages){var _this=_super.call(this,preloadedImages)||this;_this.preloadedImages=preloadedImages;return _this}CartCoordResolver.prototype.toCoord=function(px,settings,settingS,config,map,result){var TILE_WIDTH=settings.tileSize[0]*settings.scale;var TILE_HEIGHT=TILE_WIDTH;var BORDER_TOP=settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]+settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]+settingS.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]/config.maxZoom;var BORDER_LEFT=settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST]+settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]+settingS.offset[canvas_settings_interface_1.ORRIENTATION.WEST]/config.maxZoom;console.log(TILE_WIDTH);result[0]=Math.floor((px[0]-BORDER_LEFT*settings.scale)/TILE_WIDTH);result[1]=Math.floor((px[1]-BORDER_TOP*settings.scale)/TILE_HEIGHT)};CartCoordResolver.prototype.toPixel=function(coors,settings,config,map,result){var TILE_WIDTH=settings.tileSize[0];var TILE_HEIGHT=TILE_WIDTH;var BORDER_TOP=settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH];var BORDER_LEFT=settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST];result[0]=BORDER_LEFT+coors[0]*TILE_WIDTH;result[1]=BORDER_TOP+coors[1]*TILE_HEIGHT};CartCoordResolver.prototype.drawTile=function(ctx,tile,settings,config,map,cb){var _this=this;var co=[];this.toPixel([tile.coord[0],tile.coord[1]],settings,config,map,co);var _loop_1=function(_){if(this_1.preloadedImages[_]){var width=settings.tileSize[0];ctx.drawImage(this_1.preloadedImages[_],co[0],co[1],width,(this_1.preloadedImages[_].height+config.cheat.imgTileHeightAdjustment)/this_1.preloadedImages[_].width*width)}else if(cb){var img_1=new Image;img_1.onload=function(__){_this.preloadedImages[_]=img_1;_this.drawTile(ctx,tile,settings,config,map);cb()};img_1.src="assets/tiles/"+_+".svg"}};var this_1=this;for(var _i=0,_a=tile.layers;_i<_a.length;_i++){var _=_a[_i];_loop_1(_)}};CartCoordResolver.prototype.drawText=function(ctx,tile,settings,config,map,text){if(!tile.name){return}var co=[];this.toPixel([tile.coord[0]+.5,tile.coord[1]+1],settings,config,map,co);ctx.save();ctx.font=Math.floor(config.style.tile.fontSize*settings.tileSize[1])+"px "+config.style.tile.fontFamily;ctx.fillStyle=config.style.tile.fontColor;ctx.translate(co[0]+3,co[1]-3);ctx.rotate(27*(Math.PI/180));ctx.transform(1,0,-.8,1,0,0);ctx.textAlign=config.style.tile.textAlign;ctx.fillText(text,0,0);ctx.restore()};CartCoordResolver.prototype.calcCanvasTileSize=function(settings,map,width,height){return[(width-settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]-settings.border[canvas_settings_interface_1.ORRIENTATION.EAST])/map.size[0],(height-settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]-settings.border[canvas_settings_interface_1.ORRIENTATION.SOUTH])/map.size[1]]};CartCoordResolver.prototype.calcShadowTileSize=function(settings,map,width,height){return[width/map.size[0],height/map.size[1]]};return CartCoordResolver}(CoordResolver_1.CoordResolver);exports.CartCoordResolver=CartCoordResolver},{"../interface/CoordResolver":4,"../models/canvas-settings.interface":11}],4:[function(require,module,exports){"use strict";exports.__esModule=true;var CoordResolver=function(){function CoordResolver(preloadedImages){this.preloadedImages=preloadedImages}CoordResolver.prototype.toCoord=function(px,settings,settingS,config,map,result){};CoordResolver.prototype.toPixel=function(coors,settings,config,map,result){};CoordResolver.prototype.drawTile=function(ctx,tile,settings,config,map,cb){};CoordResolver.prototype.drawText=function(ctx,tile,settings,config,map,text){};CoordResolver.prototype.calcCanvasTileSize=function(settings,map,width,height){return[]};CoordResolver.prototype.calcShadowTileSize=function(settings,map,width,height){return[]};return CoordResolver}();exports.CoordResolver=CoordResolver},{}],5:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();exports.__esModule=true;var canvas_settings_interface_1=require("../models/canvas-settings.interface");var CoordResolver_1=require("../interface/CoordResolver");var IsoCoordResolver=function(_super){__extends(IsoCoordResolver,_super);function IsoCoordResolver(preloadedImages){var _this=_super.call(this,preloadedImages)||this;_this.preloadedImages=preloadedImages;return _this}IsoCoordResolver.prototype.toCoord=function(px,settings,settingS,config,map){console.log(settings);var TILE_WIDTH_HALF=settings.tileSize[0]/2*settings.scale;var TILE_HEIGHT_HALF=TILE_WIDTH_HALF/2;var BORDER_TOP=settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]+settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]+settingS.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]/config.maxZoom;var BORDER_LEFT=settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST]+settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]+settingS.offset[canvas_settings_interface_1.ORRIENTATION.WEST]/config.maxZoom+(settings.parentSize[0]-settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]-settings.border[canvas_settings_interface_1.ORRIENTATION.EAST])/(map.size[0]/map.size[1]+1);return[Math.floor((2*(px[1]-BORDER_TOP*settings.scale)/TILE_WIDTH_HALF+(px[0]-BORDER_LEFT*settings.scale)/TILE_WIDTH_HALF)/2),Math.floor((2*(px[1]-BORDER_TOP*settings.scale)/TILE_HEIGHT_HALF-(px[0]-BORDER_LEFT*settings.scale)/TILE_HEIGHT_HALF)/4)]};IsoCoordResolver.prototype.toPixel=function(coors,settings,config,map,result){var TILE_WIDTH_HALF=settings.tileSize[0]/2;var TILE_HEIGHT_HALF=TILE_WIDTH_HALF/2;var BORDER_TOP=settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH];var BORDER_LEFT=settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST]+settings.parentSize[0]/(map.size[0]/map.size[1]+1);result[0]=BORDER_LEFT+coors[0]*TILE_WIDTH_HALF-coors[1]*TILE_WIDTH_HALF;result[1]=BORDER_TOP+coors[0]*TILE_HEIGHT_HALF+coors[1]*TILE_HEIGHT_HALF};IsoCoordResolver.prototype.drawTile=function(ctx,tile,settings,config,map,cb){var _this=this;var co=[];this.toPixel([tile.coord[0],tile.coord[1]],settings,config,map,co);var _loop_1=function(_){if(this_1.preloadedImages[_]){var width=settings.tileSize[0];ctx.drawImage(this_1.preloadedImages[_],co[0],co[1]-settings.tileSize[1]*config.cheat.imgTileHeightOffsetAdjustment,width,(this_1.preloadedImages[_].height+config.cheat.imgTileHeightAdjustment)/this_1.preloadedImages[_].width*width)}else if(cb){var img_1=new Image;img_1.onload=function(__){_this.preloadedImages[_]=img_1;_this.drawTile(ctx,tile,settings,config,map);cb()};img_1.src="assets/tiles/"+_+".svg"}};var this_1=this;for(var _i=0,_a=tile.layers;_i<_a.length;_i++){var _=_a[_i];_loop_1(_)}};IsoCoordResolver.prototype.drawText=function(ctx,tile,settings,config,map,text){if(!tile.name){return}var co=[];this.toPixel([tile.coord[0]+1.5,tile.coord[1]+1],settings,config,map,co);ctx.save();ctx.font=Math.floor(config.style.tile.fontSize*settings.tileSize[1])+"px "+config.style.tile.fontFamily;ctx.fillStyle=config.style.tile.fontColor;ctx.translate(co[0]+3,co[1]-3);ctx.rotate(27*(Math.PI/180));ctx.transform(1,0,-.8,1,0,0);ctx.textAlign=config.style.tile.textAlign;ctx.fillText(text,0,0);ctx.restore()};IsoCoordResolver.prototype.calcCanvasTileSize=function(settings,map,width){return[(width-settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]-settings.border[canvas_settings_interface_1.ORRIENTATION.EAST])/(map.size[0]+map.size[1])*2,settings.tileSize[1]=settings.tileSize[0]/2]};IsoCoordResolver.prototype.calcShadowTileSize=function(settings,map,width){return[width/(map.size[0]+map.size[1])*2,settings.tileSize[0]/2]};return IsoCoordResolver}(CoordResolver_1.CoordResolver);exports.IsoCoordResolver=IsoCoordResolver},{"../interface/CoordResolver":4,"../models/canvas-settings.interface":11}],6:[function(require,module,exports){"use strict";exports.__esModule=true;var q_1=require("q");var canvas_settings_interface_1=require("../models/canvas-settings.interface");var CanvasRenderer=function(){function CanvasRenderer(res){this.resolver=res}CanvasRenderer.prototype.preload=function(map,config){var _this=this;var loadingImages={};var loading=0;return q_1.Promise(function(resolver){map.tiles.forEach(function(_){return _.layers.forEach(function(__){if(!loadingImages[__]){var img_1=new Image;loading++;loadingImages[__]=true;img_1.onload=function(___){loadingImages[__]=false;_this.resolver.preloadedImages[__]=img_1;if(--loading===0){resolver(true)}};img_1.src="assets/tiles/"+__+".svg"}})});if(config.style.map.backgroundImage){var img_2=new Image;loading++;loadingImages["config.style.map.backgroundImage"]=true;img_2.onload=function(___){loadingImages["config.style.map.backgroundImage"]=false;_this.resolver.preloadedImages["config.style.map.backgroundImage"]=img_2;if(--loading===0){resolver(true)}};img_2.src="assets/"+config.style.map.backgroundImage}if(loading===0){resolver(true)}})};CanvasRenderer.prototype.preloadShadowCanvas2=function(layer){return this.preloadShadowCanvas(layer.set.parentSize[0],layer.set.parentSize[1],layer.set,layer.config,{size:layer.map.size,tiles:[]},layer.el)};CanvasRenderer.prototype.preloadShadowCanvas=function(width,height,settings,config,map,canvas){if(!canvas){canvas=document.createElement("canvas")}settings.offset=[0,0,0,0];settings.tileSize=this.resolver.calcShadowTileSize(settings,map,width,height);var heightModifier=config.topOffset*settings.tileSize[1];canvas.width=width;canvas.height=height+heightModifier;settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]=heightModifier;settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]=0;settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]=0;settings.border[canvas_settings_interface_1.ORRIENTATION.EAST]=0;settings.border[canvas_settings_interface_1.ORRIENTATION.SOUTH]=0;return canvas};CanvasRenderer.prototype.preloadCanvas2=function(layer,dimensions){if(layer.hasOwnProperty("drawAction")){dimensions=dimensions||[layer.set.parentSize[0],layer.set.parentSize[1]];dimensions[0]=Math.min(dimensions[0]*layer.config.maxZoom,layer.config.maxSize);dimensions[1]=Math.min(dimensions[1]*layer.config.maxZoom,layer.config.maxSize/2);if(dimensions[1]>=dimensions[0]/2){layer.set.parentSize[0]=dimensions[0];layer.set.parentSize[1]=dimensions[0]/2}else{layer.set.parentSize[0]=dimensions[1]*2;layer.set.parentSize[1]=dimensions[1]}return this.preloadShadowCanvas(layer.set.parentSize[0],layer.set.parentSize[1],layer.set,layer.config,{size:layer.map.size,tiles:[]},layer.el)}else{dimensions=dimensions||[layer.el.offsetWidth,layer.el.offsetHeight];var ratio=dimensions[0]/dimensions[1];if(dimensions[0]>layer.config.maxSize){dimensions[0]=layer.config.maxSize;dimensions[1]=dimensions[0]/ratio}if(dimensions[1]>layer.config.maxSize/2){dimensions[1]=layer.config.maxSize/2;dimensions[0]=dimensions[1]*ratio}var cvs=this.preloadCanvas(dimensions[0],dimensions[1],layer.set,layer.config,{size:layer.map.size,tiles:[]},layer.el);this.zoom2(0,0,-layer.config.maxZoom,layer);return cvs}};CanvasRenderer.prototype.preloadCanvas=function(width,height,settings,config,map,canvas){if(!canvas){canvas=document.createElement("canvas")}canvas.width=width;canvas.height=height;settings.offset=[0,0,0,0];settings.border=[0,0,0,0];if(width>(height-config.topOffset)*2){settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]=settings.border[canvas_settings_interface_1.ORRIENTATION.EAST]=(width-(height-config.topOffset)*2)/2}else{settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]=settings.border[canvas_settings_interface_1.ORRIENTATION.SOUTH]=(height-config.topOffset-width/2)/2}settings.tileSize=this.resolver.calcCanvasTileSize(settings,map,width,height);return canvas};CanvasRenderer.prototype.resize2=function(addX,addY,layer){this.resize(addX,addY,layer.el,layer.set,layer.config)};CanvasRenderer.prototype.resize=function(addX,addY,canvas,settings,config){settings.parentSize[0]+=addX;settings.parentSize[1]+=addY;canvas.width+=addX;canvas.height+=addY;settings.border[canvas_settings_interface_1.ORRIENTATION.WEST]+=addX/2;settings.border[canvas_settings_interface_1.ORRIENTATION.NORTH]+=addY/2;settings.border[canvas_settings_interface_1.ORRIENTATION.EAST]+=addX/2;settings.border[canvas_settings_interface_1.ORRIENTATION.SOUTH]+=addY/2};CanvasRenderer.prototype.zoom2=function(posX,posY,step,cvs,workaround){this.zoom(posX,posY,step,cvs.el,cvs.set,cvs.config,undefined,workaround)};CanvasRenderer.prototype.zoom=function(posX,posY,step,canvas,settings,config,map,workaround){if(settings.scale+step>=config.maxZoom){step=-(settings.scale-config.maxZoom)}else if(settings.scale+step<=1){step=-(settings.scale-1)}if(step===0){return}var bef=settings.scale;settings.scale=settings.scale+step;settings.offset[canvas_settings_interface_1.ORRIENTATION.EAST]=0;settings.offset[canvas_settings_interface_1.ORRIENTATION.SOUTH]=0;settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST]-=posX*(1-1/settings.scale)-posX*(1-1/bef);settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]-=posY*(1-1/settings.scale)-posY*(1-1/bef);if(settings.scale!==1){settings.offset[canvas_settings_interface_1.ORRIENTATION.EAST]=-settings.parentSize[0]*(settings.scale-1)/settings.scale-settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST];settings.offset[canvas_settings_interface_1.ORRIENTATION.SOUTH]=-settings.parentSize[1]*(settings.scale-1)/settings.scale-settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]}};CanvasRenderer.prototype.move2=function(moveX,moveY,cvs){this.move(moveX,moveY,cvs.el,cvs.set,cvs.config)};CanvasRenderer.prototype.move=function(xStep,yStep,canvas,settings,config){settings.offset[canvas_settings_interface_1.ORRIENTATION.WEST]-=xStep/settings.scale;settings.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]-=yStep/settings.scale;settings.offset[canvas_settings_interface_1.ORRIENTATION.EAST]+=xStep/settings.scale;settings.offset[canvas_settings_interface_1.ORRIENTATION.SOUTH]+=yStep/settings.scale};CanvasRenderer.prototype.copyMap=function(ctxTarget,settings,ctxSource,ctxSourceText,ctxSourceBG,settingsS,config,map){var copy=function(target,set,setSrc,source,cfg){var scale=cfg.maxZoom/set.scale;target.drawImage(source,-(set.offset[canvas_settings_interface_1.ORRIENTATION.WEST]+set.border[canvas_settings_interface_1.ORRIENTATION.WEST])*cfg.maxZoom,-(set.offset[canvas_settings_interface_1.ORRIENTATION.NORTH]+set.border[canvas_settings_interface_1.ORRIENTATION.NORTH])*cfg.maxZoom,set.parentSize[0]*scale,set.parentSize[1]*scale,0,0,set.parentSize[0],set.parentSize[1])};ctxTarget.fillStyle=config.style.map.backgroundColor;ctxTarget.fillRect(0,0,settings.parentSize[0],settings.parentSize[1]);copy(ctxTarget,settings,settingsS,ctxSourceBG,config);copy(ctxTarget,settings,settingsS,ctxSourceText,config);copy(ctxTarget,settings,settingsS,ctxSource,config)};CanvasRenderer.prototype.drawImageLayer2=function(layer,cb){this.drawImageLayer(layer.el.getContext("2d"),layer.set,layer.config,layer.map,cb)};CanvasRenderer.prototype.drawImageLayer=function(ctx,settings,config,map,cb){var _this=this;ctx.clearRect(0,0,settings.parentSize[0]*config.maxZoom,settings.parentSize[1]*config.maxZoom);map.tiles.forEach(function(_){_.coord[0]-=1;_this.drawTile(ctx,_,settings,config,map,cb)})};CanvasRenderer.prototype.drawTextLayer2=function(layer,scale){this.drawTextLayer(layer.el.getContext("2d"),layer.set,layer.config,layer.map,scale||1)};CanvasRenderer.prototype.drawTextLayer=function(ctx,settings,config,map,zoom){var _this=this;ctx.clearRect(0,0,settings.parentSize[0]*config.maxZoom,settings.parentSize[1]*config.maxZoom);map.tiles.forEach(function(_){return _this.drawText(ctx,_,settings,config,map,zoom)})};CanvasRenderer.prototype.drawBackgroundLayer2=function(layer,select){this.drawBackgroundLayer(layer.el.getContext("2d"),layer.set,layer.config,layer.map,select)};CanvasRenderer.prototype.drawBackgroundLayer=function(ctx,settings,config,map,select){var _this=this;var temp=[];ctx.fillStyle=config.style.map.backgroundColor;ctx.fillRect(0,0,settings.parentSize[0]*config.maxZoom,settings.parentSize[1]*config.maxZoom);if(this.resolver.preloadedImages["config.style.map.backgroundImage"]){var zero=[];this.resolver.toPixel([0,0],settings,config,map,zero);this.resolver.toPixel(map.size,settings,config,map,temp);console.log(map.size,zero[0],settings,config,zero[1],temp[0],temp[1]);ctx.drawImage(this.resolver.preloadedImages["config.style.map.backgroundImage"],zero[0],zero[1],temp[0],temp[1])}ctx.fillStyle=config.style.tile.backgroundColor;ctx.strokeStyle=config.style.map.borderColor||config.style.tile.borderColor;ctx.lineWidth=config.style.map.borderWidth||config.style.tile.borderWidth;ctx.beginPath();this.resolver.toPixel([0,0],settings,config,map,temp);ctx.moveTo(temp[0],temp[1]);this.resolver.toPixel([map.size[0],0],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);this.resolver.toPixel([map.size[0],map.size[1]],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);this.resolver.toPixel([0,map.size[1]],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);this.resolver.toPixel([0,0],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);ctx.closePath();ctx.fill();ctx.stroke();if(config.style.tile.borderWidth){ctx.strokeStyle=config.style.tile.borderColor;ctx.lineWidth=config.style.tile.borderWidth;ctx.beginPath();for(var index=1;index<map.size[1];index++){this.resolver.toPixel([0,index],settings,config,map,temp);ctx.moveTo(temp[0],temp[1]);this.resolver.toPixel([map.size[0],index],settings,config,map,temp);ctx.lineTo(temp[0],temp[1])}for(var index=1;index<map.size[0];index++){this.resolver.toPixel([index,0],settings,config,map,temp);ctx.moveTo(temp[0],temp[1]);this.resolver.toPixel([index,map.size[1]],settings,config,map,temp);ctx.lineTo(temp[0],temp[1])}ctx.closePath();ctx.stroke()}var tiles=map.tiles.filter(function(_){var result=false;if(_.tags&&select){for(var _i=0,select_1=select;_i<select_1.length;_i++){var item=select_1[_i];result=result||_.tags.indexOf(item)>=0}}return result});tiles.forEach(function(tile){var co=tile.coord;if(config.style.selectedTile.borderWidth){ctx.fillStyle=config.style.selectedTile.backgroundColor;ctx.strokeStyle=config.style.selectedTile.borderColor;ctx.lineWidth=config.style.selectedTile.borderWidth;ctx.beginPath();_this.resolver.toPixel([co[0],co[1]],settings,config,map,temp);ctx.moveTo(temp[0],temp[1]);_this.resolver.toPixel([co[0]+1,co[1]],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);_this.resolver.toPixel([co[0]+1,co[1]+1],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);_this.resolver.toPixel([co[0]+1,co[1]+1],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);_this.resolver.toPixel([co[0],co[1]+1],settings,config,map,temp);ctx.lineTo(temp[0],temp[1]);ctx.closePath();ctx.fill()}})};CanvasRenderer.prototype.drawTile=function(ctx,tile,settings,config,map,cb){this.resolver.drawTile(ctx,tile,settings,config,map,cb)};CanvasRenderer.prototype.drawText=function(ctx,tile,settings,config,map,zoom){this.resolver.drawText(ctx,tile,settings,config,map,this.calcName(tile,zoom))};CanvasRenderer.prototype.toPixel=function(coors,settings,config,map,result){return this.resolver.toPixel(coors,settings,config,map,result)};CanvasRenderer.prototype.toCoord=function(px,settings,settingS,config,map,result){return this.resolver.toCoord(px,settings,settingS,config,map,result)};CanvasRenderer.prototype.calcName=function(tile,zoom){var result="";if(!tile.name)return result;for(var _i=0,_a=tile.name;_i<_a.length;_i++){var name_1=_a[_i];if(name_1.zoom<=zoom){result=name_1.text}}return result};return CanvasRenderer}();exports.CanvasRenderer=CanvasRenderer},{"../models/canvas-settings.interface":11,q:9}],7:[function(require,module,exports){"use strict";exports.__esModule=true;var Config=function(){function Config(){}Config["default"]={quality:1,zoomStepTap:.5,zoomStepScrollDebouncer:100,maxZoom:6,maxSize:16e3,maxOffset:300,topOffset:.58375,topOffsetCenterCalcModification:true,refresh:"automatic",style:{map:{backgroundColor:"lightgrey",borderColor:"darkgrey",borderWidth:0},tile:{backgroundColor:"grey",borderColor:"darkgrey",borderWidth:0,fontSize:.16739,fontFamily:"Arial",fontColor:"black",textAlign:"center"},selectedTile:{backgroundColor:"yellow",borderColor:"grey",borderWidth:2,fontSize:.26739,fontFamily:"Arial",fontColor:"black",textAlign:"center"}},cheat:{imgTileHeightAdjustment:-21,imgTileHeightOffsetAdjustment:.07}};return Config}();exports.Config=Config},{}],8:[function(require,module,exports){"use strict";exports.__esModule=true;var Config_1=require("./Config");var Controller=function(){function Controller(el,svc){var _this=this;this.svc=svc;this._config=Config_1.Config["default"];this._map={size:[1,1],tiles:[]};this._cvs={el:undefined,config:this._config,set:{offset:[0,0,0,0],border:[0,0,0,0],scale:1,parentSize:[400,400],tileSize:[0,0]},map:this._map};this._settings={offset:[0,0,0,0],border:[0,0,0,0],scale:6,parentSize:[0,0],tileSize:[0,0]};this.shadowMap={shadow:{el:document.createElement("canvas"),config:this._config,map:this._map,set:this._settings,drawAction:"IMAGES"},shadowText:{el:document.createElement("canvas"),config:this._config,map:this._map,set:this._settings,drawAction:"TEXT"},shadowBackground:{el:document.createElement("canvas"),config:this._config,map:this._map,set:this._settings,drawAction:"BACKGROUND"}};this.mouseDown=false;this.refreshInterval=undefined;this.prevClick=[];var reg=function(event,action){return el["parent"].nativeElement.addEventListener(event,function(e){action(e);e.preventDefault();e.stopPropagation()},{passive:false})};if(el["cnvs"])this.bind(el["cnvs"]);if(el["sText"])this.bind(el["sText"]);if(el["sImg"])this.bind(el["sImg"]);if(el["sBack"])this.bind(el["sBack"]);if(el["window"])el["window"].nativeElement.addEventListener("resize",function(e){console.log("test");_this.resize();e.preventDefault()},{passive:false});reg("touchmove",function(e){return _this.onTouchRouter(e)});reg("dblclick",function(e){return _this.onZoomByDblClick(e)});reg("mousewheel",function(e){return _this.onZoomByWheel(e)});reg("mouseup",function(e){return _this.onMouseup(e)});reg("mouseout",function(e){return _this.onMouseup(e)});reg("mousemove",function(e){return _this.onMoveByMouse(e)});reg("mousedown",function(e){return _this.onMousedown(e)});reg("drop",function(e){return _this.onDrop(e)});reg("dragenter",function(e){console.log("testenter")});reg("dragexit",function(e){console.log("testexit")});reg("dragover",function(e){console.log("testover")})}Controller.prototype.bind=function(el){this.initCanvas(this._cvs,el);this.svc.zoom2(0,0,0,this._cvs)};Controller.prototype.bindShadow=function(el){this.initCanvas(this.shadowMap.shadow,el,this._cvs.set.parentSize.slice())};Controller.prototype.bindShadowText=function(el){this.initCanvas(this.shadowMap.shadowText,el,this._cvs.set.parentSize.slice())};Controller.prototype.bindShadowBackground=function(el){this.initCanvas(this.shadowMap.shadowBackground,el,this._cvs.set.parentSize.slice())};Controller.prototype.mark=function(id){this.svc.drawBackgroundLayer2(this.shadowMap.shadowBackground,[id]);this.rerender()};Controller.prototype.selectedCB=function(cb){this._selectedCallback=cb};Controller.prototype.droppedCB=function(cb){this._droppedCallback=cb};Controller.prototype.config=function(newConfigRoot){var copyMap=function(newConfigBranch,config){for(var _i=0,_a=Object.keys(newConfigBranch);_i<_a.length;_i++){var item=_a[_i];if(newConfigBranch[item]instanceof Object){copyMap(newConfigBranch[item],config[item])}else{config[item]=newConfigBranch[item]}}};copyMap(newConfigRoot,this._config);this.initAll();this.actionAll()};Controller.prototype.map=function(map){var _this=this;map.tiles.sort(function(__,_){return __.coord[0]+__.coord[1]-_.coord[0]-_.coord[1]});if(map.size[0]!==this._map.size[0]||map.size[1]!==this._map.size[1]){this._map.size=map.size;this.initAll()}this._map.tiles=map.tiles;this.svc.preload(this._map,this._config).then(function(_){console.debug("on preload");console.log(_this.shadowMap);_this.svc.drawImageLayer2(_this.shadowMap.shadow,function(){return _this.rerender()});_this.svc.drawBackgroundLayer2(_this.shadowMap.shadowBackground);_this.actionAll()})};Controller.prototype.tile=function(tiles){var _this=this;if(!tiles){return}tiles=[].concat(tiles);var _loop_1=function(tile){var exist=-1;this_1._map.tiles.forEach(function(_,__){if(_.coord[0]===tile.coord[0]&&_.coord[1]===tile.coord[1])exist=__});if(exist>=0){this_1._map.tiles.splice(exist,1,tile)}else{this_1._map.tiles.push(tile)}};var this_1=this;for(var _i=0,tiles_1=tiles;_i<tiles_1.length;_i++){var tile=tiles_1[_i];_loop_1(tile)}this.svc.drawImageLayer2(this.shadowMap.shadow,function(){return _this.rerender()});this.actionAll()};Controller.prototype.zoom=function(scroll){if(!scroll){return}var X=this._cvs.set.parentSize[0]/2;var Y=this._cvs.set.parentSize[1]/2;this.zoomFn(X,Y,scroll);this.rerender()};Controller.prototype.locate=function(mark){var _this=this;if(!mark){return}var limits=[1e4,1e4,0,0];var found=this._map.tiles.filter(function(_){return _.tags&&_.tags.indexOf(mark)>=0}).map(function(_){var co=[];_this.svc.toPixel(_.coord,_this._cvs.set,_this._cvs.config,_this._cvs.map,co);return co}).forEach(function(_){limits[0]=Math.min(limits[0],_[0]+(_this._cvs.set.offset[0]+_this._cvs.set.border[0])*_this._cvs.set.scale)-50;limits[1]=Math.min(limits[1],_[1]+(_this._cvs.set.offset[1]+_this._cvs.set.border[1])*_this._cvs.set.scale)-50;limits[2]=Math.max(limits[2],_[0]+_this._cvs.set.tileSize[0]+(_this._cvs.set.offset[2]+_this._cvs.set.border[2])*_this._cvs.set.scale)+50;limits[3]=Math.max(limits[3],_[1]+_this._cvs.set.tileSize[1]+(_this._cvs.set.offset[3]+_this._cvs.set.border[3])*_this._cvs.set.scale)+50});var width=limits[2]-limits[0];var height=limits[3]-limits[1];var scale=Math.min(this._cvs.set.parentSize[0]/width-this._cvs.set.scale,this._cvs.set.parentSize[1]/height-this._cvs.set.scale);this.moveFn(-limits[0],-limits[1]);this.zoomFn(0,0,scale);this.rerender()};Controller.prototype.initAll=function(){this.initCanvas(this._cvs);for(var _i=0,_a=Object.keys(this.shadowMap);_i<_a.length;_i++){var shadow=_a[_i];this.initCanvas(this.shadowMap[shadow],undefined,this._cvs.set.parentSize.slice())}this.svc.zoom2(0,0,-this._config.maxZoom,this._cvs)};Controller.prototype.initCanvas=function(layer,el,dimensions){if(el){layer.el=el.nativeElement}this.svc.preloadCanvas2(layer,dimensions)};Controller.prototype.actionAll=function(){this.svc.drawTextLayer2(this.shadowMap.shadowText,this._cvs.set.scale);this.svc.drawBackgroundLayer2(this.shadowMap.shadowBackground);this.svc.resize2(this._cvs.el.clientWidth-this._cvs.set.parentSize[0],this._cvs.el.clientHeight-this._cvs.set.parentSize[1],this._cvs);this.rerender()};Controller.prototype.ngOnInit=function(){this.initAll()};Controller.prototype.resize=function(){this.svc.resize2(this._cvs.el.clientWidth-this._cvs.set.parentSize[0],this._cvs.el.clientHeight-this._cvs.set.parentSize[1],this._cvs);this.rerender()};Controller.prototype.onTouchRouter=function(event){if(event.touches.length===1){this.onMoveByTouch(event)}else{this.onZoomByTouch(event)}this.rerender()};Controller.prototype.onZoomByDblClick=function(event){var X=event.offsetX;var Y=event.offsetY;var scroll=this._config.zoomStepTap;this.zoomFn(X,Y,scroll);this.rerender()};Controller.prototype.onZoomByWheel=function(event){var X=event.offsetX;var Y=event.offsetY;var scroll=-(event.deltaY/this._config.zoomStepScrollDebouncer);this.zoomFn(X,Y,scroll);this.rerender()};Controller.prototype.onZoomByTouch=function(event){var X=0;var Y=0;var scroll=this._config.zoomStepTap;if((this.touchPinchLastEvent||{timeStamp:0}).timeStamp-event.timeStamp<-200){return this.touchPinchLastEvent=event}X=event.touches.item(0).clientX;var adjX=event.touches.item(0).clientX-event.touches.item(1).clientX;var adjXB=this.touchPinchLastEvent.touches.item(0).clientX-this.touchPinchLastEvent.touches.item(1).clientX;X+=adjX/2;Y=event.touches.item(0).clientY;var adjY=event.touches.item(0).clientY-event.touches.item(1).clientY;var adjYB=this.touchPinchLastEvent.touches.item(0).clientY-this.touchPinchLastEvent.touches.item(1).clientY;Y+=adjY/2;scroll=(Math.abs(adjX-adjXB)>Math.abs(adjY-adjYB)?adjX/adjXB:adjY/adjYB)-1;this.touchPinchLastEvent=event;this.zoomFn(X,Y,scroll)};Controller.prototype.zoomFn=function(X,Y,scroll){var prevX=this.prevClick[0]||X;var prevY=this.prevClick[1]||Y;var zoom=this._cvs.set.scale;this.svc.zoom2(X,Y,scroll,this._cvs,[prevX-X,prevY-Y]);this.prevClick[0]=prevX;this.prevClick[1]=prevY;if(Math.floor(zoom)!==Math.floor(this._cvs.set.scale)){this.svc.drawTextLayer2(this.shadowMap.shadowText,this._cvs.set.scale)}};Controller.prototype.onMouseup=function(event){if(!this.mouseDown){return}this.mouseDown=false;if(event.offsetX===this.mouseDownStartEvent.offsetX&&event.offsetY===this.mouseDownStartEvent.offsetY){var co_1=[];this.svc.toCoord([event.offsetX,event.offsetY],this._cvs.set,this._settings,this._config,this._map,co_1);var found=this._map.tiles.filter(function(_){return _.coord[0]===co_1[0]&&_.coord[1]===co_1[1]});if(found.length>0){this._selectedCallback(found[0])}else{this._selectedCallback({coord:co_1})}}};Controller.prototype.onMoveByMouse=function(event){if(this.mouseDown){this.moveByMouse(event);this.rerender()}};Controller.prototype.onMoveByTouch=function(event){this.moveByTouch(event);if(event.stopPropagation){event.stopPropagation()}};Controller.prototype.onMousedown=function(event){this.mouseDown=true;this.mouseDownStartEvent=event;this.mouseDownLastEvent=event};Controller.prototype.onDrop=function(event){var arr=[];console.log(event);this.svc.toCoord([event.offsetX,event.offsetY],this._cvs.set,this._settings,this._config,this._map,arr);this._droppedCallback({coord:arr},event)};Controller.prototype.moveByTouch=function(event){if((this.touchDownLastEvent||{timeStamp:0}).timeStamp-event.timeStamp<-200){return this.touchDownLastEvent=event}this.moveFn(event.touches.item(0).clientX-this.touchDownLastEvent.touches.item(0).clientX,event.touches.item(0).clientY-this.touchDownLastEvent.touches.item(0).clientY);this.touchDownLastEvent=event};Controller.prototype.moveByMouse=function(event){this.moveFn(event.offsetX-this.mouseDownLastEvent.offsetX,event.offsetY-this.mouseDownLastEvent.offsetY);this.mouseDownLastEvent=event};Controller.prototype.moveFn=function(moveX,moveY){this.svc.move2(-moveX,-moveY,this._cvs)};Controller.prototype.rerender=function(){var _this=this;this.svc.copyMap(this._cvs.el.getContext("2d"),this._cvs.set,this.shadowMap.shadow.el,this.shadowMap.shadowText.el,this.shadowMap.shadowBackground.el,this._settings,this._config,this._map);if(this._config.refresh!=="automatic"){setTimeout(function(){_this.rerender()},this._config.refresh)}};return Controller}();exports.Controller=Controller},{"./Config":7}],9:[function(require,module,exports){(function(process,setImmediate){(function(definition){"use strict";if(typeof bootstrap==="function"){bootstrap("promise",definition)}else if(typeof exports==="object"&&typeof module==="object"){module.exports=definition()}else if(typeof define==="function"&&define.amd){define(definition)}else if(typeof ses!=="undefined"){if(!ses.ok()){return}else{ses.makeQ=definition}}else if(typeof window!=="undefined"||typeof self!=="undefined"){var global=typeof window!=="undefined"?window:self;var previousQ=global.Q;global.Q=definition();global.Q.noConflict=function(){global.Q=previousQ;return this}}else{throw new Error("This environment was not anticipated by Q. Please file a bug.")}})(function(){"use strict";var hasStacks=false;try{throw new Error}catch(e){hasStacks=!!e.stack}var qStartingLine=captureLine();var qFileName;var noop=function(){};var nextTick=function(){var head={task:void 0,next:null};var tail=head;var flushing=false;var requestTick=void 0;var isNodeJS=false;var laterQueue=[];function flush(){var task,domain;while(head.next){head=head.next;task=head.task;head.task=void 0;domain=head.domain;if(domain){head.domain=void 0;domain.enter()}runSingle(task,domain)}while(laterQueue.length){task=laterQueue.pop();runSingle(task)}flushing=false}function runSingle(task,domain){try{task()}catch(e){if(isNodeJS){if(domain){domain.exit()}setTimeout(flush,0);if(domain){domain.enter()}throw e}else{setTimeout(function(){throw e},0)}}if(domain){domain.exit()}}nextTick=function(task){tail=tail.next={task:task,domain:isNodeJS&&process.domain,next:null};if(!flushing){flushing=true;requestTick()}};if(typeof process==="object"&&process.toString()==="[object process]"&&process.nextTick){isNodeJS=true;requestTick=function(){process.nextTick(flush)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){requestTick=setImmediate.bind(window,flush)}else{requestTick=function(){setImmediate(flush)}}}else if(typeof MessageChannel!=="undefined"){var channel=new MessageChannel;channel.port1.onmessage=function(){requestTick=requestPortTick;channel.port1.onmessage=flush;flush()};var requestPortTick=function(){channel.port2.postMessage(0)};requestTick=function(){setTimeout(flush,0);requestPortTick()}}else{requestTick=function(){setTimeout(flush,0)}}nextTick.runAfter=function(task){laterQueue.push(task);if(!flushing){flushing=true;requestTick()}};return nextTick}();var call=Function.call;function uncurryThis(f){return function(){return call.apply(f,arguments)}}var array_slice=uncurryThis(Array.prototype.slice);var array_reduce=uncurryThis(Array.prototype.reduce||function(callback,basis){var index=0,length=this.length;if(arguments.length===1){do{if(index in this){basis=this[index++];break}if(++index>=length){throw new TypeError}}while(1)}for(;index<length;index++){if(index in this){basis=callback(basis,this[index],index)}}return basis});var array_indexOf=uncurryThis(Array.prototype.indexOf||function(value){for(var i=0;i<this.length;i++){if(this[i]===value){return i}}return-1});var array_map=uncurryThis(Array.prototype.map||function(callback,thisp){var self=this;var collect=[];array_reduce(self,function(undefined,value,index){collect.push(callback.call(thisp,value,index,self))},void 0);return collect});var object_create=Object.create||function(prototype){function Type(){}Type.prototype=prototype;return new Type};var object_defineProperty=Object.defineProperty||function(obj,prop,descriptor){obj[prop]=descriptor.value;return obj};var object_hasOwnProperty=uncurryThis(Object.prototype.hasOwnProperty);var object_keys=Object.keys||function(object){var keys=[];for(var key in object){if(object_hasOwnProperty(object,key)){keys.push(key)}}return keys};var object_toString=uncurryThis(Object.prototype.toString);function isObject(value){return value===Object(value)}function isStopIteration(exception){return object_toString(exception)==="[object StopIteration]"||exception instanceof QReturnValue}var QReturnValue;if(typeof ReturnValue!=="undefined"){QReturnValue=ReturnValue}else{QReturnValue=function(value){this.value=value}}var STACK_JUMP_SEPARATOR="From previous event:";function makeStackTraceLong(error,promise){if(hasStacks&&promise.stack&&typeof error==="object"&&error!==null&&error.stack){var stacks=[];for(var p=promise;!!p;p=p.source){if(p.stack&&(!error.__minimumStackCounter__||error.__minimumStackCounter__>p.stackCounter)){object_defineProperty(error,"__minimumStackCounter__",{value:p.stackCounter,configurable:true});stacks.unshift(p.stack)}}stacks.unshift(error.stack);var concatedStacks=stacks.join("\n"+STACK_JUMP_SEPARATOR+"\n");var stack=filterStackString(concatedStacks);object_defineProperty(error,"stack",{value:stack,configurable:true})}}function filterStackString(stackString){var lines=stackString.split("\n");var desiredLines=[];for(var i=0;i<lines.length;++i){var line=lines[i];if(!isInternalFrame(line)&&!isNodeFrame(line)&&line){desiredLines.push(line)}}return desiredLines.join("\n")}function isNodeFrame(stackLine){return stackLine.indexOf("(module.js:")!==-1||stackLine.indexOf("(node.js:")!==-1}function getFileNameAndLineNumber(stackLine){var attempt1=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);if(attempt1){return[attempt1[1],Number(attempt1[2])]}var attempt2=/at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);if(attempt2){return[attempt2[1],Number(attempt2[2])]}var attempt3=/.*@(.+):(\d+)$/.exec(stackLine);if(attempt3){return[attempt3[1],Number(attempt3[2])]}}function isInternalFrame(stackLine){var fileNameAndLineNumber=getFileNameAndLineNumber(stackLine);if(!fileNameAndLineNumber){return false}var fileName=fileNameAndLineNumber[0];var lineNumber=fileNameAndLineNumber[1];return fileName===qFileName&&lineNumber>=qStartingLine&&lineNumber<=qEndingLine}function captureLine(){if(!hasStacks){return}try{throw new Error}catch(e){var lines=e.stack.split("\n");var firstLine=lines[0].indexOf("@")>0?lines[1]:lines[2];var fileNameAndLineNumber=getFileNameAndLineNumber(firstLine);if(!fileNameAndLineNumber){return}qFileName=fileNameAndLineNumber[0];return fileNameAndLineNumber[1]}}function deprecate(callback,name,alternative){return function(){if(typeof console!=="undefined"&&typeof console.warn==="function"){console.warn(name+" is deprecated, use "+alternative+" instead.",new Error("").stack)}return callback.apply(callback,arguments)}}function Q(value){if(value instanceof Promise){return value}if(isPromiseAlike(value)){return coerce(value)}else{return fulfill(value)}}Q.resolve=Q;Q.nextTick=nextTick;Q.longStackSupport=false;var longStackCounter=1;if(typeof process==="object"&&process&&process.env&&process.env.Q_DEBUG){Q.longStackSupport=true}Q.defer=defer;function defer(){var messages=[],progressListeners=[],resolvedPromise;var deferred=object_create(defer.prototype);var promise=object_create(Promise.prototype);promise.promiseDispatch=function(resolve,op,operands){var args=array_slice(arguments);if(messages){messages.push(args);if(op==="when"&&operands[1]){progressListeners.push(operands[1])}}else{Q.nextTick(function(){resolvedPromise.promiseDispatch.apply(resolvedPromise,args)})}};promise.valueOf=function(){if(messages){return promise}var nearerValue=nearer(resolvedPromise);if(isPromise(nearerValue)){resolvedPromise=nearerValue}return nearerValue};promise.inspect=function(){if(!resolvedPromise){return{state:"pending"}}return resolvedPromise.inspect()};if(Q.longStackSupport&&hasStacks){try{throw new Error}catch(e){promise.stack=e.stack.substring(e.stack.indexOf("\n")+1);promise.stackCounter=longStackCounter++}}function become(newPromise){resolvedPromise=newPromise;if(Q.longStackSupport&&hasStacks){promise.source=newPromise}array_reduce(messages,function(undefined,message){Q.nextTick(function(){newPromise.promiseDispatch.apply(newPromise,message)})},void 0);messages=void 0;progressListeners=void 0}deferred.promise=promise;deferred.resolve=function(value){if(resolvedPromise){return}become(Q(value))};deferred.fulfill=function(value){if(resolvedPromise){return}become(fulfill(value))};deferred.reject=function(reason){if(resolvedPromise){return}become(reject(reason))};deferred.notify=function(progress){if(resolvedPromise){return}array_reduce(progressListeners,function(undefined,progressListener){Q.nextTick(function(){progressListener(progress)})},void 0)};return deferred}defer.prototype.makeNodeResolver=function(){var self=this;return function(error,value){if(error){self.reject(error)}else if(arguments.length>2){self.resolve(array_slice(arguments,1))}else{self.resolve(value)}}};Q.Promise=promise;Q.promise=promise;function promise(resolver){if(typeof resolver!=="function"){throw new TypeError("resolver must be a function.")}var deferred=defer();try{resolver(deferred.resolve,deferred.reject,deferred.notify)}catch(reason){deferred.reject(reason)}return deferred.promise}promise.race=race;promise.all=all;promise.reject=reject;promise.resolve=Q;Q.passByCopy=function(object){return object};Promise.prototype.passByCopy=function(){return this};Q.join=function(x,y){return Q(x).join(y)};Promise.prototype.join=function(that){return Q([this,that]).spread(function(x,y){if(x===y){return x}else{throw new Error("Q can't join: not the same: "+x+" "+y)}})};Q.race=race;function race(answerPs){return promise(function(resolve,reject){for(var i=0,len=answerPs.length;i<len;i++){Q(answerPs[i]).then(resolve,reject)}})}Promise.prototype.race=function(){return this.then(Q.race)};Q.makePromise=Promise;function Promise(descriptor,fallback,inspect){if(fallback===void 0){fallback=function(op){return reject(new Error("Promise does not support operation: "+op))}}if(inspect===void 0){inspect=function(){return{state:"unknown"}}}var promise=object_create(Promise.prototype);promise.promiseDispatch=function(resolve,op,args){var result;try{if(descriptor[op]){result=descriptor[op].apply(promise,args)}else{result=fallback.call(promise,op,args)}}catch(exception){result=reject(exception)}if(resolve){resolve(result)}};promise.inspect=inspect;if(inspect){var inspected=inspect();if(inspected.state==="rejected"){promise.exception=inspected.reason}promise.valueOf=function(){var inspected=inspect();if(inspected.state==="pending"||inspected.state==="rejected"){return promise}return inspected.value}}return promise}Promise.prototype.toString=function(){return"[object Promise]"};Promise.prototype.then=function(fulfilled,rejected,progressed){var self=this;var deferred=defer();var done=false;function _fulfilled(value){try{return typeof fulfilled==="function"?fulfilled(value):value}catch(exception){return reject(exception)}}function _rejected(exception){if(typeof rejected==="function"){makeStackTraceLong(exception,self);try{return rejected(exception)}catch(newException){return reject(newException)}}return reject(exception)}function _progressed(value){return typeof progressed==="function"?progressed(value):value}Q.nextTick(function(){self.promiseDispatch(function(value){if(done){return}done=true;deferred.resolve(_fulfilled(value))},"when",[function(exception){if(done){return}done=true;deferred.resolve(_rejected(exception))}])});self.promiseDispatch(void 0,"when",[void 0,function(value){var newValue;var threw=false;try{newValue=_progressed(value)}catch(e){threw=true;if(Q.onerror){Q.onerror(e)}else{throw e}}if(!threw){deferred.notify(newValue)}}]);return deferred.promise};Q.tap=function(promise,callback){return Q(promise).tap(callback)};Promise.prototype.tap=function(callback){callback=Q(callback);return this.then(function(value){return callback.fcall(value).thenResolve(value)})};Q.when=when;function when(value,fulfilled,rejected,progressed){return Q(value).then(fulfilled,rejected,progressed)}Promise.prototype.thenResolve=function(value){return this.then(function(){return value})};Q.thenResolve=function(promise,value){return Q(promise).thenResolve(value)};Promise.prototype.thenReject=function(reason){return this.then(function(){throw reason})};Q.thenReject=function(promise,reason){return Q(promise).thenReject(reason)};Q.nearer=nearer;function nearer(value){if(isPromise(value)){var inspected=value.inspect();if(inspected.state==="fulfilled"){return inspected.value}}return value}Q.isPromise=isPromise;function isPromise(object){return object instanceof Promise}Q.isPromiseAlike=isPromiseAlike;function isPromiseAlike(object){return isObject(object)&&typeof object.then==="function"}Q.isPending=isPending;function isPending(object){return isPromise(object)&&object.inspect().state==="pending"}Promise.prototype.isPending=function(){return this.inspect().state==="pending"};Q.isFulfilled=isFulfilled;function isFulfilled(object){return!isPromise(object)||object.inspect().state==="fulfilled"}Promise.prototype.isFulfilled=function(){return this.inspect().state==="fulfilled"};Q.isRejected=isRejected;function isRejected(object){return isPromise(object)&&object.inspect().state==="rejected"}Promise.prototype.isRejected=function(){return this.inspect().state==="rejected"};var unhandledReasons=[];var unhandledRejections=[];var reportedUnhandledRejections=[];var trackUnhandledRejections=true;function resetUnhandledRejections(){unhandledReasons.length=0;unhandledRejections.length=0;if(!trackUnhandledRejections){trackUnhandledRejections=true}}function trackRejection(promise,reason){if(!trackUnhandledRejections){return}if(typeof process==="object"&&typeof process.emit==="function"){Q.nextTick.runAfter(function(){if(array_indexOf(unhandledRejections,promise)!==-1){process.emit("unhandledRejection",reason,promise);reportedUnhandledRejections.push(promise)}})}unhandledRejections.push(promise);if(reason&&typeof reason.stack!=="undefined"){unhandledReasons.push(reason.stack)}else{unhandledReasons.push("(no stack) "+reason)}}function untrackRejection(promise){if(!trackUnhandledRejections){return}var at=array_indexOf(unhandledRejections,promise);if(at!==-1){if(typeof process==="object"&&typeof process.emit==="function"){Q.nextTick.runAfter(function(){var atReport=array_indexOf(reportedUnhandledRejections,promise);if(atReport!==-1){process.emit("rejectionHandled",unhandledReasons[at],promise);reportedUnhandledRejections.splice(atReport,1)}})}unhandledRejections.splice(at,1);unhandledReasons.splice(at,1)}}Q.resetUnhandledRejections=resetUnhandledRejections;Q.getUnhandledReasons=function(){return unhandledReasons.slice()};Q.stopUnhandledRejectionTracking=function(){resetUnhandledRejections();trackUnhandledRejections=false};resetUnhandledRejections();Q.reject=reject;function reject(reason){var rejection=Promise({when:function(rejected){if(rejected){untrackRejection(this)}return rejected?rejected(reason):this}},function fallback(){return this},function inspect(){return{state:"rejected",reason:reason}});trackRejection(rejection,reason);return rejection}Q.fulfill=fulfill;function fulfill(value){return Promise({when:function(){return value},get:function(name){return value[name]},set:function(name,rhs){value[name]=rhs},delete:function(name){delete value[name]},post:function(name,args){if(name===null||name===void 0){return value.apply(void 0,args)}else{return value[name].apply(value,args)}},apply:function(thisp,args){return value.apply(thisp,args)},keys:function(){return object_keys(value)}},void 0,function inspect(){return{state:"fulfilled",value:value}})}function coerce(promise){var deferred=defer();Q.nextTick(function(){try{promise.then(deferred.resolve,deferred.reject,deferred.notify)}catch(exception){deferred.reject(exception)}});return deferred.promise}Q.master=master;function master(object){return Promise({isDef:function(){}},function fallback(op,args){return dispatch(object,op,args)},function(){return Q(object).inspect()})}Q.spread=spread;function spread(value,fulfilled,rejected){return Q(value).spread(fulfilled,rejected)}Promise.prototype.spread=function(fulfilled,rejected){return this.all().then(function(array){return fulfilled.apply(void 0,array)},rejected)};Q.async=async;function async(makeGenerator){return function(){function continuer(verb,arg){var result;if(typeof StopIteration==="undefined"){try{result=generator[verb](arg)}catch(exception){return reject(exception)}if(result.done){return Q(result.value)}else{return when(result.value,callback,errback)}}else{try{result=generator[verb](arg)}catch(exception){if(isStopIteration(exception)){return Q(exception.value)}else{return reject(exception)}}return when(result,callback,errback)}}var generator=makeGenerator.apply(this,arguments);var callback=continuer.bind(continuer,"next");var errback=continuer.bind(continuer,"throw");return callback()}}Q.spawn=spawn;function spawn(makeGenerator){Q.done(Q.async(makeGenerator)())}Q["return"]=_return;function _return(value){throw new QReturnValue(value)}Q.promised=promised;function promised(callback){return function(){return spread([this,all(arguments)],function(self,args){return callback.apply(self,args)})}}Q.dispatch=dispatch;function dispatch(object,op,args){return Q(object).dispatch(op,args)}Promise.prototype.dispatch=function(op,args){var self=this;var deferred=defer();Q.nextTick(function(){self.promiseDispatch(deferred.resolve,op,args)});return deferred.promise};Q.get=function(object,key){return Q(object).dispatch("get",[key])};Promise.prototype.get=function(key){return this.dispatch("get",[key])};Q.set=function(object,key,value){return Q(object).dispatch("set",[key,value])};Promise.prototype.set=function(key,value){return this.dispatch("set",[key,value])};Q.del=Q["delete"]=function(object,key){return Q(object).dispatch("delete",[key])};Promise.prototype.del=Promise.prototype["delete"]=function(key){return this.dispatch("delete",[key])};Q.mapply=Q.post=function(object,name,args){return Q(object).dispatch("post",[name,args])};Promise.prototype.mapply=Promise.prototype.post=function(name,args){return this.dispatch("post",[name,args])};Q.send=Q.mcall=Q.invoke=function(object,name){return Q(object).dispatch("post",[name,array_slice(arguments,2)])};Promise.prototype.send=Promise.prototype.mcall=Promise.prototype.invoke=function(name){return this.dispatch("post",[name,array_slice(arguments,1)])};Q.fapply=function(object,args){return Q(object).dispatch("apply",[void 0,args])};Promise.prototype.fapply=function(args){return this.dispatch("apply",[void 0,args])};Q["try"]=Q.fcall=function(object){return Q(object).dispatch("apply",[void 0,array_slice(arguments,1)])};Promise.prototype.fcall=function(){return this.dispatch("apply",[void 0,array_slice(arguments)])};Q.fbind=function(object){var promise=Q(object);var args=array_slice(arguments,1);return function fbound(){return promise.dispatch("apply",[this,args.concat(array_slice(arguments))])}};Promise.prototype.fbind=function(){var promise=this;var args=array_slice(arguments);return function fbound(){return promise.dispatch("apply",[this,args.concat(array_slice(arguments))])}};Q.keys=function(object){return Q(object).dispatch("keys",[])};Promise.prototype.keys=function(){return this.dispatch("keys",[])};Q.all=all;function all(promises){return when(promises,function(promises){var pendingCount=0;var deferred=defer();array_reduce(promises,function(undefined,promise,index){var snapshot;if(isPromise(promise)&&(snapshot=promise.inspect()).state==="fulfilled"){promises[index]=snapshot.value}else{++pendingCount;when(promise,function(value){promises[index]=value;if(--pendingCount===0){deferred.resolve(promises)}},deferred.reject,function(progress){deferred.notify({index:index,value:progress})})}},void 0);if(pendingCount===0){deferred.resolve(promises)}return deferred.promise})}Promise.prototype.all=function(){return all(this)};Q.any=any;function any(promises){if(promises.length===0){return Q.resolve()}var deferred=Q.defer();var pendingCount=0;array_reduce(promises,function(prev,current,index){var promise=promises[index];pendingCount++;when(promise,onFulfilled,onRejected,onProgress);function onFulfilled(result){deferred.resolve(result)}function onRejected(err){pendingCount--;if(pendingCount===0){var rejection=err||new Error(""+err);rejection.message="Q can't get fulfillment value from any promise, all "+"promises were rejected. Last error message: "+rejection.message;deferred.reject(rejection)}}function onProgress(progress){deferred.notify({index:index,value:progress})}},undefined);return deferred.promise}Promise.prototype.any=function(){return any(this)};Q.allResolved=deprecate(allResolved,"allResolved","allSettled");function allResolved(promises){return when(promises,function(promises){promises=array_map(promises,Q);return when(all(array_map(promises,function(promise){return when(promise,noop,noop)})),function(){return promises})})}Promise.prototype.allResolved=function(){return allResolved(this)};Q.allSettled=allSettled;function allSettled(promises){return Q(promises).allSettled()}Promise.prototype.allSettled=function(){return this.then(function(promises){return all(array_map(promises,function(promise){promise=Q(promise);function regardless(){return promise.inspect()}return promise.then(regardless,regardless)}))})};Q.fail=Q["catch"]=function(object,rejected){return Q(object).then(void 0,rejected)};Promise.prototype.fail=Promise.prototype["catch"]=function(rejected){return this.then(void 0,rejected)};Q.progress=progress;function progress(object,progressed){return Q(object).then(void 0,void 0,progressed)}Promise.prototype.progress=function(progressed){return this.then(void 0,void 0,progressed)};Q.fin=Q["finally"]=function(object,callback){return Q(object)["finally"](callback)};Promise.prototype.fin=Promise.prototype["finally"]=function(callback){if(!callback||typeof callback.apply!=="function"){throw new Error("Q can't apply finally callback")}callback=Q(callback);return this.then(function(value){return callback.fcall().then(function(){return value})},function(reason){return callback.fcall().then(function(){throw reason})})};Q.done=function(object,fulfilled,rejected,progress){return Q(object).done(fulfilled,rejected,progress)};Promise.prototype.done=function(fulfilled,rejected,progress){var onUnhandledError=function(error){Q.nextTick(function(){makeStackTraceLong(error,promise);if(Q.onerror){Q.onerror(error)}else{throw error}})};var promise=fulfilled||rejected||progress?this.then(fulfilled,rejected,progress):this;if(typeof process==="object"&&process&&process.domain){onUnhandledError=process.domain.bind(onUnhandledError)}promise.then(void 0,onUnhandledError)};Q.timeout=function(object,ms,error){return Q(object).timeout(ms,error)};Promise.prototype.timeout=function(ms,error){var deferred=defer();var timeoutId=setTimeout(function(){if(!error||"string"===typeof error){error=new Error(error||"Timed out after "+ms+" ms");error.code="ETIMEDOUT"}deferred.reject(error)},ms);this.then(function(value){clearTimeout(timeoutId);deferred.resolve(value)},function(exception){clearTimeout(timeoutId);deferred.reject(exception)},deferred.notify);return deferred.promise};Q.delay=function(object,timeout){if(timeout===void 0){timeout=object;object=void 0}return Q(object).delay(timeout)};Promise.prototype.delay=function(timeout){return this.then(function(value){var deferred=defer();setTimeout(function(){deferred.resolve(value)},timeout);return deferred.promise})};Q.nfapply=function(callback,args){return Q(callback).nfapply(args)};Promise.prototype.nfapply=function(args){var deferred=defer();var nodeArgs=array_slice(args);nodeArgs.push(deferred.makeNodeResolver());this.fapply(nodeArgs).fail(deferred.reject);return deferred.promise};Q.nfcall=function(callback){var args=array_slice(arguments,1);return Q(callback).nfapply(args)};Promise.prototype.nfcall=function(){var nodeArgs=array_slice(arguments);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());this.fapply(nodeArgs).fail(deferred.reject);return deferred.promise};Q.nfbind=Q.denodeify=function(callback){if(callback===undefined){throw new Error("Q can't wrap an undefined function")}var baseArgs=array_slice(arguments,1);return function(){var nodeArgs=baseArgs.concat(array_slice(arguments));var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());Q(callback).fapply(nodeArgs).fail(deferred.reject);return deferred.promise}};Promise.prototype.nfbind=Promise.prototype.denodeify=function(){var args=array_slice(arguments);args.unshift(this);return Q.denodeify.apply(void 0,args)};Q.nbind=function(callback,thisp){var baseArgs=array_slice(arguments,2);return function(){var nodeArgs=baseArgs.concat(array_slice(arguments));var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());function bound(){return callback.apply(thisp,arguments)}Q(bound).fapply(nodeArgs).fail(deferred.reject);return deferred.promise}};Promise.prototype.nbind=function(){var args=array_slice(arguments,0);args.unshift(this);return Q.nbind.apply(void 0,args)};Q.nmapply=Q.npost=function(object,name,args){return Q(object).npost(name,args)};Promise.prototype.nmapply=Promise.prototype.npost=function(name,args){var nodeArgs=array_slice(args||[]);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());this.dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Q.nsend=Q.nmcall=Q.ninvoke=function(object,name){var nodeArgs=array_slice(arguments,2);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());Q(object).dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Promise.prototype.nsend=Promise.prototype.nmcall=Promise.prototype.ninvoke=function(name){var nodeArgs=array_slice(arguments,1);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());this.dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Q.nodeify=nodeify;function nodeify(object,nodeback){return Q(object).nodeify(nodeback)}Promise.prototype.nodeify=function(nodeback){if(nodeback){this.then(function(value){Q.nextTick(function(){nodeback(null,value)})},function(error){Q.nextTick(function(){nodeback(error)})})}else{return this}};Q.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var qEndingLine=captureLine();return Q})}).call(this,require("_process"),require("timers").setImmediate)},{_process:1,timers:2}],10:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();exports.__esModule=true;var CanvasRenderer_1=require("./logic/CanvasRenderer");var IsoCoordResolver_1=require("./iso/IsoCoordResolver");var CartCoordResolver_1=require("./cart/CartCoordResolver");var Controller_1=require("./logic/Controller");var Config_1=require("./logic/Config");var GenericMap=function(){function GenericMap(ctrl){this.ctrl=ctrl}GenericMap.prototype.setConfig=function(config){this.ctrl.config(config)};GenericMap.prototype.setMap=function(map){this.ctrl.map(map)};GenericMap.prototype.setSelectedCB=function(cb){this.ctrl.selectedCB(cb)};GenericMap.prototype.setDroppedCB=function(cb){this.ctrl.droppedCB(cb)};GenericMap.prototype.changeZoom=function(zoom){this.ctrl.zoom(zoom)};return GenericMap}();exports.GenericMap=GenericMap;var IsoMap=function(_super){__extends(IsoMap,_super);function IsoMap(el,config,map){var _this=_super.call(this,new Controller_1.Controller(el,new CanvasRenderer_1.CanvasRenderer(new IsoCoordResolver_1.IsoCoordResolver({}))))||this;_this.setConfig(config||Config_1.Config["default"]);_this.setMap(map);return _this}return IsoMap}(GenericMap);exports.IsoMap=IsoMap;var CartMap=function(_super){__extends(CartMap,_super);function CartMap(el,config,map){var _this=_super.call(this,new Controller_1.Controller(el,new CanvasRenderer_1.CanvasRenderer(new CartCoordResolver_1.CartCoordResolver({}))))||this;_this.setConfig(config||Config_1.Config["default"]);_this.setMap(map);return _this}return CartMap}(GenericMap);exports.CartMap=CartMap},{"./cart/CartCoordResolver":3,"./iso/IsoCoordResolver":5,"./logic/CanvasRenderer":6,"./logic/Config":7,"./logic/Controller":8}],11:[function(require,module,exports){"use strict";exports.__esModule=true;var ORRIENTATION;(function(ORRIENTATION){ORRIENTATION[ORRIENTATION["WEST"]=0]="WEST";ORRIENTATION[ORRIENTATION["NORTH"]=1]="NORTH";ORRIENTATION[ORRIENTATION["EAST"]=2]="EAST";ORRIENTATION[ORRIENTATION["SOUTH"]=3]="SOUTH"})(ORRIENTATION=exports.ORRIENTATION||(exports.ORRIENTATION={}))},{}]},{},[10])(10)});