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

import { getCurrentInstance, ref } from 'vue';
import { k as kebabCase_1 } from '../_chunks/dep-9a85dac1.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-1372b2d3.mjs';
import '../_chunks/dep-42cc3015.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-2bc37d52.mjs';
import '../_chunks/dep-3da99438.mjs';

function useDefaultValue(value, defaultValue, onChange, propsName) {
  var _getCurrentInstance = getCurrentInstance(),
    emit = _getCurrentInstance.emit,
    vnode = _getCurrentInstance.vnode;
  var internalValue = ref();
  var vProps = vnode.props || {};
  var isVMP = Object.prototype.hasOwnProperty.call(vProps, propsName) || Object.prototype.hasOwnProperty.call(vProps, kebabCase_1(propsName));
  if (isVMP) {
    return [value, function (newValue) {
      emit("update:".concat(propsName), newValue);
      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
      }
      onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [newValue].concat(args));
    }];
  }
  internalValue.value = defaultValue;
  return [internalValue, function (newValue) {
    internalValue.value = newValue;
    for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
      args[_key2 - 1] = arguments[_key2];
    }
    onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [newValue].concat(args));
  }];
}

export { useDefaultValue as default };
//# sourceMappingURL=useDefaultValue.mjs.map
