import { Feature as d } from "../../../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/render/Feature.es.js";
import { resolveVariant as p } from "../../../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/render/utils/resolve-dynamic-variants.es.js";
let c = 0;
class E extends d {
  constructor() {
    super(...arguments), this.id = c++, this.isExitComplete = !1;
  }
  update() {
    var n;
    if (!this.node.presenceContext)
      return;
    const { isPresent: t, onExitComplete: e } = this.node.presenceContext, { isPresent: i } = this.node.prevPresenceContext || {};
    if (!this.node.animationState || t === i)
      return;
    if (t && i === !1) {
      if (this.isExitComplete) {
        const { initial: s, custom: h } = this.node.getProps();
        if (typeof s == "string") {
          const o = p(this.node, s, h);
          if (o) {
            const { transition: f, transitionEnd: l, ...r } = o;
            for (const a in r)
              (n = this.node.getValue(a)) == null || n.jump(r[a]);
          }
        }
        this.node.animationState.reset(), this.node.animationState.animateChanges();
      } else
        this.node.animationState.setActive("exit", !1);
      this.isExitComplete = !1;
      return;
    }
    const m = this.node.animationState.setActive("exit", !t);
    e && !t && m.then(() => {
      this.isExitComplete = !0, e(this.id);
    });
  }
  mount() {
    const { register: t, onExitComplete: e } = this.node.presenceContext || {};
    e && e(this.id), t && (this.unmount = t(this.id));
  }
  unmount() {
  }
}
export {
  E as ExitAnimationFeature
};
//# sourceMappingURL=exit.es.js.map
