var e = require("../../../../common/vendor.js"),
  t = {
    name: "uniCollapse",
    emits: ["change", "activeItem", "input", "update:modelValue"],
    props: {
      value: { type: [String, Array], default: "" },
      modelValue: { type: [String, Array], default: "" },
      accordion: { type: [Boolean, String], default: !1 },
    },
    data: function () {
      return {};
    },
    computed: {
      dataValue: function () {
        var e =
          ("string" == typeof this.value && "" === this.value) ||
          (Array.isArray(this.value) && 0 === this.value.length);
        return (
          ("string" == typeof this.modelValue && "" === this.modelValue) ||
            (Array.isArray(this.modelValue) && this.modelValue.length),
          e ? this.modelValue : this.value
        );
      },
    },
    watch: {
      dataValue: function (e) {
        this.setOpen(e);
      },
    },
    created: function () {
      (this.childrens = []), (this.names = []);
    },
    mounted: function () {
      var e = this;
      this.$nextTick(function () {
        e.setOpen(e.dataValue);
      });
    },
    methods: {
      setOpen: function (e) {
        var t = this,
          n = "string" == typeof e,
          i = Array.isArray(e);
        this.childrens.forEach(function (a, o) {
          if (n && e === a.nameSync) {
            if (!t.accordion)
              return void console.warn(
                "accordion 属性为 false ,v-model 类型应该为 array"
              );
            a.isOpen = !0;
          }
          i &&
            e.forEach(function (e) {
              if (e === a.nameSync) {
                if (t.accordion)
                  return void console.warn(
                    "accordion 属性为 true ,v-model 类型应该为 string"
                  );
                a.isOpen = !0;
              }
            });
        }),
          this.emit(e);
      },
      setAccordion: function (e) {
        this.accordion &&
          this.childrens.forEach(function (t, n) {
            e !== t && (t.isOpen = !1);
          });
      },
      resize: function () {
        this.childrens.forEach(function (e, t) {
          e.getCollapseHeight();
        });
      },
      onChange: function (e, t) {
        var n = [];
        this.accordion
          ? (n = e ? t.nameSync : "")
          : this.childrens.forEach(function (e, t) {
              e.isOpen && n.push(e.nameSync);
            }),
          this.$emit("change", n),
          this.emit(n);
      },
      emit: function (e) {
        this.$emit("input", e), this.$emit("update:modelValue", e);
      },
    },
  },
  n = e._export_sfc(t, [
    [
      "render",
      function (e, t, n, i, a, o) {
        return {};
      },
    ],
  ]);
wx.createComponent(n);
