import { defineComponent, openBlock, createBlock, unref, createElementBlock, normalizeClass, createElementVNode, renderSlot, withDirectives, createVNode, vShow, createTextVNode, toDisplayString, ref, computed, watchEffect, mergeProps, withCtx, createCommentVNode, watch, Fragment, renderList, normalizeStyle, withModifiers, isRef } from "vue";
import { Popup } from "vant";
import WlSvg from "@wltech/svg";
import vuedraggable from "vuedraggable";
const __default__$2 = {
  name: "WlSvgIcon"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    type: { default: "" },
    color: { default: "var(--wl-text-color-title-1)" },
    width: { default: "16" },
    height: { default: "16" }
  },
  setup(__props) {
    const sub = location.origin;
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(WlSvg), {
        type: __props.type,
        width: __props.width,
        height: __props.height,
        color: __props.color,
        sub: unref(sub)
      }, null, 8, ["type", "width", "height", "color", "sub"]);
    };
  }
});
const _hoisted_1$2 = { class: "z-2 flex uno-min-w-44 uno-max-w-88" };
const _hoisted_2$2 = { class: "uno-elli-1 z-1 box-border flex-middle-center absolute text-center uno-l-44 uno-r-44" };
const _hoisted_3$1 = { class: "relative z-2 flex-middle-center uno-min-w-44" };
const __default__$1 = {
  name: "WlHeader"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    title: { default: "" },
    showBack: { type: Boolean, default: false },
    showClose: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true },
    needBottomBorder: { type: Boolean, default: false }
  },
  emits: ["onBack", "onClose"],
  setup(__props, { emit }) {
    const props = __props;
    const onBackPage = () => {
      if (props.needAutoBack) {
        history.back();
      } else {
        emit("onBack");
      }
    };
    const onClose = () => {
      emit("onClose");
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(`uno-fs-16 uno-h-44 relative font-medium box-border text-base-color bg-white flex-between ${__props.needBottomBorder ? "border-bottom" : " "}`)
      }, [
        createElementVNode("div", _hoisted_1$2, [
          renderSlot(_ctx.$slots, "header_part_left", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onBackPage
            }, [
              createVNode(_sfc_main$4, {
                type: "arrowTipLeft",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showBack]
            ])
          ])
        ]),
        createElementVNode("div", _hoisted_2$2, [
          renderSlot(_ctx.$slots, "default", {}, () => [
            createTextVNode(toDisplayString(__props.title), 1)
          ])
        ]),
        createElementVNode("div", _hoisted_3$1, [
          renderSlot(_ctx.$slots, "header_part_right", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onClose
            }, [
              createVNode(_sfc_main$4, {
                type: "close",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showClose]
            ])
          ])
        ])
      ], 2);
    };
  }
});
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$1 = {
  class: "popup-wrap",
  "data-weiling-mobile-ui-wl-popup": ""
};
const _hoisted_2$1 = { class: "popup-content" };
const __default__ = {
  name: "WlPopup"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { type: Boolean, default: false },
    teleport: { default: "body" },
    position: { default: "bottom" },
    headerVisible: { type: Boolean, default: false },
    title: { default: "" },
    showRightClose: { type: Boolean, default: true },
    showBack: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true }
  },
  emits: ["update:modelValue", "onClose", "onBack"],
  setup(__props, { emit }) {
    const props = __props;
    const popUpVisible = ref(false);
    const popupStyle = computed(() => {
      return {
        height: "70%"
      };
    });
    const onClose = () => {
      emit("update:modelValue", false);
      emit("onClose");
    };
    const onOpen = () => {
      emit("update:modelValue", true);
    };
    const onBack = () => {
      emit("onBack");
    };
    watchEffect(() => {
      popUpVisible.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Popup), mergeProps({
        show: popUpVisible.value,
        "onUpdate:show": _cache[0] || (_cache[0] = ($event) => popUpVisible.value = $event),
        teleport: __props.teleport,
        position: __props.position,
        "close-on-popstate": true,
        style: unref(popupStyle)
      }, _ctx.$attrs, {
        onClose,
        onOpen
      }), {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1$1, [
            __props.headerVisible ? (openBlock(), createBlock(_sfc_main$3, {
              key: 0,
              title: __props.title,
              showClose: __props.showRightClose,
              onOnClose: onClose,
              onOnBack: onBack,
              showBack: __props.showBack,
              needAutoBack: __props.needAutoBack
            }, {
              header_part_left: withCtx(() => [
                renderSlot(_ctx.$slots, "header_part_left")
              ]),
              _: 3
            }, 8, ["title", "showClose", "showBack", "needAutoBack"])) : createCommentVNode("", true),
            createElementVNode("div", _hoisted_2$1, [
              renderSlot(_ctx.$slots, "default")
            ])
          ])
        ]),
        _: 3
      }, 16, ["show", "teleport", "position", "style"]);
    };
  }
});
var __uno = "";
_sfc_main$4.install = (app) => {
  app.component(_sfc_main$4.name, _sfc_main$4);
};
var FieldSort_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "field-sort",
  "data-weiling-mobile-ui-wl-field-sort": ""
};
const _hoisted_2 = { class: "field-title" };
const _hoisted_3 = /* @__PURE__ */ createElementVNode("span", { class: "title-line" }, null, -1);
const _hoisted_4 = { class: "title-text" };
const _hoisted_5 = { class: "field-box" };
const _hoisted_6 = { class: "field-item" };
const _hoisted_7 = { class: "item-left" };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "FieldSort",
  props: {
    list: { default: () => {
      return [];
    } }
  },
  emits: ["onChange"],
  setup(__props, { emit }) {
    const props = __props;
    const fieldList = ref(JSON.parse(JSON.stringify(props.list)));
    const onFieldClick = (item, element) => {
      var _a, _b, _c;
      const fieldItem = (_a = fieldList.value) == null ? void 0 : _a.find((v) => v.key === item.key);
      if (fieldItem) {
        const oldList = fieldItem == null ? void 0 : fieldItem.list;
        const i = oldList == null ? void 0 : oldList.findIndex(
          (v) => v.property_id === element.property_id
        );
        if (i !== -1) {
          oldList.splice(i, 1);
          const newList = (_c = (_b = fieldList.value) == null ? void 0 : _b.find(
            (v) => v.editKey === item.key
          )) == null ? void 0 : _c.list;
          newList && newList.push(element);
        }
      }
    };
    watch(
      () => props.list,
      () => {
        fieldList.value = JSON.parse(JSON.stringify(props.list));
      },
      {
        immediate: true,
        deep: true
      }
    );
    watch(
      () => fieldList.value,
      () => {
        emit("onChange", fieldList.value);
      },
      {
        deep: true
      }
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(fieldList.value, (item) => {
          return openBlock(), createElementBlock("div", {
            key: item.key,
            class: "field-content"
          }, [
            createElementVNode("div", _hoisted_2, [
              _hoisted_3,
              createElementVNode("span", _hoisted_4, toDisplayString(item.title), 1)
            ]),
            createElementVNode("ul", _hoisted_5, [
              createVNode(unref(vuedraggable), {
                modelValue: item.list,
                "onUpdate:modelValue": ($event) => item.list = $event,
                "item-key": "property_id",
                animation: "300",
                disabled: !item.sortable,
                handle: ".drag-icon"
              }, {
                item: withCtx(({ element }) => [
                  createElementVNode("li", _hoisted_6, [
                    createElementVNode("div", _hoisted_7, [
                      createVNode(unref(_sfc_main$4), {
                        type: item.icon,
                        class: "field-left-icon",
                        style: normalizeStyle({ color: item.color }),
                        onClick: withModifiers(($event) => onFieldClick(item, element), ["stop"])
                      }, null, 8, ["type", "style", "onClick"]),
                      createElementVNode("span", null, toDisplayString(element.name || element.view_name), 1)
                    ]),
                    createElementVNode("div", {
                      class: "drag-icon",
                      onClick: _cache[0] || (_cache[0] = withModifiers(() => {
                      }, ["stop"]))
                    }, [
                      item.sortable ? (openBlock(), createBlock(unref(_sfc_main$4), {
                        key: 0,
                        type: "drag",
                        class: "field-drag-icon"
                      })) : createCommentVNode("", true)
                    ])
                  ])
                ]),
                _: 2
              }, 1032, ["modelValue", "onUpdate:modelValue", "disabled"])
            ])
          ]);
        }), 128))
      ]);
    };
  }
});
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    modelValue: { type: Boolean, default: false },
    title: { default: "\u5B57\u6BB5\u6392\u5E8F" },
    list: { default: () => {
      return [];
    } }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    let visible = ref(false);
    watch(
      () => props.modelValue,
      (val) => {
        if (val) {
          visible.value = props.modelValue;
        }
      }
    );
    watch(
      () => visible.value,
      (val) => {
        if (!val)
          emit("update:modelValue", val);
      }
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$2, mergeProps({
        modelValue: unref(visible),
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(visible) ? visible.value = $event : visible = $event),
        position: "bottom",
        round: "",
        headerVisible: "",
        title: __props.title,
        style: { "height": "80%" }
      }, _ctx.$attrs), {
        default: withCtx(() => [
          createVNode(_sfc_main$1, mergeProps({ list: __props.list }, _ctx.$attrs), null, 16, ["list"])
        ]),
        _: 1
      }, 16, ["modelValue", "title"]);
    };
  }
});
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
