"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);
var use_pattern_settings_exports = {};
__export(use_pattern_settings_exports, {
  default: () => usePatternSettings
});
module.exports = __toCommonJS(use_pattern_settings_exports);
var import_core_data = require("@wordpress/core-data");
var import_data = require("@wordpress/data");
var import_element = require("@wordpress/element");
var import_lock_unlock = require("../../lock-unlock");
var import_store = require("../../store");
var import_utils = require("./utils");
function usePatternSettings() {
  const storedSettings = (0, import_data.useSelect)((select) => {
    const { getSettings } = (0, import_lock_unlock.unlock)(select(import_store.store));
    return getSettings();
  }, []);
  const settingsBlockPatterns = storedSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
  storedSettings.__experimentalBlockPatterns;
  const restBlockPatterns = (0, import_data.useSelect)(
    (select) => select(import_core_data.store).getBlockPatterns(),
    []
  );
  const blockPatterns = (0, import_element.useMemo)(
    () => [
      ...settingsBlockPatterns || [],
      ...restBlockPatterns || []
    ].filter(import_utils.filterOutDuplicatesByName),
    [settingsBlockPatterns, restBlockPatterns]
  );
  const settings = (0, import_element.useMemo)(() => {
    const { __experimentalAdditionalBlockPatterns, ...restStoredSettings } = storedSettings;
    return {
      ...restStoredSettings,
      __experimentalBlockPatterns: blockPatterns,
      isPreviewMode: true
    };
  }, [storedSettings, blockPatterns]);
  return settings;
}
//# sourceMappingURL=use-pattern-settings.js.map
