// https://github.com/topojson/topojson-client Version 2.1.0. Copyright 2016 Mike Bostock. !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.topojson=n.topojson||{})}(this,function(n){"use strict";function t(n,t){var e=t.id,o=t.bbox,a=null==t.properties?{}:t.properties,c=r(n,t);return null==e&&null==o?{type:"Feature",properties:a,geometry:c}:null==o?{type:"Feature",id:e,properties:a,geometry:c}:{type:"Feature",id:e,bbox:o,properties:a,geometry:c}}function r(n,t){function r(n,t){t.length&&t.pop();for(var r=l[n<0?~n:n],e=0,o=r.length;e1)e=o(n,t,r);else for(a=0,e=new Array(c=n.arcs.length);a1)for(var o,a,u=1,f=c(e[0]);uf&&(a=e[0],e[0]=e[u],e[u]=a,f=o);return e})}}var i=function(n){return n},u=function(n){if(null==(t=n.transform))return i;var t,r,e,o=t.scale[0],a=t.scale[1],c=t.translate[0],u=t.translate[1];return function(n,t){return t||(r=e=0),n[0]=(r+=n[0])*o+c,n[1]=(e+=n[1])*a+u,n}},f=function(n){function t(n){i[0]=n[0],i[1]=n[1],c(i),i[0]l&&(l=i[0]),i[1]h&&(h=i[1])}function r(n){switch(n.type){case"GeometryCollection":n.geometries.forEach(r);break;case"Point":t(n.coordinates);break;case"MultiPoint":n.coordinates.forEach(t)}}var e=n.bbox;if(!e){var o,a,c=u(n),i=new Array(2),f=1/0,s=f,l=-f,h=-f;n.arcs.forEach(function(n){for(var t=-1,r=n.length;++tl&&(l=i[0]),i[1]h&&(h=i[1])});for(a in n.objects)r(n.objects[a]);e=n.bbox=[f,s,l,h]}return e},s=function(n,t){for(var r,e=n.length,o=e-t;o<--e;)r=n[o],n[o++]=n[e],n[e]=r},l=function(n,r){return"GeometryCollection"===r.type?{type:"FeatureCollection",features:r.geometries.map(function(r){return t(n,r)})}:t(n,r)},h=function(n,t){function r(t){var r,e=n.arcs[t<0?~t:t],o=e[0];return n.transform?(r=[0,0],e.forEach(function(n){r[0]+=n[0],r[1]+=n[1]})):r=e[e.length-1],t<0?[r,o]:[o,r]}function e(n,t){for(var r in n){var e=n[r];delete t[e.start],delete e.start,delete e.end,e.forEach(function(n){o[n<0?~n:n]=1}),i.push(e)}}var o={},a={},c={},i=[],u=-1;return t.forEach(function(r,e){var o,a=n.arcs[r<0?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(o=t[++u],t[u]=r,t[e]=o)}),t.forEach(function(n){var t,e,o=r(n),i=o[0],u=o[1];if(t=c[i])if(delete c[t.end],t.push(n),t.end=u,e=a[u]){delete a[e.start];var f=e===t?t:t.concat(e);a[f.start=t.start]=c[f.end=e.end]=f}else a[t.start]=c[t.end]=t;else if(t=a[u])if(delete a[t.start],t.unshift(n),t.start=i,e=c[i]){delete c[e.end];var s=e===t?t:e.concat(t);a[s.start=e.start]=c[s.end=t.end]=s}else a[t.start]=c[t.end]=t;else t=[n],a[t.start=i]=c[t.end=u]=t}),e(c,a),e(a,c),t.forEach(function(n){o[n<0?~n:n]||i.push([n])}),i},p=function(n){return r(n,e.apply(this,arguments))},g=function(n){return r(n,c.apply(this,arguments))},d=function(n,t){for(var r=0,e=n.length;r>>1;n[o]=2))throw new Error("n must be ≥2");if(n.transform)throw new Error("already quantized");var o,a=f(n),c=a[0],i=(a[2]-c)/(t-1)||1,u=a[1],s=(a[3]-u)/(t-1)||1;n.arcs.forEach(function(n){for(var t,r,e,o=1,a=1,f=n.length,l=n[0],h=l[0]=Math.round((l[0]-c)/i),p=l[1]=Math.round((l[1]-u)/s);o