{
  "version": 3,
  "sources": ["../src/types.ts"],
  "sourcesContent": ["/**\n * External dependencies\n */\n\nimport type {\n\t// eslint-disable-next-line no-restricted-imports\n\tcombineReducers as reduxCombineReducers,\n\tStore as ReduxStore,\n} from 'redux';\n\n/**\n * Internal dependencies\n */\nimport type { DataEmitter } from './utils/emitter';\nimport type {\n\tMetadataSelectors,\n\tMetadataActions,\n} from './redux-store/metadata/types';\n\ntype MapOf< T > = { [ name: string ]: T };\n\nexport type ActionCreator = ( ...args: any[] ) => any | Generator;\nexport type Resolver = Function | Generator;\nexport type Selector = Function;\n\nexport type AnyConfig = ReduxStoreConfig< any, any, any >;\n\nexport interface StoreInstance< Config extends AnyConfig > {\n\tgetSelectors: () => SelectorsOf< Config >;\n\tgetActions: () => ActionCreatorsOf< Config >;\n\tsubscribe: ( listener: () => void ) => () => void;\n}\n\nexport interface StoreDescriptor< Config extends AnyConfig = AnyConfig > {\n\t/**\n\t * Store Name\n\t */\n\tname: string;\n\n\t/**\n\t * Creates a store instance\n\t */\n\tinstantiate: ( registry: DataRegistry ) => StoreInstance< Config >;\n}\n\nexport interface ReduxStoreConfig< State, ActionCreators, Selectors > {\n\tinitialState?: State;\n\treducer: ( state: any, action: any ) => any;\n\tactions?: ActionCreators;\n\tresolvers?: MapOf< Resolver >;\n\tselectors?: Selectors;\n\tcontrols?: MapOf< Function >;\n}\n\n// Return type for the useSelect() hook.\nexport type UseSelectReturn< F extends MapSelect | StoreDescriptor< any > > =\n\tF extends MapSelect\n\t\t? ReturnType< F >\n\t\t: F extends StoreDescriptor< any >\n\t\t? CurriedSelectorsOf< F >\n\t\t: never;\n\n// Return type for the useDispatch() hook.\nexport type UseDispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< StoreNameOrDescriptor >\n\t\t: StoreNameOrDescriptor extends undefined\n\t\t? DispatchFunction\n\t\t: any;\n\nexport type DispatchFunction = < StoreNameOrDescriptor >(\n\tstore: StoreNameOrDescriptor\n) => DispatchReturn< StoreNameOrDescriptor >;\n\nexport type DispatchReturn< StoreNameOrDescriptor > =\n\tStoreNameOrDescriptor extends StoreDescriptor< any >\n\t\t? ActionCreatorsOf< StoreNameOrDescriptor >\n\t\t: unknown;\n\nexport type MapSelect = (\n\tselect: SelectFunction,\n\tregistry: DataRegistry\n) => any;\n\nexport type SelectFunction = < S >( store: S ) => CurriedSelectorsOf< S >;\n\n/**\n * Callback for store's `subscribe()` method that\n * runs when the store data has changed.\n */\nexport type ListenerFunction = () => void;\n\nexport type CurriedSelectorsOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? {\n\t\t\t[ key in keyof Selectors ]: CurriedState< Selectors[ key ] >;\n\t  } & MetadataSelectors< S >\n\t: never;\n\n/**\n * Like CurriedState but wraps the return type in a Promise.\n * Used for resolveSelect where selectors return promises.\n *\n * For generic selectors that define PromiseCurriedSignature, that signature\n * is used directly to preserve generic type parameters (which would otherwise\n * be lost when using `infer`).\n */\ntype CurriedStateWithPromise< F > =\n\tF extends SelectorWithCustomCurrySignature & {\n\t\tPromiseCurriedSignature: infer S;\n\t}\n\t\t? S\n\t\t: F extends SelectorWithCustomCurrySignature & {\n\t\t\t\tCurriedSignature: ( ...args: infer P ) => infer R;\n\t\t  }\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F extends ( state: any, ...args: infer P ) => infer R\n\t\t? ( ...args: P ) => Promise< R >\n\t\t: F;\n\n/**\n * Like CurriedSelectorsOf but each selector returns a Promise.\n * Used for resolveSelect.\n */\nexport type CurriedSelectorsResolveOf< S > = S extends StoreDescriptor<\n\tReduxStoreConfig< any, any, infer Selectors >\n>\n\t? {\n\t\t\t[ key in keyof Selectors ]: CurriedStateWithPromise<\n\t\t\t\tSelectors[ key ]\n\t\t\t>;\n\t  }\n\t: never;\n\n/**\n * Removes the first argument from a function.\n *\n * By default, it removes the `state` parameter from\n * registered selectors since that argument is supplied\n * by the editor when calling `select(\u2026)`.\n *\n * For functions with no arguments, which some selectors\n * are free to define, returns the original function.\n *\n * It is possible to manually provide a custom curried signature\n * and avoid the automatic inference. When the\n * F generic argument passed to this helper extends the\n * SelectorWithCustomCurrySignature type, the F['CurriedSignature']\n * property is used verbatim.\n *\n * This is useful because TypeScript does not correctly remove\n * arguments from complex function signatures constrained by\n * interdependent generic parameters.\n * For more context, see https://github.com/WordPress/gutenberg/pull/41578\n */\ntype CurriedState< F > = F extends SelectorWithCustomCurrySignature\n\t? F[ 'CurriedSignature' ]\n\t: F extends ( state: any, ...args: infer P ) => infer R\n\t? ( ...args: P ) => R\n\t: F;\n\n/**\n * Utility to manually specify curried selector signatures.\n *\n * It comes handy when TypeScript can't automatically produce the\n * correct curried function signature. For example:\n *\n * ```ts\n * type BadlyInferredSignature = CurriedState<\n *     <K extends string | number>(\n *         state: any,\n *         kind: K,\n *         key: K extends string ? 'one value' : false\n *     ) => K\n * >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false \"one value\") => string number\n * ```\n *\n * With SelectorWithCustomCurrySignature, we can provide a custom\n * signature and avoid relying on TypeScript inference:\n * ```ts\n * interface MySelectorSignature extends SelectorWithCustomCurrySignature {\n *     <K extends string | number>(\n *         state: any,\n *         kind: K,\n *         key: K extends string ? 'one value' : false\n *     ): K;\n *\n *     CurriedSignature: <K extends string | number>(\n *         kind: K,\n *         key: K extends string ? 'one value' : false\n *     ): K;\n * }\n * type CorrectlyInferredSignature = CurriedState<MySelectorSignature>\n * // <K extends string | number>(kind: K, key: K extends string ? 'one value' : false): K;\n *\n * For even more context, see https://github.com/WordPress/gutenberg/pull/41578\n * ```\n */\nexport interface SelectorWithCustomCurrySignature {\n\tCurriedSignature: Function;\n\tPromiseCurriedSignature?: Function;\n}\n\n/**\n * A store name or store descriptor, used throughout the API.\n */\nexport type StoreNameOrDescriptor = string | StoreDescriptor;\n\n/**\n * An isolated orchestrator of store registrations.\n *\n * Returned by `createRegistry`. Provides methods to register stores,\n * select data, dispatch actions, and subscribe to changes.\n */\nexport interface DataRegistry {\n\tbatch: ( callback: () => void ) => void;\n\tstores: Record< string, InternalStoreInstance >;\n\tnamespaces: Record< string, InternalStoreInstance >;\n\tsubscribe: (\n\t\tlistener: ListenerFunction,\n\t\tstoreNameOrDescriptor?: StoreNameOrDescriptor\n\t) => () => void;\n\tselect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tresolveSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsResolveOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => Promise< any > >;\n\t};\n\tsuspendSelect: {\n\t\t< S extends StoreDescriptor< any > >(\n\t\t\tstore: S\n\t\t): CurriedSelectorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tdispatch: {\n\t\t< S extends StoreDescriptor< any > >( store: S ): ActionCreatorsOf< S >;\n\t\t(\n\t\t\tstore: StoreNameOrDescriptor\n\t\t): Record< string, ( ...args: any[] ) => any >;\n\t};\n\tuse: (\n\t\tplugin: DataPlugin,\n\t\toptions?: Record< string, unknown >\n\t) => DataRegistry;\n\tregister: ( store: StoreDescriptor< any > ) => void;\n\tregisterGenericStore: (\n\t\tname: string,\n\t\tstore: StoreInstance< AnyConfig >\n\t) => void;\n\tregisterStore: (\n\t\tstoreName: string,\n\t\toptions: ReduxStoreConfig< any, any, any >\n\t) => ReduxStore;\n\t__unstableMarkListeningStores: < T >(\n\t\tcallback: () => T,\n\t\tref: { current: string[] | null }\n\t) => T;\n}\n\n/**\n * The plugin function signature.\n */\nexport type DataPlugin = (\n\tregistry: DataRegistry,\n\toptions?: Record< string, unknown >\n) => Partial< DataRegistry >;\n\n/**\n * Status of a selector resolution.\n */\nexport type ResolutionStatus = 'resolving' | 'finished' | 'error';\n\n/**\n * State value for a single resolution.\n */\nexport type ResolutionState =\n\t| { status: 'resolving' }\n\t| { status: 'finished' }\n\t| { status: 'error'; error: Error | unknown };\n\n/**\n * A normalized resolver with a `fulfill` method and optional `isFulfilled`.\n */\nexport interface NormalizedResolver {\n\t/**\n\t * The function to call to fulfill the resolver.\n\t */\n\tfulfill: ( ...args: any[] ) => any;\n\t/**\n\t * Optional function to check if the resolver is already fulfilled.\n\t */\n\tisFulfilled?: ( state: any, ...args: any[] ) => boolean;\n\t/**\n\t * Optional function to check if the resolver should be invalidated.\n\t */\n\tshouldInvalidate?: ( action: any, ...args: any[] ) => boolean;\n}\n\n/**\n * A bound selector with optional resolver metadata.\n */\nexport interface BoundSelector {\n\t( ...args: any[] ): any;\n\t/**\n\t * Whether this selector has a resolver attached.\n\t */\n\thasResolver: boolean;\n\t/**\n\t * Optional function to normalize the arguments.\n\t */\n\t__unstableNormalizeArgs?: ( args: any[] ) => any[];\n\t/**\n\t * Whether this selector is a registry selector.\n\t */\n\tisRegistrySelector?: boolean;\n\t/**\n\t * The registry instance this selector is bound to.\n\t */\n\tregistry?: DataRegistry;\n}\n\n/**\n * The shape of a store instance as seen internally by the registry.\n * Extends the public StoreInstance with additional internal properties.\n */\nexport interface InternalStoreInstance< Config extends AnyConfig = AnyConfig >\n\textends StoreInstance< Config > {\n\t/**\n\t * The Redux store instance (only for Redux-based stores).\n\t */\n\tstore?: ReduxStore;\n\t/**\n\t * The internal emitter for pause/resume batching.\n\t */\n\temitter: DataEmitter;\n\t/**\n\t * The combined reducer.\n\t */\n\treducer?: ( state: any, action: any ) => any;\n\t/**\n\t * Bound actions object.\n\t */\n\tactions?: Record< string, ActionCreator >;\n\t/**\n\t * Bound selectors object.\n\t */\n\tselectors?: Record< string, Selector >;\n\t/**\n\t * Resolver definitions.\n\t */\n\tresolvers?: Record< string, NormalizedResolver >;\n\t/**\n\t * Returns resolve-wrapped selectors.\n\t */\n\tgetResolveSelectors?: () => Record<\n\t\tstring,\n\t\t( ...args: any[] ) => Promise< any >\n\t>;\n\t/**\n\t * Returns suspense-wrapped selectors.\n\t */\n\tgetSuspendSelectors?: () => Record< string, ( ...args: any[] ) => any >;\n}\n\n/**\n * Control descriptor for the controls system.\n */\nexport interface ControlDescriptor {\n\t/**\n\t * The type of the control action.\n\t */\n\ttype: string;\n\t/**\n\t * The store key to target.\n\t */\n\tstoreKey: string;\n\t/**\n\t * The name of the selector (for select/resolveSelect controls).\n\t */\n\tselectorName?: string;\n\t/**\n\t * The name of the action (for dispatch controls).\n\t */\n\tactionName?: string;\n\t/**\n\t * Arguments for the selector or action.\n\t */\n\targs: any[];\n}\n\n/**\n * Storage interface (Web Storage API subset).\n */\nexport interface StorageInterface {\n\tgetItem: ( key: string ) => string | null;\n\tsetItem: ( key: string, value: string ) => void;\n\tremoveItem?: ( key: string ) => void;\n\tclear?: VoidFunction;\n}\n\n// Type Helpers.\n\nexport type ConfigOf< S > = S extends StoreDescriptor< infer C > ? C : never;\n\nexport type ActionCreatorsOf< T > = T extends StoreDescriptor<\n\tReduxStoreConfig< any, infer ActionCreators, any >\n>\n\t? PromisifiedActionCreators< ActionCreators > & MetadataActions< T >\n\t: T extends ReduxStoreConfig< any, infer ActionCreators, any >\n\t? PromisifiedActionCreators< ActionCreators >\n\t: never;\n\n// Takes an object containing all action creators for a store and updates the\n// return type of each action creator to account for internal registry details --\n// for example, dispatched actions are wrapped with a Promise.\nexport type PromisifiedActionCreators< ActionCreators > = {\n\t[ Action in keyof ActionCreators ]: ActionCreators[ Action ] extends ActionCreator\n\t\t? PromisifyActionCreator< ActionCreators[ Action ] >\n\t\t: ActionCreators[ Action ];\n};\n\n// Wraps action creator return types with a Promise and handles thunks and generators.\nexport type PromisifyActionCreator< Action extends ActionCreator > = (\n\t...args: Parameters< Action >\n) => Promise<\n\tReturnType< Action > extends ( ..._args: any[] ) => any\n\t\t? ThunkReturnType< Action >\n\t\t: ReturnType< Action > extends Generator< any, infer TReturn, any >\n\t\t? TReturn\n\t\t: ReturnType< Action >\n>;\n\n// A thunk is an action creator which returns a function, which can optionally\n// return a Promise. The double ReturnType unwraps the innermost function's\n// return type, and Awaited gets the type the Promise resolves to. If the return\n// type is not a Promise, Awaited returns that original type.\nexport type ThunkReturnType< Action extends ActionCreator > = Awaited<\n\tReturnType< ReturnType< Action > >\n>;\n\ntype SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<\n\tany,\n\tany,\n\tinfer Selectors\n>\n\t? { [ name in keyof Selectors ]: Function }\n\t: never;\n\n/**\n * The argument object passed to every thunk function. When parameterized with\n * a store descriptor, `dispatch`, `select`, and `resolveSelect` are fully\n * typed against that store's actions and selectors.\n *\n * @example\n * ```ts\n * const myAction =\n *     ( id: number ) =>\n *     async ( { dispatch, select }: ThunkArgs< typeof myStore > ) => {\n *         const record = select.getRecord( id );\n *         dispatch.setLoading( true );\n *     };\n * ```\n */\nexport interface ThunkArgs<\n\tS extends StoreDescriptor = StoreDescriptor,\n\tPrivateSelectors extends Record< string, Function > = {},\n\tPrivateActions extends Record< string, ActionCreator > = {},\n> {\n\tdispatch: ActionCreatorsOf< S > &\n\t\tPromisifiedActionCreators< PrivateActions > & {\n\t\t\t< R >( thunk: ( ...args: any[] ) => R ): R;\n\t\t\t( action: Record< string, unknown > ): unknown;\n\t\t};\n\tselect: CurriedSelectorsOf< S > & {\n\t\t[ key in keyof PrivateSelectors ]: CurriedState<\n\t\t\tPrivateSelectors[ key ]\n\t\t>;\n\t};\n\tresolveSelect: CurriedSelectorsResolveOf< S >;\n\tregistry: DataRegistry;\n}\n\nexport type combineReducers = typeof reduxCombineReducers;\n"],
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
  "names": []
}
