'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var objects = require('../../../../utils/src/objects.js');
var operateButton = require('../operateButton/operateButton.js');
var TableOperateVNodeRenderer = require('./TableOperateVNodeRenderer.js');
var tableHelper = require('./tableHelper.js');

const _hoisted_1 = {
  key: 0,
  class: "gm-flex gm-flex-wrap gm-justify-center"
};
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "TableProEditSlot",
  props: /* @__PURE__ */ vue.mergeModels({
    tableOperateVnode: { required: true },
    slotValue: { required: true },
    isInited: { type: Boolean, required: false }
  }, {
    "customBtnPropsList": { required: true },
    "customBtnPropsListModifiers": {},
    "customDefaultPropsList": { required: true },
    "customDefaultPropsListModifiers": {}
  }),
  emits: ["update:customBtnPropsList", "update:customDefaultPropsList"],
  setup(__props) {
    const props = __props;
    const customBtnPropsList = vue.useModel(__props, "customBtnPropsList");
    const customDefaultPropsList = vue.useModel(__props, "customDefaultPropsList");
    const getPropsList = () => {
      const defaultVnodes = props.tableOperateVnode?.children?.default?.(props.slotValue);
      const children = tableHelper.getVnodesByGmName(defaultVnodes, "GmOperateButton");
      const btnProps = children.map((vNode) => vNode.props) ?? [];
      btnProps.forEach((it) => {
        for (const key in operateButton.operateButtonProps) {
          if (objects.hasOwn(it, key)) {
            continue;
          }
          if (objects.hasOwn(operateButton.operateButtonProps, key)) {
            const element = operateButton.operateButtonProps[key];
            if (objects.hasOwn(element, "default")) {
              Reflect.set(it, key, Reflect.get(element, "default"));
            }
          }
        }
      });
      return btnProps;
    };
    customDefaultPropsList.value = getPropsList();
    customBtnPropsList.value = customDefaultPropsList.value;
    return (_ctx, _cache) => {
      return __props.tableOperateVnode && __props.tableOperateVnode.children && __props.isInited && __props.slotValue && customBtnPropsList.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(TableOperateVNodeRenderer.default), {
          vnode: __props.tableOperateVnode.children?.default(__props.slotValue),
          customPropsList: customBtnPropsList.value
        }, null, 8, ["vnode", "customPropsList"])
      ])) : vue.createCommentVNode("v-if", true);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=TableProEditSlot.vue2.js.map
