{"version":3,"sources":["../../src/util/icon-utils.ts"],"names":[],"mappings":";AAAA,IAAM,YAAoC,EAAC;AAW3C,eAAsB,UAAA,CAAW,QAAA,EAAkB,UAAA,GAAa,QAAA,EAA2B;AAEvF,EAAA,IAAI,eAAe,QAAA,EAAU;AACzB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,wBAAA,EAA2B,UAAU,CAAA,CAAE,CAAA;AAAA,EAC3D;AAIA,EAAA,IAAI,QAAA,KAAa,QAAA,CAAS,WAAA,EAAY,EAAG;AACrC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mDAAA,EAAsD,QAAQ,CAAA,CAAE,CAAA;AAAA,EACpF;AAEA,EAAA,MAAM,OAAA,GAAU,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AACzC,EAAA,IAAI,SAAA,CAAU,OAAO,CAAA,EAAG;AACpB,IAAA,OAAO,UAAU,OAAO,CAAA;AAAA,EAC5B;AAEA,EAAA,MAAM,aAAA,GAAgB,sDAAsD,QAAQ,CAAA,IAAA,CAAA;AAGpF,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,aAAa,CAAA;AAC1C,EAAA,IAAI,OAAA,GAAU,MAAM,QAAA,CAAS,IAAA,EAAK;AAGlC,EAAA,OAAA,GAAU,OAAA,CAAQ,OAAA,CAAQ,0BAAA,EAA4B,wBAAwB,CAAA;AAE9E,EAAA,SAAA,CAAU,OAAO,CAAA,GAAI,OAAA;AACrB,EAAA,OAAO,OAAA;AACX","file":"icon-utils.mjs","sourcesContent":["const iconCache: Record<string, string> = {};\n\n/**\n * This is useful when you need to dynamically retrieve the SVG for an icon.\n * It will cache the icon SVG so that it doesn't need to be fetched multiple times.\n * It will also return the same SVG for the same icon name and collection.\n *\n * @param iconName - The name of the icon to retrieve.\n * @param collection - The collection of the icon to retrieve. Today we only support lucide.\n * @returns The SVG for the icon.\n */\nexport async function getIconSvg(iconName: string, collection = 'lucide'): Promise<string> {\n    // Today we only support lucide\n    if (collection !== 'lucide') {\n        throw new Error(`Unsupported collection: ${collection}`);\n    }\n\n    // Lucide icon names must be lower case and they are all hyphen based, not camel case\n    // If the icon name isn't all lower case then throw an error so the developer knows to use the correct icon name\n    if (iconName !== iconName.toLowerCase()) {\n        throw new Error(`Icon name must be all lower case and hyphen based: ${iconName}`);\n    }\n\n    const iconKey = `${collection}:${iconName}`;\n    if (iconCache[iconKey]) {\n        return iconCache[iconKey];\n    }\n\n    const lucideIconUrl = `https://cdn.jsdelivr.net/npm/lucide-static@0/icons/${iconName}.svg`;\n\n    // Use fetch to get the icon SVG\n    const response = await fetch(lucideIconUrl);\n    let iconSvg = await response.text();\n\n    // Replace the width and height attributes with width=\"24\" and height=\"24\"\n    iconSvg = iconSvg.replace(/width=\"\\d+\" height=\"\\d+\"/, 'width=\"24\" height=\"24\"');\n\n    iconCache[iconKey] = iconSvg;\n    return iconSvg;\n}\n"]}