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

import { _ as _defineProperty } from '../../_chunks/dep-eb20e23f.mjs';
import { defineComponent, computed, createVNode } from 'vue';
import props from '../props.mjs';
import { usePrefixClass } from '../../hooks/useConfig.mjs';
import { useTNodeDefault } from '../../hooks/tnode.mjs';
import { getPanels } from '../core/helper.mjs';
import { expendClickEffect, valueChangeEffect } from '../core/effect.mjs';
import Item from './Item.mjs';
import { useConfig } from '../../config-provider/useConfig.mjs';
import '../../_chunks/dep-b4041200.mjs';
import '../../_chunks/dep-44417261.mjs';
import '../../_chunks/dep-a0b4a044.mjs';
import '../../_chunks/dep-bf74f1c2.mjs';
import '../../_chunks/dep-79821ff2.mjs';
import '../../_chunks/dep-0bfbf721.mjs';
import '../../_chunks/dep-39cc276d.mjs';
import '../../_chunks/dep-6b22dd27.mjs';
import '../../_chunks/dep-c959a6fb.mjs';
import '../../_chunks/dep-0f0c89ff.mjs';
import '../../_chunks/dep-8f777748.mjs';
import '../../_chunks/dep-ae357f26.mjs';
import '../../_chunks/dep-352691c2.mjs';
import '../../_chunks/dep-2cfd5b3a.mjs';
import '../../_chunks/dep-05fa17c9.mjs';
import '../../_chunks/dep-c31e1d9e.mjs';
import '../../_chunks/dep-e3b14d70.mjs';
import '../../_chunks/dep-66d6733b.mjs';
import '../../_chunks/dep-a9c8a5d5.mjs';
import '../../_chunks/dep-10085c61.mjs';
import '../../_chunks/dep-1b058de3.mjs';
import '../../_chunks/dep-c852a61a.mjs';
import '../../_chunks/dep-92e7085e.mjs';
import '../../_chunks/dep-44f056cd.mjs';
import '../../_chunks/dep-23a0f453.mjs';
import '../../_chunks/dep-1cf2b129.mjs';
import '../../_chunks/dep-99920870.mjs';
import '../../_chunks/dep-c7e9ce16.mjs';
import '../../_chunks/dep-3afa94cf.mjs';
import '../../_chunks/dep-ba3c0b2e.mjs';
import '../../_chunks/dep-ee57d235.mjs';
import '../../_common/js/global-config/default-config.mjs';
import '../../_common/js/global-config/locale/zh_CN.mjs';
import '../../_chunks/dep-6b4aa943.mjs';
import '../../_chunks/dep-d52291a9.mjs';
import '../../config-provider/type.mjs';
import '../../_chunks/dep-f6649a46.mjs';
import '../../_chunks/dep-37ba476d.mjs';
import '../../_chunks/dep-be27d184.mjs';
import '../../_chunks/dep-1fe0ad42.mjs';
import '../../_chunks/dep-d54f2690.mjs';
import '../../_chunks/dep-59c8420d.mjs';
import '../../_chunks/dep-74848b92.mjs';
import '../../_chunks/dep-c4e1a112.mjs';
import '../../utils/render-tnode.mjs';
import '../../_chunks/dep-bd03960e.mjs';
import '../../_chunks/dep-6eea369f.mjs';
import '../../_chunks/dep-55846619.mjs';
import '../../_chunks/dep-cfcedf47.mjs';
import '@ldesign/icons-vue-next';
import '../core/className.mjs';
import '../../_chunks/dep-e091cfd9.mjs';
import '../../checkbox/index.mjs';
import '../../utils/withInstall.mjs';
import '../../checkbox/checkbox.mjs';
import '../../hooks/useVModel.mjs';
import '../../form/hooks.mjs';
import '../../hooks/useRipple.mjs';
import '../../utils/set-style.mjs';
import '../../hooks/useKeepAnimation.mjs';
import '../../checkbox/props.mjs';
import '../../checkbox/constants.mjs';
import '../../checkbox/group.mjs';
import '../../_chunks/dep-0492e83e.mjs';
import '../../_chunks/dep-5d966cee.mjs';
import '../../_chunks/dep-30451c48.mjs';
import '../../hooks/slot.mjs';
import '../../checkbox/checkbox-group-props.mjs';
import '../../checkbox/style/css.mjs';
import '../../checkbox/type.mjs';
import '../../loading/index.mjs';
import '../../loading/directive.mjs';
import '../../loading/plugin.mjs';
import '../../utils/dom.mjs';
import '../../utils/easing.mjs';
import '../../loading/loading.mjs';
import '../../hooks/useTeleport.mjs';
import '../../loading/props.mjs';
import '../../loading/icon/gradient.mjs';
import '../../_common/js/loading/circle-adapter.mjs';
import '../../_common/js/utils/set-style.mjs';
import '../../_common/js/utils/helper.mjs';
import '../../_chunks/dep-b6a73f93.mjs';
import '../../_chunks/dep-6f89b77e.mjs';
import '../../loading/style/css.mjs';
import '../../loading/type.mjs';
import '../../hooks/useGlobalIcon.mjs';

