/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { defineComponent, computed } from '@vue/composition-api';
import props from '../props.js';
import { usePrefixClass } from '../../../hooks/use-config.js';
import { useLNodeDefault } from '../../../hooks/lnode.js';
import { getPanels } from '../utils/helper.js';
import { expendClickEffect, valueChangeEffect } from '../utils/effect.js';
import Item from './Item.js';
import { useConfig } from '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash';
import '../../../_chunks/dep-def4c2ce.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../../hooks/render-lnode.js';
import 'lodash/isNumber';
import 'lodash/cloneDeep';
import '../../../_chunks/dep-29915b8e.js';
import '@ldesign/icons-vue';
import '../utils/className.js';
import '../../checkbox/index.js';
import '../../../utils/map-props.js';
import 'vue';
import '../../../utils/with-install.js';
import '../../../config.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../../_chunks/dep-70c789e5.js';
import '../../../_chunks/dep-5210251b.js';
import '../../../utils/event.js';
import '../../../utils/helper.js';
import '../../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../../utils/mixins.js';
import '../../checkbox/checkbox.js';
import '../../../utils/render-node.js';
import '../../checkbox/props.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../../utils/easing.js';
import '../../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../../_chunks/dep-eb467ddf.js';
import '../../../_chunks/dep-cf772670.js';
import '../../../_chunks/dep-47d77fc8.js';
import '../../loading/plugin.js';
import '../../../hooks/use-global-icon.js';
import '../../../utils/ripple.js';

var Panel = defineComponent({
  name: "LCascaderSubPanel",
  props: {
    empty: props.empty,
    trigger: props.trigger,
    onChange: props.onChange,
    cascaderContext: {
      type: Object
    }
  },
  setup(props, _ref) {
    let {
      emit
    } = _ref;
    const renderTNodeJSXDefault = useLNodeDefault();
    const COMPONENT_NAME = usePrefixClass("cascader");
    const {
      global
    } = useConfig("cascader");
    const panels = computed(() => getPanels(props.cascaderContext.treeNodes));
    const handleExpand = (node, trigger) => {
      const {
        trigger: propsTrigger,
        cascaderContext
      } = props;
      expendClickEffect(propsTrigger, trigger, node, cascaderContext);
    };
    return {
      global,
      panels,
      handleExpand,
      renderTNodeJSXDefault,
      COMPONENT_NAME,
      emit
    };
  },
  render() {
    const h = arguments[0];
    const {
      global,
      COMPONENT_NAME,
      handleExpand,
      renderTNodeJSXDefault,
      cascaderContext,
      panels,
      emit
    } = this;
    const renderItem = node => h(Item, {
      "key": node.value,
      "attrs": {
        "node": node,
        "cascaderContext": cascaderContext
      },
      "props": {
        ...{
          node,
          cascaderContext,
          onClick: () => {
            emit("click", node.value, node);
            handleExpand(node, "click");
          },
          onMouseenter: () => {
            handleExpand(node, "hover");
          },
          onChange: () => {
            valueChangeEffect(node, cascaderContext);
          }
        }
      }
    });
    const renderList = function (treeNodes) {
      let isFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let segment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
      let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "1";
      return h("ul", {
        "class": [`${COMPONENT_NAME}__menu`, "narrow-scrollbar", {
          [`${COMPONENT_NAME}__menu--segment`]: segment,
          [`${COMPONENT_NAME}__menu--filter`]: isFilter
        }],
        "key": key
      }, [treeNodes.map(node => renderItem(node))]);
    };
    const renderPanels = () => {
      const {
        inputVal,
        treeNodes
      } = cascaderContext;
      return inputVal ? renderList(treeNodes, true) : panels.map((treeNodes2, index) => renderList(treeNodes2, false, index !== panels.length - 1, `${COMPONENT_NAME}__menu${index}`));
    };
    let content;
    if (this.loading) {
      content = renderTNodeJSXDefault("loadingText", h("div", {
        "class": `${COMPONENT_NAME}__panel--empty`
      }, [global.loadingText]));
    } else {
      content = panels.length ? renderPanels() : renderTNodeJSXDefault("empty", h("div", {
        "class": `${COMPONENT_NAME}__panel--empty`
      }, [global.empty]));
    }
    return h("div", {
      "class": [`${COMPONENT_NAME}__panel`, {
        [`${COMPONENT_NAME}--normal`]: panels.length && !this.loading
      }]
    }, [content]);
  }
});

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