import { iconToSVG } from '../svg/build.mjs'; import { getIconData } from '../icon-set/get-icon.mjs'; import { mergeIconProps } from './utils.mjs'; import createDebugger from 'debug'; import { defaults } from '../customisations/index.mjs'; import '../svg/size.mjs'; import '../icon/index.mjs'; import '../icon/merge.mjs'; const debug = createDebugger("@iconify-loader:icon"); async function searchForIcon(iconSet, collection, ids, options) { let iconData; const { customize } = options?.customizations ?? {}; for (const id of ids) { iconData = getIconData(iconSet, id, true); if (iconData) { debug(`${collection}:${id}`); let defaultCustomizations = { ...defaults }; if (typeof customize === "function") defaultCustomizations = customize(defaultCustomizations); const { attributes: { width, height, ...restAttributes }, body } = iconToSVG(iconData, defaultCustomizations); const scale = options?.scale; return await mergeIconProps(`${body}`, collection, id, options, () => { return { ...restAttributes }; }, (props) => { if (typeof props.width === "undefined" || props.width === null) { if (typeof scale === "number") { props.width = `${scale}em`; } else { props.width = width; } } if (typeof props.height === "undefined" || props.height === null) { if (typeof scale === "number") { props.height = `${scale}em`; } else { props.height = height; } } }); } } } export { searchForIcon };