/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

'use strict';

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

var hooks_useConfig = require('../../../hooks/useConfig.js');
require('@vue/composition-api');
require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../../chunks/zh_CN.js');

function useItemEvents(props, context) {
  const {
    node
  } = props;
  const classPrefix = hooks_useConfig.usePrefixClass().value;
  const handleChange = () => {
    const event = new Event("change");
    const state = {
      event,
      node
    };
    context.emit("change", state);
  };
  let clicked = false;
  const handleClick = evt => {
    const {
      expandOnClickNode
    } = props;
    const srcTarget = evt.target;
    const isBranchTrigger = node.children && expandOnClickNode && (srcTarget.className === `${classPrefix}-checkbox__input` || srcTarget.tagName.toLowerCase() === "input");
    if (clicked || isBranchTrigger) return;
    clicked = true;
    setTimeout(() => {
      clicked = false;
    });
    if (expandOnClickNode && node.children && srcTarget.className?.indexOf?.(`${classPrefix}-tree__label`) !== -1) evt.preventDefault();
    const state = {
      mouseEvent: evt,
      event: evt,
      node,
      path: node.getPath()
    };
    context.emit("click", state);
  };
  return {
    handleChange,
    handleClick
  };
}

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