UNPKG

pencil.js

Version:

Nice modular interactive 2D drawing library.

2 lines 81.1 kB
/*! For license information please see pencil.min.js.LICENSE.txt */ (()=>{var t={96:t=>{"use strict";const e={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},s={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n};t.exports=function(t){let e=Number(s[32]),i=!1;for(let s=0;s<t.length;s++){let n=t.charCodeAt(s);n>127&&!i&&(n=(t=unescape(encodeURIComponent(t))).charCodeAt(s),i=!0),e^=n,e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24)}return e>>>0},t.exports.bigInt=function(t,{size:i=32}={}){if(!e[i])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");let n=s[i];const r=e[i];let o=!1;for(let e=0;e<t.length;e++){let s=t.charCodeAt(e);s>127&&!o&&(s=(t=unescape(encodeURIComponent(t))).charCodeAt(e),o=!0),n^=BigInt(s),n=BigInt.asUintN(i,n*r)}return n}},623:t=>{"use strict";function e(t,e,n){t instanceof RegExp&&(t=s(t,n)),e instanceof RegExp&&(e=s(e,n));var r=i(t,e,n);return r&&{start:r[0],end:r[1],pre:n.slice(0,r[0]),body:n.slice(r[0]+t.length,r[1]),post:n.slice(r[1]+e.length)}}function s(t,e){var s=e.match(t);return s?s[0]:null}function i(t,e,s){var i,n,r,o,a,h=s.indexOf(t),l=s.indexOf(e,h+1),c=h;if(h>=0&&l>0){if(t===e)return[h,l];for(i=[],r=s.length;c>=0&&!a;)c==h?(i.push(c),h=s.indexOf(t,c+1)):1==i.length?a=[i.pop(),l]:((n=i.pop())<r&&(r=n,o=l),l=s.indexOf(e,c+1)),c=h<l&&h>=0?h:l;i.length&&(a=[r,o])}return a}t.exports=e,e.range=i},644:(t,e,s)=>{var i=s(48),n=s(623);t.exports=function(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),w(function(t){return t.split("\\\\").join(r).split("\\{").join(o).split("\\}").join(a).split("\\,").join(h).split("\\.").join(l)}(t),!0).map(u)):[]};var r="\0SLASH"+Math.random()+"\0",o="\0OPEN"+Math.random()+"\0",a="\0CLOSE"+Math.random()+"\0",h="\0COMMA"+Math.random()+"\0",l="\0PERIOD"+Math.random()+"\0";function c(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function u(t){return t.split(r).join("\\").split(o).join("{").split(a).join("}").split(h).join(",").split(l).join(".")}function p(t){if(!t)return[""];var e=[],s=n("{","}",t);if(!s)return t.split(",");var i=s.pre,r=s.body,o=s.post,a=i.split(",");a[a.length-1]+="{"+r+"}";var h=p(o);return o.length&&(a[a.length-1]+=h.shift(),a.push.apply(a,h)),e.push.apply(e,a),e}function d(t){return"{"+t+"}"}function g(t){return/^-?0\d/.test(t)}function f(t,e){return t<=e}function m(t,e){return t>=e}function w(t,e){var s=[],r=n("{","}",t);if(!r||/\$$/.test(r.pre))return[t];var o,h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),u=h||l,v=r.body.indexOf(",")>=0;if(!u&&!v)return r.post.match(/,.*\}/)?w(t=r.pre+"{"+r.body+a+r.post):[t];if(u)o=r.body.split(/\.\./);else if(1===(o=p(r.body)).length&&1===(o=w(o[0],!1).map(d)).length)return(x=r.post.length?w(r.post,!1):[""]).map((function(t){return r.pre+o[0]+t}));var b,y=r.pre,x=r.post.length?w(r.post,!1):[""];if(u){var O=c(o[0]),k=c(o[1]),S=Math.max(o[0].length,o[1].length),M=3==o.length?Math.abs(c(o[2])):1,j=f;k<O&&(M*=-1,j=m);var z=o.some(g);b=[];for(var R=O;j(R,k);R+=M){var E;if(l)"\\"===(E=String.fromCharCode(R))&&(E="");else if(E=String(R),z){var C=S-E.length;if(C>0){var A=new Array(C+1).join("0");E=R<0?"-"+A+E.slice(1):A+E}}b.push(E)}}else b=i(o,(function(t){return w(t,!1)}));for(var P=0;P<b.length;P++)for(var T=0;T<x.length;T++){var L=y+b[P]+x[T];(!e||u||L)&&s.push(L)}return s}},168:(t,e,s)=>{var i=s(874),n={};for(var r in i)i.hasOwnProperty(r)&&(n[i[r]]=r);var o=t.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var a in o)if(o.hasOwnProperty(a)){if(!("channels"in o[a]))throw new Error("missing channels property: "+a);if(!("labels"in o[a]))throw new Error("missing channel labels property: "+a);if(o[a].labels.length!==o[a].channels)throw new Error("channel and label counts mismatch: "+a);var h=o[a].channels,l=o[a].labels;delete o[a].channels,delete o[a].labels,Object.defineProperty(o[a],"channels",{value:h}),Object.defineProperty(o[a],"labels",{value:l})}o.rgb.hsl=function(t){var e,s,i=t[0]/255,n=t[1]/255,r=t[2]/255,o=Math.min(i,n,r),a=Math.max(i,n,r),h=a-o;return a===o?e=0:i===a?e=(n-r)/h:n===a?e=2+(r-i)/h:r===a&&(e=4+(i-n)/h),(e=Math.min(60*e,360))<0&&(e+=360),s=(o+a)/2,[e,100*(a===o?0:s<=.5?h/(a+o):h/(2-a-o)),100*s]},o.rgb.hsv=function(t){var e,s,i,n,r,o=t[0]/255,a=t[1]/255,h=t[2]/255,l=Math.max(o,a,h),c=l-Math.min(o,a,h),u=function(t){return(l-t)/6/c+.5};return 0===c?n=r=0:(r=c/l,e=u(o),s=u(a),i=u(h),o===l?n=i-s:a===l?n=1/3+e-i:h===l&&(n=2/3+s-e),n<0?n+=1:n>1&&(n-=1)),[360*n,100*r,100*l]},o.rgb.hwb=function(t){var e=t[0],s=t[1],i=t[2];return[o.rgb.hsl(t)[0],1/255*Math.min(e,Math.min(s,i))*100,100*(i=1-1/255*Math.max(e,Math.max(s,i)))]},o.rgb.cmyk=function(t){var e,s=t[0]/255,i=t[1]/255,n=t[2]/255;return[100*((1-s-(e=Math.min(1-s,1-i,1-n)))/(1-e)||0),100*((1-i-e)/(1-e)||0),100*((1-n-e)/(1-e)||0),100*e]},o.rgb.keyword=function(t){var e=n[t];if(e)return e;var s,r,o,a=1/0;for(var h in i)if(i.hasOwnProperty(h)){var l=(r=t,o=i[h],Math.pow(r[0]-o[0],2)+Math.pow(r[1]-o[1],2)+Math.pow(r[2]-o[2],2));l<a&&(a=l,s=h)}return s},o.keyword.rgb=function(t){return i[t]},o.rgb.xyz=function(t){var e=t[0]/255,s=t[1]/255,i=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92)+.1805*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*s+.0722*i),100*(.0193*e+.1192*s+.9505*i)]},o.rgb.lab=function(t){var e=o.rgb.xyz(t),s=e[0],i=e[1],n=e[2];return i/=100,n/=108.883,s=(s/=95.047)>.008856?Math.pow(s,1/3):7.787*s+16/116,[116*(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116)-16,500*(s-i),200*(i-(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116))]},o.hsl.rgb=function(t){var e,s,i,n,r,o=t[0]/360,a=t[1]/100,h=t[2]/100;if(0===a)return[r=255*h,r,r];e=2*h-(s=h<.5?h*(1+a):h+a-h*a),n=[0,0,0];for(var l=0;l<3;l++)(i=o+1/3*-(l-1))<0&&i++,i>1&&i--,r=6*i<1?e+6*(s-e)*i:2*i<1?s:3*i<2?e+(s-e)*(2/3-i)*6:e,n[l]=255*r;return n},o.hsl.hsv=function(t){var e=t[0],s=t[1]/100,i=t[2]/100,n=s,r=Math.max(i,.01);return s*=(i*=2)<=1?i:2-i,n*=r<=1?r:2-r,[e,100*(0===i?2*n/(r+n):2*s/(i+s)),(i+s)/2*100]},o.hsv.rgb=function(t){var e=t[0]/60,s=t[1]/100,i=t[2]/100,n=Math.floor(e)%6,r=e-Math.floor(e),o=255*i*(1-s),a=255*i*(1-s*r),h=255*i*(1-s*(1-r));switch(i*=255,n){case 0:return[i,h,o];case 1:return[a,i,o];case 2:return[o,i,h];case 3:return[o,a,i];case 4:return[h,o,i];case 5:return[i,o,a]}},o.hsv.hsl=function(t){var e,s,i,n=t[0],r=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return i=(2-r)*o,s=r*a,[n,100*(s=(s/=(e=(2-r)*a)<=1?e:2-e)||0),100*(i/=2)]},o.hwb.rgb=function(t){var e,s,i,n,r,o,a,h=t[0]/360,l=t[1]/100,c=t[2]/100,u=l+c;switch(u>1&&(l/=u,c/=u),i=6*h-(e=Math.floor(6*h)),0!=(1&e)&&(i=1-i),n=l+i*((s=1-c)-l),e){default:case 6:case 0:r=s,o=n,a=l;break;case 1:r=n,o=s,a=l;break;case 2:r=l,o=s,a=n;break;case 3:r=l,o=n,a=s;break;case 4:r=n,o=l,a=s;break;case 5:r=s,o=l,a=n}return[255*r,255*o,255*a]},o.cmyk.rgb=function(t){var e=t[0]/100,s=t[1]/100,i=t[2]/100,n=t[3]/100;return[255*(1-Math.min(1,e*(1-n)+n)),255*(1-Math.min(1,s*(1-n)+n)),255*(1-Math.min(1,i*(1-n)+n))]},o.xyz.rgb=function(t){var e,s,i,n=t[0]/100,r=t[1]/100,o=t[2]/100;return s=-.9689*n+1.8758*r+.0415*o,i=.0557*n+-.204*r+1.057*o,e=(e=3.2406*n+-1.5372*r+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,[255*(e=Math.min(Math.max(0,e),1)),255*(s=Math.min(Math.max(0,s),1)),255*(i=Math.min(Math.max(0,i),1))]},o.xyz.lab=function(t){var e=t[0],s=t[1],i=t[2];return s/=100,i/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116)-16,500*(e-s),200*(s-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},o.lab.xyz=function(t){var e,s,i,n=t[0];e=t[1]/500+(s=(n+16)/116),i=s-t[2]/200;var r=Math.pow(s,3),o=Math.pow(e,3),a=Math.pow(i,3);return s=r>.008856?r:(s-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,i=a>.008856?a:(i-16/116)/7.787,[e*=95.047,s*=100,i*=108.883]},o.lab.lch=function(t){var e,s=t[0],i=t[1],n=t[2];return(e=360*Math.atan2(n,i)/2/Math.PI)<0&&(e+=360),[s,Math.sqrt(i*i+n*n),e]},o.lch.lab=function(t){var e,s=t[0],i=t[1];return e=t[2]/360*2*Math.PI,[s,i*Math.cos(e),i*Math.sin(e)]},o.rgb.ansi16=function(t){var e=t[0],s=t[1],i=t[2],n=1 in arguments?arguments[1]:o.rgb.hsv(t)[2];if(0===(n=Math.round(n/50)))return 30;var r=30+(Math.round(i/255)<<2|Math.round(s/255)<<1|Math.round(e/255));return 2===n&&(r+=60),r},o.hsv.ansi16=function(t){return o.rgb.ansi16(o.hsv.rgb(t),t[2])},o.rgb.ansi256=function(t){var e=t[0],s=t[1],i=t[2];return e===s&&s===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(s/255*5)+Math.round(i/255*5)},o.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var s=.5*(1+~~(t>50));return[(1&e)*s*255,(e>>1&1)*s*255,(e>>2&1)*s*255]},o.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var s;return t-=16,[Math.floor(t/36)/5*255,Math.floor((s=t%36)/6)/5*255,s%6/5*255]},o.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},o.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var s=e[0];3===e[0].length&&(s=s.split("").map((function(t){return t+t})).join(""));var i=parseInt(s,16);return[i>>16&255,i>>8&255,255&i]},o.rgb.hcg=function(t){var e,s=t[0]/255,i=t[1]/255,n=t[2]/255,r=Math.max(Math.max(s,i),n),o=Math.min(Math.min(s,i),n),a=r-o;return e=a<=0?0:r===s?(i-n)/a%6:r===i?2+(n-s)/a:4+(s-i)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},o.hsl.hcg=function(t){var e,s=t[1]/100,i=t[2]/100,n=0;return(e=i<.5?2*s*i:2*s*(1-i))<1&&(n=(i-.5*e)/(1-e)),[t[0],100*e,100*n]},o.hsv.hcg=function(t){var e=t[1]/100,s=t[2]/100,i=e*s,n=0;return i<1&&(n=(s-i)/(1-i)),[t[0],100*i,100*n]},o.hcg.rgb=function(t){var e=t[0]/360,s=t[1]/100,i=t[2]/100;if(0===s)return[255*i,255*i,255*i];var n,r=[0,0,0],o=e%1*6,a=o%1,h=1-a;switch(Math.floor(o)){case 0:r[0]=1,r[1]=a,r[2]=0;break;case 1:r[0]=h,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=a;break;case 3:r[0]=0,r[1]=h,r[2]=1;break;case 4:r[0]=a,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=h}return n=(1-s)*i,[255*(s*r[0]+n),255*(s*r[1]+n),255*(s*r[2]+n)]},o.hcg.hsv=function(t){var e=t[1]/100,s=e+t[2]/100*(1-e),i=0;return s>0&&(i=e/s),[t[0],100*i,100*s]},o.hcg.hsl=function(t){var e=t[1]/100,s=t[2]/100*(1-e)+.5*e,i=0;return s>0&&s<.5?i=e/(2*s):s>=.5&&s<1&&(i=e/(2*(1-s))),[t[0],100*i,100*s]},o.hcg.hwb=function(t){var e=t[1]/100,s=e+t[2]/100*(1-e);return[t[0],100*(s-e),100*(1-s)]},o.hwb.hcg=function(t){var e=t[1]/100,s=1-t[2]/100,i=s-e,n=0;return i<1&&(n=(s-i)/(1-i)),[t[0],100*i,100*n]},o.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},o.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},o.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},o.gray.hsl=o.gray.hsv=function(t){return[0,0,t[0]]},o.gray.hwb=function(t){return[0,100,t[0]]},o.gray.cmyk=function(t){return[0,0,0,t[0]]},o.gray.lab=function(t){return[t[0],0,0]},o.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),s=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(s.length)+s},o.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]}},85:(t,e,s)=>{var i=s(168),n=s(111),r={};Object.keys(i).forEach((function(t){r[t]={},Object.defineProperty(r[t],"channels",{value:i[t].channels}),Object.defineProperty(r[t],"labels",{value:i[t].labels});var e=n(t);Object.keys(e).forEach((function(s){var i=e[s];r[t][s]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var s=t(e);if("object"==typeof s)for(var i=s.length,n=0;n<i;n++)s[n]=Math.round(s[n]);return s};return"conversion"in t&&(e.conversion=t.conversion),e}(i),r[t][s].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(i)}))})),t.exports=r},111:(t,e,s)=>{var i=s(168);function n(t,e){return function(s){return e(t(s))}}function r(t,e){for(var s=[e[t].parent,t],r=i[e[t].parent][t],o=e[t].parent;e[o].parent;)s.unshift(e[o].parent),r=n(i[e[o].parent][o],r),o=e[o].parent;return r.conversion=s,r}t.exports=function(t){for(var e=function(t){var e=function(){for(var t={},e=Object.keys(i),s=e.length,n=0;n<s;n++)t[e[n]]={distance:-1,parent:null};return t}(),s=[t];for(e[t].distance=0;s.length;)for(var n=s.pop(),r=Object.keys(i[n]),o=r.length,a=0;a<o;a++){var h=r[a],l=e[h];-1===l.distance&&(l.distance=e[n].distance+1,l.parent=n,s.unshift(h))}return e}(t),s={},n=Object.keys(e),o=n.length,a=0;a<o;a++){var h=n[a];null!==e[h].parent&&(s[h]=r(h,e))}return s}},874:t=>{"use strict";t.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},48:t=>{t.exports=function(t,s){for(var i=[],n=0;n<t.length;n++){var r=s(t[n],n);e(r)?i.push.apply(i,r):i.push(r)}return i};var e=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},171:(t,e,s)=>{t.exports=p,p.Minimatch=d;var i={sep:"/"};try{i=s(67)}catch(t){}var n=p.GLOBSTAR=d.GLOBSTAR={},r=s(644),o={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},a="[^/]",h="[^/]*?",l="().*{}+?[]^$\\!".split("").reduce((function(t,e){return t[e]=!0,t}),{}),c=/\/+/;function u(t,e){t=t||{},e=e||{};var s={};return Object.keys(e).forEach((function(t){s[t]=e[t]})),Object.keys(t).forEach((function(e){s[e]=t[e]})),s}function p(t,e,s){if("string"!=typeof e)throw new TypeError("glob pattern string required");return s||(s={}),!(!s.nocomment&&"#"===e.charAt(0))&&(""===e.trim()?""===t:new d(e,s).match(t))}function d(t,e){if(!(this instanceof d))return new d(t,e);if("string"!=typeof t)throw new TypeError("glob pattern string required");e||(e={}),t=t.trim(),"/"!==i.sep&&(t=t.split(i.sep).join("/")),this.options=e,this.set=[],this.pattern=t,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.make()}function g(t,e){if(e||(e=this instanceof d?this.options:{}),void 0===(t=void 0===t?this.pattern:t))throw new TypeError("undefined pattern");return e.nobrace||!t.match(/\{.*\}/)?[t]:r(t)}p.filter=function(t,e){return e=e||{},function(s,i,n){return p(s,t,e)}},p.defaults=function(t){if(!t||!Object.keys(t).length)return p;var e=p,s=function(s,i,n){return e.minimatch(s,i,u(t,n))};return s.Minimatch=function(s,i){return new e.Minimatch(s,u(t,i))},s},d.defaults=function(t){return t&&Object.keys(t).length?p.defaults(t).Minimatch:d},d.prototype.debug=function(){},d.prototype.make=function(){if(!this._made){var t=this.pattern,e=this.options;if(e.nocomment||"#"!==t.charAt(0))if(t){this.parseNegate();var s=this.globSet=this.braceExpand();e.debug&&(this.debug=console.error),this.debug(this.pattern,s),s=this.globParts=s.map((function(t){return t.split(c)})),this.debug(this.pattern,s),s=s.map((function(t,e,s){return t.map(this.parse,this)}),this),this.debug(this.pattern,s),s=s.filter((function(t){return-1===t.indexOf(!1)})),this.debug(this.pattern,s),this.set=s}else this.empty=!0;else this.comment=!0}},d.prototype.parseNegate=function(){var t=this.pattern,e=!1,s=0;if(!this.options.nonegate){for(var i=0,n=t.length;i<n&&"!"===t.charAt(i);i++)e=!e,s++;s&&(this.pattern=t.substr(s)),this.negate=e}},p.braceExpand=function(t,e){return g(t,e)},d.prototype.braceExpand=g,d.prototype.parse=function(t,e){if(t.length>65536)throw new TypeError("pattern is too long");var s=this.options;if(!s.noglobstar&&"**"===t)return n;if(""===t)return"";var i,r="",c=!!s.nocase,u=!1,p=[],d=[],g=!1,m=-1,w=-1,v="."===t.charAt(0)?"":s.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",b=this;function y(){if(i){switch(i){case"*":r+=h,c=!0;break;case"?":r+=a,c=!0;break;default:r+="\\"+i}b.debug("clearStateChar %j %j",i,r),i=!1}}for(var x,O=0,k=t.length;O<k&&(x=t.charAt(O));O++)if(this.debug("%s\t%s %s %j",t,O,r,x),u&&l[x])r+="\\"+x,u=!1;else switch(x){case"/":return!1;case"\\":y(),u=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s\t%s %s %j <-- stateChar",t,O,r,x),g){this.debug(" in class"),"!"===x&&O===w+1&&(x="^"),r+=x;continue}b.debug("call clearStateChar %j",i),y(),i=x,s.noext&&y();continue;case"(":if(g){r+="(";continue}if(!i){r+="\\(";continue}p.push({type:i,start:O-1,reStart:r.length,open:o[i].open,close:o[i].close}),r+="!"===i?"(?:(?!(?:":"(?:",this.debug("plType %j %j",i,r),i=!1;continue;case")":if(g||!p.length){r+="\\)";continue}y(),c=!0;var S=p.pop();r+=S.close,"!"===S.type&&d.push(S),S.reEnd=r.length;continue;case"|":if(g||!p.length||u){r+="\\|",u=!1;continue}y(),r+="|";continue;case"[":if(y(),g){r+="\\"+x;continue}g=!0,w=O,m=r.length,r+=x;continue;case"]":if(O===w+1||!g){r+="\\"+x,u=!1;continue}if(g){var M=t.substring(w+1,O);try{RegExp("["+M+"]")}catch(t){var j=this.parse(M,f);r=r.substr(0,m)+"\\["+j[0]+"\\]",c=c||j[1],g=!1;continue}}c=!0,g=!1,r+=x;continue;default:y(),u?u=!1:!l[x]||"^"===x&&g||(r+="\\"),r+=x}for(g&&(M=t.substr(w+1),j=this.parse(M,f),r=r.substr(0,m)+"\\["+j[0],c=c||j[1]),S=p.pop();S;S=p.pop()){var z=r.slice(S.reStart+S.open.length);this.debug("setting tail",r,S),z=z.replace(/((?:\\{2}){0,64})(\\?)\|/g,(function(t,e,s){return s||(s="\\"),e+e+s+"|"})),this.debug("tail=%j\n %s",z,z,S,r);var R="*"===S.type?h:"?"===S.type?a:"\\"+S.type;c=!0,r=r.slice(0,S.reStart)+R+"\\("+z}y(),u&&(r+="\\\\");var E=!1;switch(r.charAt(0)){case".":case"[":case"(":E=!0}for(var C=d.length-1;C>-1;C--){var A=d[C],P=r.slice(0,A.reStart),T=r.slice(A.reStart,A.reEnd-8),L=r.slice(A.reEnd-8,A.reEnd),N=r.slice(A.reEnd);L+=N;var I=P.split("(").length-1,D=N;for(O=0;O<I;O++)D=D.replace(/\)[+*?]?/,"");var H="";""===(N=D)&&e!==f&&(H="$"),r=P+T+N+H+L}if(""!==r&&c&&(r="(?=.)"+r),E&&(r=v+r),e===f)return[r,c];if(!c)return t.replace(/\\(.)/g,"$1");var J=s.nocase?"i":"";try{var $=new RegExp("^"+r+"$",J)}catch(t){return new RegExp("$.")}return $._glob=t,$._src=r,$};var f={};p.makeRe=function(t,e){return new d(t,e||{}).makeRe()},d.prototype.makeRe=function(){if(this.regexp||!1===this.regexp)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1,this.regexp;var e=this.options,s=e.noglobstar?h:e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=e.nocase?"i":"",r=t.map((function(t){return t.map((function(t){return t===n?s:"string"==typeof t?t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):t._src})).join("\\/")})).join("|");r="^(?:"+r+")$",this.negate&&(r="^(?!"+r+").*$");try{this.regexp=new RegExp(r,i)}catch(t){this.regexp=!1}return this.regexp},p.match=function(t,e,s){var i=new d(e,s=s||{});return t=t.filter((function(t){return i.match(t)})),i.options.nonull&&!t.length&&t.push(e),t},d.prototype.match=function(t,e){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;var s=this.options;"/"!==i.sep&&(t=t.split(i.sep).join("/")),t=t.split(c),this.debug(this.pattern,"split",t);var n,r,o=this.set;for(this.debug(this.pattern,"set",o),r=t.length-1;r>=0&&!(n=t[r]);r--);for(r=0;r<o.length;r++){var a=o[r],h=t;if(s.matchBase&&1===a.length&&(h=[n]),this.matchOne(h,a,e))return!!s.flipNegate||!this.negate}return!s.flipNegate&&this.negate},d.prototype.matchOne=function(t,e,s){var i=this.options;this.debug("matchOne",{this:this,file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var r=0,o=0,a=t.length,h=e.length;r<a&&o<h;r++,o++){this.debug("matchOne loop");var l,c=e[o],u=t[r];if(this.debug(e,c,u),!1===c)return!1;if(c===n){this.debug("GLOBSTAR",[e,c,u]);var p=r,d=o+1;if(d===h){for(this.debug("** at the end");r<a;r++)if("."===t[r]||".."===t[r]||!i.dot&&"."===t[r].charAt(0))return!1;return!0}for(;p<a;){var g=t[p];if(this.debug("\nglobstar while",t,p,e,d,g),this.matchOne(t.slice(p),e.slice(d),s))return this.debug("globstar found match!",p,a,g),!0;if("."===g||".."===g||!i.dot&&"."===g.charAt(0)){this.debug("dot detected!",t,p,e,d);break}this.debug("globstar swallow a segment, and continue"),p++}return!(!s||(this.debug("\n>>> no match, partial?",t,p,e,d),p!==a))}if("string"==typeof c?(l=i.nocase?u.toLowerCase()===c.toLowerCase():u===c,this.debug("string match",c,u,l)):(l=u.match(c),this.debug("pattern match",c,u,l)),!l)return!1}if(r===a&&o===h)return!0;if(r===a)return s;if(o===h)return r===a-1&&""===t[r];throw new Error("wtf?")}},337:(t,e,s)=>{"use strict";s.d(e,{default:()=>Jt});var i={};s.r(i),s.d(i,{average:()=>f,constrain:()=>r,degreeCircle:()=>c,distribute:()=>d,equals:()=>o,lerp:()=>w,map:()=>m,modulo:()=>p,phi:()=>u,radianCircle:()=>l,random:()=>a,sum:()=>g,truncate:()=>h});var n={};s.r(n),s.d(n,{displayScene:()=>J,getCurrentScene:()=>H,prepareScenes:()=>$});const r=(t,e,s)=>Math.min(Math.max(t,e),s),o=(t,e,s=Number.EPSILON)=>Math.abs(t-e)<s,a=(t=1,e)=>{let s=t,i=e;return void 0===e&&(s=0,i=t),Math.random()*(i-s)+s},h=t=>t<<0,l=2*Math.PI,c=360,u=(Math.sqrt(5)+1)/2,p=(t,e)=>{const s=t%e;return t&&Math.sign(t)!==Math.sign(e)?s+e:s},d=(t,e=0,s=1)=>{const i=a(e,s),n=s-e;return[...new Array(t)].map(((t,s)=>e+p(i+s*u*n,n)))},g=(...t)=>t.reduce(((t,e)=>t+e),0),f=(...t)=>g(...t)/t.length,m=(t,e,s,i=0,n=1)=>(t-e)/(s-e)*(n-i)+i,w=(t,e,s)=>t+(e-t)*s;class v{constructor(t=0,e=0){this.x=+t,this.y=+e}set(t,e){let s,i;if("number"==typeof t)s=t,i=void 0===e?t:e;else{const e=v.from(t);({x:s,y:i}=e)}return this.x=s,this.y=i,this}clone(){return new v(this.x,this.y)}equals(t){const e=v.from(t);return o(this.x,e.x)&&o(this.y,e.y)}calc(t,e,s){let i=0,n=0;if("number"==typeof e)i=t(this.x,e),n=t(this.y,void 0===s?e:s);else{const s=v.from(e);i=t(this.x,s.x),n=t(this.y,s.y)}return this.set(i,n)}add(t,e){return this.calc(((t,e)=>t+e),t,e)}subtract(t,e){return this.calc(((t,e)=>t-e),t,e)}multiply(t,e){return this.calc(((t,e)=>t*e),t,e)}divide(t,e){return this.calc(((t,e)=>t/e),t,e)}modulo(t,e){return this.calc(((t,e)=>p(t,e)),t,e)}power(t,e){return this.calc(((t,e)=>t**e),t,e)}rotate(t=0,e){const{cos:s,sin:i}=Math,n=t*l,r=v.from(e),o=this.clone().subtract(r),a=o.x*s(n)-o.y*i(n),h=o.y*s(n)+o.x*i(n);return this.set(a,h).add(r)}constrain(t,e){const s=v.from(t),i=v.from(e),n=r(this.x,Math.min(s.x,i.x),Math.max(s.x,i.x)),o=r(this.y,Math.min(s.y,i.y),Math.max(s.y,i.y));return this.set(n,o)}lerp(t,e){const s=v.from(t).clone().subtract(this).multiply(e);return this.add(s)}distance(t){const e=v.from(t);return Math.hypot(e.x-this.x,e.y-this.y)}dotProduct(t){const e=v.from(t);return this.x*e.x+this.y*e.y}crossProduct(t){const e=v.from(t);return this.x*e.y-this.y*e.x}isOnSameSide(t,e){const s=v.from(t),i=this.clone().subtract(e.start),n=s.clone().subtract(e.start),r=e.getDelta(),{sign:o}=Math;return o(i.crossProduct(r))===o(n.crossProduct(r))}get length(){return this.distance()}get angle(){return 0===this.x&&0===this.y?0:Math.atan(this.y/this.x)/l+(this.x<0?.75:.25)}toJSON(){const{x:t,y:e}=this;return[t,e]}static from(t=new v){if(t instanceof v)return t;if(Array.isArray(t))return new v(...t);try{return new v(t.x,t.y)}catch{throw TypeError(`Unexpected type for position: ${JSON.stringify(t)}.`)}}static average(...t){let e=new v;t.forEach((t=>e=e.add(v.from(t))));const s=t.length;return e.divide(s)}}const b=(...t)=>t.slice(1).every((e=>e===t[0]));function y(t){return"number"==typeof t||t instanceof v?t:"function"==typeof t.getDelta?t.getDelta():"number"==typeof t[0]&&"number"==typeof t[1]?v.from(t):x.from(t).getDelta()}class x{constructor(t,e){this.start=v.from(t),this.end=v.from(e)}get width(){return Math.abs(this.start.x-this.end.x)}get height(){return Math.abs(this.start.y-this.end.y)}get length(){return this.start.distance(this.end)}clone(){return new x(this.start.clone(),this.end.clone())}equals(t){const e=x.from(t);return this.start.equals(e.start)&&this.end.equals(e.end)}getDelta(){return this.end.clone().subtract(this.start)}add(t){const e=y(t);return this.end.add(e),this}translate(t){const e=y(t);return this.start.add(e),this.end.add(e),this}multiply(t){if("number"==typeof t)return this.add(this.getDelta().multiply(t-1)),this;const e=y(t);return this.end.multiply(e),this}intersect(t){const e=x.from(t);if(!this.start.isOnSameSide(this.end,e)&&!e.start.isOnSameSide(e.end,this))return!0;const s=this.getDelta(),i=e.start.clone().subtract(this.start);return!(0!==s.crossProduct(i)||0!==s.crossProduct(e.getDelta())||b(this.start.x<e.start.x,this.start.x<e.end.x,this.end.x<e.start.x,this.end.x<e.end.x)&&b(this.start.y<e.start.y,this.start.y<e.end.y,this.end.y<e.start.y,this.end.y<e.end.y))}getIntersectionPoint(t){const e=x.from(t);if(!this.intersect(e))return null;const s=e.getDelta(),i=this.getDelta().crossProduct(s);if(0===i)return this.start.clone().constrain(e.start,e.end).lerp(this.end.clone().constrain(e.start,e.end),.5);const n=this.start.clone().subtract(e.start);return this.start.clone().lerp(this.end,s.crossProduct(n)/i)}getClosestToPoint(t){const e=v.from(t),s=new x(this.start,e).getDelta(),i=this.getDelta(),n=s.dotProduct(i)/this.length**2;return this.start.clone().add(i.multiply(n)).constrain(this.start,this.end)}toJSON(){const{start:t,end:e}=this;return[t,e]}static from(t=new x){if(t instanceof x)return t;if(Array.isArray(t)&&2===t.length)return new x(...t);try{return new x(t.start,t.end)}catch{throw new TypeError(`Unexpected type for vector: ${JSON.stringify(t)}.`)}}}class O{constructor(){this.eventListeners={}}on(t,e,s=!1){const i={callback:e,element:this,isTargeted:s};return(Array.isArray(t)?t:[t]).forEach((t=>{const[e,s]=t.split(".");this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push({...i,modifier:s})})),this}fire(t){const e=this.eventListeners[t.name];return e&&e.forEach((e=>{if(!e.isTargeted||e.element===t.target){const s=t.getModifier&&t.getModifier();e.modifier&&e.modifier!==s||e.callback.call(this,t)}})),this}removeListener(t,e){return(Array.isArray(t)?t:[t]).forEach((t=>{const[s,i]=t.split(".");e||i?this.eventListeners[s]=this.eventListeners[s].filter((t=>e&&t.callback!==e||i&&t.modifier!==i)):delete this.eventListeners[s]})),this}removeAllListener(){return this.eventListeners={},this}static get events(){return{}}}class k{constructor(t,e,s){this.name=t,this.target=e,this.event=s,this.bubble=!0}stop(){return this.bubble=!1,this}getModifier(){return null}prevent(){return this.event.preventDefault(),this}}const S=Symbol("_scenePromise");class M extends O{constructor(t=new v,e){super(),this.position=v.from(t),this.options={},this.setOptions(e),this.children=[],this.parent=null,this.frameCount=0,this[S]=new Promise((t=>{this.on(M.events.attach,(()=>{const e=this.getRoot();e.isScene?t(e):e.getScene().then((e=>t(e)))}),!0)}))}setOptions(t={}){return this.options={...this.constructor.defaultOptions,...this.options,...t},this.options.rotationCenter=v.from(this.options.rotationCenter),"number"!=typeof this.options.scale&&(this.options.scale=v.from(this.options.scale)),this}isHover(){return!1}add(...t){return t.forEach((t=>{if(t===this)throw new RangeError("A container can't contain itself.");if(t.isScene)throw new RangeError("A scene can't be contained in another container.");t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.fire(new k(M.events.attach,t))})),this}remove(...t){return t.forEach((t=>{if(this.children.includes(t)){const e=this.children.splice(this.children.indexOf(t),1)[0];e.parent=null,e.fire(new k(M.events.detach,e))}})),this}empty(){return this.remove(...this.children)}delete(){return this.parent&&this.parent.remove(this),this}getScene(){return this[S]}getRoot(){return this.parent?this.parent.getRoot():this}getAbsolutePosition(){const t=new v;return this.climbAncestry((e=>{t.rotate(e.options.rotation,e.options.rotationCenter).add(e.position)})),t}fire(t){return super.fire(t),this.parent&&t.bubble&&this.parent.fire(t),this}getTarget(t,e){if(!this.options.shown)return null;e.save(),e.translate(this.position.x,this.position.y),this.setContext(e);let s=null,i=this.children.length-1;for(;!s&&i>=0;)s=this.children[i].getTarget(t,e),--i;let n=s;return(!s||s.options.zIndex<0&&s.parent===this)&&this.isHover(t,e)&&(n=this),e.restore(),n}setContext(t){if(this.options.clip){const e=new window.Path2D,{clip:s}=this.options,{x:i,y:n}=s.position;t.translate(i,n),s.trace&&s.trace(e),t.clip(e),t.translate(-i,-n)}if(this.options.rotation){const e=v.from(this.options.rotationCenter);t.translate(e.x,e.y),t.rotate(this.options.rotation*l),t.translate(-e.x,-e.y)}if("number"==typeof this.options.scale)1!==this.options.scale&&t.scale(this.options.scale,this.options.scale);else{const e=v.from(this.options.scale);1===e.x&&1===e.y||t.scale(e.x,e.y)}return this}render(t){if(!this.options.shown)return this;this.frameCount++,this.fire(new k(M.events.draw,this)),t.save(),t.translate(this.position.x,this.position.y),this.setContext(t),this.children.sort(((t,e)=>t.options.zIndex-e.options.zIndex)),M.setOpacity(t,this.options.opacity);const e=this.children.findIndex((t=>t.options.zIndex>=0)),s=-1===e?this.children.length:e;for(let e=0,i=s;e<i;++e)this.children[e].render(t);this.makePath(t);for(let e=s,i=this.children.length;e<i;++e)this.children[e].render(t);return t.restore(),this}makePath(){return this}show(){return this.options.shown=!0,this.fire(new k(M.events.show,this)),this}hide(){return this.options.shown=!1,this.fire(new k(M.events.hide,this)),this}isAncestorOf(t){return!(!t||!t.parent)&&(t.parent===this||this.isAncestorOf(t.parent))}climbAncestry(t,e){t(this),this.parent&&this.parent!==e&&this.parent.climbAncestry(t)}toJSON(){const{defaultOptions:t}=this.constructor,e={};Object.keys(this.options).forEach((s=>{const i=this.options[s];(i&&i.equals?i.equals(t[s]):Object.is(i,t[s]))||(e[s]=i)}));const s={constructor:this.constructor.name,position:this.position};return this.children.length&&(s.children=this.children.map((t=>t.toJSON()))),Object.keys(e).length&&(s.options=e),s}clone(){return this.constructor.from(this.toJSON())}static setOpacity(t,e){null!==e&&t.globalAlpha!==e&&(t.globalAlpha=e)}static from(t){return new M(t.position,t.options)}static get defaultOptions(){return{shown:!0,opacity:null,rotation:0,rotationCenter:new v,scale:1,zIndex:1,clip:null}}static get events(){return{...super.events,attach:"attach",detach:"detach",draw:"draw",hide:"hide",show:"show"}}}class j extends M{constructor(t=1,e=1,s){super(void 0,s),this.ctx=this.constructor.getDrawingContext(t,e)}setImageSmoothing(t){return this.ctx.imageSmoothingEnabled=t,this}clear(){if(this.ctx.clearRect(0,0,this.width,this.height),this.options.fill){j.setOpacity(this.ctx,this.options.opacity);const{width:t,height:e}=this;this.ctx.fillStyle=this.options.fill.toString(this.ctx),this.ctx.fillRect(0,0,t,e)}return this}render(){return this.clear(),super.render(this.ctx),this}get width(){return this.ctx.canvas.width}set width(t){this.ctx.canvas.width=+t}get height(){return this.ctx.canvas.height}set height(t){this.ctx.canvas.height=+t}get size(){return new v(this.width,this.height)}get center(){return this.size.divide(2)}getRandomPosition(){return new v(a(this.width),a(this.height))}getImageData(t){let e;return e=t?x.from(t):new x(void 0,this.size),this.render(),this.ctx.getImageData(e.start.x,e.start.y,e.end.x,e.end.y)}setImageData(t,e){const s=v.from(e);this.ctx.putImageData(t,s.x,s.y)}toImage(t,e="image/png"){let s;s=t?x.from(t):new x(void 0,[this.width,this.height]);const i=window.document.createElement("img"),{width:n,height:r}=this,o=s.getDelta();return this.width=o.x,this.height=o.y,i.width=this.width,i.height=this.height,this.ctx.translate(-s.start.x,-s.start.y),this.render(),i.src=this.ctx.canvas.toDataURL(e),this.width=n,this.height=r,i}static getDrawingContext(t=1,e=1){const s=window.document.createElement("canvas");return s.width=t,s.height=e,s.getContext("2d")}static get defaultOptions(){return{...super.defaultOptions,fill:null,opacity:1}}}var z=s(85),R=s.n(z);function E(t,e){return(t>>8*e&255)/255}function C(t){return h(255*t+.5)}class A{constructor(...t){this.red=0,this.green=0,this.blue=0,this.alpha=1,this.set(...t)}clone(){return new A(this)}get array(){return[this.red,this.green,this.blue]}get rgb(){return`#${this.array.map((t=>C(t).toString(16).padStart(2,"0"))).join("")}`}get rgba(){return`rgba(${this.array.map((t=>C(t))).concat(this.alpha).join(",")})`}get name(){return R().rgb.keyword(this.array.map((t=>C(t))))}set(...t){if(t.length>0&&t.length<3){const e=t[0];if(e instanceof A)this.red=e.red,this.green=e.green,this.blue=e.blue,this.alpha=e.alpha;else{let s=e;if("string"==typeof e)if(e.startsWith("#")){const t=e.substr(1),i=t.length<4?t.split("").map((t=>t.repeat(2))).join(""):t;s=Number.parseInt(i,16)}else{const t=R().keyword.rgb(e.toLocaleLowerCase())||[0,0,0];this.red=t[0]/255,this.green=t[1]/255,this.blue=t[2]/255}"number"==typeof s&&(this.red=E(s,2),this.green=E(s,1),this.blue=E(s,0));const i=t[1];void 0!==i&&(this.alpha=r(i,0,1))}}else if(t.length>2){this.red=r(t[0],0,1),this.green=r(t[1],0,1),this.blue=r(t[2],0,1);const e=t[3];void 0!==e&&(this.alpha=r(e,0,1))}return this}grey(){const t=[.299,.587,.114],e=f(...this.array.map(((e,s)=>e*t[s])));return this.set(e,e,e)}hue(t){const e=R().rgb.hsl(this.array.map((t=>C(t))));return e[0]=t%1*360,this.set(...R().hsl.rgb(e).map((t=>t/255)))}saturation(t){const{array:e}=this,s=f(Math.min(...e),Math.max(...e));return this.set(...e.map((e=>s+t*(e-s))))}lightness(t){const e=t<.5?e=>e*t:e=>e+(1-e)*(t-.5)*2;return this.set(...this.array.map(e))}reverse(){return this.set(...this.array.map((t=>1-t)))}level(t){return this.set(...this.array.map((e=>h(e*t+1)/(t+1))))}lerp(t,e){const s=A.from(t),i=this.array.concat(this.alpha),n=s.array.concat(s.alpha);return this.set(...i.map(((t,s)=>w(t,n[s],e))))}toString(){return o(this.alpha,1)?this.rgb:this.rgba}toJSON(){return this.array.concat(this.alpha)}static from(...t){const e=t[0];return e instanceof A||null===e?e:new A(...t)}}class P extends M{constructor(t,e={}){super(t,e),this.path=null,this.isClicked=!1,this.isHovered=!1}getOrigin(){return v.from(this.options.origin)}setOptions(t={}){const{shadow:e}=this.options;return super.setOptions(t),"string"!=typeof this.options.origin&&(this.options.origin=v.from(this.options.origin)),this.options.shadow={...P.defaultOptions.shadow,...e,...t.shadow},this.options.shadow.position=v.from(this.options.shadow.position),this}get willFill(){return Boolean(this.options.fill)}get willStroke(){return Boolean(this.options.stroke)&&this.options.strokeWidth>0}setContext(t){if(super.setContext(t),this.options.shadow.color){const e=v.from(this.options.shadow.position);t.shadowColor=this.options.shadow.color.toString(),t.shadowBlur=this.options.shadow.blur,t.shadowOffsetX=e.x,t.shadowOffsetY=e.y}else t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;return this.willFill&&(t.fillStyle=this.options.fill.toString(t)),this.willStroke&&(t.lineJoin=this.options.join,t.lineCap=this.options.cap,t.strokeStyle=this.options.stroke.toString(t),t.lineWidth=this.options.strokeWidth),this}makePath(t){if(this.willFill||this.willStroke){const e=this.getOrigin();t.translate(e.x,e.y),this.path=new window.Path2D,this.trace(this.path),this.willFill&&t.fill(this.path),this.willStroke&&t.stroke(this.path),t.translate(-e.x,-e.y)}return this}trace(){throw new ReferenceError(`Unimplemented [trace] function in ${this.constructor.name}.`)}isHover(t,e=j.getDrawingContext()){if(!this.options.shown)return!1;e.save();const s=v.from(t),i=this.getOrigin();if(e.translate(i.x,i.y),!this.willFill&&!this.willStroke)return e.restore(),!1;this.path||(this.path=new window.Path2D,this.trace(this.path));let n=this.willFill&&e.isPointInPath(this.path,s.x,s.y)||this.willStroke&&e.isPointInStroke(this.path,s.x,s.y);return this.options.clip&&(n=n&&this.options.clip.isHover(s,e)),e.restore(),n}static get defaultOptions(){return{...super.defaultOptions,fill:"#000",stroke:null,strokeWidth:2,cursor:P.cursors.default,join:P.joins.miter,origin:new v,shadow:{blur:0,position:new v,color:null}}}static get cursors(){const t={default:"default",none:"none",contextMenu:"context-menu",help:"help",pointer:"pointer",progress:"progress",wait:"wait",cell:"cell",crosshair:"crosshair",text:"text",textVertical:"vertical-text",alias:"alias",copy:"copy",move:"move",noDrop:"no-drop",notAllowed:"not-allowed",grab:"grab",grabbing:"grabbing",allScroll:"all-scroll",colResize:"col-resize",rowResize:"row-resize",nResize:"n-resize",eResize:"e-resize",sResize:"s-resize",wResize:"w-resize",neResize:"ne-resize",seResize:"se-resize",swResize:"sw-resize",nwResize:"nw-resize",ewResize:"ew-resize",nsResize:"ns-resize",neswResize:"nesw-resize",nwseResize:"nwse-resize",zoomIn:"zoom-in",zoomOut:"zoom-out"};return t.link=t.alias,t.verticalResize=t.rowResize,t.horizontalResize=t.colResize,t.topResize=t.nResize,t.rightResize=t.eResize,t.bottomResize=t.sResize,t.leftResize=t.wResize,t}static get joins(){return{miter:"miter",round:"round",bevel:"bevel"}}}class T extends k{constructor(t,e,s){super(t,e,s),this.key=s.key}getModifier(){return this.key}static get events(){return{down:"keydown",up:"keyup"}}static get keys(){return{backspace:"Backspace",enter:"Enter",delete:"Delete",escape:"Escape",control:"Control",shift:"Shift",fn:"Fn",arrows:{up:"ArrowUp",right:"ArrowRight",down:"ArrowDown",left:"ArrowLeft"},tab:"Tab",alt:"Alt",altGr:"AltGraph",pageUp:"PageUp",pageDown:"PageDown",start:"Home",end:"End",insert:"Insert"}}}class L extends k{constructor(t,e,s,i){super(t,e,i),this.position=v.from(s),this.button=i?i.button:null}getModifier(){return this.button}static get buttons(){return{left:"0",main:"0",wheel:"1",middle:"1",right:"2",secondary:"2",backward:"3",aux1:"3",forward:"4",aux2:"4"}}static get events(){return{down:"mousedown",up:"mouseup",click:"click",contextMenu:"contextmenu",move:"mousemove",hover:"hover",leave:"leave",wheel:"mousewheel",scrollDown:"scrolldown",scrollUp:"scrollup",zoomOut:"zoomout",zoomIn:"zoomin",grab:"grab",drag:"drag",drop:"drop",resize:"resize",rotate:"rotate",doubleClick:"dblclick"}}}const N=Symbol("_listenForEvents");class I extends j{constructor(t=window.document.body,e){t===window.document.body&&(t.style.margin=0,t.style.height=`${window.innerHeight}px`);const s=t.getBoundingClientRect();t instanceof window.HTMLCanvasElement?(super(null,0,e),this.ctx=t.getContext("2d")):(super(t,0,e),t.appendChild(this.ctx.canvas)),this.cursorPosition=new v,this.containerPosition=new v(s.left+window.scrollX,s.top+window.scrollY),this.isScene=!0,this.isLooped=!1,this.isClicked=!1,this.fps=0,this.lastTick=null,this[N](t)}setCursor(t=P.cursors.default){return this.ctx.canvas.style.cursor=t,this}render(){const t=this.isLooped?window.requestAnimationFrame(this.render.bind(this,void 0)):null;try{super.render(this.ctx)}catch(e){throw window.cancelAnimationFrame(t),this.stopLoop(),e}const e=window.performance.now();return this.isLooped&&this.lastTick&&(this.fps=1e3/(e-this.lastTick)),this.lastTick=e,this}isHover(){return this.options.shown}startLoop(){return this.isLooped=!0,this.render(),this}stopLoop(){return this.isLooped=!1,this.fps=0,this}hide(){return this.ctx.canvas.style.visibility="hidden",super.hide()}show(){return this.ctx.canvas.style.visibility="",super.show()}static from(t){return new I(void 0,t.options)}static getDrawingContext(t=window.document.body){if(t){const{scrollWidth:e,scrollHeight:s}=t,i=super.getDrawingContext(e,s);return i.canvas.style.display="block",i.canvas.style.position="absolute",i}return null}static get defaultOptions(){return{...super.defaultOptions,cursor:P.cursors.default}}static get events(){return{...super.events,change:"change-scene"}}}I.prototype[N]=function(t){if(this.isReady)throw new EvalError("Can't rebind event a second time.");let e=null,s=null;const i={[L.events.down]:(t,e)=>{t.isClicked=!0,s=e},[L.events.move]:(t,i)=>{s&&(t.isClicked=t.isClicked&&i.distance(s)<10),t!==e&&(e&&(e.isHovered=!1,e.isAncestorOf(t)||e.fire(new L(L.events.leave,e,i))),e=t),t.isHovered||(t.isHovered=!0,t.fire(new L(L.events.hover,t,i))),this.setCursor(t.options.cursor),this.cursorPosition.set(i)},[L.events.up]:(t,e,i)=>{s=null,t.isClicked&&(t.fire(new L(L.events.click,t,e,i)),t.isClicked=!1)},[L.events.wheel]:(t,e,s)=>{const i=L.events,n=s.deltaY>0?[i.scrollDown,i.zoomOut]:[i.scrollUp,i.zoomIn];t.fire(new L(n[0],t,e,s)).fire(new L(n[1],t,e,s))},mouseout:(t,e,s)=>{t.fire(new L(L.events.leave,t,e,s))},mouseenter:(t,e,s)=>{t.fire(new L(L.events.hover,t,e,s))},[L.events.contextMenu]:null,[L.events.doubleClick]:null};Object.keys(i).forEach((e=>{t.addEventListener(e,(t=>{if(this.options.shown){const s=new v(t.clientX,t.clientY).subtract(this.containerPosition).add(window.scrollX,window.scrollY),n=this.getTarget(s,this.ctx);n&&(n.fire(new L(e,n,s,t)),i[e]instanceof Function&&i[e](n,s,t))}}),{passive:!1})}));const n={[T.events.down]:null,[T.events.up]:null};Object.keys(n).forEach((t=>{window.document.addEventListener(t,(e=>{this.options.shown&&(this.fire(new T(t,this,e)),n[t]instanceof Function&&n[t](e))}))}))};let D=null;const H=()=>D,J=t=>(D&&D.hide().stopLoop(),t.show().startLoop(),D=t,t),$=(t,e=window.document.body)=>{let s;e instanceof window.HTMLCanvasElement?s=e:(({canvas:s}=I.getDrawingContext(e)),e.appendChild(s));const i=Object.keys(t),n={};return i.forEach((e=>{const i=new I(s);t[e](i),n[e]=i,i.hide(),i.on(I.events.change,(t=>J(n[t.target])))})),J(n[i[0]])};class q extends k{static get events(){return{ready:"ready",error:"error"}}}class G extends P{constructor(t,e,s,i,n){super(t,{...e.options,...n}),this.base=e,this.generator=s,this.updater=i,this.data=[]}generate(t,...e){return this.data=this.data.concat([...new Array(t)].map(((t,s)=>{const i={...G.defaultData,...this.generator?this.generator(s,...e):{}};return i.position=v.from(i.position),i}))),this}trace(t){const e=new window.Path2D;this.base.trace(e);const s=new window.DOMMatrix,{cos:i,sin:n}=Math;if(this.data=this.data.filter(((r,o)=>{this.updater&&this.updater(r,o);const{position:a,scale:h=1,rotation:c=0,ttl:u}=r,p="number"==typeof h?[h,h]:v.from(h).toJSON(),d=c*l;return s.a=i(d)*p[0],s.b=n(d)*p[0],s.c=-n(d)*p[1],s.d=i(d)*p[1],s.e=a.x,s.f=a.y,t.addPath(e,s),!u||--r.ttl>0})),this.options.emit&&a()<this.options.frequency){const t=Array.isArray(this.options.emit)?a(...this.options.emit):this.options.emit;this.generate(Math.floor(t),...this.options.args)}return this}isHover(){return!1}toJSON(){const{base:t,data:e}=this;return{...super.toJSON(),base:t,data:e}}static from(t){const e=from(t.base),s=new G(t.position,e,0);return s.data=t.data,s}static get defaultOptions(){return{...super.defaultOptions,frequency:1,emit:null,args:[]}}static get defaultData(){return{position:new v}}}class F extends P{constructor(t,e,s){super(t,s),this.points=e.map((t=>v.from(t)))}trace(t){t.moveTo(0,0);const e=this.options.absolute?this.position:new v;return this.points.forEach((s=>t.lineTo(s.x-e.x,s.y-e.y))),this}toJSON(){const{points:t}=this;return{...super.toJSON(),points:t}}static from(t){return new F(t.position,t.points,t.options)}static get defaultOptions(){return{...super.defaultOptions,cap:F.caps.round,join:F.joins.round,fill:null,stroke:super.defaultOptions.fill,absolute:!1}}static get caps(){return{butt:"butt",round:"round",square:"square"}}}class B extends P{constructor(t,e=0,s=0,i=0,n=.5,r){super(t,r),this.width=e,this.height=s,this.startAngle=i,this.endAngle=n}trace(t){const e=(this.startAngle+-.25)*l,s=(this.endAngle+-.25)*l;return t.ellipse(0,0,this.width,this.height,0,e,s),this}toJSON(){const{width:t,height:e,startAngle:s,endAngle:i}=this;return{...super.toJSON(),width:t,height:e,startAngle:s,endAngle:i}}static from(t){return new B(t.position,t.width,t.height,t.startAngle,t.endAngle,t.options)}static get defaultOptions(){return F.defaultOptions}static get caps(){return F.caps}}class _ extends B{constructor(t,e,s,i){super(t,e,s,0,1,i)}toJSON(){const t=super.toJSON();return delete t.startAngle,delete t.endAngle,t}static from(t){return new _(t.position,t.width,t.height,t.options)}static get defaultOptions(){return P.defaultOptions}}class U extends _{constructor(t,e,s){super(t,e,e,s)}get radius(){return this.width}set radius(t){this.width=t,this.height=t}trace(t){return t.arc(0,0,this.radius,0,l),this}toJSON(){const{radius:t}=this,e={...super.toJSON(),radius:t};return delete e.width,delete e.height,e}static from(t){return new U(t.position,t.radius,t.options)}}class W extends F{constructor(t,e,s=W.defaultTension,i){super(t,e,i),this.tension=s}trace(t){return 1===this.points.length||o(this.tension,0)?super.trace(t):(t.moveTo(0,0),W.splineThrough(t,[new v(0,0)].concat(this.points),this.tension)),this}toJSON(){const{tension:t}=this;return{...super.toJSON(),tension:t}}static from(t){return new W(t.position,t.points,t.tension,t.options)}static get defaultTension(){return.2}static splineThrough(t,e,s=W.defaultTension){if(e.length<2)throw new RangeError(`Need at least 2 points to spline, but only ${e.length} given.`);const i=e.map((t=>v.from(t)));if(2===i.length)return void t.lineTo(i[1].x,i[1].y);const n=W.getControlPoint;let r=[null,i[0]];for(let e=1,o=i.length;e<o;++e){const a=e<o-1?n(i.slice(e-1,e+2),s):[i[e],null];t.bezierCurveTo(r[1].x,r[1].y,a[0].x,a[0].y,i[e].x,i[e].y),r=a}}static getControlPoint(t,e=W.defaultTension){if(t.length<3)throw new RangeError(`Need exactly 3 points to compute control points, but ${t.length}