"use strict";var Bigmap=function(a,r,t,g){var i=this;this.mapElement=a,this.underlyingMapGui=new MapGui(this),this.marker=$('<img class="markerBigmap" src="data/gui/avatar_icon.svg" langcaption_title="MAP_MARKER_TELEPORT" />'),this.mapImageElement=r,t.append(this.marker),this.mapDragging={scrollLeftOnDragStart:0,scrollTopOnDragStart:0,markerLeftOnDragStart:0,markerTopOnDragStart:0,dragging:!1},g.getDialog().drag(function(a,r){g.getDialog().scrollLeft(i.mapDragging.scrollLeftOnDragStart-r.deltaX),g.getDialog().scrollTop(i.mapDragging.scrollTopOnDragStart-r.deltaY)}),g.getDialog().drag("init",function(){i.mapDragging.scrollLeftOnDragStart=g.getDialog()[0].scrollLeft,i.mapDragging.scrollTopOnDragStart=g.getDialog()[0].scrollTop,i.mapDragging.dragging=!0,a.addClass("mapDialogMapDragging")}),g.getDialog().drag("end",function(){i.mapDragging.dragging=!1,a.removeClass("mapDialogMapDragging")}),this.marker.drag("init",function(a,r){i.mapDragging.dragging=!0}),this.marker.drag("end",function(a,r){i.mapDragging.dragging=!1}),this.marker.draggable({containment:g.getDialog(),scroll:!1,revertDuration:0,start:function(){i.mapDragging.markerLeftOnDragStart=i.marker.offset().left,i.mapDragging.markerTopOnDragStart=i.marker.offset().top},revert:function(){var a=Math.round(i.marker.offset().left-i.mapDragging.markerLeftOnDragStart),r=Math.round(i.marker.offset().top-i.mapDragging.markerTopOnDragStart),t=new THREE.Vector3;t.x=i.underlyingMapGui.getLastCoordinatesInMap().x+a,t.z=i.underlyingMapGui.getLastCoordinatesInMap().y-r;for(var e,n=0,o=5;n<o&&(e=gui.minimap.findAreaAt2dCoordinatesInMap(t.x,t.z),!Util.isPropertyDefined(e));n++)t.x-=1;if(e){t.y=heightmapWorld.getMain().getWorldHeightAt(t.x,t.z,appMain.getCurrentControllingEntity()),i.getUnderlyingMap().unprojectInplaceXZ(t);var p=heightmapWorld.getMain().getWorldHeightForDepth(0);return Math.abs(t.y-p)<=.1&&(t.y=heightmapWorld.getMain().getWorldHeightForDepth(.05)),appMain.getCurrentControllingEntity().setPosition(t),g.close(),!1}return!0}}),g.getDialog().mouseup(function(){g.getDialog().drag("end")})};Bigmap.prototype._resizeCallback=function(){this.underlyingMapGui._resizeCallback()},Bigmap.prototype.updateMinimap=function(a){var r=this.underlyingMapGui.computeCoordinatesInMapImage(a,!1);this.marker[0].style.left=(r.x-.5*this.marker.width())/1280*100+"%",this.marker[0].style.top=(r.y-.5*this.marker.height())/659*100+"%"},Bigmap.prototype.getUnderlyingMap=function(){return this.underlyingMapGui.underlyingMap},Bigmap.prototype.isMapDragging=function(){return this.mapDragging.dragging};