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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var components_cascader_props = require('../props.js');
var hooks_useConfig = require('../../../hooks/use-config.js');
var hooks_lnode = require('../../../hooks/lnode.js');
var components_cascader_utils_helper = require('../utils/helper.js');
var components_cascader_utils_effect = require('../utils/effect.js');
var components_cascader_components_Item = require('./Item.js');
var components_configProvider_useConfig = require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash');
require('../../../chunks/zh_CN.js');
require('lodash/isEmpty');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../../hooks/render-lnode.js');
require('lodash/isNumber');
require('lodash/cloneDeep');
require('../../../chunks/helper.js');
require('@ldesign/icons-vue');
require('../utils/className.js');
require('../../checkbox/index.js');
require('../../../utils/map-props.js');
require('vue');
require('../../../utils/with-install.js');
require('../../../config.js');
require('../../checkbox/group.js');
require('lodash/intersection');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/event.js');
require('../../../utils/helper.js');
require('../../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../../utils/mixins.js');
require('../../checkbox/checkbox.js');
require('../../../utils/render-node.js');
require('../../checkbox/props.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../utils/easing.js');
require('../../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/set-style.js');
require('../../../chunks/helper2.js');
require('../../loading/plugin.js');
require('../../../hooks/use-global-icon.js');
require('../../../utils/ripple.js');

var Panel = VueCompositionAPI.defineComponent({
  name: "LCascaderSubPanel",
  props: {
    empty: components_cascader_props["default"].empty,
    trigger: components_cascader_props["default"].trigger,
    onChange: components_cascader_props["default"].onChange,
    cascaderContext: {
      type: Object
    }
  },
  setup(props, _ref) {
    let {
      emit
    } = _ref;
    const renderTNodeJSXDefault = hooks_lnode.useLNodeDefault();
    const COMPONENT_NAME = hooks_useConfig.usePrefixClass("cascader");
    const {
      global
    } = components_configProvider_useConfig.useConfig("cascader");
    const panels = VueCompositionAPI.computed(() => components_cascader_utils_helper.getPanels(props.cascaderContext.treeNodes));
    const handleExpand = (node, trigger) => {
      const {
        trigger: propsTrigger,
        cascaderContext
      } = props;
      components_cascader_utils_effect.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(components_cascader_components_Item["default"], {
      "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: () => {
            components_cascader_utils_effect.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]);
  }
});

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