"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = BackgroundPanel;
exports.hasBackgroundImageValue = hasBackgroundImageValue;
var _blockEditor = require("@wordpress/block-editor");
var _lockUnlock = require("../../lock-unlock");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

// Initial control values where no block style is set.
const BACKGROUND_DEFAULT_VALUES = {
  backgroundSize: 'auto'
};
const {
  useGlobalStyle,
  useGlobalSetting,
  BackgroundPanel: StylesBackgroundPanel
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);

/**
 * Checks if there is a current value in the background image block support
 * attributes.
 *
 * @param {Object} style Style attribute.
 * @return {boolean}     Whether the block has a background image value set.
 */
function hasBackgroundImageValue(style) {
  return !!style?.background?.backgroundImage?.id || !!style?.background?.backgroundImage?.url || typeof style?.background?.backgroundImage === 'string';
}
function BackgroundPanel() {
  const [style] = useGlobalStyle('', undefined, 'user', {
    shouldDecodeEncode: false
  });
  const [inheritedStyle, setStyle] = useGlobalStyle('', undefined, 'all', {
    shouldDecodeEncode: false
  });
  const [settings] = useGlobalSetting('');
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StylesBackgroundPanel, {
    inheritedValue: inheritedStyle,
    value: style,
    onChange: setStyle,
    settings: settings,
    defaultValues: BACKGROUND_DEFAULT_VALUES
  });
}
//# sourceMappingURL=background-panel.js.map