var baseUrl=document.location.origin,appUrl=baseUrl;$(function(){$("#alertDetails").on("shown.bs.modal",function(n){var i=$(n.relatedTarget),t=i.data("value"),r=appUrl+"/Home/ViewAlert/"+t;n.stopPropagation();n.preventDefault();$("#alertContent").load(r,function(n,i,r){var u;if(i==="error")u="Sorry but there was an error loading data from the server!",$("#error").html(u+r.status+" "+r.statusText),$(".loadingOverlay").hide();else{var h=appUrl+"/Home/Share/"+t,f=appUrl+"/Home/Index%23"+t,e=$("#ttl").text(),o=$("#fb"),s=$("#twt");o.attr("href","https://www.facebook.com/sharer/sharer.php?u="+f+"&quote="+e);s.attr("href","https://twitter.com/intent/tweet?text="+e+"%0A"+f);$(".loadingOverlay").hide();$("div#share-div").removeAttr("class","hidden").attr("class","pull-left")}})});$(document).on("click","#prnt",function(n){var i=$("#alertContent").html(),t=window.open("","PRINT","height=600,width=800");t.document.write("<html><head><title>"+document.title+"<\/title>");t.document.write("<\/head><body >");t.document.write("<h3>"+document.title+"<\/h3><hr />");t.document.write(i);t.document.write("<\/body><\/html>");t.document.close();t.focus();t.print();t.close();n.preventDefault()});$("#siteInfo").on("shown.bs.modal",function(n){var t=$(n.relatedTarget),i=t.data("value"),r=appUrl+"/Home/Details/"+i;n.stopPropagation();n.preventDefault();$("#siteContent").load(r)});$("#help").on("shown.bs.modal",function(n){var t=appUrl+"/Home/Help/";$("#helpContent").load(t);n.stopPropagation();n.preventDefault()})});$(function(){function u(){$(".loadingOverlay").show();e=L.easyButton("fa-crosshairs",function(){function n(n){n.code===n.PERMISSION_DENIED?alert("Error: User denied to share location."):alert("Error: Location information is unavailable.")}navigator.geolocation.getCurrentPosition(g,n)}).addTo(n);t=L.markerClusterGroup({chunkedLoading:!0,spiderfyOnMaxZoom:!0,maxClusterRadius:100,showCoverageOnHover:!0});L.Map.include({clearLayers:function(){this.eachLayer(function(n){this.removeLayer(n)},this)}});t.clearLayers();var f=$(window).height(),o=$(window).width(),r=$("input:checkbox:checked.gp1").map(function(){return this.value}).get(),u=r+"";$.ajax({type:"GET",url:appUrl+"/Home/map",data:{atype:u},dataType:"json",contentType:"application/x-www-form-urlencoded",success:function(n){$.each(n,function(n,i){var u=i.IconUrl.replace("~",""),f=L.icon({iconUrl:appUrl+u,iconSize:[42,42]}),e,r=L.marker(L.latLng(i.Latitude,i.Longitude),{icon:f},{title:i.Name}),o="<div class='infoDiv'><h3><img src='"+appUrl+u+"' width='24' />"+i.Name+"<\/h3><p>"+i.Title+"<\/p><a href='#' data-value='"+i.AlertId+"' class='btn btn-success btn-sm' data-toggle='modal' data-target='#alertDetails'>Details<\/a><\/div>";e=r._leaflet_id;r.bindPopup(o);t.addLayer(r)})}}).done(function(){$(".loadingOverlay").hide();(i===""||i===undefined)&&n.fitBounds(t.getBounds());n.addLayer(t);n.invalidateSize(!0)})}function g(t){var i=L.latLng(t.coords.latitude,t.coords.longitude);return n.setView(i,10,{animation:!0}),!1}function f(){n.removeLayer(t);n.removeControl(a);n.removeControl(e)}var a=new L.control.layers,e=new L.control.layers,n=null,t=[],v=L.latLng(-30.81881,116.16596),r="pk.eyJ1IjoiZHBhd2FzaSIsImEiOiJjazB3MW9iZ24weHMxM2NxcGluMml1NW80In0.v7uQYd32Ue0yoH2Bw6Inmg",o=L.tileLayer("https://api.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token={mbkey}",{mbkey:r}),y=L.tileLayer("https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token={mbkey}",{mbkey:r}),p=L.tileLayer("https://api.mapbox.com/v4/mapbox.outdoors/{z}/{x}/{y}.png?access_token={mbkey}",{mbkey:r}),w=L.tileLayer("https://api.mapbox.com/v4/mapbox.streets-satellite/{z}/{x}/{y}.png?access_token={mbkey}",{mbkey:r}),l,i;n=new L.map("lmap",{center:v,minZoom:0,maxZoom:18,scrollwheel:!1,layers:[o],streetViewControl:!1,scrollWheelZoom:!1});window.leafletmap=n;var b=appUrl+"/media/Munda_Biddi_Trail.gpx",k=appUrl+"/media/Bibbulmun_Track.gpx",d=appUrl+"/media/Cape_to_Cape_Track.gpx",s=new L.GPX(b,{async:!0,marker_options:{startIconUrl:null,endIconUrl:null,shadowUrl:null},polyline_options:{color:"#0170FF"}}).on("loaded",function(){}),h=new L.GPX(k,{async:!0,marker_options:{startIconUrl:null,endIconUrl:null,shadowUrl:"images/pin-shadow.png"},polyline_options:{color:"#8C211F"}}).on("loaded",function(){}),c=new L.GPX(d,{async:!0,marker_options:{startIconUrl:null,endIconUrl:null,shadowUrl:null},polyline_options:{color:"#F58025"}}).on("loaded",function(){});n.addLayer(s);n.addLayer(h);n.addLayer(c);n.on("focus",function(){n.scrollWheelZoom.enable()});n.on("blur",function(){n.scrollWheelZoom.disable()});l={Streets:o,Satellite:y,Terrain:p,Hybrid:w};n.addControl(new L.Control.Layers(l,{"Munda Biddi":s,"Cape to Cape":c,Bibbulmun:h},{collapsed:!0}));i=window.location.hash.substr(1);u();$(function(){if(!i)return!1;$(".loadingOverlay").show();$.ajax({type:"GET",url:appUrl+"/Home/GetAlert/"+i,dataType:"json",contentType:"application/x-www-form-urlencoded",success:function(t){if(!t.status)return $("#msg").html(t.message).attr("class","alert alert-warning"),$(".loadingOverlay").hide(),!1;$.each(t.message,function(t,i){var u=i.IconUrl.replace("~",""),o=L.icon({iconUrl:appUrl+u,iconSize:[42,42]}),f=new L.LatLng(i.Latitude,i.Longitude),e="<div class='infoDiv'><h3><img src='"+appUrl+u+"' width='24' />"+i.Name+"<\/h3><p>"+i.Title+"<\/p><a href='#' data-value='"+i.AlertId+"' class='btn btn-success btn-sm alertInfo' data-toggle='modal' data-target='#alertDetails'>Details<\/a><\/div>",r=new L.Popup;r.setLatLng(f);r.setContent(e);n.setView(new L.LatLng(i.Latitude,i.Longitude),8);n.addLayer(r)})}}).done(function(){$(".loadingOverlay").hide();n.invalidateSize(!0)})});$("#gmap").on("shown.bs.tab",function(){f();n.invalidateSize(!0);u()});$("#listView").on("shown.bs.tab",function(){$(".loadingOverlay").show();var n=$("input:checkbox:checked.gp1").map(function(){return this.value}).get(),t=n+"";$("#updatePanel").load(appUrl+"/Home/ListView/?atype="+t,function(){$("#DPaWDataTable").dataTable({bJQueryUI:!0,sPaginationType:"full_numbers",aaSorting:[[0,"asc"]],aoColumnDefs:[{type:"date",targets:5,bSortable:!1,aTargets:[6]}]});$(".loadingOverlay").hide()})});$("#btnSearch").click(function(t){f();parent.location.hash="";$("#msg").html("").attr("class","");var i=$("input:checkbox:checked.gp1").map(function(){return this.value}).get(),r=i+"";u();n.invalidateSize(!0);$("#updatePanel").load(appUrl+"/Home/ListView/?atype="+r,function(){$("#DPaWDataTable").dataTable({bJQueryUI:!0,sPaginationType:"full_numbers",aaSorting:[[0,"asc"]],aoColumnDefs:[{type:"date",targets:5,bSortable:!1,aTargets:[6]}]})});$("#sidebarToggle").click();t.stopPropagation();t.stopImmediatePropagation();t.preventDefault()});$("#btnReset").click(function(t){f();parent.location.hash="";$("#msg").html("").attr("class","");$("input:checkbox.gp1").prop("checked",!0);$("input:checkbox.gp1").parent().parent().attr("class","list-group-item");var i=$("input:checkbox:checked.gp1").map(function(){return this.value}).get(),r=i+"";$("#updatePanel").load(appUrl+"/Home/ListView/?atype="+r);n.invalidateSize(!0);u();$("#sidebarToggle").click();t.stopPropagation();t.stopImmediatePropagation();t.preventDefault()});$("input:checkbox.gp1").click(function(){$(this).is(":checked")?$(this).parent().parent().attr("class","list-group-item"):$(this).parent().parent().attr("class","list-group-item  active")});$("input:checkbox#calert").click(function(){$(this).is(":checked")?$("input:checkbox.gp1").prop("checked",!0):$("input:checkbox.gp1").prop("checked",!1)})});var L=L||require("leaflet"),_MAX_POINT_INTERVAL_MS=15e3,_SECOND_IN_MILLIS=1e3,_MINUTE_IN_MILLIS=60*_SECOND_IN_MILLIS,_HOUR_IN_MILLIS=60*_MINUTE_IN_MILLIS,_DAY_IN_MILLIS=24*_HOUR_IN_MILLIS,_DEFAULT_MARKER_OPTS={startIconUrl:"pin-icon-start.png",endIconUrl:"pin-icon-end.png",shadowUrl:"pin-shadow.png",wptIconUrls:{"":"pin-icon-wpt.png"},iconSize:[33,50],shadowSize:[50,50],iconAnchor:[16,45],shadowAnchor:[16,47],clickable:!1},_DEFAULT_POLYLINE_OPTS={color:"blue"},_DEFAULT_GPX_OPTS={parseElements:["track","route","waypoint"]};L.GPX=L.FeatureGroup.extend({initialize:function(n,t){t.max_point_interval=t.max_point_interval||_MAX_POINT_INTERVAL_MS;t.marker_options=this._merge_objs(_DEFAULT_MARKER_OPTS,t.marker_options||{});t.polyline_options=this._merge_objs(_DEFAULT_POLYLINE_OPTS,t.polyline_options||{});t.gpx_options=this._merge_objs(_DEFAULT_GPX_OPTS,t.gpx_options||{});L.Util.setOptions(this,t);L.GPXTrackIcon=L.Icon.extend({options:t.marker_options});this._gpx=n;this._layers={};this._init_info();n&&this._parse(n,t,this.options.async)},get_duration_string:function(n,t){var i="",r,u;return n>=_DAY_IN_MILLIS&&(i+=Math.floor(n/_DAY_IN_MILLIS)+"d ",n=n%_DAY_IN_MILLIS),n>=_HOUR_IN_MILLIS&&(i+=Math.floor(n/_HOUR_IN_MILLIS)+":",n=n%_HOUR_IN_MILLIS),r=Math.floor(n/_MINUTE_IN_MILLIS),n=n%_MINUTE_IN_MILLIS,r<10&&(i+="0"),i+=r+"'",u=Math.floor(n/_SECOND_IN_MILLIS),n=n%_SECOND_IN_MILLIS,u<10&&(i+="0"),i+=u,i+(!t&&n>0?"."+Math.round(Math.floor(n)*1e3)/1e3:'"')},get_duration_string_iso:function(n,t){var i=this.get_duration_string(n,t);return i.replace("'",":").replace('"',"")},to_miles:function(n){return n/1.60934},to_ft:function(n){return n*3.28084},m_to_km:function(n){return n/1e3},m_to_mi:function(n){return n/1609.34},get_name:function(){return this._info.name},get_desc:function(){return this._info.desc},get_author:function(){return this._info.author},get_copyright:function(){return this._info.copyright},get_distance:function(){return this._info.length},get_distance_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))},get_start_time:function(){return this._info.duration.start},get_end_time:function(){return this._info.duration.end},get_moving_time:function(){return this._info.duration.moving},get_total_time:function(){return this._info.duration.total},get_moving_pace:function(){return this.get_moving_time()/this.m_to_km(this.get_distance())},get_moving_pace_imp:function(){return this.get_moving_time()/this.get_distance_imp()},get_moving_speed:function(){return this.m_to_km(this.get_distance())/(this.get_moving_time()/36e5)},get_moving_speed_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))/(this.get_moving_time()/36e5)},get_total_speed:function(){return this.m_to_km(this.get_distance())/(this.get_total_time()/36e5)},get_total_speed_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))/(this.get_total_time()/36e5)},get_elevation_gain:function(){return this._info.elevation.gain},get_elevation_loss:function(){return this._info.elevation.loss},get_elevation_gain_imp:function(){return this.to_ft(this.get_elevation_gain())},get_elevation_loss_imp:function(){return this.to_ft(this.get_elevation_loss())},get_elevation_data:function(){var n=this;return this._info.elevation._points.map(function(t){return n._prepare_data_point(t,n.m_to_km,null,function(n,t){return n.toFixed(2)+" km, "+t.toFixed(0)+" m"})})},get_elevation_data_imp:function(){var n=this;return this._info.elevation._points.map(function(t){return n._prepare_data_point(t,n.m_to_mi,n.to_ft,function(n,t){return n.toFixed(2)+" mi, "+t.toFixed(0)+" ft"})})},get_elevation_max:function(){return this._info.elevation.max},get_elevation_min:function(){return this._info.elevation.min},get_elevation_max_imp:function(){return this.to_ft(this.get_elevation_max())},get_elevation_min_imp:function(){return this.to_ft(this.get_elevation_min())},get_average_hr:function(){return this._info.hr.avg},get_average_temp:function(){return this._info.atemp.avg},get_average_cadence:function(){return this._info.cad.avg},get_heartrate_data:function(){var n=this;return this._info.hr._points.map(function(t){return n._prepare_data_point(t,n.m_to_km,null,function(n,t){return n.toFixed(2)+" km, "+t.toFixed(0)+" bpm"})})},get_heartrate_data_imp:function(){var n=this;return this._info.hr._points.map(function(t){return n._prepare_data_point(t,n.m_to_mi,null,function(n,t){return n.toFixed(2)+" mi, "+t.toFixed(0)+" bpm"})})},get_cadence_data:function(){var n=this;return this._info.cad._points.map(function(t){return n._prepare_data_point(t,n.m_to_km,null,function(n,t){return n.toFixed(2)+" km, "+t.toFixed(0)+" rpm"})})},get_temp_data:function(){var n=this;return this._info.atemp._points.map(function(t){return n._prepare_data_point(t,n.m_to_km,null,function(n,t){return n.toFixed(2)+" km, "+t.toFixed(0)+" degrees"})})},get_cadence_data_imp:function(){var n=this;return this._info.cad._points.map(function(t){return n._prepare_data_point(t,n.m_to_mi,null,function(n,t){return n.toFixed(2)+" mi, "+t.toFixed(0)+" rpm"})})},get_temp_data_imp:function(){var n=this;return this._info.atemp._points.map(function(t){return n._prepare_data_point(t,n.m_to_mi,null,function(n,t){return n.toFixed(2)+" mi, "+t.toFixed(0)+" degrees"})})},reload:function(){this._init_info();this.clearLayers();this._parse(this._gpx,this.options,this.options.async)},_merge_objs:function(n,t){var r={};for(var i in n)r[i]=n[i];for(i in t)r[i]=t[i];return r},_prepare_data_point:function(n,t,i,r){var u=[t&&t(n[0])||n[0],i&&i(n[1])||n[1]];return u.push(r&&r(u[0],u[1])||u[0]+": "+u[1]),u},_init_info:function(){this._info={name:null,length:0,elevation:{gain:0,loss:0,max:0,min:Infinity,_points:[]},hr:{avg:0,_total:0,_points:[]},duration:{start:null,end:null,moving:0,total:0},atemp:{avg:0,_total:0,_points:[]},cad:{avg:0,_total:0,_points:[]}}},_load_xml:function(n,t,i,r){r==undefined&&(r=this.options.async);i==undefined&&(i=this.options);var u=new window.XMLHttpRequest;u.open("GET",n,r);try{u.overrideMimeType("text/xml")}catch(f){}u.onreadystatechange=function(){u.readyState==4&&u.status==200&&t(u.responseXML,i)};u.send(null)},_parse:function(n,t,i){var r=this,u=function(n,t){var i=r._parse_gpx_data(n,t);i&&(r.addLayer(i),r.fire("loaded"))},f;n.substr(0,1)==="<"?(f=new DOMParser,i?setTimeout(function(){u(f.parseFromString(n,"text/xml"),t)}):u(f.parseFromString(n,"text/xml"),t)):this._load_xml(n,u,t,i)},_parse_gpx_data:function(n,t){var a,i,r,u=[],v=[],w=t.gpx_options.parseElements,h,b,k,c,d,l,g,f,nt,e,o,s,y,p;for(w.indexOf("route")>-1&&v.push(["rte","rtept"]),w.indexOf("track")>-1&&v.push(["trkseg","trkpt"]),h=n.getElementsByTagName("name"),h.length>0&&(this._info.name=h[0].textContent),f=n.getElementsByTagName("desc"),f.length>0&&(this._info.desc=f[0].textContent),b=n.getElementsByTagName("author"),b.length>0&&(this._info.author=b[0].textContent),k=n.getElementsByTagName("copyright"),k.length>0&&(this._info.copyright=k[0].textContent),a=0;a<v.length;a++)for(r=n.getElementsByTagName(v[a][0]),i=0;i<r.length;i++)(c=this._parse_trkseg(r[i],n,t,v[a][1]),c.length!==0)&&(d=new L.Polyline(c,t.polyline_options),this.fire("addline",{line:d}),u.push(d),(t.marker_options.startIcon||t.marker_options.startIconUrl)&&(l=new L.Marker(c[0],{clickable:t.marker_options.clickable,icon:t.marker_options.startIcon||new L.GPXTrackIcon({iconUrl:t.marker_options.startIconUrl})}),this.fire("addpoint",{point:l,point_type:"start"}),u.push(l)),(t.marker_options.endIcon||t.marker_options.endIconUrl)&&(l=new L.Marker(c[c.length-1],{clickable:t.marker_options.clickable,icon:t.marker_options.endIcon||new L.GPXTrackIcon({iconUrl:t.marker_options.endIconUrl})}),this.fire("addpoint",{point:l,point_type:"end"}),u.push(l)));if(this._info.hr.avg=Math.round(this._info.hr._total/this._info.hr._points.length),this._info.cad.avg=Math.round(this._info.cad._total/this._info.cad._points.length),this._info.atemp.avg=Math.round(this._info.atemp._total/this._info.atemp._points.length),w.indexOf("waypoint")>-1)for(r=n.getElementsByTagName("wpt"),i=0;i<r.length;i++){var it=new L.LatLng(r[i].getAttribute("lat"),r[i].getAttribute("lon")),tt=r[i].getElementsByTagName("name"),h="";if(tt.length>0&&(h=tt[0].textContent),g=r[i].getElementsByTagName("desc"),f="",g.length>0&&(f=g[0].textContent),nt=r[i].getElementsByTagName("sym"),e="",nt.length>0&&(e=nt[0].textContent),o=t.marker_options.wptIcons,s=t.marker_options.wptIconUrls,o&&o[e])y=o[e];else if(s&&s[e])y=new L.GPXTrackIcon({iconUrl:s[e]});else if(o&&o[""])y=o[""];else if(s&&s[""])y=new L.GPXTrackIcon({iconUrl:s[""]});else{console.log('No icon or icon URL configured for symbol type "'+e+'", and no fallback configured; ignoring waypoint.');continue}p=new L.Marker(it,{clickable:!0,title:h,icon:y});p.bindPopup("<b>"+h+"<\/b>"+(f.length>0?"<br>"+f:"")).openPopup();this.fire("addpoint",{point:p,point_type:"waypoint"});u.push(p)}return u.length>1?new L.FeatureGroup(u):u.length==1?u[0]:void 0},_parse_trkseg:function(n,t,i,r){var o=n.getElementsByTagName(r),c,h,e,f,u,s;if(!o.length)return[];for(c=[],h=null,e=0;e<o.length;e++)u=new L.LatLng(o[e].getAttribute("lat"),o[e].getAttribute("lon")),u.meta={time:null,ele:null,hr:null,cad:null,atemp:null},f=o[e].getElementsByTagName("time"),f.length>0&&(u.meta.time=new Date(Date.parse(f[0].textContent))),f=o[e].getElementsByTagName("ele"),f.length>0&&(u.meta.ele=parseFloat(f[0].textContent)),f=o[e].getElementsByTagNameNS("*","hr"),f.length>0&&(u.meta.hr=parseInt(f[0].textContent),this._info.hr._points.push([this._info.length,u.meta.hr]),this._info.hr._total+=u.meta.hr),f=o[e].getElementsByTagNameNS("*","cad"),f.length>0&&(u.meta.cad=parseInt(f[0].textContent),this._info.cad._points.push([this._info.length,u.meta.cad]),this._info.cad._total+=u.meta.cad),f=o[e].getElementsByTagNameNS("*","atemp"),f.length>0&&(u.meta.atemp=parseInt(f[0].textContent),this._info.atemp._points.push([this._info.length,u.meta.atemp]),this._info.atemp._total+=u.meta.atemp),u.meta.ele>this._info.elevation.max&&(this._info.elevation.max=u.meta.ele),u.meta.ele<this._info.elevation.min&&(this._info.elevation.min=u.meta.ele),this._info.elevation._points.push([this._info.length,u.meta.ele]),this._info.duration.end=u.meta.time,h!=null?(this._info.length+=this._dist3d(h,u),s=u.meta.ele-h.meta.ele,s>0?this._info.elevation.gain+=s:this._info.elevation.loss+=Math.abs(s),s=Math.abs(u.meta.time-h.meta.time),this._info.duration.total+=s,s<i.max_point_interval&&(this._info.duration.moving+=s)):this._info.duration.start=u.meta.time,h=u,c.push(u);return c},_dist2d:function(n,t){var i=this._deg2rad(t.lat-n.lat),r=this._deg2rad(t.lng-n.lng),u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(this._deg2rad(n.lat))*Math.cos(this._deg2rad(t.lat))*Math.sin(r/2)*Math.sin(r/2),f=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return 6371e3*f},_dist3d:function(n,t){var i=this._dist2d(n,t),r=Math.abs(t.meta.ele-n.meta.ele);return Math.sqrt(Math.pow(i,2)+Math.pow(r,2))},_deg2rad:function(n){return n*Math.PI/180}});typeof module=="object"&&typeof module.exports=="object"?module.exports=L:typeof define=="function"&&define.amd&&define(L);L.GridLayer.GoogleMutant=L.GridLayer.extend({options:{minZoom:0,maxZoom:23,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,continuousWorld:!1,noWrap:!1,type:"roadmap",maxNativeZoom:21},initialize:function(n){L.GridLayer.prototype.initialize.call(this,n);this._ready=!!window.google&&!!window.google.maps&&!!window.google.maps.Map;this._GAPIPromise=this._ready?Promise.resolve(window.google):new Promise(function(n,t){var i=0,r=setInterval(function(){if(i>=10)return clearInterval(r),t(new Error("window.google not found after 10 attempts"));if(!!window.google&&!!window.google.maps&&!!window.google.maps.Map)return clearInterval(r),n(window.google);i++},500)});this._tileCallbacks={};this._freshTiles={};this._imagesPerTile=this.options.type==="hybrid"?2:1},onAdd:function(n){L.GridLayer.prototype.onAdd.call(this,n);this._initMutantContainer();this._GAPIPromise.then(function(){this._ready=!0;this._map=n;this._initMutant();n.on("viewreset",this._reset,this);n.on("move",this._update,this);n.on("zoomend",this._handleZoomAnim,this);n.on("resize",this._resize,this);if(google.maps.event.addListenerOnce(this._mutant,"idle",function(){this._checkZoomLevels();this._mutantIsReady=!0}.bind(this)),n._controlCorners.bottomright.style.marginBottom="20px",n._controlCorners.bottomleft.style.marginBottom="20px",this._reset(),this._update(),this._subLayers)for(var t in this._subLayers)this._subLayers[t].setMap(this._mutant)}.bind(this))},onRemove:function(n){L.GridLayer.prototype.onRemove.call(this,n);n._container.removeChild(this._mutantContainer);this._mutantContainer=undefined;google.maps.event.clearListeners(n,"idle");google.maps.event.clearListeners(this._mutant,"idle");n.off("viewreset",this._reset,this);n.off("move",this._update,this);n.off("zoomend",this._handleZoomAnim,this);n.off("resize",this._resize,this);n._controlCorners&&(n._controlCorners.bottomright.style.marginBottom="0em",n._controlCorners.bottomleft.style.marginBottom="0em")},getAttribution:function(){return this.options.attribution},setOpacity:function(n){this.options.opacity=n;n<1&&L.DomUtil.setOpacity(this._mutantContainer,n)},setElementSize:function(n,t){n.style.width=t.x+"px";n.style.height=t.y+"px"},addGoogleLayer:function(n,t){return this._subLayers||(this._subLayers={}),this._GAPIPromise.then(function(){var r=google.maps[n],i=new r(t);return i.setMap(this._mutant),this._subLayers[n]=i,i}.bind(this))},removeGoogleLayer:function(n){var t=this._subLayers&&this._subLayers[n];t&&(t.setMap(null),delete this._subLayers[n])},_initMutantContainer:function(){this._mutantContainer||(this._mutantContainer=L.DomUtil.create("div","leaflet-google-mutant leaflet-top leaflet-left"),this._mutantContainer.id="_MutantContainer_"+L.Util.stamp(this._mutantContainer),this._mutantContainer.style.zIndex="399",this._mutantContainer.style.pointerEvents="none",this._map.getContainer().appendChild(this._mutantContainer));this.setOpacity(this.options.opacity);this.setElementSize(this._mutantContainer,this._map.getSize());this._attachObserver(this._mutantContainer)},_initMutant:function(){if(this._ready&&this._mutantContainer){this._mutantCenter=new google.maps.LatLng(0,0);var n=new google.maps.Map(this._mutantContainer,{center:this._mutantCenter,zoom:0,tilt:0,mapTypeId:this.options.type,disableDefaultUI:!0,keyboardShortcuts:!1,draggable:!1,disableDoubleClickZoom:!0,scrollwheel:!1,streetViewControl:!1,styles:this.options.styles||{},backgroundColor:"transparent"});this._mutant=n;google.maps.event.addListenerOnce(n,"idle",function(){for(var t=this._mutantContainer.querySelectorAll("a"),n=0;n<t.length;n++)t[n].style.pointerEvents="auto"}.bind(this));this.fire("spawned",{mapObject:n})}},_attachObserver:function(n){var t=new MutationObserver(this._onMutations.bind(this));t.observe(n,{childList:!0,subtree:!0})},_onMutations:function(n){for(var u,r,t,i=0;i<n.length;++i)for(u=n[i],r=0;r<u.addedNodes.length;++r)t=u.addedNodes[r],t instanceof HTMLImageElement?this._onMutatedImage(t):t instanceof HTMLElement&&Array.prototype.forEach.call(t.querySelectorAll("img"),this._onMutatedImage.bind(this))},_roadRegexp:/!1i(\d+)!2i(\d+)!3i(\d+)!/,_satRegexp:/x=(\d+)&y=(\d+)&z=(\d+)/,_staticRegExp:/StaticMapService\.GetMapImage/,_onMutatedImage:function(n){var r,t=n.src.match(this._roadRegexp),u=0,f,i;if(t?(r={z:t[1],x:t[2],y:t[3]},this._imagesPerTile>1&&(n.style.zIndex=1,u=1)):(t=n.src.match(this._satRegexp),t&&(r={x:t[1],y:t[2],z:t[3]}),u=0),r){if(f=this._tileCoordsToKey(r),n.style.position="absolute",n.style.visibility="hidden",i=f+"/"+u,this._freshTiles[i]=n,i in this._tileCallbacks&&this._tileCallbacks[i])this._tileCallbacks[i].pop()(n),this._tileCallbacks[i].length||delete this._tileCallbacks[i];else if(this._tiles[f]){var e=this._tiles[f].el,o=u===0?e.firstChild:e.firstChild.nextSibling,s=this._clone(n);e.replaceChild(s,o)}}else n.src.match(this._staticRegExp)&&(n.style.visibility="hidden")},createTile:function(n,t){var e=this._tileCoordsToKey(n),i=L.DomUtil.create("div"),u,r,f;for(i.dataset.pending=this._imagesPerTile,t=t.bind(this,null,i),u=0;u<this._imagesPerTile;u++)r=e+"/"+u,r in this._freshTiles?(f=this._freshTiles[r],i.appendChild(this._clone(f)),i.dataset.pending--):(this._tileCallbacks[r]=this._tileCallbacks[r]||[],this._tileCallbacks[r].push(function(n){return function(i){n.appendChild(this._clone(i));n.dataset.pending--;parseInt(n.dataset.pending)||t()}.bind(this)}.bind(this)(i)));return parseInt(i.dataset.pending)||L.Util.requestAnimFrame(t),i},_clone:function(n){var t=n.cloneNode(!0);return t.style.visibility="visible",t},_checkZoomLevels:function(){var t=this._map.getZoom(),n=this._mutant.getZoom();t&&n&&(n!==t||n>this.options.maxNativeZoom)&&this._setMaxNativeZoom(n)},_setMaxNativeZoom:function(n){n!=this.options.maxNativeZoom&&(this.options.maxNativeZoom=n,this._resetView())},_reset:function(){this._initContainer()},_update:function(){var t,i;if(this._mutant){t=this._map.getCenter();i=new google.maps.LatLng(t.lat,t.lng);this._mutant.setCenter(i);var n=this._map.getZoom(),r=n!==Math.round(n),u=this._mutant.getZoom();r||n==u||(this._mutant.setZoom(n),this._mutantIsReady&&this._checkZoomLevels())}L.GridLayer.prototype._update.call(this)},_resize:function(){var n=this._map.getSize();(this._mutantContainer.style.width!==n.x||this._mutantContainer.style.height!==n.y)&&(this.setElementSize(this._mutantContainer,n),this._mutant)&&google.maps.event.trigger(this._mutant,"resize")},_handleZoomAnim:function(){if(this._mutant){var n=this._map.getCenter(),t=new google.maps.LatLng(n.lat,n.lng);this._mutant.setCenter(t);this._mutant.setZoom(Math.round(this._map.getZoom()))}},_removeTile:function(n){if(this._mutant)return setTimeout(this._pruneTile.bind(this,n),1e3),L.GridLayer.prototype._removeTile.call(this,n)},_pruneTile:function(n){for(var i,e,o,s=this._mutant.getZoom(),h=n.split(":")[2],r=this._mutant.getBounds(),u=r.getSouthWest(),f=r.getNorthEast(),c=L.latLngBounds([[u.lat(),u.lng()],[f.lat(),f.lng()]]),t=0;t<this._imagesPerTile;t++)i=n+"/"+t,i in this._freshTiles&&(e=this._map&&this._keyToBounds(n),o=this._map&&e.overlaps(c)&&h==s,o||delete this._freshTiles[i])}});L.gridLayer.googleMutant=function(n){return new L.GridLayer.GoogleMutant(n)},function(){function n(n,i){this.title=n.title;this.stateName=n.stateName?n.stateName:"unnamed-state";this.icon=L.DomUtil.create("span","");L.DomUtil.addClass(this.icon,"button-state state-"+this.stateName.replace(/(^\s*|\s*$)/g,""));this.icon.innerHTML=t(n.icon);this.onClick=L.Util.bind(n.onClick?n.onClick:function(){},i)}function t(n){var t;return n.match(/[&;=<>"']/)?t=n:(n=n.replace(/(^\s*|\s*$)/g,""),t=L.DomUtil.create("span",""),n.indexOf("fa-")===0?L.DomUtil.addClass(t,"fa "+n):n.indexOf("glyphicon-")===0?L.DomUtil.addClass(t,"glyphicon "+n):L.DomUtil.addClass(t,n),t=t.outerHTML),t}L.Control.EasyBar=L.Control.extend({options:{position:"topleft",id:null,leafletClasses:!0},initialize:function(n,t){t&&L.Util.setOptions(this,t);this._buildContainer();this._buttons=[];for(var i=0;i<n.length;i++)n[i]._bar=this,n[i]._container=n[i].button,this._buttons.push(n[i]),this.container.appendChild(n[i].button)},_buildContainer:function(){this._container=this.container=L.DomUtil.create("div","");this.options.leafletClasses&&L.DomUtil.addClass(this.container,"leaflet-bar easy-button-container leaflet-control");this.options.id&&(this.container.id=this.options.id)},enable:function(){return L.DomUtil.addClass(this.container,"enabled"),L.DomUtil.removeClass(this.container,"disabled"),this.container.setAttribute("aria-hidden","false"),this},disable:function(){return L.DomUtil.addClass(this.container,"disabled"),L.DomUtil.removeClass(this.container,"enabled"),this.container.setAttribute("aria-hidden","true"),this},onAdd:function(){return this.container},addTo:function(n){var t;for(this._map=n,t=0;t<this._buttons.length;t++)this._buttons[t]._map=n;var i=this._container=this.onAdd(n),u=this.getPosition(),r=n._controlCorners[u];return L.DomUtil.addClass(i,"leaflet-control"),u.indexOf("bottom")!==-1?r.insertBefore(i,r.firstChild):r.appendChild(i),this}});L.easyBar=function(){for(var t=[L.Control.EasyBar],n=0;n<arguments.length;n++)t.push(arguments[n]);return new(Function.prototype.bind.apply(L.Control.EasyBar,t))};L.Control.EasyButton=L.Control.extend({options:{position:"topleft",id:null,type:"replace",states:[],leafletClasses:!0,tagName:"button"},initialize:function(t,i,r,u){this.options.states=[];u!=null&&(this.options.id=u);this.storage={};typeof arguments[arguments.length-1]=="object"&&L.Util.setOptions(this,arguments[arguments.length-1]);this.options.states.length===0&&typeof t=="string"&&typeof i=="function"&&this.options.states.push({icon:t,onClick:i,title:typeof r=="string"?r:""});this._states=[];for(var f=0;f<this.options.states.length;f++)this._states.push(new n(this.options.states[f],this));this._buildButton();this._activateState(this._states[0])},_buildButton:function(){if(this.button=L.DomUtil.create(this.options.tagName,""),this.tagName==="button"&&(this.button.type="button"),this.options.id&&(this.button.id=this.options.id),this.options.leafletClasses&&L.DomUtil.addClass(this.button,"easy-button-button leaflet-bar-part leaflet-interactive"),L.DomEvent.addListener(this.button,"dblclick",L.DomEvent.stop),L.DomEvent.addListener(this.button,"mousedown",L.DomEvent.stop),L.DomEvent.addListener(this.button,"click",function(n){L.DomEvent.stop(n);this._currentState.onClick(this,this._map?this._map:null);this._map.getContainer().focus()},this),this.options.type=="replace")this.button.appendChild(this._currentState.icon);else for(var n=0;n<this._states.length;n++)this.button.appendChild(this._states[n].icon)},_currentState:{stateName:"unnamed",icon:function(){return document.createElement("span")}()},_states:null,state:function(n){return typeof n=="string"?this._activateStateNamed(n):typeof n=="number"&&this._activateState(this._states[n]),this},_activateStateNamed:function(n){for(var t=0;t<this._states.length;t++)this._states[t].stateName==n&&this._activateState(this._states[t])},_activateState:function(n){if(n!==this._currentState){this.options.type=="replace"&&(this.button.appendChild(n.icon),this.button.removeChild(this._currentState.icon));n.title?this.button.title=n.title:this.button.removeAttribute("title");for(var t=0;t<this._states.length;t++)L.DomUtil.removeClass(this._states[t].icon,this._currentState.stateName+"-active"),L.DomUtil.addClass(this._states[t].icon,n.stateName+"-active");L.DomUtil.removeClass(this.button,this._currentState.stateName+"-active");L.DomUtil.addClass(this.button,n.stateName+"-active");this._currentState=n}},enable:function(){return L.DomUtil.addClass(this.button,"enabled"),L.DomUtil.removeClass(this.button,"disabled"),this.button.setAttribute("aria-hidden","false"),this},disable:function(){return L.DomUtil.addClass(this.button,"disabled"),L.DomUtil.removeClass(this.button,"enabled"),this.button.setAttribute("aria-hidden","true"),this},removeFrom:function(){return this._container.parentNode.removeChild(this._container),this._map=null,this},onAdd:function(){var n=L.easyBar([this],{position:this.options.position,leafletClasses:this.options.leafletClasses});return this._container=n.container,this._container}});L.easyButton=function(){var n=Array.prototype.concat.apply([L.Control.EasyButton],arguments);return new(Function.prototype.bind.apply(L.Control.EasyButton,n))}}()