/
earthjs.min.js
executable file
·1 lines (1 loc) · 94.6 KB
/
earthjs.min.js
1
var earthjs=function(){"use strict";function t(t,e){(arguments.length<2||isNaN(parseFloat(e))||!isFinite(e)||e<0)&&(e=42),THREE.Geometry.call(this);var n,o=[];for(n=0;n<t.vertices.length;n+=2){var r=t.vertices[n],a=t.vertices[n+1],i=.01745329252*+(90-a),s=.01745329252*+(180-r),l=Math.sin(s)*Math.sin(i)*-1,c=Math.cos(s)*Math.sin(i),u=Math.cos(i),h=.25+r/360,d=.5+a/180;this.vertices.push(new THREE.Vector3(l,u,c)),o.push(new THREE.Vector2(h,d))}var f=this.vertices.length;if(e<=1)for(n=0;n<f;n++){var p=this.vertices[n];this.vertices.push(p.clone().multiplyScalar(e))}for(n=0;n<t.triangles.length;n+=3){var v=t.triangles[n],g=t.triangles[n+1],m=t.triangles[n+2];this.faces.push(new THREE.Face3(v,g,m,[this.vertices[v],this.vertices[g],this.vertices[m]])),this.faceVertexUvs[0].push([o[v],o[g],o[m]]),0<e&&e<=1&&(this.faces.push(new THREE.Face3(f+g,f+v,f+m,[this.vertices[g].clone().multiplyScalar(-1),this.vertices[v].clone().multiplyScalar(-1),this.vertices[m].clone().multiplyScalar(-1)])),this.faceVertexUvs[0].push([o[g],o[v],o[m]]))}if(e<1)for(n=0;n<t.polygons.length;n++)for(var y=t.polygons[n],w=0;w<y.length;w++)for(var b=y[w],C=0;C<b.length;C++){var j,v=b[C],g=b[(C+1)%b.length],E=this.vertices[v],_=this.vertices[g],T=this.vertices[f+v];w<1?(j=_.clone().sub(E).cross(T.clone().sub(E)).normalize(),this.faces.push(new THREE.Face3(v,g,f+v,[j,j,j])),this.faceVertexUvs[0].push([o[v],o[g],o[v]]),e>0&&(this.faces.push(new THREE.Face3(g,f+g,f+v,[j,j,j])),this.faceVertexUvs[0].push([o[g],o[g],o[v]]))):(j=T.clone().sub(E).cross(_.clone().sub(E)).normalize(),this.faces.push(new THREE.Face3(g,v,f+v,[j,j,j])),this.faceVertexUvs[0].push([o[g],o[v],o[v]]),e>0&&(this.faces.push(new THREE.Face3(g,f+v,f+g,[j,j,j])),this.faceVertexUvs[0].push([o[g],o[v],o[g]])))}this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,1)}var e=function(){function t(t){var e=t[0]/2*d,n=u(e),o=i(e),r=t[1]/2*d,a=u(r),s=i(r),l=t[2]/2*d,c=u(l),h=i(l);return[o*s*h+n*a*c,n*s*h-o*a*c,o*a*h+n*s*c,o*s*c-n*a*h]}function e(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function n(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}var o=Math.acos,r=Math.asin,a=Math.atan2,i=Math.cos,s=Math.max,l=Math.min,c=Math.PI,u=Math.sin,h=Math.sqrt,d=c/180,f=180/c;return t.cartesian=function(t){var e=t[0]*d,n=t[1]*d,o=i(n);return[o*i(e),o*u(e),u(n)]},t.rotation=function(t){return[a(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*f,r(s(-1,l(1,2*(t[0]*t[2]-t[3]*t[1]))))*f,a(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*f]},t.delta=function(t,r){var a=e(t,r),c=h(n(a,a));if(!c)return[1,0,0,0];var d=o(s(-1,l(1,n(t,r))))/2,f=u(d);return[i(d),a[2]/c*f,-a[1]/c*f,a[0]/c*f]},t.multiply=function(t,e){return[t[0]*e[0]-t[1]*e[1]-t[2]*e[2]-t[3]*e[3],t[0]*e[1]+t[1]*e[0]+t[2]*e[3]-t[3]*e[2],t[0]*e[2]-t[1]*e[3]+t[2]*e[0]+t[3]*e[1],t[0]*e[3]+t[1]*e[2]-t[2]*e[1]+t[3]*e[0]]},t}(),n=function t(){function n(t,e,n){t[e]&&(r[e][n||t.name]=t[e],r[e+"Keys"]=Object.keys(r[e]),r[e+"Vals"]=r[e+"Keys"].map(function(t){return r[e][t]}))}var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};cancelAnimationFrame(t.ticker),o=Object.assign({selector:"#earth-js",rotate:[130,-33,-11],transparent:!1},o);var r={onCreate:{},onCreateVals:[],onRefresh:{},onRefreshVals:[],onResize:{},onResizeVals:[],onInterval:{},onIntervalVals:[],ready:null,promeses:[],loadingData:null,recreateSvgOrCanvas:function(){return r.onCreateVals.forEach(function(t){t.call(c)}),c}},a=d3.selectAll(o.selector),i=a.attr("width"),s=a.attr("height");i&&s||(i=o.width||700,s=o.height||500,a.attr("width",i).attr("height",s));var l=[i/2,s/2];Object.defineProperty(o,"width",{get:function(){return i},set:function(t){i=t,l[0]=t/2}}),Object.defineProperty(o,"height",{get:function(){return s},set:function(t){s=t,l[1]=t/2}});var c={_:{svg:a,drag:!1,versor:e,center:l,options:o},$slc:{},ready:function(t){if(t&&r.promeses.length>0){var e=d3.queue();r.loadingData=!0,r.promeses.forEach(function(t){t.urls.forEach(function(t){var n=t.split(".").pop();"geojson"===n&&(n="json"),e.defer(d3[n],t)})}),e.await(function(){var e=[].slice.call(arguments),n=e.shift();r.promeses.forEach(function(t){var o=t.urls.length,r=e.slice(0,o),a=c[t.name].ready;r.unshift(n),a?a.apply(c,r):t.onReady.apply(c,r),e=e.slice(o)}),r.loadingData=!1,t.call(c)})}else if(0===arguments.length)return r.loadingData},register:function(t,e){var o={name:e||t.name};return c[o.name]=o,Object.keys(t).forEach(function(e){-1===["urls","onReady","onInit","onCreate","onRefresh","onResize","onInterval"].indexOf(e)&&"function"==typeof t[e]&&(o[e]=function(){return t[e].apply(c,arguments)})}),t.onInit&&t.onInit.call(c,o),n(t,"onCreate",o.name),n(t,"onResize",o.name),n(t,"onRefresh",o.name),n(t,"onInterval",o.name),t.urls&&t.onReady&&r.promeses.push({name:o.name,urls:t.urls,onReady:t.onReady}),c}};Object.defineProperty(c,"loading",{get:function(){return r.loadingData}});var u=[],h=c._;return c.create=function(t){return u=t||[],r.recreateSvgOrCanvas(),u.forEach(function(t){t.create(null)}),u!==[]&&h.ticker(),c},c.$slc.defs=h.svg.append("defs"),h.ticker=function(e){function n(s){if(s-a>e&&(a=s,!r.loadingData&&(o.call(c,s),s-i>e+30))){i=s;var l=!0,h=!1,d=void 0;try{for(var f,p=u[Symbol.iterator]();!(l=(f=p.next()).done);l=!0){var v=f.value;v._.interval.call(v,s)}}catch(t){h=!0,d=t}finally{try{!l&&p.return&&p.return()}finally{if(h)throw d}}}t.ticker=requestAnimationFrame(n)}var o=h.interval;e=e||10;var a=0,i=0;return t.ticker=requestAnimationFrame(n),c},h.scale=function(t){return h.proj.scale(t),h.resize(),h.refresh(),c},h.rotate=function(t){return h.proj.rotate(t),h.refresh(),c},h.interval=function(t){var e=!0,n=!1,o=void 0;try{for(var a,i=r.onIntervalVals[Symbol.iterator]();!(e=(a=i.next()).done);e=!0)a.value.call(c,t)}catch(t){n=!0,o=t}finally{try{!e&&i.return&&i.return()}finally{if(n)throw o}}return c},h.refresh=function(t){if(t)(t?r.onRefreshKeys.filter(function(e){return t.test(e)}):r.onRefreshKeys).forEach(function(t){r.onRefresh[t].call(c)});else{var e=!0,n=!1,o=void 0;try{for(var a,i=r.onRefreshVals[Symbol.iterator]();!(e=(a=i.next()).done);e=!0)a.value.call(c)}catch(t){n=!0,o=t}finally{try{!e&&i.return&&i.return()}finally{if(n)throw o}}}return c},h.resize=function(){var t=!0,e=!1,n=void 0;try{for(var o,a=r.onResizeVals[Symbol.iterator]();!(t=(o=a.next()).done);t=!0)o.value.call(c)}catch(t){e=!0,n=t}finally{try{!t&&a.return&&a.return()}finally{if(e)throw n}}return c},h.orthoGraphic=function(){var t=h.options.rotate;"number"==typeof t&&(h.options.rotate=[t,-33,-11]);var e=h.options.scale;return e||(e=h.options.width/3.5),d3.geoOrthographic().rotate(h.options.rotate).translate(h.center).precision(.1).clipAngle(90).scale(e)},h.proj=h.orthoGraphic(),h.path=d3.geoPath().projection(h.proj),c};void 0===window.d3&&(window.d3={}),window.d3.earthjs=n;var o=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)};window.THREE&&(t.prototype=Object.create(THREE.Geometry.prototype));return n.plugins={baseCsv:function(t){var e={data:null};return{name:"baseCsv",urls:t&&[t],onReady:function(t,n){e.me.data(n)},onInit:function(t){e.me=t},data:function(t){if(!t)return e.data;e.data=t},message:function(t){e.data=e.data.map(t)},allData:function(t){if(!t)return{data:e.data};e.data=t.data}}},worldJson:function(t){var e={world:null,land:null,lakes:{type:"FeatureCollection",features:[]},selected:{type:"FeatureCollection",features:[]},countries:{type:"FeatureCollection",features:[]}};return{name:"worldJson",urls:t&&[t],onReady:function(t,n){e.me.data(n)},onInit:function(t){e.me=t},data:function(t){if(!t)return e.world;e.world=t,e.land=topojson.feature(t,t.objects.land),e.lakes.features=topojson.feature(t,t.objects.ne_110m_lakes).features,e.countries.features=topojson.feature(t,t.objects.countries).features},allData:function(t){if(!t)return{world:e.world,land:e.land,lakes:e.lakes,countries:e.countries};e.world=t.world,e.land=t.land,e.lakes=t.lakes,e.countries=t.countries}}},choroplethCsv:function(t){var e={choropleth:null,color:null};return{name:"choroplethCsv",urls:t&&[t],onReady:function(t,n){e.me.data(n)},onInit:function(t){e.me=t},data:function(t){if(!t)return e.choropleth;e.choropleth=t},mergeData:function(t,n){var o=e.choropleth,r=n[0].split(":"),a=n[1].split(":");t.features.forEach(function(t){var e=o.find(function(e){return""+t[r[0]]===e[r[1]]});e&&(t[a[0]]=e[a[1]])})},colorize:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"schemeReds",r=e.choropleth.map(function(e){return+e[t]});r=[].concat(o(new Set(r))),e.min=d3.min(r),e.max=d3.max(r);var a=d3[n]||d3.schemeReds,i=d3.scaleLinear().domain([1,10]).rangeRound([e.min,e.max]),s=d3.scaleThreshold().domain(d3.range(2,10)).range(a[9]);e.choropleth.forEach(function(e){e.color=s(i(+e[t]))})}}},countryNamesCsv:function(t){var e={countryNames:null};return{name:"countryNamesCsv",urls:t&&[t],onReady:function(t,n){e.me.data(n)},onInit:function(t){e.me=t},data:function(t){if(!t)return e.countryNames;e.countryNames=t},mergeData:function(t,n){var o=e.countryNames,r=n[0].split(":"),a=n[1].split(":");t.features.forEach(function(t){var e=o.find(function(e){return""+t[r[0]]===e[r[1]]});e&&(t[a[0]]=e[a[1]])})}}},colorScale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[d3.rgb("#FFAAFF"),d3.rgb("#FF0000")],n={};return{name:"colorScale",onInit:function(e){n.me=e,n.me.data(t)},data:function(t){n.mnMax=d3.extent(t),n.color=d3.scaleLinear().domain(n.mnMax).interpolate(d3.interpolateHcl).range(e)},color:function(t){return n.color(t)},colors:function(t){return t.map(function(t){return n.color(t)})},colorScale:function(t){for(var e=0,o=[[0,n.me.color(0)]],r=n.mnMax[1]/t,a=0;a<t;a++)e+=r,o.push([e,n.me.color(e)]);return o},colorRange:function(t){if(!t)return e;e=t}}},hoverCanvas:function(){function t(){if(this.worldCanvas){var t=this.worldCanvas.data();t&&(n.world=t,n.countries=topojson.feature(t,t.objects.countries))}var o=this._,r=this;n.hoverHandler=function(){var t=this,a=d3.event;if(!o.drag&&a){a.sourceEvent&&(a=a.sourceEvent);var i=[a.clientX,a.clientY],s=o.proj.invert(d3.mouse(this));n.pos=s,n.dot=null,n.mouse=i,n.country=null,o.options.showDots&&n.onCircleVals.forEach(function(e){n.dot=e.call(t,a,s)}),o.options.showLand&&n.countries&&!n.dot&&(o.drag||(r.countryCanvas?n.country=r.countryCanvas.detectCountry(s):n.country=e(s),n.ocountry!==n.country&&r.canvasThreejs&&(n.ocountry=n.country,r.canvasThreejs.refresh())),n.onCountryVals.forEach(function(e){e.tooltips?e.call(t,a,n.country):n.ocountry2!==n.country&&e.call(t,a,n.country)}),n.ocountry2=n.country)}},n.svg.on("mousemove",n.hoverHandler),this.mousePlugin&&this.mousePlugin.onDrag({hoverCanvas:n.hoverHandler})}function e(t){return n.countries.features.find(function(e){return e.geometry.coordinates.find(function(e){return d3.polygonContains(e,t)||e.find(function(e){return d3.polygonContains(e,t)})})})}var n={svg:null,mouse:null,country:null,ocountry:null,countries:null,hoverHandler:null,onCircle:{},onCircleVals:[],onCountry:{},onCountryVals:[]};return{name:"hoverCanvas",onInit:function(e){n.me=e,n.svg=this._.svg,this._.options.showSelectedCountry=!1,t.call(this)},selectAll:function(e){return e&&(n.q=e,n.svg.on("mousemove",null),n.svg=d3.selectAll(e),t.call(this)),n.svg},onCreate:function(){this.worldJson&&!n.world&&n.me.allData(this.worldJson.allData())},onCircle:function(t){Object.assign(n.onCircle,t),n.onCircleVals=Object.keys(n.onCircle).map(function(t){return n.onCircle[t]})},onCountry:function(t){Object.assign(n.onCountry,t),n.onCountryVals=Object.keys(n.onCountry).map(function(t){return n.onCountry[t]})},data:function(t){if(!t)return n.world;n.world=t,n.countries=topojson.feature(t,t.objects.countries)},allData:function(t){if(!t)return{world:n.world,countries:n.countries};n.world=t.world,n.countries=t.countries},states:function(){return{pos:n.pos,dot:n.dot,mouse:n.mouse,country:n.country}},registerMouseDrag:function(){this.mousePlugin.onDrag({hoverCanvas:n.hoverHandler})}}},clickCanvas:function(){function t(){if(this.worldCanvas){var t=this.worldCanvas.data();t&&(n.world=t,n.countries=topojson.feature(t,t.objects.countries))}var o=this._,r=this;this.mousePlugin&&this.mousePlugin.onClick({clickCanvas:function(t,a){var i=this;if(t){t.sourceEvent&&(t=t.sourceEvent);var s=[t.clientX,t.clientY],l=o.proj.invert(a);n.pos=l,n.dot=null,n.mouse=s,n.country=null,o.options.showDots&&n.onCircleVals.forEach(function(e){n.dot=e.call(i,t,l)}),o.options.showLand&&!n.dot&&(o.drag||(r.countryCanvas?n.country=r.countryCanvas.detectCountry(l):n.country=e(l)),n.onCountryVals.forEach(function(e){e.call(i,t,n.country)}))}}}),o.options.showLand=!0}function e(t){return n.countries.features.find(function(e){return e.geometry.coordinates.find(function(e){return d3.polygonContains(e,t)||e.find(function(e){return d3.polygonContains(e,t)})})})}var n={mouse:null,country:null,countries:null,onCircle:{},onCircleVals:[],onCountry:{},onCountryVals:[]};return{name:"clickCanvas",onInit:function(e){n.me=e,t.call(this)},onCreate:function(){this.worldJson&&!n.world&&n.me.allData(this.worldJson.allData())},onCircle:function(t){Object.assign(n.onCircle,t),n.onCircleVals=Object.keys(n.onCircle).map(function(t){return n.onCircle[t]})},onCountry:function(t){Object.assign(n.onCountry,t),n.onCountryVals=Object.keys(n.onCountry).map(function(t){return n.onCountry[t]})},data:function(t){if(!t)return n.world;n.world=t,n.countries=topojson.feature(t,t.objects.countries)},allData:function(t){if(!t)return{world:n.world,countries:n.countries};n.world=t.world,n.countries=t.countries},state:function(){return{pos:n.pos,dot:n.dot,mouse:n.mouse,country:n.country}}}},mousePlugin:function(){function t(){c.onClickVals.forEach(function(t){t.call(c._this,c.event,c.mouse)})}function e(){c.onDblClickVals.forEach(function(t){t.call(c._this,c.event,c.mouse)})}function n(t){var e=t.versor,n=e.cartesian(t.proj.rotate(h).invert(c.mouse)),o=e.multiply(d,e.delta(u,n));c.r=e.rotation(o)}function o(t){var e=this;n(t),t.rotate(c.r),c.onDragVals.forEach(function(t){t.call(e,c.mouse)})}function r(){function r(t){var e=t[0]-h[0];t[0]=e+this._.proj.rotate()[0],t[0]>=180&&(t[0]-=360),this._.rotate(t)}var a=this._,i=a.versor,f=a.proj.scale(),p=[a.options.width,a.options.height];c.scale=d3.scaleLinear().domain([30,a.proj.scale()]).range([.1,1]),c.zoom=d3.zoom().on("zoom",function(){var t=s,e=f*d3.event.transform.k;e>=t[0]&&e<=t[1]&&(a.scale(e),c.sync.forEach(function(t){return t._.scale(e)}))}).scaleExtent([.1,160]).translateExtent([[0,0],p]),c.svg.call(d3.drag().on("start",function(){var t=this,e=d3.mouse(this);u=i.cartesian(a.proj.invert(e)),h=a.proj.rotate(),d=i(h),a.drag=null,c.onDragStartVals.forEach(function(n){return n.call(t,e)}),c.onDragVals.forEach(function(n){return n.call(t,e)}),a.refresh(),c.mouse=e,c._this=this,c.t1=0,c.t2=0}).on("end",function(){var o=this,i=a.drag;a.drag=!1,null===i?(c.event=d3.event,a.options.spin?t():c.wait?(c.wait=null,e()):null===c.wait&&(c.wait=window.setTimeout(function(){c.wait&&(c.wait=!1)},250))):i&&(n(a),a.rotate(c.r),c.onDragVals.forEach(function(t){return t.call(c._this,c.mouse)}),c.sync.forEach(function(t){return r.call(t,c.r)})),c.onDragEndVals.forEach(function(t){return t.call(o,c.mouse)}),a.refresh()}).on("drag",function(){a.drag=!0,c._this=this,c.mouse=d3.mouse(this),!l&&o(a)})),c.svg.call(c.zoom)}function a(){var e=this._;e.drag&&l?c.oMouse[0]!==c.mouse[0]&&c.oMouse[1]!==c.mouse[1]&&(c.oMouse=c.mouse,o(e)):!1===c.wait&&(c.wait=null,t())}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{zoomScale:[0,5e4]},s=i.zoomScale,l=i.intervalDrag,c={svg:null,wait:null,zoom:null,mouse:null,q:null,sync:[],onDrag:{},onDragVals:[],onDragStart:{},onDragStartVals:[],onDragEnd:{},onDragEndVals:[],onClick:{},onClickVals:[],onDblClick:{},onDblClickVals:[]};void 0===s&&(s=[0,5e4]);var u=void 0,h=void 0,d=void 0;return{name:"mousePlugin",onInit:function(t){c.me=t,c.oMouse=[],c.svg=this._.svg,r.call(this)},onInterval:function(){a.call(this)},selectAll:function(t){return t&&(c.q=t,c.svg.call(d3.zoom().on("zoom start end",null)),c.svg.call(d3.drag().on("start",null).on("end",null).on("drag",null)),c.svg=d3.selectAll(t),r.call(this),this.hoverCanvas&&this.hoverCanvas.selectAll(t)),c.svg},sync:function(t){c.sync=t},zoom:function(t){c.zoom.scaleTo(c.svg,t?c.scale(t):1)},mouse:function(){return c.mouse},onDrag:function(t){Object.assign(c.onDrag,t),c.onDragVals=Object.keys(c.onDrag).map(function(t){return c.onDrag[t]})},onDragStart:function(t){Object.assign(c.onDragStart,t),c.onDragStartVals=Object.keys(c.onDragStart).map(function(t){return c.onDragStart[t]})},onDragEnd:function(t){Object.assign(c.onDragEnd,t),c.onDragEndVals=Object.keys(c.onDragEnd).map(function(t){return c.onDragEnd[t]})},onClick:function(t){Object.assign(c.onClick,t),c.onClickVals=Object.keys(c.onClick).map(function(t){return c.onClick[t]})},onDblClick:function(t){Object.assign(c.onDblClick,t),c.onDblClickVals=Object.keys(c.onDblClick).map(function(t){return c.onDblClick[t]})}}},configPlugin:function(){return{name:"configPlugin",set:function(t){if(t){if(Object.assign(this._.options,t),void 0!==t.spin){var e=this.autorotatePlugin;t.spin?e.start():e.stop()}this.create()}return Object.assign({},this._.options)}}},canvasPlugin:function(){function t(){var t=this._;t.options.showCanvas=!0,o.path=d3.geoPath().projection(t.proj)}function e(){var t=this._;if(t.options.showCanvas){if(!o.canvas){var e=t.svg.append("g").attr("class","canvas").append("foreignObject").attr("x",0).attr("y",0).attr("width",t.options.width).attr("height",t.options.height).append("xhtml:body").style("margin","0px").style("padding","0px").style("background-color","none").style("width",t.options.width+"px").style("height",t.options.height+"px");o.canvas=e.append("canvas")}o.canvas.attr("x",0).attr("y",0).attr("width",t.options.width).attr("height",t.options.height)}o.canvas&&n.call(this)}function n(){var t=this._.options,e=t.width,n=t.height;o.canvas.each(function(){this.getContext("2d").clearRect(0,0,e,n)})}var o={canvas:null,path:null,q:null};return{name:"canvasPlugin",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onRefresh:function(){n.call(this)},selectAll:function(t){return t&&(o.q=t,o.canvas=d3.selectAll(t)),o.canvas},render:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=this._;if(r.options.showCanvas){var a=!1,i=r.proj,s=i.rotate(),l=this;o.canvas.each(function(r,c){if(!e||e.indexOf(c)>-1){var u=n[c]||{};u.rotate?(a=!0,i.rotate([s[0]+u.rotate,s[1],s[2]])):a&&(a=!1,i.rotate(s));var h=this.getContext("2d");t.call(l,h,o.path.context(h))}}),a&&(a=!1,i.rotate(s))}},flipRender:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=this._,a=r.center[0],i=r.proj.rotate();o.me.render(function(e,n){e.save(),e.translate(a,0),e.scale(-1,1),e.translate(-a,0),r.proj.rotate([i[0]+180,-i[1],-i[2]]),t.call(this,e,n),e.restore(),r.proj.rotate(i)},e,n)}}},countryCanvas:function(t){function e(){o.canvas=d3.select("body").append("canvas").attr("class","ej-hidden").attr("width","1024").attr("height","512").node(),o.context=o.canvas.getContext("2d"),o.proj=d3.geoEquirectangular().precision(.5).translate([512,256]).scale(163),o.path=d3.geoPath().projection(o.proj).context(o.context)}function n(){if(o.recreate){o.recreate=!1,o.context.clearRect(0,0,1024,512);for(var t=o.countries.features.length;t--;)o.context.beginPath(),o.path(o.countries.features[t]),o.context.fillStyle="rgb("+(t+1)+",0,0)",o.context.fill()}}var o={recreate:!0};return{name:"countryCanvas",urls:t&&[t],onReady:function(t,e){o.me.data(e)},onInit:function(t){o.me=t,e.call(this)},onCreate:function(){this.worldJson&&!o.world&&o.me.allData(this.worldJson.allData()),n.call(this)},data:function(t){if(!t)return o.world;o.world=t,o.countries=topojson.feature(t,t.objects.countries)},allData:function(t){if(!t)return{world:o.world,countries:o.countries};o.world=t.world,o.countries=t.countries},detectCountry:function(t){var e=o.proj(t);if(e[0]>0){var n=o.context.getImageData(e[0],e[1],1,1).data;return o.countries.features[n[0]-1]}}}},threejsPlugin:function(){function t(t){var e=t[0]*Math.PI/180,n=t[1]*Math.PI/180,o=Math.cos(n);return new THREE.Vector3(l*o*Math.cos(e),l*Math.sin(n),-l*o*Math.sin(e))}function e(e,n){var o=new THREE.Geometry;return e.coordinates.forEach(function(e){d3.pairs(e.map(t),function(t,e){o.vertices.push(t,e)})}),new THREE.LineSegments(o,n)}function n(){var t=this._;l=t.proj.scale();var e=t.options,n=e.width,o=e.height,r=document.getElementById(i);s.scale=d3.scaleLinear().domain([0,l]).range([0,1]),s.camera=new THREE.OrthographicCamera(-n/2,n/2,o/2,-o/2,.1,3e4),s.light=new THREE.PointLight(16777215,0),s.scene=new THREE.Scene,s.group=new THREE.Group,s.camera.position.z=3010,s.scene.add(s.camera),s.scene.add(s.group),s.camera.add(s.light),this._.camera=s.camera,s.renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0,canvas:r}),s.renderer.setClearColor(0,0),s.renderer.setSize(n,o),s.renderer.sortObjects=!1,this.renderThree=a,window.THREEx&&window.THREEx.DomEvents&&(s.domEvents=new window.THREEx.DomEvents(s.camera,s.renderer.domElement)),this._.domEvents=s.domEvents}function o(t){t||(t=s.group);var e=s.scale(this._.proj.scale());t.scale.x=e,t.scale.y=e,t.scale.z=e,a.call(this)}function r(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t||(t=s.group);var n=this._,o=n.proj.rotate();o[0]-=90;var r=n.versor(o),i=new THREE.Quaternion(-r[2],r[1],r[3],r[0]);t.setRotationFromQuaternion(i),a.call(this,e)}function a(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments[1];e?s.renderer.render(s.scene,s.camera):null===c&&(c=setTimeout(function(){n&&n.call(t,s.group),s.renderer.render(s.scene,s.camera),c=null},0))}var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"three-js",s={renderer:null,scene:null,camera:null},l=void 0,c=null;return{name:"threejsPlugin",onInit:function(t){s.me=t,n.call(this)},onCreate:function(){s.group.children=[],a.call(this,!1,r)},onRefresh:function(){r.call(this,null,!0)},onResize:function(){o.call(this)},group:function(){return s.group},addGroup:function(t){s.group.add(t)},scale:function(t){o.call(this,t)},rotate:function(t){r.call(this,t)},vertex:function(e){return t(e)},wireframe:function(t,n){return e(t,n)},renderThree:function(){a.call(this)},light:function(){return s.camera.children[0]}}},dblClickCanvas:function(){function t(t){return n.countries.features.find(function(e){return e.geometry.coordinates.find(function(e){return d3.polygonContains(e,t)||e.find(function(e){return d3.polygonContains(e,t)})})})}function e(){if(this.worldCanvas){var e=this.worldCanvas.data();e&&(n.countries=topojson.feature(e,e.objects.countries))}var o=this._,r=this;this.mousePlugin&&this.mousePlugin.onDblClick({dblClickCanvas:function(e,a){var i=this;if(e){e.sourceEvent&&(e=e.sourceEvent);var s=[e.clientX,e.clientY],l=o.proj.invert(a);n.pos=l,n.dot=null,n.mouse=s,n.country=null,o.options.showDots&&n.onCircleVals.forEach(function(t){n.dot=t.call(i,e,l)}),o.options.showLand&&!n.dot&&(o.drag||(r.countryCanvas?n.country=r.countryCanvas.detectCountry(l):n.country=t(l)),n.onCountryVals.forEach(function(t){t.call(i,e,n.country)}))}}})}var n={mouse:null,country:null,countries:null,onCircle:{},onCircleVals:[],onCountry:{},onCountryVals:[]};return{name:"dblClickCanvas",onInit:function(t){n.me=t,e.call(this)},onCreate:function(){this.worldJson&&!n.world&&n.me.allData(this.worldJson.allData())},onCircle:function(t){Object.assign(n.onCircle,t),n.onCircleVals=Object.keys(n.onCircle).map(function(t){return n.onCircle[t]})},onCountry:function(t){Object.assign(n.onCountry,t),n.onCountryVals=Object.keys(n.onCountry).map(function(t){return n.onCountry[t]})},data:function(t){if(!t)return n.world;n.world=t,n.countries=topojson.feature(t,t.objects.countries)},allData:function(t){if(!t)return{world:n.world,countries:n.countries};n.world=t.world,n.countries=t.countries},state:function(){return{pos:n.pos,dot:n.dot,mouse:n.mouse,country:n.country}}}},autorotatePlugin:function(){function t(){var t=this._.options;this.clickCanvas&&this.clickCanvas.onCountry({autorotatePlugin:function(e,n){n||(t.spin=!t.spin)}})}function e(t){if(t-a>40){a=t;var e=new Date;if(this._.options.spin&&!this._.drag){var o=e-r.lastTick;n.call(this,o),r.sync.forEach(function(t){return n.call(t,o)})}r.lastTick=e}}function n(t){var e=this._.proj.rotate();e[0]+=r.degree*t,this._.rotate(e)}var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r={lastTick:new Date,degree:o/1e3,sync:[]},a=0;return{name:"autorotatePlugin",onInit:function(t){r.me=t,this._.options.spin=!0},onCreate:function(){t.call(this)},onInterval:function(t){e.call(this,t)},speed:function(t){r.degree=t/1e3},sync:function(t){r.sync=t},start:function(){this._.options.spin=!0},stop:function(){this._.options.spin=!1},spin:function(t){if(void 0===t)return this._.options.spin;this._.options.spin=t}}},oceanSvg:function(){function t(){var t=this._;this._.options.showOcean=!0,Object.defineProperty(t.options,"oceanColor",{get:function(){return o.oceanColor},set:function(t){o.oceanColor=t}}),o.svg=t.svg}function e(){if(o.svg.selectAll("#ocean,.ocean").remove(),this._.options.showOcean){var t=o.oceanColor,e=this.$slc.defs.append("radialGradient").attr("id","ocean").attr("cx","75%").attr("cy","25%");"string"==typeof t&&(t=[t,t]),e.append("stop").attr("offset","100%").attr("stop-color",t[1]),r.ocean=o.svg.append("g").attr("class","ocean").append("circle").attr("cx",this._.center[0]).attr("cy",this._.center[1]).attr("class","noclicks"),n.call(this)}}function n(){r.ocean&&this._.options.showOcean&&r.ocean.attr("r",this._.proj.scale()+o.scale)}var o={svg:null,q:null,scale:0,oceanColor:["rgba(221, 221, 255, 0.6)","rgba(153, 170, 187,0.8)"]},r={};return{name:"oceanSvg",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onResize:function(){n.call(this)},selectAll:function(t){return t&&(o.q=t,o.svg=d3.selectAll(t)),o.svg},scale:function(t){if(!t)return o.scale;o.scale=t,n.call(this)},recreate:function(){e.call(this)},$ocean:function(){return r.ocean}}},sphereSvg:function(){function t(){var t=this._;t.options.showSphere=!0,o.svg=t.svg}function e(){o.svg.selectAll("#glow,.sphere").remove(),this._.options.showSphere&&(this.$slc.defs.nodes()[0].append("\n<filter id='glow'>\n <feColorMatrix type='matrix'\n values=\n '0 0 0 0 0\n 0 0 0 0.9 0\n 0 0 0 0.9 0\n 0 0 0 1 0'/>\n <feGaussianBlur stdDeviation='5.5' result='coloredBlur'/>\n <feMerge>\n <feMergeNode in='coloredBlur'/>\n <feMergeNode in='SourceGraphic'/>\n </feMerge>\n</filter>\n"),r.sphere=o.svg.append("g").attr("class","sphere").append("circle").attr("cx",this._.center[0]).attr("cy",this._.center[1]).attr("class","noclicks").attr("filter","url(#glow)"),n.call(this))}function n(){r.sphere.attr("r",this._.proj.scale())}var o={svg:null,q:null,sphereColor:0},r={};return{name:"sphereSvg",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onResize:function(){n.call(this)},selectAll:function(t){return t&&(o.q=t,o.svg=d3.selectAll(t)),o.svg},$sphere:function(){return r.sphere}}},zoomPlugin:function(){function t(){var t=this._,e=t.proj.scale(),n=[t.options.width,t.options.height];t.svg.call(d3.zoom().on("zoom start end",function(){var n=d3.event.transform;t.proj.scale(e*n.k),t.resize(),t.refresh()}).scaleExtent([.1,5]).translateExtent([[0,0],n]))}var e={};return{name:"zoomPlugin",onInit:function(n){e.me=n,t.call(this)}}},fauxGlobeSvg:function(){function t(){var t=this._;t.options.showGlobeShading=!0,t.options.showGlobeHilight=!0,a.svg=t.svg}function e(){n.call(this),o.call(this)}function n(){var t=this._;if(a.svg.selectAll("#shading,.shading").remove(),t.options.showGlobeShading){var e=this.$slc.defs.append("radialGradient").attr("id","shading").attr("cx","50%").attr("cy","40%");e.append("stop").attr("offset","50%").attr("stop-color","#9ab").attr("stop-opacity","0"),e.append("stop").attr("offset","100%").attr("stop-color","#3e6184").attr("stop-opacity","0.3"),i.globeShading=a.svg.append("g").attr("class","shading").append("circle").attr("cx",t.center[0]).attr("cy",t.center[1]).attr("r",t.proj.scale()).attr("class","noclicks").style("fill","url(#shading)")}}function o(){var t=this._;if(a.svg.selectAll("#hilight,.hilight").remove(),t.options.showGlobeHilight){var e=this.$slc.defs.append("radialGradient").attr("id","hilight").attr("cx","75%").attr("cy","25%");e.append("stop").attr("offset","5%").attr("stop-color","#ffd").attr("stop-opacity","0.6"),e.append("stop").attr("offset","100%").attr("stop-color","#ba9").attr("stop-opacity","0.2"),i.globeHilight=a.svg.append("g").attr("class","hilight").append("circle").attr("cx",t.center[0]).attr("cy",t.center[1]).attr("r",t.proj.scale()).attr("class","noclicks").style("fill","url(#hilight)")}}function r(){var t=this._,e=t.options,n=t.proj.scale();i.globeShading&&e.showGlobeShading&&i.globeShading.attr("r",n),i.globeHilight&&e.showGlobeHilight&&i.globeHilight.attr("r",n)}var a={svg:null,q:null},i={};return{name:"fauxGlobeSvg",onInit:function(e){a.me=e,t.call(this)},onCreate:function(){e.call(this)},onResize:function(){r.call(this)},selectAll:function(t){return t&&(a.q=t,a.svg=d3.selectAll(t)),a.svg},$globeShading:function(){return i.globeShading},$globeHilight:function(){return i.globeHilight}}},graticuleSvg:function(){function t(){var t=this._;t.options.showGraticule=!0,t.options.transparentGraticule=!1,o.svg=t.svg}function e(){o.svg.selectAll(".graticule").remove(),this._.options.showGraticule&&(r.graticule=o.svg.append("g").attr("class","graticule").append("path").datum(o.graticule).attr("class","noclicks"),n.call(this))}function n(){var t=this._;r.graticule&&t.options.showGraticule&&(t.options.transparent||t.options.transparentGraticule?(t.proj.clipAngle(180),r.graticule.attr("d",this._.path),t.proj.clipAngle(90)):r.graticule.attr("d",this._.path))}var o={svg:null,q:null,graticule:d3.geoGraticule()},r={};return{name:"graticuleSvg",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onRefresh:function(){n.call(this)},selectAll:function(t){return t&&(o.q=t,o.svg=d3.selectAll(t)),o.svg},$graticule:function(){return r.graticule}}},dropShadowSvg:function(){function t(){var t=this._;t.options.showDropShadow=!0,o.svg=t.svg}function e(){var t=this._;if(o.svg.selectAll("#drop_shadow,.drop_shadow").remove(),t.options.showDropShadow){var e=this.$slc.defs.append("radialGradient").attr("id","drop_shadow").attr("cx","50%").attr("cy","50%");e.append("stop").attr("offset","20%").attr("stop-color","#000").attr("stop-opacity",".5"),e.append("stop").attr("offset","100%").attr("stop-color","#000").attr("stop-opacity","0"),r.dropShadow=o.svg.append("g").attr("class","drop_shadow").append("ellipse").attr("cx",t.center[0]).attr("class","noclicks").style("fill","url(#drop_shadow)"),n.call(this)}}function n(){var t=this._.proj.scale();r.dropShadow.attr("cy",t+this._.center[1]).attr("rx",.9*t).attr("ry",.25*t)}var o={svg:null,q:null},r={};return{name:"dropShadowSvg",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onResize:function(){r.dropShadow&&this._.options.showDropShadow&&n.call(this)},selectAll:function(t){return t&&(o.q=t,o.svg=d3.selectAll(t)),o.svg},$dropShadow:function(){return r.dropShadow}}},dotTooltipSvg:function(){function t(t,e){var n=t.properties,o=Object.keys(n).map(function(t){return t+": "+n[t]}).join("<br/>");return e.html(o)}function e(){var e=this;this.dotsSvg.$dots().on("mouseover",function(){if(e._.options.showBarTooltip){r.visible=!0,r.mouseXY=[d3.event.pageX+7,d3.event.pageY-15];var o=+this.dataset.index,i=e.dotsSvg.data().features[o];(r.me.show||t)(i,a).style("display","block").style("opacity",1),n()}}).on("mouseout",function(){r.visible=!1,a.style("opacity",0).style("display","none")}).on("mousemove",function(){e._.options.showBarTooltip&&(r.mouseXY=[d3.event.pageX+7,d3.event.pageY-15],n())})}function n(){a.style("left",r.mouseXY[0]+7+"px").style("top",r.mouseXY[1]-15+"px")}function o(){e.call(this),a.style("opacity",0).style("display","none")}var r={mouseXY:[0,0],visible:!1},a=d3.select("body").append("div").attr("class","ej-dot-tooltip");return{name:"dotTooltipSvg",onInit:function(t){r.me=t,this._.options.showBarTooltip=!0},onCreate:function(){e.call(this)},onRefresh:function(){n.call(this)},onResize:function(){o.call(this)},visible:function(){return r.visible}}},dotSelectCanvas:function(){function t(t){var e=null;if(n.dots){var o=this.hoverCanvas.states().mouse;n.dots.forEach(function(n){o&&!e&&d3.geoDistance(n.coordinates,t)<=.02&&(e=n)})}return e}function e(){var e=this;if(this.hoverCanvas){var o=function(o,r){var a=t.call(e,r);return n.onHoverVals.forEach(function(t){t.call(e,o,a)}),a};o.tooltips=!0,this.hoverCanvas.onCircle({dotsCanvas:o})}if(this.clickCanvas){var r=function(o,r){var a=t.call(e,r);return n.onClickVals.forEach(function(t){t.call(e,o,a)}),a};this.clickCanvas.onCircle({dotsCanvas:r})}if(this.dblClickCanvas){var a=function(o,r){var a=t(o,r);return n.onDblClickVals.forEach(function(t){t.call(e,o,a)}),a};this.dblClickCanvas.onCircle({dotsCanvas:a})}}var n={dataDots:null,dots:null,radiusPath:null,onHover:{},onHoverVals:[],onClick:{},onClickVals:[],onDblClick:{},onDblClickVals:[]};return{name:"dotSelectCanvas",onInit:function(t){n.me=t,e.call(this)},onCreate:function(){this.dotsCanvas&&!n.dots&&n.me.dots(this.dotsCanvas.dots())},onHover:function(t){Object.assign(n.onHover,t),n.onHoverVals=Object.keys(n.onHover).map(function(t){return n.onHover[t]})},onClick:function(t){Object.assign(n.onClick,t),n.onClickVals=Object.keys(n.onClick).map(function(t){return n.onClick[t]})},onDblClick:function(t){Object.assign(n.onDblClick,t),n.onDblClickVals=Object.keys(n.onDblClick).map(function(t){return n.onDblClick[t]})},dots:function(t){n.dots=t}}},graticuleCanvas:function(){function t(){var t=this._;t.options.showGraticule=!0,t.options.transparentGraticule=!1}function e(){var t=this._;t.options.showGraticule&&((t.options.transparent||t.options.transparentGraticule)&&t.proj.clipAngle(180),this.canvasPlugin.render(function(t,e){t.beginPath(),e(n),t.lineWidth=.4,t.strokeStyle=o.style.line||"rgba(119,119,119,0.6)",t.stroke()},o.drawTo),(t.options.transparent||t.options.transparentGraticule)&&t.proj.clipAngle(90))}var n=d3.geoGraticule()(),o={style:{},drawTo:null};return{name:"graticuleCanvas",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},onRefresh:function(){e.call(this)},drawTo:function(t){o.drawTo=t},style:function(t){return t&&(o.style=t),o.style}}},dotTooltipCanvas:function(){function t(t,e){var n=t.properties,o=Object.keys(n).map(function(t){return t+": "+n[t]}).join("<br/>");return e.html(o)}function e(e,n){var o=[e.clientX,e.clientY];(r.me.show||t)(n,a).style("display","block").style("opacity",1).style("left",o[0]+7+"px").style("top",o[1]-15+"px"),r.oldData=n,r.hidden=!1}function n(){r.hidden||(r.hidden=!0,a.style("opacity",0).style("display","none"))}function o(){var t=this;this.dotSelectCanvas.onHover({dotTooltipCanvas:function(o,r){r&&null!==t._.drag?e(o,r):n()}})}var r={hidden:null},a=d3.select("body").append("div").attr("class","ej-dot-tooltip");return{name:"dotTooltipCanvas",onInit:function(t){r.me=t,o.call(this)}}},countrySelectCanvas:function(){function t(){var t=this;if(this.hoverCanvas){var e=function(e,o){return n.onHoverVals.forEach(function(n){n.call(t,e,o)}),o};this.hoverCanvas.onCountry({countrySelectCanvas:e})}if(this.clickCanvas){var o=function(e,o){return n.onClickVals.forEach(function(n){n.call(t,e,o)}),o};this.clickCanvas.onCountry({countrySelectCanvas:o})}if(this.dblClickCanvas){var r=function(e,o){return n.onDblClickVals.forEach(function(n){n.call(t,e,o)}),o};this.dblClickCanvas.onCountry({countrySelectCanvas:r})}}function e(){if(this.worldCanvas&&!n.countries){var t=this.worldCanvas.data();t&&(n.world=t,n.countries=topojson.feature(t,t.objects.countries))}}var n={countries:null,onHover:{},onHoverVals:[],onClick:{},onClickVals:[],onDblClick:{},onDblClickVals:[]};return{name:"countrySelectCanvas",onInit:function(e){n.me=e,t.call(this)},onCreate:function(){e.call(this)},onHover:function(t){Object.assign(n.onHover,t),n.onHoverVals=Object.keys(n.onHover).map(function(t){return n.onHover[t]})},onClick:function(t){Object.assign(n.onClick,t),n.onClickVals=Object.keys(n.onClick).map(function(t){return n.onClick[t]})},onDblClick:function(t){Object.assign(n.onDblClick,t),n.onDblClickVals=Object.keys(n.onDblClick).map(function(t){return n.onDblClick[t]})},data:function(t){if(!t)return n.world;n.world=t,n.countries=topojson.feature(t,t.objects.countries)}}},countryTooltipCanvas:function(t){function e(t){var e="";return s.countryNames&&(e=s.countryNames.find(function(e){return e.id==t.id})),e}function n(t){return l.style("left",t[0]+7+"px").style("top",t[1]-15+"px")}function o(t,e){var n=Object.keys(t).map(function(e){return e+": "+t[e]}).join("<br/>");return e.html(n)}function r(t,e){n([t.clientX,t.clientY]),(s.me.show||o)(e,l).style("display","block").style("opacity",1),s.hidden=!1}function a(){s.hidden||(s.hidden=!0,l.style("opacity",0).style("display","none"))}function i(){var t=this,n=function(n,o){if(null!==t._.drag&&o&&t._.options.showCountryTooltip){var i=e(o);!i||t.barTooltipSvg&&t.barTooltipSvg.visible()?a():r(n,i)}else a()};n.tooltips=!0,this.hoverCanvas.onCountry({countryTooltipCanvas:n}),this._.options.showCountryTooltip=!0}var s={hidden:null},l=d3.select("body").append("div").attr("class","ej-country-tooltip");return{name:"countryTooltipCanvas",urls:t&&[t],onReady:function(t,e){s.countryNames=e},onInit:function(t){s.me=t,i.call(this)},onRefresh:function(){this._.drag&&n(this.mousePlugin.mouse())},data:function(t){if(!t)return s.countryNames;s.countryNames=t}}},countryTooltipSvg:function(t){function e(t){var e="";return a.countryNames&&(e=a.countryNames.find(function(e){return e.id==t.id})),e}function n(t,e){var n=Object.keys(t).map(function(e){return e+": "+t[e]}).join("<br/>");return e.html(n)}function o(){var t=this;this.worldSvg.$countries().on("mouseover",function(o){if(t._.options.showCountryTooltip){a.show=!0;var s=e(o);r(),(a.me.show||n)(s,i).style("display","block").style("opacity",1)}}).on("mouseout",function(){a.show=!1,i.style("opacity",0).style("display","none")}).on("mousemove",function(){t._.options.showCountryTooltip&&r()})}function r(t){return t||(t=[d3.event.pageX,d3.event.pageY]),i.style("left",t[0]+7+"px").style("top",t[1]-15+"px")}var a={show:!1},i=d3.select("body").append("div").attr("class","ej-country-tooltip");return{name:"countryTooltipSvg",urls:t&&[t],onReady:function(t,e){a.countryNames=e},onInit:function(t){a.me=t,this._.options.showCountryTooltip=!0},onCreate:function(){o.call(this)},onRefresh:function(){this._.drag&&a.show&&r(this.mousePlugin.mouse())},data:function(t){if(!t)return a.countryNames;a.countryNames=t}}},barTooltipSvg:function(){function t(t,e){var n=t.properties,o=Object.keys(n).map(function(t){return t+": "+n[t]}).join("<br/>");return e.html(o)}function e(){var e=this;this.barSvg.$bar().on("mouseover",function(){if(e._.options.showBarTooltip){r.visible=!0,r.mouseXY=[d3.event.pageX+7,d3.event.pageY-15];var o=+this.dataset.index,i=e.barSvg.data().features[o];(r.me.show||t)(i,a).style("display","block").style("opacity",1),n()}}).on("mouseout",function(){r.visible=!1,a.style("opacity",0).style("display","none")}).on("mousemove",function(){e._.options.showBarTooltip&&(r.mouseXY=[d3.event.pageX+7,d3.event.pageY-15],n())})}function n(){a.style("left",r.mouseXY[0]+7+"px").style("top",r.mouseXY[1]-15+"px")}function o(){e.call(this),a.style("opacity",0).style("display","none")}var r={mouseXY:[0,0],visible:!1},a=d3.select("body").append("div").attr("class","ej-bar-tooltip");return{name:"barTooltipSvg",onInit:function(t){r.me=t,this._.options.showBarTooltip=!0},onCreate:function(){e.call(this)},onRefresh:function(){n.call(this)},onResize:function(){o.call(this)},visible:function(){return r.visible}}},worldCanvas:function(t){function e(){var t=this._;if(a.world&&((t.options.transparent||t.options.transparentLand)&&this.canvasPlugin.flipRender(function(t,e){t.beginPath(),e(a.land),t.fillStyle=a.style.backLand||"rgba(119,119,119,0.2)",t.fill()},a.drawTo,a.options),t.options.showLand?(t.options.showCountries||a.me.showCountries?o.call(this,t.options.showBorder):n.call(this),!t.drag&&t.options.showLakes&&r.call(this)):t.options.showBorder&&o.call(this,!0),this.hoverCanvas&&t.options.showSelectedCountry)){if(a.selected.features.length>0)if(a.selected.multiColor){var e=!0,i=!1,s=void 0;try{for(var l,c=a.selected.features[Symbol.iterator]();!(e=(l=c.next()).done);e=!0){var u=l.value;this.canvasPlugin.render(function(t,e){t.beginPath(),e(u),t.fillStyle=u.color,t.fill()},a.drawTo,a.options)}}catch(t){i=!0,s=t}finally{try{!e&&c.return&&c.return()}finally{if(i)throw s}}}else this.canvasPlugin.render(function(t,e){t.beginPath(),e(a.selected),t.fillStyle=a.style.selected||"rgba(87, 255, 99, 0.4)",t.fill()},a.drawTo,a.options);var h=this.hoverCanvas.states().country;h&&!a.selected.features.find(function(t){return t.id===h.id})&&this.canvasPlugin.render(function(t,e){t.beginPath(),e(h),t.fillStyle=a.style.hover||"rgba(117, 0, 0, 0.4)",t.fill()},a.drawTo,a.options)}}function n(){this.canvasPlugin.render(function(t,e){t.beginPath(),e(a.land),t.fillStyle=a.style.land||"rgba(2, 20, 37,0.8)",t.fill()},a.drawTo,a.options)}function o(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.canvasPlugin.render(function(e,n){e.beginPath(),n(a.countries),t||(e.fillStyle=a.style.countries||"rgba(2, 20, 37,0.8)",e.fill()),e.lineWidth=.1,e.strokeStyle=a.style.border||"rgb(239, 237, 234)",e.stroke()},a.drawTo,a.options)}function r(){this.canvasPlugin.render(function(t,e){t.beginPath(),e(a.lakes),t.fillStyle=a.style.lakes||"rgba(80, 87, 97, 0.4)",t.fill()},a.drawTo,a.options)}var a={style:{},options:{},drawTo:null,world:null,land:null,lakes:{type:"FeatureCollection",features:[]},countries:{type:"FeatureCollection",features:[]},selected:{type:"FeatureCollection",features:[],multiColor:!1}};return{name:"worldCanvas",urls:t&&[t],onReady:function(t,e){a.me.data(e)},onInit:function(t){a.me=t;var e=this._.options;e.showLand=!0,e.showLakes=!0,e.showBorder=!1,e.showCountries=!0,e.transparentLand=!1},onCreate:function(){var t=this;if(this.worldJson&&!a.world&&a.me.allData(this.worldJson.allData()),e.call(this),this.hoverCanvas){var n={};n[a.me.name]=function(){t._.options.spin||t._.refresh()},this.hoverCanvas.onCountry(n)}},onRefresh:function(){e.call(this)},countries:function(t){if(!t)return a.countries.features;a.countries.features=t},selectedCountries:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return a.selected.features;a.selected.features=t,a.selected={type:"FeatureCollection",features:t,multiColor:e}},data:function(t){if(!t)return a.world;a.world=t,a.land=topojson.feature(t,t.objects.land),a.lakes.features=topojson.feature(t,t.objects.ne_110m_lakes).features,a.countries.features=topojson.feature(t,t.objects.countries).features},allData:function(t){if(!t)return{world:a.world,land:a.land,lakes:a.lakes,countries:a.countries};a.world=t.world,a.land=t.land,a.lakes=t.lakes,a.countries=t.countries},drawTo:function(t){a.drawTo=t},style:function(t){return t&&(a.style=t),a.style},options:function(t){a.options=t}}},centerSvg:function(){function t(t,e){e=e.replace("x","");for(var n=0,o=t.length;n<o;n++)if(t[n].id==e)return t[n]}function e(t){var e=this._,n=d3.interpolate(e.proj.rotate(),[-t[0],-t[1],0]),o=function(t){return e.rotate(n(t))};d3.transition().duration(2500).tween("rotate",function(){return o})}function n(){var n=this;this.worldSvg.$countries().on("click",function(){if(n._.options.enableCenter){var r=this.id.replace("x",""),a=t(n.worldSvg.countries(),r);e.call(n,d3.geoCentroid(a)),"function"==typeof o.focused&&o.focused.call(n)}})}var o={focused:null,svgAddCountriesOld:null};return{name:"centerSvg",onInit:function(t){o.me=t,this._.options.enableCenter=!0},onCreate:function(){n.call(this)},go:function(n){var o=t(this.worldSvg.countries(),n),r=d3.geoCentroid(o);e.call(this,r)},focused:function(t){o.focused=t}}},placesSvg:function(t){function e(){var t=this._;t.options.showPlaces=!0,s.svg=t.svg}function n(){s.svg.selectAll(".points,.labels").remove(),s.places&&this._.options.showPlaces&&(o.call(this),r.call(this),i.call(this))}function o(){l.placePoints=s.svg.append("g").attr("class","points").selectAll("path").data(s.places.features).enter().append("path").attr("class","point")}function r(){l.placeLabels=s.svg.append("g").attr("class","labels").selectAll("text").data(s.places.features).enter().append("text").attr("class","label").text(function(t){return t.properties.name})}function a(){var t=this,e=this._.proj.invert(this._.center);l.placeLabels.attr("text-anchor",function(e){var n=t._.proj(e.geometry.coordinates)[0];return n<t._.center[0]-20?"end":n<t._.center[0]+20?"middle":"start"}).attr("transform",function(e){var n=t._.proj(e.geometry.coordinates),o=n[0],r=n[1];return"translate("+(o+(o<t._.center[0]?-5:5))+","+(r-2)+")"}).style("display",function(t){return d3.geoDistance(t.geometry.coordinates,e)>1.57?"none":"inline"})}function i(){l.placePoints&&(l.placePoints.attr("d",this._.path),a.call(this))}var s={svg:null,q:null,places:null},l={};return{name:"placesSvg",urls:t&&[t],onReady:function(t,e){s.places=e},onInit:function(t){s.me=t,e.call(this)},onCreate:function(){n.call(this)},onRefresh:function(){i.call(this)},data:function(t){if(!t)return s.places;s.places=t},selectAll:function(t){return t&&(s.q=t,s.svg=d3.selectAll(t)),s.svg},$placePoints:function(){return l.placePoints},$placeLabels:function(){return l.placeLabels}}},worldSvg:function(t){function e(){var t=this._;s.svg.selectAll(".landbg,.land,.lakes,.countries").remove(),t.options.showLand&&(s.world&&((t.options.transparent||t.options.transparentLand)&&s.svgAddWorldBg.call(this),t.options.showCountries||s.me.showCountries?s.svgAddCountries.call(this):s.svgAddWorld.call(this),!t.drag&&t.options.showLakes&&s.svgAddLakes.call(this)),n.call(this))}function n(){var t=this._;s.world&&(t.options.transparent||t.options.transparentLand?(l.worldBg||o(),t.proj.clipAngle(180),l.worldBg.attr("d",t.path),t.proj.clipAngle(90)):l.worldBg&&(l.worldBg.remove(),l.worldBg=null),t.options.showLand&&(t.options.showCountries?(l.countries||(l.world.remove(),l.world=null,a()),l.countries.attr("d",t.path)):(l.world||(l.countries.remove(),l.countries=null,r()),l.world.attr("d",t.path)),t.options.showLakes&&l.lakes.attr("d",t.path)))}function o(){l.worldBg=s.svg.append("g").attr("class","landbg").append("path").datum(s.land).attr("fill","rgba(119,119,119,0.2)")}function r(){l.world=s.svg.append("g").attr("class","land").append("path").datum(s.land)}function a(){l.countries=s.svg.append("g").attr("class","countries").selectAll("path").data(s.countries.features).enter().append("path").attr("id",function(t){return"x"+t.id})}function i(){l.lakes=s.svg.append("g").attr("class","lakes").append("path").datum(s.lakes)}var s={q:null,svg:null,world:null,land:null,lakes:{type:"FeatureCollection",features:[]},selected:{type:"FeatureCollection",features:[]},countries:{type:"FeatureCollection",features:[]}},l={};return{name:"worldSvg",urls:t&&[t],onReady:function(t,e){s.me.data(e)},onInit:function(t){s.me=t;var e=this._,n=e.options;n.showLand=!0,n.showLakes=!0,n.showCountries=!0,n.transparentLand=!1,s.svgAddCountries=a,s.svgAddWorldBg=o,s.svgAddLakes=i,s.svgAddWorld=r,s.svg=e.svg},onCreate:function(){this.worldJson&&!s.world&&s.me.allData(this.worldJson.allData()),e.call(this)},onRefresh:function(){n.call(this)},countries:function(t){if(!t)return s.countries.features;s.countries.features=t},data:function(t){if(!t)return s.world;s.world=t,s.land=topojson.feature(t,t.objects.land),s.lakes.features=topojson.feature(t,t.objects.ne_110m_lakes).features,s.countries.features=topojson.feature(t,t.objects.countries).features},allData:function(t){if(!t)return{world:s.world,land:s.land,lakes:s.lakes,countries:s.countries};s.world=t.world,s.land=t.land,s.lakes=t.lakes,s.countries=t.countries},selectAll:function(t){return t&&(s.q=t,s.svg=d3.selectAll(t)),s.svg},$world:function(){return l.world},$lakes:function(){return l.lakes},$countries:function(){return l.countries}}},barSvg:function(t){function e(){var t=this._;t.options.showBars=!0,a.barProjection=t.orthoGraphic(),a.svg=t.svg}function n(){var t=this._;if(r.call(this),a.svg.selectAll(".bar").remove(),a.bars&&t.options.showBars){var e=a.svg.append("g").attr("class","bar"),n=e.append("mask").attr("id","edge");n.append("rect").attr("x",0).attr("y",0).attr("width","100%").attr("height","100%").attr("fill","white"),n.append("use").attr("xlink:href","#edgeCircle").attr("fill","black"),a.max=d3.max(a.bars.features,function(t){return parseInt(t.geometry.value)});var l=t.proj.scale();a.heightScale=d3.scaleLinear().domain([0,a.max]).range([l,l+s(l)]),i.bar=e.selectAll("line").data(a.bars.features).enter().append("line").attr("stroke","red").attr("stroke-width","2").attr("data-index",function(t,e){return e}),o.call(this)}}function o(){var t=this._;if(a.bars&&t.options.showBars){var e=t.proj,n=a.heightScale,o=a.barProjection,r=e.invert(t.center);o.rotate(this._.proj.rotate()),i.bar.each(function(t){var a=t.geometry.coordinates;o.scale(n(t.geometry.value));var i=d3.geoDistance(a,r),s=e(a),l=o(a);d3.select(this).attr("x1",s[0]).attr("y1",s[1]).attr("x2",l[0]).attr("y2",l[1]).attr("mask",i<1.57?null:"url(#edge)")})}}function r(){var t=this._;this.$slc.defs.selectAll("clipPath").remove(),this.$slc.defs.append("clipPath").append("circle").attr("id","edgeCircle").attr("cx",t.center[0]).attr("cy",t.center[1]).attr("r",t.proj.scale())}var a={svg:null,barProjection:null,q:null,bars:null,valuePath:null},i={},s=d3.scaleLinear().domain([0,200]).range([5,50]);return{name:"barSvg",urls:t&&[t],onReady:function(t,e){a.me.data(e)},onInit:function(t){a.me=t,e.call(this)},onCreate:function(){n.call(this)},onRefresh:function(){o.call(this)},onResize:function(){n.call(this)},selectAll:function(t){return t&&(a.q=t,a.svg=d3.selectAll(t)),a.svg},valuePath:function(t){a.valuePath=t},data:function(t){var e=this;if(!t)return a.bars;if(a.valuePath){var n=a.valuePath.split(".");t.features.forEach(function(t){var e=t;n.forEach(function(t){return e=e[t]}),t.geometry.value=e})}a.bars=t,setTimeout(function(){return o.call(e)},1)},$bar:function(){return i.bar}}},dotsSvg:function(t){function e(){var t=this._;t.options.showDots=!0,i.svg=t.svg}function n(){var t=this._;if(i.svg.selectAll(".dot").remove(),i.dataDots&&t.options.showDots){var e=[];if(i.circles.forEach(function(t){e.push(t.circle)}),s.dots=i.svg.append("g").attr("class","dot").selectAll("path").data(e).enter().append("path"),i.dataDots.geometry){var n=i.dataDots.geometry||{};s.dots.style("stroke-width",n.lineWidth||.2).style("fill",n.fillStyle||"rgba(100,0,0,.4)").style("stroke",n.strokeStyle||"rgba(119,119,119,.4)").attr("data-index",function(t,e){return e})}o.call(this)}}function o(){var t=this._,e=void 0,n=void 0;if(s.dots&&t.options.showDots){var o=i.dataDots.geometry||{};t.options.transparent||t.options.transparentDots?(t.proj.clipAngle(180),s.dots.style("fill",function(r,a){return e=r.coordinates[0][a],(n=d3.geoDistance(e,t.proj.invert(t.center)))>1.57?"none":o.fillStyle||"rgba(100,0,0,.4)"}),s.dots.style("display",function(){return t.drag&&!a?"none":"inline"}),s.dots.attr("d",t.path),t.proj.clipAngle(90)):(s.dots.style("display",function(o,r){return e=o.coordinates[0][r],(n=d3.geoDistance(e,t.proj.invert(t.center)))>1.57||t.drag&&!a?"none":"inline"}),s.dots.style("fill",o.fillStyle||"rgba(100,0,0,.4)"),s.dots.attr("d",t.path))}}function r(){var t=d3.geoCircle(),e=(i.dataDots.geometry||{}).radius||.5;i.circles=i.dataDots.features.map(function(n){var o=n.geometry.coordinates,r=n.properties,a=n.geometry.radius||e;return{properties:r,coordinates:o,circle:t.center(o).radius(a)()}})}var a=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).important,i={dataDots:null,radiusPath:null},s={};return{name:"dotsSvg",urls:t&&[t],onReady:function(t,e){i.me.data(e)},onInit:function(t){i.me=t,e.call(this)},onCreate:function(){n.call(this)},onRefresh:function(){o.call(this)},radiusPath:function(t){i.radiusPath=t},data:function(t){var e=this;if(!t)return i.dataDots;if(i.radiusPath){var n=i.radiusPath.split("."),a=t.features.map(function(t){var e=t;return n.forEach(function(t){return e=e[t]}),e}).sort(),s=d3.scaleLinear().domain([a[0],a.pop()]).range([.5,2]);t.features.forEach(function(t){var e=t;n.forEach(function(t){return e=e[t]}),t.geometry.radius=s(e)})}i.dataDots=t,r(),setTimeout(function(){return o.call(e)},1)},selectAll:function(t){return t&&(i.q=t,i.svg=d3.selectAll(t)),i.svg},$dots:function(){return s.dots}}},pingsSvg:function(){function t(){var t=this,e=this._;e.options.showPings=!0,setInterval(function(){return n.call(t)},3e3),r.svg=e.svg}function e(){if(r.svg.selectAll(".pings").remove(),r.dataPings&&this._.options.showPings){var t=r.svg.append("g").attr("class","pings");a.ping2=t.selectAll(".ping-2").data(r.dataPings.features).enter().append("circle").attr("class","ping-2").attr("id",function(t,e){return"ping-"+e}),a.pings=t.selectAll(".ping-2"),o.call(this),n.call(this)}}function n(){var t=a.ping2.nodes().filter(function(t){return"inline"==t.style.display});t.length>0&&d3.select("#"+t[Math.floor(Math.random()*(t.length-1))].id).attr("r",2).attr("stroke","#F00").attr("stroke-opacity",1).attr("stroke-width","10px").transition().duration(1e3).attr("r",30).attr("fill","none").attr("stroke-width","0.1px")}function o(){if(null==this._.drag)a.pings.style("display","none");else if(!this._.drag&&a.pings&&this._.options.showPings){var t=this._.proj,e=this._.proj.invert(this._.center);a.pings.attr("cx",function(e){return t(e.geometry.coordinates)[0]}).attr("cy",function(e){return t(e.geometry.coordinates)[1]}).style("display",function(t){return d3.geoDistance(t.geometry.coordinates,e)>1.57?"none":"inline"})}}var r={svg:null,dataPings:null},a={};return{name:"pingsSvg",onInit:function(e){r.me=e,t.call(this)},onCreate:function(){e.call(this)},onRefresh:function(){o.call(this)},data:function(t){if(!t)return r.dataPings;r.dataPings=t},selectAll:function(t){return t&&(r.q=t,r.svg=d3.selectAll(t)),r.svg},$pings:function(){return a.pings}}},pinCanvas:function(t,e){function n(t){this._.options.showPin=!0;var e=this._.proj.scale();i.w=d3.scaleLinear().domain([0,e]).range([0,t[0]]),i.h=d3.scaleLinear().domain([0,e]).range([0,t[1]]),r.call(this)}function o(){if(this._.options.showPin){var t=this._,e=t.proj.invert(t.center);this.canvasPlugin.render(function(n){i.dataPin.features.forEach(function(o){var r=o.geometry.coordinates;if(d3.geoDistance(r,e)<=1.57){var a=t.path.centroid(o);n.drawImage(i.image,a[0]-i.pX,a[1]-i.pY,i.wh[0],i.wh[1])}})},i.drawTo)}}function r(){var t=this._.proj.scale(),e=[i.w(t),i.h(t)];i.wh=e,i.pX=e[0]/2,i.pY=e[1]}var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[15,25],i={dataPin:null,image:null,w:null,h:null};return d3.select("body").append("img").attr("src",e).attr("id","pin").attr("width","0").attr("height","0"),i.image=document.getElementById("pin"),{name:"pinCanvas",urls:t&&[t],onReady:function(t,e){i.me.data(e)},onInit:function(t){i.me=t,n.call(this,a)},onCreate:function(){var t=this;setTimeout(function(){return o.call(t)},1)},onResize:function(){r.call(this)},onRefresh:function(){o.call(this)},data:function(t){if(!t)return i.dataPin;i.dataPin=t},drawTo:function(t){i.drawTo=t},image:function(){return i.image},size:function(t){if(!t)return i.wh;i.wh=t,n.call(this,t)}}},dotsCanvas:function(t){function e(){var t=this._;if((!t.drag||o)&&r.dataDots&&this._.options.showDots){var e=this._.proj,n=r.dataDots.geometry||{},a=e.invert(this._.center),i=[],s=[];r.dots.forEach(function(t){d3.geoDistance(t.coordinates,a)>1.57?i.push(t.circle):s.push(t.circle)}),(t.options.transparent||t.options.transparentDots)&&this.canvasPlugin.flipRender(function(t,e){t.beginPath(),e({type:"GeometryCollection",geometries:i}),t.lineWidth=.2,t.strokeStyle="rgba(119,119,119,.4)",t.stroke()},r.drawTo),this.canvasPlugin.render(function(t,e){t.beginPath(),e({type:"GeometryCollection",geometries:s}),t.lineWidth=n.lineWidth||.2,t.fillStyle=n.fillStyle||"rgba(100,0,0,.4)",t.strokeStyle=n.strokeStyle||"rgba(100,0,0,.6)",t.fill(),t.stroke()},r.drawTo)}}function n(){var t=d3.geoCircle(),e=(r.dataDots.geometry||{}).radius||.5;r.dots=r.dataDots.features.map(function(n){var o=n.geometry.coordinates,r=n.properties,a=n.geometry.radius||e;return{properties:r,coordinates:o,circle:t.center(o).radius(a)()}})}var o=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).important,r={dataDots:null,dots:[],radiusPath:null};return{name:"dotsCanvas",urls:t&&[t],onReady:function(t,e){r.me.data(e)},onInit:function(t){r.me=t,this._.options.transparentDots=!1,this._.options.showDots=!0},onCreate:function(){e.call(this)},onRefresh:function(){(o||!0!==this._.drag)&&e.call(this)},radiusPath:function(t){r.radiusPath=t},data:function(t){var o=this;if(!t)return r.dataDots;if(r.radiusPath){var a=r.radiusPath.split("."),i=t.features.map(function(t){var e=t;return a.forEach(function(t){return e=e[t]}),e}).sort(),s=d3.scaleLinear().domain([i[0],i.pop()]).range([.5,2]);t.features.forEach(function(t){var e=t;a.forEach(function(t){return e=e[t]}),t.geometry.radius=s(e)})}r.dataDots=t,n(),setTimeout(function(){return e.call(o)},1)},drawTo:function(t){r.drawTo=t},dots:function(){return r.dots}}},pingsCanvas:function(){function t(t){if(t-n>40&&(n=t,!this._.drag&&this._.options.showPings)){var o=void 0,r=this._.proj;if(e.pings.length<=7){o=this._.proj.invert(this._.center);var a=e.dataPings.features.filter(function(t){return d3.geoDistance(t.geometry.coordinates,o)<=1.57}),i=a[Math.floor(Math.random()*(a.length-1))];e.pings.push({r:2.5,l:i.geometry.coordinates})}var s=e.pings[0];d3.geoDistance(s.l,this._.proj.invert(this._.center))>1.57?e.pings.shift():(this._.options.spin||this._.refresh(/anvas/),this.canvasPlugin.render(function(t){if(t.beginPath(),t.fillStyle="#F80",t.arc(r(s.l)[0],r(s.l)[1],s.r,0,2*Math.PI),t.fill(),t.closePath(),s.r=s.r+.2,s.r>5)e.pings.shift();else if(e.pings.length>1){var n=e.pings.shift();e.pings.push(n)}},e.drawTo))}}var e={dataPings:null,pings:[]},n=0;return{name:"pingsCanvas",onInit:function(t){e.me=t,this._.options.showPings=!0},onInterval:function(e){t.call(this,e)},data:function(t){if(!t)return e.dataPings;e.dataPings=t},drawTo:function(t){e.drawTo=t}}},centerCanvas:function(){function t(t,e){e=(""+e).replace("x","");for(var n=0,o=t.length;n<o;n++)if(t[n].id==e)return t[n]}function e(t){var e=this._,n=d3.interpolate(e.proj.rotate(),[-t[0],-t[1],0]),o=function(t){return e.rotate(n(t))};d3.transition().duration(2500).tween("rotate",function(){return o})}function n(){var t=this;this.clickCanvas&&this.clickCanvas.onCountry({centerCanvas:function(n,r){r&&(e.call(t,d3.geoCentroid(r)),"function"==typeof o.focused&&o.focused.call(t,n,r))}})}var o={focused:null};return{name:"centerCanvas",onInit:function(t){o.me=t,this._.options.enableCenter=!0},onCreate:function(){n.call(this)},go:function(n){var o=t(this.worldCanvas.countries(),n),r=d3.geoCentroid(o);e.call(this,r)},focused:function(t){o.focused=t}}},flattenSvg:function(){function t(){var t=this._.proj,e=d3.geoEquirectangular().scale(this._.options.width/6.3).translate(this._.center);r.g1=t,r.g2=e}function e(){var t=this;return t._.svg.transition().duration(10500).tween("projection",function(){return function(n){e.alpha(n),t._.refresh()}})}function n(t,n){var o=d3.geoProjection(function(e,o){var a=t([e*=180/Math.PI,o*=180/Math.PI]),i=n([e,o]);return[(1-r)*a[0]+r*i[0],(r-1)*a[1]-r*i[1]]}).scale(1),r=void 0;return e.alpha=function(e){if(!arguments.length)return r;r=+e;var a=t.center(),i=n.center(),s=t.translate(),l=n.translate();return o.center([(1-r)*a[0]+r*i[0],(1-r)*a[1]+r*i[1]]),o.translate([(1-r)*s[0]+r*l[0],(1-r)*s[1]+r*l[1]]),o},e.alpha(0),o}function o(){var t=this._;return d3.transition().duration(1500).tween("rotate",function(){t.rotate(t.proj.rotate());var e=d3.interpolate(t.proj.rotate(),[0,0,0]);return function(n){t.rotate(e(n))}})}var r={};return{name:"flattenSvg",onInit:function(e){r.me=e,t.call(this)},toMap:function(){var t=this;o.call(this).on("end",function(){var o=n(r.g1,r.g2);t._.path=d3.geoPath().projection(o),e.call(t).on("end",function(){t._.options.enableCenter=!1})})},toGlobe:function(){var t=this;this._.rotate([0,0,0]);var o=n(r.g2,r.g1);this._.path=d3.geoPath().projection(o),e.call(this).on("end",function(){t._.path=d3.geoPath().projection(t._.proj),t._.options.enableCenter=!0,t._.refresh()})}}},barThreejs:function(t){function e(t){for(var e=new THREE.BoxGeometry(2,2,t),n=0;n<e.faces.length;n+=2){var o=16777215*Math.random();e.faces[n].color.setHex(o),e.faces[n+1].color.setHex(o)}return e}function n(t,e){var n=.017453292519943295*(90-t.coordinates[1]),o=.017453292519943295*(360-t.coordinates[0]);t.position.x=e*Math.sin(n)*Math.cos(o),t.position.y=e*Math.cos(n),t.position.z=e*Math.sin(n)*Math.sin(o),t.lookAt({x:0,y:0,z:0})}function o(){this._.options.showBars=!0}function r(){var t=this.threejsPlugin;if(!i.sphereObject){var o=new THREE.Group,r=this._.proj.scale();i.max=d3.max(i.data.features,function(t){return parseInt(t.geometry.value)}),i.scale=d3.scaleLinear().domain([0,i.max]).range([2,70]),i.data.features.forEach(function(t){var l=t.geometry.value,c=l?i.scale(l):a,u=e(c),h=new THREE.Mesh(u,s);h.coordinates=t.geometry.coordinates,n(h,c/2+r),h.ov=c,o.add(h)}),i.sphereObject=o}t.addGroup(i.sphereObject)}var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i={sphereObject:null,data:null},s=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,morphTargets:!1,color:11206655});return{name:"barThreejs",urls:t&&[t],onReady:function(t,e){i.me.data(e)},onInit:function(t){i.me=t,o.call(this)},onCreate:function(){r.call(this)},data:function(t){if(!t)return i.data;if(i.valuePath){var e=i.valuePath.split(".");t.features.forEach(function(t){var n=t;e.forEach(function(t){return n=n[t]}),t.geometry.value=n})}i.data=t},scale:function(t){i.sphereObject.children.forEach(function(e){e.scale.x=t,e.scale.y=t,e.scale.z=t})},sphere:function(){return i.sphereObject},color:function(t){s.color.set(t),s.needsUpdate=!0,this.threejsPlugin.renderThree()}}},hmapThreejs:function(t){function e(){this._.options.showHmap=!0;var e=this._.proj.scale();if(r.geometry=new THREE.SphereGeometry(e,30,30),a.canvas=d3.select("body").append("canvas").style("position","absolute").style("display","none").style("top","450px").attr("id","webgl-hmap"),r.canvas=a.canvas.node(),r.heatmap=createWebGLHeatmap({intensityToAlpha:!0,width:1024,height:512,canvas:r.canvas}),r.texture=new THREE.Texture(r.canvas),r.material.map=r.texture,!t){a.canvas.style("display","inherit");var n=function(t,e){for(var n=0;n<200;){var o=2*Math.random()-1,a=2*Math.random()-1,i=o*o+a*a;if(!(i>1)){var s=Math.sqrt(i);o/=s,a/=s,o*=1-i,a*=1-i,n+=1,r.heatmap.addPoint(t+50*o,e+50*a,30,2/300)}}},o=function(t){t.preventDefault();for(var e=t.changedTouches,o=0;o<e.length;o++){var r=e[o];n(r.pageX,r.pageY)}};r.canvas.addEventListener("touchmove",o,!1),r.canvas.onmousemove=function(t){var e=t.offsetX||t.clientX,o=t.offsetY||t.clientY;n(e,o)},r.canvas.onclick=function(){r.heatmap.clear()}}}function n(){var t=this.threejsPlugin;r.sphereObject||(r.sphereObject=new THREE.Mesh(r.geometry,r.material)),r.texture.needsUpdate=!0,t.addGroup(r.sphereObject)}function o(){r.heatmap.update(),r.heatmap.display()}var r={sphereObject:null,material:new THREE.MeshBasicMaterial({transparent:!0})},a={canvas:null};return{name:"hmapThreejs",urls:t&&[t],onReady:function(t,e){r.me.data(e)},onInit:function(t){r.me=t,e.call(this)},onInterval:function(){t||(r.texture.needsUpdate=!0)},onCreate:function(){n.call(this)},onRefresh:function(){o.call(this)},data:function(t){if(!t)return r.world;r.world=t,r.countries=topojson.feature(t,t.objects.countries)},sphere:function(){return r.sphereObject}}},dotsThreejs:function(t){function e(){this._.options.showDots=!0}function n(t){var e=this.threejsPlugin,n=new THREE.CircleGeometry(10,30),o=new THREE.Mesh(n,a),r=e.vertex(t.geometry.coordinates);return o.position.set(r.x,r.y,r.z),o.lookAt({x:0,y:0,z:0}),o}function o(){var t=this,e=this.threejsPlugin;r.sphereObject||(r.sphereObject=new THREE.Group,r.dataDots.features.forEach(function(e){var o=n.call(t,e);r.sphereObject.add(o)})),e.addGroup(r.sphereObject)}var r={dataDots:null},a=new THREE.MeshBasicMaterial({side:THREE.DoubleSide,color:12687769});return{name:"dotsThreejs",urls:t&&[t],onReady:function(t,e){r.me.data(e)},onInit:function(t){r.me=t,e.call(this)},onCreate:function(){o.call(this)},data:function(t){if(!t)return r.dataDots;r.dataDots=t},sphere:function(){return r.sphereObject},color:function(t){a.color.set(t),a.needsUpdate=!0,this.threejsPlugin.renderThree()}}},dotsCThreejs:function(t){function e(){var t=void 0,e=this._.options;e.showDots=!0,this.canvasThreejs.onDraw({dotsCThreejs:function(n,r){if(e.showDots){t||(t=o.dots.map(function(t){return t.circle}));var a=o.dataDots.geometry||{};n.beginPath(),r({type:"GeometryCollection",geometries:t}),n.lineWidth=a.lineWidth||.2,n.fillStyle=a.fillStyle||"rgba(100,0,0,.4)",n.strokeStyle=a.strokeStyle||"rgba(100,0,0,.6)",n.fill(),n.stroke()}}})}function n(){var t=d3.geoCircle(),e=(o.dataDots.geometry||{}).radius||.5;o.dots=o.dataDots.features.map(function(n){var o=n.geometry.coordinates,r=n.properties,a=n.geometry.radius||e;return{properties:r,coordinates:o,circle:t.center(o).radius(a)()}})}var o={dataDots:null};return{name:"dotsCThreejs",urls:t&&[t],onReady:function(t,e){o.me.data(e)},onInit:function(t){o.me=t,e.call(this)},data:function(t){if(!t)return o.dataDots;o.dataDots=t,n()}}},iconsThreejs:function(t,e){function n(t,e){var n=.017453292519943295*(90-t.coordinates[1]),o=.017453292519943295*(360-t.coordinates[0]);t.position.x=e*Math.sin(n)*Math.cos(o),t.position.y=e*Math.cos(n),t.position.z=e*Math.sin(n)*Math.sin(o),t.lookAt({x:0,y:0,z:0})}function o(){var t=this.threejsPlugin;if(!i.sphereObject){var e=new THREE.Group,o=this._.proj.scale();i.data.features.forEach(function(t){var r=new THREE.PlaneGeometry(1,1,1,1),a=new THREE.Mesh(r,i.material);a.coordinates=t.geometry.coordinates,n(a,o+1),a.scale.set(6,6,1),e.add(a)}),i.sphereObject=e}t.addGroup(i.sphereObject)}function r(){var t=this,n=this.threejsPlugin;this._.options.showIcons=!0,(new THREE.TextureLoader).load(e,function(e){i.material=new THREE.MeshPhongMaterial({side:THREE.DoubleSide,transparent:!0,map:e}),i.data&&!i.loaded&&(o.call(t),n.rotate())})}function a(){i.material&&!i.loaded&&o.call(this)}var i={sphereObject:null};return{name:"iconsThreejs",urls:t&&[t],onReady:function(t,e){i.me.data(e)},onInit:function(t){i.me=t,r.call(this)},onCreate:function(){a.call(this)},data:function(t){if(!t)return i.data;if(i.valuePath){var e=i.valuePath.split(".");t.features.forEach(function(t){var n=t;e.forEach(function(t){return n=n[t]}),t.geometry.value=n})}i.data=t},scale:function(t){i.sphereObject.children.forEach(function(e){e.scale.set(t+2,t+2,1)})},sphere:function(){return i.sphereObject}}},canvasThreejs:function(t){function e(){var t=2*s,e=this._.proj.scale();l.geometry=new THREE.SphereGeometry(e,30,30),l.newCanvas=document.createElement("canvas"),l.newContext=l.newCanvas.getContext("2d"),l.texture=new THREE.Texture(l.newCanvas),l.texture.transparent=!0,l.material.map=l.texture,l.canvas=d3.select("body").append("canvas").style("position","absolute").style("display","none").style("top","450px").attr("width",t).attr("height",s).attr("id","tjs-canvas").node(),l.context=l.canvas.getContext("2d"),l.proj=d3.geoEquirectangular().scale(t/i).translate([t/2,s/2]),l.path=d3.geoPath().projection(l.proj).context(l.context),l.path2=d3.geoPath().projection(l.proj).context(l.newContext),l.newCanvas.width=l.canvas.width,l.newCanvas.height=l.canvas.height}function n(){var t=this,e=this.threejsPlugin;l.sphereObject||(r.call(this),l.sphereObject=new THREE.Mesh(l.geometry,l.material)),l.onDrawVals.forEach(function(e){e.call(t,l.newContext,l.path)}),l.texture.needsUpdate=!0,e.addGroup(l.sphereObject)}function o(){if(this._.options.choropleth){for(var t=l.countries.features.length;t--;){var e=l.countries.features[t];l.context.beginPath(),l.path(e),l.context.fillStyle=e.color||"#8f9fc1",l.context.fill()}return!0}return l.path(l.countries),l.context.fillStyle="#8f9fc1",l.context.fill(),!1}function r(){var t=this._.options;l.style.ocean?(l.context.fillStyle=l.style.ocean,l.context.fillRect(0,0,l.canvas.width,l.canvas.height)):l.context.clearRect(0,0,l.canvas.width,l.canvas.height);var e=!0;if(l.context.beginPath(),t.showBorder||(e=o.call(this)),t.showBorder||void 0===t.showBorder){var n=c(this._.proj.scale());n<1&&(n=1),e&&l.path(l.countries),l.context.lineWidth=n,l.context.strokeStyle=l.style.countries||"rgb(239, 237, 234)",l.context.stroke()}l.newContext.drawImage(l.canvas,0,0),l.refresh=!0}function a(){if(l.refresh&&this.hoverCanvas&&this._.options.showSelectedCountry){l.refresh=!1,l.newContext.clearRect(0,0,l.canvas.width,l.canvas.height),l.newContext.drawImage(l.canvas,0,0),l.selected.features.length>0&&(l.newContext.beginPath(),l.path2(l.selected),l.newContext.fillStyle=l.style.selected||"rgba(255, 235, 0, 0.4)",l.newContext.fill());var t=this.hoverCanvas.states().country;t&&!l.selected.features.find(function(e){return e.id===t.id})&&(l.newContext.beginPath(),l.path2(t),l.newContext.fillStyle=l.style.hover||"rgba(117, 0, 0, 0.4)",l.newContext.fill()),l.texture.needsUpdate=!0,this.threejsPlugin.renderThree()}}var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6.279,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2048,l={world:null,sphereObject:null,style:{},onDraw:{},onDrawVals:[],selected:{type:"FeatureCollection",features:[]},material:new THREE.MeshBasicMaterial({side:THREE.DoubleSide,alphaTest:.5})},c=d3.scaleLinear().domain([30,450]).range([10,2]);return{name:"canvasThreejs",urls:t&&[t],onReady:function(t,e){l.me.data(e)},onInit:function(t){l.me=t,e.call(this)},onCreate:function(){this.worldJson&&!l.world&&l.me.allData(this.worldJson.allData()),n.call(this)},onResize:function(){r.call(this)},onRefresh:function(){a.call(this)},onDraw:function(t){Object.assign(l.onDraw,t),l.onDrawVals=Object.keys(l.onDraw).map(function(t){return l.onDraw[t]})},selectedCountries:function(t){if(!t)return l.selected.features;l.selected.features=t},data:function(t){if(!t)return l.world;l.world=t,l.countries=topojson.feature(t,t.objects.countries)},allData:function(t){if(!t)return{world:l.world,countries:l.countries};l.world=t.world,l.countries=t.countries},style:function(t){return t&&(l.style=t),l.style},refresh:function(){l.refresh=!0,a.call(this)},sphere:function(){return l.sphereObject}}},textureThreejs:function(){function t(){var t=this._,e=t.proj.scale(),r=t.options.width,i=t.options.height;this._.options.showDrawing=!0,n=new THREE.SphereGeometry(e,30,30);var s=d3.select("body").append("canvas");s.attr("height",i).attr("width",r),o.canvas=s.node(),o.context=o.canvas.getContext("2d"),o.texture=new THREE.Texture(o.canvas),o.canvas.width=o.canvas.height=512,o.texture.needsUpdate=!0,a.map=o.texture;var l=d3.geoMercator().scale(r/2/Math.PI).translate([r/2,i/2]).precision(.5);o.path=d3.geoPath(l,o.context)}function e(){var t=this._,e=this.threejsPlugin,i=t.options.width,s=t.options.height;o.sphereObject||(o.context.fillStyle="white",o.context.fillRect(0,0,i,s),o.context.beginPath(),o.path(r),o.context.lineWidth=.4,o.context.strokeStyle="rgba(119,119,119,0.6)",o.context.stroke(),o.sphereObject=new THREE.Mesh(n,a),o.texture.needsUpdate=!1),e.addGroup(o.sphereObject)}var n,o={},r=d3.geoGraticule()(),a=new THREE.MeshBasicMaterial;return{name:"textureThreejs",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){e.call(this)},sphere:function(){return o.sphereObject}}},graticuleThreejs:function(){function t(){this._.options.showGraticule=!0,o.graticule10=e()}function e(){function t(t,e,o){var r=d3.range(t,e-n,o).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function e(t,e,o){var r=d3.range(t,e-n,o).concat(e);return function(t){return r.map(function(e){return[e,t]})}}var n=1e-6,o=t(-80,80,2.5),r=e(-180,180,2.5),a=t(-90,90,2.5),i=e(-180,180,2.5);return{type:"MultiLineString",coordinates:d3.range(90*Math.ceil(-2),180,90).map(a).concat(d3.range(360*Math.ceil(-.25),90,360).map(i)).concat(d3.range(10*Math.ceil(-18),180,10).filter(function(t){return Math.abs(t%90)>n}).map(o)).concat(d3.range(10*Math.ceil(-8),80+n,10).filter(function(t){return Math.abs(t%360)>n}).map(r))}}function n(){var t=this.threejsPlugin;if(!o.sphereObject){var e=new THREE.LineBasicMaterial({color:11184810});o.sphereObject=t.wireframe(o.graticule10,e)}t.addGroup(o.sphereObject)}var o={sphereObject:null};return{name:"graticuleThreejs",onInit:function(e){o.me=e,t.call(this)},onCreate:function(){n.call(this)},sphere:function(){return o.sphereObject}}},flightLineThreejs:function(t,e){function n(t){for(var e=0;e<y.data.length;++e){var n=y.data[e][0],i=y.data[e][1],s=y.data[e][2],l=y.data[e][3],c=y.data[e][4];if(n!==s||i!==l){for(var u=[],h=Math.random()*m+.05,d=0;d<9;d++){var f=180*d/8,p=t+Math.sin(f*b)*h,v=a(n,i,s,l,d/8),g=o(v.lat,v.lng,p);u.push(new THREE.Vector3(g.x,g.y,g.z))}for(var w=[],C=new THREE.CatmullRomCurve3(u),x=r(n,i,s,l,t),k=0;k<x;k+=T){var P=k/x;w.push(C.getPoint(P))}var H=x/(2*Math.PI)*24901;H<j&&(j=H),H>E&&(E=parseInt(1e3*Math.ceil(H/1e3)),_=E);var D=c?y.color(c):"rgb(255,255,255)",O=600*Math.random()+400,A=O*R,G=parseInt(x/T)+1,I=A*G;S+=G,M.push({spline:C,num_points:G,spd_points:I,arc_distance:x,arc_distance_miles:H,point_positions:w,default_speed:O,value:c,color:D,speed:A})}}}function o(t,e,n){var o=(90-t)*b,r=(360-e)*b;return{x:n*Math.sin(o)*Math.cos(r),y:n*Math.cos(o),z:n*Math.sin(o)*Math.sin(r)}}function r(t,e,n,o,r){var a=Math.sin((n-t)*b/2)*Math.sin((n-t)*b/2)+Math.cos(t*b)*Math.cos(n*b)*Math.sin((o-e)*b/2)*Math.sin((o-e)*b/2);return r*(2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)))}function a(t,e,n,o,r){t*=b,e*=b,n*=b,o*=b;var a=2*Math.asin(Math.sqrt(Math.pow(Math.sin((t-n)/2),2)+Math.cos(t)*Math.cos(n)*Math.pow(Math.sin((e-o)/2),2))),i=Math.sin((1-r)*a)/Math.sin(a),s=Math.sin(r*a)/Math.sin(a),l=i*Math.cos(t)*Math.cos(e)+s*Math.cos(n)*Math.cos(o),c=i*Math.cos(t)*Math.sin(e)+s*Math.cos(n)*Math.sin(o),u=i*Math.sin(t)+s*Math.sin(n);return{lat:180*Math.atan2(u,Math.sqrt(Math.pow(l,2)+Math.pow(c,2)))/Math.PI,lng:180*Math.atan2(c,l)/Math.PI}}function i(){P=new Float32Array(3*S);for(var t=new Float32Array(3*S),e=new Float32Array(S),n=new Float32Array(S),o=0,r=0;r<M.length;++r){for(var a=M[r],i=a.value,s=a.color,l=a.point_positions,c=new THREE.Color(s),u=c.r,h=c.g,d=c.b,f=y.point(i||1),p=0;p<l.length;++p)P[3*o+0]=0,P[3*o+1]=0,P[3*o+2]=0,t[3*o+0]=u,t[3*o+1]=h,t[3*o+2]=d,e[o]=i||1,n[o]=f,++o;k[r]=[]}var v=new THREE.BufferGeometry;return v.addAttribute("position",new THREE.BufferAttribute(P,3)),v.addAttribute("customColor",new THREE.BufferAttribute(t,3)),v.addAttribute("value",new THREE.BufferAttribute(e,1)),v.addAttribute("size",new THREE.BufferAttribute(n,1)),v.computeBoundingBox(),y.track_points_object=new THREE.Points(v,y.shaderMaterial),y.attr_position=y.track_points_object.geometry.attributes.position,y.track_points_object}function s(){for(var t=M.length,e=Date.now(),n=0,o=0;o<t;++o){var r=M[o],a=r.speed,i=r.spline,s=r.num_points,c=r.spd_points,u=r.arc_distance;if(r.arc_distance_miles<=_)for(var h=T/u,d=e%a/c,f=0;f<s;f++){var p=l(o,f*h+d,i),v=p.x,g=p.y,m=p.z,w=3*n;P[w+0]=v,P[w+1]=g,P[w+2]=m,n++}else for(var b=0;b<s;b++){var C=3*n;P[C+0]=1/0,P[C+1]=1/0,P[C+2]=1/0,n++}}y.attr_position.needsUpdate=!0}function l(t,e,n){var o=k[t],r=parseInt(1e3*e);return void 0===o[r]&&(o[r]=n.getPoint(e)),o[r]}function c(){for(var t=M.length,e=6*t*H,n=new THREE.BufferGeometry,o=new Float32Array(e),r=new Float32Array(e),a=0;a<t;++a)for(var i=a*H,s=M[a],l=s.spline,c=s.color,u=new THREE.Color(c),h=u.r,d=u.g,f=u.b,p=0;p<D;++p){var v=p+1,g=l.getPoint(p/D),m=l.getPoint(v/D);r[w+0]=g.x,r[w+1]=g.y,r[w+2]=g.z,r[w+3]=m.x,r[w+4]=m.y,r[w+5]=m.z;var w=6*(p+i);o[w+0]=h,o[w+1]=d,o[w+2]=f,o[w+3]=h,o[w+4]=d,o[w+5]=f}return n.addAttribute("position",new THREE.BufferAttribute(r,3)),n.addAttribute("color",new THREE.BufferAttribute(o,3)),n.computeBoundingSphere(),y.track_lines_object=new THREE.Line(n,O,THREE.LineSegments),y.track_lines_object}function u(){for(var t=M.length,e=new THREE.Group,n=w(this._.proj.scale()),o=0;o<t;++o){for(var r=M[o],a=r.spline,i=r.color,s=new Float32Array(3*H),l=new MeshLineMaterial({color:new THREE.Color(i),useMap:!1,opacity:1,lineWidth:n}),c=0;c<D;++c){var u=3*c,h=a.getPoint(c/D),d=h.x,f=h.y,p=h.z;s[u+0]=d,s[u+1]=f,s[u+2]=p}var v=new MeshLine;v.setGeometry(s),e.add(new THREE.Mesh(v.geometry,l))}return y.track_lines_object=e,y.track_lines_object}function h(){var t={color:{type:"c",value:new THREE.Color(11184810)},texture:{type:"t",value:y.texture},opacity:{type:"f",value:x}};y.shaderMaterial=new THREE.ShaderMaterial({uniforms:t,vertexShader:A,fragmentShader:G,blending:THREE.AdditiveBlending,depthTest:!0,depthWrite:!1,transparent:!0});var e=new THREE.Group;n(y.SCALE+1),e.add(window.MeshLineMaterial?u.call(this):c.call(this)),e.add(i.call(this)),e.name="flightLineThreejs",this._.domEvents&&this._.domEvents.addEventListener(y.track_lines_object,"mousemove",function(t){var e=!0,n=!1,o=void 0;try{for(var r,a=y.onHoverVals[Symbol.iterator]();!(e=(r=a.next()).done);e=!0)r.value.call(t.target,t)}catch(t){n=!0,o=t}finally{try{!e&&a.return&&a.return()}finally{if(n)throw o}}},!1),y.sphereObject=e,y.loaded=!0}function d(){y.SCALE=this._.proj.scale();var t=new THREE.LoadingManager,n=new THREE.TextureLoader(t);this._.options.showFlightLine=!0,y.texture=n.load(e,function(t){return t})}function f(){!y.texture||y.sphereObject||y.loaded||h.call(this),this.threejsPlugin.addGroup(y.sphereObject)}function p(){M=[],k=[];var t=this.threejsPlugin;h.call(this);var e=t.group(),n=e.children,o=n.findIndex(function(t){return"flightLineThreejs"===t.name});e.remove(n[o]),e.add(y.sphereObject),t.renderThree()}function v(t){t-I>30&&!this._.drag&&(I=t,s(),this.threejsPlugin.renderThree())}function g(){var t=this._.proj.scale(),e=y.resize(t),n=y.sphereObject.children[1].geometry.attributes,o=n.size,r=n.value;o.array=r.array.map(function(t){return y.point(t)*e}),o.needsUpdate=!0,window.MeshLineMaterial&&y.track_lines_object.children.forEach(function(e){e.material.uniforms.lineWidth.value=w(t),e.material.needsUpdate=!0})}var m=arguments.length>2&&void 0!==arguments[2]?arguments[2]:150,y={data:[],sphereObject:null,track_lines_object:null,track_points_object:null,lightFlow:!0,linewidth:3,texture:null,maxVal:1,onHover:{},onHoverVals:[]},w=d3.scaleLinear().domain([30,2500]).range([.001,.02]),b=Math.PI/180,C=[d3.rgb("#ff0000"),d3.rgb("#aaffff")],j=1/0,E=-1/0,_=0,T=100,x=.8,R=1,k=[],M=[],S=0,P=void 0,H=24,D=H-1,O=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,opacity:.4,transparent:!0,depthWrite:!1,depthTest:!0,color:16777215,linewidth:y.linewidth}),A="\n attribute float size;\n attribute vec3 customColor;\n varying vec3 vColor;\n\n void main() {\n vColor = customColor;\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) );\n gl_Position = projectionMatrix * mvPosition;\n }",G="\n uniform vec3 color;\n uniform sampler2D texture;\n uniform float opacity;\n\n varying vec3 vColor;\n\n void main() {\n gl_FragColor = vec4( color * vColor, opacity );\n gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );\n }",I=0;return{name:"flightLineThreejs",urls:t&&[t],onReady:function(t,e){y.me.data(e)},onInit:function(t){y.me=t,d.call(this)},onResize:function(){g.call(this)},onInterval:function(t){y.lightFlow&&v.call(this,t)},onCreate:function(){f.call(this)},onHover:function(t){Object.assign(y.onHover,t),y.onHoverVals=Object.keys(y.onHover).map(function(t){return y.onHover[t]})},reload:function(){p.call(this)},data:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[50,500],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:150,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.8;if(!t)return y.data;if(y.data=t,e){Array.isArray(e)||(e=["#ff0000","#aaffff"]);var a=d3.extent(t.map(function(t){return t[4]}));C=[d3.rgb(e[0]),d3.rgb(e[1])],y.color=d3.scaleLinear().domain(a).interpolate(d3.interpolateHcl).range(C),y.point=d3.scaleLinear().domain(a).range(n),y.maxVal=a[1]}else y.color=function(){return"rgb(255, 255, 255)"},y.point=function(){return 150},y.maxVal=1;m=o,x=r,y.resize=d3.scaleLinear().domain([30,this._.proj.scale()]).range([.1,1])},sphere:function(){return y.sphereObject},pointSize:function(t){var e=y.sphereObject.children[1].geometry.attributes.size;e.array=e.array.map(function(e){return e*t}),e.needsUpdate=!0},lightFlow:function(t){if(void 0===t)return y.lightFlow;y.lightFlow=t}}},debugThreejs:function(){function t(){this._.options.showDebugSpahre=!0}function e(){var t=this.threejsPlugin;if(!n.sphereObject){var e=this._.proj.scale();n.scale=d3.scaleLinear().domain([0,e]).range([0,1]);var o=new THREE.SphereGeometry(e,100,100),r=new THREE.MeshNormalMaterial({wireframe:!1}),a=new THREE.Mesh(o,r),i=new THREE.SphereGeometry(30,10,10),s=new THREE.SphereGeometry(30,10,10),l=new THREE.SphereGeometry(30,10,10);i.translate(0,0,e),s.translate(e,0,0),l.translate(0,-e,0);var c=new THREE.MeshBasicMaterial({color:"blue"}),u=new THREE.MeshBasicMaterial({color:"red"}),h=new THREE.MeshBasicMaterial({color:"green"}),d=new THREE.Mesh(i,c),f=new THREE.Mesh(s,u),p=new THREE.Mesh(l,h);n.sphereObject=new THREE.Object3D,n.sphereObject.add(a,d,f,p)}t.addGroup(n.sphereObject)}var n={sphereObject:null,scale:null};return{name:"debugThreejs",onInit:function(e){n.me=e,t.call(this)},onCreate:function(){e.call(this)},sphere:function(){return n.sphereObject}}},oceanThreejs:function(t){function e(){this._.options.transparentOcean=!1}function n(){var e=this.threejsPlugin;if(!r.sphereObject){var n=this._.proj.scale(),a=new THREE.SphereGeometry(n,30,30);if(t){var i=new THREE.AmbientLight(o),s=new THREE.Mesh(a,r.material);r.sphereObject=new THREE.Group,r.sphereObject.add(i),r.sphereObject.add(s)}else r.sphereObject=new THREE.Mesh(a,r.material)}e.addGroup(r.sphereObject)}var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:11184810,r={sphereObject:null};return r.material=t?new THREE.MeshPhongMaterial({color:t}):new THREE.MeshNormalMaterial({transparent:!1,wireframe:!1,opacity:.8}),{name:"oceanThreejs",onInit:function(t){r.me=t,e.call(this)},onCreate:function(){n.call(this)},sphere:function(){return r.sphereObject}}},imageThreejs:function(){function t(){var t=this.threejsPlugin;if(n.sphereObject)t.addGroup(n.sphereObject);else{var o=this._.proj.scale();(new THREE.TextureLoader).load(e,function(e){var r=new THREE.SphereGeometry(o,30,30),a=new THREE.MeshBasicMaterial({map:e});n.sphereObject=new THREE.Mesh(r,a),t.addGroup(n.sphereObject)})}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world.png",n={sphereObject:null};return{name:"imageThreejs",onInit:function(t){n.me=t,this._.options.showImage=!0},onCreate:function(){t.call(this)},sphere:function(){return n.sphereObject}}},worldThreejs:function(){function t(){var t=this.threejsPlugin;if(!n.sphereObject){var e=topojson.mesh(n.world,n.world.objects.countries),o=new THREE.MeshBasicMaterial({color:7368816});n.sphereObject=t.wireframe(e,o)}t.addGroup(n.sphereObject)}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world.png",n={world:null,land:null,lakes:{type:"FeatureCollection",features:[]},selected:{type:"FeatureCollection",features:[]},countries:{type:"FeatureCollection",features:[]}};return{name:"worldThreejs",urls:e&&[e],onReady:function(t,e){n.me.data(e)},onInit:function(t){n.me=t,this._.options.showLand=!0},onCreate:function(){t.call(this)},data:function(t){if(!t)return n.world;n.world=t,n.land=topojson.feature(t,t.objects.land),n.lakes.features=topojson.feature(t,t.objects.ne_110m_lakes).features,n.countries.features=topojson.feature(t,t.objects.countries).features},sphere:function(){return n.sphereObject}}},globeThreejs:function(){function t(){this._.options.showGlobe=!0}function e(){var t=this.threejsPlugin;if(a.sphereObject)t.addGroup(a.sphereObject);else{var e=this._.proj.scale(),i=s.load(n,function(t){return t}),l=s.load(o,function(t){return t}),c=s.load(r,function(t){return t}),u=new THREE.SphereGeometry(e,30,30),h=new THREE.MeshPhongMaterial({map:i,bumpMap:l,bumpScale:.01,specularMap:c,specular:new THREE.Color("grey")});a.sphereObject=new THREE.Mesh(u,h),this._.domEvents&&this._.domEvents.addEventListener(a.sphereObject,"mousemove",function(t){var e=!0,n=!1,o=void 0;try{for(var r,i=a.onHoverVals[Symbol.iterator]();!(e=(r=i.next()).done);e=!0)r.value.call(t.target,t)}catch(t){n=!0,o=t}finally{try{!e&&i.return&&i.return()}finally{if(n)throw o}}},!1);var d=new THREE.AmbientLight(7829367),f=new THREE.DirectionalLight(16777215,.2),p=new THREE.DirectionalLight(16777215,.2);f.position.set(5,3,6),p.position.set(5,3,-6),t.addGroup(d),t.addGroup(f),t.addGroup(p),t.addGroup(a.sphereObject)}}var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world.jpg",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"../d/elevation.jpg",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"../d/water.png",a={sphereObject:null,onHover:{},onHoverVals:[]},i=new THREE.LoadingManager,s=new THREE.TextureLoader(i);return{name:"globeThreejs",onInit:function(e){a.me=e,t.call(this)},onCreate:function(){e.call(this)},onHover:function(t){Object.assign(a.onHover,t),a.onHoverVals=Object.keys(a.onHover).map(function(t){return a.onHover[t]})},sphere:function(){return a.sphereObject}}},sphereThreejs:function(){function t(){var t=this.threejsPlugin;if(n.sphereObject)t.addGroup(n.sphereObject);else{var o=this._.proj.scale(),i=new THREE.SphereGeometry(o,30,30),s=THREE.UniformsUtils.clone(a.earth.uniforms),l=THREE.UniformsUtils.clone(a.atmosphere.uniforms);s.texture.value=r.load(e,function(t){return t});var c=new THREE.Mesh(i,new THREE.ShaderMaterial({uniforms:s,vertexShader:a.earth.vertexShader,fragmentShader:a.earth.fragmentShader})),u=new THREE.Mesh(i,new THREE.ShaderMaterial({uniforms:l,vertexShader:a.atmosphere.vertexShader,fragmentShader:a.atmosphere.fragmentShader,side:THREE.BackSide,blending:THREE.AdditiveBlending,transparent:!0})),h=new THREE.Group;h.add(c),h.add(u),n.sphereObject=h,t.addGroup(n.sphereObject),t.rotate()}}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world.png",n={sphereObject:null},o=new THREE.LoadingManager,r=new THREE.TextureLoader(o),a={earth:{uniforms:{texture:{type:"t",value:null}},vertexShader:["varying vec3 vNormal;","varying vec2 vUv;","void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","vNormal = normalize( normalMatrix * normal );","vUv = uv;","}"].join("\n"),fragmentShader:["uniform sampler2D texture;","varying vec3 vNormal;","varying vec2 vUv;","void main() {","vec3 diffuse = texture2D( texture, vUv ).xyz;","float intensity = 1.05 - dot( vNormal, vec3( 0.0, 0.0, 1.0 ) );","vec3 atmosphere = vec3( 1.0, 1.0, 1.0 ) * pow( intensity, 3.0 );","gl_FragColor = vec4( diffuse + atmosphere, 1.0 );","}"].join("\n")},atmosphere:{uniforms:{},vertexShader:["varying vec3 vNormal;","void main() {","vNormal = normalize( normalMatrix * normal );","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["varying vec3 vNormal;","void main() {","float intensity = pow( 0.8 - dot( vNormal, vec3( 0, 0, 1.0 ) ), 12.0 );","gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 ) * intensity;","}"].join("\n")}};return{name:"sphereThreejs",onInit:function(t){n.me=t,this._.options.showSphere=!0},onCreate:function(){t.call(this)},sphere:function(){return n.sphereObject},imgSrc:function(t){var e=n.me.sphere().children[0].material;e.uniforms.texture.value=r.load(t,function(t){return t}),e.needsUpdate=!0}}},world3d:function(){function e(){var e=l.world;for(var n in e){var o=new t(e[n],.9);l.sphereObject.add(e[n].mesh=new THREE.Mesh(o,l.material))}l.loaded=!0}function n(){this._.options.showWorld=!0,l.sphereObject.rotation.y=s,l.sphereObject.scale.set(205,205,205),r(i,function(t){l.material=t,l.world&&!l.loaded&&e()})}function o(){l.material&&!l.loaded&&e(),this.threejsPlugin.addGroup(l.sphereObject)}function r(t,e){(new THREE.TextureLoader).load(t,function(t){var n={tMatCap:{type:"t",value:t}},o=new THREE.ShaderMaterial({uniforms:n,vertexShader:c,fragmentShader:u,shading:THREE.SmoothShading});e.call(this,o)})}var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world_geometry.json",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"../d/gold.jpg",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1.57,l={sphereObject:new THREE.Object3D},c="\n varying vec2 vN;\n void main() {\n vec4 p = vec4( position, 1. );\n vec3 e = normalize( vec3( modelViewMatrix * p ) );\n vec3 n = normalize( normalMatrix * normal );\n vec3 r = reflect( e, n );\n float m = 2. * length( vec3( r.xy, r.z + 1. ) );\n vN = r.xy / m + .5;\n gl_Position = projectionMatrix * modelViewMatrix * p;\n }\n ",u="\n uniform sampler2D tMatCap;\n varying vec2 vN;\n void main() {\n vec3 base = texture2D( tMatCap, vN ).rgb;\n gl_FragColor = vec4( base, 1. );\n }\n ";return{name:"world3d",urls:a&&[a],onReady:function(t,e){l.me.data(e)},onInit:function(t){l.me=t,n.call(this)},onCreate:function(){o.call(this)},rotate:function(t){l.sphereObject.rotation.y=t},data:function(t){if(!t)return l.world;l.world=t},sphere:function(){return l.sphereObject}}},world3d2:function(){function t(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.9,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=t.vertices.length/2;t.vertices.forEach(function(t,r){var a=e;r>=o&&(a=1+n);var i=.017453292519943295*(90-t.oy),s=.017453292519943295*(360-t.ox);t.x=a*Math.sin(i)*Math.cos(s),t.y=a*Math.cos(i),t.z=a*Math.sin(i)*Math.sin(s)}),t.verticesNeedUpdate=!0,t.computeFaceNormals()}function e(e){var n=new THREE.Shape(e),o=new THREE.ExtrudeGeometry(n,{bevelEnabled:!1,amount:16});return o.vertices.forEach(function(t){t.ox=t.x,t.oy=t.y,t.oz=t.z}),t(o,c,u),new THREE.Mesh(o,d.material)}function n(t,n){var o=t.id,r=[],a=d.group[o];void 0===a&&((a=new THREE.Group).name=o,d.group[o]=a,d.sphereObject.add(a)),n.forEach(function(t){r.push(new THREE.Vector2(t[0],t[1]))}),a.add(e(r))}function o(){d.world.features.forEach(function(t){var e=t.geometry.coordinates;1===e.length?n(t,e[0]):e.forEach(function(e){1==e.length?n(t,e[0]):n(t,e)})})}function r(){var t=this._.proj.scale();this._.options.showWorld=!0,d.sphereObject.rotation.y=h,d.sphereObject.scale.set(t,t,t),i(l,function(t){d.material=t,d.world&&!d.loaded&&o()})}function a(){d.material&&!d.loaded&&o(),this.threejsPlugin.addGroup(d.sphereObject)}function i(t,e){(new THREE.TextureLoader).load(t,function(t){var n={tMatCap:{type:"t",value:t}},o=new THREE.ShaderMaterial({uniforms:n,vertexShader:f,fragmentShader:p,shading:THREE.SmoothShading});e.call(this,o)})}var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/countries.geo.json",l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"../d/gold.jpg",c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.9,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,h=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,d={sphereObject:new THREE.Object3D,group:{}},f="\n varying vec2 vN;\n void main() {\n vec4 p = vec4( position, 1. );\n vec3 e = normalize( vec3( modelViewMatrix * p ) );\n vec3 n = normalize( normalMatrix * normal );\n vec3 r = reflect( e, n );\n float m = 2. * length( vec3( r.xy, r.z + 1. ) );\n vN = r.xy / m + .5;\n gl_Position = projectionMatrix * modelViewMatrix * p;\n }\n ",p="\n uniform sampler2D tMatCap;\n varying vec2 vN;\n void main() {\n vec3 base = texture2D( tMatCap, vN ).rgb;\n gl_FragColor = vec4( base, 1. );\n }\n ";return{name:"world3d2",urls:s&&[s],onReady:function(t,e){d.me.data(e)},onInit:function(t){d.me=t,r.call(this)},onCreate:function(){a.call(this)},rotate:function(t){d.sphereObject.rotation.y=t},data:function(t){if(!t)return d.world;d.world=t},sphere:function(){return d.sphereObject},group:function(){return d.group},extrude:function(e,n,o){d.group[e]&&d.group[e].children.forEach(function(e){t(e.geometry,n,o)})}}},commonPlugins:function(t){function e(){var e=this,n=this.register,o=earthjs.plugins;n(o.mousePlugin()),n(o.configPlugin()),n(o.autorotatePlugin()),n(o.dropShadowSvg()),n(o.oceanSvg()),n(o.canvasPlugin()),n(o.graticuleCanvas()),n(o.worldCanvas(t)),this._.options.transparent=!0,this.canvasPlugin.selectAll(".ej-canvas"),this.graticuleCanvas.drawTo([1]),this.worldCanvas.drawTo([0]),r.options=this.configPlugin.set(),r.buttonClick=function(t){var n=t.split(":")[2],o={},r=e.configPlugin.set();r[n]=!r[n],o[n]=r[n],"transparent"==n?((r.transparentGraticule||r.transparentLand)&&(o.transparent=!1),o.transparentGraticule=!1,o.transparentLand=!1):"showCountries"==n||"showLakes"==n?o.showLand=!0:"transparentGraticule"!=n&&"transparentLand"!=n||(r.transparent&&(o.transparentGraticule=!1,o.transparentLand=!1),o.transparent=!1),e.configPlugin.set(o)}}function n(t,e,n,o,r,a,i){t.append("br"),t.append("input").attr("id",e).attr("type","range").attr("min",n).attr("max",o).attr("step",r).attr("value",a).on("input",i)}function o(){var t=this,e=this,o=d3.select(".set-options"),a=d3.select(".set-options2");if(o.selectAll("button, input, br").remove(),a.selectAll("button, input, br").remove(),this._.options.showControll){o.selectAll("button").data(r.checker).enter().append("button").text(function(t){return t[1]}).on("click",function(e){return r.buttonClick.call(t,e.join(":"))}),n(a,"pan",0,400,1,r.pan,function(){r.pan=+this.value;for(var t=1;t<i.length;t++)i[t].style.left=r.pan*t+"px"}),n(a,"ocn",0,20,1,r.ocn,function(){r.ocn=this.value,e.oceanSvg.scale(-r.ocn)}),n(a,"spd",10,200,10,r.spd,function(){r.spd=this.value,e.autorotatePlugin.speed(r.spd)});var i=d3.selectAll(".ea-layer").nodes()}}var r={checker:[],ocn:0,spd:10,pan:0,clr:0};return r.checker=[":Shadow:showDropShadow",":Ocean:showOcean",":Graticule:showGraticule",":Land:showLand",":Country:showCountries",":Lakes:showLakes",":Transparent:transparent",":Canvas:showCanvas",":Spin:spin"].map(function(t){return t.split(":")}),{name:"commonPlugins",onInit:function(t){r.me=t,e.call(this),this._.options.showControll=!0},onCreate:function(){o.call(this)},addChecker:function(t){r.checker.push(t),r.options=this.configPlugin.set(),o.call(this)}}},selectCountryMix:function(){function t(){var t=this.register(earthjs.plugins.mousePlugin()).register(earthjs.plugins.hoverCanvas()).register(earthjs.plugins.clickCanvas()).register(earthjs.plugins.centerCanvas()).register(earthjs.plugins.canvasPlugin()).register(earthjs.plugins.countryCanvas()).register(earthjs.plugins.autorotatePlugin()).register(earthjs.plugins.worldCanvas(e)).register(earthjs.plugins.threejsPlugin());t.canvasPlugin.selectAll(".ej-canvas"),t._.options.showSelectedCountry=!0,t._.options.showBorder=!1,t.worldCanvas.style({countries:"rgba(220,91,52,0.2)"}),t.worldCanvas.ready=function(e,n){t.countryCanvas.data(n),t.worldCanvas.data(n),t.hoverCanvas.data(n),t.clickCanvas.data(n)},t.centerCanvas.focused(function(e,n){if(t.autorotatePlugin.stop(),e.metaKey){var o=t.worldCanvas.selectedCountries().concat(n);t.worldCanvas.selectedCountries(o)}else t.worldCanvas.selectedCountries([n]);console.log(n)})}var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"../d/world-110m.json",n={};return{name:"selectCountryMix",onInit:function(e){n.me=e,t.call(this)},region:function(t,e){var n=this,o=n.worldCanvas.countries().filter(function(e){return t.indexOf(e.id)>-1});n.worldCanvas.selectedCountries(o),n.autorotatePlugin.stop(),e&&n.centerCanvas.go(e)},multiRegion:function(t,e){var n=[],o=this,r=!0,a=!1,i=void 0;try{for(var s,l=t[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var c=s.value,u=o.worldCanvas.countries().filter(function(t){var e=c.countries.indexOf(t.id)>-1;return e&&(t.color=c.color),e});n=n.concat(u)}}catch(t){a=!0,i=t}finally{try{!r&&l.return&&l.return()}finally{if(a)throw i}}o.worldCanvas.selectedCountries(n,!0),o.autorotatePlugin.stop(),e&&o.centerCanvas.go(e)}}}},n}();