import discreteBuffer from "./discreteBuffer.js";
import numericBuffer from "./numericBuffer.js";
/**
    @module circleBuffer
    Adds a buffer to either side of the non-discrete axis.


    @param buffer Defaults to the radius of the largest Circle.
    @private
*/ export default function(param) {
    var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2, yScale = param.yScale, xScale = param.xScale, config = param.config, buffer = param.buffer;
    x = x.copy();
    y = y.copy();
    var xKey = x2 ? "x2" : "x";
    var yKey = y2 ? "y2" : "y";
    var xD = x.domain().slice(), yD = y.domain().slice();
    var xR = x.range(), yR = y.range();
    if (!x.invert && x.padding) discreteBuffer(x, data, this._discrete);
    if (!y.invert && y.padding) discreteBuffer(y, data, this._discrete);
    if (x.invert || y.invert) {
        data.forEach(function(d) {
            var s = buffer ? buffer : (config === null || config === void 0 ? void 0 : config.r)(d.data, d.i) * 2;
            if (x.invert) {
                xD = numericBuffer(x, xScale !== null && xScale !== void 0 ? xScale : "linear", d[xKey], s, xR, xD, 0, false);
                xD = numericBuffer(x, xScale !== null && xScale !== void 0 ? xScale : "linear", d[xKey], s, xR, xD, 1, false);
            }
            if (y.invert) {
                yD = numericBuffer(y, yScale !== null && yScale !== void 0 ? yScale : "linear", d[yKey], s, yR, yD, 0, true);
                yD = numericBuffer(y, yScale !== null && yScale !== void 0 ? yScale : "linear", d[yKey], s, yR, yD, 1, true);
            }
        });
    }
    return [
        x,
        y
    ];
}
