"use strict";var _a;const REGISTRY_KEY="scIconLibraries",EVENT_REGISTERED="surecart:icon-library-registered",win="undefined"!=typeof window?window:void 0,watchedIcons=new Set;function readRegistry(){return win&&Array.isArray(win[REGISTRY_KEY])?win[REGISTRY_KEY]:[]}function writeRegistry(r){win&&(win[REGISTRY_KEY]=r)}function redrawForLibrary(r){watchedIcons.forEach((n=>{n.library===r&&n.redraw()}))}function watchIcon(r){watchedIcons.add(r)}function unwatchIcon(r){watchedIcons.delete(r)}function getIconLibrary(r){try{return readRegistry().find((n=>(null==n?void 0:n.name)===r))}catch{return}}function registerIconLibrary(r,n){const e=readRegistry().filter((n=>(null==n?void 0:n.name)!==r));e.push({name:r,...n}),writeRegistry(e);try{null==win||win.dispatchEvent(new CustomEvent(EVENT_REGISTERED,{detail:{name:r}}))}catch{}}null===(_a=null==win?void 0:win.addEventListener)||void 0===_a||_a.call(win,EVENT_REGISTERED,(r=>{var n;const e=null===(n=r.detail)||void 0===n?void 0:n.name;e&&redrawForLibrary(e)})),win&&(win.ceRegisterIconLibrary=registerIconLibrary),exports.getIconLibrary=getIconLibrary,exports.registerIconLibrary=registerIconLibrary,exports.unwatchIcon=unwatchIcon,exports.watchIcon=watchIcon;