var Panel = defineComponent({
  name: "TCascaderSubPanel",
  props: {
    empty: props.empty,
    trigger: props.trigger,
    onChange: props.onChange,
    loading: props.loading,
    loadingText: props.loadingText,
    cascaderContext: {
      type: Object
    }
  },
  setup: function setup(props) {
    var renderTNodeJSXDefault = useTNodeDefault();
    var COMPONENT_NAME = usePrefixClass("cascader");
    var _useConfig = useConfig("cascader"),
      globalConfig = _useConfig.globalConfig;
    var panels = computed(function () {
      return getPanels(props.cascaderContext.treeNodes);
    });
    var handleExpand = function handleExpand(node, trigger) {
      var propsTrigger = props.trigger,
        cascaderContext = props.cascaderContext;
      expendClickEffect(propsTrigger, trigger, node, cascaderContext);
    };
    var renderItem = function renderItem(node) {
      return createVNode(Item, {
        "key": node.value,
        "node": node,
        "cascaderContext": props.cascaderContext,
        "onClick": function onClick() {
          handleExpand(node, "click");
        },
        "onMouseenter": function onMouseenter() {
          handleExpand(node, "hover");
        },
        "onChange": function onChange() {
          valueChangeEffect(node, props.cascaderContext);
        }
      }, null);
    };
    var renderList = function renderList(treeNodes) {
      var _ref;
      var isFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var segment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "1";
      return createVNode("ul", {
        "class": ["".concat(COMPONENT_NAME.value, "__menu"), "narrow-scrollbar", (_ref = {}, _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "__menu--segment"), segment), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "__menu--filter"), isFilter), _ref)],
        "key": key
      }, [treeNodes.map(function (node) {
        return renderItem(node);
      })]);
    };
    var renderPanels = function renderPanels() {
      var _props$cascaderContex = props.cascaderContext,
        inputVal = _props$cascaderContex.inputVal,
        treeNodes = _props$cascaderContex.treeNodes;
      return inputVal ? renderList(treeNodes, true) : panels.value.map(function (treeNodes2, index) {
        return renderList(treeNodes2, false, index !== panels.value.length - 1, "".concat(COMPONENT_NAME.value, "__menu").concat(index));
      });
    };
    return function () {
      var content;
      if (props.loading) {
        content = renderTNodeJSXDefault("loadingText", createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.loadingText]));
      } else {
        content = panels.value.length ? renderPanels() : renderTNodeJSXDefault("empty", createVNode("div", {
          "class": "".concat(COMPONENT_NAME.value, "__panel--empty")
        }, [globalConfig.value.empty]));
      }
      return createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__panel"), _defineProperty({}, "".concat(COMPONENT_NAME.value, "--normal"), panels.value.length && !props.loading)]
      }, [content]);
    };
  }
});

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