/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { prefix } from '../../config.js';
import { renderTNodeJSXDefault } from '../../utils/render-tnode.js';
import getConfigReceiverMixins from '../../config-provider/config-receiver.js';
import mixins from '../../utils/mixins.js';
import { getPanels, expendClickEffect, valueChangeEffect } from '../utils/panel.js';
import Item from './Item.js';
import props from '../props.js';
import '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import 'lodash/merge';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '../../config-provider/type.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/isNumber';
import '../../_chunks/dep-37d5b9c4.js';
import 'tdesign-icons-vue';
import '../../utils/classnames.js';
import '../../utils/ripple.js';
import '../../_common/js/utils/set-style.js';
import '../utils/helper.js';
import 'lodash/isEmpty';
import '../utils/item.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/index.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../checkbox/index.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../checkbox/checkbox.js';
import '../../checkbox/props.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../../utils/event.js';
import '../../checkbox/checkbox-group-props.js';
import '../../utils/map-props.js';
import '../../checkbox/type.js';
import '../../tooltip/index.js';
import '../../tooltip/tooltip.js';
import 'lodash/isFunction';
import '../../tooltip/props.js';
import '../../popup/props.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../popup/container.js';
import '../../tooltip/type.js';

var name = "".concat(prefix, "-cascader");
var Panel = mixins(getConfigReceiverMixins("cascader")).extend({
  name: "".concat(name, "-panel"),
  props: {
    empty: props.empty,
    trigger: props.trigger,
    onChange: props.onChange,
    cascaderContext: {
      type: Object
    }
  },
  computed: {
    panels: function panels() {
      return getPanels(this.cascaderContext.treeNodes);
    }
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var _this$cascaderContext = this.cascaderContext,
        filterActive = _this$cascaderContext.filterActive,
        treeNodes = _this$cascaderContext.treeNodes,
        inputWidth = _this$cascaderContext.inputWidth,
        cascaderContext = this.cascaderContext,
        panels = this.panels;

    var handleExpand = function handleExpand(ctx, trigger) {
      var node = ctx.node;
      var propsTrigger = _this.trigger,
          cascaderContext2 = _this.cascaderContext;
      expendClickEffect(propsTrigger, trigger, node, cascaderContext2);
    };

    var handleChange = function handleChange(ctx) {
      var node = ctx.node;
      var cascaderContext2 = _this.cascaderContext;
      valueChangeEffect(node, cascaderContext2);
    };

    var renderEmpty = renderTNodeJSXDefault(this, "empty", h("div", {
      "class": "".concat(name, "__panel--empty")
    }, [this.t(this.global.empty)]));

    var renderItem = function renderItem(node) {
      return h(Item, {
        "key": node.value,
        "attrs": {
          "node": node,
          "cascaderContext": cascaderContext
        },
        "on": {
          "click": function click(ctx) {
            handleExpand(ctx, "click");
          },
          "mouseenter": function mouseenter(ctx) {
            handleExpand(ctx, "hover");
          },
          "change": handleChange
        }
      });
    };

    var panelsContainer = panels.map(function (panel, index) {
      return h("ul", {
        "class": ["".concat(name, "__menu"), "narrow-scrollbar", _defineProperty({}, "".concat(name, "__menu--segment"), index !== panels.length - 1)],
        "key": index
      }, [panel.map(function (node) {
        return renderItem(node);
      })]);
    });
    var filterPanelsContainer = h("ul", {
      "class": ["".concat(name, "__menu"), "narrow-scrollbar", "".concat(name, "__menu--segment"), "".concat(name, "__menu--filter")]
    }, [treeNodes.map(function (node) {
      return renderItem(node);
    })]);
    var renderPanels = filterActive ? filterPanelsContainer : panelsContainer;
    return h("div", {
      "class": ["".concat(name, "__panel"), _defineProperty({}, "".concat(name, "--normal"), panels.length)],
      "style": {
        width: panels.length === 0 ? "".concat(inputWidth, "px") : null
      }
    }, [panels && panels.length ? renderPanels : renderEmpty]);
  }
});

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