const t=Object.freeze({left:0,top:0,width:16,height:16}),e=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),n=Object.freeze({...t,...e}),i=Object.freeze({...n,body:"",hidden:!1}),o=Object.freeze({width:null,height:null}),r=Object.freeze({...o,...e}),l=(t,e,n,i="")=>{const o=t.split(":");if("@"===t.slice(0,1)){if(o.length<2||o.length>3)return null;i=o.shift().slice(1)}if(o.length>3||!o.length)return null;if(o.length>1){const t=o.pop(),e=o.pop(),n={provider:o.length>0?o[0]:i,prefix:e,name:t};return s(n)?n:null}const r=o[0],l=r.split("-");if(l.length>1){const t={provider:i,prefix:l.shift(),name:l.join("-")};return s(t)?t:null}if(n&&""===i){const t={provider:i,prefix:"",name:r};return s(t,n)?t:null}return null},s=(t,e)=>!!t&&!(!(e&&""===t.prefix||t.prefix)||!t.name);function c(t,n){const o=function(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const i=((t.rotate||0)+(e.rotate||0))%4;return i&&(n.rotate=i),n}(t,n);for(const r in i)r in e?r in t&&!(r in o)&&(o[r]=e[r]):r in n?o[r]=n[r]:r in t&&(o[r]=t[r]);return o}function f(t,e,n){const i=t.icons,o=t.aliases||Object.create(null);let r={};function l(t){r=c(i[t]||o[t],r)}return l(e),n.forEach(l),c(t,r)}function h(t,e){if(t.icons[e])return f(t,e,[]);const n=function(t,e){const n=t.icons,i=t.aliases||Object.create(null),o=Object.create(null);return(e||Object.keys(n).concat(Object.keys(i))).forEach(function t(e){if(n[e])return o[e]=[];if(!(e in o)){o[e]=null;const n=i[e]&&i[e].parent,r=n&&t(n);r&&(o[e]=[n].concat(r))}return o[e]}),o}(t,[e])[e];return n?f(t,e,n):null}const u=/(-?[0-9.]*[0-9]+[0-9.]*)/g,a=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function p(t,e,n){if(1===e)return t;if(n=n||100,"number"==typeof t)return Math.ceil(t*e*n)/n;if("string"!=typeof t)return t;const i=t.split(u);if(null===i||!i.length)return t;const o=[];let r=i.shift(),l=a.test(r);for(;;){if(l){const t=parseFloat(r);isNaN(t)?o.push(r):o.push(Math.ceil(t*e*n)/n)}else o.push(r);if(r=i.shift(),void 0===r)return o.join("");l=!l}}function g(t,e){const i={...n,...t},o={...r,...e},l={left:i.left,top:i.top,width:i.width,height:i.height};let s=i.body;[i,o].forEach(t=>{const e=[],n=t.hFlip,i=t.vFlip;let o,r=t.rotate;switch(n?i?r+=2:(e.push("translate("+(l.width+l.left).toString()+" "+(0-l.top).toString()+")"),e.push("scale(-1 1)"),l.top=l.left=0):i&&(e.push("translate("+(0-l.left).toString()+" "+(l.height+l.top).toString()+")"),e.push("scale(1 -1)"),l.top=l.left=0),r<0&&(r-=4*Math.floor(r/4)),r%=4,r){case 1:o=l.height/2+l.top,e.unshift("rotate(90 "+o.toString()+" "+o.toString()+")");break;case 2:e.unshift("rotate(180 "+(l.width/2+l.left).toString()+" "+(l.height/2+l.top).toString()+")");break;case 3:o=l.width/2+l.left,e.unshift("rotate(-90 "+o.toString()+" "+o.toString()+")")}r%2==1&&(l.left!==l.top&&(o=l.left,l.left=l.top,l.top=o),l.width!==l.height&&(o=l.width,l.width=l.height,l.height=o)),e.length&&(s=function(t,e,n){const i=function(t,e="defs"){let n="";const i=t.indexOf("<"+e);for(;i>=0;){const o=t.indexOf(">",i),r=t.indexOf("</"+e);if(-1===o||-1===r)break;const l=t.indexOf(">",r);if(-1===l)break;n+=t.slice(o+1,r).trim(),t=t.slice(0,i).trim()+t.slice(l+1)}return{defs:n,content:t}}(t);return o=i.defs,r=e+i.content+n,o?"<defs>"+o+"</defs>"+r:r;var o,r}(s,'<g transform="'+e.join(" ")+'">',"</g>"))});const c=o.width,f=o.height,h=l.width,u=l.height;let a,g;null===c?(g=null===f?"1em":"auto"===f?u:f,a=p(g,h/u)):(a="auto"===c?h:c,g=null===f?p(a,u/h):"auto"===f?u:f);const d={},w=(t,e)=>{(t=>"unset"===t||"undefined"===t||"none"===t)(e)||(d[t]=e.toString())};w("width",a),w("height",g);const x=[l.left,l.top,h,u];return d.viewBox=x.join(" "),{attributes:d,viewBox:x,body:s}}const d=/\sid="(\S+)"/g,w="IconifyId"+Date.now().toString(16)+(16777216*Math.random()|0).toString(16);let x=0;function b(t,e=w){const n=[];let i;for(;i=d.exec(t);)n.push(i[1]);if(!n.length)return t;const o="suffix"+(16777216*Math.random()|Date.now()).toString(16);return n.forEach(n=>{const i="function"==typeof e?e(n):e+(x++).toString(),r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+i+o+"$3")}),t=t.replace(new RegExp(o,"g"),"")}function O(t,e){let n=-1===t.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const i in e)n+=" "+i+'="'+e[i]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}export{O as a,h as g,g as i,b as r,l as s};
