"use client";
const x = Math.PI, c = 2 * x, d = 1e-6, m = c - d;
function E(l) {
  this._ += l[0];
  for (let t = 1, h = l.length; t < h; ++t)
    this._ += arguments[t] + l[t];
}
function q(l) {
  let t = Math.floor(l);
  if (!(t >= 0)) throw new Error(`invalid digits: ${l}`);
  if (t > 15) return E;
  const h = 10 ** t;
  return function(i) {
    this._ += i[0];
    for (let s = 1, _ = i.length; s < _; ++s)
      this._ += Math.round(arguments[s] * h) / h + i[s];
  };
}
class C {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? E : q(t);
  }
  moveTo(t, h) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +h}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
  }
  lineTo(t, h) {
    this._append`L${this._x1 = +t},${this._y1 = +h}`;
  }
  quadraticCurveTo(t, h, i, s) {
    this._append`Q${+t},${+h},${this._x1 = +i},${this._y1 = +s}`;
  }
  bezierCurveTo(t, h, i, s, _, $) {
    this._append`C${+t},${+h},${+i},${+s},${this._x1 = +_},${this._y1 = +$}`;
  }
  arcTo(t, h, i, s, _) {
    if (t = +t, h = +h, i = +i, s = +s, _ = +_, _ < 0) throw new Error(`negative radius: ${_}`);
    let $ = this._x1, u = this._y1, o = i - t, a = s - h, e = $ - t, p = u - h, n = e * e + p * p;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = h}`;
    else if (n > d) if (!(Math.abs(p * o - a * e) > d) || !_)
      this._append`L${this._x1 = t},${this._y1 = h}`;
    else {
      let f = i - $, M = s - u, y = o * o + a * a, L = f * f + M * M, v = Math.sqrt(y), b = Math.sqrt(n), T = _ * Math.tan((x - Math.acos((y + n - L) / (2 * v * b))) / 2), r = T / b, A = T / v;
      Math.abs(r - 1) > d && this._append`L${t + r * e},${h + r * p}`, this._append`A${_},${_},0,0,${+(p * f > e * M)},${this._x1 = t + A * o},${this._y1 = h + A * a}`;
    }
  }
  arc(t, h, i, s, _, $) {
    if (t = +t, h = +h, i = +i, $ = !!$, i < 0) throw new Error(`negative radius: ${i}`);
    let u = i * Math.cos(s), o = i * Math.sin(s), a = t + u, e = h + o, p = 1 ^ $, n = $ ? s - _ : _ - s;
    this._x1 === null ? this._append`M${a},${e}` : (Math.abs(this._x1 - a) > d || Math.abs(this._y1 - e) > d) && this._append`L${a},${e}`, i && (n < 0 && (n = n % c + c), n > m ? this._append`A${i},${i},0,1,${p},${t - u},${h - o}A${i},${i},0,1,${p},${this._x1 = a},${this._y1 = e}` : n > d && this._append`A${i},${i},0,${+(n >= x)},${p},${this._x1 = t + i * Math.cos(_)},${this._y1 = h + i * Math.sin(_)}`);
  }
  rect(t, h, i, s) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +h}h${i = +i}v${+s}h${-i}Z`;
  }
  toString() {
    return this._;
  }
}
export {
  C as Path
};
