"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-library/src/template-part/edit/advanced-controls.js
var advanced_controls_exports = {};
__export(advanced_controls_exports, {
  TemplatePartAdvancedControls: () => TemplatePartAdvancedControls
});
module.exports = __toCommonJS(advanced_controls_exports);
var import_core_data = require("@wordpress/core-data");
var import_components = require("@wordpress/components");
var import_i18n = require("@wordpress/i18n");
var import_data = require("@wordpress/data");
var import_block_editor = require("@wordpress/block-editor");
var import_import_controls = require("./import-controls");
var import_lock_unlock = require("../../lock-unlock");
var import_jsx_runtime = require("react/jsx-runtime");
var { HTMLElementControl } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
function TemplatePartAdvancedControls({
  tagName,
  setAttributes,
  isEntityAvailable,
  templatePartId,
  defaultWrapper,
  hasInnerBlocks,
  clientId
}) {
  const [area, setArea] = (0, import_core_data.useEntityProp)(
    "postType",
    "wp_template_part",
    "area",
    templatePartId
  );
  const [title, setTitle] = (0, import_core_data.useEntityProp)(
    "postType",
    "wp_template_part",
    "title",
    templatePartId
  );
  const defaultTemplatePartAreas = (0, import_data.useSelect)(
    (select) => select(import_core_data.store).getCurrentTheme()?.default_template_part_areas || [],
    []
  );
  const areaOptions = defaultTemplatePartAreas.map(
    ({ label, area: _area }) => ({
      label,
      value: _area
    })
  );
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    isEntityAvailable && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import_components.TextControl,
        {
          __next40pxDefaultSize: true,
          __nextHasNoMarginBottom: true,
          label: (0, import_i18n.__)("Title"),
          value: title,
          onChange: (value) => {
            setTitle(value);
          },
          onFocus: (event) => event.target.select()
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
        import_components.SelectControl,
        {
          __next40pxDefaultSize: true,
          __nextHasNoMarginBottom: true,
          label: (0, import_i18n.__)("Area"),
          labelPosition: "top",
          options: areaOptions,
          value: area,
          onChange: setArea
        }
      )
    ] }),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      HTMLElementControl,
      {
        tagName: tagName || "",
        onChange: (value) => setAttributes({ tagName: value }),
        clientId,
        options: [
          {
            label: (0, import_i18n.sprintf)(
              /* translators: %s: HTML tag based on area. */
              (0, import_i18n.__)("Default based on area (%s)"),
              `<${defaultWrapper}>`
            ),
            value: ""
          },
          { label: "<header>", value: "header" },
          { label: "<main>", value: "main" },
          { label: "<section>", value: "section" },
          { label: "<article>", value: "article" },
          { label: "<aside>", value: "aside" },
          { label: "<footer>", value: "footer" },
          { label: "<div>", value: "div" }
        ]
      }
    ),
    !hasInnerBlocks && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      import_import_controls.TemplatePartImportControls,
      {
        area,
        setAttributes
      }
    )
  ] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  TemplatePartAdvancedControls
});
//# sourceMappingURL=advanced-controls.js.map
