"use strict";function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}var _createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}(),M$=M$||$||jQuery.noConflict(),AbfMaps=function(){function n(t,i){_classCallCheck(this,n);this.settings=i;this.container=t;this.map={};this.selectedCluster=null;this.selectedFeature=null;this.highlightedFeature=null;this.postRender=!1;this.selectCallback=null;this.maxIconSize=-1;this.init()}return _createClass(n,[{key:"init",value:function(){this._getAbfMapsRoot();var n=this;if(!this.settings.getConfigFromFile){this._callInitFunctions();return}M$.when(this._getConfigFromFile()).then(function(){n._callInitFunctions()}).then(function(){})}},{key:"_callInitFunctions",value:function(){var n=this.settings;this._initMap(n.map);this._initSelectStyle();this._initHighlightStyle();this._initSelectCallbacks();this.addOsmLayer(n.osmLayer);this.addWmsLayers(n.wmsLayers);this.addWmtsLayers(n.wmtsLayers);this.addWfsLayers(n.wfsLayers);this.addVectorLayers(n.vectorLayers);this.addObjectLayer(n.objectLayer)}},{key:"_getAbfMapsRoot",value:function(){for(var r=M$("script"),u,n,t,i=0;i<r.length;i++)u=r[i],t=u.src,t.toLowerCase().indexOf("abfmaps.js")!==-1&&(n=t.toLowerCase().indexOf("abfmaps/"),n===-1?(n=t.toLowerCase().indexOf("abfmaps2/"),this.abfMapsRoot=n===-1?"/":t.substring(0,n)+"abfmaps2/"):this.abfMapsRoot=t.substring(0,n)+"abfmaps/")}},{key:"_getConfigFromFile",value:function(){var n=this,t=this.settings.projection?this.settings.projection:"28992",i="AbfMapsHandler.ashx?function=getconfig&proj="+t,r=function(t){n.settings=t};return this._ajaxDeferredPost(i,{},r)}},{key:"_initMap",value:function(n){var t=this,i,r=[],u=new ol.proj.Projection({code:n.projection.code,units:n.projection.unit,extent:[n.extent.minX,n.extent.minY,n.extent.maxX,n.extent.maxY]}),f,e;this.defaultProjection=u;ol.proj.addProjection(u);f=new ol.proj.Projection({code:"http://www.opengis.net/gml/srs/epsg.xml#"+n.projection.code.replace("EPSG:",""),units:n.projection.unit});ol.proj.addEquivalentProjections([ol.proj.get(n.projection.code),f]);n.controls&&(n.controls.attribution&&n.controls.attribution.enabled===!0&&(i=new ol.control.Attribution,r.push(i)),n.controls.mousePosition&&n.controls.mousePosition.enabled===!0&&(i=new ol.control.MousePosition,r.push(i)),n.controls.zoom&&n.controls.zoom.enabled===!0&&(i=new ol.control.Zoom,r.push(i)));n.resolution===-1&&(n.resolution=undefined);this.map=new ol.Map({interactions:ol.interaction.defaults({doubleClickZoom:!n.disableZoom,mouseWheelZoom:!1,altShiftDragRotate:!n.disableZoom,dragPan:!1,pinchZoom:!n.disableZoom,pinchRotate:!1,keyboard:!n.disableZoom,shiftDragZoom:!n.disableZoom}),controls:r,target:t.container,layers:[],view:new ol.View({center:[n.center.x,n.center.y],extent:[n.extent.minX,n.extent.minY,n.extent.maxX,n.extent.maxY],maxResolution:n.maxResolution,minResolution:n.minResolution,projection:u,resolution:n.resolution,zoom:n.zoom,zoomFactor:n.zoomFactor,constrainOnlyCenter:!0})});n.disableZoom||(t._addDragPanInteraction(n.enableTwoFingerTouch),t._addMouseWheelZoomInteraction(n.enableTwoFingerTouch));t._initMapEvents();t._addZoomInstructionPanel();e=navigator.platform.toUpperCase().indexOf("MAC")>=0;t.settings.map.mouseWheelZoomMessage=e?t.settings.map.commandMouseWheelZoomMessage:t.settings.map.ctrlMouseWheelZoomMessage}},{key:"_addMouseWheelZoomInteraction",value:function(){var n=this,t=new ol.interaction.MouseWheelZoom({condition:function(t){return t.type==="wheel"?n.settings.map.enableCtrlMouseWheelZoom===!0?(n.zoomInstructionPanelTimerID&&clearTimeout(n.zoomInstructionPanelTimerID),t.originalEvent.ctrlKey===!0?(n._hideZoomInstructionPanel(),!0):(n._fadeInZoomInstructionPanel(n.settings.map.mouseWheelZoomMessage),!1)):!0:!0}});this.map.addInteraction(t)}},{key:"_fadeOutZoomInstructionPanel",value:function(n){n||(n=800);M$("#"+this.container+" .zoominstruction").css("transition","opacity "+n/1e3+"s ease-in-out");M$("#"+this.container+" .zoominstruction").removeClass("fadeIn")}},{key:"_fadeInZoomInstructionPanel",value:function(n,t){var i=this;t||(t=800);i.zoomInstructionPanelTimerID_fadeIn?i._fadeInZoomInstructionPanel2(n,t):i.zoomInstructionPanelTimerID_fadeIn=setTimeout(function(){i._fadeInZoomInstructionPanel2(n,t)},100)}},{key:"_fadeInZoomInstructionPanel2",value:function(n,t){var i=this;i.zoomInstructionPanelTimerID_fadeIn=null;M$("#"+i.container+" .zoominstruction-message").html(n);M$("#"+i.container+" .zoominstruction-parent").show();M$("#"+i.container+" .zoominstruction").css("transition","opacity "+t/1e3+"s ease-in-out");M$("#"+i.container+" .zoominstruction").addClass("fadeIn");i.zoomInstructionPanelTimerID=setTimeout(function(){i._fadeOutZoomInstructionPanel();setTimeout(function(){M$("#"+i.container+" .zoominstruction-parent").hide()},t)},t*2)}},{key:"_hideZoomInstructionPanel",value:function(){this.zoomInstructionPanelTimerID_fadeIn&&clearTimeout(this.zoomInstructionPanelTimerID_fadeIn);M$("#"+this.container+" .zoominstruction-parent").hide()}},{key:"_addZoomInstructionPanel",value:function(){var n=this;M$("#"+n.container+" .zoominstruction-parent").length>0||(M$("<style type='text/css'>             .zoominstruction-message { font-size: 22px; color: white; position: relative; margin: 0; top: 50%; }             .zoominstruction.fadeIn { opacity: 1; } .zoominstruction { background-color: rgba(0,0,0,0.45); text-align: center; }             .overlay-panel { opacity: 0; z-index: 2; position: absolute; height: 100%; width: 100%; padding: 0px; border-width: 0px; margin: 0px; left: 0px; top: 0px; }             span.zoom-key { display:inline-block; padding: 0 5px; border: 2px solid #fff; border-radius: 2px; }         <\/style>").appendTo("head"),M$("#"+n.container+" .ol-viewport").append(function(){return"<div class='zoominstruction-parent' style='display: none;'><div class='zoominstruction overlay-panel'><p class='zoominstruction-message'><\/p><\/div><\/div>"}))}},{key:"_addDragPanInteraction",value:function(n){var t=this,i;i=n===!0?new ol.interaction.DragPan({condition:function(n){t.zoomInstructionPanelTimerID&&clearTimeout(t.zoomInstructionPanelTimerID);var i=!0;return n.originalEvent.touches?i=n.originalEvent.touches.length===2:n.originalEvent.pointerType==="touch"&&(i=t.eventCache.length<=1||t.eventCache.length>2?!1:!0),i===!0?(t._hideZoomInstructionPanel(),t.eventCache.length=0):t._fadeInZoomInstructionPanel(t.settings.map.twoFingerTouchMessage),i}}):new ol.interaction.DragPan;this.map.addInteraction(i)}},{key:"_initMapEvents",value:function(){var n=this,t=this.map;t.once("postrender",function(t){n.postRender=!0;var i=n._getFunctionByName(n.settings.map.postrenderCallback);i&&i(t)});t.on("movestart",function(t){n._mapMoveStart(t)});t.on("moveend",function(t){n._mapMoveEnd(t)});t.on("singleclick",function(t){n._mapClicked(t)});t.on("pointermove",function(t){n._mapPointerMove(t)});t.getViewport().addEventListener("contextmenu",function(t){t.preventDefault();n._mapContextMenu(t)});t.getView().on("change:resolution",function(t){n._mapZoomChanged(t)});t.getViewport().addEventListener("mouseout",function(t){n._mapPointerMove(t)});t.on("pointerdown",function(t){n.eventCache.push(t)});t.on("pointerup",function(t){n.zoomInstructionPanelTimerID_fadeIn&&(clearTimeout(n.zoomInstructionPanelTimerID_fadeIn),n.zoomInstructionPanelTimerID_fadeIn=null);for(var i=0;i<n.eventCache.length;i++)if(n.eventCache[i].pointerId==t.pointerId){n.eventCache.splice(i,1);break}});n.eventCache=[]}},{key:"_mapContextMenu",value:function(n){for(var r,y,h,p,g,w,s=this,b=this.settings,c=this.map,k=c.getEventPixel(n),nt=c.getCoordinateFromPixel(k),t,u,e=[],o=[],f={loaded:!1,loadingCount:0},d=this.getLayers(),l=0;l<d.length;l++){var i=d[l],a=i.get("code"),v=i.get("type"),tt=i.get("visible");if(tt!==!1)if(r=c.getFeaturesAtPixel(k,{layerFilter:function(n){return n===i}}),v==="object"){if(r!==null)for(t=0;t<r.length;t++)u=r[t],y=u,h=u.get("features"),h&&h.length===1&&(y=h[0]),i.layerSettings.inContextMenuCallback===!0&&(e.push(a),o.push(y))}else if(v==="vector"){if(r!==null)for(t=0;t<r.length;t++)u=r[t],i.layerSettings.inContextMenuCallback===!0&&(e.push(a),o.push(u))}else if(v==="circle"){if(i.layerSettings.inContextMenuCallback!==!0)continue;if(r!==null)for(t=0;t<r.length;t++)u=r[t],e.push(a),o.push(u)}else{if(i.layerSettings.inContextMenuCallback!==!0)continue;p=i.getSource();(p instanceof ol.source.TileWMS||p instanceof ol.source.ImageWMS)&&(f.loadingCount++,g=function(n,t){e.push(n);o.push(t);f.loadingCount--;f.loaded=f.loadingCount===0},s._getWmsFeatureInfo(nt,i,g))}}b.map.contextMenuCallback&&(w=s._getFunctionByName(b.map.contextMenuCallback),w&&(f.loadingCount===0&&(f.loaded=!0),s._executeWhenReady(f,"loaded",function(){w(n,e,o)})));s._clearTempObjectLayer()}},{key:"_mapClicked",value:function(n){var f=this,nt=this.settings,t,ut=this.map,v=null,y,u,i,r,o,a,p,b,k,d,rt,g;this.selectedFeature!==null&&(this.selectedCluster===null&&(t=this.selectedFeature.get("layer"),t.get("type")==="vector"?this.selectedFeature.getStyle()&&this.selectedFeature.setStyle(null):t.get("type")==="object"&&(v=this.selectedFeature)),this.selectedFeature=null);var s=[],h=[],w=!0,tt=f.getLayers(),c,l,e={loaded:!1,loadingCount:0},it=0;for((n.originalEvent.type==="touchstart"||n.originalEvent.pointerType==="touch")&&(it=5),y=0;y<tt.length;y++)if(t=tt[y],c=t.get("code"),l=t.get("type"),t.get("visible")!==!1)if(u=ut.getFeaturesAtPixel(n.pixel,{layerFilter:function(n){return n===t},hitTolerance:it}),l==="object"){if(u!==null)for(t.get("isTempLayer")===!0&&(w=!1),i=0;i<u.length;i++){if(r=u[i],a=r.get("features"),a)if(a.length===1)o=a[0];else{if(a.length>10&&(p=f.map.getView(),b=p.getZoom(),p.setZoom(b+1),p.getZoom()!==b))return;f.selectedCluster=r;o=r;w=!1}else o=r;this.selectedFeature=o;o!==v&&t.changed();t.layerSettings.inClickCallback===!0&&(s.push(c),h.push(o.getProperties()));f.selectCallback(n,t,o)}v&&this.selectedFeature===null&&(t=v.get("layer"),t.changed())}else if(l==="vector"){if(u!==null)for(i=0;i<u.length;i++)r=u[i],this.selectedFeature===null&&(this.selectedFeature=r),k=f.vectorLayerSelectStyleFunction(t,r),k&&r.setStyle(k),t.layerSettings.inClickCallback===!0&&(s.push(c),h.push(r)),f.selectCallback(n,t,r)}else if(l==="wfs"){if(t.layerSettings.inClickCallback===!0&&u)for(i=0;i<u.length;i++)r=u[i],s.push(c),h.push(r)}else if(l==="circle"){if(t.layerSettings.inClickCallback===!0&&u!==null)for(i=0;i<u.length;i++)r=u[i],s.push(c),h.push(r.getProperties())}else{if(t.layerSettings.inClickCallback!==!0)continue;d=t.getSource();(d instanceof ol.source.TileWMS||d instanceof ol.source.ImageWMS)&&(e.loadingCount++,rt=function(n,t){t.features&&t.features.length>0&&(s.push(n),h.push(t));e.loadingCount--;e.loaded=e.loadingCount===0},f._getWmsFeatureInfo(n.coordinate,t,rt))}nt.map.clickCallback&&(g=f._getFunctionByName(nt.map.clickCallback),g&&(e.loadingCount===0&&(e.loaded=!0),f._executeWhenReady(e,"loaded",function(){g(n,s,h)})));w&&f._clearTempObjectLayer()}},{key:"_mapPointerMove",value:function(n){var e=this,b=this.settings,d=this.map,r,f,u,s=[],h=[],k=this.getLayers(),c,l,a=!1,v=null,t,y,i,o,p,w;if(this.highlightedFeature!==null&&(t=this.highlightedFeature.get("layer"),t&&(t.get("type")==="vector"?this.highlightedFeature===this.selectedFeature?(f=e.vectorLayerSelectStyleFunction(t,this.selectedFeature),f||this.highlightedFeature.getStyle()&&this.highlightedFeature.setStyle(null)):this.highlightedFeature.getStyle()&&this.highlightedFeature.setStyle(null):t.get("type")==="object"&&(v=this.highlightedFeature)),this.highlightedFeature=null),n.type!="mouseout")for(y=0;y<k.length;y++)if(t=k[y],c=t.get("code"),l=t.get("type"),t.get("visible")!==!1)if(i=d.getFeaturesAtPixel(n.pixel,{layerFilter:function(n){return n===t}}),l==="circle"){if(i!==null&&i.length>0){if(t.layerSettings.inMouseMoveCallback===!0)for(r=0;r<i.length;r++)u=i[r],s.push(c),h.push(u.getProperties());t.layerSettings.inClickCallback===!0&&(a=!0)}}else if(l==="object"){if(i!==null&&i.length>0){for(r=0;r<i.length;r++){if(u=i[r],p=u.get("features"),p)if(p.length===1)o=p[0];else return;else o=u;this.highlightedFeature=o;o!==v&&t.changed();t.layerSettings.inMouseMoveCallback===!0&&(s.push(c),h.push(o.getProperties()))}t.layerSettings.inClickCallback===!0&&(a=!0)}}else if(l==="vector"&&i!==null&&i.length>0){for(r=Math.max(i.length-1,0);r<i.length;r++)(u=i[r],u===this.selectedFeature&&(f=e.vectorLayerSelectStyleFunction(t,this.selectedFeature),f))||(f=e.vectorLayerHighlightStyleFunction(t,u),f&&u.setStyle(f),this.highlightedFeature=u,t.layerSettings.inMouseMoveCallback===!0&&(s.push(c),h.push(u)));t.layerSettings.inClickCallback===!0&&(a=!0)}v&&this.highlightedFeature===null&&(t=v.get("layer"),t.changed());b.map.mouseMoveCallback&&(w=e._getFunctionByName(b.map.mouseMoveCallback),w&&w(n,s,h));a===!0?M$("#"+e.container).css("cursor","pointer"):M$("#"+e.container).css("cursor","default")}},{key:"_mapMoveStart",value:function(){this.mapMoveStart_Zoom=this.getView().zoom}},{key:"_mapMoveEnd",value:function(n){var r=this.map.getView().getZoom(),t,i;r!==this.mapMoveStart_Zoom&&this._clearTempObjectLayer();t=this.settings;t.map.mapDragCallback&&(i=this._getFunctionByName(t.map.mapDragCallback),i&&i(n))}},{key:"_mapZoomChanged",value:function(){}},{key:"setViewByResolution",value:function(n,t,i){var r=this.map.getView();n&&r.setResolution(n);t&&i&&r.setCenter([t,i])}},{key:"setViewByZoom",value:function(n,t,i){var r=this.map.getView();n&&r.setZoom(n);t&&i&&r.setCenter([t,i])}},{key:"setViewByExtent",value:function(n,t,i,r){var u=[n,t,i,r],f=this.map.getView();f.fit(u)}},{key:"setViewByLayerExtent",value:function(n){var t,i,r;(n instanceof ol.layer.Vector||(n=this.getLayer(n)),n instanceof ol.layer.Vector)&&(t=n.getSource(),t instanceof ol.source.Cluster&&(t=t.getSource()),i=t.getExtent(),r=this.map.getView(),isFinite(i[0])&&r.fit(i))}},{key:"getView",value:function(){var n=this.map.getView(),t=n.getProperties();return t.zoom=n.getZoom(),t}},{key:"getLayerExtent",value:function(n){var t;return(n instanceof ol.layer.Vector||(n=this.getLayer(n)),!(n instanceof ol.layer.Vector))?null:(t=n.getSource(),t instanceof ol.source.Cluster&&(t=t.getSource()),t.getExtent())}},{key:"getMapExtent",value:function(){return this.map.getView().calculateExtent(this.map.getSize())}},{key:"getLayers",value:function(){function i(n,t){return n.get("zIndex")<t.get("zIndex")?1:n.get("zIndex")>t.get("zIndex")?-1:0}var t=this.map,n=[];return t.getLayers().forEach(function(t){t instanceof ol.layer.Group?t.getLayers().forEach(function(t){n.push(t)}):n.push(t)}),n.sort(i),n}},{key:"getLayersByType",value:function(n){for(var r=this.getLayers(),u=[],i,t=0;t<r.length;t++)i=r[t],i.get("type")===n&&u.push(i);return u}},{key:"getLayer",value:function(n){var i=this.map,t;return i.getLayers().forEach(function(i){if(i instanceof ol.layer.Group)i.getLayers().forEach(function(i){var r=i.get("code");if(r===n){t=i;return}});else{var r=i.get("code");if(r===n){t=i;return}}}),t}},{key:"setLayerVisible",value:function(n,t){(typeof n=="string"&&(n=this.getLayer(n)),n)&&n.setVisible(t)}},{key:"isLayerDisplayed",value:function(n){if(typeof n=="string"&&(n=this.getLayer(n)),n){var t=this.getView().resolution;return n.getVisible()&&n.getMinResolution()<t&&t<n.getMaxResolution()}}},{key:"removeLayer",value:function(n){(typeof n=="string"&&(n=this.getLayer(n)),n)&&this.map.removeLayer(n)}},{key:"refreshLayer",value:function(n){if(typeof n=="string"&&(n=this.getLayer(n)),n){var t=n.getSource();t instanceof ol.source.Cluster&&(t=t.getSource());t.clear()}}},{key:"filterLayer",value:function(n,t){(n instanceof ol.layer.Vector||(n=this.getLayer(n)),n)&&(this.map.removeLayer(n),n.layerSettings.filter=t,this.addVectorLayer(n.layerSettings))}},{key:"_initLayer",value:function(n){var t,r,i;return n?n.enabled===!1?!1:(n.addToLayerSwitcher||(n.addToLayerSwitcher=!1),typeof n.visible!="boolean"&&(n.visible=!0),n.projection?n.projection instanceof ol.proj.Projection||(t=n.projection.code,r={code:t,units:n.projection.unit},n.projection=new ol.proj.Projection(r),i=ol.proj.get(t),i&&n.projection.setExtent(i.getExtent())):n.projection=this.defaultProjection,n.minResolution===-1&&(n.minResolution=undefined),n.maxResolution===-1&&(n.maxResolution=undefined),n.extent||(n.extent=n.projection.getExtent()),n.origin===null&&(n.origin={},n.origin.x=-20037508.34,n.origin.y=20037508.34),n.resolutions===null&&(n.resolutions=[156543.0339,78271.51695,39135.758475,19567.8792375,9783.93961875,4891.969809375,2445.9849046875,1222.99245234375,611.496226171875,305.748113085938,152.874056542969,76.4370282714844,38.2185141357422,19.1092570678711,9.55462853393555,4.77731426696777,2.38865713348389,1.19432856674194,.597164283370971]),!0):!1}},{key:"addOsmLayer",value:function(n){if(this._initLayer(n)!==!1){var i=new ol.source.TileImage({attributions:n.attribution,crossOrigin:null,projection:n.projection,tileGrid:new ol.tilegrid.TileGrid({origin:[n.origin.x,n.origin.y],resolutions:n.resolutions}),url:n.url}),t=new ol.layer.Tile({opacity:n.opacity,code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,source:i,visible:n.visible,zIndex:n.zIndex});t.layerSettings=n;this.map.addLayer(t)}}},{key:"addWmsLayers",value:function(n){var t=this;n&&M$(n).each(function(){t.addWmsLayer(this)})}},{key:"addWmsLayer",value:function(n){this._initLayer(n)!==!1&&(n.singleImage?this._addSingleImageWmsLayer(n):this._addWmsLayer(n))}},{key:"_addWmsLayer",value:function(n){var i=new ol.source.TileWMS({attributions:n.attribution,crossOrigin:null,params:{BBOX:n.extent,CRS:n.projection.getCode(),SRS:n.projection.getCode(),FORMAT:n.format,HEIGHT:n.height,LAYERS:n.code,STYLES:n.styles,VERSION:n.version,WIDTH:n.width,TILED:n.tiled},projection:n.projection,tileGrid:new ol.tilegrid.TileGrid({origin:[n.origin.x,n.origin.y],resolutions:n.resolutions}),transition:n.transition,url:n.url}),t=new ol.layer.Tile({code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,opacity:n.opacity,source:i,visible:n.visible,zIndex:n.zIndex,type:"wms"});t.layerSettings=n;this.map.addLayer(t)}},{key:"_addSingleImageWmsLayer",value:function(n){var i={BBOX:n.extent,CRS:n.projection.getCode(),SRS:n.projection.getCode(),FORMAT:n.format,LAYERS:n.code,STYLES:"",VERSION:n.version},r=new ol.source.ImageWMS({attributions:n.attribution,crossOrigin:null,params:i,projection:n.projection,ratio:1.5,resolutions:n.resolutions,url:n.url}),t=new ol.layer.Image({code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,opacity:n.opacity,source:r,visible:n.visible,zIndex:n.zIndex,type:"singleimagewms"});t.layerSettings=n;this.map.addLayer(t)}},{key:"addWmtsLayers",value:function(n){var t=this;n&&M$(n).each(function(){t.addWmtsLayer(this)})}},{key:"addWmtsLayer",value:function(n){var i,t,r,u;if(this._initLayer(n)!==!1){if(i=[],t=[],n.isRestful)for(t=n.resolutions,r=0;r<t.length;r++)i.push(r);else for(u=n.maxResolution/Math.pow(2,t.length);u>=n.minResolution;)i.push(t.length),t.push(u),u=n.maxResolution/Math.pow(2,t.length);var e=n.projection.getCode(),o=n.isRestful||n.matrixSet?n.matrixSet:e,s=n.isRestful?n.style:"",h=n.isRestful?"REST":"KVP",c=new ol.source.WMTS({attributions:n.attribution,crossOrigin:null,format:n.format,projection:n.projection,layer:n.code,matrixSet:o,style:s,requestEncoding:h,tileGrid:new ol.tilegrid.WMTS({origin:[n.origin.x,n.origin.y],resolutions:t,matrixIds:i}),url:n.url,version:n.version}),f=new ol.layer.Tile({opacity:n.opacity,code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,source:c,visible:n.visible,zIndex:n.zIndex});f.layerSettings=n;this.map.addLayer(f)}}},{key:"_getWmsFeatureInfo",value:function(n,t,i){var o=this.map,u=o.getView(),f=t.getSource(),r=f.getProjection(),s=u.getResolution(),h=t.get("code"),e;r||(r=u.getProjection());e=f.getGetFeatureInfoUrl(n,s,r,{INFO_FORMAT:"application/json"});M$.post(e,{},function(n){i(h,n)})}},{key:"addWfsLayers",value:function(n){var t=this;n&&M$(n).each(function(){t.addWfsLayer(this)})}},{key:"addWfsLayer",value:function(n){var i,t,f,r,e,u;this._initLayer(n)!==!1&&(n.version||(n.version="1.1.0"),n.outputFormat?n.outputFormat==="GML2"?i=new ol.format.GML2:n.outputFormat==="GML3"?i=new ol.format.GML3:n.outputFormat==="GML32"?i=new ol.format.GML32:(n.outputFormat="application/json",i=new ol.format.GeoJSON):(n.outputFormat="application/json",i=new ol.format.GeoJSON),t=new ol.layer.Vector({code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,opacity:n.opacity,visible:n.visible,zIndex:n.zIndex,type:"wfs"}),t.layerSettings=n,n.styles&&n.styles.length!==0||(n.styles=[],f={fillColor:"transparent",strokeColor:"#666666",strokeWidth:1.5},n.styles.push(f)),r={},e=function(i){var f=t.get("filter"),o;if(f&&(o=i.get(f.attribute),M$.inArray(o,f.values)===-1))return null;var e=n.styles[0],s=i.get("strokeColor")||e.strokeColor,h=i.get("strokeWidth")||e.strokeWidth,c=i.get("fillColor")||e.fillColor,l=s+"_"+h+"_"+c,u=r[l];return u||(u=new ol.style.Style({fill:new ol.style.Fill({color:c}),stroke:new ol.style.Stroke({color:s,width:h})}),r[l]=u),u},t.setStyle(e),u=new ol.source.Vector({format:i,loader:function(i,r,f){var d=this,o=ol.format.filter,h=t.layerSettings.filter,a,v=o.bbox("",i,p),e,c,l,p,k;if(h&&h.length>0){for(e=[],e.push(v),c=0;c<h.length;c++){var w=h[c],y=w.property,s=w.values,b=[];if(s)if(s.length===0)e.push(o.equalTo(y,"thisisadummyvalue"));else if(s.length===1)e.push(o.equalTo(y,s[0]));else{for(l=0;l<s.length;l++)b.push(o.equalTo(y,s[l]));e.push(o.or.apply(null,b))}else continue}a=e.length===1?v:o.and.apply(null,e)}else a=v;p=f.getCode();k=(new ol.format.WFS).writeGetFeature({srsName:p,featurePrefix:n.typeName.split(":")[0],featureTypes:[n.typeName.split(":")[1]],outputFormat:n.outputFormat,filter:a});M$.ajax(n.url,{contentType:"text/plain",type:"POST",data:(new XMLSerializer).serializeToString(k)}).done(function(n){var t=u.getFormat(),i=t.readFeatures(n);d.addFeatures(i)})},strategy:ol.loadingstrategy.bbox}),t.setSource(u),this.map.addLayer(t))}},{key:"addVectorLayers",value:function(n){var t=this;n&&M$(n).each(function(){t.addVectorLayer(this)})}},{key:"getFeatureCount",value:function(n,t,i,r){var u=n[i],f;return u||(f=t.getView().calculateExtent(),u=r.getSource().getFeaturesInExtent(f).length,n[i]=u),[u,n]}},{key:"addCircleVectorLayer",value:function(n,t){var u=this,r,i;this._initLayer(n)!==!1&&(r=new ol.source.Vector({features:t}),i=new ol.layer.Vector({code:n.code,name:n.name,type:"circle",source:r,visible:n.visible,zIndex:n.zIndex,declutter:!1}),i.layerSettings=n,this.map.addLayer(i))}},{key:"addVectorLayer",value:function(n,t){var u=this,f,e,r,i;this._initLayer(n)!==!1&&(n.styles&&n.styles.length!==0||(n.styles=[],f={fillColor:"transparent",strokeColor:"#666666",strokeWidth:1.5},n.styles.push(f)),e=n.format?n.format==="GML"?new ol.format.WFS({gmlFormat:new ol.format.GML}):n.format==="GML2"?new ol.format.WFS({gmlFormat:new ol.format.GML2}):n.format==="GML3"?new ol.format.WFS({gmlFormat:new ol.format.GML}):new ol.format.GeoJSON:new ol.format.GeoJSON,r=new ol.source.Vector({attributions:n.attribution,format:e,projection:n.projection,loader:function(){t?u.getSourceLoaderCallback(r,i,t):M$.ajax(n.url,{type:"GET"}).done(function(n){u.getSourceLoaderCallback(r,i,n)})}}),i=new ol.layer.Vector({renderMode:n.renderMode==="image"?"image":"vector",code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,opacity:n.opacity,source:r,visible:n.visible,zIndex:n.zIndex,style:u.getVectorStyleFunction.bind(this),type:"vector",declutter:!0}),i.layerSettings=n,this.map.addLayer(i))}},{key:"getVectorStyleFunction",value:function(n,t){var o=n.get("layer"),r=o.layerSettings,i=r.styles[0],c=n.get("styleIndex"),h,v,y,p,w,e;c&&c>=0&&r.styles.length>c&&(i=r.styles[c]);var u=r.styleCache||{},s=n.get("strokeColor")||i.strokeColor,a=n.get("strokeWidth")||i.strokeWidth,l=n.get("fillColor")||i.fillColor,g=n.get("usePattern")||i.usePattern,nt=n.get("patternStyle")||i.patternStyle,tt=n.get("patternColor")||i.patternColor,b=s+"_"+a+"_"+l,f=u[b];if(f||(f=new ol.style.Style({fill:new ol.style.Fill({color:g?this.getPattern(l,nt,tt):l}),stroke:new ol.style.Stroke({color:s,width:a})}),u[b]=f,r.styleCache=u),o.get("code")!==undefined&&o.get("code")==="arrowstream"&&(h=n.getGeometry().getCoordinates(),v=0,h.length>2&&(y=h[0],p=h[h.length-1],v=Math.atan2(p[0]-y[0],p[1]-y[1])),f.setText(new ol.style.Text({font:"normal 16px 'Font Awesome 5 Pro'",stroke:new ol.style.Stroke({color:s,width:2}),fill:new ol.style.Fill({color:s}),backgroundFill:new ol.style.Fill({color:i.textBackgroundColor?i.textBackgroundColor:"transparent"}),text:"",overflow:!0,rotation:v}))),i.textFeatureProperty){var k={},d=this.getFeatureCount(k,this.map,o.get("code")+"_"+t,o),it=d[0],rt=n.get("force");if(k=d[1],!i.textFeatureLimit||it<=i.textFeatureLimit||rt)return w="label_"+s+"_"+a+"_"+l,e=u[w],e||(e=new ol.style.Style({geometry:function(n){var o=n.get("coordinateX"),s=n.get("coordinateY"),t,r,u,i,h,f,e;if(o&&s)return new ol.geom.Point([o,s]);if(t=n.getGeometry(),t.getType()==="MultiPolygon")for(r=t.getPolygons(),u=0,i=0,h=r.length;i<h;++i)f=r[i],e=ol.extent.getWidth(f.getExtent()),e>u&&(u=e,t=f);return t}}),u[w]=e,r.styleCache=u),e.setText(new ol.style.Text({font:i.textFont,stroke:new ol.style.Stroke({color:i.textStrokeColor,width:i.textStrokeWidth}),fill:new ol.style.Fill({color:i.textFillColor}),backgroundFill:new ol.style.Fill({color:i.textBackgroundColor?i.textBackgroundColor:"transparent"}),text:n.get(i.textFeatureProperty),textBaseline:i.textBaseLine?i.textBaseLine:"middle",overflow:!0})),[e,f]}return f}},{key:"getSourceLoaderCallback",value:function(n,t,i){for(var h=n.getFormat(),e=h.readFeatures(i),o=[],f=t.layerSettings.filter,u,s,r=0;r<e.length;r++)(u=e[r],f&&(s=u.get(f.attribute),M$.inArray(s,f.values)===-1))||(u.set("layer",t),o.push(u));n.addFeatures(o);t.set("featuresAdded",!0)}},{key:"addObjectLayer",value:function(n,t){var f=this,o,r,e,l,a,p,u,s,i,w,c,b;if(this._initLayer(n)!==!1){r=new ol.layer.Vector({code:n.code,minResolution:n.minResolution,maxResolution:n.maxResolution,name:n.name,opacity:n.opacity,visible:n.visible,zIndex:n.zIndex,defaultIcon:n.defaultIcon,icons:n.icons,type:"object",isTempLayer:n.isTempLayer,styles:n.styles});r.layerSettings=n;var v=new ol.source.Vector({attributions:n.attribution,projection:n.projection}),y=v,h=n.cluster&&n.cluster.enabled===!0;for(h&&(y=new ol.source.Cluster({attributions:n.attribution,distance:n.cluster.distance,source:v,geometryFunction:function(n){return n.getGeometry()}})),r.setSource(y),f.map.addLayer(r),e=r.get("icons"),l={},o=0;o<e.length;o++)l[e[o].code]=e[o];return n.defaultIcon&&e.push(n.defaultIcon),n.selectIcon&&e.push(n.selectIcon),n.highlightIcon&&e.push(n.highlightIcon),h&&e.push(n.cluster.icon),f._setMaxIconSize(e),h&&(u=n.cluster.icon,u.src===null&&u.iconFont?p=new ol.style.Text({text:u.iconText,font:u.iconFont,textBaseline:"bottom",fill:new ol.style.Fill({color:u.iconColor}),stroke:new ol.style.Stroke({width:3,color:"rgb(128,128,128)"})}):a=new ol.style.Icon({anchor:u.anchor?u.anchor:undefined,opacity:1,scale:1,size:[u.width,u.height],src:u.src})),s={},w=function(t){var v,c,y,e,w,u,o,b;if(t.get("geometry")instanceof ol.geom.LineString)return new ol.style.Style({stroke:new ol.style.Stroke({color:"000",width:1})});if(t===f.selectedCluster)return i=f.objectLayerSelectStyleFunction(r,t);if(h)if(v=t.get("features"),c=v.length,c===1)t=v[0];else return y="cluster_"+c,i=s[y],i||(i=a?new ol.style.Style({image:a,text:new ol.style.Text({text:c.toString(),fill:new ol.style.Fill({color:"#000000"}),offsetY:-18})}):[new ol.style.Style({text:p}),new ol.style.Style({text:new ol.style.Text({text:c.toString(),fill:new ol.style.Fill({color:"#000000"}),offsetY:n.cluster.icon.height*-.65})})],s[y]=i),i;return(e=r.get("filter"),e&&(w=t.get("properties")[e.attribute],e.values&&M$.inArray(w,e.values)===-1||e.notInValues&&M$.inArray(w,e.notInValues)===0))?null:t===f.selectedFeature&&n.selectIcon?i=f.objectLayerSelectStyleFunction(r,t):t===f.highlightedFeature&&n.highlightIcon?i=f.objectLayerHighlightStyleFunction(r,t):(u=l[t.get("properties").icon],u||(u=n.defaultIcon),i=s[u.code],i||(i=u.src===null&&u.iconFont?new ol.style.Style({text:new ol.style.Text({text:u.iconText,font:u.iconFont,textBaseline:"bottom",fill:new ol.style.Fill({color:u.iconColor})})}):new ol.style.Style({image:new ol.style.Icon({anchor:u.anchor?u.anchor:undefined,size:[u.width,u.height],opacity:1,scale:u.scale,src:u.src})}),s[u.code]=i),u.src===null&&u.iconFont&&n.styles&&(o=n.styles[0],o))?(b=new ol.style.Style({text:new ol.style.Text({font:o.textFont,stroke:new ol.style.Stroke({color:o.textStrokeColor,width:o.textStrokeWidth}),fill:new ol.style.Fill({color:o.textFillColor}),text:t.getProperties().properties.name,overflow:!1})}),[i,b]):i},r.setStyle(w),r.imagesLoaded=!0,f.addFeaturesToObjectLayer(r,t),c=[],n.isTempLayer||(b={isTempLayer:!0,code:n.code+"_temp",addToLayerSwitcher:!1,defaultIcon:n.defaultIcon,enabled:!0,highlightIcon:n.highlightIcon,icons:n.icons,inClickCallback:n.inClickCallback,inMouseMoveCallback:n.inMouseMoveCallback,opacity:n.opacity,projection:n.projection,selectIcon:n.selectIcon,visible:!0,zIndex:n.zIndex+1},c=f.addObjectLayer(b)),c.push(r),c}}},{key:"_initSelectCallbacks",value:function(){var n=this,t=function(t,i,r){var y=r,e,u,o,s=y.get("features"),b,l,f,ft,k,h,nt,tt,g,c,it,rt,w,ht,ut,ct,lt;for(s||(s=[],s.push(y)),b=[],e=0;e<s.length;e++)b.push(s[e].get("properties"));if(s.length===1)y=s[0],y.get("layer").get("isTempLayer")!==!0?n._clearTempObjectLayer():(l=y.get("properties"),l._originalX&&(l.x=l._originalX,l.y=l._originalY));else if(s.length>1){for(f=[],e=0;e<b.length;e++)ft=M$.extend({},b[e]),f.push(ft);k=n.getLayer(i.get("code")+"_temp");n.clearFeaturesObjectLayer(k);var d=r.getGeometry().getCoordinates(),et=n.map.getPixelFromCoordinate(d),at=n.maxIconSize,vt=[et[0]+10+f.length*at/(Math.PI*2),et[1]],ot=n.map.getCoordinateFromPixel(vt)[0]-d[0],p=[];for(u=0;u<f.length;u++){var st=360/f.length*u,yt=d[0]+Math.cos(st*Math.PI/180)*ot,pt=d[1]+Math.sin(st*Math.PI/180)*ot;p.push([yt,pt])}for(h=[],nt={},u=0;u<f.length;u++){for(tt=Number.MAX_VALUE,g=-1,r=f[u],c=0;c<f.length;c++)nt[c]!==!0&&(it=Math.sqrt(Math.pow(p[c][0]-r.x,2)+Math.pow(p[c][1]-r.y,2)),it<tt&&(tt=it,g=c));o=[];o.push([f[u].x,f[u].y]);o.push(p[g]);h.push(o);nt[g]=!0}for(u=0;u<f.length;u++)r=f[u],o=[],o.push([f[u].x,f[u].y]),o.push(p[u]),h.push(o);for(rt=0;rt<5;rt++)for(u=0;u<f.length;u++)for(w=0;w<f.length;w++)if(u!==w){var a=h[u],v=h[w],wt=a[0][0],bt=a[0][1],kt=a[1][0],dt=a[1][1],gt=v[0][0],ni=v[0][1],ti=v[1][0],ii=v[1][1];n._lineIntersect(wt,bt,kt,dt,gt,ni,ti,ii)&&(ht=a[1],a[1]=v[1],v[1]=ht)}for(ut=[],u=0;u<f.length;u++)ct=new ol.Feature({geometry:new ol.geom.LineString(h[u]),layer:i}),ut.push(ct);for(lt=k.getSource(),lt.addFeatures(ut),u=0;u<f.length;u++)r=f[u],r._originalX=r.x,r._originalY=r.y,r.x=h[u][1][0],r.y=h[u][1][1];n.addFeaturesToObjectLayer(k,f,!1)}},i=function(){};this.selectCallback=function(n,r,u){var f=r.get("type");return f==="vector"?i(n,r,u):f==="object"?t(n,r,u):void 0}}},{key:"_initSelectStyle",value:function(){var n=this;n.objectLayerSelectStyleFunction=function(n,t){var r,u=t.get("features"),i,f,e;if(u)if(u.length===1)r=u[0];else return null;else r=t;return i=n.layerSettings,i.selectIcon?(e=new ol.style.Style({image:new ol.style.Icon({anchor:i.selectIcon.anchor?i.selectIcon.anchor:undefined,size:[i.selectIcon.width,i.selectIcon.height],opacity:1,scale:i.selectIcon.scale,src:i.selectIcon.src})}),f=e):f=r.getStyle(i),f};n.vectorLayerSelectStyleFunction=function(n,t){var i=n.layerSettings,r;return i.selectStyles&&i.selectStyles.length>0&&(r=new ol.style.Style({fill:new ol.style.Fill({color:i.selectStyles[0].fillColor}),stroke:new ol.style.Stroke({color:i.selectStyles[0].strokeColor,width:i.selectStyles[0].strokeWidth}),text:new ol.style.Text({font:i.selectStyles[0].textFont,stroke:new ol.style.Stroke({color:i.selectStyles[0].textStrokeColor,width:i.selectStyles[0].textStrokeWidth}),fill:new ol.style.Fill({color:i.selectStyles[0].textFillColor}),text:t.get(i.selectStyles[0].textFeatureProperty),overflow:!1})})),r}}},{key:"_lineIntersect",value:function(n,t,i,r,u,f,e,o){var s=((n*r-t*i)*(u-e)-(n-i)*(u*o-f*e))/((n-i)*(f-o)-(t-r)*(u-e)),h=((n*r-t*i)*(f-o)-(t-r)*(u*o-f*e))/((n-i)*(f-o)-(t-r)*(u-e));if(isNaN(s)||isNaN(h))return!1;if(n>=i){if(!(i<=s&&s<=n))return!1}else if(!(n<=s&&s<=i))return!1;if(t>=r){if(!(r<=h&&h<=t))return!1}else if(!(t<=h&&h<=r))return!1;if(u>=e){if(!(e<=s&&s<=u))return!1}else if(!(u<=s&&s<=e))return!1;if(f>=o){if(!(o<=h&&h<=f))return!1}else if(!(f<=h&&h<=o))return!1;return!0}},{key:"_initHighlightStyle",value:function(){var n=this;n.objectLayerHighlightStyleFunction=function(n,t){var i=n.layerSettings,r,u;return i.highlightIcon?new ol.style.Style({image:new ol.style.Icon({anchor:i.highlightIcon.anchor?i.highlightIcon.anchor:undefined,size:[i.highlightIcon.width,i.highlightIcon.height],opacity:1,scale:i.highlightIcon.scale,src:i.highlightIcon.src})}):(r=n.getStyleFunction(),u=r(t),u)};n.vectorLayerHighlightStyleFunction=function(n,t){var i=n.layerSettings,r;return i.highlightStyles&&i.highlightStyles.length>0&&(r=new ol.style.Style({fill:new ol.style.Fill({color:i.highlightStyles[0].fillColor}),stroke:new ol.style.Stroke({color:i.highlightStyles[0].strokeColor,width:i.highlightStyles[0].strokeWidth}),text:new ol.style.Text({font:i.highlightStyles[0].textFont,stroke:new ol.style.Stroke({color:i.highlightStyles[0].textStrokeColor,width:i.highlightStyles[0].textStrokeWidth}),fill:new ol.style.Fill({color:i.highlightStyles[0].textFillColor}),text:t.get(i.highlightStyles[0].textFeatureProperty),overflow:!0})})),r}}},{key:"getFeature",value:function(n,t,i){var r,u,f;if((typeof n=="string"&&(n=this.getLayer(n)),!n)||(r=n.getSource(),r instanceof ol.source.Cluster&&(r=r.getSource()),!r))return null;if(u=r.getFeatures(),u)for(f=0;f<u.length;f++)if(u[f].get(t)===i)return u[f];return null}},{key:"selectFeature",value:function(n,t,i){var r,u,f;(typeof n=="string"&&(n=this.getLayer(n)),r=this.getFeature(n,t,i),n)&&(u=n.get("type"),u==="object"?r!==this.highlightedFeature&&n.changed():u==="vector"&&(f=this.vectorLayerSelectStyleFunction(n,r),f&&r.setStyle(f)),this.selectedFeature=r)}},{key:"unselectFeature",value:function(){this.selectedFeature&&this.selectedFeature.setStyle(null)}},{key:"highlightFeature",value:function(n,t,i){var r,u,f;(typeof n=="string"&&(n=this.getLayer(n)),r=this.getFeature(n,t,i),n)&&(u=n.get("type"),u==="object"?r!==this.highlightedFeature&&n.changed():u==="vector"&&(f=this.vectorLayerHighlightStyleFunction(n,r),f&&r.setStyle(f)),this.highlightedFeature=r)}},{key:"unhighlightFeature",value:function(){this.highlightedFeature&&this.highlightedFeature.setStyle(null)}},{key:"addFeaturesToObjectLayer",value:function(n,t,i){var e,f,r,o,u;if((i===!1||i||(i=!0),n instanceof ol.layer.Vector||(n=this.getLayer(n)),n)&&t){for(e=[],f=0;f<t.length;f++)r=t[f],r&&r.x&&r.x!==-1&&r.y&&r.y!==-1&&(o=new ol.Feature({geometry:new ol.geom.Point([r.x,r.y]),properties:r,layer:n}),e.push(o));u=n.getSource();u instanceof ol.source.Cluster&&(u=u.getSource());i&&u.clear();u.addFeatures(e)}}},{key:"clearFeaturesObjectLayer",value:function(n){(n instanceof ol.layer.Vector||(n=this.getLayer(n)),n)&&n.getSource().clear()}},{key:"_clearTempObjectLayer",value:function(){var t=this.getLayersByType("object"),n,i,r,u;if(t){for(n=0;n<t.length;n++)i=t[n],i.get("isTempLayer")===!0&&i.getSource().clear();this.selectedCluster!==null&&(r=this.selectedCluster.get("features"),u=r[0].get("layer"),u.changed());this.selectedFeature===this.selectedCluster&&(this.selectedFeature=null);this.selectedCluster=null}}},{key:"addCircle",value:function(n,t,i,r,u,f,e,o){var l={},s,a,h,v,y,c;this._initLayer(l)!==!1&&(s=new ol.Feature({geometry:new ol.geom.Circle([t,i],r)}),a="rgba("+f+","+u+")",s.setStyle(new ol.style.Style({fill:new ol.style.Fill({color:a}),stroke:new ol.style.Stroke({color:e,width:o})})),h=new ol.Feature({geometry:new ol.geom.Point([t,i])}),v="rgba("+f+",1)",h.setStyle(new ol.style.Style({image:new ol.style.Circle({radius:3,fill:new ol.style.Fill({color:v}),stroke:new ol.style.Stroke({color:e})})})),y=new ol.source.Vector({projection:l.projection,features:[s,h]}),c=new ol.layer.Vector({code:n,name:"circle",source:y,type:"circle"}),c.layerSettings={},this.map.addLayer(c))}},{key:"_setMaxIconSize",value:function(n){for(var t,i=0;i<n.length;i++)t=n[i],t.width>this.maxIconSize&&(this.maxIconSize=t.width),t.height>this.maxIconSize&&(this.maxIconSize=t.height)}},{key:"_setIconSize",value:function(n,t){for(var f=this,i,u=[],o=0,e,r=0;r<n.length;r++)i=n[r],(i.width<=0||i.height<=0)&&u.push(i),i.width>this.maxIconSize&&(f.maxIconSize=i.width),i.height>this.maxIconSize&&(f.maxIconSize=i.height);for(u.length===0&&t(),r=0;r<u.length;r++)i=u[r],(i.width<=0||i.height<=0)&&(e=new Image,e.icon=i,e.onload=function(){o++;this.icon.width=this.width;this.icon.height=this.height;o===u.length&&t();this.icon.width>this.maxIconSize&&(f.maxIconSize=this.icon.width);this.icon.height>this.maxIconSize&&(f.maxIconSize=this.icon.height)},e.src=i.src)}},{key:"clearMap",value:function(){var t=this,n=this.map,u=n.getLayers(),r=[],f,i;for(n.getLayers().forEach(function(n){n instanceof ol.layer.Vector&&(n.getSource()&&(n.getSource().clear(!1),n.getSource().setLoader(null)),n.setSource(null),n.setStyle(null));r.push(n)}),f=r.length,i=0;i<f;i++)n.removeLayer(r[i]);u.clear();u=null;n.un("movestart",function(n){t._mapMoveStart(n)});n.un("moveend",function(n){t._mapMoveEnd(n)});n.un("singleclick",function(n){t._mapClicked(n)});n.un("pointermove",function(n){t._mapPointerMove(n)});n.getViewport().removeEventListener("contextmenu",function(n){n.preventDefault();t._mapContextMenu(n)});n.getView().un("change:resolution",function(n){t._mapZoomChanged(n)})}},{key:"clearLayer",value:function(n){var t=this.map;n instanceof ol.layer.Vector&&(n.getSource()&&(n.getSource().clear(!1),n.getSource().setLoader(null)),n.setSource(null),n.setStyle(null));t.removeLayer()}},{key:"getPattern",value:function(n,t,i){var u=document.createElement("canvas"),r=u.getContext("2d");u.width=10;u.height=10;switch(t){case"ForwardDiagonal":r.moveTo(0,0);r.lineTo(10,10);r.moveTo(-1,9);r.lineTo(1,11);r.moveTo(9,-1);break;case"BackwardDiagonal":r.moveTo(0,10);r.lineTo(10,0);r.moveTo(-1,1);r.lineTo(1,-1);r.moveTo(9,11);r.lineTo(11,9);break;case"Cross":r.moveTo(0,0);r.lineTo(11,0);r.moveTo(0,0);r.lineTo(0,11);break;case"DarkDownwardDiagonal":u.width=4;u.height=4;r.moveTo(0,0);r.lineTo(4,4);r.moveTo(-1,3);r.lineTo(1,5);r.moveTo(3,-1);r.lineTo(5,1);break;case"DarkUpwardDiagonal":u.width=4;u.height=4;r.moveTo(0,4);r.lineTo(4,0);r.moveTo(-1,1);r.lineTo(1,-1);r.moveTo(3,5);r.lineTo(5,3);break;case"Horizontal":r.moveTo(0,0);r.lineTo(11,0);break;case"Vertical":r.moveTo(0,0);r.lineTo(0,11);break;case"DarkHorizontal":u.width=5;u.height=5;r.moveTo(0,0);r.lineTo(6,0);break;case"DarkVertical":u.width=5;u.height=5;r.moveTo(0,0);r.lineTo(0,6);break;case"DashedDownwardDiagonal":u.width=5;u.height=5;r.moveTo(0,0);r.lineTo(3,5);break;case"DashedUpwardDiagonal":u.width=5;u.height=5;r.moveTo(0,5);r.lineTo(3,0);break;case"DashedHorizontal":r.moveTo(0,1);r.lineTo(6,1);r.moveTo(4,6);r.lineTo(10,6);break;case"DashedVertical":r.moveTo(1,0);r.lineTo(1,6);r.moveTo(6,4);r.lineTo(6,10);break;default:return n}return r.fillStyle=n,r.fillRect(0,0,u.width,u.height),r.lineWidth="1",r.strokeStyle=i,r.stroke(),r.createPattern(u,"repeat")}},{key:"_getFunctionByName",value:function(n){var i,t,r;if(typeof n=="function")return n;if(!n)return null;for(i=n.split("."),t=window[i[0]],r=1;r<i.length;r++){if(!t)return;t=t[i[r]]}return t}},{key:"_ajaxDeferredPost",value:function(n,t,i){var r=M$.Deferred();return M$.ajax({type:"POST",url:this.abfMapsRoot+n,data:t,dataType:"json"}).done(function(n){if(n&&!n.error){var t=i;t&&typeof t=="function"&&t(n);r.resolveWith(this,[n])}else n.error&&r.rejectWith(this,[n])}),r.promise()}},{key:"_executeWhenReady",value:function(n,t,i){var r=this;n[t]?i():setTimeout(function(){r._executeWhenReady(n,t,i)},50)}}]),n}(),ABF_GeoJSON={GeoJson:{},GeoTimestamps:{},IndexedDb:{Name:"",MapDb:null,MapDbLoaded:!1,IndexedDbAvailable:function(){return window.indexedDB!=null&&window.indexedDB!=undefined},OpenMapDb:function(){if(!ABF_GeoJSON.IndexedDb.IndexedDbAvailable()){ABF_GeoJSON.IndexedDb.MapDb="unavailable";ABF_GeoJSON.IndexedDb.MapDbLoaded=!0;return}try{var n=window.indexedDB.open(ABF_GeoJSON.IndexedDb.Name,6);n.onsuccess=function(){ABF_GeoJSON.IndexedDb.MapDb=this.result;ABF_GeoJSON.IndexedDb.LoadGeoJsonFromIndexedDb()};n.onerror=function(){ABF_GeoJSON.IndexedDb.MapDb="unavailable";ABF_GeoJSON.IndexedDb.MapDbLoaded=!0};n.onupgradeneeded=function(n){n.oldVersion>0&&n.newVersion==6&&n.currentTarget.result.deleteObjectStore("geoJson_dashboard");var t=n.currentTarget.result.createObjectStore("geoJson_dashboard",{keyPath:"geoLevel"})};n.onblocked=function(){ABF_GeoJSON.IndexedDb.MapDb="unavailable";ABF_GeoJSON.IndexedDb.MapDbLoaded=!0}}catch(t){ABF_GeoJSON.IndexedDb.MapDb="unavailable";ABF_GeoJSON.IndexedDb.MapDbLoaded=!0}},SetGeoJsonForLevel:function(n,t){ABF_GeoJSON.GeoJson[t]=n;ABF_GeoJSON.IndexedDb.IndexedDbAvailable()&&setTimeout(function(){ABF_GeoJSON.IndexedDb.SetGeoJsonToIndexedDb(t,n)},100)},GetGeoJsonForLevel:function(n){return ABF_GeoJSON.GeoJson[n]},HasGeoJsonForLevel:function(n){var t,i;if(ABF_GeoJSON.GeoJson[n]!=null)return ABF_Model.JiveTimestamps.StudioTimestamp&&(t=ABF_GeoJSON.IndexedDb.GetTimeStamp(ABF_Model.JiveTimestamps.StudioTimestamp),ABF_GeoJSON.GeoTimestamps.hasOwnProperty(n)&&(i=ABF_GeoJSON.GeoTimestamps[n],ABF_GeoJSON.IndexedDb.GetTimeStamp(i)>=t))?!0:!1},AvailableGeoJsonLevels:function(){var t=[],i,n,r;if(ABF_Model.JiveTimestamps.StudioTimestamp){i=ABF_GeoJSON.IndexedDb.GetTimeStamp(ABF_Model.JiveTimestamps.StudioTimestamp);for(n in ABF_GeoJSON.GeoTimestamps)ABF_GeoJSON.GeoTimestamps.hasOwnProperty(n)&&(r=ABF_GeoJSON.GeoTimestamps[n],ABF_GeoJSON.IndexedDb.GetTimeStamp(r)>=i&&t.push(n))}return t},GetTimeStamp:function(n){var r=n.split(" "),o;if(r.length===2){var s=r[0],h=r[1],t=s.split("-");if(t.length===3){var c=t[0],l=t[1]-1,a=t[2],i=h.split(":"),u=0,f=0,e=0;return i.length===3&&(u=i[0],f=i[1],e=i[2]),o=new Date(a,l,c,u,f,e,0),o.getTime()/1e3}return n}return n},SetGeoJsonToIndexedDb:function(n,t){if(ABF_GeoJSON.IndexedDb.IndexedDbAvailable()&&ABF_GeoJSON.IndexedDb.MapDb!="unavailable"&&(ABF_GeoJSON.IndexedDb.MapDb==null&&ABF_GeoJSON.IndexedDb.OpenMapDb(),ABF_GeoJSON.IndexedDb.MapDb!=null)){var i=ABF_GeoJSON.IndexedDb.MapDb.transaction("geoJson_dashboard","readwrite"),r=i.objectStore("geoJson_dashboard"),u=r.get(n);u.onsuccess=function(i){var f=JSON.parse(t).manageTs,u=i.target.result,o,e;u==null?(o={geoLevel:n,geoJson:JSON.stringify(t),manageTs:f},r.add(o)):(u.geoJson=JSON.stringify(t),u.manageTs=f,e=r.put(u),e.onerror=function(){},e.onsuccess=function(){});ABF_GeoJSON.GeoTimestamps[n]=f};i.oncomplete=function(){};i.onerror=function(){}}},LoadGeoJsonFromIndexedDb:function(){var n=ABF_GeoJSON.IndexedDb.MapDb.transaction("geoJson_dashboard").objectStore("geoJson_dashboard");n.openCursor().onsuccess=function(n){var t=n.target.result;t?(ABF_GeoJSON.GeoJson[t.key]=JSON.parse(t.value.geoJson),ABF_GeoJSON.GeoTimestamps[t.key]=t.value.manageTs,t.continue()):ABF_GeoJSON.IndexedDb.MapDbLoaded=!0}}}}