import { n as c, o as x, b as f, r as R, p as m, q as p, P as D, h as u, j as y } from "./am-chart.H2jnOzFc.js";
class h extends c {
  constructor() {
    super(...arguments), this._display = this._root._renderer.makeRadialText("", this.textStyle);
  }
  _afterNew() {
    super._afterNew();
  }
  _beforeChanged() {
    super._beforeChanged(), this._display.clear(), this.isDirty("textType") && (this._display.textType = this.get("textType"), this.markDirtyBounds()), this.isDirty("radius") && (this._display.radius = this.get("radius"), this.markDirtyBounds()), this.isDirty("startAngle") && (this._display.startAngle = (this.get("startAngle", 0) + 90) * x, this.markDirtyBounds()), this.isDirty("inside") && (this._display.inside = this.get("inside"), this.markDirtyBounds()), this.isDirty("orientation") && (this._display.orientation = this.get("orientation"), this.markDirtyBounds()), this.isDirty("kerning") && (this._display.kerning = this.get("kerning"), this.markDirtyBounds());
  }
}
h.className = "RadialText";
h.classNames = c.classNames.concat([h.className]);
class g extends f {
  constructor() {
    super(...arguments), this._flipped = !1;
  }
  _afterNew() {
    this._textKeys.push("textType", "kerning"), super._afterNew();
  }
  _makeText() {
    this._text = this.children.push(h.new(this._root, {}));
  }
  /**
   * Returns base radius in pixels.
   *
   * @return Base radius
   */
  baseRadius() {
    const t = this.getPrivate("radius", 0), a = this.getPrivate("innerRadius", 0), i = this.get("baseRadius", 0);
    return a + R(i, t - a);
  }
  /**
   * Returns radius adjustment in pixels.
   *
   * @return Radius
   */
  radius() {
    const t = this.get("inside", !1);
    return this.baseRadius() + this.get("radius", 0) * (t ? -1 : 1);
  }
  _updateChildren() {
    if (super._updateChildren(), this.isDirty("baseRadius") || this.isPrivateDirty("radius") || this.isPrivateDirty("innerRadius") || this.isDirty("labelAngle") || this.isDirty("radius") || this.isDirty("inside") || this.isDirty("orientation") || this.isDirty("textType")) {
      const t = this.get("textType", "adjusted"), a = this.get("inside", !1), i = this.get("orientation");
      let s = m(this.get("labelAngle", 0));
      this._text.set("startAngle", this.get("labelAngle", 0)), this._text.set("inside", a);
      const r = y(s), n = u(s);
      let e = this.baseRadius(), l = this.radius();
      if (this._display.angle = 0, t == "circular")
        this.setAll({
          paddingTop: 0,
          paddingBottom: 0,
          paddingLeft: 0,
          paddingRight: 0
        }), this.setRaw("x", void 0), this.setRaw("y", void 0), this._text.set("orientation", i), this._text.set("radius", l);
      else {
        e == 0 && (s = 0, l = 0);
        let d = l * n, o = l * r;
        t == "radial" ? (this.setRaw("x", d), this.setRaw("y", o), s < 90 || s > 270 || i != "auto" ? (this._display.angle = s, this._flipped = !1) : (this._display.angle = s + 180, this._flipped = !0), this._dirty.rotation = !1) : t == "adjusted" ? (this.setRaw("centerX", p), this.setRaw("centerY", p), this.setRaw("x", d), this.setRaw("y", o)) : t == "regular" && (this.setRaw("x", d), this.setRaw("y", o));
      }
      this.markDirtyPosition(), this.markDirtyBounds();
    }
  }
  _updatePosition() {
    const t = this.get("textType", "regular"), a = this.get("inside", !1);
    let i = 0, s = 0, r = this.get("labelAngle", 0), n = this.localBounds(), e = n.right - n.left, l = n.bottom - n.top;
    if (t == "radial") {
      if (this._flipped) {
        let d = this.get("centerX");
        d instanceof D && (e = e * (1 - d.value * 2)), i = e * u(r), s = e * y(r);
      }
    } else !a && t == "adjusted" && (i = e / 2 * u(r), s = l / 2 * y(r));
    this.setRaw("dx", i), this.setRaw("dy", s), super._updatePosition();
  }
  /**
   * @ignore
   */
  get text() {
    return this._text;
  }
}
g.className = "RadialLabel";
g.classNames = f.classNames.concat([g.className]);
export {
  g as R,
  h as a
};
