import { defineComponent, useCssVars, unref, markRaw, defineAsyncComponent, ref, computed, openBlock, createElementBlock, Fragment, renderList, withDirectives, normalizeClass, normalizeStyle, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, createBlock, Suspense, withCtx, resolveDynamicComponent, mergeProps, toHandlers, vShow } from "vue";
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "render-form",
  "data-weiling-mobile-ui-bc-render-form": ""
};
const _hoisted_2 = {
  key: 0,
  class: "label"
};
const __default__ = {
  name: "BCRenderForm"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    list: { default: null },
    data: { default: null },
    space: { default: "0px" },
    needBorder: { type: Boolean, default: true },
    labelPosition: { default: "left" },
    backgroundColor: { default: "#fff" }
  },
  setup(__props) {
    const props = __props;
    useCssVars((_ctx) => ({
      "5cd474fd": __props.space,
      "2d8416b8": unref(labelPositionClass),
      "3164320c": __props.backgroundColor
    }));
    const componentDict = {
      input: markRaw(defineAsyncComponent(() => import("./index2.js"))),
      select: markRaw(defineAsyncComponent(() => import("./index6.js"))),
      date: markRaw(defineAsyncComponent(() => import("./index8.js"))),
      content: markRaw(defineAsyncComponent(() => import("./index9.js"))),
      textarea: markRaw(defineAsyncComponent(() => import("./index10.js"))),
      picSelect: markRaw(defineAsyncComponent(() => import("./index12.js"))),
      mulSelect: markRaw(defineAsyncComponent(() => import("./index13.js"))),
      colorSelect: markRaw(defineAsyncComponent(() => import("./index14.js"))),
      selectInput: markRaw(defineAsyncComponent(() => import("./index15.js")))
    };
    const componentName = ref(componentDict);
    const filterList = computed(() => {
      return props.list.map((res) => {
        return {
          labelVisible: true,
          ...res
        };
      });
    });
    const contentClass = computed(() => {
      return {
        content: true
      };
    });
    const formItemStyle = computed(() => {
      return (item) => {
        return {
          "margin-bottom": item.marginBottom + "px"
        };
      };
    });
    const formItemClass = computed(() => {
      return {
        "render-form-item": true,
        border: props.needBorder,
        [`render-form-${props.labelPosition}`]: true
      };
    });
    const labelPositionClass = computed(() => {
      return props.labelPosition === "left" ? "flex" : "block";
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(unref(filterList), (item) => {
          return withDirectives((openBlock(), createElementBlock("div", {
            class: normalizeClass(unref(formItemClass)),
            key: item.prop,
            style: normalizeStyle(unref(formItemStyle)(item))
          }, [
            item.labelVisible ? (openBlock(), createElementBlock("div", _hoisted_2, [
              item.labelSlot ? renderSlot(_ctx.$slots, item.labelSlot, { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                createTextVNode(toDisplayString(item.label), 1)
              ], 64))
            ])) : createCommentVNode("", true),
            createElementVNode("div", {
              class: normalizeClass(unref(contentClass))
            }, [
              !item.slot ? (openBlock(), createBlock(Suspense, { key: 0 }, {
                default: withCtx(() => [
                  !item.slot ? (openBlock(), createBlock(resolveDynamicComponent(componentName.value[item.type]), mergeProps({ key: 0 }, { ...item }, { labelPosition: __props.labelPosition }, toHandlers(item["event"] || {}), {
                    modelValue: __props.data[item.prop],
                    "onUpdate:modelValue": ($event) => __props.data[item.prop] = $event
                  }), null, 16, ["labelPosition", "modelValue", "onUpdate:modelValue"])) : createCommentVNode("", true)
                ]),
                _: 2
              }, 1024)) : createCommentVNode("", true),
              renderSlot(_ctx.$slots, item.slot)
            ], 2)
          ], 6)), [
            [vShow, item.visible !== false]
          ]);
        }), 128))
      ]);
    };
  }
});
var __uno = "";
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
