"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/fill.js
var fill_exports = {};
__export(fill_exports, {
  PrivateInspectorControlsFill: () => PrivateInspectorControlsFill,
  default: () => InspectorControlsFill
});
module.exports = __toCommonJS(fill_exports);
var import_components = require("@wordpress/components");
var import_warning = __toESM(require("@wordpress/warning"));
var import_deprecated = __toESM(require("@wordpress/deprecated"));
var import_element = require("@wordpress/element");
var import_context = require("../block-edit/context.cjs");
var import_groups = __toESM(require("./groups.cjs"));
var import_jsx_runtime = require("react/jsx-runtime");
function PrivateInspectorControlsFill({
  children,
  group = "default",
  __experimentalGroup,
  resetAllFilter,
  forceDisplayControls
}) {
  if (__experimentalGroup) {
    (0, import_deprecated.default)(
      "`__experimentalGroup` property in `InspectorControlsFill`",
      {
        since: "6.2",
        version: "6.4",
        alternative: "`group`"
      }
    );
    group = __experimentalGroup;
  }
  const context = (0, import_context.useBlockEditContext)();
  const Fill = import_groups.default[group]?.Fill;
  if (!Fill) {
    (0, import_warning.default)(`Unknown InspectorControls group "${group}" provided.`);
    return null;
  }
  if (!forceDisplayControls && !context[import_context.mayDisplayControlsKey]) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalStyleProvider, { document, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fill, { children: (fillProps) => {
    return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      ToolsPanelInspectorControl,
      {
        fillProps,
        children,
        resetAllFilter
      }
    );
  } }) });
}
function InspectorControlsFill({
  children,
  group = "default",
  __experimentalGroup,
  resetAllFilter
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    PrivateInspectorControlsFill,
    {
      group,
      __experimentalGroup,
      resetAllFilter,
      children
    }
  );
}
function RegisterResetAll({ resetAllFilter, children }) {
  const { registerResetAllFilter, deregisterResetAllFilter } = (0, import_element.useContext)(import_components.__experimentalToolsPanelContext);
  (0, import_element.useEffect)(() => {
    if (resetAllFilter && registerResetAllFilter && deregisterResetAllFilter) {
      registerResetAllFilter(resetAllFilter);
      return () => {
        deregisterResetAllFilter(resetAllFilter);
      };
    }
  }, [resetAllFilter, registerResetAllFilter, deregisterResetAllFilter]);
  return children;
}
function ToolsPanelInspectorControl({ children, resetAllFilter, fillProps }) {
  const { forwardedContext = [] } = fillProps;
  const innerMarkup = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RegisterResetAll, { resetAllFilter, children });
  return forwardedContext.reduce(
    (inner, [Provider, props]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, { ...props, children: inner }),
    innerMarkup
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PrivateInspectorControlsFill
});
//# sourceMappingURL=fill.cjs.map
