import { BailSignal as Y, Controller as tt, FrameValue as et, Interpolation as rt, SpringContext as ot, SpringRef as st, SpringValue as it, config as at, inferTo as lt, to as ut, useSpring as nt, useSprings as dt, useTransition as pt } from "./index-react-spring_core.modern.js";
import { unstable_batchedUpdates as A } from "react-dom";
import { Globals as C, colors as F, createStringInterpolator as I, eachProp as P, is as h, toArray as k, FluidValue as T, each as f, getFluidValue as y, hasFluidValue as w, addFluidObserver as N, removeFluidObserver as j, callFluidObservers as V } from "./index-react-spring_shared.modern.js";
import { createInterpolator as ft, easings as ct, useIsomorphicLayoutEffect as ht } from "./index-react-spring_shared.modern.js";
import { createHost as _, AnimatedObject as E } from "./index-react-spring_animated.modern.js";
var S = /^--/;
function G(t, e) {
  return e == null || typeof e == "boolean" || e === "" ? "" : typeof e == "number" && e !== 0 && !S.test(t) && !(c.hasOwnProperty(t) && c[t]) ? e + "px" : ("" + e).trim();
}
var O = {};
function R(t, e) {
  if (!t.nodeType || !t.setAttribute || !t.removeAttribute)
    return !1;
  const r = t.nodeName === "filter" || t.parentNode && t.parentNode.nodeName === "filter", {
    className: l,
    style: i,
    children: u,
    scrollTop: a,
    scrollLeft: s,
    viewBox: n,
    ...d
  } = e, m = Object.values(d), g = Object.keys(d).map(
    (o) => r || t.hasAttribute(o) ? o : O[o] || (O[o] = o.replace(
      /([A-Z])/g,
      // Attributes are written in dash case
      (p) => "-" + p.toLowerCase()
    ))
  );
  e.hasOwnProperty("children") && (t.textContent = u);
  for (const o in i)
    if (i.hasOwnProperty(o)) {
      const p = G(o, i[o]);
      S.test(o) ? t.style.setProperty(o, p) : t.style[o] = p;
    }
  g.forEach((o, p) => {
    const x = m[p];
    x !== void 0 ? t.setAttribute(o, x) : t.removeAttribute(o);
  }), e.hasOwnProperty("className") && (l !== void 0 ? t.className = l : t.removeAttribute("class")), a !== void 0 && (t.scrollTop = a), s !== void 0 && (t.scrollLeft = s), e.hasOwnProperty("viewBox") && (n !== void 0 ? t.setAttribute("viewBox", n) : t.removeAttribute("viewBox"));
}
var c = {
  animationIterationCount: !0,
  borderImageOutset: !0,
  borderImageSlice: !0,
  borderImageWidth: !0,
  boxFlex: !0,
  boxFlexGroup: !0,
  boxOrdinalGroup: !0,
  columnCount: !0,
  columns: !0,
  flex: !0,
  flexGrow: !0,
  flexPositive: !0,
  flexShrink: !0,
  flexNegative: !0,
  flexOrder: !0,
  gridRow: !0,
  gridRowEnd: !0,
  gridRowSpan: !0,
  gridRowStart: !0,
  gridColumn: !0,
  gridColumnEnd: !0,
  gridColumnSpan: !0,
  gridColumnStart: !0,
  fontWeight: !0,
  lineClamp: !0,
  lineHeight: !0,
  opacity: !0,
  order: !0,
  orphans: !0,
  tabSize: !0,
  widows: !0,
  zIndex: !0,
  zoom: !0,
  // SVG-related properties
  fillOpacity: !0,
  floodOpacity: !0,
  stopOpacity: !0,
  strokeDasharray: !0,
  strokeDashoffset: !0,
  strokeMiterlimit: !0,
  strokeOpacity: !0,
  strokeWidth: !0
}, $ = (t, e) => t + e.charAt(0).toUpperCase() + e.substring(1), B = ["Webkit", "Ms", "Moz", "O"];
c = Object.keys(c).reduce((t, e) => (B.forEach((r) => t[$(r, e)] = t[e]), t), c);
var L = /^(matrix|translate|scale|rotate|skew)/, U = /^(translate)/, W = /^(rotate|skew)/, v = (t, e) => h.num(t) && t !== 0 ? t + e : t, b = (t, e) => h.arr(t) ? t.every((r) => b(r, e)) : h.num(t) ? t === e : parseFloat(t) === e, M = class extends E {
  constructor({ x: t, y: e, z: r, ...l }) {
    const i = [], u = [];
    (t || e || r) && (i.push([t || 0, e || 0, r || 0]), u.push((a) => [
      `translate3d(${a.map((s) => v(s, "px")).join(",")})`,
      // prettier-ignore
      b(a, 0)
    ])), P(l, (a, s) => {
      if (s === "transform")
        i.push([a || ""]), u.push((n) => [n, n === ""]);
      else if (L.test(s)) {
        if (delete l[s], h.und(a)) return;
        const n = U.test(s) ? "px" : W.test(s) ? "deg" : "";
        i.push(k(a)), u.push(
          s === "rotate3d" ? ([d, m, g, o]) => [
            `rotate3d(${d},${m},${g},${v(o, n)})`,
            b(o, 0)
          ] : (d) => [
            `${s}(${d.map((m) => v(m, n)).join(",")})`,
            b(d, s.startsWith("scale") ? 1 : 0)
          ]
        );
      }
    }), i.length && (l.transform = new q(i, u)), super(l);
  }
}, q = class extends T {
  constructor(t, e) {
    super(), this.inputs = t, this.transforms = e, this._value = null;
  }
  get() {
    return this._value || (this._value = this._get());
  }
  _get() {
    let t = "", e = !0;
    return f(this.inputs, (r, l) => {
      const i = y(r[0]), [u, a] = this.transforms[l](
        h.arr(i) ? i : r.map(y)
      );
      t += " " + u, e = e && a;
    }), e ? "none" : t;
  }
  // Start observing our inputs once we have an observer.
  observerAdded(t) {
    t == 1 && f(
      this.inputs,
      (e) => f(
        e,
        (r) => w(r) && N(r, this)
      )
    );
  }
  // Stop observing our inputs once we have no observers.
  observerRemoved(t) {
    t == 0 && f(
      this.inputs,
      (e) => f(
        e,
        (r) => w(r) && j(r, this)
      )
    );
  }
  eventObserved(t) {
    t.type == "change" && (this._value = null), V(this, t);
  }
}, z = [
  "a",
  "abbr",
  "address",
  "area",
  "article",
  "aside",
  "audio",
  "b",
  "base",
  "bdi",
  "bdo",
  "big",
  "blockquote",
  "body",
  "br",
  "button",
  "canvas",
  "caption",
  "cite",
  "code",
  "col",
  "colgroup",
  "data",
  "datalist",
  "dd",
  "del",
  "details",
  "dfn",
  "dialog",
  "div",
  "dl",
  "dt",
  "em",
  "embed",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "head",
  "header",
  "hgroup",
  "hr",
  "html",
  "i",
  "iframe",
  "img",
  "input",
  "ins",
  "kbd",
  "keygen",
  "label",
  "legend",
  "li",
  "link",
  "main",
  "map",
  "mark",
  "menu",
  "menuitem",
  "meta",
  "meter",
  "nav",
  "noscript",
  "object",
  "ol",
  "optgroup",
  "option",
  "output",
  "p",
  "param",
  "picture",
  "pre",
  "progress",
  "q",
  "rp",
  "rt",
  "ruby",
  "s",
  "samp",
  "script",
  "section",
  "select",
  "small",
  "source",
  "span",
  "strong",
  "style",
  "sub",
  "summary",
  "sup",
  "table",
  "tbody",
  "td",
  "textarea",
  "tfoot",
  "th",
  "thead",
  "time",
  "title",
  "tr",
  "track",
  "u",
  "ul",
  "var",
  "video",
  "wbr",
  // SVG
  "circle",
  "clipPath",
  "defs",
  "ellipse",
  "foreignObject",
  "g",
  "image",
  "line",
  "linearGradient",
  "mask",
  "path",
  "pattern",
  "polygon",
  "polyline",
  "radialGradient",
  "rect",
  "stop",
  "svg",
  "text",
  "tspan"
];
C.assign({
  batchedUpdates: A,
  createStringInterpolator: I,
  colors: F
});
var D = _(z, {
  applyAnimatedValues: R,
  createAnimatedStyle: (t) => new M(t),
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  getComponentProps: ({ scrollTop: t, scrollLeft: e, ...r }) => r
}), J = D.animated;
export {
  Y as BailSignal,
  tt as Controller,
  et as FrameValue,
  C as Globals,
  rt as Interpolation,
  ot as SpringContext,
  st as SpringRef,
  it as SpringValue,
  J as a,
  J as animated,
  at as config,
  ft as createInterpolator,
  ct as easings,
  lt as inferTo,
  ut as to,
  ht as useIsomorphicLayoutEffect,
  nt as useSpring,
  dt as useSprings,
  pt as useTransition
};
