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AO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC1E,CAAC;AACF,CAAC","sourcesContent":["import { isArrayLike, isIterable } from '@dojo/shim/iterator';\nimport { Load } from '../load';\n\nexport interface LoadPlugin<T> {\n\t/**\n\t * An optional method that normmalizes a resource id.\n\t *\n\t * @param resourceId\n\t * The raw resource id.\n\t *\n\t * @param resolver\n\t * A method that can resolve an id to an absolute path. Depending on the environment, this will\n\t * usually be either `require.toUrl` or `require.resolve`.\n\t */\n\tnormalize?: (resourceId: string, resolver: (resourceId: string) => string) => string;\n\n\t/**\n\t * A method that loads the specified resource.\n\t *\n\t * @param resourceId\n\t * The id of the resource to load.\n\t *\n\t * @param load\n\t * The `load` method that was used to load and execute the plugin.\n\t *\n\t * @return\n\t * A promise that resolves to the loaded resource.\n\t */\n\tload(resourceId: string, load: Load): Promise<T>;\n}\n\nexport function isPlugin(value: any): value is LoadPlugin<any> {\n\treturn Boolean(value) && typeof value.load === 'function';\n}\n\nexport function useDefault(modules: any[]): any[];\nexport function useDefault(module: any): any;\nexport function useDefault(modules: any | any[]): any[] | any {\n\tif (isArrayLike(modules)) {\n\t\tlet processedModules: any[] = [];\n\n\t\tfor (let i = 0; i < modules.length; i++) {\n\t\t\tconst module = modules[i];\n\t\t\tprocessedModules.push(module.__esModule && module.default ? module.default : module);\n\t\t}\n\n\t\treturn processedModules;\n\t} else if (isIterable(modules)) {\n\t\tlet processedModules: any[] = [];\n\n\t\tfor (const module of modules) {\n\t\t\tprocessedModules.push(module.__esModule && module.default ? module.default : module);\n\t\t}\n\n\t\treturn processedModules;\n\t} else {\n\t\treturn modules.__esModule && modules.default ? modules.default : modules;\n\t}\n}\n"]}