function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _assert_this_initialized(self) {
    if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }
    return self;
}
function _call_super(_this, derived, args) {
    derived = _get_prototype_of(derived);
    return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
    }
}
function _defineProperties(target, props) {
    for(var i = 0; i < props.length; i++){
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
    }
}
function _create_class(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
}
function _get(target, property, receiver) {
    if (typeof Reflect !== "undefined" && Reflect.get) {
        _get = Reflect.get;
    } else {
        _get = function get(target, property, receiver) {
            var base = _super_prop_base(target, property);
            if (!base) return;
            var desc = Object.getOwnPropertyDescriptor(base, property);
            if (desc.get) {
                return desc.get.call(receiver || target);
            }
            return desc.value;
        };
    }
    return _get(target, property, receiver || target);
}
function _get_prototype_of(o) {
    _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
    };
    return _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
    if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
    }
    subClass.prototype = Object.create(superClass && superClass.prototype, {
        constructor: {
            value: subClass,
            writable: true,
            configurable: true
        }
    });
    if (superClass) _set_prototype_of(subClass, superClass);
}
function _instanceof(left, right) {
    "@swc/helpers - instanceof";
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _possible_constructor_return(self, call) {
    if (call && (_type_of(call) === "object" || typeof call === "function")) {
        return call;
    }
    return _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
    _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
        o.__proto__ = p;
        return o;
    };
    return _set_prototype_of(o, p);
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _super_prop_base(object, property) {
    while(!Object.prototype.hasOwnProperty.call(object, property)){
        object = _get_prototype_of(object);
        if (object === null) break;
    }
    return object;
}
function _type_of(obj) {
    "@swc/helpers - typeof";
    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function _is_native_reflect_construct() {
    try {
        var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
    } catch (_) {}
    return (_is_native_reflect_construct = function() {
        return !!result;
    })();
}
import { extent, max, quantile } from "d3-array";
import { color } from "d3-color";
import { zoomTransform } from "d3-zoom";
import * as d3GeoCore from "d3-geo";
import * as d3GeoProjection from "d3-geo-projection";
import * as d3CompositeProjections from "d3-composite-projections";
var d3Geo = Object.assign({}, d3GeoCore, d3GeoProjection, d3CompositeProjections);
import * as scales from "d3-scale";
import { tile } from "d3-tile";
import { feature } from "topojson-client";
import { addToQueue } from "@d3plus/data";
import { assign, parseSides } from "@d3plus/dom";
import { pointDistance } from "@d3plus/math";
import { Circle, Path } from "../shapes/index.js";
import { accessor, configPrep, constant } from "../utils/index.js";
import Viz from "./Viz.js";
import attributions from "./helpers/tileAttributions.js";
/**
 * @name findAttribution
 * @param {String} url
 * @private
 */ function findAttribution(url) {
    var a = attributions.find(function(d) {
        return d.matches.some(function(m) {
            return url.includes(m);
        });
    });
    return a ? a.text : false;
}
/**
    @name topo2feature
    Converts a specific topojson object key into a feature ready for projection.
    @param topo A valid topojson json object.
    @param key The topojson object key to be used. If undefined, the first key available will be used.
    @private
*/ function topo2feature(topo, key) {
    var k = key && topo.objects[key] ? key : Object.keys(topo.objects)[0];
    return feature(topo, k);
}
var Geomap = /*#__PURE__*/ function(Viz) {
    "use strict";
    _inherits(Geomap, Viz);
    function Geomap() {
        _class_call_check(this, Geomap);
        var _this;
        _this = _call_super(this, Geomap);
        _this._fitObject = false;
        _this._noDataMessage = false;
        _this._ocean = "#d4dadc";
        _this._point = accessor("point");
        _this._pointSize = constant(1);
        _this._pointSizeMax = 10;
        _this._pointSizeMin = 5;
        _this._pointSizeScale = "linear";
        _this._projection = d3Geo.geoMercator();
        _this._projectionPadding = parseSides(20);
        _this._shape = constant("Circle");
        _this._shapeConfig = assign(_this._shapeConfig, {
            ariaLabel: function ariaLabel(d, i) {
                return "".concat(_this._drawLabel(d, i), ", ").concat(_this._pointSize(d, i));
            },
            hoverOpacity: 1,
            Path: {
                ariaLabel: function ariaLabel(d, i) {
                    var validColorScale = _this._colorScale ? ", ".concat(_this._colorScale(d, i)) : "";
                    return "".concat(_this._drawLabel(d, i)).concat(validColorScale, ".");
                },
                fill: function fill(d, i) {
                    if (_this._colorScale && !_this._coordData.features.includes(d)) {
                        var c = _this._colorScale(d);
                        if (c !== undefined && c !== null) {
                            if (_this._colorScaleClass._colorScale) {
                                return _this._colorScaleClass._colorScale(c);
                            } else {
                                var color = _this._colorScaleClass.color();
                                if (_instanceof(color, Array)) color = color[color.length - 1];
                                return color;
                            }
                        }
                    }
                    return _this._topojsonFill(d, i);
                },
                on: {
                    mouseenter: function mouseenter(d, i, x, event) {
                        return !_this._coordData.features.includes(d) ? _this._on.mouseenter.bind(_this)(d, i, x, event) : null;
                    },
                    "mousemove.shape": function(d, i, x, event) {
                        return !_this._coordData.features.includes(d) ? _this._on["mousemove.shape"].bind(_this)(d, i, x, event) : null;
                    },
                    mouseleave: function mouseleave(d, i, x, event) {
                        return !_this._coordData.features.includes(d) ? _this._on.mouseleave.bind(_this)(d, i, x, event) : null;
                    }
                },
                stroke: function stroke(d, i) {
                    var c = typeof _this._shapeConfig.Path.fill === "function" ? _this._shapeConfig.Path.fill(d, i) : _this._shapeConfig.Path.fill;
                    return color(c).darker();
                },
                strokeWidth: 1
            }
        });
        _this._tiles = true;
        _this._tileGen = tile();
        _this.tileUrl("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png");
        _this._topojson = false;
        _this._topojsonFill = constant("#f5f5f3");
        _this._topojsonFilter = function(d) {
            return ![
                "010"
            ].includes(d.id);
        };
        _this._topojsonId = accessor("id");
        _this._zoom = true;
        _this._zoomSet = false;
        return _this;
    }
    _create_class(Geomap, [
        {
            /**
      Renders map tiles based on the current zoom level.
      @private
  */ key: "_renderTiles",
            value: function _renderTiles() {
                var _this = this;
                var transform = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : zoomTransform(this._container.node()), duration = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
                var tileData = [];
                if (this._tiles) {
                    tileData = this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this._projection.scale() * (2 * Math.PI) * transform.k).translate(transform.apply(this._projection.translate()))();
                    this._tileGroup.transition().duration(duration).attr("transform", transform);
                }
                var images = this._tileGroup.selectAll("image.d3plus-geomap-tile").data(tileData, function(param) {
                    var _param = _sliced_to_array(param, 3), x = _param[0], y = _param[1], z = _param[2];
                    return "".concat(x, "-").concat(y, "-").concat(z);
                });
                images.exit().transition().duration(duration).attr("opacity", 0).remove();
                var scale = tileData.scale / transform.k;
                var tileEnter = images.enter().append("image").attr("class", "d3plus-geomap-tile");
                tileEnter.attr("opacity", 0).transition().duration(duration).attr("opacity", 1);
                images.merge(tileEnter).attr("width", scale).attr("height", scale).attr("xlink:href", function(param) {
                    var _param = _sliced_to_array(param, 3), x = _param[0], y = _param[1], z = _param[2];
                    return _this._tileUrl.replace("{s}", [
                        "a",
                        "b",
                        "c"
                    ][Math.random() * 3 | 0]).replace("{z}", "".concat(z)).replace("{x}", "".concat(x)).replace("{y}", "".concat(y));
                }).attr("x", function(param) {
                    var _param = _sliced_to_array(param, 1), x = _param[0];
                    return x * scale + tileData.translate[0] * scale - transform.x / transform.k;
                }).attr("y", function(param) {
                    var _param = _sliced_to_array(param, 2), y = _param[1];
                    return y * scale + tileData.translate[1] * scale - transform.y / transform.k;
                });
            }
        },
        {
            /**
      Extends the draw behavior of the abstract Viz class.
      @private
  */ key: "_draw",
            value: function _draw(callback) {
                var _this = this;
                _get(_get_prototype_of(Geomap.prototype), "_draw", this).call(this, callback);
                var height = this._height - this._margin.top - this._margin.bottom, width = this._width - this._margin.left - this._margin.right;
                this._container = this._select.selectAll("svg.d3plus-geomap").data([
                    0
                ]);
                this._container = this._container.enter().append("svg").attr("class", "d3plus-geomap").attr("opacity", 0).attr("width", width).attr("height", height).attr("x", this._margin.left).attr("y", this._margin.top).style("background-color", this._ocean || "transparent").merge(this._container);
                this._container.transition(this._transition).attr("opacity", 1).attr("width", width).attr("height", height).attr("x", this._margin.left).attr("y", this._margin.top);
                var ocean = this._container.selectAll("rect.d3plus-geomap-ocean").data([
                    0
                ]);
                ocean.enter().append("rect").attr("class", "d3plus-geomap-ocean").merge(ocean).attr("width", width).attr("height", height).attr("fill", this._ocean || "transparent");
                this._tileGroup = this._container.selectAll("g.d3plus-geomap-tileGroup").data([
                    0
                ]);
                this._tileGroup = this._tileGroup.enter().append("g").attr("class", "d3plus-geomap-tileGroup").merge(this._tileGroup);
                this._zoomGroup = this._container.selectAll("g.d3plus-geomap-zoomGroup").data([
                    0
                ]);
                this._zoomGroup = this._zoomGroup.enter().append("g").attr("class", "d3plus-geomap-zoomGroup").merge(this._zoomGroup);
                var pathGroup = this._zoomGroup.selectAll("g.d3plus-geomap-paths").data([
                    0
                ]);
                pathGroup = pathGroup.enter().append("g").attr("class", "d3plus-geomap-paths").merge(pathGroup);
                var coordData = this._coordData = this._topojson ? topo2feature(this._topojson, this._topojsonKey) : {
                    type: "FeatureCollection",
                    features: []
                };
                if (this._topojsonFilter) coordData.features = coordData.features.filter(this._topojsonFilter);
                var path = this._path = d3Geo.geoPath().projection(this._projection);
                var pointData = this._filteredData.filter(function(d, i) {
                    return _instanceof(_this._point(d, i), Array);
                });
                var pathData = this._filteredData.filter(function(d, i) {
                    return !_instanceof(_this._point(d, i), Array);
                }).reduce(function(obj, d) {
                    obj[_this._id(d)] = d;
                    return obj;
                }, {});
                var topoData = coordData.features.reduce(function(arr, feature) {
                    var id = _this._topojsonId(feature);
                    arr.push({
                        __d3plus__: true,
                        data: pathData[id],
                        feature: feature,
                        id: id
                    });
                    return arr;
                }, []);
                var scaleName = "scale".concat(this._pointSizeScale.charAt(0).toUpperCase()).concat(this._pointSizeScale.slice(1));
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                var r = scales[scaleName]().domain(extent(pointData, function(d, i) {
                    return _this._pointSize(d, i);
                })).range([
                    this._pointSizeMin,
                    this._pointSizeMax
                ]);
                if (!this._zoomSet) {
                    var fitData = this._fitObject ? topo2feature(this._fitObject, this._fitKey) : coordData;
                    this._extentBounds = {
                        type: "FeatureCollection",
                        features: this._fitFilter ? fitData.features.filter(this._fitFilter) : fitData.features.slice()
                    };
                    this._extentBounds.features = this._extentBounds.features.reduce(function(arr, d) {
                        if (d.geometry) {
                            var reduced = {
                                type: d.type,
                                id: d.id,
                                geometry: {
                                    coordinates: d.geometry.coordinates,
                                    type: d.geometry.type
                                }
                            };
                            if (d.geometry.type === "MultiPolygon" && d.geometry.coordinates.length > 1) {
                                var areas = [], distances = [];
                                d.geometry.coordinates.forEach(function(c) {
                                    reduced.geometry.coordinates = [
                                        c
                                    ];
                                    areas.push(path.area(reduced));
                                });
                                reduced.geometry.coordinates = [
                                    d.geometry.coordinates[areas.indexOf(max(areas))]
                                ];
                                var center = path.centroid(reduced);
                                d.geometry.coordinates.forEach(function(c) {
                                    reduced.geometry.coordinates = [
                                        c
                                    ];
                                    distances.push(pointDistance(path.centroid(reduced), center));
                                });
                                var distCutoff = quantile(areas.reduce(function(arr, dist, i) {
                                    if (dist) arr.push(areas[i] / dist);
                                    return arr;
                                }, []), 0.9);
                                reduced.geometry.coordinates = d.geometry.coordinates.filter(function(c, i) {
                                    var dist = distances[i];
                                    return dist === 0 || areas[i] / dist >= distCutoff;
                                });
                            }
                            arr.push(reduced);
                        }
                        return arr;
                    }, []);
                    if (!this._extentBounds.features.length && pointData.length) {
                        var bounds = [
                            [
                                undefined,
                                undefined
                            ],
                            [
                                undefined,
                                undefined
                            ]
                        ];
                        pointData.forEach(function(d, i) {
                            var point = _this._projection(_this._point(d, i));
                            if (bounds[0][0] === void 0 || point[0] < bounds[0][0]) bounds[0][0] = point[0];
                            if (bounds[1][0] === void 0 || point[0] > bounds[1][0]) bounds[1][0] = point[0];
                            if (bounds[0][1] === void 0 || point[1] < bounds[0][1]) bounds[0][1] = point[1];
                            if (bounds[1][1] === void 0 || point[1] > bounds[1][1]) bounds[1][1] = point[1];
                        });
                        this._extentBounds = {
                            type: "FeatureCollection",
                            features: [
                                {
                                    type: "Feature",
                                    geometry: {
                                        type: "MultiPoint",
                                        coordinates: bounds.map(function(b) {
                                            return _this._projection.invert(b);
                                        })
                                    }
                                }
                            ]
                        };
                        var maxSize = max(pointData, function(d, i) {
                            return r(_this._pointSize(d, i));
                        });
                        this._projectionPadding.top += maxSize;
                        this._projectionPadding.right += maxSize;
                        this._projectionPadding.bottom += maxSize;
                        this._projectionPadding.left += maxSize;
                    }
                    this._zoomBehavior.extent([
                        [
                            0,
                            0
                        ],
                        [
                            width,
                            height
                        ]
                    ]).scaleExtent([
                        1,
                        this._zoomMax
                    ]).translateExtent([
                        [
                            0,
                            0
                        ],
                        [
                            width,
                            height
                        ]
                    ]);
                    this._zoomSet = true;
                }
                this._projection = this._projection.fitExtent(this._extentBounds.features.length ? [
                    [
                        this._projectionPadding.left,
                        this._projectionPadding.top
                    ],
                    [
                        width - this._projectionPadding.right,
                        height - this._projectionPadding.bottom
                    ]
                ] : [
                    [
                        0,
                        0
                    ],
                    [
                        width,
                        height
                    ]
                ], this._extentBounds.features.length ? this._extentBounds : {
                    type: "Sphere"
                });
                this._shapes.push(new Path().data(topoData).d(function(d) {
                    return path(d.feature);
                }).select(pathGroup.node()).x(0).y(0).config(configPrep.bind(this)(this._shapeConfig, "shape", "Path")).render());
                var pointGroup = this._zoomGroup.selectAll("g.d3plus-geomap-pins").data([
                    0
                ]);
                pointGroup = pointGroup.enter().append("g").attr("class", "d3plus-geomap-pins").merge(pointGroup);
                var circles = new Circle().config(configPrep.bind(this)(this._shapeConfig, "shape", "Circle")).data(pointData).r(function(d, i) {
                    return r(_this._pointSize(d, i));
                }).select(pointGroup.node()).sort(function(a, b) {
                    return _this._pointSize(b) - _this._pointSize(a);
                }).x(function(d, i) {
                    return _this._projection(_this._point(d, i))[0];
                }).y(function(d, i) {
                    return _this._projection(_this._point(d, i))[1];
                });
                var events = Object.keys(this._on);
                var classEvents = events.filter(function(e) {
                    return e.includes(".Circle");
                }), globalEvents = events.filter(function(e) {
                    return !e.includes(".");
                }), shapeEvents = events.filter(function(e) {
                    return e.includes(".shape");
                });
                for(var e = 0; e < globalEvents.length; e++)circles.on(globalEvents[e], this._on[globalEvents[e]]);
                for(var e1 = 0; e1 < shapeEvents.length; e1++)circles.on(shapeEvents[e1], this._on[shapeEvents[e1]]);
                for(var e2 = 0; e2 < classEvents.length; e2++)circles.on(classEvents[e2], this._on[classEvents[e2]]);
                this._shapes.push(circles.render());
                return this;
            }
        },
        {
            /**
      Topojson files sometimes include small geographies that negatively impact how the library determines the default zoom level (for example, a small island or territory far off the coast that is barely visible to the eye). The fitFilter method can be used to remove specific geographies from the logic used to determine the zooming.

The *value* passed can be a single id to remove, an array of ids, or a filter function. Take a look at the [Choropleth Example](http://d3plus.org/examples/d3plus-geomap/getting-started/) to see it in action.
  */ key: "fitFilter",
            value: function fitFilter(_) {
                if (arguments.length) {
                    this._zoomSet = false;
                    if (typeof _ === "function") return this._fitFilter = _, this;
                    if (!_instanceof(_, Array)) _ = [
                        _
                    ];
                    return this._fitFilter = function(d) {
                        return _.includes(d.id);
                    }, this;
                }
                return this._fitFilter;
            }
        },
        {
            /**
      If the topojson being used to determine the zoom fit (either the main [topojson](#Geomap.topojson) object or the [fitObject](#Geomap.fitObject)) contains multiple geographical sets (for example, a file containing state and county boundaries), use this method to indentify which set to use for the zoom fit.

If not specified, the first key in the *Array* returned from using `Object.keys` on the topojson will be used.
  */ key: "fitKey",
            value: function fitKey(_) {
                if (arguments.length) {
                    this._fitKey = _;
                    this._zoomSet = false;
                    return this;
                }
                return this._fitKey;
            }
        },
        {
            /**
      The topojson to be used for the initial projection [fit extent](https://github.com/d3/d3-geo#projection_fitExtent). The value passed should either be a valid Topojson *Object* or a *String* representing a filepath or URL to be loaded.

Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function needs to return the final Topojson *Object*.
      @param _ `undefined`
      @param f Topojson data or a URL to load.
  */ key: "fitObject",
            value: function fitObject(_, f) {
                if (arguments.length) {
                    addToQueue.bind(this)(_, f, "fitObject");
                    this._zoomSet = false;
                    return this;
                }
                return this._fitObject;
            }
        },
        {
            /**
      The color visible behind any shapes drawn on the map projection. By default, a color value matching the color used in the map tiles is used to help mask the loading time needed to render the tiles. Any value CSS color value may be used, including hexidecimal, rgb, rgba, and color strings like `"blue"` and `"transparent"`.
      @param _ "#d4dadc"]
  */ key: "ocean",
            value: function ocean(_) {
                return arguments.length ? (this._ocean = _, this) : this._ocean;
            }
        },
        {
            /**
      The accessor to be used when detecting coordinate points in the objects passed to the [data](https://d3plus.org/docs/#Viz.data) method. Values are expected to be in the format `[longitude, latitude]`, which is in-line with d3's expected coordinate mapping.
  */ key: "point",
            value: function point(_) {
                return arguments.length ? (this._point = typeof _ === "function" ? _ : constant(_), this) : this._point;
            }
        },
        {
            /**
      The accessor or static value to be used for sizing coordinate points.
  */ key: "pointSize",
            value: function pointSize(_) {
                return arguments.length ? (this._pointSize = typeof _ === "function" ? _ : constant(_), this) : this._pointSize;
            }
        },
        {
            /**
      The maximum pixel radius used in the scale for sizing coordinate points.
      @param _ 10]
  */ key: "pointSizeMax",
            value: function pointSizeMax(_) {
                return arguments.length ? (this._pointSizeMax = _, this) : this._pointSizeMax;
            }
        },
        {
            /**
      The minimum pixel radius used in the scale for sizing coordinate points.
      @param _ 5]
  */ key: "pointSizeMin",
            value: function pointSizeMin(_) {
                return arguments.length ? (this._pointSizeMin = _, this) : this._pointSizeMin;
            }
        },
        {
            /**
      The map projection used when displaying topojson and coordinate points. All projections from [d3-geo](https://github.com/d3/d3-geo#projections), [d3-geo-projection](https://github.com/d3/d3-geo-projection#api-reference), and [d3-composite-projections](http://geoexamples.com/d3-composite-projections/) are accepted, either as the string name (ie. "geoMercator") or the generator function itself. Map tiles are only usable when the projection is set to Mercator (the default).
      @param _ "geoMercator"
  */ key: "projection",
            value: function projection(_) {
                if (arguments.length && _ !== "geoMercator") this.tiles(false);
                return arguments.length ? (this._projection = typeof _ === "string" ? d3Geo[_] ? d3Geo[_]() : d3Geo.geoMercator() : _, this) : this._projection;
            }
        },
        {
            /**
      The outer padding between the edge of the visualization and the shapes drawn. The value passed can be either a single number to be used on all sides, or a CSS string pattern (ie. `"20px 0 10px"`).
      @param _ 20]
  */ key: "projectionPadding",
            value: function projectionPadding(_) {
                return arguments.length ? (this._projectionPadding = parseSides(_), this) : this._projectionPadding;
            }
        },
        {
            /**
      An array that corresponds to the value passed to the projection's [rotate](https://github.com/d3/d3-geo#projection_rotate) function. Use this method to shift the centerpoint of a map.
      @param _ [0, 0]]
  */ key: "projectionRotate",
            value: function projectionRotate(_) {
                if (arguments.length) {
                    this._projection.rotate(_);
                    this.tiles(false);
                    this._zoomSet = false;
                    return this;
                } else {
                    return this._projectionRotate;
                }
            }
        },
        {
            /**
      Toggles the visibility of the map tiles.
      @param _ true]
  */ key: "tiles",
            value: function tiles(_) {
                if (arguments.length) {
                    this._tiles = _;
                    var attribution = findAttribution(this._tileUrl);
                    if (_ && this._attribution === "") this._attribution = attribution;
                    else if (!_ && this._attribution === attribution) this._attribution = "";
                    return this;
                }
                return this._tiles;
            }
        },
        {
            /**
      By default, d3plus uses the `light_all` style provided by [CARTO](https://carto.com/location-data-services/basemaps/) for it's map tiles. The [tileUrl](https://d3plus.org/docs/#Geomap.tileUrl) method changes the base URL used for fetching the tiles, as long as the string passed contains `{x}`, `{y}`, and `{z}` variables enclosed in curly brackets for the zoom logic to load the correct tiles.
      @param _ "https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png"]
  */ key: "tileUrl",
            value: function tileUrl(_) {
                if (arguments.length) {
                    this._tileUrl = _;
                    if (this._tiles) this._attribution = findAttribution(_);
                    if (this._tileGroup) this._renderTiles.bind(this)();
                    return this;
                }
                return this._tileUrl;
            }
        },
        {
            /**
      The topojson to be used for drawing geographical paths. The value passed should either be a valid Topojson *Object* or a *String* representing a filepath or URL to be loaded.

Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final Topojson *Obejct*.
      @param _ []
      @param f Topojson data or a URL to load.
  */ key: "topojson",
            value: function topojson(_, f) {
                if (arguments.length) {
                    addToQueue.bind(this)(_, f, "topojson");
                    this._zoomSet = false;
                    return this;
                }
                return this._topojson;
            }
        },
        {
            /**
      The function is used to set default color of the map.
      @param _ string
  */ key: "topojsonFill",
            value: function topojsonFill(_) {
                return arguments.length ? (this._topojsonFill = typeof _ === "function" ? _ : constant(_), this, this) : this._topojsonFill;
            }
        },
        {
            /**
      If the [topojson](#Geomap.topojson) being used contains boundaries that should not be shown, this method can be used to filter them out of the final output. The *value* passed can be a single id to remove, an array of ids, or a filter function.
  */ key: "topojsonFilter",
            value: function topojsonFilter(_) {
                if (arguments.length) {
                    this._zoomSet = false;
                    if (typeof _ === "function") return this._topojsonFilter = _, this;
                    if (!_instanceof(_, Array)) _ = [
                        _
                    ];
                    return this._topojsonFilter = function(d) {
                        return _.includes(d.id);
                    }, this;
                }
                return this._topojsonFilter;
            }
        },
        {
            /**
      If the [topojson](#Geomap.topojson) contains multiple geographical sets (for example, a file containing state and county boundaries), use this method to indentify which set to use.

If not specified, the first key in the *Array* returned from using `Object.keys` on the topojson will be used.
  */ key: "topojsonKey",
            value: function topojsonKey(_) {
                if (arguments.length) {
                    this._topojsonKey = _;
                    this._zoomSet = false;
                    return this;
                }
                return this._topojsonKey;
            }
        },
        {
            /**
      The accessor used to map each topojson geometry to it's corresponding [data](https://d3plus.org/docs/#Viz.data) point.
      @param _ "id"
  */ key: "topojsonId",
            value: function topojsonId(_) {
                return arguments.length ? (this._topojsonId = typeof _ === "function" ? _ : accessor(_), this, this) : this._topojsonId;
            }
        }
    ]);
    return Geomap;
}(Viz);
/**
    Creates a geographical map with zooming, panning, image tiles, and the ability to layer choropleth paths and coordinate points. See [this example](https://d3plus.org/examples/d3plus-geomap/getting-started/) for help getting started.
*/ export { Geomap as default };
