"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-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js
var use_spacing_sizes_exports = {};
__export(use_spacing_sizes_exports, {
  default: () => useSpacingSizes
});
module.exports = __toCommonJS(use_spacing_sizes_exports);
var import_element = require("@wordpress/element");
var import_i18n = require("@wordpress/i18n");
var import_use_settings = require("../../use-settings");
var import_utils = require("../utils");
var EMPTY_ARRAY = [];
var compare = new Intl.Collator("und", { numeric: true }).compare;
function useSpacingSizes() {
  const [
    customSpacingSizes,
    themeSpacingSizes,
    defaultSpacingSizes,
    defaultSpacingSizesEnabled
  ] = (0, import_use_settings.useSettings)(
    "spacing.spacingSizes.custom",
    "spacing.spacingSizes.theme",
    "spacing.spacingSizes.default",
    "spacing.defaultSpacingSizes"
  );
  const customSizes = customSpacingSizes ?? EMPTY_ARRAY;
  const themeSizes = themeSpacingSizes ?? EMPTY_ARRAY;
  const defaultSizes = defaultSpacingSizes && defaultSpacingSizesEnabled !== false ? defaultSpacingSizes : EMPTY_ARRAY;
  return (0, import_element.useMemo)(() => {
    const sizes = [
      { name: (0, import_i18n.__)("None"), slug: "0", size: 0 },
      ...customSizes,
      ...themeSizes,
      ...defaultSizes
    ];
    if (sizes.every(({ slug }) => /^[0-9]/.test(slug))) {
      sizes.sort((a, b) => compare(a.slug, b.slug));
    }
    return sizes.length > import_utils.RANGE_CONTROL_MAX_SIZE ? [
      {
        name: (0, import_i18n.__)("Default"),
        slug: "default",
        size: void 0
      },
      ...sizes
    ] : sizes;
  }, [customSizes, themeSizes, defaultSizes]);
}
//# sourceMappingURL=use-spacing-sizes.js.map
