{"version":3,"file":"index.mjs","names":[],"sources":["../../src/redux-store/index.ts"],"sourcesContent":["import { createStore, applyMiddleware } from 'redux';\nimport type { Store as ReduxStore, StoreEnhancer } from 'redux';\nimport EquivalentKeyMap from 'equivalent-key-map';\nimport createReduxRoutineMiddleware from '@wordpress/redux-routine';\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from './combine-reducers';\nimport { builtinControls } from '../controls';\nimport { lock } from '../lock-unlock';\nimport promise from '../promise-middleware';\nimport createResolversCacheMiddleware from '../resolvers-cache-middleware';\nimport createThunkMiddleware from './thunk-middleware';\nimport metadataReducer from './metadata/reducer';\nimport * as metadataSelectors from './metadata/selectors';\nimport * as metadataActions from './metadata/actions';\nimport type {\n\tDataRegistry,\n\tListenerFunction,\n\tStoreDescriptor,\n\tReduxStoreConfig,\n\tActionCreator,\n\tNormalizedResolver,\n} from '../types';\n\nexport { combineReducers };\n\n/**\n * Augment the Redux store with internal properties used by the data module.\n */\ninterface AugmentedReduxStore extends ReduxStore {\n\t__unstableOriginalGetState: ReduxStore[ 'getState' ];\n}\n\ninterface ResolversCache {\n\tisRunning: ( selectorName: string, args: unknown[] ) => boolean;\n\tclear: ( selectorName: string, args: unknown[] ) => void;\n\tmarkAsRunning: ( selectorName: string, args: unknown[] ) => void;\n}\n\ninterface BindingCache {\n\tget: ( itemName: string ) => ( ( ...args: unknown[] ) => unknown ) | null;\n}\n\ninterface SelectorLike {\n\t( ...args: any[] ): any;\n\thasResolver?: boolean;\n\tisRegistrySelector?: boolean;\n\tregistry?: DataRegistry;\n\tnormalizeArgs?: ( args: unknown[] ) => unknown[];\n\t__unstableNormalizeArgs?: ( args: unknown[] ) => unknown[];\n}\n\nconst trimUndefinedValues = ( array: unknown[] ): unknown[] => {\n\tconst result = [ ...array ];\n\tfor ( let i = result.length - 1; i >= 0; i-- ) {\n\t\tif ( result[ i ] === undefined ) {\n\t\t\tresult.splice( i, 1 );\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Creates a new object with the same keys, but with `callback()` called as\n * a transformer function on each of the values.\n *\n * @param obj      The object to transform.\n * @param callback The function to transform each object value.\n * @return Transformed object.\n */\nconst mapValues = < T, U >(\n\tobj: Record< string, T > | undefined,\n\tcallback: ( value: T, key: string ) => U\n): Record< string, U > =>\n\tObject.fromEntries(\n\t\tObject.entries( obj ?? {} ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tcallback( value, key ),\n\t\t] )\n\t);\n\n// Convert  non serializable types to plain objects\nconst devToolsReplacer = ( _key: string, state: unknown ): unknown => {\n\tif ( state instanceof Map ) {\n\t\treturn Object.fromEntries( state );\n\t}\n\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\tstate instanceof window.HTMLElement\n\t) {\n\t\treturn null;\n\t}\n\n\treturn state;\n};\n\n/**\n * Create a cache to track whether resolvers started running or not.\n *\n * @return Resolvers Cache.\n */\nfunction createResolversCache(): ResolversCache {\n\tconst cache: Record< string, EquivalentKeyMap< unknown[], boolean > > = {};\n\treturn {\n\t\tisRunning( selectorName: string, args: unknown[] ): boolean {\n\t\t\treturn !! (\n\t\t\t\tcache[ selectorName ] &&\n\t\t\t\tcache[ selectorName ].get( trimUndefinedValues( args ) )\n\t\t\t);\n\t\t},\n\n\t\tclear( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ].delete( trimUndefinedValues( args ) );\n\t\t\t}\n\t\t},\n\n\t\tmarkAsRunning( selectorName: string, args: unknown[] ): void {\n\t\t\tif ( ! cache[ selectorName ] ) {\n\t\t\t\tcache[ selectorName ] = new EquivalentKeyMap();\n\t\t\t}\n\n\t\t\tcache[ selectorName ].set( trimUndefinedValues( args ), true );\n\t\t},\n\t};\n}\n\nfunction createBindingCache(\n\tgetItem: ( name: string ) => ( ( ...args: any[] ) => any ) | undefined,\n\tbindItem: (\n\t\titem: ( ...args: any[] ) => any,\n\t\tname: string\n\t) => ( ...args: unknown[] ) => unknown\n): BindingCache {\n\tconst cache = new WeakMap<\n\t\t( ...args: any[] ) => any,\n\t\t( ...args: unknown[] ) => unknown\n\t>();\n\n\treturn {\n\t\tget( itemName: string ) {\n\t\t\tconst item = getItem( itemName );\n\t\t\tif ( ! item ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet boundItem = cache.get( item );\n\t\t\tif ( ! boundItem ) {\n\t\t\t\tboundItem = bindItem( item, itemName );\n\t\t\t\tcache.set( item, boundItem );\n\t\t\t}\n\t\t\treturn boundItem;\n\t\t},\n\t};\n}\n\nfunction createPrivateProxy< T extends Record< string, any > >(\n\tpublicItems: T,\n\tprivateItems: BindingCache\n): T {\n\treturn new Proxy( publicItems, {\n\t\tget: ( target, itemName: string ) =>\n\t\t\tprivateItems.get( itemName ) || Reflect.get( target, itemName ),\n\t} );\n}\n\n/**\n * Creates a data store descriptor for the provided Redux store configuration containing\n * properties describing reducer, actions, selectors, controls and resolvers.\n *\n * @example\n * ```js\n * import { createReduxStore } from '@wordpress/data';\n *\n * const store = createReduxStore( 'demo', {\n *     reducer: ( state = 'OK' ) => state,\n *     selectors: {\n *         getValue: ( state ) => state,\n *     },\n * } );\n * ```\n *\n * @param key     Unique namespace identifier.\n * @param options Registered store options, with properties\n *                describing reducer, actions, selectors,\n *                and resolvers.\n *\n * @return Store Object.\n */\nexport default function createReduxStore< State, Actions, Selectors >(\n\tkey: string,\n\toptions: ReduxStoreConfig< State, Actions, Selectors >\n): StoreDescriptor< ReduxStoreConfig< State, Actions, Selectors > > {\n\tconst privateActions: Record< string, ActionCreator > = {};\n\tconst privateSelectors: Record< string, SelectorLike > = {};\n\tconst privateRegistrationFunctions = {\n\t\tprivateActions,\n\t\tregisterPrivateActions: (\n\t\t\tactions: Record< string, ActionCreator >\n\t\t) => {\n\t\t\tObject.assign( privateActions, actions );\n\t\t},\n\t\tprivateSelectors,\n\t\tregisterPrivateSelectors: (\n\t\t\tselectors: Record< string, SelectorLike >\n\t\t) => {\n\t\t\tObject.assign( privateSelectors, selectors );\n\t\t},\n\t};\n\tconst storeDescriptor = {\n\t\tname: key,\n\t\tinstantiate: ( registry: DataRegistry ) => {\n\t\t\t/**\n\t\t\t * Stores listener functions registered with `subscribe()`.\n\t\t\t *\n\t\t\t * When functions register to listen to store changes with\n\t\t\t * `subscribe()` they get added here. Although Redux offers\n\t\t\t * its own `subscribe()` function directly, by wrapping the\n\t\t\t * subscription in this store instance it's possible to\n\t\t\t * optimize checking if the state has changed before calling\n\t\t\t * each listener.\n\t\t\t */\n\t\t\tconst listeners = new Set< ListenerFunction >();\n\t\t\tconst reducer = options.reducer;\n\n\t\t\t// Object that every thunk function receives as the first argument. It contains the\n\t\t\t// `registry`, `dispatch`, `select` and `resolveSelect` fields. Some of them are\n\t\t\t// constructed as getters to avoid circular dependencies.\n\t\t\tconst thunkArgs = {\n\t\t\t\tregistry,\n\t\t\t\tget dispatch() {\n\t\t\t\t\treturn thunkDispatch;\n\t\t\t\t},\n\t\t\t\tget select() {\n\t\t\t\t\treturn thunkSelect;\n\t\t\t\t},\n\t\t\t\tget resolveSelect() {\n\t\t\t\t\treturn resolveSelectors;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst store = instantiateReduxStore(\n\t\t\t\tkey,\n\t\t\t\toptions,\n\t\t\t\tregistry,\n\t\t\t\tthunkArgs\n\t\t\t) as AugmentedReduxStore;\n\n\t\t\t// Expose the private registration functions on the store\n\t\t\t// so they can be copied to a sub registry in registry.js.\n\t\t\tlock( store, privateRegistrationFunctions );\n\t\t\tconst resolversCache = createResolversCache();\n\n\t\t\t// Binds an action creator (`action`) to the `store`, making it a callable function.\n\t\t\t// These are the functions that are returned by `useDispatch`, for example.\n\t\t\t// It always returns a `Promise`, although actions are not always async. That's an\n\t\t\t// unfortunate backward compatibility measure.\n\t\t\tfunction bindAction( action: ( ...args: any[] ) => any ) {\n\t\t\t\treturn ( ...args: unknown[] ) =>\n\t\t\t\t\tPromise.resolve( store.dispatch( action( ...args ) ) );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Object with all public actions, both metadata and store actions.\n\t\t\t */\n\t\t\tconst actions = {\n\t\t\t\t...mapValues(\n\t\t\t\t\tmetadataActions as Record< string, ActionCreator >,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t\t...mapValues(\n\t\t\t\t\toptions.actions as\n\t\t\t\t\t\tRecord< string, ActionCreator > | undefined,\n\t\t\t\t\tbindAction\n\t\t\t\t),\n\t\t\t};\n\n\t\t\t// Object with both public and private actions. Private actions are accessed through a proxy,\n\t\t\t// which looks them up in real time on the `privateActions` object. That's because private\n\t\t\t// actions can be registered at any time with `registerPrivateActions`. Also once a private\n\t\t\t// action creator is bound to the store, it is cached to give it a stable identity.\n\t\t\tconst allActions = createPrivateProxy(\n\t\t\t\tactions,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) => privateActions[ name ],\n\t\t\t\t\tbindAction\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// An object that implements the `dispatch` object that is passed to thunk functions.\n\t\t\t// It is callable (`dispatch( action )`) and also has methods (`dispatch.foo()`) that\n\t\t\t// correspond to bound registered actions, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allActions`.\n\t\t\tconst thunkDispatch = new Proxy(\n\t\t\t\t( action: any ) => store.dispatch( action ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allActions[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `actions` object, add the \"locked\" `allActions` object. When used,\n\t\t\t// `unlock( actions )` will return `allActions`, implementing a way how to get at the private actions.\n\t\t\tlock( actions, allActions );\n\n\t\t\t// If we have selector resolvers, convert them to a normalized form.\n\t\t\tconst resolvers: Record< string, NormalizedResolver > =\n\t\t\t\toptions.resolvers\n\t\t\t\t\t? mapValues(\n\t\t\t\t\t\t\toptions.resolvers as Record< string, any >,\n\t\t\t\t\t\t\tmapResolver\n\t\t\t\t\t\t)\n\t\t\t\t\t: {};\n\n\t\t\t// Bind a selector to the store. Call the selector with the current state, correct registry,\n\t\t\t// and if there is a resolver, attach the resolver logic to the selector.\n\t\t\tfunction bindSelector(\n\t\t\t\tselector: SelectorLike,\n\t\t\t\tselectorName: string\n\t\t\t): SelectorLike {\n\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\tselector.registry = registry;\n\t\t\t\t}\n\t\t\t\tconst boundSelector: SelectorLike = ( ...args: any[] ) => {\n\t\t\t\t\targs = normalize( selector, args );\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\t\t// Before calling the selector, switch to the correct registry.\n\t\t\t\t\tif ( selector.isRegistrySelector ) {\n\t\t\t\t\t\tselector.registry = registry;\n\t\t\t\t\t}\n\t\t\t\t\treturn selector( state.root, ...args );\n\t\t\t\t};\n\n\t\t\t\t// Expose normalization method on the bound selector\n\t\t\t\t// in order that it can be called when fulfilling\n\t\t\t\t// the resolver.\n\t\t\t\tboundSelector.normalizeArgs = getNormalizeArgs( selector );\n\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\n\t\t\t\tif ( ! resolver ) {\n\t\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\t\treturn boundSelector;\n\t\t\t\t}\n\n\t\t\t\treturn mapSelectorWithResolver(\n\t\t\t\t\tboundSelector,\n\t\t\t\t\tselectorName,\n\t\t\t\t\tresolver,\n\t\t\t\t\tstore,\n\t\t\t\t\tresolversCache,\n\t\t\t\t\tboundMetadataSelectors\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Metadata selectors are bound differently: different state (`state.metadata`), no resolvers,\n\t\t\t// normalization depending on the target selector.\n\t\t\tfunction bindMetadataSelector(\n\t\t\t\tmetaDataSelector: ( ...args: any[] ) => any\n\t\t\t): SelectorLike {\n\t\t\t\tconst boundSelector: SelectorLike = (\n\t\t\t\t\tselectorName: string,\n\t\t\t\t\tselectorArgs: unknown[],\n\t\t\t\t\t...args: unknown[]\n\t\t\t\t) => {\n\t\t\t\t\t// Normalize the arguments passed to the target selector, then\n\t\t\t\t\t// map them to the cache key.\n\t\t\t\t\tif ( selectorName ) {\n\t\t\t\t\t\tconst targetSelector = ( options.selectors as any )?.[\n\t\t\t\t\t\t\tselectorName\n\t\t\t\t\t\t];\n\t\t\t\t\t\tif ( targetSelector ) {\n\t\t\t\t\t\t\tselectorArgs = normalize(\n\t\t\t\t\t\t\t\ttargetSelector,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst resolver = resolvers[ selectorName ];\n\t\t\t\t\t\tif ( resolver && selectorArgs ) {\n\t\t\t\t\t\t\tselectorArgs = normalizeResolutionArgs(\n\t\t\t\t\t\t\t\tresolver,\n\t\t\t\t\t\t\t\tselectorArgs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst state = store.__unstableOriginalGetState();\n\n\t\t\t\t\treturn metaDataSelector(\n\t\t\t\t\t\tstate.metadata,\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\tselectorArgs,\n\t\t\t\t\t\t...args\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tboundSelector.hasResolver = false;\n\t\t\t\treturn boundSelector;\n\t\t\t}\n\n\t\t\t// Perform binding of both metadata and store selectors and combine them in one\n\t\t\t// `selectors` object. These are all public selectors of the store.\n\t\t\tconst boundMetadataSelectors = mapValues(\n\t\t\t\tmetadataSelectors as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t( ...args: any[] ) => any\n\t\t\t\t>,\n\t\t\t\tbindMetadataSelector\n\t\t\t);\n\n\t\t\tconst boundSelectors = mapValues(\n\t\t\t\toptions.selectors as Record< string, SelectorLike > | undefined,\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst selectors = {\n\t\t\t\t...boundMetadataSelectors,\n\t\t\t\t...boundSelectors,\n\t\t\t};\n\n\t\t\t// Cache of bound private selectors. They are bound only when first accessed, because\n\t\t\t// new private selectors can be registered at any time (with `registerPrivateSelectors`).\n\t\t\t// Once bound, they are cached to give them a stable identity.\n\t\t\tconst boundPrivateSelectors = createBindingCache(\n\t\t\t\t( name ) => privateSelectors[ name ],\n\t\t\t\tbindSelector\n\t\t\t);\n\n\t\t\tconst allSelectors = createPrivateProxy(\n\t\t\t\tselectors,\n\t\t\t\tboundPrivateSelectors\n\t\t\t);\n\n\t\t\t// Pre-bind the private selectors that have been registered by the time of\n\t\t\t// instantiation, so that registry selectors are bound to the registry.\n\t\t\tfor ( const selectorName of Object.keys( privateSelectors ) ) {\n\t\t\t\tboundPrivateSelectors.get( selectorName );\n\t\t\t}\n\n\t\t\t// An object that implements the `select` object that is passed to thunk functions.\n\t\t\t// It is callable (`select( selector )`) and also has methods (`select.foo()`) that\n\t\t\t// correspond to bound registered selectors, both public and private. Implemented with the proxy\n\t\t\t// `get` method, delegating to `allSelectors`.\n\t\t\tconst thunkSelect = new Proxy(\n\t\t\t\t( selector: ( state: any ) => any ) =>\n\t\t\t\t\tselector( store.__unstableOriginalGetState() ),\n\t\t\t\t{\n\t\t\t\t\tget: ( _target, name: string ) => allSelectors[ name ],\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// To the public `selectors` object, add the \"locked\" `allSelectors` object. When used,\n\t\t\t// `unlock( selectors )` will return `allSelectors`, implementing a way how to get at the private selectors.\n\t\t\tlock( selectors, allSelectors );\n\n\t\t\t// For each selector, create a function that calls the selector, waits for resolution and returns\n\t\t\t// a promise that resolves when the resolution is finished.\n\t\t\tconst bindResolveSelector = mapResolveSelector(\n\t\t\t\tstore,\n\t\t\t\tresolvers,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\t// Now apply this function to all bound selectors, public and private. We are excluding\n\t\t\t// metadata selectors because they don't have resolvers.\n\t\t\tconst resolveSelectors = mapValues(\n\t\t\t\tboundSelectors,\n\t\t\t\tbindResolveSelector\n\t\t\t);\n\n\t\t\tconst allResolveSelectors = createPrivateProxy(\n\t\t\t\tresolveSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindResolveSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( resolveSelectors )` returns `allResolveSelectors`.\n\t\t\tlock( resolveSelectors, allResolveSelectors );\n\n\t\t\t// Now, in a way very similar to `bindResolveSelector`, we create a function that maps\n\t\t\t// selectors to functions that throw a suspense promise if not yet resolved.\n\t\t\tconst bindSuspendSelector = mapSuspendSelector(\n\t\t\t\tstore,\n\t\t\t\tboundMetadataSelectors\n\t\t\t);\n\n\t\t\tconst suspendSelectors = {\n\t\t\t\t...boundMetadataSelectors, // no special suspense behavior\n\t\t\t\t...mapValues( boundSelectors, bindSuspendSelector ),\n\t\t\t};\n\n\t\t\tconst allSuspendSelectors = createPrivateProxy(\n\t\t\t\tsuspendSelectors,\n\t\t\t\tcreateBindingCache(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tboundPrivateSelectors.get( name ) as (\n\t\t\t\t\t\t\t...args: any[]\n\t\t\t\t\t\t) => any | undefined,\n\t\t\t\t\tbindSuspendSelector\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Lock the selectors so that `unlock( suspendSelectors )` returns 'allSuspendSelectors`.\n\t\t\tlock( suspendSelectors, allSuspendSelectors );\n\n\t\t\tconst getSelectors = () => selectors;\n\t\t\tconst getActions = () => actions;\n\t\t\tconst getResolveSelectors = () => resolveSelectors;\n\t\t\tconst getSuspendSelectors = () => suspendSelectors;\n\n\t\t\t// We have some modules monkey-patching the store object\n\t\t\t// It's wrong to do so but until we refactor all of our effects to controls\n\t\t\t// We need to keep the same \"store\" instance here.\n\t\t\tstore.__unstableOriginalGetState = store.getState;\n\t\t\tstore.getState = () => store.__unstableOriginalGetState().root;\n\n\t\t\t// Customize subscribe behavior to call listeners only on effective change,\n\t\t\t// not on every dispatch.\n\t\t\tconst subscribe = ( listener: ListenerFunction ) => {\n\t\t\t\tlisteners.add( listener );\n\n\t\t\t\treturn () => listeners.delete( listener );\n\t\t\t};\n\n\t\t\tlet lastState = store.__unstableOriginalGetState();\n\t\t\tstore.subscribe( () => {\n\t\t\t\tconst state = store.__unstableOriginalGetState();\n\t\t\t\tconst hasChanged = state !== lastState;\n\t\t\t\tlastState = state;\n\n\t\t\t\tif ( hasChanged ) {\n\t\t\t\t\tfor ( const listener of listeners ) {\n\t\t\t\t\t\tlistener();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// This can be simplified to just { subscribe, getSelectors, getActions }\n\t\t\t// Once we remove the use function.\n\t\t\treturn {\n\t\t\t\treducer,\n\t\t\t\tstore,\n\t\t\t\tactions,\n\t\t\t\tselectors,\n\t\t\t\tresolvers,\n\t\t\t\tgetSelectors,\n\t\t\t\tgetResolveSelectors,\n\t\t\t\tgetSuspendSelectors,\n\t\t\t\tgetActions,\n\t\t\t\tsubscribe,\n\t\t\t};\n\t\t},\n\t};\n\n\t// Expose the private registration functions on the store\n\t// descriptor. That's a natural choice since that's where the\n\t// public actions and selectors are stored.\n\tlock( storeDescriptor, privateRegistrationFunctions );\n\n\treturn storeDescriptor as unknown as StoreDescriptor<\n\t\tReduxStoreConfig< State, Actions, Selectors >\n\t>;\n}\n\n/**\n * Creates a redux store for a namespace.\n *\n * @param key       Unique namespace identifier.\n * @param options   Registered store options, with properties\n *                  describing reducer, actions, selectors,\n *                  and resolvers.\n * @param registry  Registry reference.\n * @param thunkArgs Argument object for the thunk middleware.\n * @return Newly created redux store.\n */\nfunction instantiateReduxStore(\n\tkey: string,\n\toptions: ReduxStoreConfig< any, any, any >,\n\tregistry: DataRegistry,\n\tthunkArgs: unknown\n): ReduxStore {\n\tconst controls = {\n\t\t...options.controls,\n\t\t...builtinControls,\n\t};\n\n\tconst normalizedControls = mapValues( controls, ( control: any ) =>\n\t\tcontrol.isRegistryControl ? control( registry ) : control\n\t);\n\n\tconst middlewares = [\n\t\tcreateResolversCacheMiddleware( registry, key ),\n\t\tpromise,\n\t\tcreateReduxRoutineMiddleware( normalizedControls ),\n\t\tcreateThunkMiddleware( thunkArgs ),\n\t];\n\n\tconst enhancers: StoreEnhancer[] = [ applyMiddleware( ...middlewares ) ];\n\tif (\n\t\ttypeof window !== 'undefined' &&\n\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__\n\t) {\n\t\tenhancers.push(\n\t\t\t( window as any ).__REDUX_DEVTOOLS_EXTENSION__( {\n\t\t\t\tname: key,\n\t\t\t\tinstanceId: key,\n\t\t\t\tserialize: {\n\t\t\t\t\treplacer: devToolsReplacer,\n\t\t\t\t},\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst { reducer, initialState } = options;\n\tconst enhancedReducer = combineReducers( {\n\t\tmetadata: metadataReducer,\n\t\troot: reducer,\n\t} );\n\n\treturn createStore(\n\t\tenhancedReducer,\n\t\t{ root: initialState } as any,\n\t\tcompose( ...enhancers ) as unknown as StoreEnhancer\n\t);\n}\n\n/**\n * Maps selectors to functions that return a resolution promise for them.\n *\n * @param store                  The redux store the selectors are bound to.\n * @param resolvers              The normalized resolvers for the store.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to resolvers.\n */\nfunction mapResolveSelector(\n\tstore: ReduxStore,\n\tresolvers: Record< string, NormalizedResolver >,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// If the selector doesn't have a resolver, just convert the return value\n\t\t// (including exceptions) to a Promise, no additional extra behavior is needed.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn async ( ...args: unknown[] ) => selector( ...args );\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) =>\n\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\tconst resolver = resolvers[ selectorName ];\n\t\t\t\t// `isFulfilled` takes these; the metadata selectors derive\n\t\t\t\t// them on their own.\n\t\t\t\tconst resolutionArgs = normalizeResolutionArgs(\n\t\t\t\t\tresolver,\n\t\t\t\t\tnormalize( selector, args )\n\t\t\t\t);\n\t\t\t\tconst hasFinished = () => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\t\t\t\tresolver.isFulfilled(\n\t\t\t\t\t\t\t\tstore.getState(),\n\t\t\t\t\t\t\t\t...resolutionArgs\n\t\t\t\t\t\t\t) )\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst finalize = ( result: unknown ) => {\n\t\t\t\t\tconst hasFailed =\n\t\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\tif ( hasFailed ) {\n\t\t\t\t\t\tconst error = boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t);\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve( result );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst getResult = () => selector( ...args );\n\n\t\t\t\t// Trigger the selector (to trigger the resolver)\n\t\t\t\tconst result = getResult();\n\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\treturn finalize( result );\n\t\t\t\t}\n\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif ( hasFinished() ) {\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\tfinalize( getResult() );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Maps selectors to functions that throw a suspense promise if not yet resolved.\n *\n * @param store                  The redux store the selectors select from.\n * @param boundMetadataSelectors The bound metadata selectors.\n *\n * @return Function that maps selectors to their suspending versions.\n */\nfunction mapSuspendSelector(\n\tstore: ReduxStore,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n) {\n\treturn ( selector: SelectorLike, selectorName: string ) => {\n\t\t// Selector without a resolver doesn't have any extra suspense behavior.\n\t\tif ( ! selector.hasResolver ) {\n\t\t\treturn selector;\n\t\t}\n\n\t\treturn ( ...args: unknown[] ) => {\n\t\t\tconst result = selector( ...args );\n\n\t\t\tif (\n\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\tselectorName,\n\t\t\t\t\targs\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\tboundMetadataSelectors.hasResolutionFailed(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow boundMetadataSelectors.getResolutionError(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tthrow new Promise< void >( ( resolve ) => {\n\t\t\t\tconst unsubscribe = store.subscribe( () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tboundMetadataSelectors.hasFinishedResolution(\n\t\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\t\targs\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t};\n\t};\n}\n\n/**\n * Convert a resolver to a normalized form, an object with `fulfill` method and\n * optional methods like `isFulfilled`.\n *\n * @param resolver Resolver to convert\n */\nfunction mapResolver( resolver: any ): NormalizedResolver {\n\tif ( resolver.fulfill ) {\n\t\treturn resolver;\n\t}\n\n\treturn {\n\t\t...resolver, // Copy the enumerable properties of the resolver function.\n\t\tfulfill: resolver, // Add the fulfill method.\n\t};\n}\n\n/**\n * Returns a selector with a matched resolver.\n * Resolvers are side effects invoked once per argument set of a given selector call,\n * used in ensuring that the data needs for the selector are satisfied.\n *\n * @param selector               The selector function to be bound.\n * @param selectorName           The selector name.\n * @param resolver               Resolver to call.\n * @param store                  The redux store to which the resolvers should be mapped.\n * @param resolversCache         Resolvers Cache.\n * @param boundMetadataSelectors The bound metadata selectors.\n */\nfunction mapSelectorWithResolver(\n\tselector: SelectorLike,\n\tselectorName: string,\n\tresolver: NormalizedResolver,\n\tstore: AugmentedReduxStore,\n\tresolversCache: ResolversCache,\n\tboundMetadataSelectors: Record< string, SelectorLike >\n): SelectorLike {\n\tfunction fulfillSelector( selectorArgs: unknown[] ): void {\n\t\t// The resolver and both caches key off these. The bound metadata\n\t\t// selectors derive them on their own, so they take the selector args.\n\t\tconst args = normalizeResolutionArgs( resolver, selectorArgs );\n\n\t\tif (\n\t\t\tresolversCache.isRunning( selectorName, args ) ||\n\t\t\tboundMetadataSelectors.hasStartedResolution(\n\t\t\t\tselectorName,\n\t\t\t\tselectorArgs\n\t\t\t) ||\n\t\t\t( typeof resolver.isFulfilled === 'function' &&\n\t\t\t\tresolver.isFulfilled( store.getState(), ...args ) )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tresolversCache.markAsRunning( selectorName, args );\n\n\t\tsetTimeout( async () => {\n\t\t\tresolversCache.clear( selectorName, args );\n\t\t\tstore.dispatch(\n\t\t\t\tmetadataActions.startResolution( selectorName, args )\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tconst action = resolver.fulfill( ...args );\n\t\t\t\tif ( action ) {\n\t\t\t\t\tawait store.dispatch( action );\n\t\t\t\t}\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.finishResolution( selectorName, args )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tstore.dispatch(\n\t\t\t\t\tmetadataActions.failResolution( selectorName, args, error )\n\t\t\t\t);\n\t\t\t}\n\t\t}, 0 );\n\t}\n\n\tconst selectorResolver: SelectorLike = ( ...args: unknown[] ) => {\n\t\targs = normalize( selector, args );\n\t\tfulfillSelector( args );\n\t\treturn selector( ...args );\n\t};\n\tselectorResolver.hasResolver = true;\n\t// Forward the normalization method so `resolveSelect` can map its own\n\t// arguments the same way.\n\tselectorResolver.normalizeArgs = selector.normalizeArgs;\n\treturn selectorResolver;\n}\n\n/**\n * Returns the selector's normalization method, falling back to the legacy\n * `__unstableNormalizeArgs` property.\n *\n * @param selector The selector potentially with a normalization method property.\n * @return The normalization method, if any.\n */\nfunction getNormalizeArgs( selector: SelectorLike ) {\n\treturn selector.normalizeArgs ?? selector.__unstableNormalizeArgs;\n}\n\n/**\n * Applies selector's normalization function to the given arguments\n * if it exists.\n *\n * @param selector The selector potentially with a normalization method property.\n * @param args     selector arguments to normalize.\n * @return Potentially normalized arguments.\n */\nfunction normalize( selector: SelectorLike, args: unknown[] ): unknown[] {\n\tconst normalizeArgs = getNormalizeArgs( selector );\n\tif ( typeof normalizeArgs === 'function' && args?.length ) {\n\t\treturn normalizeArgs( args );\n\t}\n\treturn args;\n}\n\n/**\n * Maps selector arguments to the key their resolution is cached under, using\n * the resolver's `getResolutionArgs` if it has one. Calls that map to the same\n * key share a single resolver run.\n *\n * Not idempotent: the result can have fewer arguments than the input, so call\n * this once, on args that have already been through `normalize`.\n *\n * @param resolver The resolver, which may define `getResolutionArgs`.\n * @param args     Normalized selector arguments.\n * @return The cache key arguments.\n */\nfunction normalizeResolutionArgs(\n\tresolver: NormalizedResolver,\n\targs: unknown[]\n): unknown[] {\n\tif ( typeof resolver.getResolutionArgs === 'function' ) {\n\t\treturn resolver.getResolutionArgs( ...args );\n\t}\n\treturn args;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,MAAM,uBAAwB,UAAiC;CAC9D,MAAM,SAAS,CAAE,GAAG,KAAM;CAC1B,KAAM,IAAI,IAAI,OAAO,SAAS,GAAG,KAAK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