diff --git a/docs/assets/collect-3e738344.js b/docs/assets/collect-9cb57440.js similarity index 88% rename from docs/assets/collect-3e738344.js rename to docs/assets/collect-9cb57440.js index d90f351..67f8c03 100644 --- a/docs/assets/collect-3e738344.js +++ b/docs/assets/collect-9cb57440.js @@ -1 +1 @@ -import{l as g}from"./index-c3c47574.js";(async(o,n,t,a,r,c,s,d,i,e)=>{const m={z:`${o()}`.substr(2),cid:`${n.getItem(i)||(e=`${o()}`.substr(2),n.setItem(i,e),e)}`,ua:d.userAgent,dr:a.referrer||"",sr:`${t.width}x${t.height}`,vp:`${r.clientWidth}x${r.clientHeight}`,sd:`${t.pixelDepth}-bits`,ul:d.language,dl:c(s.href),dp:c(s.pathname),dt:a.title},h=new FormData;for(const[l,p]of Object.entries(m))h.append(l,p);try{await fetch("https://svgcode.glitch.me/",{method:"post",body:h})}catch{}})(Math.random,localStorage,screen,document,g,encodeURIComponent,location,navigator,"cid",0); +import{l as g}from"./index-567ccd08.js";(async(o,n,t,a,r,c,s,d,i,e)=>{const m={z:`${o()}`.substr(2),cid:`${n.getItem(i)||(e=`${o()}`.substr(2),n.setItem(i,e),e)}`,ua:d.userAgent,dr:a.referrer||"",sr:`${t.width}x${t.height}`,vp:`${r.clientWidth}x${r.clientHeight}`,sd:`${t.pixelDepth}-bits`,ul:d.language,dl:c(s.href),dp:c(s.pathname),dt:a.title},h=new FormData;for(const[l,p]of Object.entries(m))h.append(l,p);try{await fetch("https://svgcode.glitch.me/",{method:"post",body:h})}catch{}})(Math.random,localStorage,screen,document,g,encodeURIComponent,location,navigator,"cid",0); diff --git a/docs/assets/filehandling-01abf381.js b/docs/assets/filehandling-e9a81a95.js similarity index 80% rename from docs/assets/filehandling-01abf381.js rename to docs/assets/filehandling-e9a81a95.js index 07e6748..5eaf94a 100644 --- a/docs/assets/filehandling-01abf381.js +++ b/docs/assets/filehandling-e9a81a95.js @@ -1 +1 @@ -import{i as n,s as a,F as o}from"./index-c3c47574.js";window.launchQueue.setConsumer(async e=>{if(e.files.length)for(const t of e.files){const s=await t.getFile();if(s.type.startsWith("image/")){const i=URL.createObjectURL(s);n.addEventListener("load",()=>{URL.revokeObjectURL(i)},{once:!0}),n.src=i,await a(o,t);return}}}); +import{i as n,s as a,F as o}from"./index-567ccd08.js";window.launchQueue.setConsumer(async e=>{if(e.files.length)for(const t of e.files){const s=await t.getFile();if(s.type.startsWith("image/")){const i=URL.createObjectURL(s);n.addEventListener("load",()=>{URL.revokeObjectURL(i)},{once:!0}),n.src=i,await a(o,t);return}}}); diff --git a/docs/assets/index-c3c47574.js b/docs/assets/index-567ccd08.js similarity index 68% rename from docs/assets/index-c3c47574.js rename to docs/assets/index-567ccd08.js index c2f1a24..74a8d5a 100644 --- a/docs/assets/index-c3c47574.js +++ b/docs/assets/index-567ccd08.js @@ -1,29 +1,29 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const en="modulepreload",tn=function(e){return"/"+e},pt={},p=function(t,n,r){if(!n||n.length===0)return t();const i=document.getElementsByTagName("link");return Promise.all(n.map(a=>{if(a=tn(a),a in pt)return;pt[a]=!0;const s=a.endsWith(".css"),o=s?'[rel="stylesheet"]':"";if(!!r)for(let d=i.length-1;d>=0;d--){const u=i[d];if(u.href===a&&(!s||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${a}"]${o}`))return;const l=document.createElement("link");if(l.rel=s?"stylesheet":en,s||(l.as="script",l.crossOrigin=""),l.href=a,document.head.appendChild(l),s)return new Promise((d,u)=>{l.addEventListener("load",d),l.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${a}`)))})})).then(()=>t()).catch(a=>{const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a})},z=document.querySelector("canvas"),jr=document.querySelector(".menu"),zr=document.querySelector("main"),mt=document.querySelector(".details"),R=document.querySelector(".posterize"),nn=document.querySelector("[for=posterize]"),_=document.querySelector(".color"),rn=document.querySelector("[for=color]"),C=document.querySelector(".monochrome"),on=document.querySelector("[for=monochrome]"),$=document.querySelector(".consider-dpr"),an=document.querySelector('[for="consider-dpr"]'),O=document.querySelector(".optimize-curves"),sn=document.querySelector('[for="optimize-curves"]'),G=document.querySelector(".show-advanced"),cn=document.querySelector('[for="show-advanced"]'),y=document.querySelector("img"),at=document.querySelector(".reset-all"),Ee=document.querySelector(".open"),ke=document.querySelector(".save"),Se=document.querySelector(".copy"),xe=document.querySelector(".share"),Pe=document.querySelector(".paste"),Ce=document.querySelector(".install"),w=document.querySelector(".svg-output"),he=document.querySelector(".debug"),Oe=document.querySelector("progress"),Q=document.querySelector(".toast"),rt=document.querySelector("details.main"),Ne=document.querySelector("summary"),Rt=document.querySelector(".close-options-button"),ln=document.querySelector(".license"),dn=document.querySelector(".about"),oe=document.querySelector("pinch-zoom"),Ie=document.querySelector(".language"),At=document.querySelector("dark-mode-toggle"),T=document.documentElement,un=document.querySelector("meta[name=theme-color]"),ee=window.devicePixelRatio;oe.addEventListener("change",()=>{const{x:e,y:t,scale:n}=oe;w.setAttribute("transform",`translate(${e}, ${t}) scale(${n})`)});oe.addEventListener("pointerdown",()=>{oe.style.cursor="grabbing"});oe.addEventListener("pointerup",()=>{oe.style.cursor=""});const It=()=>{w.setAttribute("transform","")},Te=(e,t)=>{let n;return function(...i){const a=()=>{clearTimeout(n),e(...i)};clearTimeout(n),n=setTimeout(a,t)}},Mt=/Mac|iPhone/.test(navigator.platform);/*! +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const en="modulepreload",tn=function(e){return"/"+e},pt={},p=function(t,n,r){if(!n||n.length===0)return t();const i=document.getElementsByTagName("link");return Promise.all(n.map(s=>{if(s=tn(s),s in pt)return;pt[s]=!0;const a=s.endsWith(".css"),o=a?'[rel="stylesheet"]':"";if(!!r)for(let u=i.length-1;u>=0;u--){const d=i[u];if(d.href===s&&(!a||d.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${o}`))return;const l=document.createElement("link");if(l.rel=a?"stylesheet":en,a||(l.as="script",l.crossOrigin=""),l.href=s,document.head.appendChild(l),a)return new Promise((u,d)=>{l.addEventListener("load",u),l.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>t()).catch(s=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s})},A=document.querySelector("canvas"),jr=document.querySelector(".menu"),zr=document.querySelector("main"),mt=document.querySelector(".details"),R=document.querySelector(".posterize"),nn=document.querySelector("[for=posterize]"),L=document.querySelector(".color"),rn=document.querySelector("[for=color]"),C=document.querySelector(".monochrome"),on=document.querySelector("[for=monochrome]"),V=document.querySelector(".consider-dpr"),an=document.querySelector('[for="consider-dpr"]'),O=document.querySelector(".optimize-curves"),sn=document.querySelector('[for="optimize-curves"]'),G=document.querySelector(".show-advanced"),cn=document.querySelector('[for="show-advanced"]'),y=document.querySelector("img"),at=document.querySelector(".reset-all"),Ee=document.querySelector(".open"),ke=document.querySelector(".save"),Se=document.querySelector(".copy"),xe=document.querySelector(".share"),Pe=document.querySelector(".paste"),Ce=document.querySelector(".install"),w=document.querySelector(".svg-output"),he=document.querySelector(".debug"),Oe=document.querySelector("progress"),Q=document.querySelector(".toast"),rt=document.querySelector("details.main"),Ne=document.querySelector("summary"),Rt=document.querySelector(".close-options-button"),ln=document.querySelector(".license"),dn=document.querySelector(".about"),oe=document.querySelector("pinch-zoom"),Ie=document.querySelector(".language"),At=document.querySelector("dark-mode-toggle"),T=document.documentElement,un=document.querySelector("meta[name=theme-color]"),ee=window.devicePixelRatio;oe.addEventListener("change",()=>{const{x:e,y:t,scale:n}=oe;w.setAttribute("transform",`translate(${e}, ${t}) scale(${n})`)});oe.addEventListener("pointerdown",()=>{oe.style.cursor="grabbing"});oe.addEventListener("pointerup",()=>{oe.style.cursor=""});const It=()=>{w.setAttribute("transform","")},Te=(e,t)=>{let n;return function(...i){const s=()=>{clearTimeout(n),e(...i)};clearTimeout(n),n=setTimeout(s,t)}},Mt=/Mac|iPhone/.test(navigator.platform);/*! * canvas-size * v1.2.6 * https://github.com/jhildenbiddle/canvas-size * (c) 2015-2023 John Hildenbiddle * MIT license - */function hn(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,o=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(o.push(r.value),o.length!==t);c=!0);}catch(d){l=!0,i=d}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(l)throw i}}return o}}function ft(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function x(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function fn(e,t){if(e==null)return{};var n=mn(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function gt(e,t){return vn(e)||hn(e,t)||$t(e,t)||bn()}function ve(e){return gn(e)||yn(e)||$t(e)||wn()}function gn(e){if(Array.isArray(e))return it(e)}function vn(e){if(Array.isArray(e))return e}function yn(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $t(e,t){if(e){if(typeof e=="string")return it(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return it(e,t)}}function it(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0)&&(n[i]=e[i]);return n}function fn(e,t){if(e==null)return{};var n=mn(e,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function gt(e,t){return vn(e)||hn(e,t)||$t(e,t)||bn()}function ve(e){return gn(e)||yn(e)||$t(e)||wn()}function gn(e){if(Array.isArray(e))return it(e)}function vn(e){if(Array.isArray(e))return e}function yn(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $t(e,t){if(e){if(typeof e=="string")return it(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return it(e,t)}}function it(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=a;){var c=t||n?o:1,l=t||r?o:1;i.push([c,l]),o-=s}return i}function ye(e){var t=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),i=e.onError,a=e.onSuccess,s=fn(e,En),o=null;if(!t)return!1;if(e.useWorker&&n){var c=` +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _n(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ln(e){var t=_n(e,"string");return typeof t=="symbol"?t:String(t)}function pe(e){var t=e.sizes.shift(),n=Math.max(Math.ceil(t[0]),1),r=Math.max(Math.ceil(t[1]),1),i=[n-1,r-1,1,1],s=Date.now(),a=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,o,c;a?(o=new OffscreenCanvas(1,1),c=new OffscreenCanvas(n,r)):(o=document.createElement("canvas"),o.width=1,o.height=1,c=document.createElement("canvas"),c.width=n,c.height=r);var l=o.getContext("2d"),u=c.getContext("2d");u&&(u.fillRect.apply(u,i),l.drawImage(c,n-1,r-1,1,1,0,0,1,1));var d=l&&l.getImageData(0,0,1,1).data[3]!==0,h=Date.now()-s;return[o,c].forEach(function(g){g.height=0,g.width=0}),a?(postMessage({width:n,height:r,benchmark:h,isTestPass:d}),!d&&e.sizes.length&&pe(e)):d?e.onSuccess(n,r,h):(e.onError(n,r,h),e.sizes.length&&pe(e)),d}var Ue={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},En=["onError","onSuccess"],te={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},se={};function qe(e){var t=e.width===e.height,n=e.height===1,r=e.width===1,i=[];if(!e.width||!e.height)e.sizes.forEach(function(u){var d=t||n?u:1,h=t||r?u:1;i.push([d,h])});else for(var s=e.min||te.min,a=e.step||te.step,o=Math.max(e.width,e.height);o>=s;){var c=t||n?o:1,l=t||r?o:1;i.push([c,l]),o-=a}return i}function ye(e){var t=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),i=e.onError,s=e.onSuccess,a=fn(e,En),o=null;if(!t)return!1;if(e.useWorker&&n){var c=` var canvasTest = `.concat(pe.toString(),`; onmessage = function(e) { canvasTest(e.data); }; - `),l=new Blob([c],{type:"application/javascript"}),d=URL.createObjectURL(l);o=new Worker(d),URL.revokeObjectURL(d),o.onmessage=function(u){var h=u.data,f=h.width,E=h.height,V=h.benchmark,He=h.isTestPass;He?(se[r].onSuccess(f,E,V),delete se[r]):se[r].onError(f,E,V)}}if(e.usePromise)return new Promise(function(u,h){var f=x(x({},e),{},{onError:function(X,K,ae){var Be;if(e.sizes.length===0)Be=!0;else{var Kt=e.sizes.slice(-1),Jt=gt(Kt,1),ht=gt(Jt[0],2),Zt=ht[0],Qt=ht[1];Be=X===Zt&&K===Qt}i(X,K,ae),Be&&h({width:X,height:K,benchmark:ae})},onSuccess:function(X,K,ae){a(X,K,ae),u({width:X,height:K,benchmark:ae})}});if(o){var E=f.onError,V=f.onSuccess;se[r]={onError:E,onSuccess:V},o.postMessage(s)}else pe(f)});if(o)se[r]={onError:i,onSuccess:a},o.postMessage(s);else return pe(e)}var kn={maxArea:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:t.max,height:t.max,min:t.min,step:t.step,sizes:ve(Ue.area)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},maxHeight:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:1,height:t.max,min:t.min,step:t.step,sizes:ve(Ue.height)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},maxWidth:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:t.max,height:1,min:t.min,step:t.step,sizes:ve(Ue.width)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},test:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=x(x({},te),t);return n.sizes=ve(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),ye(n)}};let Vt,jt;const zt="OffscreenCanvas"in window&&"CanvasFilter"in window;if(zt)p(()=>import("./preprocessworker-83ff0da1.js"),[]).then(e=>{const t=e.default;let n=null;const r=z.getContext("2d");Vt=async()=>{n&&n.terminate(),n=new t;const i=z.cloneNode().transferControlToOffscreen();return n.postMessage({offscreen:i},[i]),new Promise(async a=>{const{width:s,height:o}=vt();let c;try{c=await createImageBitmap(y)}catch{try{c=await createImageBitmap(y,0,0,s,o)}catch(d){console.error(d.name,d.message),w.innerHTML="",P(d.message);return}}const l=new MessageChannel;l.port1.onmessage=({data:d})=>{l.port1.close(),n&&(n.terminate(),n=null),z.width=s,z.height=o,r.putImageData(d.result,0,0),a(d.result)},n.postMessage({inputImageBitmap:c,posterize:R.checked,rgba:{r:N(v[S.red]),g:N(v[S.green]),b:N(v[S.blue]),a:N(v[S.alpha])},cssFilters:Dt(),rotate:Number(v[fe.rotation].value),width:s,height:o,dpr:ee},[l.port2])})}});else{const e=z.getContext("2d",{desynchronized:!0});e.scale(ee,ee),e.imageSmoothingEnabled=!0,jt=()=>{let{width:t,height:n}=vt();const r=$.checked?ee:1;let i=1;for(;!kn.test({width:t,height:n});)t=Math.floor(t/2),n=Math.floor(n/2),i/=2;z.width=t,z.height=n,e.clearRect(0,0,t,n),e.filter=xn(),e.setTransform(1,0,0,1,t/2,n/2);const a=Number(v[fe.rotation].value);return e.rotate(a*Math.PI/180),e.drawImage(y,-r*y.naturalWidth*i/2,-r*y.naturalHeight*i/2),e.getImageData(0,0,t,n)}}const vt=()=>{const e=Number(v[fe.scale].value)/100;return{width:Math.ceil(ee*y.naturalWidth*e),height:Math.ceil(ee*y.naturalHeight*e)}},N=e=>{const t=Number(e.value),n=[];for(let r=0;r<=t;r++)n[r]=Number((1/t*r).toFixed(1));return n},Sn=()=>`data:image/svg+xml;utf8,0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:t.max,height:t.max,min:t.min,step:t.step,sizes:ve(Ue.area)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},maxHeight:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:1,height:t.max,min:t.min,step:t.step,sizes:ve(Ue.height)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},maxWidth:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=qe({width:t.max,height:1,min:t.min,step:t.step,sizes:ve(Ue.width)}),r=x(x(x({},te),t),{},{sizes:n});return ye(r)},test:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=x(x({},te),t);return n.sizes=ve(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),ye(n)}};let Vt,jt;const zt="OffscreenCanvas"in window&&"CanvasFilter"in window;if(zt)p(()=>import("./preprocessworker-83ff0da1.js"),[]).then(e=>{const t=e.default;let n=null;const r=A.getContext("2d");Vt=async()=>{n&&n.terminate(),n=new t;const i=A.cloneNode().transferControlToOffscreen();return n.postMessage({offscreen:i},[i]),new Promise(async s=>{const{width:a,height:o}=vt();let c;try{c=await createImageBitmap(y)}catch{try{c=await createImageBitmap(y,0,0,a,o)}catch(u){console.error(u.name,u.message),w.innerHTML="",P(u.message);return}}const l=new MessageChannel;l.port1.onmessage=({data:u})=>{l.port1.close(),n&&(n.terminate(),n=null),A.width=a,A.height=o,r.putImageData(u.result,0,0),s(u.result)},n.postMessage({inputImageBitmap:c,posterize:R.checked,rgba:{r:N(f[_.red]),g:N(f[_.green]),b:N(f[_.blue]),a:N(f[_.alpha])},cssFilters:Dt(),rotate:Number(f[fe.rotation].value),width:a,height:o,dpr:ee},[l.port2])})}});else{const e=A.getContext("2d",{desynchronized:!0});e.scale(ee,ee),e.imageSmoothingEnabled=!0,jt=()=>{let{width:t,height:n}=vt();const r=V.checked?ee:1;let i=1;for(;!kn.test({width:t,height:n});)t=Math.floor(t/2),n=Math.floor(n/2),i/=2;A.width=t,A.height=n,e.clearRect(0,0,t,n),e.setTransform(1,0,0,1,t/2,n/2),e.drawImage(y,-r*y.naturalWidth*i/2,-r*y.naturalHeight*i/2);const s=Number(f[fe.rotation].value);e.rotate(s*Math.PI/180),e.filter=xn();const a=e.getImageData(0,0,A.width,A.height),o=f[_.red].value,c=f[_.green].value,l=f[_.blue].value,u=f[_.alpha].value+1;for(let d=0;d{const e=Number(f[fe.scale].value)/100;return{width:Math.ceil(ee*y.naturalWidth*e),height:Math.ceil(ee*y.naturalHeight*e)}},N=e=>{const t=Number(e.value),n=[];for(let r=0;r<=t;r++)n[r]=Number((1/t*r).toFixed(1));return n},Sn=()=>`data:image/svg+xml;utf8, - - - - + + + + - `.replace(/[\r\n]/g,"").replace(/\s+/g," ").trim(),Dt=()=>{let e="";for(const[t,n]of Object.entries(Ut)){const r=v[t];n.initial!==Number(r.value)&&(e+=`${t}(${r.value}${r.dataset.unit}) `)}return e},xn=()=>{let e=`${R.checked?`url('${Sn()}#posterize') `:""}`;return e+=Dt(),e.trim()||"none"};function Pn(){return new Worker("/assets/monochromeworker-f4bfce91.js")}let q=null;const Cn=async e=>(q&&q.terminate(),q=new Pn,new Promise(async t=>{const n=new MessageChannel;n.port1.onmessage=({data:i})=>{n.port1.close(),q&&(q.terminate(),q=null),t(i.result)};const r={turdsize:Number(v[L.turdsize].value),alphamax:Number(v[L.alphamax].value),turnpolicy:Number(v[L.turnpolicy].value),opttolerance:Number(v[L.opttolerance].value),opticurve:O.checked?1:0,extractcolors:!1};q.postMessage({imageData:e,params:r},[n.port2])}));function On(){return new Worker("/assets/colorworker-9f272d25.js")}let W=null;const M={},Tn=async e=>(W&&W.terminate(),W=new On,new Promise(async t=>{const n=new MessageChannel;n.port1.onmessage=({data:l})=>{n.port1.close(),W&&(W.terminate(),W=null),t(l.result)},Oe.value=0;let r="",i="",a="",s=0;M.current&&(clearInterval(M.current),M.current=null),M.current=setInterval(()=>{const l=`${r}${a}${i}`;if(l.length!==s){const d=w.dataset.transform;d&&w.setAttribute("transform",d),w.innerHTML=l,s=l.length}},500);const o=new MessageChannel;o.port1.onmessage=({data:l})=>{const d=Math.floor(l.processed/l.total*100);if(Oe.value=d,l.svg){r||(r=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$1").replace(/\s+width="\d+(?:\.\d+)?"/,"").replace(/\s+height="\d+(?:\.\d+)"/,""),i=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$3"));const u=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$2");a+=u}l.processed===l.total&&(clearInterval(M.current),M.current=null,o.port1.close(),Oe.value=0)};const c={minPathSegments:Number(v[L.minPathLength].value),strokeWidth:Number(v[L.strokeWidth].value),turdsize:Number(v[L.turdsize].value),alphamax:Number(v[L.alphamax].value),turnpolicy:Number(v[L.turnpolicy].value),opttolerance:Number(v[L.opttolerance].value),opticurve:O.checked?1:0,extractcolors:!1,posterizelevel:2,posterizationalgorithm:0};W.postMessage({imageData:e,params:c},[n.port2,o.port2])})),yt=(e,t)=>{const n=e[t];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((r,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t)))})},we="language",Rn=["ar","be","ca","da","de","el","en","es","fr","he","id","it","ja","ko","nl","no","pl","pt","ru","uk","zh"],An=["ar-TN","be-BY","ca-ES","da-DK","de-DE","el-GR","en-GB","en-US","es-ES","fr-FR","he-IL","id-ID","it-IT","ja-JP","ko-KR","nl-NL","no-NO","pl-PL","pt-BR","ru-RU","uk-UA","zh-CN"],In=["ar","fa","he","ur"];class Mn{constructor(){this.defaultLanguage="en",this.defaultLocale="US",this.translations=null,this.supportedLanguages=Rn,this.supportedLocales=An,this.currentLanguageAndLocale=this.detectOrRestoreLanguageAndLocale()}findBestMatchingLanguageAndLocale(t,n){return n&&(n=n.toUpperCase()),!t||!this.supportedLanguages.includes(t)?(t=this.defaultLanguage,n=this.defaultLocale):(!n||!this.supportedLocales.includes(`${t}-${n}`))&&(n=this.supportedLocales.find(r=>r.startsWith(`${t}-`)).split("-")[1]),{language:t,locale:n}}detectOrRestoreLanguageAndLocale(){const t=new URL(location),n=t.searchParams,r=n.get("lang");if(r){n.delete("lang"),history.pushState({},"",t);const[c,l=""]=r.split("-"),{language:d,locale:u}=this.findBestMatchingLanguageAndLocale(c,l);return this.setLanguageAndLocale(d,u),{language:d,locale:u}}try{const c=localStorage.getItem(we);if(c){const{language:l,locale:d}=JSON.parse(c);return this.setLanguageAndLocale(l,d),{language:l,locale:d}}}catch{}const[i,a=""]=navigator.language?.split("-"),{language:s,locale:o}=this.findBestMatchingLanguageAndLocale(i,a);return this.setLanguageAndLocale(s,o),{language:s,locale:o}}async setLanguageAndLocale(t,n){try{this.supportedLanguages.includes(t)||(localStorage.removeItem(we),t=this.defaultLanguage,n=this.defaultLocale),n&&!this.supportedLocales.includes(`${t}-${n}`)&&(localStorage.removeItem(we),t=this.defaultLanguage,n=this.defaultLocale),this.currentLanguageAndLocale={language:t,locale:n},localStorage.setItem(we,JSON.stringify(this.currentLanguageAndLocale))}catch{}T.lang=`${t}${n?`-${n}`:""}`,In.includes(t)?T.dir="rtl":T.dir="ltr",await this.getTranslations()}async getTranslations(){const{language:t,locale:n}=this.currentLanguageAndLocale;this.translations=(await yt(Object.assign({"../i18n/ar-TN.js":()=>p(()=>import("./ar-TN-917a8102.js"),["assets/ar-TN-917a8102.js","assets/languages-e8d9835d.js"]),"../i18n/be-BY.js":()=>p(()=>import("./be-BY-e27002d9.js"),["assets/be-BY-e27002d9.js","assets/languages-e8d9835d.js"]),"../i18n/ca-ES.js":()=>p(()=>import("./ca-ES-450231bf.js"),["assets/ca-ES-450231bf.js","assets/languages-e8d9835d.js"]),"../i18n/da-DK.js":()=>p(()=>import("./da-DK-fecf3d76.js"),["assets/da-DK-fecf3d76.js","assets/languages-e8d9835d.js"]),"../i18n/de-DE.js":()=>p(()=>import("./de-DE-c44b440e.js"),["assets/de-DE-c44b440e.js","assets/languages-e8d9835d.js"]),"../i18n/el-GR.js":()=>p(()=>import("./el-GR-cf1cb156.js"),["assets/el-GR-cf1cb156.js","assets/languages-e8d9835d.js"]),"../i18n/en-GB.js":()=>p(()=>import("./en-GB-1ebb0134.js"),["assets/en-GB-1ebb0134.js","assets/languages-e8d9835d.js"]),"../i18n/en-US.js":()=>p(()=>import("./en-US-14af226a.js"),["assets/en-US-14af226a.js","assets/languages-e8d9835d.js"]),"../i18n/es-ES.js":()=>p(()=>import("./es-ES-8cdc11e3.js"),["assets/es-ES-8cdc11e3.js","assets/languages-e8d9835d.js"]),"../i18n/fr-FR.js":()=>p(()=>import("./fr-FR-dff4346a.js"),["assets/fr-FR-dff4346a.js","assets/languages-e8d9835d.js"]),"../i18n/he-IL.js":()=>p(()=>import("./he-IL-3b82a749.js"),["assets/he-IL-3b82a749.js","assets/languages-e8d9835d.js"]),"../i18n/id-ID.js":()=>p(()=>import("./id-ID-d5dc62f7.js"),["assets/id-ID-d5dc62f7.js","assets/languages-e8d9835d.js"]),"../i18n/it-IT.js":()=>p(()=>import("./it-IT-24240090.js"),["assets/it-IT-24240090.js","assets/languages-e8d9835d.js"]),"../i18n/ja-JP.js":()=>p(()=>import("./ja-JP-6b72f65f.js"),["assets/ja-JP-6b72f65f.js","assets/languages-e8d9835d.js"]),"../i18n/ko-KR.js":()=>p(()=>import("./ko-KR-9fdbc612.js"),["assets/ko-KR-9fdbc612.js","assets/languages-e8d9835d.js"]),"../i18n/languages.js":()=>p(()=>import("./languages-e8d9835d.js"),[]),"../i18n/nl-NL.js":()=>p(()=>import("./nl-NL-f6a4c727.js"),["assets/nl-NL-f6a4c727.js","assets/languages-e8d9835d.js"]),"../i18n/no-NO.js":()=>p(()=>import("./no-NO-cb14a155.js"),["assets/no-NO-cb14a155.js","assets/languages-e8d9835d.js"]),"../i18n/pl-PL.js":()=>p(()=>import("./pl-PL-9ac090e3.js"),["assets/pl-PL-9ac090e3.js","assets/languages-e8d9835d.js"]),"../i18n/pt-BR.js":()=>p(()=>import("./pt-BR-30fb79a1.js"),["assets/pt-BR-30fb79a1.js","assets/languages-e8d9835d.js"]),"../i18n/ru-RU.js":()=>p(()=>import("./ru-RU-e5f207da.js"),["assets/ru-RU-e5f207da.js","assets/languages-e8d9835d.js"]),"../i18n/uk-UA.js":()=>p(()=>import("./uk-UA-87a01182.js"),["assets/uk-UA-87a01182.js","assets/languages-e8d9835d.js"]),"../i18n/zh-CN.js":()=>p(()=>import("./zh-CN-148f9e59.js"),["assets/zh-CN-148f9e59.js","assets/languages-e8d9835d.js"])}),`../i18n/${t}${n?`-${n}`:""}.js`).catch(()=>yt(Object.assign({"../i18n/ar-TN.js":()=>p(()=>import("./ar-TN-917a8102.js"),["assets/ar-TN-917a8102.js","assets/languages-e8d9835d.js"]),"../i18n/be-BY.js":()=>p(()=>import("./be-BY-e27002d9.js"),["assets/be-BY-e27002d9.js","assets/languages-e8d9835d.js"]),"../i18n/ca-ES.js":()=>p(()=>import("./ca-ES-450231bf.js"),["assets/ca-ES-450231bf.js","assets/languages-e8d9835d.js"]),"../i18n/da-DK.js":()=>p(()=>import("./da-DK-fecf3d76.js"),["assets/da-DK-fecf3d76.js","assets/languages-e8d9835d.js"]),"../i18n/de-DE.js":()=>p(()=>import("./de-DE-c44b440e.js"),["assets/de-DE-c44b440e.js","assets/languages-e8d9835d.js"]),"../i18n/el-GR.js":()=>p(()=>import("./el-GR-cf1cb156.js"),["assets/el-GR-cf1cb156.js","assets/languages-e8d9835d.js"]),"../i18n/en-GB.js":()=>p(()=>import("./en-GB-1ebb0134.js"),["assets/en-GB-1ebb0134.js","assets/languages-e8d9835d.js"]),"../i18n/en-US.js":()=>p(()=>import("./en-US-14af226a.js"),["assets/en-US-14af226a.js","assets/languages-e8d9835d.js"]),"../i18n/es-ES.js":()=>p(()=>import("./es-ES-8cdc11e3.js"),["assets/es-ES-8cdc11e3.js","assets/languages-e8d9835d.js"]),"../i18n/fr-FR.js":()=>p(()=>import("./fr-FR-dff4346a.js"),["assets/fr-FR-dff4346a.js","assets/languages-e8d9835d.js"]),"../i18n/he-IL.js":()=>p(()=>import("./he-IL-3b82a749.js"),["assets/he-IL-3b82a749.js","assets/languages-e8d9835d.js"]),"../i18n/id-ID.js":()=>p(()=>import("./id-ID-d5dc62f7.js"),["assets/id-ID-d5dc62f7.js","assets/languages-e8d9835d.js"]),"../i18n/it-IT.js":()=>p(()=>import("./it-IT-24240090.js"),["assets/it-IT-24240090.js","assets/languages-e8d9835d.js"]),"../i18n/ja-JP.js":()=>p(()=>import("./ja-JP-6b72f65f.js"),["assets/ja-JP-6b72f65f.js","assets/languages-e8d9835d.js"]),"../i18n/ko-KR.js":()=>p(()=>import("./ko-KR-9fdbc612.js"),["assets/ko-KR-9fdbc612.js","assets/languages-e8d9835d.js"]),"../i18n/languages.js":()=>p(()=>import("./languages-e8d9835d.js"),[]),"../i18n/nl-NL.js":()=>p(()=>import("./nl-NL-f6a4c727.js"),["assets/nl-NL-f6a4c727.js","assets/languages-e8d9835d.js"]),"../i18n/no-NO.js":()=>p(()=>import("./no-NO-cb14a155.js"),["assets/no-NO-cb14a155.js","assets/languages-e8d9835d.js"]),"../i18n/pl-PL.js":()=>p(()=>import("./pl-PL-9ac090e3.js"),["assets/pl-PL-9ac090e3.js","assets/languages-e8d9835d.js"]),"../i18n/pt-BR.js":()=>p(()=>import("./pt-BR-30fb79a1.js"),["assets/pt-BR-30fb79a1.js","assets/languages-e8d9835d.js"]),"../i18n/ru-RU.js":()=>p(()=>import("./ru-RU-e5f207da.js"),["assets/ru-RU-e5f207da.js","assets/languages-e8d9835d.js"]),"../i18n/uk-UA.js":()=>p(()=>import("./uk-UA-87a01182.js"),["assets/uk-UA-87a01182.js","assets/languages-e8d9835d.js"]),"../i18n/zh-CN.js":()=>p(()=>import("./zh-CN-148f9e59.js"),["assets/zh-CN-148f9e59.js","assets/languages-e8d9835d.js"])}),`../i18n/${this.defaultLocale}.js`))).default}t(t){return this.translations[t]||"⛔️ Missing translation"}}const m=new Mn,$n='',Vn=e=>{if(e===0)return"0B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(2)*1} ${["B","KB","MB"][t]}`},wt=(e,t)=>{e&&(e=e.replace(/\s+width="\d+(?:\.\d+)?"/,"").replace(/\s+height="\d+(?:\.\d+)"/,""),w.classList.remove(Me),w.classList.remove($e),w.classList.add(t),w.innerHTML=e,P(`${m.t("svgSize")}: ${Vn(e.length)}`,3e3))},A=async()=>{w.innerHTML="",w.classList.remove(Me,$e),M.current&&(clearInterval(M.current),M.current=null);const e=w.getAttribute("transform");w.innerHTML=$n,e&&(w.dataset.transform=e,w.setAttribute("transform",""));const t=zt?await Vt():jt();if(_.checked){const n=await Tn(t);e&&w.setAttribute("transform",e),wt(n,Me)}else{const n=await Cn(t);e&&w.setAttribute("transform",e),wt(n,$e)}},ge=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{top.window.document._=0}catch{return!1}return"showOpenFilePicker"in self})(),jn=ge?Promise.resolve().then(function(){return Un}):Promise.resolve().then(function(){return Xn});async function zn(...e){return(await jn).default(...e)}ge?Promise.resolve().then(function(){return Wn}):Promise.resolve().then(function(){return Jn});const Dn=ge?Promise.resolve().then(function(){return Gn}):Promise.resolve().then(function(){return Qn});async function Hn(...e){return(await Dn).default(...e)}const Bn=async e=>{const t=await e.getFile();return t.handle=e,t};var Nn=async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((i,a)=>{t[a]={description:i.description||"Files",accept:{}},i.mimeTypes?i.mimeTypes.map(s=>{t[a].accept[s]=i.extensions||[]}):t[a].accept["*/*"]=i.extensions||[]});const n=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=await Promise.all(n.map(Bn));return e[0].multiple?r:r[0]},Un={__proto__:null,default:Nn};function Re(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Re=function(n){this.s=n,this.n=n.next},Re.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(n){var r=this.s.return;return r===void 0?Promise.resolve({value:n,done:!0}):t(r.apply(this.s,arguments))},throw:function(n){var r=this.s.return;return r===void 0?Promise.reject(n):t(r.apply(this.s,arguments))}},new Re(e)}const Ht=async(e,t,n=e.name,r)=>{const i=[],a=[];var s,o=!1,c=!1;try{for(var l,d=function(u){var h,f,E,V=2;for(typeof Symbol<"u"&&(f=Symbol.asyncIterator,E=Symbol.iterator);V--;){if(f&&(h=u[f])!=null)return h.call(u);if(E&&(h=u[E])!=null)return new Re(h.call(u));f="@@asyncIterator",E="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());o=!(l=await d.next()).done;o=!1){const u=l.value,h=`${n}/${u.name}`;u.kind==="file"?a.push(u.getFile().then(f=>(f.directoryHandle=e,f.handle=u,Object.defineProperty(f,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>h})))):u.kind!=="directory"||!t||r&&r(u)||i.push(Ht(u,t,h,r))}}catch(u){c=!0,s=u}finally{try{o&&d.return!=null&&await d.return()}finally{if(c)throw s}}return[...(await Promise.all(i)).flat(),...await Promise.all(a)]};var qn=async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:Ht(t,e.recursive,void 0,e.skipDirectory)},Wn={__proto__:null,default:qn},Fn=async(e,t=[{}],n=null,r=!1,i=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const a=[];let s=null;if(e instanceof Blob&&e.type?s=e.type:e.headers&&e.headers.get("content-type")&&(s=e.headers.get("content-type")),t.forEach((l,d)=>{a[d]={description:l.description||"Files",accept:{}},l.mimeTypes?(d===0&&s&&l.mimeTypes.push(s),l.mimeTypes.map(u=>{a[d].accept[u]=l.extensions||[]})):s?a[d].accept[s]=l.extensions||[]:a[d].accept["*/*"]=l.extensions||[]}),n)try{await n.getFile()}catch(l){if(n=null,r)throw l}const o=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&i&&i(o);const c=await o.createWritable();return"stream"in e?(await e.stream().pipeTo(c),o):"body"in e?(await e.body.pipeTo(c),o):(await c.write(await e),await c.close(),o)},Gn={__proto__:null,default:Fn},Yn=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,n)=>{const r=document.createElement("input");r.type="file";const i=[...e.map(c=>c.mimeTypes||[]),...e.map(c=>c.extensions||[])].join();r.multiple=e[0].multiple||!1,r.accept=i||"",r.style.display="none",document.body.append(r);const a=c=>{typeof s=="function"&&s(),t(c)},s=e[0].legacySetup&&e[0].legacySetup(a,()=>s(n),r),o=()=>{window.removeEventListener("focus",o),r.remove()};r.addEventListener("click",()=>{window.addEventListener("focus",o)}),r.addEventListener("change",()=>{window.removeEventListener("focus",o),r.remove(),a(r.multiple?Array.from(r.files):r.files[0])}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Xn={__proto__:null,default:Yn},Kn=async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,n)=>{const r=document.createElement("input");r.type="file",r.webkitdirectory=!0;const i=s=>{typeof a=="function"&&a(),t(s)},a=e[0].legacySetup&&e[0].legacySetup(i,()=>a(n),r);r.addEventListener("change",()=>{let s=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(s=s.filter(o=>o.webkitRelativePath.split("/").every(c=>!e[0].skipDirectory({name:c,kind:"directory"})))):s=s.filter(o=>o.webkitRelativePath.split("/").length===2),i(s)}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Jn={__proto__:null,default:Kn},Zn=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const n=document.createElement("a");let r=e;"body"in e&&(r=await async function(s,o){const c=s.getReader(),l=new ReadableStream({start:h=>async function f(){return c.read().then(({done:E,value:V})=>{if(!E)return h.enqueue(V),f();h.close()})}()}),d=new Response(l),u=await d.blob();return c.releaseLock(),new Blob([u],{type:o})}(e.body,e.headers.get("content-type"))),n.download=t.fileName||"Untitled",n.href=URL.createObjectURL(await r);const i=()=>{typeof a=="function"&&a()},a=t.legacySetup&&t.legacySetup(i,()=>a(),n);return n.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null},Qn={__proto__:null,default:Zn};function er(){return new Worker("/assets/svgoworker-7ff1a964.js")}let F=null;const Ae=async e=>(F&&F.terminate(),F=new er,new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=({data:r})=>{n.port1.close(),F&&(F.terminate(),F=null),t(r.result)},F.postMessage({svg:e},[n.port2])}));function ze(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function tr(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=ze(n);return(i,a)=>r.then(s=>a(s.transaction(t,i).objectStore(t)))}let We;function st(){return We||(We=tr("keyval-store","keyval")),We}function re(e,t=st()){return t("readonly",n=>ze(n.get(e)))}function U(e,t,n=st()){return n("readwrite",r=>(r.put(t,e),ze(r.transaction)))}function nr(e,t=st()){return t("readwrite",n=>(n.delete(e),ze(n.transaction)))}const me="fileHandle",rr=e=>e?e.name.replace(/\.[^\.]+$/,""):"";Ee.addEventListener("click",async()=>{try{const e=await zn({mimeTypes:["image/*"],description:"Image files"}),t=URL.createObjectURL(e);y.addEventListener("load",()=>{URL.revokeObjectURL(t)},{once:!0}),y.src=t,ge&&await U(me,e.handle)}catch(e){console.error(e.name,e.message),P(e.message)}});document.addEventListener("dragover",e=>{e.preventDefault()});document.addEventListener("dragenter",e=>{e.preventDefault(),T.classList.add("dropenter")});document.addEventListener("dragleave",e=>{e.preventDefault(),e.target===T&&T.classList.remove("dropenter")});document.addEventListener("drop",async e=>{e.preventDefault(),e.stopPropagation(),T.classList.remove("dropenter");const t=e.dataTransfer.items[0];if(t.kind==="file"){let n;if(y.addEventListener("load",()=>{URL.revokeObjectURL(n)},{once:!0}),ge){const i=await t.getAsFileSystemHandle();if(i.kind!=="file")return;const a=await i.getFile();n=URL.createObjectURL(a),y.src=n,await U(me,i);return}const r=t.getAsFile();n=URL.createObjectURL(r),y.src=n}});ke.addEventListener("click",async()=>{const e=async()=>{P(m.t("optimizingSVG"),1/0);const t=await Ae(w.innerHTML);return Tr(),new Blob([t],{type:"image/svg+xml"})};try{let t=!1;try{t=await re(me)}catch{}const n=rr(t);await Hn(e(),{fileName:n,description:"SVG file",extensions:[".svg"],mimeTypes:["image/svg+xml"]}),P(m.t("savedSVG"))}catch(t){console.error(t.name,t.message),P(t.message)}});Pe.addEventListener("click",async()=>{try{const e=await navigator.clipboard.read();for(const t of e)for(const n of t.types)if(n.startsWith("image/")){const r=await t.getType(n);if(!r)return;const i=URL.createObjectURL(r);y.src=i;return}}catch(e){console.error(e.name,e.message),P(e.message)}});document.addEventListener("paste",e=>{try{if(!e.clipboardData.files.length)return;const t=e.clipboardData.files[0];if(t.type.startsWith("image/")){const n=URL.createObjectURL(t);y.src=n;return}}catch(t){console.error(t.name,t.message),P(t.message)}});Se.addEventListener("click",async()=>{let e=w.innerHTML;P(m.t("optimizingSVG"),1/0);try{"ClipboardItem"in window?Mt?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"})})]):(e=await Ae(e),await navigator.clipboard.write([new ClipboardItem({"text/plain":new Promise(async t=>{t(new Blob([e],{type:"text/plain"}))}),"image/svg+xml":new Promise(async t=>{t(new Blob([e],{type:"image/svg+xml"}))})})])):await navigator.clipboard.writeText(await Ae(e))}catch{e=await Ae(e);const n=new Blob([e],{type:"text/plain"}),r=new Blob([e],{type:"image/svg+xml"});try{Number(navigator.userAgent.replace(/.*Chrome\/(\d+).*/,"$1"))<=88?await navigator.clipboard.write([new ClipboardItem({[n.type]:n})]):await navigator.clipboard.write([new ClipboardItem({[r.type]:r,[n.type]:n})])}catch{try{await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}catch(a){P(a.message);return}}}P(m.t("copiedSVG"))});class B{constructor(t){this.id=-1,this.nativePointer=t,this.pageX=t.pageX,this.pageY=t.pageY,this.clientX=t.clientX,this.clientY=t.clientY,self.Touch&&t instanceof Touch?this.id=t.identifier:le(t)&&(this.id=t.pointerId)}getCoalesced(){if("getCoalescedEvents"in this.nativePointer){const t=this.nativePointer.getCoalescedEvents().map(n=>new B(n));if(t.length>0)return t}return[this]}}const le=e=>"pointerId"in e,Fe=e=>"changedTouches"in e,bt=()=>{};class ir{constructor(t,{start:n=()=>!0,move:r=bt,end:i=bt,rawUpdates:a=!1,avoidPointerEvents:s=!1}={}){this._element=t,this.startPointers=[],this.currentPointers=[],this._excludeFromButtonsCheck=new Set,this._pointerStart=o=>{if(le(o)&&o.buttons===0)this._excludeFromButtonsCheck.add(o.pointerId);else if(!(o.buttons&1))return;const c=new B(o);this.currentPointers.some(l=>l.id===c.id)||this._triggerPointerStart(c,o)&&(le(o)?((o.target&&"setPointerCapture"in o.target?o.target:this._element).setPointerCapture(o.pointerId),this._element.addEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.addEventListener("pointerup",this._pointerEnd),this._element.addEventListener("pointercancel",this._pointerEnd)):(window.addEventListener("mousemove",this._move),window.addEventListener("mouseup",this._pointerEnd)))},this._touchStart=o=>{for(const c of Array.from(o.changedTouches))this._triggerPointerStart(new B(c),o)},this._move=o=>{if(!Fe(o)&&(!le(o)||!this._excludeFromButtonsCheck.has(o.pointerId))&&o.buttons===0){this._pointerEnd(o);return}const c=this.currentPointers.slice(),l=Fe(o)?Array.from(o.changedTouches).map(u=>new B(u)):[new B(o)],d=[];for(const u of l){const h=this.currentPointers.findIndex(f=>f.id===u.id);h!==-1&&(d.push(u),this.currentPointers[h]=u)}d.length!==0&&this._moveCallback(c,d,o)},this._triggerPointerEnd=(o,c)=>{if(!Fe(c)&&c.buttons&1)return!1;const l=this.currentPointers.findIndex(u=>u.id===o.id);if(l===-1)return!1;this.currentPointers.splice(l,1),this.startPointers.splice(l,1),this._excludeFromButtonsCheck.delete(o.id);const d=!(c.type==="mouseup"||c.type==="touchend"||c.type==="pointerup");return this._endCallback(o,c,d),!0},this._pointerEnd=o=>{if(this._triggerPointerEnd(new B(o),o))if(le(o)){if(this.currentPointers.length)return;this._element.removeEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.removeEventListener("pointerup",this._pointerEnd),this._element.removeEventListener("pointercancel",this._pointerEnd)}else window.removeEventListener("mousemove",this._move),window.removeEventListener("mouseup",this._pointerEnd)},this._touchEnd=o=>{for(const c of Array.from(o.changedTouches))this._triggerPointerEnd(new B(c),o)},this._startCallback=n,this._moveCallback=r,this._endCallback=i,this._rawUpdates=a&&"onpointerrawupdate"in window,self.PointerEvent&&!s?this._element.addEventListener("pointerdown",this._pointerStart):(this._element.addEventListener("mousedown",this._pointerStart),this._element.addEventListener("touchstart",this._touchStart),this._element.addEventListener("touchmove",this._move),this._element.addEventListener("touchend",this._touchEnd),this._element.addEventListener("touchcancel",this._touchEnd))}stop(){this._element.removeEventListener("pointerdown",this._pointerStart),this._element.removeEventListener("mousedown",this._pointerStart),this._element.removeEventListener("touchstart",this._touchStart),this._element.removeEventListener("touchmove",this._move),this._element.removeEventListener("touchend",this._touchEnd),this._element.removeEventListener("touchcancel",this._touchEnd),this._element.removeEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.removeEventListener("pointerup",this._pointerEnd),this._element.removeEventListener("pointercancel",this._pointerEnd),window.removeEventListener("mousemove",this._move),window.removeEventListener("mouseup",this._pointerEnd)}_triggerPointerStart(t,n){return this._startCallback(t,n)?(this.currentPointers.push(t),this.startPointers.push(t),!0):!1}}function or(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(!e||typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",n==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var ar=`pinch-zoom { + `.replace(/[\r\n]/g,"").replace(/\s+/g," ").trim(),Dt=()=>{let e="";for(const[t,n]of Object.entries(Ut)){const r=f[t];n.initial!==Number(r.value)&&(e+=`${t}(${r.value}${r.dataset.unit}) `)}return e},xn=()=>{let e=`${R.checked?`url('${Sn()}#posterize') `:""}`;return e+=Dt(),e.trim()||"none"};function Pn(){return new Worker("/assets/monochromeworker-f4bfce91.js")}let q=null;const Cn=async e=>(q&&q.terminate(),q=new Pn,new Promise(async t=>{const n=new MessageChannel;n.port1.onmessage=({data:i})=>{n.port1.close(),q&&(q.terminate(),q=null),t(i.result)};const r={turdsize:Number(f[E.turdsize].value),alphamax:Number(f[E.alphamax].value),turnpolicy:Number(f[E.turnpolicy].value),opttolerance:Number(f[E.opttolerance].value),opticurve:O.checked?1:0,extractcolors:!1};q.postMessage({imageData:e,params:r},[n.port2])}));function On(){return new Worker("/assets/colorworker-9f272d25.js")}let W=null;const $={},Tn=async e=>(W&&W.terminate(),W=new On,new Promise(async t=>{const n=new MessageChannel;n.port1.onmessage=({data:l})=>{n.port1.close(),W&&(W.terminate(),W=null),t(l.result)},Oe.value=0;let r="",i="",s="",a=0;$.current&&(clearInterval($.current),$.current=null),$.current=setInterval(()=>{const l=`${r}${s}${i}`;if(l.length!==a){const u=w.dataset.transform;u&&w.setAttribute("transform",u),w.innerHTML=l,a=l.length}},500);const o=new MessageChannel;o.port1.onmessage=({data:l})=>{const u=Math.floor(l.processed/l.total*100);if(Oe.value=u,l.svg){r||(r=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$1").replace(/\s+width="\d+(?:\.\d+)?"/,"").replace(/\s+height="\d+(?:\.\d+)"/,""),i=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$3"));const d=l.svg.replace(/(.*?]+>)(.*?)(<\/svg>)/,"$2");s+=d}l.processed===l.total&&(clearInterval($.current),$.current=null,o.port1.close(),Oe.value=0)};const c={minPathSegments:Number(f[E.minPathLength].value),strokeWidth:Number(f[E.strokeWidth].value),turdsize:Number(f[E.turdsize].value),alphamax:Number(f[E.alphamax].value),turnpolicy:Number(f[E.turnpolicy].value),opttolerance:Number(f[E.opttolerance].value),opticurve:O.checked?1:0,extractcolors:!1,posterizelevel:2,posterizationalgorithm:0};W.postMessage({imageData:e,params:c},[n.port2,o.port2])})),yt=(e,t)=>{const n=e[t];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((r,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t)))})},we="language",Rn=["ar","be","ca","da","de","el","en","es","fr","he","id","it","ja","ko","nl","no","pl","pt","ru","uk","zh"],An=["ar-TN","be-BY","ca-ES","da-DK","de-DE","el-GR","en-GB","en-US","es-ES","fr-FR","he-IL","id-ID","it-IT","ja-JP","ko-KR","nl-NL","no-NO","pl-PL","pt-BR","ru-RU","uk-UA","zh-CN"],In=["ar","fa","he","ur"];class Mn{constructor(){this.defaultLanguage="en",this.defaultLocale="US",this.translations=null,this.supportedLanguages=Rn,this.supportedLocales=An,this.currentLanguageAndLocale=this.detectOrRestoreLanguageAndLocale()}findBestMatchingLanguageAndLocale(t,n){return n&&(n=n.toUpperCase()),!t||!this.supportedLanguages.includes(t)?(t=this.defaultLanguage,n=this.defaultLocale):(!n||!this.supportedLocales.includes(`${t}-${n}`))&&(n=this.supportedLocales.find(r=>r.startsWith(`${t}-`)).split("-")[1]),{language:t,locale:n}}detectOrRestoreLanguageAndLocale(){const t=new URL(location),n=t.searchParams,r=n.get("lang");if(r){n.delete("lang"),history.pushState({},"",t);const[c,l=""]=r.split("-"),{language:u,locale:d}=this.findBestMatchingLanguageAndLocale(c,l);return this.setLanguageAndLocale(u,d),{language:u,locale:d}}try{const c=localStorage.getItem(we);if(c){const{language:l,locale:u}=JSON.parse(c);return this.setLanguageAndLocale(l,u),{language:l,locale:u}}}catch{}const[i,s=""]=navigator.language?.split("-"),{language:a,locale:o}=this.findBestMatchingLanguageAndLocale(i,s);return this.setLanguageAndLocale(a,o),{language:a,locale:o}}async setLanguageAndLocale(t,n){try{this.supportedLanguages.includes(t)||(localStorage.removeItem(we),t=this.defaultLanguage,n=this.defaultLocale),n&&!this.supportedLocales.includes(`${t}-${n}`)&&(localStorage.removeItem(we),t=this.defaultLanguage,n=this.defaultLocale),this.currentLanguageAndLocale={language:t,locale:n},localStorage.setItem(we,JSON.stringify(this.currentLanguageAndLocale))}catch{}T.lang=`${t}${n?`-${n}`:""}`,In.includes(t)?T.dir="rtl":T.dir="ltr",await this.getTranslations()}async getTranslations(){const{language:t,locale:n}=this.currentLanguageAndLocale;this.translations=(await yt(Object.assign({"../i18n/ar-TN.js":()=>p(()=>import("./ar-TN-917a8102.js"),["assets/ar-TN-917a8102.js","assets/languages-e8d9835d.js"]),"../i18n/be-BY.js":()=>p(()=>import("./be-BY-e27002d9.js"),["assets/be-BY-e27002d9.js","assets/languages-e8d9835d.js"]),"../i18n/ca-ES.js":()=>p(()=>import("./ca-ES-450231bf.js"),["assets/ca-ES-450231bf.js","assets/languages-e8d9835d.js"]),"../i18n/da-DK.js":()=>p(()=>import("./da-DK-fecf3d76.js"),["assets/da-DK-fecf3d76.js","assets/languages-e8d9835d.js"]),"../i18n/de-DE.js":()=>p(()=>import("./de-DE-c44b440e.js"),["assets/de-DE-c44b440e.js","assets/languages-e8d9835d.js"]),"../i18n/el-GR.js":()=>p(()=>import("./el-GR-cf1cb156.js"),["assets/el-GR-cf1cb156.js","assets/languages-e8d9835d.js"]),"../i18n/en-GB.js":()=>p(()=>import("./en-GB-1ebb0134.js"),["assets/en-GB-1ebb0134.js","assets/languages-e8d9835d.js"]),"../i18n/en-US.js":()=>p(()=>import("./en-US-14af226a.js"),["assets/en-US-14af226a.js","assets/languages-e8d9835d.js"]),"../i18n/es-ES.js":()=>p(()=>import("./es-ES-8cdc11e3.js"),["assets/es-ES-8cdc11e3.js","assets/languages-e8d9835d.js"]),"../i18n/fr-FR.js":()=>p(()=>import("./fr-FR-dff4346a.js"),["assets/fr-FR-dff4346a.js","assets/languages-e8d9835d.js"]),"../i18n/he-IL.js":()=>p(()=>import("./he-IL-3b82a749.js"),["assets/he-IL-3b82a749.js","assets/languages-e8d9835d.js"]),"../i18n/id-ID.js":()=>p(()=>import("./id-ID-d5dc62f7.js"),["assets/id-ID-d5dc62f7.js","assets/languages-e8d9835d.js"]),"../i18n/it-IT.js":()=>p(()=>import("./it-IT-24240090.js"),["assets/it-IT-24240090.js","assets/languages-e8d9835d.js"]),"../i18n/ja-JP.js":()=>p(()=>import("./ja-JP-6b72f65f.js"),["assets/ja-JP-6b72f65f.js","assets/languages-e8d9835d.js"]),"../i18n/ko-KR.js":()=>p(()=>import("./ko-KR-9fdbc612.js"),["assets/ko-KR-9fdbc612.js","assets/languages-e8d9835d.js"]),"../i18n/languages.js":()=>p(()=>import("./languages-e8d9835d.js"),[]),"../i18n/nl-NL.js":()=>p(()=>import("./nl-NL-f6a4c727.js"),["assets/nl-NL-f6a4c727.js","assets/languages-e8d9835d.js"]),"../i18n/no-NO.js":()=>p(()=>import("./no-NO-cb14a155.js"),["assets/no-NO-cb14a155.js","assets/languages-e8d9835d.js"]),"../i18n/pl-PL.js":()=>p(()=>import("./pl-PL-9ac090e3.js"),["assets/pl-PL-9ac090e3.js","assets/languages-e8d9835d.js"]),"../i18n/pt-BR.js":()=>p(()=>import("./pt-BR-30fb79a1.js"),["assets/pt-BR-30fb79a1.js","assets/languages-e8d9835d.js"]),"../i18n/ru-RU.js":()=>p(()=>import("./ru-RU-e5f207da.js"),["assets/ru-RU-e5f207da.js","assets/languages-e8d9835d.js"]),"../i18n/uk-UA.js":()=>p(()=>import("./uk-UA-87a01182.js"),["assets/uk-UA-87a01182.js","assets/languages-e8d9835d.js"]),"../i18n/zh-CN.js":()=>p(()=>import("./zh-CN-148f9e59.js"),["assets/zh-CN-148f9e59.js","assets/languages-e8d9835d.js"])}),`../i18n/${t}${n?`-${n}`:""}.js`).catch(()=>yt(Object.assign({"../i18n/ar-TN.js":()=>p(()=>import("./ar-TN-917a8102.js"),["assets/ar-TN-917a8102.js","assets/languages-e8d9835d.js"]),"../i18n/be-BY.js":()=>p(()=>import("./be-BY-e27002d9.js"),["assets/be-BY-e27002d9.js","assets/languages-e8d9835d.js"]),"../i18n/ca-ES.js":()=>p(()=>import("./ca-ES-450231bf.js"),["assets/ca-ES-450231bf.js","assets/languages-e8d9835d.js"]),"../i18n/da-DK.js":()=>p(()=>import("./da-DK-fecf3d76.js"),["assets/da-DK-fecf3d76.js","assets/languages-e8d9835d.js"]),"../i18n/de-DE.js":()=>p(()=>import("./de-DE-c44b440e.js"),["assets/de-DE-c44b440e.js","assets/languages-e8d9835d.js"]),"../i18n/el-GR.js":()=>p(()=>import("./el-GR-cf1cb156.js"),["assets/el-GR-cf1cb156.js","assets/languages-e8d9835d.js"]),"../i18n/en-GB.js":()=>p(()=>import("./en-GB-1ebb0134.js"),["assets/en-GB-1ebb0134.js","assets/languages-e8d9835d.js"]),"../i18n/en-US.js":()=>p(()=>import("./en-US-14af226a.js"),["assets/en-US-14af226a.js","assets/languages-e8d9835d.js"]),"../i18n/es-ES.js":()=>p(()=>import("./es-ES-8cdc11e3.js"),["assets/es-ES-8cdc11e3.js","assets/languages-e8d9835d.js"]),"../i18n/fr-FR.js":()=>p(()=>import("./fr-FR-dff4346a.js"),["assets/fr-FR-dff4346a.js","assets/languages-e8d9835d.js"]),"../i18n/he-IL.js":()=>p(()=>import("./he-IL-3b82a749.js"),["assets/he-IL-3b82a749.js","assets/languages-e8d9835d.js"]),"../i18n/id-ID.js":()=>p(()=>import("./id-ID-d5dc62f7.js"),["assets/id-ID-d5dc62f7.js","assets/languages-e8d9835d.js"]),"../i18n/it-IT.js":()=>p(()=>import("./it-IT-24240090.js"),["assets/it-IT-24240090.js","assets/languages-e8d9835d.js"]),"../i18n/ja-JP.js":()=>p(()=>import("./ja-JP-6b72f65f.js"),["assets/ja-JP-6b72f65f.js","assets/languages-e8d9835d.js"]),"../i18n/ko-KR.js":()=>p(()=>import("./ko-KR-9fdbc612.js"),["assets/ko-KR-9fdbc612.js","assets/languages-e8d9835d.js"]),"../i18n/languages.js":()=>p(()=>import("./languages-e8d9835d.js"),[]),"../i18n/nl-NL.js":()=>p(()=>import("./nl-NL-f6a4c727.js"),["assets/nl-NL-f6a4c727.js","assets/languages-e8d9835d.js"]),"../i18n/no-NO.js":()=>p(()=>import("./no-NO-cb14a155.js"),["assets/no-NO-cb14a155.js","assets/languages-e8d9835d.js"]),"../i18n/pl-PL.js":()=>p(()=>import("./pl-PL-9ac090e3.js"),["assets/pl-PL-9ac090e3.js","assets/languages-e8d9835d.js"]),"../i18n/pt-BR.js":()=>p(()=>import("./pt-BR-30fb79a1.js"),["assets/pt-BR-30fb79a1.js","assets/languages-e8d9835d.js"]),"../i18n/ru-RU.js":()=>p(()=>import("./ru-RU-e5f207da.js"),["assets/ru-RU-e5f207da.js","assets/languages-e8d9835d.js"]),"../i18n/uk-UA.js":()=>p(()=>import("./uk-UA-87a01182.js"),["assets/uk-UA-87a01182.js","assets/languages-e8d9835d.js"]),"../i18n/zh-CN.js":()=>p(()=>import("./zh-CN-148f9e59.js"),["assets/zh-CN-148f9e59.js","assets/languages-e8d9835d.js"])}),`../i18n/${this.defaultLocale}.js`))).default}t(t){return this.translations[t]||"⛔️ Missing translation"}}const m=new Mn,$n='',Vn=e=>{if(e===0)return"0B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(2)*1} ${["B","KB","MB"][t]}`},wt=(e,t)=>{e&&(e=e.replace(/\s+width="\d+(?:\.\d+)?"/,"").replace(/\s+height="\d+(?:\.\d+)"/,""),w.classList.remove(Me),w.classList.remove($e),w.classList.add(t),w.innerHTML=e,P(`${m.t("svgSize")}: ${Vn(e.length)}`,3e3))},I=async()=>{w.innerHTML="",w.classList.remove(Me,$e),$.current&&(clearInterval($.current),$.current=null);const e=w.getAttribute("transform");w.innerHTML=$n,e&&(w.dataset.transform=e,w.setAttribute("transform",""));const t=zt?await Vt():jt();if(L.checked){const n=await Tn(t);e&&w.setAttribute("transform",e),wt(n,Me)}else{const n=await Cn(t);e&&w.setAttribute("transform",e),wt(n,$e)}},ge=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{top.window.document._=0}catch{return!1}return"showOpenFilePicker"in self})(),jn=ge?Promise.resolve().then(function(){return Un}):Promise.resolve().then(function(){return Xn});async function zn(...e){return(await jn).default(...e)}ge?Promise.resolve().then(function(){return Wn}):Promise.resolve().then(function(){return Jn});const Dn=ge?Promise.resolve().then(function(){return Gn}):Promise.resolve().then(function(){return Qn});async function Hn(...e){return(await Dn).default(...e)}const Bn=async e=>{const t=await e.getFile();return t.handle=e,t};var Nn=async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((i,s)=>{t[s]={description:i.description||"Files",accept:{}},i.mimeTypes?i.mimeTypes.map(a=>{t[s].accept[a]=i.extensions||[]}):t[s].accept["*/*"]=i.extensions||[]});const n=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=await Promise.all(n.map(Bn));return e[0].multiple?r:r[0]},Un={__proto__:null,default:Nn};function Re(e){function t(n){if(Object(n)!==n)return Promise.reject(new TypeError(n+" is not an object."));var r=n.done;return Promise.resolve(n.value).then(function(i){return{value:i,done:r}})}return Re=function(n){this.s=n,this.n=n.next},Re.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(n){var r=this.s.return;return r===void 0?Promise.resolve({value:n,done:!0}):t(r.apply(this.s,arguments))},throw:function(n){var r=this.s.return;return r===void 0?Promise.reject(n):t(r.apply(this.s,arguments))}},new Re(e)}const Ht=async(e,t,n=e.name,r)=>{const i=[],s=[];var a,o=!1,c=!1;try{for(var l,u=function(d){var h,g,k,j=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,k=Symbol.iterator);j--;){if(g&&(h=d[g])!=null)return h.call(d);if(k&&(h=d[k])!=null)return new Re(h.call(d));g="@@asyncIterator",k="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());o=!(l=await u.next()).done;o=!1){const d=l.value,h=`${n}/${d.name}`;d.kind==="file"?s.push(d.getFile().then(g=>(g.directoryHandle=e,g.handle=d,Object.defineProperty(g,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>h})))):d.kind!=="directory"||!t||r&&r(d)||i.push(Ht(d,t,h,r))}}catch(d){c=!0,a=d}finally{try{o&&u.return!=null&&await u.return()}finally{if(c)throw a}}return[...(await Promise.all(i)).flat(),...await Promise.all(s)]};var qn=async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:Ht(t,e.recursive,void 0,e.skipDirectory)},Wn={__proto__:null,default:qn},Fn=async(e,t=[{}],n=null,r=!1,i=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const s=[];let a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach((l,u)=>{s[u]={description:l.description||"Files",accept:{}},l.mimeTypes?(u===0&&a&&l.mimeTypes.push(a),l.mimeTypes.map(d=>{s[u].accept[d]=l.extensions||[]})):a?s[u].accept[a]=l.extensions||[]:s[u].accept["*/*"]=l.extensions||[]}),n)try{await n.getFile()}catch(l){if(n=null,r)throw l}const o=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:s,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&i&&i(o);const c=await o.createWritable();return"stream"in e?(await e.stream().pipeTo(c),o):"body"in e?(await e.body.pipeTo(c),o):(await c.write(await e),await c.close(),o)},Gn={__proto__:null,default:Fn},Yn=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,n)=>{const r=document.createElement("input");r.type="file";const i=[...e.map(c=>c.mimeTypes||[]),...e.map(c=>c.extensions||[])].join();r.multiple=e[0].multiple||!1,r.accept=i||"",r.style.display="none",document.body.append(r);const s=c=>{typeof a=="function"&&a(),t(c)},a=e[0].legacySetup&&e[0].legacySetup(s,()=>a(n),r),o=()=>{window.removeEventListener("focus",o),r.remove()};r.addEventListener("click",()=>{window.addEventListener("focus",o)}),r.addEventListener("change",()=>{window.removeEventListener("focus",o),r.remove(),s(r.multiple?Array.from(r.files):r.files[0])}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Xn={__proto__:null,default:Yn},Kn=async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,n)=>{const r=document.createElement("input");r.type="file",r.webkitdirectory=!0;const i=a=>{typeof s=="function"&&s(),t(a)},s=e[0].legacySetup&&e[0].legacySetup(i,()=>s(n),r);r.addEventListener("change",()=>{let a=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(a=a.filter(o=>o.webkitRelativePath.split("/").every(c=>!e[0].skipDirectory({name:c,kind:"directory"})))):a=a.filter(o=>o.webkitRelativePath.split("/").length===2),i(a)}),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()})),Jn={__proto__:null,default:Kn},Zn=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const n=document.createElement("a");let r=e;"body"in e&&(r=await async function(a,o){const c=a.getReader(),l=new ReadableStream({start:h=>async function g(){return c.read().then(({done:k,value:j})=>{if(!k)return h.enqueue(j),g();h.close()})}()}),u=new Response(l),d=await u.blob();return c.releaseLock(),new Blob([d],{type:o})}(e.body,e.headers.get("content-type"))),n.download=t.fileName||"Untitled",n.href=URL.createObjectURL(await r);const i=()=>{typeof s=="function"&&s()},s=t.legacySetup&&t.legacySetup(i,()=>s(),n);return n.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null},Qn={__proto__:null,default:Zn};function er(){return new Worker("/assets/svgoworker-7ff1a964.js")}let F=null;const Ae=async e=>(F&&F.terminate(),F=new er,new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=({data:r})=>{n.port1.close(),F&&(F.terminate(),F=null),t(r.result)},F.postMessage({svg:e},[n.port2])}));function ze(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function tr(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=ze(n);return(i,s)=>r.then(a=>s(a.transaction(t,i).objectStore(t)))}let We;function st(){return We||(We=tr("keyval-store","keyval")),We}function re(e,t=st()){return t("readonly",n=>ze(n.get(e)))}function U(e,t,n=st()){return n("readwrite",r=>(r.put(t,e),ze(r.transaction)))}function nr(e,t=st()){return t("readwrite",n=>(n.delete(e),ze(n.transaction)))}const me="fileHandle",rr=e=>e?e.name.replace(/\.[^\.]+$/,""):"";Ee.addEventListener("click",async()=>{try{const e=await zn({mimeTypes:["image/*"],description:"Image files"}),t=URL.createObjectURL(e);y.addEventListener("load",()=>{URL.revokeObjectURL(t)},{once:!0}),y.src=t,ge&&await U(me,e.handle)}catch(e){console.error(e.name,e.message),P(e.message)}});document.addEventListener("dragover",e=>{e.preventDefault()});document.addEventListener("dragenter",e=>{e.preventDefault(),T.classList.add("dropenter")});document.addEventListener("dragleave",e=>{e.preventDefault(),e.target===T&&T.classList.remove("dropenter")});document.addEventListener("drop",async e=>{e.preventDefault(),e.stopPropagation(),T.classList.remove("dropenter");const t=e.dataTransfer.items[0];if(t.kind==="file"){let n;if(y.addEventListener("load",()=>{URL.revokeObjectURL(n)},{once:!0}),ge){const i=await t.getAsFileSystemHandle();if(i.kind!=="file")return;const s=await i.getFile();n=URL.createObjectURL(s),y.src=n,await U(me,i);return}const r=t.getAsFile();n=URL.createObjectURL(r),y.src=n}});ke.addEventListener("click",async()=>{const e=async()=>{P(m.t("optimizingSVG"),1/0);const t=await Ae(w.innerHTML);return Tr(),new Blob([t],{type:"image/svg+xml"})};try{let t=!1;try{t=await re(me)}catch{}const n=rr(t);await Hn(e(),{fileName:n,description:"SVG file",extensions:[".svg"],mimeTypes:["image/svg+xml"]}),P(m.t("savedSVG"))}catch(t){console.error(t.name,t.message),P(t.message)}});Pe.addEventListener("click",async()=>{try{const e=await navigator.clipboard.read();for(const t of e)for(const n of t.types)if(n.startsWith("image/")){const r=await t.getType(n);if(!r)return;const i=URL.createObjectURL(r);y.src=i;return}}catch(e){console.error(e.name,e.message),P(e.message)}});document.addEventListener("paste",e=>{try{if(!e.clipboardData.files.length)return;const t=e.clipboardData.files[0];if(t.type.startsWith("image/")){const n=URL.createObjectURL(t);y.src=n;return}}catch(t){console.error(t.name,t.message),P(t.message)}});Se.addEventListener("click",async()=>{let e=w.innerHTML;P(m.t("optimizingSVG"),1/0);try{"ClipboardItem"in window?Mt?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"})})]):(e=await Ae(e),await navigator.clipboard.write([new ClipboardItem({"text/plain":new Promise(async t=>{t(new Blob([e],{type:"text/plain"}))}),"image/svg+xml":new Promise(async t=>{t(new Blob([e],{type:"image/svg+xml"}))})})])):await navigator.clipboard.writeText(await Ae(e))}catch{e=await Ae(e);const n=new Blob([e],{type:"text/plain"}),r=new Blob([e],{type:"image/svg+xml"});try{Number(navigator.userAgent.replace(/.*Chrome\/(\d+).*/,"$1"))<=88?await navigator.clipboard.write([new ClipboardItem({[n.type]:n})]):await navigator.clipboard.write([new ClipboardItem({[r.type]:r,[n.type]:n})])}catch{try{await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}catch(s){P(s.message);return}}}P(m.t("copiedSVG"))});class B{constructor(t){this.id=-1,this.nativePointer=t,this.pageX=t.pageX,this.pageY=t.pageY,this.clientX=t.clientX,this.clientY=t.clientY,self.Touch&&t instanceof Touch?this.id=t.identifier:le(t)&&(this.id=t.pointerId)}getCoalesced(){if("getCoalescedEvents"in this.nativePointer){const t=this.nativePointer.getCoalescedEvents().map(n=>new B(n));if(t.length>0)return t}return[this]}}const le=e=>"pointerId"in e,Fe=e=>"changedTouches"in e,bt=()=>{};class ir{constructor(t,{start:n=()=>!0,move:r=bt,end:i=bt,rawUpdates:s=!1,avoidPointerEvents:a=!1}={}){this._element=t,this.startPointers=[],this.currentPointers=[],this._excludeFromButtonsCheck=new Set,this._pointerStart=o=>{if(le(o)&&o.buttons===0)this._excludeFromButtonsCheck.add(o.pointerId);else if(!(o.buttons&1))return;const c=new B(o);this.currentPointers.some(l=>l.id===c.id)||this._triggerPointerStart(c,o)&&(le(o)?((o.target&&"setPointerCapture"in o.target?o.target:this._element).setPointerCapture(o.pointerId),this._element.addEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.addEventListener("pointerup",this._pointerEnd),this._element.addEventListener("pointercancel",this._pointerEnd)):(window.addEventListener("mousemove",this._move),window.addEventListener("mouseup",this._pointerEnd)))},this._touchStart=o=>{for(const c of Array.from(o.changedTouches))this._triggerPointerStart(new B(c),o)},this._move=o=>{if(!Fe(o)&&(!le(o)||!this._excludeFromButtonsCheck.has(o.pointerId))&&o.buttons===0){this._pointerEnd(o);return}const c=this.currentPointers.slice(),l=Fe(o)?Array.from(o.changedTouches).map(d=>new B(d)):[new B(o)],u=[];for(const d of l){const h=this.currentPointers.findIndex(g=>g.id===d.id);h!==-1&&(u.push(d),this.currentPointers[h]=d)}u.length!==0&&this._moveCallback(c,u,o)},this._triggerPointerEnd=(o,c)=>{if(!Fe(c)&&c.buttons&1)return!1;const l=this.currentPointers.findIndex(d=>d.id===o.id);if(l===-1)return!1;this.currentPointers.splice(l,1),this.startPointers.splice(l,1),this._excludeFromButtonsCheck.delete(o.id);const u=!(c.type==="mouseup"||c.type==="touchend"||c.type==="pointerup");return this._endCallback(o,c,u),!0},this._pointerEnd=o=>{if(this._triggerPointerEnd(new B(o),o))if(le(o)){if(this.currentPointers.length)return;this._element.removeEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.removeEventListener("pointerup",this._pointerEnd),this._element.removeEventListener("pointercancel",this._pointerEnd)}else window.removeEventListener("mousemove",this._move),window.removeEventListener("mouseup",this._pointerEnd)},this._touchEnd=o=>{for(const c of Array.from(o.changedTouches))this._triggerPointerEnd(new B(c),o)},this._startCallback=n,this._moveCallback=r,this._endCallback=i,this._rawUpdates=s&&"onpointerrawupdate"in window,self.PointerEvent&&!a?this._element.addEventListener("pointerdown",this._pointerStart):(this._element.addEventListener("mousedown",this._pointerStart),this._element.addEventListener("touchstart",this._touchStart),this._element.addEventListener("touchmove",this._move),this._element.addEventListener("touchend",this._touchEnd),this._element.addEventListener("touchcancel",this._touchEnd))}stop(){this._element.removeEventListener("pointerdown",this._pointerStart),this._element.removeEventListener("mousedown",this._pointerStart),this._element.removeEventListener("touchstart",this._touchStart),this._element.removeEventListener("touchmove",this._move),this._element.removeEventListener("touchend",this._touchEnd),this._element.removeEventListener("touchcancel",this._touchEnd),this._element.removeEventListener(this._rawUpdates?"pointerrawupdate":"pointermove",this._move),this._element.removeEventListener("pointerup",this._pointerEnd),this._element.removeEventListener("pointercancel",this._pointerEnd),window.removeEventListener("mousemove",this._move),window.removeEventListener("mouseup",this._pointerEnd)}_triggerPointerStart(t,n){return this._startCallback(t,n)?(this.currentPointers.push(t),this.startPointers.push(t),!0):!1}}function or(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(!e||typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",n==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var ar=`pinch-zoom { display: block; overflow: hidden; touch-action: none; @@ -37,5 +37,5 @@ pinch-zoom > * { transform-origin: 0 0; will-change: transform; } -`;or(ar);const be="min-scale";function _t(e,t){return t?Math.sqrt((t.clientX-e.clientX)**2+(t.clientY-e.clientY)**2):0}function Lt(e,t){return t?{clientX:(e.clientX+t.clientX)/2,clientY:(e.clientY+t.clientY)/2}:e}function Et(e,t){return typeof e=="number"?e:e.trimRight().endsWith("%")?t*parseFloat(e)/100:parseFloat(e)}let kt;function Bt(){return kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","svg"))}function Ge(){return Bt().createSVGMatrix()}function St(){return Bt().createSVGPoint()}const Ye=.01;class sr extends HTMLElement{constructor(){super(),this._transform=Ge(),new MutationObserver(()=>this._stageElChange()).observe(this,{childList:!0});const t=new ir(this,{start:(n,r)=>t.currentPointers.length===2||!this._positioningEl?!1:(r.preventDefault(),!0),move:n=>{this._onPointerMove(n,t.currentPointers)}});this.addEventListener("wheel",n=>this._onWheel(n))}static get observedAttributes(){return[be]}attributeChangedCallback(t,n,r){t===be&&this.scales.width?i+=s.width-c.x:l.x<0&&(i+=-l.x),c.y>s.height?a+=s.height-c.y:l.y<0&&(a+=-l.y),this._updateTransform(n,i,a,r)}_updateTransform(t,n,r,i){if(!(t1&&console.warn(" must not have more than one child."),this.setTransform({allowChangeEvent:!0}))}_onWheel(t){if(!this._positioningEl)return;t.preventDefault();const n=this._positioningEl.getBoundingClientRect();let{deltaY:r}=t;const{ctrlKey:i,deltaMode:a}=t;a===1&&(r*=15);const o=1-r/(i?100:300);this._applyChange({scaleDiff:o,originX:t.clientX-n.left,originY:t.clientY-n.top,allowChangeEvent:!0})}_onPointerMove(t,n){if(!this._positioningEl)return;const r=this._positioningEl.getBoundingClientRect(),i=Lt(t[0],t[1]),a=Lt(n[0],n[1]),s=i.clientX-r.left,o=i.clientY-r.top,c=_t(t[0],t[1]),l=_t(n[0],n[1]),d=c?l/c:1;this._applyChange({originX:s,originY:o,scaleDiff:d,panX:a.clientX-i.clientX,panY:a.clientY-i.clientY,allowChangeEvent:!0})}_applyChange(t={}){const{panX:n=0,panY:r=0,originX:i=0,originY:a=0,scaleDiff:s=1,allowChangeEvent:o=!1}=t,c=Ge().translate(n,r).translate(i,a).translate(this.x,this.y).scale(s).translate(-i,-a).scale(this.scale);this.setTransform({allowChangeEvent:o,scale:c.a,x:c.e,y:c.f})}}customElements.define("pinch-zoom",sr);const cr='',lr='',dr='',ur='',hr='',pr='',mr='',fr='',gr='',vr='',yr='',wr='',ct="monochromeSettings",lt="colorSettings",Me="color",$e="monochrome",D="%",Nt="deg",de="steps",xt="pixels",ot="",br="segments",j={brightness:"brightness",contrast:"contrast",grayscale:"grayscale",hueRotate:"hue-rotate",invert:"invert",opacity:"opacity",saturate:"saturate",sepia:"sepia"},S={red:"red",green:"green",blue:"blue",alpha:"alpha"},fe={scale:"scale",rotation:"rotation"},L={minPathLength:"minPathSegments",strokeWidth:"strokeWidth",turdsize:"turdsize",alphamax:"alphamax",turnpolicy:"turnpolicy",opticurve:"opticurve",opttolerance:"opttolerance"},Ut={[j.brightness]:{unit:D,initial:100,min:0,max:200},[j.contrast]:{unit:D,initial:100,min:0,max:200},[j.grayscale]:{unit:D,initial:0,min:0,max:100},[j.hueRotate]:{unit:Nt,initial:0,min:0,max:360},[j.invert]:{unit:D,initial:0,min:0,max:100},[j.opacity]:{unit:D,initial:100,min:0,max:100},[j.saturate]:{unit:D,initial:100,min:0,max:200},[j.sepia]:{unit:D,initial:0,min:0,max:100}},_r={[S.red]:{unit:de,initial:5,min:1,max:20},[S.green]:{unit:de,initial:5,min:1,max:20},[S.blue]:{unit:de,initial:5,min:1,max:20},[S.alpha]:{unit:de,initial:1,min:1,max:10}},Lr={[fe.scale]:{unit:D,initial:100,min:1,max:200},[fe.rotation]:{unit:Nt,initial:0,min:0,max:360}},Er={[L.turdsize]:{unit:xt,initial:2,min:0,max:50},[L.strokeWidth]:{unit:xt,initial:0,min:0,max:100},[L.minPathLength]:{unit:br,initial:0,min:0,max:30},[L.alphamax]:{unit:ot,initial:1,min:0,max:1.3334},[L.turnpolicy]:{unit:de,initial:4,min:0,max:6},[L.opttolerance]:{unit:ot,initial:.2,min:0,max:1}},kr=[{name:"svgOptions",icon:ur},{name:"colorChannels",icon:cr},{name:"imageSizeAndRotation",icon:lr},{name:"imagePreprocessing",icon:dr}],dt=[Object.entries(Er),Object.entries(_r),Object.entries(Lr),Object.entries(Ut)],v={},Ve={},I={},ie=(e,t)=>{const n=m.t(e);return` (${e?`${t}${n.length===1?n:` ${n}`}`:t})`},H=e=>{const t=document.createElement("span");return t.classList.add("icon"),t.innerHTML=e,t},Sr=(e,t)=>{const n=document.createElement("details");I[e]=n;const r=document.createElement("summary"),i=H(t);r.append(i);const a=document.createElement("span");return a.textContent=m.t(e),a.dataset.i18nKey=e,r.append(a),n.append(r),n},xr=["alphamax","turnpolicy","optimize-curves","opttolerance","minPathSegments"],Pr=async(e,t,n)=>{const{unit:r,min:i,max:a,initial:s}=t,o=document.createElement("div");o.classList.add("preprocess-input"),xr.includes(e)&&o.classList.add("advanced");const c=document.createElement("label"),l=document.createElement("span");l.textContent=m.t(e),l.dataset.i18nKey=e,c.append(l),c.htmlFor=e;const d=await De(),u=document.createElement("span");Ve[e]=u,u.textContent=ie(r,d[e]||s),u.dataset.dynamicI18nKey=r,u.dataset.dynamicValue=d[e]||s;const h=document.createElement("input");v[e]=h,h.id=e,h.type="range",h.class=e,r&&(h.dataset.unit=r),r===ot&&(h.step=.01),h.min=i,h.max=a,h.value=d[e]||s,h.addEventListener("input",()=>{u.textContent=ie(r,h.value),u.dataset.dynamicValue=h.value}),Object.keys(S).includes(e)?h.addEventListener("change",Te(async()=>{await Y(h),await A()},250)):Object.keys(L).includes(e)?h.addEventListener("change",Te(async()=>{await Y(h),await A()},250)):h.addEventListener("change",Te(async()=>{await Y(h),await A()},250));const f=document.createElement("button");f.type="button",f.textContent=m.t("reset"),f.dataset.i18nKey="reset",f.addEventListener("click",async()=>{h.value=s,u.textContent=ie(r,s),u.dataset.dynamicValue=s,h.dispatchEvent(new Event("change"))}),c.append(u),o.append(c);const E=document.createElement("div");o.append(E),E.append(h),E.append(f),n.append(o)},qt=()=>{const e=!R.checked;Object.keys(S).forEach(t=>{v[t].disabled=e})};R.addEventListener("change",async()=>{qt(),await Y(R),await A()});const ut=async()=>{const e=await De();R.checked=e[R.id]??R.defaultChecked,qt(),$.checked=e[$.id]??$.defaultChecked,O.checked=e[O.id]??O.defaultChecked,Wt(),G.checked=e[G.id]??G.defaultChecked,Gt(),dt.forEach(t=>{for(const[n,r]of t){const i=e[v[n].id]||r.initial;v[n].value=i,Ve[n].textContent=ie(r.unit,i)}})};_.addEventListener("change",async()=>{await U(_.id,_.checked),await U(C.id,C.checked),await ut(),await A()});C.addEventListener("change",async()=>{await U(_.id,_.checked),await U(C.id,C.checked),await ut(),await A()});$.addEventListener("change",async()=>{await Y($),await A()});const Wt=()=>{v.opttolerance.disabled=!O.checked};O.addEventListener("change",async()=>{Wt(),await Y(O),await A()});he.addEventListener("input",()=>{z.classList.toggle("debug",he.checked)});const Cr=async()=>{await m.getTranslations(),Ft();const e=getComputedStyle(T).getPropertyValue("--mobile-breakpoint"),t=window.matchMedia(`(max-width: ${e})`),n=()=>{if(t.matches){rt.open=!1;return}rt.open=!0};n(),t.addEventListener("change",n);try{_.checked=await re(_.id)??_.defaultChecked}catch{_.checked=_.defaultChecked}try{C.checked=await re(C.id)??C.defaultChecked}catch{C.checked=C.defaultChecked}_.checked&&w.classList.add(Me),C.checked&&w.classList.add($e);const r=[];dt.forEach(async(s,o)=>{const{name:c,icon:l}=kr[o],d=Sr(c,l);mt.append(d),o<2&&(d.open=!0),c==="colorChannels"?I.colorChannels.append(R.parentNode):c==="svgOptions"?(I.svgOptions.append(_.parentNode),I.svgOptions.append(C.parentNode)):c==="imageSizeAndRotation"&&I.imageSizeAndRotation.append($.parentNode);for(const[u,h]of s)r.push(Pr(u,h,d));Promise.all(r).then(async()=>{for(const[u]of s){if(u==="opttolerance"){const h=I.svgOptions.querySelector('[for="opttolerance"]').parentNode;I.svgOptions.insertBefore(O.parentNode,h)}if(c==="svgOptions"){const h=I.svgOptions.querySelector(".preprocess-input.advanced");I.svgOptions.insertBefore(G.parentNode,h)}}await ut()})}),mt.append(at.parentNode),y.addEventListener("load",async()=>{y.width=y.naturalWidth,y.height=y.naturalHeight;const s=await De();if(y.src!==new URL("/favicon.png",location.href).toString()||Object.keys(s).length>1)setTimeout(async()=>{It(),await A()},100);else{const o=await fetch(`/potraced-${_.checked?"color":"monochrome"}.svg`).then(c=>c.text());w.innerHTML=o}}),y.complete&&y.dispatchEvent(new Event("load")),Oe.hidden=!1,new URL(location).searchParams.has("debug")&&(he.checked=!0,he.labels[0].hidden=!1,he.dispatchEvent(new Event("input")));try{const s=await re(me);if(s&&await Or(s)){const o=await s.getFile(),c=URL.createObjectURL(o);y.src=c}}catch(s){console.error(s.name,s.message);try{await nr(me)}catch(o){console.error(o.name,o.message)}}},Or=async e=>{const t={mode:"read"};return await e.queryPermission(t)==="granted"||await e.requestPermission(t)==="granted"},Ft=()=>{ln.textContent=m.t("license"),dn.textContent=m.t("about"),at.textContent=m.t("resetAll"),nn.textContent=m.t("posterizeInputImage"),rn.textContent=m.t("colorSVG"),on.textContent=m.t("monochromeSVG"),an.textContent=m.t("considerDPR"),sn.textContent=m.t("opticurve"),cn.textContent=m.t("showAdvancedControls"),Ee.innerHTML="",Ee.append(H(hr));const e=document.createElement("span");e.textContent=m.t("openImage"),Ee.append(e),ke.innerHTML="",ke.append(H(pr));const t=document.createElement("span");t.textContent=m.t("saveSVG"),ke.append(t),xe.innerHTML="",xe.append(H(Mt?gr:vr));const n=document.createElement("span");n.textContent=m.t("shareSVG"),xe.append(n),Se.innerHTML="",Se.append(H(mr));const r=document.createElement("span");r.textContent=m.t("copySVG"),Se.append(r),Pe.innerHTML="",Pe.append(H(fr));const i=document.createElement("span");i.textContent=m.t("pasteImage"),Pe.append(i),Ce.innerHTML="",Ce.append(H(wr));const a=document.createElement("span");a.textContent=m.t("install"),Ce.append(a),T.dataset.dropText=m.t("dropFileHere"),Ne.innerHTML="",Ne.append(H(yr)),Ne.append(document.createTextNode(m.t("tweak"))),Rt.ariaLabel=m.t("closeOptions"),document.querySelectorAll("[data-i18n-key]").forEach(s=>{s.textContent=m.t(s.dataset.i18nKey)}),document.querySelectorAll("[data-dynamic-i18n-key]").forEach(s=>{s.textContent=ie(s.dataset.dynamicI18nKey,s.dataset.dynamicValue)}),Ie.innerHTML="",m.supportedLocales.sort().forEach(s=>{const[o,c]=s.split("-"),l=document.createElement("option");l.value=s,l.textContent=m.t(`${o}${c}`),o===m.currentLanguageAndLocale.language&&c===m.currentLanguageAndLocale.locale&&(l.selected=!0),Ie.append(l)})};Ie.addEventListener("change",async()=>{const[e,t]=Ie.value.split("-");try{await m.setLanguageAndLocale(e,t),Ft()}catch(n){console.error(n.name,n.message)}});at.addEventListener("click",async()=>{const e=(t,n,r)=>{v[t].value=r,Ve[t].textContent=ie(n,r),Ve[t].dataset.dynamicValue=r};dt.forEach(t=>{for(const[n,r]of t)e(n,r.unit,r.initial)}),O.checked=O.defaultChecked,opttolerance.disabled=!O.defaultChecked,R.checked=R.defaultChecked,$.checked=$.defaultChecked,await Rr(),It(),await A()});let Xe=null;const P=(e,t=5e3)=>{if(Q.innerHTML=e,Q.hidden=!1,Xe&&clearTimeout(Xe),t!==1/0){Xe=setTimeout(()=>{Q.hidden=!0,Q.textContent=""},t);return}},Tr=()=>{Q.hidden=!0,Q.textContent=""},Gt=async()=>{await Y(G),document.querySelectorAll(".advanced").forEach(e=>{G.checked?e.style.display="block":e.style.display="none"})};G.addEventListener("change",Gt);T.style.setProperty("--100vh",`${window.innerHeight}px`);window.addEventListener("resize",Te(()=>{T.style.setProperty("--100vh",`${window.innerHeight}px`)},250));Rt.addEventListener("click",()=>{rt.open=!1});const Rr=async()=>{await U(_.checked?lt:ct,{})},De=async()=>{try{const e=_.checked?await re(lt):await re(ct);return e||{}}catch{return{}}},Y=async e=>{try{const t=await De();t[e.id]=e.type==="range"?e.value:e.checked,await U(_.checked?lt:ct,t)}catch{}};function Ar(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:s}=e;let o,c;const l=async(u=!0)=>{await c};async function d(){if("serviceWorker"in navigator){const{Workbox:u}=await p(()=>import("./workbox-window.prod.es5-a7b12eab.js"),[]);o=new u("/sw.js",{scope:"/",type:"classic"}),o.addEventListener("activated",h=>{(h.isUpdate||h.isExternal)&&window.location.reload()}),o.addEventListener("installed",h=>{h.isUpdate||r?.()}),o.register({immediate:t}).then(h=>{a?a("/sw.js",h):i?.(h)}).catch(h=>{s?.(h)})}}return c=d(),l}// @license © 2019 Google LLC. Licensed under the Apache License, Version 2.0. -const ue=document;let Z={};try{Z=localStorage}catch{}const je="prefers-color-scheme",_e="media",b="light",k="dark",Pt=`(${je}:${k})`,Ir=`(${je}:${b})`,Ct="link[rel=stylesheet]",Ke="remember",Je="legend",Le="toggle",Ot="switch",Ze="appearance",Qe="permanent",et="mode",ce="colorschemechange",tt="permanentcolorscheme",Tt="all",nt="not all",g="dark-mode-toggle",ne="https://googlechromelabs.github.io/dark-mode-toggle/demo/",J=(e,t,n=t)=>{Object.defineProperty(e,n,{enumerable:!0,get(){const r=this.getAttribute(t);return r===null?"":r},set(r){this.setAttribute(t,r)}})},Mr=(e,t,n=t)=>{Object.defineProperty(e,n,{enumerable:!0,get(){return this.hasAttribute(t)},set(r){r?this.setAttribute(t,""):this.removeAttribute(t)}})},Yt=ue.createElement("template");Yt.innerHTML=`
`;class $r extends HTMLElement{static get observedAttributes(){return[et,Ze,Qe,Je,b,k,Ke]}constructor(){super(),J(this,et),J(this,Ze),J(this,Je),J(this,b),J(this,k),J(this,Ke),Mr(this,Qe),this.t=null,this.i=null,ue.addEventListener(ce,t=>{this.mode=t.detail.colorScheme,this.o(),this.l()}),ue.addEventListener(tt,t=>{this.permanent=t.detail.permanent,this.h.checked=this.permanent}),this.p()}p(){const t=this.attachShadow({mode:"open"});t.append(Yt.content.cloneNode(!0)),this.t=ue.querySelectorAll(`${Ct}[${_e}*=${je}][${_e}*="${k}"]`),this.i=ue.querySelectorAll(`${Ct}[${_e}*=${je}][${_e}*="${b}"]`),this.g=t.querySelector("[part=lightRadio]"),this.m=t.querySelector("[part=lightLabel]"),this.u=t.querySelector("[part=darkRadio]"),this.k=t.querySelector("[part=darkLabel]"),this.v=t.querySelector("[part=toggleCheckbox]"),this.$=t.querySelector("[part=toggleLabel]"),this.L=t.querySelector("legend"),this.C=t.querySelector("aside"),this.h=t.querySelector("[part=permanentCheckbox]"),this.M=t.querySelector("[part=permanentLabel]")}connectedCallback(){const t=matchMedia(Pt).media!==nt;t&&matchMedia(Pt).addListener(({matches:r})=>{this.permanent||(this.mode=r?k:b,this.R(ce,{colorScheme:this.mode}))});let n=!1;try{n=Z.getItem(g)}catch{}if(n&&[k,b].includes(n)?(this.mode=n,this.h.checked=!0,this.permanent=!0):t&&(this.mode=matchMedia(Ir).matches?b:k),this.mode||(this.mode=b),this.permanent&&!n)try{Z.setItem(g,this.mode)}catch{}this.appearance||(this.appearance=Le),this._(),this.o(),this.l(),[this.g,this.u].forEach(r=>{r.addEventListener("change",()=>{this.mode=this.g.checked?b:k,this.l(),this.R(ce,{colorScheme:this.mode})})}),this.v.addEventListener("change",()=>{this.mode=this.v.checked?k:b,this.o(),this.R(ce,{colorScheme:this.mode})}),this.h.addEventListener("change",()=>{this.permanent=this.h.checked,this.R(tt,{permanent:this.permanent})}),this.A(),this.R(ce,{colorScheme:this.mode}),this.R(tt,{permanent:this.permanent})}attributeChangedCallback(t,n,r){if(t===et){if(![b,k].includes(r))throw new RangeError(`Allowed values: "${b}" and "${k}".`);if(matchMedia("(hover:none)").matches&&this.remember&&this.S(),this.permanent)try{Z.setItem(g,this.mode)}catch{}this.o(),this.l(),this.A()}else if(t===Ze){if(![Le,Ot].includes(r))throw new RangeError(`Allowed values: "${Le}" and "${Ot}".`);this._()}else if(t===Qe){if(this.permanent){if(this.mode)try{Z.setItem(g,this.mode)}catch{}}else try{Z.removeItem(g)}catch{}this.h.checked=this.permanent}else t===Je?this.L.textContent=r:t===Ke?this.M.textContent=r:t===b?(this.m.textContent=r,this.mode===b&&(this.$.textContent=r)):t===k&&(this.k.textContent=r,this.mode===k&&(this.$.textContent=r))}R(t,n){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:n}))}_(){const t=this.appearance===Le;this.g.hidden=t,this.m.hidden=t,this.u.hidden=t,this.k.hidden=t,this.v.hidden=!t,this.$.hidden=!t}o(){this.mode===b?this.g.checked=!0:this.u.checked=!0}l(){this.mode===b?(this.$.style.setProperty(`--${g}-checkbox-icon`,`var(--${g}-light-icon,url("${ne}moon.png"))`),this.$.textContent=this.light,this.light||(this.$.ariaLabel=k),this.v.checked=!1):(this.$.style.setProperty(`--${g}-checkbox-icon`,`var(--${g}-dark-icon,url("${ne}sun.png"))`),this.$.textContent=this.dark,this.dark||(this.$.ariaLabel=b),this.v.checked=!0)}A(){this.mode===b?(this.i.forEach(t=>{t.media=Tt,t.disabled=!1}),this.t.forEach(t=>{t.media=nt,t.disabled=!0})):(this.t.forEach(t=>{t.media=Tt,t.disabled=!1}),this.i.forEach(t=>{t.media=nt,t.disabled=!0}))}S(){this.C.style.visibility="visible",setTimeout(()=>{this.C.style.visibility="hidden"},3e3)}}customElements.define(g,$r);"launchQueue"in window&&p(()=>import("./filehandling-01abf381.js"),[]);"windowControlsOverlay"in navigator&&p(()=>import("./windowcontrols-23e4325e.js"),[]);"onbeforeinstallprompt"in window&&"onappinstalled"in window?p(()=>import("./install-2c7186a7.js"),[]):Ce.style.display="none";"share"in navigator&&"canShare"in navigator?p(()=>import("./share-4940c82e.js"),[]):xe.style.display="none";"serviceWorker"in navigator&&window.addEventListener("load",async()=>{try{await navigator.serviceWorker.register("./sharetargetsw.js",{scope:"/share-target/"})}catch(e){console.error(e.name,e.message),P(e.message)}if(location.search.includes("share-target")){const e=await caches.keys(),t=await caches.open(e.filter(r=>r.startsWith("media"))[0]),n=await t.match("shared-image");if(n){const r=await n.blob();await t.delete("shared-image");const i=URL.createObjectURL(r);y.addEventListener("load",()=>{URL.revokeObjectURL(i)},{once:!0}),y.src=i}}});const Vr=()=>{let e=!1;const t={get type(){e=!0}};try{new Worker("blob://",t)}finally{return e}},Xt=()=>{const e=At.mode;T.style.setProperty("--color-scheme",e),un.content=e==="dark"?"#131313":"#fff"};At.addEventListener("colorschemechange",Xt);Xt();(async()=>(Cr(),Vr()||await p(()=>import("./module-workers-polyfill.min-53ae82b3.js"),[]),Ar({onOfflineReady(){P(m.t("readyToWorkOffline"))},onNeedRefresh(){location.reload()}})()))();location.href==="https://svgco.de/"&&p(()=>import("./collect-3e738344.js"),[]);export{me as F,zr as a,Ce as b,xe as c,Te as d,w as e,P as f,m as g,Tr as h,y as i,re as j,rr as k,T as l,jr as m,Ae as o,U as s}; +`;or(ar);const be="min-scale";function _t(e,t){return t?Math.sqrt((t.clientX-e.clientX)**2+(t.clientY-e.clientY)**2):0}function Lt(e,t){return t?{clientX:(e.clientX+t.clientX)/2,clientY:(e.clientY+t.clientY)/2}:e}function Et(e,t){return typeof e=="number"?e:e.trimRight().endsWith("%")?t*parseFloat(e)/100:parseFloat(e)}let kt;function Bt(){return kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","svg"))}function Ge(){return Bt().createSVGMatrix()}function St(){return Bt().createSVGPoint()}const Ye=.01;class sr extends HTMLElement{constructor(){super(),this._transform=Ge(),new MutationObserver(()=>this._stageElChange()).observe(this,{childList:!0});const t=new ir(this,{start:(n,r)=>t.currentPointers.length===2||!this._positioningEl?!1:(r.preventDefault(),!0),move:n=>{this._onPointerMove(n,t.currentPointers)}});this.addEventListener("wheel",n=>this._onWheel(n))}static get observedAttributes(){return[be]}attributeChangedCallback(t,n,r){t===be&&this.scalea.width?i+=a.width-c.x:l.x<0&&(i+=-l.x),c.y>a.height?s+=a.height-c.y:l.y<0&&(s+=-l.y),this._updateTransform(n,i,s,r)}_updateTransform(t,n,r,i){if(!(t1&&console.warn(" must not have more than one child."),this.setTransform({allowChangeEvent:!0}))}_onWheel(t){if(!this._positioningEl)return;t.preventDefault();const n=this._positioningEl.getBoundingClientRect();let{deltaY:r}=t;const{ctrlKey:i,deltaMode:s}=t;s===1&&(r*=15);const o=1-r/(i?100:300);this._applyChange({scaleDiff:o,originX:t.clientX-n.left,originY:t.clientY-n.top,allowChangeEvent:!0})}_onPointerMove(t,n){if(!this._positioningEl)return;const r=this._positioningEl.getBoundingClientRect(),i=Lt(t[0],t[1]),s=Lt(n[0],n[1]),a=i.clientX-r.left,o=i.clientY-r.top,c=_t(t[0],t[1]),l=_t(n[0],n[1]),u=c?l/c:1;this._applyChange({originX:a,originY:o,scaleDiff:u,panX:s.clientX-i.clientX,panY:s.clientY-i.clientY,allowChangeEvent:!0})}_applyChange(t={}){const{panX:n=0,panY:r=0,originX:i=0,originY:s=0,scaleDiff:a=1,allowChangeEvent:o=!1}=t,c=Ge().translate(n,r).translate(i,s).translate(this.x,this.y).scale(a).translate(-i,-s).scale(this.scale);this.setTransform({allowChangeEvent:o,scale:c.a,x:c.e,y:c.f})}}customElements.define("pinch-zoom",sr);const cr='',lr='',dr='',ur='',hr='',pr='',mr='',fr='',gr='',vr='',yr='',wr='',ct="monochromeSettings",lt="colorSettings",Me="color",$e="monochrome",D="%",Nt="deg",de="steps",xt="pixels",ot="",br="segments",z={brightness:"brightness",contrast:"contrast",grayscale:"grayscale",hueRotate:"hue-rotate",invert:"invert",opacity:"opacity",saturate:"saturate",sepia:"sepia"},_={red:"red",green:"green",blue:"blue",alpha:"alpha"},fe={scale:"scale",rotation:"rotation"},E={minPathLength:"minPathSegments",strokeWidth:"strokeWidth",turdsize:"turdsize",alphamax:"alphamax",turnpolicy:"turnpolicy",opticurve:"opticurve",opttolerance:"opttolerance"},Ut={[z.brightness]:{unit:D,initial:100,min:0,max:200},[z.contrast]:{unit:D,initial:100,min:0,max:200},[z.grayscale]:{unit:D,initial:0,min:0,max:100},[z.hueRotate]:{unit:Nt,initial:0,min:0,max:360},[z.invert]:{unit:D,initial:0,min:0,max:100},[z.opacity]:{unit:D,initial:100,min:0,max:100},[z.saturate]:{unit:D,initial:100,min:0,max:200},[z.sepia]:{unit:D,initial:0,min:0,max:100}},_r={[_.red]:{unit:de,initial:5,min:1,max:20},[_.green]:{unit:de,initial:5,min:1,max:20},[_.blue]:{unit:de,initial:5,min:1,max:20},[_.alpha]:{unit:de,initial:1,min:1,max:10}},Lr={[fe.scale]:{unit:D,initial:100,min:1,max:200},[fe.rotation]:{unit:Nt,initial:0,min:0,max:360}},Er={[E.turdsize]:{unit:xt,initial:2,min:0,max:50},[E.strokeWidth]:{unit:xt,initial:0,min:0,max:100},[E.minPathLength]:{unit:br,initial:0,min:0,max:30},[E.alphamax]:{unit:ot,initial:1,min:0,max:1.3334},[E.turnpolicy]:{unit:de,initial:4,min:0,max:6},[E.opttolerance]:{unit:ot,initial:.2,min:0,max:1}},kr=[{name:"svgOptions",icon:ur},{name:"colorChannels",icon:cr},{name:"imageSizeAndRotation",icon:lr},{name:"imagePreprocessing",icon:dr}],dt=[Object.entries(Er),Object.entries(_r),Object.entries(Lr),Object.entries(Ut)],f={},Ve={},M={},ie=(e,t)=>{const n=m.t(e);return` (${e?`${t}${n.length===1?n:` ${n}`}`:t})`},H=e=>{const t=document.createElement("span");return t.classList.add("icon"),t.innerHTML=e,t},Sr=(e,t)=>{const n=document.createElement("details");M[e]=n;const r=document.createElement("summary"),i=H(t);r.append(i);const s=document.createElement("span");return s.textContent=m.t(e),s.dataset.i18nKey=e,r.append(s),n.append(r),n},xr=["alphamax","turnpolicy","optimize-curves","opttolerance","minPathSegments"],Pr=async(e,t,n)=>{const{unit:r,min:i,max:s,initial:a}=t,o=document.createElement("div");o.classList.add("preprocess-input"),xr.includes(e)&&o.classList.add("advanced");const c=document.createElement("label"),l=document.createElement("span");l.textContent=m.t(e),l.dataset.i18nKey=e,c.append(l),c.htmlFor=e;const u=await De(),d=document.createElement("span");Ve[e]=d,d.textContent=ie(r,u[e]||a),d.dataset.dynamicI18nKey=r,d.dataset.dynamicValue=u[e]||a;const h=document.createElement("input");f[e]=h,h.id=e,h.type="range",h.class=e,r&&(h.dataset.unit=r),r===ot&&(h.step=.01),h.min=i,h.max=s,h.value=u[e]||a,h.addEventListener("input",()=>{d.textContent=ie(r,h.value),d.dataset.dynamicValue=h.value}),Object.keys(_).includes(e)?h.addEventListener("change",Te(async()=>{await Y(h),await I()},250)):Object.keys(E).includes(e)?h.addEventListener("change",Te(async()=>{await Y(h),await I()},250)):h.addEventListener("change",Te(async()=>{await Y(h),await I()},250));const g=document.createElement("button");g.type="button",g.textContent=m.t("reset"),g.dataset.i18nKey="reset",g.addEventListener("click",async()=>{h.value=a,d.textContent=ie(r,a),d.dataset.dynamicValue=a,h.dispatchEvent(new Event("change"))}),c.append(d),o.append(c);const k=document.createElement("div");o.append(k),k.append(h),k.append(g),n.append(o)},qt=()=>{const e=!R.checked;Object.keys(_).forEach(t=>{f[t].disabled=e})};R.addEventListener("change",async()=>{qt(),await Y(R),await I()});const ut=async()=>{const e=await De();R.checked=e[R.id]??R.defaultChecked,qt(),V.checked=e[V.id]??V.defaultChecked,O.checked=e[O.id]??O.defaultChecked,Wt(),G.checked=e[G.id]??G.defaultChecked,Gt(),dt.forEach(t=>{for(const[n,r]of t){const i=e[f[n].id]||r.initial;f[n].value=i,Ve[n].textContent=ie(r.unit,i)}})};L.addEventListener("change",async()=>{await U(L.id,L.checked),await U(C.id,C.checked),await ut(),await I()});C.addEventListener("change",async()=>{await U(L.id,L.checked),await U(C.id,C.checked),await ut(),await I()});V.addEventListener("change",async()=>{await Y(V),await I()});const Wt=()=>{f.opttolerance.disabled=!O.checked};O.addEventListener("change",async()=>{Wt(),await Y(O),await I()});he.addEventListener("input",()=>{A.classList.toggle("debug",he.checked)});const Cr=async()=>{await m.getTranslations(),Ft();const e=getComputedStyle(T).getPropertyValue("--mobile-breakpoint"),t=window.matchMedia(`(max-width: ${e})`),n=()=>{if(t.matches){rt.open=!1;return}rt.open=!0};n(),t.addEventListener("change",n);try{L.checked=await re(L.id)??L.defaultChecked}catch{L.checked=L.defaultChecked}try{C.checked=await re(C.id)??C.defaultChecked}catch{C.checked=C.defaultChecked}L.checked&&w.classList.add(Me),C.checked&&w.classList.add($e);const r=[];dt.forEach(async(a,o)=>{const{name:c,icon:l}=kr[o],u=Sr(c,l);mt.append(u),o<2&&(u.open=!0),c==="colorChannels"?M.colorChannels.append(R.parentNode):c==="svgOptions"?(M.svgOptions.append(L.parentNode),M.svgOptions.append(C.parentNode)):c==="imageSizeAndRotation"&&M.imageSizeAndRotation.append(V.parentNode);for(const[d,h]of a)r.push(Pr(d,h,u));Promise.all(r).then(async()=>{for(const[d]of a){if(d==="opttolerance"){const h=M.svgOptions.querySelector('[for="opttolerance"]').parentNode;M.svgOptions.insertBefore(O.parentNode,h)}if(c==="svgOptions"){const h=M.svgOptions.querySelector(".preprocess-input.advanced");M.svgOptions.insertBefore(G.parentNode,h)}}await ut()})}),mt.append(at.parentNode),y.addEventListener("load",async()=>{y.width=y.naturalWidth,y.height=y.naturalHeight;const a=await De();if(y.src!==new URL("/favicon.png",location.href).toString()||Object.keys(a).length>1)setTimeout(async()=>{It(),await I()},100);else{const o=await fetch(`/potraced-${L.checked?"color":"monochrome"}.svg`).then(c=>c.text());w.innerHTML=o}}),y.complete&&y.dispatchEvent(new Event("load")),Oe.hidden=!1,new URL(location).searchParams.has("debug")&&(he.checked=!0,he.labels[0].hidden=!1,he.dispatchEvent(new Event("input")));try{const a=await re(me);if(a&&await Or(a)){const o=await a.getFile(),c=URL.createObjectURL(o);y.src=c}}catch(a){console.error(a.name,a.message);try{await nr(me)}catch(o){console.error(o.name,o.message)}}},Or=async e=>{const t={mode:"read"};return await e.queryPermission(t)==="granted"||await e.requestPermission(t)==="granted"},Ft=()=>{ln.textContent=m.t("license"),dn.textContent=m.t("about"),at.textContent=m.t("resetAll"),nn.textContent=m.t("posterizeInputImage"),rn.textContent=m.t("colorSVG"),on.textContent=m.t("monochromeSVG"),an.textContent=m.t("considerDPR"),sn.textContent=m.t("opticurve"),cn.textContent=m.t("showAdvancedControls"),Ee.innerHTML="",Ee.append(H(hr));const e=document.createElement("span");e.textContent=m.t("openImage"),Ee.append(e),ke.innerHTML="",ke.append(H(pr));const t=document.createElement("span");t.textContent=m.t("saveSVG"),ke.append(t),xe.innerHTML="",xe.append(H(Mt?gr:vr));const n=document.createElement("span");n.textContent=m.t("shareSVG"),xe.append(n),Se.innerHTML="",Se.append(H(mr));const r=document.createElement("span");r.textContent=m.t("copySVG"),Se.append(r),Pe.innerHTML="",Pe.append(H(fr));const i=document.createElement("span");i.textContent=m.t("pasteImage"),Pe.append(i),Ce.innerHTML="",Ce.append(H(wr));const s=document.createElement("span");s.textContent=m.t("install"),Ce.append(s),T.dataset.dropText=m.t("dropFileHere"),Ne.innerHTML="",Ne.append(H(yr)),Ne.append(document.createTextNode(m.t("tweak"))),Rt.ariaLabel=m.t("closeOptions"),document.querySelectorAll("[data-i18n-key]").forEach(a=>{a.textContent=m.t(a.dataset.i18nKey)}),document.querySelectorAll("[data-dynamic-i18n-key]").forEach(a=>{a.textContent=ie(a.dataset.dynamicI18nKey,a.dataset.dynamicValue)}),Ie.innerHTML="",m.supportedLocales.sort().forEach(a=>{const[o,c]=a.split("-"),l=document.createElement("option");l.value=a,l.textContent=m.t(`${o}${c}`),o===m.currentLanguageAndLocale.language&&c===m.currentLanguageAndLocale.locale&&(l.selected=!0),Ie.append(l)})};Ie.addEventListener("change",async()=>{const[e,t]=Ie.value.split("-");try{await m.setLanguageAndLocale(e,t),Ft()}catch(n){console.error(n.name,n.message)}});at.addEventListener("click",async()=>{const e=(t,n,r)=>{f[t].value=r,Ve[t].textContent=ie(n,r),Ve[t].dataset.dynamicValue=r};dt.forEach(t=>{for(const[n,r]of t)e(n,r.unit,r.initial)}),O.checked=O.defaultChecked,opttolerance.disabled=!O.defaultChecked,R.checked=R.defaultChecked,V.checked=V.defaultChecked,await Rr(),It(),await I()});let Xe=null;const P=(e,t=5e3)=>{if(Q.innerHTML=e,Q.hidden=!1,Xe&&clearTimeout(Xe),t!==1/0){Xe=setTimeout(()=>{Q.hidden=!0,Q.textContent=""},t);return}},Tr=()=>{Q.hidden=!0,Q.textContent=""},Gt=async()=>{await Y(G),document.querySelectorAll(".advanced").forEach(e=>{G.checked?e.style.display="block":e.style.display="none"})};G.addEventListener("change",Gt);T.style.setProperty("--100vh",`${window.innerHeight}px`);window.addEventListener("resize",Te(()=>{T.style.setProperty("--100vh",`${window.innerHeight}px`)},250));Rt.addEventListener("click",()=>{rt.open=!1});const Rr=async()=>{await U(L.checked?lt:ct,{})},De=async()=>{try{const e=L.checked?await re(lt):await re(ct);return e||{}}catch{return{}}},Y=async e=>{try{const t=await De();t[e.id]=e.type==="range"?e.value:e.checked,await U(L.checked?lt:ct,t)}catch{}};function Ar(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:s,onRegisterError:a}=e;let o,c;const l=async(d=!0)=>{await c};async function u(){if("serviceWorker"in navigator){const{Workbox:d}=await p(()=>import("./workbox-window.prod.es5-a7b12eab.js"),[]);o=new d("/sw.js",{scope:"/",type:"classic"}),o.addEventListener("activated",h=>{(h.isUpdate||h.isExternal)&&window.location.reload()}),o.addEventListener("installed",h=>{h.isUpdate||r?.()}),o.register({immediate:t}).then(h=>{s?s("/sw.js",h):i?.(h)}).catch(h=>{a?.(h)})}}return c=u(),l}// @license © 2019 Google LLC. Licensed under the Apache License, Version 2.0. +const ue=document;let Z={};try{Z=localStorage}catch{}const je="prefers-color-scheme",_e="media",b="light",S="dark",Pt=`(${je}:${S})`,Ir=`(${je}:${b})`,Ct="link[rel=stylesheet]",Ke="remember",Je="legend",Le="toggle",Ot="switch",Ze="appearance",Qe="permanent",et="mode",ce="colorschemechange",tt="permanentcolorscheme",Tt="all",nt="not all",v="dark-mode-toggle",ne="https://googlechromelabs.github.io/dark-mode-toggle/demo/",J=(e,t,n=t)=>{Object.defineProperty(e,n,{enumerable:!0,get(){const r=this.getAttribute(t);return r===null?"":r},set(r){this.setAttribute(t,r)}})},Mr=(e,t,n=t)=>{Object.defineProperty(e,n,{enumerable:!0,get(){return this.hasAttribute(t)},set(r){r?this.setAttribute(t,""):this.removeAttribute(t)}})},Yt=ue.createElement("template");Yt.innerHTML=`
`;class $r extends HTMLElement{static get observedAttributes(){return[et,Ze,Qe,Je,b,S,Ke]}constructor(){super(),J(this,et),J(this,Ze),J(this,Je),J(this,b),J(this,S),J(this,Ke),Mr(this,Qe),this.t=null,this.i=null,ue.addEventListener(ce,t=>{this.mode=t.detail.colorScheme,this.o(),this.l()}),ue.addEventListener(tt,t=>{this.permanent=t.detail.permanent,this.h.checked=this.permanent}),this.p()}p(){const t=this.attachShadow({mode:"open"});t.append(Yt.content.cloneNode(!0)),this.t=ue.querySelectorAll(`${Ct}[${_e}*=${je}][${_e}*="${S}"]`),this.i=ue.querySelectorAll(`${Ct}[${_e}*=${je}][${_e}*="${b}"]`),this.g=t.querySelector("[part=lightRadio]"),this.m=t.querySelector("[part=lightLabel]"),this.u=t.querySelector("[part=darkRadio]"),this.k=t.querySelector("[part=darkLabel]"),this.v=t.querySelector("[part=toggleCheckbox]"),this.$=t.querySelector("[part=toggleLabel]"),this.L=t.querySelector("legend"),this.C=t.querySelector("aside"),this.h=t.querySelector("[part=permanentCheckbox]"),this.M=t.querySelector("[part=permanentLabel]")}connectedCallback(){const t=matchMedia(Pt).media!==nt;t&&matchMedia(Pt).addListener(({matches:r})=>{this.permanent||(this.mode=r?S:b,this.R(ce,{colorScheme:this.mode}))});let n=!1;try{n=Z.getItem(v)}catch{}if(n&&[S,b].includes(n)?(this.mode=n,this.h.checked=!0,this.permanent=!0):t&&(this.mode=matchMedia(Ir).matches?b:S),this.mode||(this.mode=b),this.permanent&&!n)try{Z.setItem(v,this.mode)}catch{}this.appearance||(this.appearance=Le),this._(),this.o(),this.l(),[this.g,this.u].forEach(r=>{r.addEventListener("change",()=>{this.mode=this.g.checked?b:S,this.l(),this.R(ce,{colorScheme:this.mode})})}),this.v.addEventListener("change",()=>{this.mode=this.v.checked?S:b,this.o(),this.R(ce,{colorScheme:this.mode})}),this.h.addEventListener("change",()=>{this.permanent=this.h.checked,this.R(tt,{permanent:this.permanent})}),this.A(),this.R(ce,{colorScheme:this.mode}),this.R(tt,{permanent:this.permanent})}attributeChangedCallback(t,n,r){if(t===et){if(![b,S].includes(r))throw new RangeError(`Allowed values: "${b}" and "${S}".`);if(matchMedia("(hover:none)").matches&&this.remember&&this.S(),this.permanent)try{Z.setItem(v,this.mode)}catch{}this.o(),this.l(),this.A()}else if(t===Ze){if(![Le,Ot].includes(r))throw new RangeError(`Allowed values: "${Le}" and "${Ot}".`);this._()}else if(t===Qe){if(this.permanent){if(this.mode)try{Z.setItem(v,this.mode)}catch{}}else try{Z.removeItem(v)}catch{}this.h.checked=this.permanent}else t===Je?this.L.textContent=r:t===Ke?this.M.textContent=r:t===b?(this.m.textContent=r,this.mode===b&&(this.$.textContent=r)):t===S&&(this.k.textContent=r,this.mode===S&&(this.$.textContent=r))}R(t,n){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:n}))}_(){const t=this.appearance===Le;this.g.hidden=t,this.m.hidden=t,this.u.hidden=t,this.k.hidden=t,this.v.hidden=!t,this.$.hidden=!t}o(){this.mode===b?this.g.checked=!0:this.u.checked=!0}l(){this.mode===b?(this.$.style.setProperty(`--${v}-checkbox-icon`,`var(--${v}-light-icon,url("${ne}moon.png"))`),this.$.textContent=this.light,this.light||(this.$.ariaLabel=S),this.v.checked=!1):(this.$.style.setProperty(`--${v}-checkbox-icon`,`var(--${v}-dark-icon,url("${ne}sun.png"))`),this.$.textContent=this.dark,this.dark||(this.$.ariaLabel=b),this.v.checked=!0)}A(){this.mode===b?(this.i.forEach(t=>{t.media=Tt,t.disabled=!1}),this.t.forEach(t=>{t.media=nt,t.disabled=!0})):(this.t.forEach(t=>{t.media=Tt,t.disabled=!1}),this.i.forEach(t=>{t.media=nt,t.disabled=!0}))}S(){this.C.style.visibility="visible",setTimeout(()=>{this.C.style.visibility="hidden"},3e3)}}customElements.define(v,$r);"launchQueue"in window&&p(()=>import("./filehandling-e9a81a95.js"),[]);"windowControlsOverlay"in navigator&&p(()=>import("./windowcontrols-56fcfc9e.js"),[]);"onbeforeinstallprompt"in window&&"onappinstalled"in window?p(()=>import("./install-49bda3c1.js"),[]):Ce.style.display="none";"share"in navigator&&"canShare"in navigator?p(()=>import("./share-8dfeeb31.js"),[]):xe.style.display="none";"serviceWorker"in navigator&&window.addEventListener("load",async()=>{try{await navigator.serviceWorker.register("./sharetargetsw.js",{scope:"/share-target/"})}catch(e){console.error(e.name,e.message),P(e.message)}if(location.search.includes("share-target")){const e=await caches.keys(),t=await caches.open(e.filter(r=>r.startsWith("media"))[0]),n=await t.match("shared-image");if(n){const r=await n.blob();await t.delete("shared-image");const i=URL.createObjectURL(r);y.addEventListener("load",()=>{URL.revokeObjectURL(i)},{once:!0}),y.src=i}}});const Vr=()=>{let e=!1;const t={get type(){e=!0}};try{new Worker("blob://",t)}finally{return e}},Xt=()=>{const e=At.mode;T.style.setProperty("--color-scheme",e),un.content=e==="dark"?"#131313":"#fff"};At.addEventListener("colorschemechange",Xt);Xt();(async()=>(Cr(),Vr()||await p(()=>import("./module-workers-polyfill.min-53ae82b3.js"),[]),Ar({onOfflineReady(){P(m.t("readyToWorkOffline"))},onNeedRefresh(){location.reload()}})()))();location.href==="https://svgco.de/"&&p(()=>import("./collect-9cb57440.js"),[]);export{me as F,zr as a,Ce as b,xe as c,Te as d,w as e,P as f,m as g,Tr as h,y as i,re as j,rr as k,T as l,jr as m,Ae as o,U as s}; diff --git a/docs/assets/install-2c7186a7.js b/docs/assets/install-49bda3c1.js similarity index 82% rename from docs/assets/install-2c7186a7.js rename to docs/assets/install-49bda3c1.js index 3b34b2a..b93cef5 100644 --- a/docs/assets/install-2c7186a7.js +++ b/docs/assets/install-49bda3c1.js @@ -1 +1 @@ -import{b as l}from"./index-c3c47574.js";let e=null;window.addEventListener("beforeinstallprompt",t=>{t.preventDefault(),e=t,l.style.display="flex"});l.addEventListener("click",async()=>{if(!e)return;e.prompt(),(await e.userChoice).outcome==="accepted"&&(l.style.display="none",e=null)});window.addEventListener("appinstalled",t=>{l.style.display="none",e=null}); +import{b as l}from"./index-567ccd08.js";let e=null;window.addEventListener("beforeinstallprompt",t=>{t.preventDefault(),e=t,l.style.display="flex"});l.addEventListener("click",async()=>{if(!e)return;e.prompt(),(await e.userChoice).outcome==="accepted"&&(l.style.display="none",e=null)});window.addEventListener("appinstalled",t=>{l.style.display="none",e=null}); diff --git a/docs/assets/share-4940c82e.js b/docs/assets/share-8dfeeb31.js similarity index 86% rename from docs/assets/share-4940c82e.js rename to docs/assets/share-8dfeeb31.js index 02c07ef..9c4b16e 100644 --- a/docs/assets/share-4940c82e.js +++ b/docs/assets/share-8dfeeb31.js @@ -1 +1 @@ -import{c as r,e as l,f as i,g as o,o as g,h as c,j as m,F as f,k as d}from"./index-c3c47574.js";r.style.display="flex";r.addEventListener("click",async()=>{let a=l.innerHTML;i(o.t("optimizingSVG"),1/0),a=await g(a),c();let t=!1;try{t=await m(f)}catch{}const n=t?d(t):"Untitled.svg",s={files:[new File([a],n,{type:"image/svg+xml"})]};if(navigator.canShare(s))try{await navigator.share(s)}catch(e){e.name!=="AbortError"&&(console.error(e.name,e.message),i(e.message))}}); +import{c as r,e as l,f as i,g as o,o as g,h as c,j as m,F as f,k as d}from"./index-567ccd08.js";r.style.display="flex";r.addEventListener("click",async()=>{let a=l.innerHTML;i(o.t("optimizingSVG"),1/0),a=await g(a),c();let t=!1;try{t=await m(f)}catch{}const n=t?d(t):"Untitled.svg",s={files:[new File([a],n,{type:"image/svg+xml"})]};if(navigator.canShare(s))try{await navigator.share(s)}catch(e){e.name!=="AbortError"&&(console.error(e.name,e.message),i(e.message))}}); diff --git a/docs/assets/windowcontrols-23e4325e.js b/docs/assets/windowcontrols-56fcfc9e.js similarity index 79% rename from docs/assets/windowcontrols-23e4325e.js rename to docs/assets/windowcontrols-56fcfc9e.js index c9076f0..3469184 100644 --- a/docs/assets/windowcontrols-23e4325e.js +++ b/docs/assets/windowcontrols-56fcfc9e.js @@ -1 +1 @@ -import{d as a,m as e,a as s}from"./index-c3c47574.js";const o="window-controls-overlay",n=()=>{e.classList.toggle(o,navigator.windowControlsOverlay.visible),s.classList.toggle(o,navigator.windowControlsOverlay.visible)};navigator.windowControlsOverlay.addEventListener("geometrychange",a(async()=>{n()},250));n(); +import{d as a,m as e,a as s}from"./index-567ccd08.js";const o="window-controls-overlay",n=()=>{e.classList.toggle(o,navigator.windowControlsOverlay.visible),s.classList.toggle(o,navigator.windowControlsOverlay.visible)};navigator.windowControlsOverlay.addEventListener("geometrychange",a(async()=>{n()},250));n(); diff --git a/docs/index.html b/docs/index.html index 7b20850..4f5122b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -101,7 +101,7 @@ } - + diff --git a/docs/sw.js b/docs/sw.js index de948e2..db9027f 100644 --- a/docs/sw.js +++ b/docs/sw.js @@ -1 +1 @@ -if(!self.define){let s,e={};const l=(l,r)=>(l=new URL(l+".js",r).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s})));self.define=(r,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const o=s=>l(s,i),a={module:{uri:i},exports:u,require:o};e[i]=Promise.all(r.map((s=>a[s]||o(s)))).then((s=>(n(...s),u)))}}define(["./workbox-fa446783"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/ar-TN-917a8102.js",revision:null},{url:"assets/be-BY-e27002d9.js",revision:null},{url:"assets/ca-ES-450231bf.js",revision:null},{url:"assets/collect-3e738344.js",revision:null},{url:"assets/colorworker-9f272d25.js",revision:null},{url:"assets/da-DK-fecf3d76.js",revision:null},{url:"assets/de-DE-c44b440e.js",revision:null},{url:"assets/el-GR-cf1cb156.js",revision:null},{url:"assets/en-GB-1ebb0134.js",revision:null},{url:"assets/en-US-14af226a.js",revision:null},{url:"assets/es-ES-8cdc11e3.js",revision:null},{url:"assets/filehandling-01abf381.js",revision:null},{url:"assets/fr-FR-dff4346a.js",revision:null},{url:"assets/he-IL-3b82a749.js",revision:null},{url:"assets/id-ID-d5dc62f7.js",revision:null},{url:"assets/index-c3c47574.js",revision:null},{url:"assets/install-2c7186a7.js",revision:null},{url:"assets/it-IT-24240090.js",revision:null},{url:"assets/ja-JP-6b72f65f.js",revision:null},{url:"assets/ko-KR-9fdbc612.js",revision:null},{url:"assets/languages-e8d9835d.js",revision:null},{url:"assets/module-workers-polyfill.min-53ae82b3.js",revision:null},{url:"assets/monochromeworker-f4bfce91.js",revision:null},{url:"assets/nl-NL-f6a4c727.js",revision:null},{url:"assets/no-NO-cb14a155.js",revision:null},{url:"assets/pl-PL-9ac090e3.js",revision:null},{url:"assets/preprocessworker-83ff0da1.js",revision:null},{url:"assets/preprocessworker-b268b8a0.js",revision:null},{url:"assets/pt-BR-30fb79a1.js",revision:null},{url:"assets/ru-RU-e5f207da.js",revision:null},{url:"assets/share-4940c82e.js",revision:null},{url:"assets/style-02ad85c7.css",revision:null},{url:"assets/svgoworker-7ff1a964.js",revision:null},{url:"assets/uk-UA-87a01182.js",revision:null},{url:"assets/windowcontrols-23e4325e.js",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js",revision:null},{url:"assets/zh-CN-148f9e59.js",revision:null},{url:"index.html",revision:"f740f343f3df0417acd17c4a7865f956"},{url:"sharetargetsw.js",revision:"fe6035ce16732cd07fe629f4f0959ef6"},{url:"manifest.webmanifest",revision:"7a2ef1bd424eb0509a90f05dee6fc11d"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))})); +if(!self.define){let s,e={};const l=(l,r)=>(l=new URL(l+".js",r).href,e[l]||new Promise((e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()})).then((()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s})));self.define=(r,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const o=s=>l(s,i),a={module:{uri:i},exports:u,require:o};e[i]=Promise.all(r.map((s=>a[s]||o(s)))).then((s=>(n(...s),u)))}}define(["./workbox-fa446783"],(function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"assets/ar-TN-917a8102.js",revision:null},{url:"assets/be-BY-e27002d9.js",revision:null},{url:"assets/ca-ES-450231bf.js",revision:null},{url:"assets/collect-9cb57440.js",revision:null},{url:"assets/colorworker-9f272d25.js",revision:null},{url:"assets/da-DK-fecf3d76.js",revision:null},{url:"assets/de-DE-c44b440e.js",revision:null},{url:"assets/el-GR-cf1cb156.js",revision:null},{url:"assets/en-GB-1ebb0134.js",revision:null},{url:"assets/en-US-14af226a.js",revision:null},{url:"assets/es-ES-8cdc11e3.js",revision:null},{url:"assets/filehandling-e9a81a95.js",revision:null},{url:"assets/fr-FR-dff4346a.js",revision:null},{url:"assets/he-IL-3b82a749.js",revision:null},{url:"assets/id-ID-d5dc62f7.js",revision:null},{url:"assets/index-567ccd08.js",revision:null},{url:"assets/install-49bda3c1.js",revision:null},{url:"assets/it-IT-24240090.js",revision:null},{url:"assets/ja-JP-6b72f65f.js",revision:null},{url:"assets/ko-KR-9fdbc612.js",revision:null},{url:"assets/languages-e8d9835d.js",revision:null},{url:"assets/module-workers-polyfill.min-53ae82b3.js",revision:null},{url:"assets/monochromeworker-f4bfce91.js",revision:null},{url:"assets/nl-NL-f6a4c727.js",revision:null},{url:"assets/no-NO-cb14a155.js",revision:null},{url:"assets/pl-PL-9ac090e3.js",revision:null},{url:"assets/preprocessworker-83ff0da1.js",revision:null},{url:"assets/preprocessworker-b268b8a0.js",revision:null},{url:"assets/pt-BR-30fb79a1.js",revision:null},{url:"assets/ru-RU-e5f207da.js",revision:null},{url:"assets/share-8dfeeb31.js",revision:null},{url:"assets/style-02ad85c7.css",revision:null},{url:"assets/svgoworker-7ff1a964.js",revision:null},{url:"assets/uk-UA-87a01182.js",revision:null},{url:"assets/windowcontrols-56fcfc9e.js",revision:null},{url:"assets/workbox-window.prod.es5-a7b12eab.js",revision:null},{url:"assets/zh-CN-148f9e59.js",revision:null},{url:"index.html",revision:"058d89bd5dfd7c24f37112a6d3c427a5"},{url:"sharetargetsw.js",revision:"fe6035ce16732cd07fe629f4f0959ef6"},{url:"manifest.webmanifest",revision:"7a2ef1bd424eb0509a90f05dee6fc11d"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))})); diff --git a/src/js/preprocess.js b/src/js/preprocess.js index be34621..4282e10 100644 --- a/src/js/preprocess.js +++ b/src/js/preprocess.js @@ -127,16 +127,41 @@ if (supportsOffscreenCanvas) { canvasMain.width = width; canvasMain.height = height; ctxMain.clearRect(0, 0, width, height); - ctxMain.filter = getFilterString(); ctxMain.setTransform(1, 0, 0, 1, width / 2, height / 2); - const rotate = Number(filterInputs[SCALE_ROTATION.rotation].value); - ctxMain.rotate((rotate * Math.PI) / 180); ctxMain.drawImage( inputImage, (-factor * inputImage.naturalWidth * shrinkFactor) / 2, (-factor * inputImage.naturalHeight * shrinkFactor) / 2, ); - return ctxMain.getImageData(0, 0, width, height); + const rotate = Number(filterInputs[SCALE_ROTATION.rotation].value); + ctxMain.rotate((rotate * Math.PI) / 180); + ctxMain.filter = getFilterString(); + const imgData = ctxMain.getImageData( + 0, + 0, + canvasMain.width, + canvasMain.height, + ); + const redSteps = filterInputs[COLORS.red].value; + const greenSteps = filterInputs[COLORS.green].value; + const blueSteps = filterInputs[COLORS.blue].value; + const alphaSteps = filterInputs[COLORS.alpha].value + 1; + for (let i = 0; i < imgData.data.length; i += 4) { + imgData.data[i] = + Math.floor((imgData.data[i] / 255) * (redSteps - 1)) * + (255 / (redSteps - 1)); + imgData.data[i + 1] = + Math.floor((imgData.data[i + 1] / 255) * (greenSteps - 1)) * + (255 / (greenSteps - 1)); + imgData.data[i + 2] = + Math.floor((imgData.data[i + 2] / 255) * (blueSteps - 1)) * + (255 / (blueSteps - 1)); + imgData.data[i + 3] = + Math.floor((imgData.data[i + 3] / 255) * (alphaSteps - 1)) * + (255 / (alphaSteps - 1)); + } + ctxMain.putImageData(imgData, 0, 0); + return imgData; }; }