"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = CategorySelect;
var _terms = require("./terms");
var _treeSelect = _interopRequireDefault(require("../tree-select"));
var _element = require("@wordpress/element");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * Internal dependencies
 */

/**
 * WordPress dependencies
 */

function CategorySelect({
  __next40pxDefaultSize,
  label,
  noOptionLabel,
  categoriesList,
  selectedCategoryId,
  onChange: onChangeProp,
  ...props
}) {
  const termsTree = (0, _element.useMemo)(() => {
    return (0, _terms.buildTermsTree)(categoriesList);
  }, [categoriesList]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_treeSelect.default, {
    label,
    noOptionLabel,
    onChange: onChangeProp,
    tree: termsTree,
    selectedId: selectedCategoryId !== undefined ? String(selectedCategoryId) : undefined,
    ...props,
    __nextHasNoMarginBottom: true,
    __next40pxDefaultSize: __next40pxDefaultSize
  });
}
//# sourceMappingURL=category-select.js.map