/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var VueCompositionAPI = require('@vue/composition-api');
var collapse_props = require('./props.js');
var hooks_useVModel = require('../hooks/useVModel.js');
var hooks_tnode = require('../hooks/tnode.js');
var hooks_useConfig = require('../hooks/useConfig.js');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../hooks/render-tnode.js');
require('lodash/isString');
require('lodash/isObject');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);

var _Collapse = VueCompositionAPI.defineComponent({
  name: "TCollapse",
  props: collapse_props["default"],
  setup: function setup(props2) {
    var componentName = hooks_useConfig.usePrefixClass("collapse");
    var borderlessClass = hooks_useConfig.usePrefixClass("-border-less");

    var _toRefs = VueCompositionAPI.toRefs(props2),
        value = _toRefs.value,
        expandMutex = _toRefs.expandMutex,
        borderless = _toRefs.borderless;

    var _useVModel = hooks_useVModel["default"](value, props2.defaultValue, props2.onChange, "change"),
        _useVModel2 = _slicedToArray__default["default"](_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 = VueCompositionAPI.computed(function () {
      return [componentName.value, _defineProperty__default["default"]({}, borderlessClass.value, !!borderless.value)];
    });

    var getUniqId = function () {
      var index = 0;
      return function () {
        return index += 1;
      };
    }();

    VueCompositionAPI.provide("collapseValue", collapseValue);
    VueCompositionAPI.provide("updateCollapseValue", updateCollapseValue);
    VueCompositionAPI.provide("collapseProps", VueCompositionAPI.toRefs(props2));
    VueCompositionAPI.provide("getUniqId", getUniqId);
    return {
      classes: classes
    };
  },
  render: function render() {
    var h = arguments[0];
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var nodes = renderTNodeJSX("default");
    return h("div", {
      "class": this.classes
    }, [nodes]);
  }
});

exports["default"] = _Collapse;
//# sourceMappingURL=collapse.js.map
