var R = Object.defineProperty;
var p = (o, e, n) => e in o ? R(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
var r = (o, e, n) => (p(o, typeof e != "symbol" ? e + "" : e, n), n);
import { a as u } from "../../../three-vrm.module-BuztCP2r.js";
import { E as z, M as l, Q as y } from "../../../three.module-BPupfU8l.js";
const g = new z(), d = new y(), m = l.DEG2RAD * 2.5, M = 1, i = {
  xmin: -m,
  xmax: m,
  ymin: -m,
  ymax: m,
  zmin: 0,
  zmax: 0
}, s = {
  xmin: -m,
  xmax: m,
  ymin: 0,
  ymax: 0,
  zmin: 0,
  zmax: 0
}, t = u, I = /* @__PURE__ */ new Map([
  [t.Chest, i],
  [t.Head, i],
  // [BoneNames.Hips, defaultNoise],
  [t.Jaw, i],
  // [BoneNames.LeftEye, defaultNoise],
  [t.LeftFoot, i],
  [t.LeftHand, i],
  [t.LeftIndexDistal, s],
  [t.LeftIndexIntermediate, s],
  [t.LeftIndexProximal, i],
  [t.LeftLittleDistal, s],
  [t.LeftLittleIntermediate, s],
  [t.LeftLittleProximal, i],
  [t.LeftLowerArm, s],
  [t.LeftLowerLeg, s],
  [t.LeftMiddleDistal, s],
  [t.LeftMiddleIntermediate, s],
  [t.LeftMiddleProximal, i],
  [t.LeftRingDistal, s],
  [t.LeftRingIntermediate, s],
  [t.LeftRingProximal, i],
  [t.LeftShoulder, i],
  [t.LeftThumbDistal, s],
  [t.LeftThumbMetacarpal, s],
  [t.LeftThumbProximal, i],
  [t.LeftToes, s],
  [t.LeftUpperArm, i],
  [t.LeftUpperLeg, i],
  [t.Neck, i],
  // [BoneNames.RightEye, defaultNoise],
  [t.RightFoot, i],
  [t.RightHand, i],
  [t.RightIndexDistal, s],
  [t.RightIndexIntermediate, s],
  [t.RightIndexProximal, i],
  [t.RightLittleDistal, s],
  [t.RightLittleIntermediate, s],
  [t.RightLittleProximal, i],
  [t.RightLowerArm, s],
  [t.RightLowerLeg, s],
  [t.RightMiddleDistal, s],
  [t.RightMiddleIntermediate, s],
  [t.RightMiddleProximal, i],
  [t.RightRingDistal, s],
  [t.RightRingIntermediate, s],
  [t.RightRingProximal, i],
  [t.RightShoulder, i],
  [t.RightThumbDistal, s],
  [t.RightThumbMetacarpal, s],
  [t.RightThumbProximal, i],
  [t.RightToes, s],
  [t.RightUpperArm, i],
  [t.RightUpperLeg, i],
  [t.Spine, i],
  [t.UpperChest, i]
]);
class w {
  constructor(e, n, a, h, f, x, c, L) {
    r(this, "x", 0);
    r(this, "y", 0);
    r(this, "z", 0);
    r(this, "firstRun", !0);
    this.bone = e, this.xmin = n, this.xmax = a, this.ymin = h, this.ymax = f, this.zmin = x, this.zmax = c, this.lerpScale = L, a === n && (this.x = n), f === h && (this.y = h), c === x && (this.z = x);
  }
  update(e, n) {
    n && this.firstRun && this.bone.quaternion.multiply(
      d.setFromEuler(g.set(this.x, this.y, this.z)).invert()
    ), e *= this.lerpScale, e > this.lerpScale && (e = this.lerpScale), this.xmax !== this.xmin && (this.x = l.lerp(
      this.x,
      l.randFloat(this.xmin, this.xmax),
      e
    )), this.ymax !== this.ymin && (this.y = l.lerp(
      this.y,
      l.randFloat(this.ymin, this.ymax),
      e
    )), this.zmax !== this.zmin && (this.z = l.lerp(
      this.z,
      l.randFloat(this.zmin, this.zmax),
      e
    )), this.bone.quaternion.multiply(
      d.setFromEuler(g.set(this.x, this.y, this.z))
    ), this.firstRun = !1;
  }
}
class N {
  constructor(e) {
    r(this, "channels", []);
    this.humanoid = e;
    const n = e.getNormalizedPose();
    e.resetNormalizedPose();
    for (const [a, h] of I) {
      const f = e.getNormalizedBoneNode(a);
      f && this.channels.push(
        new w(
          f,
          h.xmin,
          h.xmax,
          h.ymin,
          h.ymax,
          h.zmin,
          h.zmax,
          M
        )
      );
    }
    e.setNormalizedPose(n);
  }
  static get(e) {
    const { humanoid: n } = e;
    if (!n)
      throw new Error("VRM does not have humanoid.");
    let a = this.cache.get(e);
    return a || this.cache.set(e, a = new this(n)), a;
  }
  update(e, n) {
    for (const a of this.channels)
      a.update(e, n);
  }
}
r(N, "cache", /* @__PURE__ */ new WeakMap());
export {
  N as default
};
