"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _components = require("@wordpress/components");
var _element = require("@wordpress/element");
var _i18n = require("@wordpress/i18n");
var _patternExplorerSidebar = _interopRequireDefault(require("./pattern-explorer-sidebar"));
var _patternList = _interopRequireDefault(require("./pattern-list"));
var _usePatternCategories = require("../block-patterns-tab/use-pattern-categories");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function PatternsExplorer({
  initialCategory,
  rootClientId
}) {
  const [searchValue, setSearchValue] = (0, _element.useState)('');
  const [selectedCategory, setSelectedCategory] = (0, _element.useState)(initialCategory?.name);
  const patternCategories = (0, _usePatternCategories.usePatternCategories)(rootClientId);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "block-editor-block-patterns-explorer",
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_patternExplorerSidebar.default, {
      selectedCategory: selectedCategory,
      patternCategories: patternCategories,
      onClickCategory: setSelectedCategory,
      searchValue: searchValue,
      setSearchValue: setSearchValue
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_patternList.default, {
      searchValue: searchValue,
      selectedCategory: selectedCategory,
      patternCategories: patternCategories,
      rootClientId: rootClientId
    })]
  });
}
function PatternsExplorerModal({
  onModalClose,
  ...restProps
}) {
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
    title: (0, _i18n.__)('Patterns'),
    onRequestClose: onModalClose,
    isFullScreen: true,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PatternsExplorer, {
      ...restProps
    })
  });
}
var _default = exports.default = PatternsExplorerModal;
//# sourceMappingURL=index.js.map