"use strict";

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

/**
 * Internal dependencies
 */

const {
  useGlobalStyle,
  useGlobalSetting,
  useSettingsForBlockElement,
  TypographyPanel: StylesTypographyPanel
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
function TypographyPanel({
  element,
  headingLevel
}) {
  let prefixParts = [];
  if (element === 'heading') {
    prefixParts = prefixParts.concat(['elements', headingLevel]);
  } else if (element && element !== 'text') {
    prefixParts = prefixParts.concat(['elements', element]);
  }
  const prefix = prefixParts.join('.');
  const [style] = useGlobalStyle(prefix, undefined, 'user', {
    shouldDecodeEncode: false
  });
  const [inheritedStyle, setStyle] = useGlobalStyle(prefix, undefined, 'all', {
    shouldDecodeEncode: false
  });
  const [rawSettings] = useGlobalSetting('');
  const usedElement = element === 'heading' ? headingLevel : element;
  const settings = useSettingsForBlockElement(rawSettings, undefined, usedElement);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StylesTypographyPanel, {
    inheritedValue: inheritedStyle,
    value: style,
    onChange: setStyle,
    settings: settings
  });
}
//# sourceMappingURL=typography-panel.js.map