"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-editor/src/components/inspector-controls-tabs/index.js
var inspector_controls_tabs_exports = {};
__export(inspector_controls_tabs_exports, {
  default: () => InspectorControlsTabs
});
module.exports = __toCommonJS(inspector_controls_tabs_exports);
var import_components = require("@wordpress/components");
var import_element = require("@wordpress/element");
var import_preferences = require("@wordpress/preferences");
var import_data = require("@wordpress/data");
var import_utils = require("./utils");
var import_settings_tab = __toESM(require("./settings-tab"));
var import_styles_tab = __toESM(require("./styles-tab"));
var import_content_tab = __toESM(require("./content-tab"));
var import_inspector_controls = __toESM(require("../inspector-controls"));
var import_use_is_list_view_tab_disabled = __toESM(require("./use-is-list-view-tab-disabled"));
var import_lock_unlock = require("../../lock-unlock");
var import_jsx_runtime = require("react/jsx-runtime");
var { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
function InspectorControlsTabs({
  blockName,
  clientId,
  hasBlockStyles,
  tabs,
  isSectionBlock,
  contentClientIds
}) {
  const showIconLabels = (0, import_data.useSelect)((select) => {
    return select(import_preferences.store).get("core", "showIconLabels");
  }, []);
  const initialTabName = !(0, import_use_is_list_view_tab_disabled.default)(blockName) ? import_utils.TAB_LIST_VIEW.name : void 0;
  const [selectedTabId, setSelectedTabId] = (0, import_element.useState)(
    initialTabName ?? tabs[0]?.name
  );
  (0, import_element.useEffect)(() => {
    if (initialTabName) {
      return;
    }
    if (tabs?.length && selectedTabId) {
      const activeTab = tabs.find(
        (tab) => tab.name === selectedTabId
      );
      if (!activeTab) {
        setSelectedTabId(tabs[0].name);
      }
    }
  }, [tabs, selectedTabId, initialTabName]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "block-editor-block-inspector__tabs", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
    Tabs,
    {
      defaultTabId: initialTabName,
      selectedTabId,
      onSelect: setSelectedTabId,
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabList, { children: tabs.map(
          (tab) => showIconLabels ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: tab.name, children: tab.title }, tab.name) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: tab.title, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
            Tabs.Tab,
            {
              tabId: tab.name,
              "aria-label": tab.title,
              children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: tab.icon })
            }
          ) }, tab.name)
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabPanel, { tabId: import_utils.TAB_SETTINGS.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_settings_tab.default, { showAdvancedControls: !!blockName }) }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabPanel, { tabId: import_utils.TAB_STYLES.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_styles_tab.default,
          {
            blockName,
            clientId,
            hasBlockStyles,
            isSectionBlock,
            contentClientIds
          }
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabPanel, { tabId: import_utils.TAB_CONTENT.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
          import_content_tab.default,
          {
            rootClientId: clientId,
            contentClientIds
          }
        ) }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabPanel, { tabId: import_utils.TAB_LIST_VIEW.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inspector_controls.default.Slot, { group: "list" }) })
      ]
    },
    clientId
  ) });
}
//# sourceMappingURL=index.js.map
