import * as bt from "react";
import ye, { createContext as et, useContext as C, useRef as wt, useInsertionEffect as ti, useEffect as ei, useCallback as ii, useMemo as it, forwardRef as si, createElement as ni } from "react";
import { P as ve, x as oi, y as z, z as Pe, A as pt, B as Rt, i as ri, k as Tt, C as ai, D as li, E as xe, F as Te, G as ci, u as ui, I as hi, J as St, K as fi, L as di, f as D, M as mi, N as pi, O as G, Q as M, R as Dt, t as Se, T as Mt, U as De, c as K, o as gi, g as yi, V as L, j as T, p as gt, W as Ae, X as x, a as vi, Y as Pi, Z as xi, _ as Ti, $ as Q, a0 as Si, a1 as Le, a2 as Bt, a3 as Di, w as Ai, a4 as Li, a5 as kt, a6 as Ce, r as Ee, a7 as Ci, b as Ei, a8 as Vi, a9 as ct, aa as I, ab as U, ac as Y, ad as jt, ae as bi, af as wi, ag as Ri, ah as O, q as Mi, ai as Ft, S as Bi, H as ki } from "./SVGVisualElement-aqO4D4Z5.js";
import { u as ji, L as Ve } from "./LayoutGroupContext-3euHzeKi.js";
const be = et({
  transformPagePoint: (t) => t,
  isStatic: !1,
  reducedMotion: "never"
}), st = et({}), we = et({ strict: !1 });
function Fi(t, e, i, s) {
  const { visualElement: r } = C(st), u = C(we), n = C(ve), o = C(be).reducedMotion, a = wt();
  s = s || u.renderer, !a.current && s && (a.current = s(t, {
    visualState: e,
    parent: r,
    props: i,
    presenceContext: n,
    blockInitialAnimation: n ? n.initial === !1 : !1,
    reducedMotionConfig: o
  }));
  const l = a.current;
  ti(() => {
    l && l.update(i, n);
  });
  const c = wt(!!(i[oi] && !window.HandoffComplete));
  return ji(() => {
    l && (l.render(), c.current && l.animationState && l.animationState.animateChanges());
  }), ei(() => {
    l && (l.updateFeatures(), !c.current && l.animationState && l.animationState.animateChanges(), c.current && (c.current = !1, window.HandoffComplete = !0));
  }), l;
}
function Ii(t, e, i) {
  return ii(
    (s) => {
      s && t.mount && t.mount(s), e && (s ? e.mount(s) : e.unmount()), i && (typeof i == "function" ? i(s) : z(i) && (i.current = s));
    },
    /**
     * Only pass a new ref callback to React if we've received a visual element
     * factory. Otherwise we'll be mounting/remounting every time externalRef
     * or other dependencies change.
     */
    [e]
  );
}
function Ui(t, e) {
  if (Pe(t)) {
    const { initial: i, animate: s } = t;
    return {
      initial: i === !1 || pt(i) ? i : void 0,
      animate: pt(s) ? s : void 0
    };
  }
  return t.inherit !== !1 ? e : {};
}
function Oi(t) {
  const { initial: e, animate: i } = Ui(t, C(st));
  return it(() => ({ initial: e, animate: i }), [It(e), It(i)]);
}
function It(t) {
  return Array.isArray(t) ? t.join(" ") : t;
}
function Gi(t) {
  for (const e in t)
    Rt[e] = {
      ...Rt[e],
      ...t[e]
    };
}
const Re = et({}), Hi = Symbol.for("motionComponentSymbol");
function Ni({ preloadedFeatures: t, createVisualElement: e, useRender: i, useVisualState: s, Component: r }) {
  t && Gi(t);
  function u(o, a) {
    let l;
    const c = {
      ...C(be),
      ...o,
      layoutId: Wi(o)
    }, { isStatic: h } = c, f = Oi(o), d = s(o, h);
    if (!h && ri) {
      f.visualElement = Fi(r, d, c, e);
      const m = C(Re), p = C(we).strict;
      f.visualElement && (l = f.visualElement.loadFeatures(
        // Note: Pass the full new combined props to correctly re-render dynamic feature components.
        c,
        p,
        t,
        m
      ));
    }
    return bt.createElement(
      st.Provider,
      { value: f },
      l && f.visualElement ? bt.createElement(l, { visualElement: f.visualElement, ...c }) : null,
      i(r, o, Ii(d, f.visualElement, a), d, h, f.visualElement)
    );
  }
  const n = si(u);
  return n[Hi] = r, n;
}
function Wi({ layoutId: t }) {
  const e = C(Ve).id;
  return e && t !== void 0 ? e + "-" + t : t;
}
function zi(t) {
  function e(s, r = {}) {
    return Ni(t(s, r));
  }
  if (typeof Proxy > "u")
    return e;
  const i = /* @__PURE__ */ new Map();
  return new Proxy(e, {
    /**
     * Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc.
     * The prop name is passed through as `key` and we can use that to generate a `motion`
     * DOM component with that name.
     */
    get: (s, r) => (i.has(r) || i.set(r, e(r)), i.get(r))
  });
}
const _i = [
  "animate",
  "circle",
  "defs",
  "desc",
  "ellipse",
  "g",
  "image",
  "line",
  "filter",
  "marker",
  "mask",
  "metadata",
  "path",
  "pattern",
  "polygon",
  "polyline",
  "rect",
  "stop",
  "switch",
  "symbol",
  "svg",
  "text",
  "tspan",
  "use",
  "view"
];
function At(t) {
  return (
    /**
     * If it's not a string, it's a custom React component. Currently we only support
     * HTML custom React components.
     */
    typeof t != "string" || /**
     * If it contains a dash, the element is a custom HTML webcomponent.
     */
    t.includes("-") ? !1 : (
      /**
       * If it's in our list of lowercase SVG tags, it's an SVG component
       */
      !!(_i.indexOf(t) > -1 || /**
       * If it contains a capital letter, it's an SVG component
       */
      /[A-Z]/.test(t))
    )
  );
}
const Lt = () => ({
  style: {},
  transform: {},
  transformOrigin: {},
  vars: {}
});
function Me(t, e, i) {
  for (const s in e)
    !Tt(e[s]) && !ai(s, i) && (t[s] = e[s]);
}
function $i({ transformTemplate: t }, e, i) {
  return it(() => {
    const s = Lt();
    return li(s, e, { enableHardwareAcceleration: !i }, t), Object.assign({}, s.vars, s.style);
  }, [e]);
}
function Ki(t, e, i) {
  const s = t.style || {}, r = {};
  return Me(r, s, t), Object.assign(r, $i(t, e, i)), t.transformValues ? t.transformValues(r) : r;
}
function Xi(t, e, i) {
  const s = {}, r = Ki(t, e, i);
  return t.drag && t.dragListener !== !1 && (s.draggable = !1, r.userSelect = r.WebkitUserSelect = r.WebkitTouchCallout = "none", r.touchAction = t.drag === !0 ? "none" : `pan-${t.drag === "x" ? "y" : "x"}`), t.tabIndex === void 0 && (t.onTap || t.onTapStart || t.whileTap) && (s.tabIndex = 0), s.style = r, s;
}
const Yi = /* @__PURE__ */ new Set([
  "animate",
  "exit",
  "variants",
  "initial",
  "style",
  "values",
  "variants",
  "transition",
  "transformTemplate",
  "transformValues",
  "custom",
  "inherit",
  "onLayoutAnimationStart",
  "onLayoutAnimationComplete",
  "onLayoutMeasure",
  "onBeforeLayoutMeasure",
  "onAnimationStart",
  "onAnimationComplete",
  "onUpdate",
  "onDragStart",
  "onDrag",
  "onDragEnd",
  "onMeasureDragConstraints",
  "onDirectionLock",
  "onDragTransitionEnd",
  "_dragX",
  "_dragY",
  "onHoverStart",
  "onHoverEnd",
  "onViewportEnter",
  "onViewportLeave",
  "ignoreStrict",
  "viewport"
]);
function tt(t) {
  return t.startsWith("while") || t.startsWith("drag") && t !== "draggable" || t.startsWith("layout") || t.startsWith("onTap") || t.startsWith("onPan") || Yi.has(t);
}
let Be = (t) => !tt(t);
function qi(t) {
  t && (Be = (e) => e.startsWith("on") ? !tt(e) : t(e));
}
try {
  qi(require("@emotion/is-prop-valid").default);
} catch {
}
function Zi(t, e, i) {
  const s = {};
  for (const r in t)
    r === "values" && typeof t.values == "object" || (Be(r) || i === !0 && tt(r) || !e && !tt(r) || // If trying to use native HTML drag events, forward drag listeners
    t.draggable && r.startsWith("onDrag")) && (s[r] = t[r]);
  return s;
}
const ke = () => ({
  ...Lt(),
  attrs: {}
});
function Ji(t, e, i, s) {
  const r = it(() => {
    const u = ke();
    return xe(u, e, { enableHardwareAcceleration: !1 }, Te(s), t.transformTemplate), {
      ...u.attrs,
      style: { ...u.style }
    };
  }, [e]);
  if (t.style) {
    const u = {};
    Me(u, t.style, t), r.style = { ...u, ...r.style };
  }
  return r;
}
function Qi(t = !1) {
  return (i, s, r, { latestValues: u }, n) => {
    const a = (At(i) ? Ji : Xi)(s, u, n, i), c = {
      ...Zi(s, typeof i == "string", t),
      ...a,
      ref: r
    }, { children: h } = s, f = it(() => Tt(h) ? h.get() : h, [h]);
    return ni(i, {
      ...c,
      children: f
    });
  };
}
function Z(t) {
  const e = Tt(t) ? t.get() : t;
  return ci(e) ? e.toValue() : e;
}
function ts({ scrapeMotionValuesFromProps: t, createRenderState: e, onMount: i }, s, r, u) {
  const n = {
    latestValues: es(s, r, u, t),
    renderState: e()
  };
  return i && (n.mount = (o) => i(s, o, n)), n;
}
const je = (t) => (e, i) => {
  const s = C(st), r = C(ve), u = () => ts(t, e, s, r);
  return i ? u() : ui(u);
};
function es(t, e, i, s) {
  const r = {}, u = s(t, {});
  for (const f in u)
    r[f] = Z(u[f]);
  let { initial: n, animate: o } = t;
  const a = Pe(t), l = hi(t);
  e && l && !a && t.inherit !== !1 && (n === void 0 && (n = e.initial), o === void 0 && (o = e.animate));
  let c = i ? i.initial === !1 : !1;
  c = c || n === !1;
  const h = c ? o : n;
  return h && typeof h != "boolean" && !St(h) && (Array.isArray(h) ? h : [h]).forEach((d) => {
    const m = fi(t, d);
    if (!m)
      return;
    const { transitionEnd: p, transition: S, ...v } = m;
    for (const y in v) {
      let g = v[y];
      if (Array.isArray(g)) {
        const P = c ? g.length - 1 : 0;
        g = g[P];
      }
      g !== null && (r[y] = g);
    }
    for (const y in p)
      r[y] = p[y];
  }), r;
}
const is = {
  useVisualState: je({
    scrapeMotionValuesFromProps: di,
    createRenderState: ke,
    onMount: (t, e, { renderState: i, latestValues: s }) => {
      D.read(() => {
        try {
          i.dimensions = typeof e.getBBox == "function" ? e.getBBox() : e.getBoundingClientRect();
        } catch {
          i.dimensions = {
            x: 0,
            y: 0,
            width: 0,
            height: 0
          };
        }
      }), D.render(() => {
        xe(i, s, { enableHardwareAcceleration: !1 }, Te(e.tagName), t.transformTemplate), mi(e, i);
      });
    }
  })
}, ss = {
  useVisualState: je({
    scrapeMotionValuesFromProps: pi,
    createRenderState: Lt
  })
};
function ns(t, { forwardMotionProps: e = !1 }, i, s) {
  return {
    ...At(t) ? is : ss,
    preloadedFeatures: i,
    useRender: Qi(e),
    createVisualElement: s,
    Component: t
  };
}
function R(t, e, i, s = { passive: !0 }) {
  return t.addEventListener(e, i, s), () => t.removeEventListener(e, i);
}
const Fe = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1;
function nt(t, e = "page") {
  return {
    point: {
      x: t[e + "X"],
      y: t[e + "Y"]
    }
  };
}
const os = (t) => (e) => Fe(e) && t(e, nt(e));
function B(t, e, i, s) {
  return R(t, e, os(i), s);
}
function Ie(t) {
  let e = null;
  return () => {
    const i = () => {
      e = null;
    };
    return e === null ? (e = t, i) : !1;
  };
}
const Ut = Ie("dragHorizontal"), Ot = Ie("dragVertical");
function Ue(t) {
  let e = !1;
  if (t === "y")
    e = Ot();
  else if (t === "x")
    e = Ut();
  else {
    const i = Ut(), s = Ot();
    i && s ? e = () => {
      i(), s();
    } : (i && i(), s && s());
  }
  return e;
}
function Oe() {
  const t = Ue(!0);
  return t ? (t(), !1) : !0;
}
class k {
  constructor(e) {
    this.isMounted = !1, this.node = e;
  }
  update() {
  }
}
function Gt(t, e) {
  const i = "pointer" + (e ? "enter" : "leave"), s = "onHover" + (e ? "Start" : "End"), r = (u, n) => {
    if (u.type === "touch" || Oe())
      return;
    const o = t.getProps();
    t.animationState && o.whileHover && t.animationState.setActive("whileHover", e), o[s] && D.update(() => o[s](u, n));
  };
  return B(t.current, i, r, {
    passive: !t.getProps()[s]
  });
}
class rs extends k {
  mount() {
    this.unmount = G(Gt(this.node, !0), Gt(this.node, !1));
  }
  unmount() {
  }
}
class as extends k {
  constructor() {
    super(...arguments), this.isActive = !1;
  }
  onFocus() {
    let e = !1;
    try {
      e = this.node.current.matches(":focus-visible");
    } catch {
      e = !0;
    }
    !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
  }
  onBlur() {
    !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
  }
  mount() {
    this.unmount = G(R(this.node.current, "focus", () => this.onFocus()), R(this.node.current, "blur", () => this.onBlur()));
  }
  unmount() {
  }
}
const Ge = (t, e) => e ? t === e ? !0 : Ge(t, e.parentElement) : !1;
function ut(t, e) {
  if (!e)
    return;
  const i = new PointerEvent("pointer" + t);
  e(i, nt(i));
}
class ls extends k {
  constructor() {
    super(...arguments), this.removeStartListeners = M, this.removeEndListeners = M, this.removeAccessibleListeners = M, this.startPointerPress = (e, i) => {
      if (this.removeEndListeners(), this.isPressing)
        return;
      const s = this.node.getProps(), u = B(window, "pointerup", (o, a) => {
        if (!this.checkPressEnd())
          return;
        const { onTap: l, onTapCancel: c } = this.node.getProps();
        D.update(() => {
          Ge(this.node.current, o.target) ? l && l(o, a) : c && c(o, a);
        });
      }, { passive: !(s.onTap || s.onPointerUp) }), n = B(window, "pointercancel", (o, a) => this.cancelPress(o, a), { passive: !(s.onTapCancel || s.onPointerCancel) });
      this.removeEndListeners = G(u, n), this.startPress(e, i);
    }, this.startAccessiblePress = () => {
      const e = (u) => {
        if (u.key !== "Enter" || this.isPressing)
          return;
        const n = (o) => {
          o.key !== "Enter" || !this.checkPressEnd() || ut("up", (a, l) => {
            const { onTap: c } = this.node.getProps();
            c && D.update(() => c(a, l));
          });
        };
        this.removeEndListeners(), this.removeEndListeners = R(this.node.current, "keyup", n), ut("down", (o, a) => {
          this.startPress(o, a);
        });
      }, i = R(this.node.current, "keydown", e), s = () => {
        this.isPressing && ut("cancel", (u, n) => this.cancelPress(u, n));
      }, r = R(this.node.current, "blur", s);
      this.removeAccessibleListeners = G(i, r);
    };
  }
  startPress(e, i) {
    this.isPressing = !0;
    const { onTapStart: s, whileTap: r } = this.node.getProps();
    r && this.node.animationState && this.node.animationState.setActive("whileTap", !0), s && D.update(() => s(e, i));
  }
  checkPressEnd() {
    return this.removeEndListeners(), this.isPressing = !1, this.node.getProps().whileTap && this.node.animationState && this.node.animationState.setActive("whileTap", !1), !Oe();
  }
  cancelPress(e, i) {
    if (!this.checkPressEnd())
      return;
    const { onTapCancel: s } = this.node.getProps();
    s && D.update(() => s(e, i));
  }
  mount() {
    const e = this.node.getProps(), i = B(this.node.current, "pointerdown", this.startPointerPress, { passive: !(e.onTapStart || e.onPointerStart) }), s = R(this.node.current, "focus", this.startAccessiblePress);
    this.removeStartListeners = G(i, s);
  }
  unmount() {
    this.removeStartListeners(), this.removeEndListeners(), this.removeAccessibleListeners();
  }
}
const yt = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap(), cs = (t) => {
  const e = yt.get(t.target);
  e && e(t);
}, us = (t) => {
  t.forEach(cs);
};
function hs({ root: t, ...e }) {
  const i = t || document;
  ht.has(i) || ht.set(i, {});
  const s = ht.get(i), r = JSON.stringify(e);
  return s[r] || (s[r] = new IntersectionObserver(us, { root: t, ...e })), s[r];
}
function fs(t, e, i) {
  const s = hs(e);
  return yt.set(t, i), s.observe(t), () => {
    yt.delete(t), s.unobserve(t);
  };
}
const ds = {
  some: 0,
  all: 1
};
class ms extends k {
  constructor() {
    super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
  }
  startObserver() {
    this.unmount();
    const { viewport: e = {} } = this.node.getProps(), { root: i, margin: s, amount: r = "some", once: u } = e, n = {
      root: i ? i.current : void 0,
      rootMargin: s,
      threshold: typeof r == "number" ? r : ds[r]
    }, o = (a) => {
      const { isIntersecting: l } = a;
      if (this.isInView === l || (this.isInView = l, u && !l && this.hasEnteredView))
        return;
      l && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", l);
      const { onViewportEnter: c, onViewportLeave: h } = this.node.getProps(), f = l ? c : h;
      f && f(a);
    };
    return fs(this.node.current, n, o);
  }
  mount() {
    this.startObserver();
  }
  update() {
    if (typeof IntersectionObserver > "u")
      return;
    const { props: e, prevProps: i } = this.node;
    ["amount", "margin", "root"].some(ps(e, i)) && this.startObserver();
  }
  unmount() {
  }
}
function ps({ viewport: t = {} }, { viewport: e = {} } = {}) {
  return (i) => t[i] !== e[i];
}
const gs = {
  inView: {
    Feature: ms
  },
  tap: {
    Feature: ls
  },
  focus: {
    Feature: as
  },
  hover: {
    Feature: rs
  }
};
function He(t, e) {
  if (!Array.isArray(e))
    return !1;
  const i = e.length;
  if (i !== t.length)
    return !1;
  for (let s = 0; s < i; s++)
    if (e[s] !== t[s])
      return !1;
  return !0;
}
function vt(t, e, i = {}) {
  const s = Dt(t, e, i.custom);
  let { transition: r = t.getDefaultTransition() || {} } = s || {};
  i.transitionOverride && (r = i.transitionOverride);
  const u = s ? () => Promise.all(Se(t, s, i)) : () => Promise.resolve(), n = t.variantChildren && t.variantChildren.size ? (a = 0) => {
    const { delayChildren: l = 0, staggerChildren: c, staggerDirection: h } = r;
    return ys(t, e, l + a, c, h, i);
  } : () => Promise.resolve(), { when: o } = r;
  if (o) {
    const [a, l] = o === "beforeChildren" ? [u, n] : [n, u];
    return a().then(() => l());
  } else
    return Promise.all([u(), n(i.delay)]);
}
function ys(t, e, i = 0, s = 0, r = 1, u) {
  const n = [], o = (t.variantChildren.size - 1) * s, a = r === 1 ? (l = 0) => l * s : (l = 0) => o - l * s;
  return Array.from(t.variantChildren).sort(vs).forEach((l, c) => {
    l.notify("AnimationStart", e), n.push(vt(l, e, {
      ...u,
      delay: i + a(c)
    }).then(() => l.notify("AnimationComplete", e)));
  }), Promise.all(n);
}
function vs(t, e) {
  return t.sortNodePosition(e);
}
function Ps(t, e, i = {}) {
  t.notify("AnimationStart", e);
  let s;
  if (Array.isArray(e)) {
    const r = e.map((u) => vt(t, u, i));
    s = Promise.all(r);
  } else if (typeof e == "string")
    s = vt(t, e, i);
  else {
    const r = typeof e == "function" ? Dt(t, e, i.custom) : e;
    s = Promise.all(Se(t, r, i));
  }
  return s.then(() => t.notify("AnimationComplete", e));
}
const xs = [...De].reverse(), Ts = De.length;
function Ss(t) {
  return (e) => Promise.all(e.map(({ animation: i, options: s }) => Ps(t, i, s)));
}
function Ds(t) {
  let e = Ss(t);
  const i = Ls();
  let s = !0;
  const r = (a, l) => {
    const c = Dt(t, l);
    if (c) {
      const { transition: h, transitionEnd: f, ...d } = c;
      a = { ...a, ...d, ...f };
    }
    return a;
  };
  function u(a) {
    e = a(t);
  }
  function n(a, l) {
    const c = t.getProps(), h = t.getVariantContext(!0) || {}, f = [], d = /* @__PURE__ */ new Set();
    let m = {}, p = 1 / 0;
    for (let v = 0; v < Ts; v++) {
      const y = xs[v], g = i[y], P = c[y] !== void 0 ? c[y] : h[y], w = pt(P), ot = y === l ? g.isActive : null;
      ot === !1 && (p = v);
      let X = P === h[y] && P !== c[y] && w;
      if (X && s && t.manuallyAnimateOnMount && (X = !1), g.protectedKeys = { ...m }, // If it isn't active and hasn't *just* been set as inactive
      !g.isActive && ot === null || // If we didn't and don't have any defined prop for this animation type
      !P && !g.prevProp || // Or if the prop doesn't define an animation
      St(P) || typeof P == "boolean")
        continue;
      const Ct = As(g.prevProp, P);
      let rt = Ct || // If we're making this variant active, we want to always make it active
      y === l && g.isActive && !X && w || // If we removed a higher-priority variant (i is in reverse order)
      v > p && w;
      const Et = Array.isArray(P) ? P : [P];
      let H = Et.reduce(r, {});
      ot === !1 && (H = {});
      const { prevResolvedValues: Vt = {} } = g, Qe = {
        ...Vt,
        ...H
      }, at = (A) => {
        rt = !0, d.delete(A), g.needsAnimating[A] = !0;
      };
      for (const A in Qe) {
        const N = H[A], lt = Vt[A];
        m.hasOwnProperty(A) || (N !== lt ? Mt(N) && Mt(lt) ? !He(N, lt) || Ct ? at(A) : g.protectedKeys[A] = !0 : N !== void 0 ? at(A) : d.add(A) : N !== void 0 && d.has(A) ? at(A) : g.protectedKeys[A] = !0);
      }
      g.prevProp = P, g.prevResolvedValues = H, g.isActive && (m = { ...m, ...H }), s && t.blockInitialAnimation && (rt = !1), rt && !X && f.push(...Et.map((A) => ({
        animation: A,
        options: { type: y, ...a }
      })));
    }
    if (d.size) {
      const v = {};
      d.forEach((y) => {
        const g = t.getBaseTarget(y);
        g !== void 0 && (v[y] = g);
      }), f.push({ animation: v });
    }
    let S = !!f.length;
    return s && (c.initial === !1 || c.initial === c.animate) && !t.manuallyAnimateOnMount && (S = !1), s = !1, S ? e(f) : Promise.resolve();
  }
  function o(a, l, c) {
    var h;
    if (i[a].isActive === l)
      return Promise.resolve();
    (h = t.variantChildren) === null || h === void 0 || h.forEach((d) => {
      var m;
      return (m = d.animationState) === null || m === void 0 ? void 0 : m.setActive(a, l);
    }), i[a].isActive = l;
    const f = n(c, a);
    for (const d in i)
      i[d].protectedKeys = {};
    return f;
  }
  return {
    animateChanges: n,
    setActive: o,
    setAnimateFunction: u,
    getState: () => i
  };
}
function As(t, e) {
  return typeof e == "string" ? e !== t : Array.isArray(e) ? !He(e, t) : !1;
}
function j(t = !1) {
  return {
    isActive: t,
    protectedKeys: {},
    needsAnimating: {},
    prevResolvedValues: {}
  };
}
function Ls() {
  return {
    animate: j(!0),
    whileInView: j(),
    whileHover: j(),
    whileTap: j(),
    whileDrag: j(),
    whileFocus: j(),
    exit: j()
  };
}
class Cs extends k {
  /**
   * We dynamically generate the AnimationState manager as it contains a reference
   * to the underlying animation library. We only want to load that if we load this,
   * so people can optionally code split it out using the `m` component.
   */
  constructor(e) {
    super(e), e.animationState || (e.animationState = Ds(e));
  }
  updateAnimationControlsSubscription() {
    const { animate: e } = this.node.getProps();
    this.unmount(), St(e) && (this.unmount = e.subscribe(this.node));
  }
  /**
   * Subscribe any provided AnimationControls to the component's VisualElement
   */
  mount() {
    this.updateAnimationControlsSubscription();
  }
  update() {
    const { animate: e } = this.node.getProps(), { animate: i } = this.node.prevProps || {};
    e !== i && this.updateAnimationControlsSubscription();
  }
  unmount() {
  }
}
let Es = 0;
class Vs extends k {
  constructor() {
    super(...arguments), this.id = Es++;
  }
  update() {
    if (!this.node.presenceContext)
      return;
    const { isPresent: e, onExitComplete: i, custom: s } = this.node.presenceContext, { isPresent: r } = this.node.prevPresenceContext || {};
    if (!this.node.animationState || e === r)
      return;
    const u = this.node.animationState.setActive("exit", !e, { custom: s ?? this.node.getProps().custom });
    i && !e && u.then(() => i(this.id));
  }
  mount() {
    const { register: e } = this.node.presenceContext || {};
    e && (this.unmount = e(this.id));
  }
  unmount() {
  }
}
const bs = {
  animation: {
    Feature: Cs
  },
  exit: {
    Feature: Vs
  }
}, Ht = (t, e) => Math.abs(t - e);
function ws(t, e) {
  const i = Ht(t.x, e.x), s = Ht(t.y, e.y);
  return Math.sqrt(i ** 2 + s ** 2);
}
class Ne {
  constructor(e, i, { transformPagePoint: s, contextWindow: r } = {}) {
    if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => {
      if (!(this.lastMoveEvent && this.lastMoveEventInfo))
        return;
      const c = dt(this.lastMoveEventInfo, this.history), h = this.startEvent !== null, f = ws(c.offset, { x: 0, y: 0 }) >= 3;
      if (!h && !f)
        return;
      const { point: d } = c, { timestamp: m } = L;
      this.history.push({ ...d, timestamp: m });
      const { onStart: p, onMove: S } = this.handlers;
      h || (p && p(this.lastMoveEvent, c), this.startEvent = this.lastMoveEvent), S && S(this.lastMoveEvent, c);
    }, this.handlePointerMove = (c, h) => {
      this.lastMoveEvent = c, this.lastMoveEventInfo = ft(h, this.transformPagePoint), D.update(this.updatePoint, !0);
    }, this.handlePointerUp = (c, h) => {
      if (this.end(), !(this.lastMoveEvent && this.lastMoveEventInfo))
        return;
      const { onEnd: f, onSessionEnd: d } = this.handlers, m = dt(c.type === "pointercancel" ? this.lastMoveEventInfo : ft(h, this.transformPagePoint), this.history);
      this.startEvent && f && f(c, m), d && d(c, m);
    }, !Fe(e))
      return;
    this.handlers = i, this.transformPagePoint = s, this.contextWindow = r || window;
    const u = nt(e), n = ft(u, this.transformPagePoint), { point: o } = n, { timestamp: a } = L;
    this.history = [{ ...o, timestamp: a }];
    const { onSessionStart: l } = i;
    l && l(e, dt(n, this.history)), this.removeListeners = G(B(this.contextWindow, "pointermove", this.handlePointerMove), B(this.contextWindow, "pointerup", this.handlePointerUp), B(this.contextWindow, "pointercancel", this.handlePointerUp));
  }
  updateHandlers(e) {
    this.handlers = e;
  }
  end() {
    this.removeListeners && this.removeListeners(), K(this.updatePoint);
  }
}
function ft(t, e) {
  return e ? { point: e(t.point) } : t;
}
function Nt(t, e) {
  return { x: t.x - e.x, y: t.y - e.y };
}
function dt({ point: t }, e) {
  return {
    point: t,
    delta: Nt(t, We(e)),
    offset: Nt(t, Rs(e)),
    velocity: Ms(e, 0.1)
  };
}
function Rs(t) {
  return t[0];
}
function We(t) {
  return t[t.length - 1];
}
function Ms(t, e) {
  if (t.length < 2)
    return { x: 0, y: 0 };
  let i = t.length - 1, s = null;
  const r = We(t);
  for (; i >= 0 && (s = t[i], !(r.timestamp - s.timestamp > gi(e))); )
    i--;
  if (!s)
    return { x: 0, y: 0 };
  const u = yi(r.timestamp - s.timestamp);
  if (u === 0)
    return { x: 0, y: 0 };
  const n = {
    x: (r.x - s.x) / u,
    y: (r.y - s.y) / u
  };
  return n.x === 1 / 0 && (n.x = 0), n.y === 1 / 0 && (n.y = 0), n;
}
function E(t) {
  return t.max - t.min;
}
function Pt(t, e = 0, i = 0.01) {
  return Math.abs(t - e) <= i;
}
function Wt(t, e, i, s = 0.5) {
  t.origin = s, t.originPoint = T(e.min, e.max, t.origin), t.scale = E(i) / E(e), (Pt(t.scale, 1, 1e-4) || isNaN(t.scale)) && (t.scale = 1), t.translate = T(i.min, i.max, t.origin) - t.originPoint, (Pt(t.translate) || isNaN(t.translate)) && (t.translate = 0);
}
function _(t, e, i, s) {
  Wt(t.x, e.x, i.x, s ? s.originX : void 0), Wt(t.y, e.y, i.y, s ? s.originY : void 0);
}
function zt(t, e, i) {
  t.min = i.min + e.min, t.max = t.min + E(e);
}
function Bs(t, e, i) {
  zt(t.x, e.x, i.x), zt(t.y, e.y, i.y);
}
function _t(t, e, i) {
  t.min = e.min - i.min, t.max = t.min + E(e);
}
function $(t, e, i) {
  _t(t.x, e.x, i.x), _t(t.y, e.y, i.y);
}
function ks(t, { min: e, max: i }, s) {
  return e !== void 0 && t < e ? t = s ? T(e, t, s.min) : Math.max(t, e) : i !== void 0 && t > i && (t = s ? T(i, t, s.max) : Math.min(t, i)), t;
}
function $t(t, e, i) {
  return {
    min: e !== void 0 ? t.min + e : void 0,
    max: i !== void 0 ? t.max + i - (t.max - t.min) : void 0
  };
}
function js(t, { top: e, left: i, bottom: s, right: r }) {
  return {
    x: $t(t.x, i, r),
    y: $t(t.y, e, s)
  };
}
function Kt(t, e) {
  let i = e.min - t.min, s = e.max - t.max;
  return e.max - e.min < t.max - t.min && ([i, s] = [s, i]), { min: i, max: s };
}
function Fs(t, e) {
  return {
    x: Kt(t.x, e.x),
    y: Kt(t.y, e.y)
  };
}
function Is(t, e) {
  let i = 0.5;
  const s = E(t), r = E(e);
  return r > s ? i = gt(e.min, e.max - s, t.min) : s > r && (i = gt(t.min, t.max - r, e.min)), Ae(0, 1, i);
}
function Us(t, e) {
  const i = {};
  return e.min !== void 0 && (i.min = e.min - t.min), e.max !== void 0 && (i.max = e.max - t.min), i;
}
const xt = 0.35;
function Os(t = xt) {
  return t === !1 ? t = 0 : t === !0 && (t = xt), {
    x: Xt(t, "left", "right"),
    y: Xt(t, "top", "bottom")
  };
}
function Xt(t, e, i) {
  return {
    min: Yt(t, e),
    max: Yt(t, i)
  };
}
function Yt(t, e) {
  return typeof t == "number" ? t : t[e] || 0;
}
function b(t) {
  return [t("x"), t("y")];
}
const ze = ({ current: t }) => t ? t.ownerDocument.defaultView : null, Gs = /* @__PURE__ */ new WeakMap();
class Hs {
  constructor(e) {
    this.openGlobalLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = x(), this.visualElement = e;
  }
  start(e, { snapToCursor: i = !1 } = {}) {
    const { presenceContext: s } = this.visualElement;
    if (s && s.isPresent === !1)
      return;
    const r = (a) => {
      this.stopAnimation(), i && this.snapToCursor(nt(a, "page").point);
    }, u = (a, l) => {
      const { drag: c, dragPropagation: h, onDragStart: f } = this.getProps();
      if (c && !h && (this.openGlobalLock && this.openGlobalLock(), this.openGlobalLock = Ue(c), !this.openGlobalLock))
        return;
      this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), b((m) => {
        let p = this.getAxisMotionValue(m).get() || 0;
        if (Q.test(p)) {
          const { projection: S } = this.visualElement;
          if (S && S.layout) {
            const v = S.layout.layoutBox[m];
            v && (p = E(v) * (parseFloat(p) / 100));
          }
        }
        this.originPoint[m] = p;
      }), f && D.update(() => f(a, l), !1, !0);
      const { animationState: d } = this.visualElement;
      d && d.setActive("whileDrag", !0);
    }, n = (a, l) => {
      const { dragPropagation: c, dragDirectionLock: h, onDirectionLock: f, onDrag: d } = this.getProps();
      if (!c && !this.openGlobalLock)
        return;
      const { offset: m } = l;
      if (h && this.currentDirection === null) {
        this.currentDirection = Ns(m), this.currentDirection !== null && f && f(this.currentDirection);
        return;
      }
      this.updateAxis("x", l.point, m), this.updateAxis("y", l.point, m), this.visualElement.render(), d && d(a, l);
    }, o = (a, l) => this.stop(a, l);
    this.panSession = new Ne(e, {
      onSessionStart: r,
      onStart: u,
      onMove: n,
      onSessionEnd: o
    }, {
      transformPagePoint: this.visualElement.getTransformPagePoint(),
      contextWindow: ze(this.visualElement)
    });
  }
  stop(e, i) {
    const s = this.isDragging;
    if (this.cancel(), !s)
      return;
    const { velocity: r } = i;
    this.startAnimation(r);
    const { onDragEnd: u } = this.getProps();
    u && D.update(() => u(e, i));
  }
  cancel() {
    this.isDragging = !1;
    const { projection: e, animationState: i } = this.visualElement;
    e && (e.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0;
    const { dragPropagation: s } = this.getProps();
    !s && this.openGlobalLock && (this.openGlobalLock(), this.openGlobalLock = null), i && i.setActive("whileDrag", !1);
  }
  updateAxis(e, i, s) {
    const { drag: r } = this.getProps();
    if (!s || !q(e, r, this.currentDirection))
      return;
    const u = this.getAxisMotionValue(e);
    let n = this.originPoint[e] + s[e];
    this.constraints && this.constraints[e] && (n = ks(n, this.constraints[e], this.elastic[e])), u.set(n);
  }
  resolveConstraints() {
    var e;
    const { dragConstraints: i, dragElastic: s } = this.getProps(), r = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : (e = this.visualElement.projection) === null || e === void 0 ? void 0 : e.layout, u = this.constraints;
    i && z(i) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : i && r ? this.constraints = js(r.layoutBox, i) : this.constraints = !1, this.elastic = Os(s), u !== this.constraints && r && this.constraints && !this.hasMutatedConstraints && b((n) => {
      this.getAxisMotionValue(n) && (this.constraints[n] = Us(r.layoutBox[n], this.constraints[n]));
    });
  }
  resolveRefConstraints() {
    const { dragConstraints: e, onMeasureDragConstraints: i } = this.getProps();
    if (!e || !z(e))
      return !1;
    const s = e.current;
    vi(s !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
    const { projection: r } = this.visualElement;
    if (!r || !r.layout)
      return !1;
    const u = Pi(s, r.root, this.visualElement.getTransformPagePoint());
    let n = Fs(r.layout.layoutBox, u);
    if (i) {
      const o = i(xi(n));
      this.hasMutatedConstraints = !!o, o && (n = Si(o));
    }
    return n;
  }
  startAnimation(e) {
    const { drag: i, dragMomentum: s, dragElastic: r, dragTransition: u, dragSnapToOrigin: n, onDragTransitionEnd: o } = this.getProps(), a = this.constraints || {}, l = b((c) => {
      if (!q(c, i, this.currentDirection))
        return;
      let h = a && a[c] || {};
      n && (h = { min: 0, max: 0 });
      const f = r ? 200 : 1e6, d = r ? 40 : 1e7, m = {
        type: "inertia",
        velocity: s ? e[c] : 0,
        bounceStiffness: f,
        bounceDamping: d,
        timeConstant: 750,
        restDelta: 1,
        restSpeed: 10,
        ...u,
        ...h
      };
      return this.startAxisValueAnimation(c, m);
    });
    return Promise.all(l).then(o);
  }
  startAxisValueAnimation(e, i) {
    const s = this.getAxisMotionValue(e);
    return s.start(Ti(e, s, 0, i));
  }
  stopAnimation() {
    b((e) => this.getAxisMotionValue(e).stop());
  }
  /**
   * Drag works differently depending on which props are provided.
   *
   * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
   * - Otherwise, we apply the delta to the x/y motion values.
   */
  getAxisMotionValue(e) {
    const i = "_drag" + e.toUpperCase(), s = this.visualElement.getProps(), r = s[i];
    return r || this.visualElement.getValue(e, (s.initial ? s.initial[e] : void 0) || 0);
  }
  snapToCursor(e) {
    b((i) => {
      const { drag: s } = this.getProps();
      if (!q(i, s, this.currentDirection))
        return;
      const { projection: r } = this.visualElement, u = this.getAxisMotionValue(i);
      if (r && r.layout) {
        const { min: n, max: o } = r.layout.layoutBox[i];
        u.set(e[i] - T(n, o, 0.5));
      }
    });
  }
  /**
   * When the viewport resizes we want to check if the measured constraints
   * have changed and, if so, reposition the element within those new constraints
   * relative to where it was before the resize.
   */
  scalePositionWithinConstraints() {
    if (!this.visualElement.current)
      return;
    const { drag: e, dragConstraints: i } = this.getProps(), { projection: s } = this.visualElement;
    if (!z(i) || !s || !this.constraints)
      return;
    this.stopAnimation();
    const r = { x: 0, y: 0 };
    b((n) => {
      const o = this.getAxisMotionValue(n);
      if (o) {
        const a = o.get();
        r[n] = Is({ min: a, max: a }, this.constraints[n]);
      }
    });
    const { transformTemplate: u } = this.visualElement.getProps();
    this.visualElement.current.style.transform = u ? u({}, "") : "none", s.root && s.root.updateScroll(), s.updateLayout(), this.resolveConstraints(), b((n) => {
      if (!q(n, e, null))
        return;
      const o = this.getAxisMotionValue(n), { min: a, max: l } = this.constraints[n];
      o.set(T(a, l, r[n]));
    });
  }
  addListeners() {
    if (!this.visualElement.current)
      return;
    Gs.set(this.visualElement, this);
    const e = this.visualElement.current, i = B(e, "pointerdown", (a) => {
      const { drag: l, dragListener: c = !0 } = this.getProps();
      l && c && this.start(a);
    }), s = () => {
      const { dragConstraints: a } = this.getProps();
      z(a) && (this.constraints = this.resolveRefConstraints());
    }, { projection: r } = this.visualElement, u = r.addEventListener("measure", s);
    r && !r.layout && (r.root && r.root.updateScroll(), r.updateLayout()), s();
    const n = R(window, "resize", () => this.scalePositionWithinConstraints()), o = r.addEventListener("didUpdate", ({ delta: a, hasLayoutChanged: l }) => {
      this.isDragging && l && (b((c) => {
        const h = this.getAxisMotionValue(c);
        h && (this.originPoint[c] += a[c].translate, h.set(h.get() + a[c].translate));
      }), this.visualElement.render());
    });
    return () => {
      n(), i(), u(), o && o();
    };
  }
  getProps() {
    const e = this.visualElement.getProps(), { drag: i = !1, dragDirectionLock: s = !1, dragPropagation: r = !1, dragConstraints: u = !1, dragElastic: n = xt, dragMomentum: o = !0 } = e;
    return {
      ...e,
      drag: i,
      dragDirectionLock: s,
      dragPropagation: r,
      dragConstraints: u,
      dragElastic: n,
      dragMomentum: o
    };
  }
}
function q(t, e, i) {
  return (e === !0 || e === t) && (i === null || i === t);
}
function Ns(t, e = 10) {
  let i = null;
  return Math.abs(t.y) > e ? i = "y" : Math.abs(t.x) > e && (i = "x"), i;
}
class Ws extends k {
  constructor(e) {
    super(e), this.removeGroupControls = M, this.removeListeners = M, this.controls = new Hs(e);
  }
  mount() {
    const { dragControls: e } = this.node.getProps();
    e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || M;
  }
  unmount() {
    this.removeGroupControls(), this.removeListeners();
  }
}
const qt = (t) => (e, i) => {
  t && D.update(() => t(e, i));
};
class zs extends k {
  constructor() {
    super(...arguments), this.removePointerDownListener = M;
  }
  onPointerDown(e) {
    this.session = new Ne(e, this.createPanHandlers(), {
      transformPagePoint: this.node.getTransformPagePoint(),
      contextWindow: ze(this.node)
    });
  }
  createPanHandlers() {
    const { onPanSessionStart: e, onPanStart: i, onPan: s, onPanEnd: r } = this.node.getProps();
    return {
      onSessionStart: qt(e),
      onStart: qt(i),
      onMove: s,
      onEnd: (u, n) => {
        delete this.session, r && D.update(() => r(u, n));
      }
    };
  }
  mount() {
    this.removePointerDownListener = B(this.node.current, "pointerdown", (e) => this.onPointerDown(e));
  }
  update() {
    this.session && this.session.updateHandlers(this.createPanHandlers());
  }
  unmount() {
    this.removePointerDownListener(), this.session && this.session.end();
  }
}
const J = {
  /**
   * Global flag as to whether the tree has animated since the last time
   * we resized the window
   */
  hasAnimatedSinceResize: !0,
  /**
   * We set this to true once, on the first update. Any nodes added to the tree beyond that
   * update will be given a `data-projection-id` attribute.
   */
  hasEverUpdated: !1
};
function Zt(t, e) {
  return e.max === e.min ? 0 : t / (e.max - e.min) * 100;
}
const W = {
  correct: (t, e) => {
    if (!e.target)
      return t;
    if (typeof t == "string")
      if (Le.test(t))
        t = parseFloat(t);
      else
        return t;
    const i = Zt(t, e.target.x), s = Zt(t, e.target.y);
    return `${i}% ${s}%`;
  }
}, _s = {
  correct: (t, { treeScale: e, projectionDelta: i }) => {
    const s = t, r = Bt.parse(t);
    if (r.length > 5)
      return s;
    const u = Bt.createTransformer(t), n = typeof r[0] != "number" ? 1 : 0, o = i.x.scale * e.x, a = i.y.scale * e.y;
    r[0 + n] /= o, r[1 + n] /= a;
    const l = T(o, a, 0.5);
    return typeof r[2 + n] == "number" && (r[2 + n] /= l), typeof r[3 + n] == "number" && (r[3 + n] /= l), u(r);
  }
};
class $s extends ye.Component {
  /**
   * This only mounts projection nodes for components that
   * need measuring, we might want to do it for all components
   * in order to incorporate transforms
   */
  componentDidMount() {
    const { visualElement: e, layoutGroup: i, switchLayoutGroup: s, layoutId: r } = this.props, { projection: u } = e;
    Di(Ks), u && (i.group && i.group.add(u), s && s.register && r && s.register(u), u.root.didUpdate(), u.addEventListener("animationComplete", () => {
      this.safeToRemove();
    }), u.setOptions({
      ...u.options,
      onExitComplete: () => this.safeToRemove()
    })), J.hasEverUpdated = !0;
  }
  getSnapshotBeforeUpdate(e) {
    const { layoutDependency: i, visualElement: s, drag: r, isPresent: u } = this.props, n = s.projection;
    return n && (n.isPresent = u, r || e.layoutDependency !== i || i === void 0 ? n.willUpdate() : this.safeToRemove(), e.isPresent !== u && (u ? n.promote() : n.relegate() || D.postRender(() => {
      const o = n.getStack();
      (!o || !o.members.length) && this.safeToRemove();
    }))), null;
  }
  componentDidUpdate() {
    const { projection: e } = this.props.visualElement;
    e && (e.root.didUpdate(), queueMicrotask(() => {
      !e.currentAnimation && e.isLead() && this.safeToRemove();
    }));
  }
  componentWillUnmount() {
    const { visualElement: e, layoutGroup: i, switchLayoutGroup: s } = this.props, { projection: r } = e;
    r && (r.scheduleCheckAfterUnmount(), i && i.group && i.group.remove(r), s && s.deregister && s.deregister(r));
  }
  safeToRemove() {
    const { safeToRemove: e } = this.props;
    e && e();
  }
  render() {
    return null;
  }
}
function _e(t) {
  const [e, i] = Ai(), s = C(Ve);
  return ye.createElement($s, { ...t, layoutGroup: s, switchLayoutGroup: C(Re), isPresent: e, safeToRemove: i });
}
const Ks = {
  borderRadius: {
    ...W,
    applyTo: [
      "borderTopLeftRadius",
      "borderTopRightRadius",
      "borderBottomLeftRadius",
      "borderBottomRightRadius"
    ]
  },
  borderTopLeftRadius: W,
  borderTopRightRadius: W,
  borderBottomLeftRadius: W,
  borderBottomRightRadius: W,
  boxShadow: _s
}, $e = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], Xs = $e.length, Jt = (t) => typeof t == "string" ? parseFloat(t) : t, Qt = (t) => typeof t == "number" || Le.test(t);
function Ys(t, e, i, s, r, u) {
  r ? (t.opacity = T(
    0,
    // TODO Reinstate this if only child
    i.opacity !== void 0 ? i.opacity : 1,
    qs(s)
  ), t.opacityExit = T(e.opacity !== void 0 ? e.opacity : 1, 0, Zs(s))) : u && (t.opacity = T(e.opacity !== void 0 ? e.opacity : 1, i.opacity !== void 0 ? i.opacity : 1, s));
  for (let n = 0; n < Xs; n++) {
    const o = `border${$e[n]}Radius`;
    let a = te(e, o), l = te(i, o);
    if (a === void 0 && l === void 0)
      continue;
    a || (a = 0), l || (l = 0), a === 0 || l === 0 || Qt(a) === Qt(l) ? (t[o] = Math.max(T(Jt(a), Jt(l), s), 0), (Q.test(l) || Q.test(a)) && (t[o] += "%")) : t[o] = l;
  }
  (e.rotate || i.rotate) && (t.rotate = T(e.rotate || 0, i.rotate || 0, s));
}
function te(t, e) {
  return t[e] !== void 0 ? t[e] : t.borderRadius;
}
const qs = Ke(0, 0.5, Li), Zs = Ke(0.5, 0.95, M);
function Ke(t, e, i) {
  return (s) => s < t ? 0 : s > e ? 1 : i(gt(t, e, s));
}
function ee(t, e) {
  t.min = e.min, t.max = e.max;
}
function V(t, e) {
  ee(t.x, e.x), ee(t.y, e.y);
}
function ie(t, e, i, s, r) {
  return t -= e, t = kt(t, 1 / i, s), r !== void 0 && (t = kt(t, 1 / r, s)), t;
}
function Js(t, e = 0, i = 1, s = 0.5, r, u = t, n = t) {
  if (Q.test(e) && (e = parseFloat(e), e = T(n.min, n.max, e / 100) - n.min), typeof e != "number")
    return;
  let o = T(u.min, u.max, s);
  t === u && (o -= e), t.min = ie(t.min, e, i, o, r), t.max = ie(t.max, e, i, o, r);
}
function se(t, e, [i, s, r], u, n) {
  Js(t, e[i], e[s], e[r], e.scale, u, n);
}
const Qs = ["x", "scaleX", "originX"], tn = ["y", "scaleY", "originY"];
function ne(t, e, i, s) {
  se(t.x, e, Qs, i ? i.x : void 0, s ? s.x : void 0), se(t.y, e, tn, i ? i.y : void 0, s ? s.y : void 0);
}
function oe(t) {
  return t.translate === 0 && t.scale === 1;
}
function Xe(t) {
  return oe(t.x) && oe(t.y);
}
function en(t, e) {
  return t.x.min === e.x.min && t.x.max === e.x.max && t.y.min === e.y.min && t.y.max === e.y.max;
}
function Ye(t, e) {
  return Math.round(t.x.min) === Math.round(e.x.min) && Math.round(t.x.max) === Math.round(e.x.max) && Math.round(t.y.min) === Math.round(e.y.min) && Math.round(t.y.max) === Math.round(e.y.max);
}
function re(t) {
  return E(t.x) / E(t.y);
}
class sn {
  constructor() {
    this.members = [];
  }
  add(e) {
    Ce(this.members, e), e.scheduleRender();
  }
  remove(e) {
    if (Ee(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) {
      const i = this.members[this.members.length - 1];
      i && this.promote(i);
    }
  }
  relegate(e) {
    const i = this.members.findIndex((r) => e === r);
    if (i === 0)
      return !1;
    let s;
    for (let r = i; r >= 0; r--) {
      const u = this.members[r];
      if (u.isPresent !== !1) {
        s = u;
        break;
      }
    }
    return s ? (this.promote(s), !0) : !1;
  }
  promote(e, i) {
    const s = this.lead;
    if (e !== s && (this.prevLead = s, this.lead = e, e.show(), s)) {
      s.instance && s.scheduleRender(), e.scheduleRender(), e.resumeFrom = s, i && (e.resumeFrom.preserveOpacity = !0), s.snapshot && (e.snapshot = s.snapshot, e.snapshot.latestValues = s.animationValues || s.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0);
      const { crossfade: r } = e.options;
      r === !1 && s.hide();
    }
  }
  exitAnimationComplete() {
    this.members.forEach((e) => {
      const { options: i, resumingFrom: s } = e;
      i.onExitComplete && i.onExitComplete(), s && s.options.onExitComplete && s.options.onExitComplete();
    });
  }
  scheduleRender() {
    this.members.forEach((e) => {
      e.instance && e.scheduleRender(!1);
    });
  }
  /**
   * Clear any leads that have been removed this render to prevent them from being
   * used in future animations and to prevent memory leaks
   */
  removeLeadSnapshot() {
    this.lead && this.lead.snapshot && (this.lead.snapshot = void 0);
  }
}
function ae(t, e, i) {
  let s = "";
  const r = t.x.translate / e.x, u = t.y.translate / e.y;
  if ((r || u) && (s = `translate3d(${r}px, ${u}px, 0) `), (e.x !== 1 || e.y !== 1) && (s += `scale(${1 / e.x}, ${1 / e.y}) `), i) {
    const { rotate: a, rotateX: l, rotateY: c } = i;
    a && (s += `rotate(${a}deg) `), l && (s += `rotateX(${l}deg) `), c && (s += `rotateY(${c}deg) `);
  }
  const n = t.x.scale * e.x, o = t.y.scale * e.y;
  return (n !== 1 || o !== 1) && (s += `scale(${n}, ${o})`), s || "none";
}
const nn = (t, e) => t.depth - e.depth;
class on {
  constructor() {
    this.children = [], this.isDirty = !1;
  }
  add(e) {
    Ce(this.children, e), this.isDirty = !0;
  }
  remove(e) {
    Ee(this.children, e), this.isDirty = !0;
  }
  forEach(e) {
    this.isDirty && this.children.sort(nn), this.isDirty = !1, this.children.forEach(e);
  }
}
function rn(t, e) {
  const i = performance.now(), s = ({ timestamp: r }) => {
    const u = r - i;
    u >= e && (K(s), t(u - e));
  };
  return D.read(s, !0), () => K(s);
}
function an(t) {
  window.MotionDebug && window.MotionDebug.record(t);
}
const le = ["", "X", "Y", "Z"], ln = { visibility: "hidden" }, ce = 1e3;
let cn = 0;
const F = {
  type: "projectionFrame",
  totalNodes: 0,
  resolvedTargetDeltas: 0,
  recalculatedProjection: 0
};
function qe({ attachResizeListener: t, defaultParent: e, measureScroll: i, checkIsScrollRoot: s, resetTransform: r }) {
  return class {
    constructor(n = {}, o = e == null ? void 0 : e()) {
      this.id = cn++, this.animationId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.updateScheduled = !1, this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => {
        this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots());
      }, this.updateProjection = () => {
        this.projectionUpdateScheduled = !1, F.totalNodes = F.resolvedTargetDeltas = F.recalculatedProjection = 0, this.nodes.forEach(fn), this.nodes.forEach(yn), this.nodes.forEach(vn), this.nodes.forEach(dn), an(F);
      }, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = n, this.root = o ? o.root || o : this, this.path = o ? [...o.path, o] : [], this.parent = o, this.depth = o ? o.depth + 1 : 0;
      for (let a = 0; a < this.path.length; a++)
        this.path[a].shouldResetTransform = !0;
      this.root === this && (this.nodes = new on());
    }
    addEventListener(n, o) {
      return this.eventHandlers.has(n) || this.eventHandlers.set(n, new Ci()), this.eventHandlers.get(n).add(o);
    }
    notifyListeners(n, ...o) {
      const a = this.eventHandlers.get(n);
      a && a.notify(...o);
    }
    hasListeners(n) {
      return this.eventHandlers.has(n);
    }
    /**
     * Lifecycles
     */
    mount(n, o = this.root.hasTreeAnimated) {
      if (this.instance)
        return;
      this.isSVG = Ei(n), this.instance = n;
      const { layoutId: a, layout: l, visualElement: c } = this.options;
      if (c && !c.current && c.mount(n), this.root.nodes.add(this), this.parent && this.parent.children.add(this), o && (l || a) && (this.isLayoutDirty = !0), t) {
        let h;
        const f = () => this.root.updateBlockedByResize = !1;
        t(n, () => {
          this.root.updateBlockedByResize = !0, h && h(), h = rn(f, 250), J.hasAnimatedSinceResize && (J.hasAnimatedSinceResize = !1, this.nodes.forEach(he));
        });
      }
      a && this.root.registerSharedNode(a, this), this.options.animate !== !1 && c && (a || l) && this.addEventListener("didUpdate", ({ delta: h, hasLayoutChanged: f, hasRelativeTargetChanged: d, layout: m }) => {
        if (this.isTreeAnimationBlocked()) {
          this.target = void 0, this.relativeTarget = void 0;
          return;
        }
        const p = this.options.transition || c.getDefaultTransition() || Dn, { onLayoutAnimationStart: S, onLayoutAnimationComplete: v } = c.getProps(), y = !this.targetLayout || !Ye(this.targetLayout, m) || d, g = !f && d;
        if (this.options.layoutRoot || this.resumeFrom && this.resumeFrom.instance || g || f && (y || !this.currentAnimation)) {
          this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0), this.setAnimationOrigin(h, g);
          const P = {
            ...Vi(p, "layout"),
            onPlay: S,
            onComplete: v
          };
          (c.shouldReduceMotion || this.options.layoutRoot) && (P.delay = 0, P.type = !1), this.startAnimation(P);
        } else
          f || he(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete();
        this.targetLayout = m;
      });
    }
    unmount() {
      this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this);
      const n = this.getStack();
      n && n.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, K(this.updateProjection);
    }
    // only on the root
    blockUpdate() {
      this.updateManuallyBlocked = !0;
    }
    unblockUpdate() {
      this.updateManuallyBlocked = !1;
    }
    isUpdateBlocked() {
      return this.updateManuallyBlocked || this.updateBlockedByResize;
    }
    isTreeAnimationBlocked() {
      return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1;
    }
    // Note: currently only running on root node
    startUpdate() {
      this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(Pn), this.animationId++);
    }
    getTransformTemplate() {
      const { visualElement: n } = this.options;
      return n && n.getProps().transformTemplate;
    }
    willUpdate(n = !0) {
      if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) {
        this.options.onExitComplete && this.options.onExitComplete();
        return;
      }
      if (!this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty)
        return;
      this.isLayoutDirty = !0;
      for (let c = 0; c < this.path.length; c++) {
        const h = this.path[c];
        h.shouldResetTransform = !0, h.updateScroll("snapshot"), h.options.layoutRoot && h.willUpdate(!1);
      }
      const { layoutId: o, layout: a } = this.options;
      if (o === void 0 && !a)
        return;
      const l = this.getTransformTemplate();
      this.prevTransformTemplateValue = l ? l(this.latestValues, "") : void 0, this.updateSnapshot(), n && this.notifyListeners("willUpdate");
    }
    update() {
      if (this.updateScheduled = !1, this.isUpdateBlocked()) {
        this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(ue);
        return;
      }
      this.isUpdating || this.nodes.forEach(pn), this.isUpdating = !1, this.nodes.forEach(gn), this.nodes.forEach(un), this.nodes.forEach(hn), this.clearAllSnapshots();
      const o = performance.now();
      L.delta = Ae(0, 1e3 / 60, o - L.timestamp), L.timestamp = o, L.isProcessing = !0, ct.update.process(L), ct.preRender.process(L), ct.render.process(L), L.isProcessing = !1;
    }
    didUpdate() {
      this.updateScheduled || (this.updateScheduled = !0, queueMicrotask(() => this.update()));
    }
    clearAllSnapshots() {
      this.nodes.forEach(mn), this.sharedNodes.forEach(xn);
    }
    scheduleUpdateProjection() {
      this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, D.preRender(this.updateProjection, !1, !0));
    }
    scheduleCheckAfterUnmount() {
      D.postRender(() => {
        this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed();
      });
    }
    /**
     * Update measurements
     */
    updateSnapshot() {
      this.snapshot || !this.instance || (this.snapshot = this.measure());
    }
    updateLayout() {
      if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty))
        return;
      if (this.resumeFrom && !this.resumeFrom.instance)
        for (let a = 0; a < this.path.length; a++)
          this.path[a].updateScroll();
      const n = this.layout;
      this.layout = this.measure(!1), this.layoutCorrected = x(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox);
      const { visualElement: o } = this.options;
      o && o.notify("LayoutMeasure", this.layout.layoutBox, n ? n.layoutBox : void 0);
    }
    updateScroll(n = "measure") {
      let o = !!(this.options.layoutScroll && this.instance);
      this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === n && (o = !1), o && (this.scroll = {
        animationId: this.root.animationId,
        phase: n,
        isRoot: s(this.instance),
        offset: i(this.instance)
      });
    }
    resetTransform() {
      if (!r)
        return;
      const n = this.isLayoutDirty || this.shouldResetTransform, o = this.projectionDelta && !Xe(this.projectionDelta), a = this.getTransformTemplate(), l = a ? a(this.latestValues, "") : void 0, c = l !== this.prevTransformTemplateValue;
      n && (o || I(this.latestValues) || c) && (r(this.instance, l), this.shouldResetTransform = !1, this.scheduleRender());
    }
    measure(n = !0) {
      const o = this.measurePageBox();
      let a = this.removeElementScroll(o);
      return n && (a = this.removeTransform(a)), An(a), {
        animationId: this.root.animationId,
        measuredBox: o,
        layoutBox: a,
        latestValues: {},
        source: this.id
      };
    }
    measurePageBox() {
      const { visualElement: n } = this.options;
      if (!n)
        return x();
      const o = n.measureViewportBox(), { scroll: a } = this.root;
      return a && (U(o.x, a.offset.x), U(o.y, a.offset.y)), o;
    }
    removeElementScroll(n) {
      const o = x();
      V(o, n);
      for (let a = 0; a < this.path.length; a++) {
        const l = this.path[a], { scroll: c, options: h } = l;
        if (l !== this.root && c && h.layoutScroll) {
          if (c.isRoot) {
            V(o, n);
            const { scroll: f } = this.root;
            f && (U(o.x, -f.offset.x), U(o.y, -f.offset.y));
          }
          U(o.x, c.offset.x), U(o.y, c.offset.y);
        }
      }
      return o;
    }
    applyTransform(n, o = !1) {
      const a = x();
      V(a, n);
      for (let l = 0; l < this.path.length; l++) {
        const c = this.path[l];
        !o && c.options.layoutScroll && c.scroll && c !== c.root && Y(a, {
          x: -c.scroll.offset.x,
          y: -c.scroll.offset.y
        }), I(c.latestValues) && Y(a, c.latestValues);
      }
      return I(this.latestValues) && Y(a, this.latestValues), a;
    }
    removeTransform(n) {
      const o = x();
      V(o, n);
      for (let a = 0; a < this.path.length; a++) {
        const l = this.path[a];
        if (!l.instance || !I(l.latestValues))
          continue;
        jt(l.latestValues) && l.updateSnapshot();
        const c = x(), h = l.measurePageBox();
        V(c, h), ne(o, l.latestValues, l.snapshot ? l.snapshot.layoutBox : void 0, c);
      }
      return I(this.latestValues) && ne(o, this.latestValues), o;
    }
    setTargetDelta(n) {
      this.targetDelta = n, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0;
    }
    setOptions(n) {
      this.options = {
        ...this.options,
        ...n,
        crossfade: n.crossfade !== void 0 ? n.crossfade : !0
      };
    }
    clearMeasurements() {
      this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1;
    }
    forceRelativeParentToResolveTarget() {
      this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== L.timestamp && this.relativeParent.resolveTargetDelta(!0);
    }
    resolveTargetDelta(n = !1) {
      var o;
      const a = this.getLead();
      this.isProjectionDirty || (this.isProjectionDirty = a.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = a.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = a.isSharedProjectionDirty);
      const l = !!this.resumingFrom || this !== a;
      if (!(n || l && this.isSharedProjectionDirty || this.isProjectionDirty || !((o = this.parent) === null || o === void 0) && o.isProjectionDirty || this.attemptToResolveRelativeTarget))
        return;
      const { layout: h, layoutId: f } = this.options;
      if (!(!this.layout || !(h || f))) {
        if (this.resolvedRelativeTargetAt = L.timestamp, !this.targetDelta && !this.relativeTarget) {
          const d = this.getClosestProjectingParent();
          d && d.layout && this.animationProgress !== 1 ? (this.relativeParent = d, this.forceRelativeParentToResolveTarget(), this.relativeTarget = x(), this.relativeTargetOrigin = x(), $(this.relativeTargetOrigin, this.layout.layoutBox, d.layout.layoutBox), V(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
        }
        if (!(!this.relativeTarget && !this.targetDelta)) {
          if (this.target || (this.target = x(), this.targetWithTransforms = x()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), Bs(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : V(this.target, this.layout.layoutBox), bi(this.target, this.targetDelta)) : V(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget) {
            this.attemptToResolveRelativeTarget = !1;
            const d = this.getClosestProjectingParent();
            d && !!d.resumingFrom == !!this.resumingFrom && !d.options.layoutScroll && d.target && this.animationProgress !== 1 ? (this.relativeParent = d, this.forceRelativeParentToResolveTarget(), this.relativeTarget = x(), this.relativeTargetOrigin = x(), $(this.relativeTargetOrigin, this.target, d.target), V(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
          }
          F.resolvedTargetDeltas++;
        }
      }
    }
    getClosestProjectingParent() {
      if (!(!this.parent || jt(this.parent.latestValues) || wi(this.parent.latestValues)))
        return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent();
    }
    isProjecting() {
      return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
    }
    calcProjection() {
      var n;
      const o = this.getLead(), a = !!this.resumingFrom || this !== o;
      let l = !0;
      if ((this.isProjectionDirty || !((n = this.parent) === null || n === void 0) && n.isProjectionDirty) && (l = !1), a && (this.isSharedProjectionDirty || this.isTransformDirty) && (l = !1), this.resolvedRelativeTargetAt === L.timestamp && (l = !1), l)
        return;
      const { layout: c, layoutId: h } = this.options;
      if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(c || h))
        return;
      V(this.layoutCorrected, this.layout.layoutBox);
      const f = this.treeScale.x, d = this.treeScale.y;
      Ri(this.layoutCorrected, this.treeScale, this.path, a), o.layout && !o.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (o.target = o.layout.layoutBox);
      const { target: m } = o;
      if (!m) {
        this.projectionTransform && (this.projectionDelta = O(), this.projectionTransform = "none", this.scheduleRender());
        return;
      }
      this.projectionDelta || (this.projectionDelta = O(), this.projectionDeltaWithTransform = O());
      const p = this.projectionTransform;
      _(this.projectionDelta, this.layoutCorrected, m, this.latestValues), this.projectionTransform = ae(this.projectionDelta, this.treeScale), (this.projectionTransform !== p || this.treeScale.x !== f || this.treeScale.y !== d) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", m)), F.recalculatedProjection++;
    }
    hide() {
      this.isVisible = !1;
    }
    show() {
      this.isVisible = !0;
    }
    scheduleRender(n = !0) {
      if (this.options.scheduleRender && this.options.scheduleRender(), n) {
        const o = this.getStack();
        o && o.scheduleRender();
      }
      this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0);
    }
    setAnimationOrigin(n, o = !1) {
      const a = this.snapshot, l = a ? a.latestValues : {}, c = { ...this.latestValues }, h = O();
      (!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !o;
      const f = x(), d = a ? a.source : void 0, m = this.layout ? this.layout.source : void 0, p = d !== m, S = this.getStack(), v = !S || S.members.length <= 1, y = !!(p && !v && this.options.crossfade === !0 && !this.path.some(Sn));
      this.animationProgress = 0;
      let g;
      this.mixTargetDelta = (P) => {
        const w = P / 1e3;
        fe(h.x, n.x, w), fe(h.y, n.y, w), this.setTargetDelta(h), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && ($(f, this.layout.layoutBox, this.relativeParent.layout.layoutBox), Tn(this.relativeTarget, this.relativeTargetOrigin, f, w), g && en(this.relativeTarget, g) && (this.isProjectionDirty = !1), g || (g = x()), V(g, this.relativeTarget)), p && (this.animationValues = c, Ys(c, l, this.latestValues, w, y, v)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = w;
      }, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
    }
    startAnimation(n) {
      this.notifyListeners("animationStart"), this.currentAnimation && this.currentAnimation.stop(), this.resumingFrom && this.resumingFrom.currentAnimation && this.resumingFrom.currentAnimation.stop(), this.pendingAnimation && (K(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = D.update(() => {
        J.hasAnimatedSinceResize = !0, this.currentAnimation = Mi(0, ce, {
          ...n,
          onUpdate: (o) => {
            this.mixTargetDelta(o), n.onUpdate && n.onUpdate(o);
          },
          onComplete: () => {
            n.onComplete && n.onComplete(), this.completeAnimation();
          }
        }), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0;
      });
    }
    completeAnimation() {
      this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0);
      const n = this.getStack();
      n && n.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete");
    }
    finishAnimation() {
      this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(ce), this.currentAnimation.stop()), this.completeAnimation();
    }
    applyTransformsToTarget() {
      const n = this.getLead();
      let { targetWithTransforms: o, target: a, layout: l, latestValues: c } = n;
      if (!(!o || !a || !l)) {
        if (this !== n && this.layout && l && Ze(this.options.animationType, this.layout.layoutBox, l.layoutBox)) {
          a = this.target || x();
          const h = E(this.layout.layoutBox.x);
          a.x.min = n.target.x.min, a.x.max = a.x.min + h;
          const f = E(this.layout.layoutBox.y);
          a.y.min = n.target.y.min, a.y.max = a.y.min + f;
        }
        V(o, a), Y(o, c), _(this.projectionDeltaWithTransform, this.layoutCorrected, o, c);
      }
    }
    registerSharedNode(n, o) {
      this.sharedNodes.has(n) || this.sharedNodes.set(n, new sn()), this.sharedNodes.get(n).add(o);
      const l = o.options.initialPromotionConfig;
      o.promote({
        transition: l ? l.transition : void 0,
        preserveFollowOpacity: l && l.shouldPreserveFollowOpacity ? l.shouldPreserveFollowOpacity(o) : void 0
      });
    }
    isLead() {
      const n = this.getStack();
      return n ? n.lead === this : !0;
    }
    getLead() {
      var n;
      const { layoutId: o } = this.options;
      return o ? ((n = this.getStack()) === null || n === void 0 ? void 0 : n.lead) || this : this;
    }
    getPrevLead() {
      var n;
      const { layoutId: o } = this.options;
      return o ? (n = this.getStack()) === null || n === void 0 ? void 0 : n.prevLead : void 0;
    }
    getStack() {
      const { layoutId: n } = this.options;
      if (n)
        return this.root.sharedNodes.get(n);
    }
    promote({ needsReset: n, transition: o, preserveFollowOpacity: a } = {}) {
      const l = this.getStack();
      l && l.promote(this, a), n && (this.projectionDelta = void 0, this.needsReset = !0), o && this.setOptions({ transition: o });
    }
    relegate() {
      const n = this.getStack();
      return n ? n.relegate(this) : !1;
    }
    resetRotation() {
      const { visualElement: n } = this.options;
      if (!n)
        return;
      let o = !1;
      const { latestValues: a } = n;
      if ((a.rotate || a.rotateX || a.rotateY || a.rotateZ) && (o = !0), !o)
        return;
      const l = {};
      for (let c = 0; c < le.length; c++) {
        const h = "rotate" + le[c];
        a[h] && (l[h] = a[h], n.setStaticValue(h, 0));
      }
      n.render();
      for (const c in l)
        n.setStaticValue(c, l[c]);
      n.scheduleRender();
    }
    getProjectionStyles(n) {
      var o, a;
      if (!this.instance || this.isSVG)
        return;
      if (!this.isVisible)
        return ln;
      const l = {
        visibility: ""
      }, c = this.getTransformTemplate();
      if (this.needsReset)
        return this.needsReset = !1, l.opacity = "", l.pointerEvents = Z(n == null ? void 0 : n.pointerEvents) || "", l.transform = c ? c(this.latestValues, "") : "none", l;
      const h = this.getLead();
      if (!this.projectionDelta || !this.layout || !h.target) {
        const p = {};
        return this.options.layoutId && (p.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, p.pointerEvents = Z(n == null ? void 0 : n.pointerEvents) || ""), this.hasProjected && !I(this.latestValues) && (p.transform = c ? c({}, "") : "none", this.hasProjected = !1), p;
      }
      const f = h.animationValues || h.latestValues;
      this.applyTransformsToTarget(), l.transform = ae(this.projectionDeltaWithTransform, this.treeScale, f), c && (l.transform = c(f, l.transform));
      const { x: d, y: m } = this.projectionDelta;
      l.transformOrigin = `${d.origin * 100}% ${m.origin * 100}% 0`, h.animationValues ? l.opacity = h === this ? (a = (o = f.opacity) !== null && o !== void 0 ? o : this.latestValues.opacity) !== null && a !== void 0 ? a : 1 : this.preserveOpacity ? this.latestValues.opacity : f.opacityExit : l.opacity = h === this ? f.opacity !== void 0 ? f.opacity : "" : f.opacityExit !== void 0 ? f.opacityExit : 0;
      for (const p in Ft) {
        if (f[p] === void 0)
          continue;
        const { correct: S, applyTo: v } = Ft[p], y = l.transform === "none" ? f[p] : S(f[p], h);
        if (v) {
          const g = v.length;
          for (let P = 0; P < g; P++)
            l[v[P]] = y;
        } else
          l[p] = y;
      }
      return this.options.layoutId && (l.pointerEvents = h === this ? Z(n == null ? void 0 : n.pointerEvents) || "" : "none"), l;
    }
    clearSnapshot() {
      this.resumeFrom = this.snapshot = void 0;
    }
    // Only run on root
    resetTree() {
      this.root.nodes.forEach((n) => {
        var o;
        return (o = n.currentAnimation) === null || o === void 0 ? void 0 : o.stop();
      }), this.root.nodes.forEach(ue), this.root.sharedNodes.clear();
    }
  };
}
function un(t) {
  t.updateLayout();
}
function hn(t) {
  var e;
  const i = ((e = t.resumeFrom) === null || e === void 0 ? void 0 : e.snapshot) || t.snapshot;
  if (t.isLead() && t.layout && i && t.hasListeners("didUpdate")) {
    const { layoutBox: s, measuredBox: r } = t.layout, { animationType: u } = t.options, n = i.source !== t.layout.source;
    u === "size" ? b((h) => {
      const f = n ? i.measuredBox[h] : i.layoutBox[h], d = E(f);
      f.min = s[h].min, f.max = f.min + d;
    }) : Ze(u, i.layoutBox, s) && b((h) => {
      const f = n ? i.measuredBox[h] : i.layoutBox[h], d = E(s[h]);
      f.max = f.min + d, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[h].max = t.relativeTarget[h].min + d);
    });
    const o = O();
    _(o, s, i.layoutBox);
    const a = O();
    n ? _(a, t.applyTransform(r, !0), i.measuredBox) : _(a, s, i.layoutBox);
    const l = !Xe(o);
    let c = !1;
    if (!t.resumeFrom) {
      const h = t.getClosestProjectingParent();
      if (h && !h.resumeFrom) {
        const { snapshot: f, layout: d } = h;
        if (f && d) {
          const m = x();
          $(m, i.layoutBox, f.layoutBox);
          const p = x();
          $(p, s, d.layoutBox), Ye(m, p) || (c = !0), h.options.layoutRoot && (t.relativeTarget = p, t.relativeTargetOrigin = m, t.relativeParent = h);
        }
      }
    }
    t.notifyListeners("didUpdate", {
      layout: s,
      snapshot: i,
      delta: a,
      layoutDelta: o,
      hasLayoutChanged: l,
      hasRelativeTargetChanged: c
    });
  } else if (t.isLead()) {
    const { onExitComplete: s } = t.options;
    s && s();
  }
  t.options.transition = void 0;
}
function fn(t) {
  F.totalNodes++, t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty));
}
function dn(t) {
  t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1;
}
function mn(t) {
  t.clearSnapshot();
}
function ue(t) {
  t.clearMeasurements();
}
function pn(t) {
  t.isLayoutDirty = !1;
}
function gn(t) {
  const { visualElement: e } = t.options;
  e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform();
}
function he(t) {
  t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0;
}
function yn(t) {
  t.resolveTargetDelta();
}
function vn(t) {
  t.calcProjection();
}
function Pn(t) {
  t.resetRotation();
}
function xn(t) {
  t.removeLeadSnapshot();
}
function fe(t, e, i) {
  t.translate = T(e.translate, 0, i), t.scale = T(e.scale, 1, i), t.origin = e.origin, t.originPoint = e.originPoint;
}
function de(t, e, i, s) {
  t.min = T(e.min, i.min, s), t.max = T(e.max, i.max, s);
}
function Tn(t, e, i, s) {
  de(t.x, e.x, i.x, s), de(t.y, e.y, i.y, s);
}
function Sn(t) {
  return t.animationValues && t.animationValues.opacityExit !== void 0;
}
const Dn = {
  duration: 0.45,
  ease: [0.4, 0, 0.1, 1]
}, me = (t) => typeof navigator < "u" && navigator.userAgent.toLowerCase().includes(t), pe = me("applewebkit/") && !me("chrome/") ? Math.round : M;
function ge(t) {
  t.min = pe(t.min), t.max = pe(t.max);
}
function An(t) {
  ge(t.x), ge(t.y);
}
function Ze(t, e, i) {
  return t === "position" || t === "preserve-aspect" && !Pt(re(e), re(i), 0.2);
}
const Ln = qe({
  attachResizeListener: (t, e) => R(t, "resize", e),
  measureScroll: () => ({
    x: document.documentElement.scrollLeft || document.body.scrollLeft,
    y: document.documentElement.scrollTop || document.body.scrollTop
  }),
  checkIsScrollRoot: () => !0
}), mt = {
  current: void 0
}, Je = qe({
  measureScroll: (t) => ({
    x: t.scrollLeft,
    y: t.scrollTop
  }),
  defaultParent: () => {
    if (!mt.current) {
      const t = new Ln({});
      t.mount(window), t.setOptions({ layoutScroll: !0 }), mt.current = t;
    }
    return mt.current;
  },
  resetTransform: (t, e) => {
    t.style.transform = e !== void 0 ? e : "none";
  },
  checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed"
}), Cn = {
  pan: {
    Feature: zs
  },
  drag: {
    Feature: Ws,
    ProjectionNode: Je,
    MeasureLayout: _e
  }
}, En = (t, e) => At(t) ? new Bi(e, { enableHardwareAcceleration: !1 }) : new ki(e, { enableHardwareAcceleration: !0 }), Vn = {
  layout: {
    ProjectionNode: Je,
    MeasureLayout: _e
  }
}, bn = {
  ...bs,
  ...gs,
  ...Cn,
  ...Vn
}, kn = /* @__PURE__ */ zi((t, e) => ns(t, e, bn, En));
export {
  kn as m
};
