{"version":3,"file":"selectors.cjs","names":["createRegistrySelector","normalizeComplementaryAreaScope","preferencesStore","normalizeComplementaryAreaName"],"sources":["../../src/store/selectors.ts"],"sourcesContent":["import { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tnormalizeComplementaryAreaScope,\n\tnormalizeComplementaryAreaName,\n} from './deprecated';\nimport type { StoreState } from './types';\n\n/**\n * Returns the complementary area that is active in a given scope.\n *\n * @param state Global application state.\n * @param scope Item scope.\n *\n * @return The complementary area that is active in the given scope.\n */\nexport const getActiveComplementaryArea = createRegistrySelector(\n\t( select ) => ( state: StoreState, scope: string ) => {\n\t\tscope = normalizeComplementaryAreaScope( scope );\n\t\tconst isComplementaryAreaVisible = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'isComplementaryAreaVisible'\n\t\t);\n\n\t\t// Return `undefined` to indicate that the user has never toggled\n\t\t// visibility, this is the vanilla default. Other code relies on this\n\t\t// nuance in the return value.\n\t\tif ( isComplementaryAreaVisible === undefined ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Return `null` to indicate the user hid the complementary area.\n\t\tif ( isComplementaryAreaVisible === false ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn state?.complementaryAreas?.[ scope ];\n\t}\n);\n\nexport const isComplementaryAreaLoading = createRegistrySelector(\n\t( select ) => ( state: StoreState, scope: string ) => {\n\t\tscope = normalizeComplementaryAreaScope( scope );\n\t\tconst isVisible: boolean | undefined = select( preferencesStore ).get(\n\t\t\tscope,\n\t\t\t'isComplementaryAreaVisible'\n\t\t);\n\t\tconst identifier = state?.complementaryAreas?.[ scope ];\n\n\t\treturn isVisible && identifier === undefined;\n\t}\n);\n\n/**\n * Returns a boolean indicating if an item is pinned or not.\n *\n * @param state Global application state.\n * @param scope Scope.\n * @param item  Item to check.\n *\n * @return True if the item is pinned and false otherwise.\n */\nexport const isItemPinned = createRegistrySelector(\n\t( select ) => ( state: StoreState, scope: string, item: string ) => {\n\t\tscope = normalizeComplementaryAreaScope( scope );\n\t\titem = normalizeComplementaryAreaName( scope, item );\n\t\tconst pinnedItems: Record< string, boolean > | undefined = select(\n\t\t\tpreferencesStore\n\t\t).get( scope, 'pinnedItems' );\n\t\treturn pinnedItems?.[ item ] ?? true;\n\t}\n);\n\n/**\n * Returns a boolean indicating whether a feature is active for a particular\n * scope.\n *\n * @param state       The store state.\n * @param scope       The scope of the feature (e.g. core/edit-post).\n * @param featureName The name of the feature.\n *\n * @return Is the feature enabled?\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state: StoreState, scope: string, featureName: string ) => {\n\t\tdeprecated(\n\t\t\t`select( 'core/interface' ).isFeatureActive( scope, featureName )`,\n\t\t\t{\n\t\t\t\tsince: '6.0',\n\t\t\t\talternative: `select( 'core/preferences' ).get( scope, featureName )`,\n\t\t\t}\n\t\t);\n\n\t\treturn !! select( preferencesStore ).get( scope, featureName );\n\t}\n);\n\n/**\n * Returns true if a modal is active, or false otherwise.\n *\n * @param state     Global application state.\n * @param modalName A string that uniquely identifies the modal.\n *\n * @return Whether the modal is active.\n */\nexport function isModalActive( state: StoreState, modalName: string ): boolean {\n\treturn state.activeModal === modalName;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,8BAAA,GAA6BA,gBAAAA,uBAAAA,EACvC,YAAc,OAAmB,UAAmB;CACrD,SAAA,GAAQC,gBAAAA,gCAAAA,CAAiC,KAAM;CAC/C,MAAM,6BAA6B,OAAQC,uBAAAA,KAAiB,CAAC,CAAC,IAC7D,OACA,4BACD;CAKA,IAAK,+BAA+B,KAAA,GACnC;CAID,IAAK,+BAA+B,OACnC,OAAO;CAGR,OAAO,OAAO,qBAAsB;AACrC,CACD;AAEA,MAAa,8BAAA,GAA6BF,gBAAAA,uBAAAA,EACvC,YAAc,OAAmB,UAAmB;CACrD,SAAA,GAAQC,gBAAAA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