"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Vue = require("vue");
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const index = require("../../../hooks/use-forward-ref/index.js");
const index$1 = require("../../../hooks/use-namespace/index.js");
const o = "ElOnlyChild", T = Vue.defineComponent({
  name: o,
  setup(r, {
    slots: n,
    attrs: e
  }) {
    var i;
    const l = Vue.inject(index.FORWARD_REF_INJECTION_KEY), s = index.useForwardRefDirective((i = l == null ? void 0 : l.setForwardRef) != null ? i : shared_esmBundler.NOOP);
    return () => {
      var c;
      const t = (c = n.default) == null ? void 0 : c.call(n, e);
      if (!t)
        return null;
      if (t.length > 1)
        return null;
      const u = f(t);
      return u ? Vue.withDirectives(Vue.cloneVNode(u, e), [[s]]) : null;
    };
  }
});
function f(r) {
  if (!r)
    return null;
  const n = r;
  for (const e of n) {
    if (shared_esmBundler.isObject(e))
      switch (e.type) {
        case Vue.Comment:
          continue;
        case Vue.Text:
        case "svg":
          return d(e);
        case Vue.Fragment:
          return f(e.children);
        default:
          return e;
      }
    return d(e);
  }
  return null;
}
function d(r) {
  const n = index$1.useNamespace("only-child");
  return Vue.createVNode("span", {
    class: n.e("content")
  }, [r]);
}
exports.OnlyChild = T;
