{"version":3,"file":"prizm-ui-icons-core.mjs","sources":["../../../../../libs/icons/base/core/src/lib/icons.registry.ts","../../../../../libs/icons/base/core/src/lib/icons-full.registry.ts","../../../../../libs/icons/base/core/src/lib/token.ts","../../../../../libs/icons/base/core/src/prizm-ui-icons-core.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { PrizmIcon } from './types';\nimport { PrizmIconsLoader } from './token';\nimport { Observable, of, tap } from 'rxjs';\n\n/**\n * Service for registering and retrieving icons. Icons can be loaded once and then retrieved from the registry.\n */\n@Injectable({\n  providedIn: 'root',\n})\nexport class PrizmIconsRegistry {\n  // A registry to store icons by their names.\n  private registry = new Map<string, string>();\n\n  /**\n   * Registers a list of icons to make them available for retrieval.\n   * @param {PrizmIcon[]} icons - An array of PrizmIcon objects to register.\n   */\n  public registerIcons(...icons: PrizmIcon[]): void;\n  public registerIcons(icons: PrizmIcon[]): void;\n  public registerIcons(icons: PrizmIcon[] | PrizmIcon, ...otherIcons: PrizmIcon[]): void {\n    const arr = Array.isArray(icons) ? [...icons, ...otherIcons] : [icons, ...otherIcons];\n    arr.forEach(icon => this.registry.set(icon.name, icon.data));\n  }\n\n  /**\n   * Retrieves an icon by its name. If the icon is not in the registry and a loader is provided,\n   * it will attempt to load the icon using the loader and then register it.\n   * @param {string} name - The name of the icon to retrieve.\n   * @param {PrizmIconsLoader} [loader] - An optional loader function to load the icon if it's not registered.\n   * @returns {Observable<string | null>} An observable that emits the icon data or null if not found.\n   */\n  public getIcon(name: string, loader: PrizmIconsLoader | null = null): Observable<string | null> {\n    // Check if the icon is already in the registry.\n    if (this.registry.has(name)) {\n      // Return the icon data as an observable.\n      return of(this.registry.get(name)!);\n    } else if (loader) {\n      // Attempt to load the icon using the provided loader function.\n      return loader(name).pipe(\n        tap(data => {\n          // If the icon data is loaded, register it for future retrievals.\n          if (data) {\n            this.registerIcons([{ name, data }]);\n          }\n        })\n      );\n    } else {\n      // Return null if the icon is not in the registry and no loader is provided.\n      return of(null);\n    }\n  }\n}\n","import { Injectable } from '@angular/core';\nimport { PrizmIconsRegistry } from './icons.registry';\n\n/**\n * Service for registering and retrieving 16px size icons. It extends the PrizmIconsRegistry class.\n * Currently, it does not add any new functionality or properties. It can be used to segregate 16px icons\n * if such a distinction is necessary in the application.\n */\n@Injectable({\n  providedIn: 'root',\n})\nexport class PrizmIconsFullRegistry extends PrizmIconsRegistry {\n  // Since there is no new functionality, no additional code is required.\n  // If specific behavior for 16px icons is needed in the future, it can be implemented here.\n}\n","import { from, map, Observable, of } from 'rxjs';\nimport { InjectionToken } from '@angular/core';\n\n// Define a type for the lazy icon set which maps icon names to lazy loader functions.\nexport type PrizmIconsLazySet = { [iconName: string]: () => Promise<{ data: string }> };\n\n// Define a type for the icon loader function which takes an icon name and returns an observable.\nexport type PrizmIconsLoader = (name: string) => Observable<string | null>;\n\n/**\n * Creates an icon loader function from a given lazy set of icons.\n * The loader function will attempt to load an icon and return an Observable of the icon data.\n *\n * @param {PrizmIconsLazySet} lazySet - The set of lazy-loaded icons.\n * @returns {PrizmIconsLoader} - The icon loader function.\n */\nexport function prizmCreateIconsLoader(lazySet: PrizmIconsLazySet): PrizmIconsLoader {\n  return (name: string) => {\n    const lazyIcon = lazySet[name];\n    // Check if the icon loader function exists and load the icon, otherwise return null.\n    return typeof lazyIcon === 'function' ? from(lazyIcon()).pipe(map(icon => icon.data)) : of(null);\n  };\n}\n\nexport const PRIZM_ICONS_LOADER = new InjectionToken<PrizmIconsLoader>('prizm icons lazy loader');\nexport const PRIZM_ICONS_FULL_LOADER = new InjectionToken<PrizmIconsLoader>(\n  'prizm icons lazy loader for full component'\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAKA;;AAEG;MAIU,kBAAkB,CAAA;AAH/B,IAAA,WAAA,GAAA;;AAKU,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,GAAG,EAAkB;AAwC7C;AAhCQ,IAAA,aAAa,CAAC,KAA8B,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