/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { defineComponent, toRefs, computed, provide, createVNode } from 'vue';
import useVModel from '../hooks/useVModel.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import props from './props.js';
import 'lodash/kebabCase';
import 'lodash/isFunction';
import 'lodash/camelCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isString';
import 'lodash/isObject';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-2e5d8948.js';
import 'dayjs';
import '../_chunks/dep-4580aabe.js';
import '../config-provider/type.js';

var _Collapse = defineComponent({
  name: "TCollapse",
  props: props,
  setup: function setup(props2) {
    var componentName = usePrefixClass("collapse");
    var borderlessClass = usePrefixClass("-border-less");
    var renderTNodeJSX = useTNodeJSX();
    var _toRefs = toRefs(props2),
      value = _toRefs.value,
      expandMutex = _toRefs.expandMutex,
      borderless = _toRefs.borderless,
      modelValue = _toRefs.modelValue;
    var _useVModel = useVModel(value, modelValue, props2.defaultValue, props2.onChange),
      _useVModel2 = _slicedToArray(_useVModel, 2),
      collapseValue = _useVModel2[0],
      setCollapseValue = _useVModel2[1];
    var updateCollapseValue = function updateCollapseValue(value2) {
      var newValue = [].concat(collapseValue.value || []);
      var index = newValue.indexOf(value2);
      if (index >= 0) newValue.splice(index, 1);else if (expandMutex.value) newValue = [value2];else newValue.push(value2);
      setCollapseValue(newValue);
    };
    var classes = computed(function () {
      return [componentName.value, _defineProperty({}, borderlessClass.value, !!borderless.value)];
    });
    var getUniqId = function () {
      var index = 0;
      return function () {
        return index++;
      };
    }();
    provide("collapseValue", collapseValue);
    provide("updateCollapseValue", updateCollapseValue);
    provide("collapseProps", toRefs(props2));
    provide("getUniqId", getUniqId);
    provide("renderParentTNode", renderTNodeJSX);
    return function () {
      var nodes = renderTNodeJSX("default");
      return createVNode("div", {
        "class": classes.value
      }, [nodes]);
    };
  }
});

export { _Collapse as default };
//# sourceMappingURL=collapse.js.map
