"use strict";!function(){function e(e){if(!l(e))throw new Error("an HTMLElement or SVGElement is required; got "+e)}function t(e){return new Promise((function(t,n){l(e)?t(e):n(new Error("an HTMLElement or SVGElement is required; got "+e))}))}function n(e){for(var t=window.atob(e.split(",")[1]),n=(e=e.split(",")[0].split(":")[1].split(";")[0],new ArrayBuffer(t.length)),r=new Uint8Array(n),o=0;o *")).forEach((function(e){e.setAttributeNS(i,"xmlns","svg"===e.tagName?a:"http://www.w3.org/1999/xhtml")})),v?((y=document.createElement("div")).appendChild(T),e=y.innerHTML,"function"!=typeof r?{src:e,width:k,height:L}:void r(e,k,L)):(o=t,s=(U=(U=n)||{}).selectorRemap,b=U.modifyStyle,O=U.modifyCss,y=U.fonts,x=U.excludeUnusedCss,A=O||function(e,t){return(s?s(e):e)+"{"+(b?b(t):t)+"}\n"},S=[],E=void 0===y,C=y||[],p().forEach((function(e){var t=e.rules,n=e.href;t&&Array.from(t).forEach((function(e){var t;void 0!==e.style&&(function(e,t){if(t)try{return e.querySelector(t)||e.parentNode&&e.parentNode.querySelector(t)}catch(e){console.warn('Invalid CSS selector "'+t+'"',e)}}(o,e.selectorText)?S.push(A(e.selectorText,e.style.cssText)):E&&e.cssText.match(/^@font-face/)?(t=f(e,n))&&C.push(t):x||S.push(e.cssText))}))})),w(C).then((function(e){return S.join("\n")+e})).then((function(e){var t;if((t=document.createElement("style")).setAttribute("type","text/css"),t.innerHTML="",((e=document.createElement("defs")).appendChild(t),T.insertBefore(e,T.firstChild),t=document.createElement("div")).appendChild(T),e=t.innerHTML.replace(/NS\d+:href/gi,'xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href'),"function"!=typeof r)return{src:e,width:k,height:L};r(e,k,L)})))}))},o.svgAsDataUri=function(t,n,r){return e(t),o.prepareSvg(t,n).then((function(e){var t=e.src,n=e.width;return e=e.height,t="data:image/svg+xml;base64,"+window.btoa(decodeURIComponent(encodeURIComponent(']>'+t).replace(/%([0-9A-F]{2})/g,(function(e,t){return"%"===(t=String.fromCharCode("0x"+t))?"%25":t})))),"function"==typeof r&&r(t,n,e),t}))},o.svgAsPngUri=function(t,n,r){function i(e){var t=e.src,n=e.width,o=(e=e.height,document.createElement("canvas")),i=o.getContext("2d"),a=window.devicePixelRatio||1;o.width=n*a,o.height=e*a,o.style.width=o.width+"px",o.style.height=o.height+"px",i.setTransform(a,0,0,a,0,0),n=void(c?c(o,t):i.drawImage(t,0,0));try{n=o.toDataURL(u,l)}catch(e){if("undefined"!=typeof SecurityError&&e instanceof SecurityError||"SecurityError"===e.name)return void console.error("Rendered SVG images cannot be downloaded in this browser.");throw e}return"function"==typeof r&&r(n,o.width,o.height),Promise.resolve(n)}e(t);var a,s=n||{},u=void 0===(a=s.encoderType)?"image/png":a,l=void 0===(a=s.encoderOptions)?.8:a,c=s.canvg;return c?o.prepareSvg(t,n).then(i):o.svgAsDataUri(t,n).then((function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){return t(i({src:r,width:r.width,height:r.height}))},r.onerror=function(){n("There was an error loading the data URI as an image on the following SVG\n"+window.atob(e.slice(26))+"Open the following link to see browser's diagnosis\n"+e)},r.src=e}))}))},o.download=function(e,t,r){if(navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(n(t),e);else{var o=document.createElement("a");if("download"in o){o.download=e,o.style.display="none",document.body.appendChild(o);try{var i=n(t),a=URL.createObjectURL(i);o.href=a,o.onclick=function(){return requestAnimationFrame((function(){return URL.revokeObjectURL(a)}))}}catch(e){console.error(e),console.warn("Error while getting object URL. Falling back to string URL."),o.href=t}o.click(),document.body.removeChild(o)}else r&&r.popup&&(r.popup.document.title=e,r.popup.location.replace(t))}},o.saveSvg=function(e,n,i){var a=r();return t(e).then((function(e){return o.svgAsDataUri(e,i||{})})).then((function(e){return o.download(n,e,a)}))},o.saveSvgAsPng=function(e,n,i){var a=r();return t(e).then((function(e){return o.svgAsPngUri(e,i||{})})).then((function(e){return o.download(n,e,a)}))}}();