import k from "react";
import { __require as P } from "./index-attributes-to-props.js";
import { __require as S } from "./index-utilities.js";
var m, h;
function A() {
  if (h) return m;
  h = 1;
  var p = k, v = P(), c = S(), y = c.setStyleProp, T = c.canTextBeChildOfNode;
  function d(a, t) {
    t = t || {};
    for (var u = t.library || p, E = u.cloneElement, R = u.createElement, b = u.isValidElement, i = [], e, s, g = typeof t.replace == "function", n, r, o, q = t.trim, l = 0, f = a.length; l < f; l++) {
      if (e = a[l], g && (n = t.replace(e), b(n))) {
        f > 1 && (n = E(n, {
          key: n.key || l
        })), i.push(n);
        continue;
      }
      if (e.type === "text") {
        if (s = !e.data.trim().length, s && e.parent && !T(e.parent) || q && s)
          continue;
        i.push(e.data);
        continue;
      }
      switch (r = e.attribs, _(e) ? y(r.style, r) : r && (r = v(r, e.name)), o = null, e.type) {
        case "script":
        case "style":
          e.children[0] && (r.dangerouslySetInnerHTML = {
            __html: e.children[0].data
          });
          break;
        case "tag":
          e.name === "textarea" && e.children[0] ? r.defaultValue = e.children[0].data : e.children && e.children.length && (o = d(e.children, t));
          break;
        // skip all other cases (e.g., comment)
        default:
          continue;
      }
      f > 1 && (r.key = l), i.push(R(e.name, r, o));
    }
    return i.length === 1 ? i[0] : i;
  }
  function _(a) {
    return c.PRESERVE_CUSTOM_ATTRIBUTES && a.type === "tag" && c.isCustomComponent(a.name, a.attribs);
  }
  return m = d, m;
}
export {
  A as __require
};
