{ "version": 3, "sources": ["../../../../src/lib/ui/hooks/usePreloadIcons.ts"], "sourcesContent": ["import { useEffect, useState } from 'react'\nimport { iconTypes } from '../icon-types'\nimport { useAssetUrls } from './useAssetUrls'\n\n/** @internal */\nexport function usePreloadIcons(): boolean {\n\tconst [isLoaded, setIsLoaded] = useState(false)\n\tconst assetUrls = useAssetUrls()\n\n\tuseEffect(() => {\n\t\tlet cancelled = false\n\t\tasync function loadImages() {\n\t\t\t// Run through all of the icons and load them. It doesn't matter\n\t\t\t// if any of the images don't load; though we expect that they would.\n\t\t\t// Instead, we just want to make sure that the browser has cached\n\t\t\t// all of the icons it can so that they're available when we need them.\n\n\t\t\tawait Promise.allSettled(\n\t\t\t\ticonTypes.map((icon) => {\n\t\t\t\t\tconst image = new Image()\n\t\t\t\t\timage.src = assetUrls.icons[icon]\n\t\t\t\t\treturn image.decode()\n\t\t\t\t})\n\t\t\t)\n\n\t\t\tif (cancelled) return\n\t\t\tsetIsLoaded(true)\n\t\t}\n\n\t\tloadImages()\n\n\t\treturn () => {\n\t\t\tcancelled = true\n\t\t}\n\t}, [isLoaded, assetUrls])\n\n\treturn isLoaded\n}\n"], "mappings": "AAAA,SAAS,WAAW,gBAAgB;AACpC,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAGtB,SAAS,kBAA2B;AAC1C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkB,KAAK;AACvD,QAAM,YAAY,aAAa;AAE/B,YAAU,MAAM;AACf,QAAI,YAAY;AAChB,mBAAe,aAAa;AAM3B,YAAM,QAAQ;AAAA,QACb,UAAU,IAAI,CAAC,SAAS;AACvB,gBAAM,QAAQ,IAAI,MAAM;AACxB,gBAAM,MAAM,UAAU,MAAM,IAAI;AAChC,iBAAO,MAAM,OAAO;AAAA,QACrB,CAAC;AAAA,MACF;AAEA,UAAI;AAAW;AACf,kBAAY,IAAI;AAAA,IACjB;AAEA,eAAW;AAEX,WAAO,MAAM;AACZ,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAC,UAAU,SAAS,CAAC;AAExB,SAAO;AACR;", "names": [] }