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

import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, createVNode, mergeProps } from 'vue';
import useVModel from '../hooks/useVModel.js';
import { renderTNodeJSXDefault } from '../utils/render-tnode.js';
import { Popup } from '../popup/index.js';
import props from './props.js';
import ColorPanel from './panel/index.js';
import DefaultTrigger from './trigger.js';
import { useBaseClassName } from './hooks.js';
import 'lodash/kebabCase';
import 'lodash/isEmpty';
import 'lodash/isString';
import 'lodash/isFunction';
import 'lodash/isObject';
import 'lodash/camelCase';
import '../utils/withInstall.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../hooks/useConfig.js';
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-e041f5b0.js';
import 'dayjs';
import '../utils/dom.js';
import '../utils/easing.js';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'lodash/isUndefined';
import '../hooks/useResizeObserver.js';
import '../hooks/useDefaultValue.js';
import './panel/header.js';
import '../radio/index.js';
import '../radio/radio.js';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isNumber';
import '../form/hooks.js';
import '../hooks/tnode.js';
import '../radio/constants.js';
import '../radio/props.js';
import '../radio/group.js';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/regenerator';
import 'lodash/isNil';
import '../radio/radio-group-props.js';
import '../radio/useKeyboard.js';
import '../radio/radio-button.js';
import '../_common/js/color-picker/constants.js';
import './panel/linear-gradient.js';
import '../input-number/index.js';
import '../input-number/input-number.js';
import '@ldesign/icons-vue-next';
import '../button/index.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../loading/loading.js';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/helper.js';
import '../hooks/useRipple.js';
import '../utils/set-style.js';
import '../hooks/useKeepAnimation.js';
import '../button/props.js';
import '../input/index.js';
import '../input/input.js';
import '../hooks/useGlobalIcon.js';
import '../input/props.js';
import '../input/useInput.js';
import '../form/const.js';
import '../input/useLengthLimit.js';
import '../_common/js/log/log.js';
import '../input/useInputEventHandler.js';
import '../input/useInputWidth.js';
import '../input/input-group.js';
import '../input/input-group-props.js';
import '../input-number/props.js';
import '../input-number/useInputNumber.js';
import '../hooks/useCommonClassName.js';
import '../_common/js/input-number/number.js';
import '../_common/js/input-number/large-number.js';
import './panel/base-props.js';
import '../_common/js/color-picker/color.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import 'tinycolor2';
import '../_common/js/color-picker/cmyk.js';
import '../_common/js/color-picker/gradient.js';
import './panel/saturation.js';
import '../_common/js/color-picker/draggable.js';
import './panel/hue.js';
import './panel/slider.js';
import './panel/alpha.js';
import './panel/format/index.js';
import 'lodash/upperCase';
import './const.js';
import '../select/index.js';
import '../select/select.js';
import 'lodash/pick';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/intersection';
import '../common-components/fake-arrow.js';
import '../select-input/index.js';
import '../select-input/select-input.js';
import '../select-input/props.js';
import '../select-input/useSingle.js';
import '../select-input/useMultiple.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../select-input/useOverlayInnerStyle.js';
import '../select/props.js';
import '../select/select-panel.js';
import 'lodash/omit';
import '../select/option.js';
import '../checkbox/index.js';
import '../checkbox/checkbox.js';
import '../checkbox/props.js';
import '../checkbox/constants.js';
import '../checkbox/group.js';
import '../hooks/slot.js';
import '../checkbox/checkbox-group-props.js';
import '../select/option-props.js';
import '../select/helper.js';
import '../select/optionGroup.js';
import '../select/option-group-props.js';
import '../select/hooks/usePanelVirtualScroll.js';
import '../hooks/useVirtualScroll.js';
import '../select/hooks/useSelectOptions.js';
import './panel/format/inputs.js';
import 'lodash/throttle';
import './panel/format/config.js';
import './panel/swatches.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _ColorPicker = defineComponent({
  name: "TColorPicker",
  props: _objectSpread({}, props),
  setup: function setup(props2) {
    var baseClassName = useBaseClassName();
    var visible = ref(false);
    var setVisible = function setVisible(value) {
      return visible.value = value;
    };
    var _toRefs = toRefs(props2),
      inputValue = _toRefs.value,
      modelValue = _toRefs.modelValue;
    var _useVModel = useVModel(inputValue, modelValue, props2.defaultValue, props2.onChange),
      _useVModel2 = _slicedToArray(_useVModel, 2),
      innerValue = _useVModel2[0],
      setInnerValue = _useVModel2[1];
    var refTrigger = ref();
    var renderPopupContent = function renderPopupContent() {
      if (props2.disabled) return null;
      var newProps = _objectSpread({}, props2);
      delete newProps.onChange;
      return createVNode(ColorPanel, mergeProps(newProps, {
        "disabled": props2.disabled,
        "value": innerValue.value,
        "togglePopup": setVisible,
        "onChange": function onChange(value, context) {
          return setInnerValue(value, context);
        }
      }), null);
    };
    return {
      baseClassName: baseClassName,
      innerValue: innerValue,
      visible: visible,
      refTrigger: refTrigger,
      renderPopupContent: renderPopupContent,
      setVisible: setVisible,
      setInnerValue: setInnerValue
    };
  },
  render: function render() {
    var _this = this;
    var popupProps = this.popupProps,
      baseClassName = this.baseClassName;
    var popProps = _objectSpread(_objectSpread({
      placement: "bottom-left"
    }, popupProps || {}), {}, {
      trigger: "click",
      attach: "body",
      overlayClassName: [baseClassName],
      visible: this.visible,
      overlayInnerStyle: {
        padding: 0
      },
      onVisibleChange: function onVisibleChange(visible, context) {
        if (context.trigger === "document") _this.setVisible(false);
      }
    });
    return createVNode(Popup, mergeProps(popProps, {
      "content": this.renderPopupContent
    }), {
      "default": function _default() {
        return [createVNode("div", {
          "class": "".concat(baseClassName, "__trigger"),
          "onClick": function onClick() {
            return _this.setVisible(!_this.visible);
          },
          "ref": "refTrigger"
        }, [renderTNodeJSXDefault(_this, "default", createVNode(DefaultTrigger, {
          "color": _this.innerValue,
          "disabled": _this.disabled,
          "clearable": _this.clearable,
          "input-props": _this.inputProps,
          "onTriggerChange": _this.setInnerValue
        }, null))])];
      }
    });
  }
});

export { _ColorPicker as default };
//# sourceMappingURL=color-picker.js.map
