"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _i18n = require("@wordpress/i18n");
var _components = require("@wordpress/components");
var _icons = require("@wordpress/icons");
var _lockUnlock = require("../../../lock-unlock");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const {
  Tabs
} = (0, _lockUnlock.unlock)(_components.privateApis);
function CategoryTabs({
  categories,
  selectedCategory,
  onSelectCategory,
  children
}) {
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tabs, {
    className: "block-editor-inserter__category-tabs",
    selectOnMove: false,
    selectedTabId: selectedCategory ? selectedCategory.name : null,
    orientation: "vertical",
    onSelect: categoryId => {
      // Pass the full category object
      onSelectCategory(categories.find(category => category.name === categoryId));
    },
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabList, {
      className: "block-editor-inserter__category-tablist",
      children: categories.map(category => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.Tab, {
        tabId: category.name,
        className: "block-editor-inserter__category-tab",
        "aria-label": category.label,
        "aria-current": category === selectedCategory ? 'true' : undefined,
        children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexBlock, {
            children: category.label
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
            icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
          })]
        })
      }, category.name))
    }), categories.map(category => /*#__PURE__*/(0, _jsxRuntime.jsx)(Tabs.TabPanel, {
      tabId: category.name,
      focusable: false,
      className: "block-editor-inserter__category-panel",
      children: children
    }, category.name))]
  });
}
var _default = exports.default = CategoryTabs;
//# sourceMappingURL=index.js.map