{
  "version": 3,
  "sources": ["../../../src/components/block-editor/use-site-editor-settings.js"],
  "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { usePrevious } from '@wordpress/compose';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { generateGlobalStyles } from '@wordpress/global-styles-engine';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport useNavigateToEntityRecord from './use-navigate-to-entity-record';\nimport { FOCUSABLE_ENTITIES } from '../../utils/constants';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\nconst { useGlobalStyles } = unlock( editorPrivateApis );\n\nfunction useNavigateToPreviousEntityRecord() {\n\tconst location = useLocation();\n\tconst previousCanvas = usePrevious( location.query.canvas );\n\tconst history = useHistory();\n\tconst goBack = useMemo( () => {\n\t\tconst isFocusMode =\n\t\t\tlocation.query.focusMode ||\n\t\t\t( location?.params?.postId &&\n\t\t\t\tFOCUSABLE_ENTITIES.includes( location?.params?.postType ) );\n\t\tconst didComeFromEditorCanvas = previousCanvas === 'edit';\n\t\tconst showBackButton = isFocusMode && didComeFromEditorCanvas;\n\t\treturn showBackButton ? () => history.back() : undefined;\n\t}, [ location, history, previousCanvas ] );\n\treturn goBack;\n}\n\nexport function useSpecificEditorSettings() {\n\tconst { query } = useLocation();\n\tconst { canvas = 'view' } = query;\n\tconst onNavigateToEntityRecord = useNavigateToEntityRecord();\n\n\t/*\n\t * Generate global styles directly to avoid circular dependency with GlobalStylesRenderer\n\t * (which runs inside ExperimentalEditorProvider after this hook).\n\t * GlobalStylesRenderer updates editorStore, but reading from it here would cause infinite\n\t * loops. Reading config from useGlobalStyles and generating CSS directly keeps us in sync.\n\t * See: https://github.com/WordPress/gutenberg/issues/73350\n\t */\n\tconst { merged: mergedConfig } = useGlobalStyles();\n\n\tconst { settings, currentPostIsTrashed } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( editSiteStore );\n\t\tconst { getCurrentPostAttribute } = select( editorStore );\n\t\treturn {\n\t\t\tsettings: getSettings(),\n\t\t\tcurrentPostIsTrashed:\n\t\t\t\tgetCurrentPostAttribute( 'status' ) === 'trash',\n\t\t};\n\t}, [] );\n\n\tconst onNavigateToPreviousEntityRecord =\n\t\tuseNavigateToPreviousEntityRecord();\n\n\tconst [ globalStyles, globalSettings ] = useMemo( () => {\n\t\treturn generateGlobalStyles( mergedConfig, [], {\n\t\t\tdisableRootPadding: false,\n\t\t} );\n\t}, [ mergedConfig ] );\n\n\tconst defaultEditorSettings = useMemo( () => {\n\t\t// Preserve non-global styles from settings.styles (e.g., editor styles from add_editor_style)\n\t\tconst nonGlobalStyles = ( settings?.styles ?? [] ).filter(\n\t\t\t( style ) => ! style.isGlobalStyles\n\t\t);\n\n\t\treturn {\n\t\t\t...settings,\n\t\t\tstyles: [\n\t\t\t\t...nonGlobalStyles,\n\t\t\t\t...globalStyles,\n\t\t\t\t{\n\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\tcss:\n\t\t\t\t\t\tcanvas === 'view'\n\t\t\t\t\t\t\t? `body{min-height: 100vh; ${\n\t\t\t\t\t\t\t\t\tcurrentPostIsTrashed\n\t\t\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t\t\t: 'cursor: pointer;'\n\t\t\t\t\t\t\t  }}`\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t],\n\t\t\t__experimentalFeatures: globalSettings,\n\t\t\trichEditingEnabled: true,\n\t\t\tsupportsTemplateMode: true,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tisPreviewMode: canvas === 'view',\n\t\t};\n\t}, [\n\t\tsettings,\n\t\tglobalStyles,\n\t\tglobalSettings,\n\t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