/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/iconly@3.0.2/dist/index.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
(function(y,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(y=typeof globalThis<"u"?globalThis:y||self,s(y.Iconly={}))})(this,(function(y){"use strict";const s=(e,t,o)=>({code:e,message:t,cause:o}),c=e=>({ok:!0,value:e}),a=e=>({ok:!1,error:e}),h=(e,t)=>{const o=e.querySelector('[data-iconly="iconset"]');let n=o instanceof HTMLElement?o:null;n||(n=document.createElement("div"),n.setAttribute("data-iconly","iconset"),n.setAttribute("aria-hidden","true"),n.style.cssText="width: 0; height: 0; position: absolute; left: -9999px;",e.appendChild(n));const f=new DOMParser().parseFromString(t,"image/svg+xml"),d=f.querySelector("parsererror");if(d)return a(s("parse_error",`SVG parsing error: ${d.textContent??"Unknown error"}`));n.innerHTML="";const g=f.documentElement;if(!g)return a(s("parse_error","No valid SVG content found."));const b=document.importNode(g,!0);return n.appendChild(b),c(void 0)},w=async(e,t)=>{try{const o=await fetch(e,{signal:t});if(!o.ok)return a(s("fetch_failed",`Failed to fetch icons from "${e}".`));const n=await o.text();return c(n)}catch(o){return o instanceof DOMException&&o.name==="AbortError"?a(s("fetch_aborted","Fetch request was aborted.",o)):a(s("fetch_failed","Failed to fetch icons.",o))}},x=(e={})=>{const t=e.dbName??"iconlyDB",o=e.storeName??"icons";let n=null;const p=async()=>{if(n)return n;if(typeof indexedDB>"u")throw s("indexeddb_not_supported","IndexedDB is not supported.");return n=new Promise((u,r)=>{const i=indexedDB.open(t,1);i.onerror=()=>{r(s("indexeddb_open_failed","Failed to open IndexedDB connection.",i.error))},i.onupgradeneeded=m=>{const l=m.target.result;l.objectStoreNames.contains(o)||l.createObjectStore(o,{keyPath:"version"})},i.onsuccess=()=>u(i.result)}),n},f=(u,r)=>u.transaction(o,r).objectStore(o),d=(u,r,i)=>u&&typeof u=="object"&&"code"in u&&"message"in u?u:s(r,i,u);return{get:async u=>{try{const r=await p(),i=f(r,"readonly");return await new Promise(m=>{const l=i.get(u);l.onsuccess=()=>m(c(l.result)),l.onerror=()=>m(a(s("indexeddb_request_failed","Failed to read from IndexedDB.",l.error)))})}catch(r){return a(d(r,"indexeddb_open_failed","Failed to open IndexedDB."))}},set:async u=>{try{const r=await p(),i=f(r,"readwrite");return await new Promise(m=>{const l=i.put(u);l.onsuccess=()=>m(c(void 0)),l.onerror=()=>m(a(s("indexeddb_request_failed","Failed to write to IndexedDB.",l.error)))})}catch(r){return a(s("indexeddb_open_failed","Failed to open IndexedDB.",r))}}}},_=()=>{const e=new Map;return{get:async n=>e.has(n)?c({version:n,data:e.get(n)??""}):c(void 0),set:async n=>(e.set(n.version,n.data),c(void 0))}},D=(e={})=>{const t=e.keyPrefix??"iconly",o=()=>typeof window>"u"||!window.sessionStorage?a(s("storage_unavailable","SessionStorage is not available.")):c(window.sessionStorage);return{get:async f=>{const d=o();if(!d.ok)return d;try{const g=d.value.getItem(`${t}:${f}`);if(!g)return c(void 0);const b=JSON.parse(g);return c(b)}catch(g){return a(s("storage_read_failed","Failed to read from SessionStorage.",g))}},set:async f=>{const d=o();if(!d.ok)return d;try{return d.value.setItem(`${t}:${f.version}`,JSON.stringify(f)),c(void 0)}catch(g){return a(s("storage_write_failed","Failed to write to SessionStorage.",g))}}}},I=(e,t)=>!e||e==="indexeddb"?x({dbName:t.dbName,storeName:t.storeName}):e==="memory"?_():e==="session"?D({keyPrefix:t.sessionKeyPrefix}):e,N=(e={})=>{const t={file:e.file??"./icons.svg",version:e.version??"1.0",debug:e.debug??!1,container:e.container,logger:e.logger,onError:e.onError,onDebug:e.onDebug},o=I(e.storage,{dbName:e.dbName,storeName:e.storeName,sessionKeyPrefix:e.sessionKeyPrefix});let n=null;const p=()=>{n?.abort()},f=()=>{if(typeof document>"u")return a(s("container_invalid","Document is not available in this environment."));if(typeof t.container=="string"){const i=document.querySelector(t.container);return!i||!(i instanceof HTMLElement)?a(s("container_invalid",`Invalid container selector: "${t.container}".`)):c(i)}if(t.container instanceof HTMLElement)return c(t.container);const r=document.body??document.documentElement;return r?c(r):a(s("container_invalid","No valid container element found."))},d=(...r)=>{t.debug&&(t.onDebug?.(...r),t.logger?.debug?.("[Iconly debug]",...r))},g=r=>{t.onError?.(r),t.logger?.error?.("[Iconly error]",r)},b=r=>(g(r),a(r));return{init:async()=>{const r=f();if(!r.ok)return b(r.error);const i=await o.get(t.version);if(!i.ok)return b(i.error);let m=i.value?.data;if(m)d("Using cached icon set",t.version);else{n=new AbortController;const v=await w(t.file,n.signal);if(!v.ok)return b(v.error);m=v.value;const S=await o.set({version:t.version,data:m});if(!S.ok)return b(S.error)}const l=h(r.value,m);return l.ok?(d("Iconly has successfully initialized."),c(void 0)):b(l.error)},abort:p}};y.createIconly=N,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
//# sourceMappingURL=index.umd.js.map
