import { defineComponent, useSlots, computed, resolveComponent, createElementBlock, openBlock, Fragment, createCommentVNode, createBlock, normalizeProps, mergeProps, createSlots, withCtx, unref, renderSlot, guardReactiveProps, createVNode } from 'vue';
import { tableColumnProps } from './tableColumn.mjs';

var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "GmTableColumn"
  },
  __name: "TableColumn",
  props: tableColumnProps,
  setup(__props) {
    const slots = useSlots();
    const props = __props;
    const hasDefaultSlot = computed(() => !!slots.default);
    const isColumnComponent = (vnode) => {
      if (!vnode) return false;
      if (vnode.type) {
        const typeName = typeof vnode.type === "object" ? vnode.type.name : null;
        if (typeName === "GmTableColumn" || typeName === "GmTableColumnPro" || typeName === "ElTableColumn") {
          return true;
        }
      }
      if (vnode.children) {
        const children = Array.isArray(vnode.children) ? vnode.children : [vnode.children];
        if (children.some((child) => isColumnComponent(child))) {
          return true;
        }
      }
      return false;
    };
    const isMultiLevelHeader = computed(() => {
      if (!slots.default) return false;
      try {
        const vnodes = slots.default({ row: {}, column: {}, $index: -1 });
        if (!Array.isArray(vnodes)) return false;
        return vnodes.some((vnode) => isColumnComponent(vnode));
      } catch {
        return false;
      }
    });
    return (_ctx, _cache) => {
      const _component_el_table_column = resolveComponent("el-table-column");
      return openBlock(), createElementBlock(
        Fragment,
        null,
        [
          createCommentVNode(" \u65E0\u81EA\u5B9A\u4E49 slot\uFF1A\u4F7F\u7528 el-table-column \u9ED8\u8BA4\u6E32\u67D3 "),
          !hasDefaultSlot.value ? (openBlock(), createBlock(
            _component_el_table_column,
            normalizeProps(mergeProps({ key: 0 }, props)),
            createSlots({
              _: 2
              /* DYNAMIC */
            }, [
              unref(slots).header ? {
                name: "header",
                fn: withCtx((scope) => [
                  renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps(scope)))
                ]),
                key: "0"
              } : void 0
            ]),
            1040
            /* FULL_PROPS, DYNAMIC_SLOTS */
          )) : (openBlock(), createElementBlock(
            Fragment,
            { key: 1 },
            [
              createCommentVNode(" \u6709\u81EA\u5B9A\u4E49 slot "),
              createVNode(
                _component_el_table_column,
                normalizeProps(guardReactiveProps(props)),
                createSlots({
                  default: withCtx((scope) => [
                    createCommentVNode(" \u591A\u7EA7\u8868\u5934\u59CB\u7EC8\u6E32\u67D3\uFF1B\u81EA\u5B9A\u4E49\u5185\u5BB9\u4EC5\u5728 $index !== -1 \u65F6\u6E32\u67D3\uFF08\u907F\u514D el-switch \u7B49\u89E6\u53D1\u526F\u4F5C\u7528\uFF09 "),
                    isMultiLevelHeader.value || scope.$index !== -1 ? renderSlot(_ctx.$slots, "default", normalizeProps(mergeProps({ key: 0 }, scope))) : createCommentVNode("v-if", true)
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, [
                  unref(slots).header ? {
                    name: "header",
                    fn: withCtx((scope) => [
                      renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps(scope)))
                    ]),
                    key: "0"
                  } : void 0
                ]),
                1040
                /* FULL_PROPS, DYNAMIC_SLOTS */
              )
            ],
            2112
            /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
          ))
        ],
        2112
        /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=TableColumn.vue2.mjs.map
