import { s as __toESM } from "./chunk-BNovOVIE.js";
import { t as require_react } from "./react-DA-nE2FX.js";
import { t as isPropValid } from "./emotion-is-prop-valid.esm-DtW2o230.js";
var cx_default = function() {
  let e = Array.prototype.slice.call(arguments).filter(Boolean), n = {}, r = [];
  e.forEach((e2) => {
    (e2 ? e2.split(" ") : []).forEach((e3) => {
      if (e3.startsWith("atm_")) {
        let [, r2] = e3.split("_");
        n[r2] = e3;
      } else r.push(e3);
    });
  });
  let i = [];
  for (let e2 in n) Object.prototype.hasOwnProperty.call(n, e2) && i.push(n[e2]);
  return i.push(...r), i.join(" ");
}, import_react = /* @__PURE__ */ __toESM(require_react(), 1), isCapital = (e) => e.toUpperCase() === e, filterKey = (e) => (n) => e.indexOf(n) === -1, omit = (e, n) => {
  let r = {};
  return Object.keys(e).filter(filterKey(n)).forEach((n2) => {
    r[n2] = e[n2];
  }), r;
};
function filterProps(e, n, i) {
  let a = omit(n, i);
  if (!e) {
    let e2 = typeof isPropValid == "function" ? { default: isPropValid } : isPropValid;
    Object.keys(a).forEach((n2) => {
      e2.default(n2) || delete a[n2];
    });
  }
  return a;
}
function styled(e) {
  return (n) => {
    let r = (r2, s2) => {
      let { as: c = e, class: l = "" } = r2, u = filterProps(n.propsAsIs === void 0 ? !(typeof c == "string" && c.indexOf("-") === -1 && !isCapital(c[0])) : n.propsAsIs, r2, ["as", "class"]);
      u.ref = s2, u.className = n.atomic ? cx_default(n.class, u.className || l) : cx_default(u.className || l, n.class);
      let { vars: d } = n;
      if (d) {
        let e2 = {};
        for (let i2 in d) {
          let a2 = d[i2], o = a2[0], s3 = a2[1] || "", c2 = typeof o == "function" ? o(r2) : o;
          n.name, e2[`--${i2}`] = `${c2}${s3}`;
        }
        let i = u.style || {}, a = Object.keys(i);
        a.length > 0 && a.forEach((n2) => {
          e2[n2] = i[n2];
        }), u.style = e2;
      }
      return e.__linaria && e !== c ? (u.as = c, import_react.createElement(e, u)) : import_react.createElement(c, u);
    }, s = import_react.forwardRef ? import_react.forwardRef(r) : (e2) => r(omit(e2, ["innerRef"]), e2.innerRef);
    return s.displayName = n.name, s.__linaria = {
      className: n.class || "",
      extends: e
    }, s;
  };
}
var styled_default = styled;
export {
  styled_default as t
};
