-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
1 lines (1 loc) · 250 KB
/
main.js
1
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function e(){return t.default}:function e(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){var i,r,s=function(a,o){var h=(a=a||n(1)).window,l=a.document,u=new function(){var t=/^(statics|enumerable|beans|preserve)$/,e=[],n=e.slice,i=Object.create,r=Object.getOwnPropertyDescriptor,s=Object.defineProperty,a=e.forEach||function(t,e){for(var n=0,i=this.length;n<i;n++)t.call(e,this[n],n,this)},h=function(t,e){for(var n in this)this.hasOwnProperty(n)&&t.call(e,this[n],n,this)},l=Object.assign||function(t){for(var e=1,n=arguments.length;e<n;e++){var i=arguments[e];for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}return t},u=function(t,e,n){if(t){var i=r(t,"length");(i&&"number"==typeof i.value?a:h).call(t,e,n=n||t)}return n};function c(e,n,i,a,o){var h={};function l(t,l){"string"==typeof(l=l||(l=r(n,t))&&(l.get?l:l.value))&&"#"===l[0]&&(l=e[l.substring(1)]||l);var u="function"==typeof l,c=l,f=o||u&&!l.base?l&&l.get?t in e:e[t]:null,_;o&&f||(u&&f&&(l.base=f),u&&!1!==a&&(_=t.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(h[_[3].toLowerCase()+_[4]]=_[2]),c&&!u&&c.get&&"function"==typeof c.get&&d.isPlainObject(c)||(c={value:c,writable:!0}),(r(e,t)||{configurable:!0}).configurable&&(c.configurable=!0,c.enumerable=null!=i?i:!_),s(e,t,c))}if(n){for(var u in n)n.hasOwnProperty(u)&&!t.test(u)&&l(u);for(var u in h){var c=h[u],f=e["set"+c],_=e["get"+c]||f&&e["is"+c];!_||!0!==a&&0!==_.length||l(u,{get:_,set:f})}}return e}function d(){for(var t=0,e=arguments.length;t<e;t++){var n=arguments[t];n&&l(this,n)}return this}return c(d,{inject:function(t){if(t){var e=!0===t.statics?t:t.statics,n=t.beans,i=t.preserve;e!==t&&c(this.prototype,t,t.enumerable,n,i),c(this,e,null,n,i)}for(var r=1,s=arguments.length;r<s;r++)this.inject(arguments[r]);return this},extend:function(){for(var t=this,e,n,r=0,a,o=arguments.length;r<o&&(!e||!n);r++)a=arguments[r],e=e||a.initialize,n=n||a.prototype;return n=(e=e||function(){t.apply(this,arguments)}).prototype=n||i(this.prototype),s(n,"constructor",{value:e,writable:!0,configurable:!0}),c(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=t,e}}).inject({enumerable:!1,initialize:d,set:d,inject:function(){for(var t=0,e=arguments.length;t<e;t++){var n=arguments[t];n&&c(this,n,n.enumerable,n.beans,n.preserve)}return this},extend:function(){var t=i(this);return t.inject.apply(t,arguments)},each:function(t,e){return u(this,t,e)},clone:function(){return new this.constructor(this)},statics:{set:l,each:u,create:i,define:s,describe:r,clone:function(t){return l(new t.constructor,t)},isPlainObject:function(t){var e=null!=t&&t.constructor;return e&&(e===Object||e===d||"Object"===e.name)},pick:function(t,e){return t!==o?t:e},slice:function(t,e,i){return n.call(t,e,i)}}})};t.exports=u,u.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+u.each(this,function(t,e){if(!/^_/.test(e)){var n=typeof t;this.push(e+": "+("number"===n?_.instance.number(t):"string"===n?"'"+t+"'":t))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(t){return u.importJSON(t,this)},exportJSON:function(t){return u.exportJSON(this,t)},toJSON:function(){return u.serialize(this)},set:function(t,e){return t&&u.filter(this,t,e,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function t(){var e=t.base.apply(this,arguments),n=e.prototype._class;return n&&!u.exports[n]&&(u.exports[n]=e),e},equals:function(t,e){if(t===e)return!0;if(t&&t.equals)return t.equals(e);if(e&&e.equals)return e.equals(t);if(t&&e&&"object"==typeof t&&"object"==typeof e){if(Array.isArray(t)&&Array.isArray(e)){var n;if((n=t.length)!==e.length)return!1;for(;n--;)if(!u.equals(t[n],e[n]))return!1}else{var i=Object.keys(t),n;if((n=i.length)!==Object.keys(e).length)return!1;for(;n--;){var r=i[n];if(!e.hasOwnProperty(r)||!u.equals(t[r],e[r]))return!1}}return!0}return!1},read:function(t,e,n,i){if(this===u){var r=this.peek(t,e);return t.__index++,r}var s=this.prototype,a=s._readIndex,h=e||a&&t.__index||0,l=t.length,c=t[h];if(i=i||l-h,c instanceof this||n&&n.readNull&&null==c&&i<=1)return a&&(t.__index=h+1),c&&n&&n.clone?c.clone():c;if(c=u.create(s),a&&(c.__read=!0),c=c.initialize.apply(c,h>0||h+i<l?u.slice(t,h,h+i):t)||c,a){t.__index=h+c.__read;var d=c.__filtered;d&&(t.__filtered=d,c.__filtered=o),c.__read=o}return c},peek:function(t,e){return t[t.__index=e||t.__index||0]},remain:function(t){return t.length-(t.__index||0)},readList:function(t,e,n,i){for(var r=[],s,a=e||0,o=i?a+i:t.length,h=a;h<o;h++)r.push(Array.isArray(s=t[h])?this.read(s,0,n):this.read(t,h,n,1));return r},readNamed:function(t,e,n,i,r){var s=this.getNamed(t,e),a=s!==o;if(a){var h=t.__filtered;h||((h=t.__filtered=u.create(t[0])).__unfiltered=t[0]),h[e]=o}var l=a?[s]:t,c;return this.read(l,n,i,r)},getNamed:function(t,e){var n=t[0];if(t._hasObject===o&&(t._hasObject=1===t.length&&u.isPlainObject(n)),t._hasObject)return e?n[e]:t.__filtered||n},hasNamed:function(t,e){return!!this.getNamed(t,e)},filter:function(t,e,n,i){var r;function s(i){if(!(n&&i in n||r&&i in r)){var s=e[i];s!==o&&(t[i]=s)}}if(i){for(var a={},h=0,l,u=i.length;h<u;h++)(l=i[h])in e&&(s(l),a[l]=!0);r=a}return Object.keys(e.__unfiltered||e).forEach(s),t},isPlainValue:function(t,e){return u.isPlainObject(t)||Array.isArray(t)||e&&"string"==typeof t},serialize:function(t,e,n,i){e=e||{};var r=!i,s;if(r&&(e.formatter=new _(e.precision),i={length:0,definitions:{},references:{},add:function(t,e){var n="#"+t._id,i=this.references[n];if(!i){this.length++;var r=e.call(t),s=t._class;s&&r[0]!==s&&r.unshift(s),this.definitions[n]=r,i=this.references[n]=[n]}return i}}),t&&t._serialize){s=t._serialize(e,i);var a=t._class;!a||t._compactSerialize||!r&&n||s[0]===a||s.unshift(a)}else if(Array.isArray(t)){s=[];for(var o=0,h=t.length;o<h;o++)s[o]=u.serialize(t[o],e,n,i)}else if(u.isPlainObject(t)){s={};for(var l=Object.keys(t),o=0,h=l.length;o<h;o++){var c=l[o];s[c]=u.serialize(t[c],e,n,i)}}else s="number"==typeof t?e.formatter.number(t,e.precision):t;return r&&i.length>0?[["dictionary",i.definitions],s]:s},deserialize:function(t,e,n,i,r){var s=t,a=!n,o=a&&t&&t.length&&"dictionary"===t[0][0];if(n=n||{},Array.isArray(t)){var h=t[0],l="dictionary"===h;if(1==t.length&&/^#/.test(h))return n.dictionary[h];s=[];for(var c=(h=u.exports[h])?1:0,d=t.length;c<d;c++)s.push(u.deserialize(t[c],e,n,l,o));if(h){var f=s;e?s=e(h,f,a||r):(s=u.create(h.prototype),h.apply(s,f))}}else if(u.isPlainObject(t))for(var _ in s={},i&&(n.dictionary=s),t)s[_]=u.deserialize(t[_],e,n);return o?s[1]:s},exportJSON:function(t,e){var n=u.serialize(t,e);return e&&0==e.asString?n:JSON.stringify(n)},importJSON:function(t,e){return u.deserialize("string"==typeof t?JSON.parse(t):t,function(t,n,i){var r=i&&e&&e.constructor===t,s=r?e:u.create(t.prototype);if(1===n.length&&s instanceof P&&(r||!(s instanceof I))){var a=n[0];u.isPlainObject(a)&&(a.insert=!1)}return(r?s.set:t).apply(s,n),r&&(e=null),s})},splice:function(t,e,n,i){var r=e&&e.length,s=n===o;(n=s?t.length:n)>t.length&&(n=t.length);for(var a=0;a<r;a++)e[a]._index=n+a;if(s)return t.push.apply(t,e),[];var h=[n,i];e&&h.push.apply(h,e);for(var l=t.splice.apply(t,h),a=0,u=l.length;a<u;a++)l[a]._index=o;for(var a=n+r,u=t.length;a<u;a++)t[a]._index=a;return l},capitalize:function(t){return t.replace(/\b[a-z]/g,function(t){return t.toUpperCase()})},camelize:function(t){return t.replace(/-(.)/g,function(t,e){return e.toUpperCase()})},hyphenate:function(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}});var c={on:function(t,e){if("string"!=typeof t)u.each(t,function(t,e){this.on(e,t)},this);else{var n=this._eventTypes,i=n&&n[t],r=this._callbacks=this._callbacks||{};-1===(r=r[t]=r[t]||[]).indexOf(e)&&(r.push(e),i&&i.install&&1===r.length&&i.install.call(this,t))}return this},off:function(t,e){if("string"==typeof t){var n=this._eventTypes,i=n&&n[t],r=this._callbacks&&this._callbacks[t],s;return r&&(!e||-1!==(s=r.indexOf(e))&&1===r.length?(i&&i.uninstall&&i.uninstall.call(this,t),delete this._callbacks[t]):-1!==s&&r.splice(s,1)),this}u.each(t,function(t,e){this.off(e,t)},this)},once:function(t,e){return this.on(t,function(){e.apply(this,arguments),this.off(t,e)})},emit:function(t,e){var n=this._callbacks&&this._callbacks[t];if(!n)return!1;var i=u.slice(arguments,1),r=e&&e.target&&!e.currentTarget;n=n.slice(),r&&(e.currentTarget=this);for(var s=0,a=n.length;s<a;s++)if(0==n[s].apply(this,i)){e&&e.stop&&e.stop();break}return r&&delete e.currentTarget,!0},responds:function(t){return!(!this._callbacks||!this._callbacks[t])},attach:"#on",detach:"#off",fire:"#emit",_installEvents:function(t){var e=this._eventTypes,n=this._callbacks,i=t?"install":"uninstall";if(e)for(var r in n)if(n[r].length>0){var s=e[r],a=s&&s[i];a&&a.call(this,r)}},statics:{inject:function t(e){var n=e._events;if(n){var i={};u.each(n,function(t,n){var r="string"==typeof t,s=r?t:n,a=u.capitalize(s),o=s.substring(2).toLowerCase();i[o]=r?{}:t,s="_"+s,e["get"+a]=function(){return this[s]},e["set"+a]=function(t){var e=this[s];e&&this.off(o,e),t&&this.on(o,t),this[s]=t}}),e._eventTypes=i}return t.base.apply(this,arguments)}}},d=u.extend({_class:"PaperScope",initialize:function t(){s=this,this.settings=new u({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this._id=t._id++,t._scopes[this._id]=this;var e=t.prototype;if(!this.support){var n=at.getContext(1,1)||{};e.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:ot.nativeModes},at.release(n)}if(!this.agent){var i=a.navigator.userAgent.toLowerCase(),r=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(i)||[])[0],o="darwin"===r?"mac":r,h=e.agent=e.browser={platform:o};o&&(h[o]=!0),i.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(t,e,n,i,r){if(!h.chrome){var s="opera"===e?i:/^(node|trident)$/.test(e)?r:n;h.version=s,h.versionNumber=parseFloat(s),e="trident"===e?"msie":e,h.name=e,h[e]=!0}}),h.chrome&&delete h.webkit,h.atom&&delete h.chrome}},version:"0.11.5",getView:function(){var t=this.project;return t&&t._view},getPaper:function(){return this},execute:function(t,e){s.PaperScript.execute(t,this,e),X.updateFocus()},install:function(t){var e=this;for(var n in u.each(["project","view","tool"],function(n){u.define(t,n,{configurable:!0,get:function(){return e[n]}})}),this)!/^_/.test(n)&&this[n]&&(t[n]=this[n])},setup:function(t){return s=this,this.project=new M(t),this},createCanvas:function(t,e){return at.getCanvas(t,e)},activate:function(){s=this},clear:function(){for(var t=this.projects,e=this.tools,n=t.length-1;n>=0;n--)t[n].remove();for(var n=e.length-1;n>=0;n--)e[n].remove()},remove:function(){this.clear(),delete d._scopes[this._id]},statics:new function(){function t(t){return t+="Attribute",function(e,n){return e[t](n)||e[t]("data-paper-"+n)}}return{_scopes:{},_id:0,get:function(t){return this._scopes[t]||null},getAttribute:t("get"),hasAttribute:t("has")}}}),f=u.extend(c,{initialize:function(t){this._scope=s,this._index=this._scope[this._list].push(this)-1,!t&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var t=this._scope[this._reference];return t&&t!==this&&t.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",t),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(u.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),_=u.extend({initialize:function(t){this.precision=u.pick(t,5),this.multiplier=Math.pow(10,this.precision)},number:function(t){return this.precision<16?Math.round(t*this.multiplier)/this.multiplier:t},pair:function(t,e,n){return this.number(t)+(n||",")+this.number(e)},point:function(t,e){return this.number(t.x)+(e||",")+this.number(t.y)},size:function(t,e){return this.number(t.width)+(e||",")+this.number(t.height)},rectangle:function(t,e){return this.point(t,e)+(e||",")+this.size(t,e)}});_.instance=new _;var g=new function(){var t=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],e=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],n=Math.abs,i=Math.sqrt,r=Math.pow,s=Math.log2||function(t){return Math.log(t)*Math.LOG2E},a=1e-12,o=1.12e-16;function h(t,e,n){return t<e?e:t>n?n:t}function l(t,e,i){function r(t){var e=134217729*t,n,i=t-e+e,r;return[i,t-i]}var s=e*e-t*i,a=e*e+t*i;if(3*n(s)<a){var o=r(t),h=r(e),l=r(i),u=e*e,c,d=t*i,f;s=u-d+(h[0]*h[0]-u+2*h[0]*h[1]+h[1]*h[1]-(o[0]*l[0]-d+o[0]*l[1]+o[1]*l[0]+o[1]*l[1]))}return s}function u(){var t=Math.max.apply(Math,arguments);return t&&(t<1e-8||t>1e8)?r(2,-Math.round(s(t))):0}return{EPSILON:1e-12,MACHINE_EPSILON:1.12e-16,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,KAPPA:4*(i(2)-1)/3,isZero:function(t){return t>=-1e-12&&t<=1e-12},clamp:h,integrate:function(n,i,r,s){for(var a=t[s-2],o=e[s-2],h=.5*(r-i),l=h+i,u=0,c=s+1>>1,d=1&s?o[u++]*n(l):0;u<c;){var f=h*a[u];d+=o[u++]*(n(l+f)+n(l-f))}return h*d},findRoot:function(t,e,i,r,s,a,o){for(var l=0;l<a;l++){var u=t(i),c=u/e(i),d=i-c;if(n(c)<o){i=d;break}u>0?(s=i,i=d<=r?.5*(r+s):d):(r=i,i=d>=s?.5*(r+s):d)}return h(i,r,s)},solveQuadratic:function(t,e,r,s,a,o){var c,d=1/0;if(n(t)<1e-12){if(n(e)<1e-12)return n(r)<1e-12?-1:0;c=-r/e}else{var f=l(t,e*=-.5,r);if(f&&n(f)<1.12e-16){var _=u(n(t),n(e),n(r));_&&(f=l(t*=_,e*=_,r*=_))}if(f>=-1.12e-16){var g=f<0?0:i(f),v=e+(e<0?-g:g);0===v?d=-(c=r/t):(c=v/t,d=r/v)}}var p=0,m=null==a,y=a-1e-12,w=o+1e-12;return isFinite(c)&&(m||c>y&&c<w)&&(s[p++]=m?c:h(c,a,o)),d!==c&&isFinite(d)&&(m||d>y&&d<w)&&(s[p++]=m?d:h(d,a,o)),p},solveCubic:function(t,e,s,a,o,l,c){var d=u(n(t),n(e),n(s),n(a)),f,_,v,p,m;function y(n){var i=t*(f=n);p=(i+(_=i+e))*f+(v=_*f+s),m=v*f+a}if(d&&(t*=d,e*=d,s*=d,a*=d),n(t)<1e-12)t=e,_=s,v=a,f=1/0;else if(n(a)<1e-12)_=e,v=s,f=0;else{y(-e/t/3);var w=m/t,x=r(n(w),1/3),b=w<0?-1:1,C=-p/t,S=C>0?1.324717957244746*Math.max(x,i(C)):x,M=f-b*S;if(M!==f){do{y(M),M=0===p?f:f-m/p/(1+1.12e-16)}while(b*M>b*f);n(t)*f*f>n(a/f)&&(_=((v=-a/f)-s)/f)}}var P=g.solveQuadratic(t,_,v,o,l,c),k=null==l;return isFinite(f)&&(0===P||P>0&&f!==o[0]&&f!==o[1])&&(k||f>l-1e-12&&f<c+1e-12)&&(o[P++]=k?f:h(f,l,c)),P}}},v={_id:1,_pools:{},get:function(t){if(t){var e=this._pools[t];return e||(e=this._pools[t]={_id:1}),e._id++}return this._id++}},p=u.extend({_class:"Point",_readIndex:!0,initialize:function t(e,n){var i=typeof e,r=this.__read,s=0;if("number"===i){var a="number"==typeof n;this._set(e,a?n:e),r&&(s=a?2:1)}else if("undefined"===i||null===e)this._set(0,0),r&&(s=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;s=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"x"in o?this._set(o.x||0,o.y||0):"width"in o?this._set(o.width||0,o.height||0):"angle"in o?(this._set(o.length||0,0),this.setAngle(o.angle||0)):(this._set(0,0),s=0)}return r&&(this.__read=s),this},set:"#initialize",_set:function(t,e){return this.x=t,this.y=e,this},equals:function(t){return this===t||t&&(this.x===t.x&&this.y===t.y||Array.isArray(t)&&this.x===t[0]&&this.y===t[1])||!1},clone:function(){return new p(this.x,this.y)},toString:function(){var t=_.instance;return"{ x: "+t.number(this.x)+", y: "+t.number(this.y)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.x),e.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(t){if(this.isZero()){var e=this._angle||0;this._set(Math.cos(e)*t,Math.sin(e)*t)}else{var n=t/this.getLength();g.isZero(n)&&this.getAngle(),this._set(this.x*n,this.y*n)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(t){this.setAngleInRadians.call(this,t*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var t=p.read(arguments),e=this.getLength()*t.getLength();if(g.isZero(e))return NaN;var n=this.dot(t)/e;return Math.acos(n<-1?-1:n>1?1:n)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(t){if(this._angle=t,!this.isZero()){var e=this.getLength();this._set(Math.cos(t)*e,Math.sin(t)*e)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var t=p.read(arguments);return 180*Math.atan2(this.cross(t),this.dot(t))/Math.PI},getDistance:function(){var t=p.read(arguments),e=t.x-this.x,n=t.y-this.y,i=e*e+n*n,r;return u.read(arguments)?i:Math.sqrt(i)},normalize:function(t){t===o&&(t=1);var e=this.getLength(),n=0!==e?t/e:0,i=new p(this.x*n,this.y*n);return n>=0&&(i._angle=this._angle),i},rotate:function(t,e){if(0===t)return this.clone();t=t*Math.PI/180;var n=e?this.subtract(e):this,i=Math.sin(t),r=Math.cos(t);return n=new p(n.x*r-n.y*i,n.x*i+n.y*r),e?n.add(e):n},transform:function(t){return t?t._transformPoint(this):this},add:function(){var t=p.read(arguments);return new p(this.x+t.x,this.y+t.y)},subtract:function(){var t=p.read(arguments);return new p(this.x-t.x,this.y-t.y)},multiply:function(){var t=p.read(arguments);return new p(this.x*t.x,this.y*t.y)},divide:function(){var t=p.read(arguments);return new p(this.x/t.x,this.y/t.y)},modulo:function(){var t=p.read(arguments);return new p(this.x%t.x,this.y%t.y)},negate:function(){return new p(-this.x,-this.y)},isInside:function(){return x.read(arguments).contains(this)},isClose:function(){var t=p.read(arguments),e=u.read(arguments);return this.getDistance(t)<=e},isCollinear:function(){var t=p.read(arguments);return p.isCollinear(this.x,this.y,t.x,t.y)},isColinear:"#isCollinear",isOrthogonal:function(){var t=p.read(arguments);return p.isOrthogonal(this.x,this.y,t.x,t.y)},isZero:function(){var t=g.isZero;return t(this.x)&&t(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},isInQuadrant:function(t){return this.x*(t>1&&t<4?-1:1)>=0&&this.y*(t>2?-1:1)>=0},dot:function(){var t=p.read(arguments);return this.x*t.x+this.y*t.y},cross:function(){var t=p.read(arguments);return this.x*t.y-this.y*t.x},project:function(){var t=p.read(arguments),e=t.isZero()?0:this.dot(t)/t.dot(t);return new p(t.x*e,t.y*e)},statics:{min:function(){var t=p.read(arguments),e=p.read(arguments);return new p(Math.min(t.x,e.x),Math.min(t.y,e.y))},max:function(){var t=p.read(arguments),e=p.read(arguments);return new p(Math.max(t.x,e.x),Math.max(t.y,e.y))},random:function(){return new p(Math.random(),Math.random())},isCollinear:function(t,e,n,i){return Math.abs(t*i-e*n)<=1e-8*Math.sqrt((t*t+e*e)*(n*n+i*i))},isOrthogonal:function(t,e,n,i){return Math.abs(t*n+e*i)<=1e-8*Math.sqrt((t*t+e*e)*(n*n+i*i))}}},u.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new p(e(this.x),e(this.y))}},{})),m=p.extend({initialize:function t(e,n,i,r){this._x=e,this._y=n,this._owner=i,this._setter=r},_set:function(t,e,n){return this._x=t,this._y=e,n||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(t){this._x=t,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(t){this._y=t,this._owner[this._setter](this)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(t){this._owner._changeSelection(this._getSelection(),t)},_getSelection:function(){return"setPosition"===this._setter?4:0}}),y=u.extend({_class:"Size",_readIndex:!0,initialize:function t(e,n){var i=typeof e,r=this.__read,s=0;if("number"===i){var a="number"==typeof n;this._set(e,a?n:e),r&&(s=a?2:1)}else if("undefined"===i||null===e)this._set(0,0),r&&(s=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;s=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"width"in o?this._set(o.width||0,o.height||0):"x"in o?this._set(o.x||0,o.y||0):(this._set(0,0),s=0)}return r&&(this.__read=s),this},set:"#initialize",_set:function(t,e){return this.width=t,this.height=e,this},equals:function(t){return t===this||t&&(this.width===t.width&&this.height===t.height||Array.isArray(t)&&this.width===t[0]&&this.height===t[1])||!1},clone:function(){return new y(this.width,this.height)},toString:function(){var t=_.instance;return"{ width: "+t.number(this.width)+", height: "+t.number(this.height)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.width),e.number(this.height)]},add:function(){var t=y.read(arguments);return new y(this.width+t.width,this.height+t.height)},subtract:function(){var t=y.read(arguments);return new y(this.width-t.width,this.height-t.height)},multiply:function(){var t=y.read(arguments);return new y(this.width*t.width,this.height*t.height)},divide:function(){var t=y.read(arguments);return new y(this.width/t.width,this.height/t.height)},modulo:function(){var t=y.read(arguments);return new y(this.width%t.width,this.height%t.height)},negate:function(){return new y(-this.width,-this.height)},isZero:function(){var t=g.isZero;return t(this.width)&&t(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(t,e){return new y(Math.min(t.width,e.width),Math.min(t.height,e.height))},max:function(t,e){return new y(Math.max(t.width,e.width),Math.max(t.height,e.height))},random:function(){return new y(Math.random(),Math.random())}}},u.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new y(e(this.width),e(this.height))}},{})),w=y.extend({initialize:function t(e,n,i,r){this._width=e,this._height=n,this._owner=i,this._setter=r},_set:function(t,e,n){return this._width=t,this._height=e,n||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(t){this._width=t,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(t){this._height=t,this._owner[this._setter](this)}}),x=u.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function t(e,n,i,r){var s=typeof e,a;if("number"===s?(this._set(e,n,i,r),a=4):"undefined"===s||null===e?(this._set(0,0,0,0),a=null===e?1:0):1===arguments.length&&(Array.isArray(e)?(this._set.apply(this,e),a=1):e.x!==o||e.width!==o?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),a=1):e.from===o&&e.to===o&&(this._set(0,0,0,0),u.filter(this,e),a=1)),a===o){var h=p.readNamed(arguments,"from"),l=u.peek(arguments),c=h.x,d=h.y,f,_;if(l&&l.x!==o||u.hasNamed(arguments,"to")){var g=p.readNamed(arguments,"to");f=g.x-c,_=g.y-d,f<0&&(c=g.x,f=-f),_<0&&(d=g.y,_=-_)}else{var v=y.read(arguments);f=v.width,_=v.height}this._set(c,d,f,_),a=arguments.__index;var m=arguments.__filtered;m&&(this.__filtered=m)}return this.__read&&(this.__read=a),this},set:"#initialize",_set:function(t,e,n,i){return this.x=t,this.y=e,this.width=n,this.height=i,this},clone:function(){return new x(this.x,this.y,this.width,this.height)},equals:function(t){var e=u.isPlainValue(t)?x.read(arguments):t;return e===this||e&&this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height||!1},toString:function(){var t=_.instance;return"{ x: "+t.number(this.x)+", y: "+t.number(this.y)+", width: "+t.number(this.width)+", height: "+t.number(this.height)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.x),e.number(this.y),e.number(this.width),e.number(this.height)]},getPoint:function(t){var e;return new(t?p:m)(this.x,this.y,this,"setPoint")},setPoint:function(){var t=p.read(arguments);this.x=t.x,this.y=t.y},getSize:function(t){var e;return new(t?y:w)(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var t=y.read(arguments),e=this._sx,n=this._sy,i=t.width,r=t.height;e&&(this.x+=(this.width-i)*e),n&&(this.y+=(this.height-r)*n),this.width=i,this.height=r,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(t){if(!this._fw){var e=t-this.x;this.width-=.5===this._sx?2*e:e}this.x=t,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(t){if(!this._fh){var e=t-this.y;this.height-=.5===this._sy?2*e:e}this.y=t,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(t){if(!this._fw){var e=t-this.x;this.width=.5===this._sx?2*e:e}this.x=t-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(t){if(!this._fh){var e=t-this.y;this.height=.5===this._sy?2*e:e}this.y=t-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(t){this._fw||.5===this._sx?this.x=t-this.width/2:(this._sx&&(this.x+=2*(t-this.x)*this._sx),this.width=2*(t-this.x)),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(t){this._fh||.5===this._sy?this.y=t-this.height/2:(this._sy&&(this.y+=2*(t-this.y)*this._sy),this.height=2*(t-this.y)),this._sy=.5,this._fh=0},getCenter:function(t){var e;return new(t?p:m)(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var t=p.read(arguments);return this.setCenterX(t.x),this.setCenterY(t.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(t){return t&&t.width!==o||4===(Array.isArray(t)?t:arguments).length?this._containsRectangle(x.read(arguments)):this._containsPoint(p.read(arguments))},_containsPoint:function(t){var e=t.x,n=t.y;return e>=this.x&&n>=this.y&&e<=this.x+this.width&&n<=this.y+this.height},_containsRectangle:function(t){var e=t.x,n=t.y;return e>=this.x&&n>=this.y&&e+t.width<=this.x+this.width&&n+t.height<=this.y+this.height},intersects:function(){var t=x.read(arguments),e=u.read(arguments)||0;return t.x+t.width>this.x-e&&t.y+t.height>this.y-e&&t.x<this.x+this.width+e&&t.y<this.y+this.height+e},intersect:function(){var t=x.read(arguments),e=Math.max(this.x,t.x),n=Math.max(this.y,t.y),i=Math.min(this.x+this.width,t.x+t.width),r=Math.min(this.y+this.height,t.y+t.height);return new x(e,n,i-e,r-n)},unite:function(){var t=x.read(arguments),e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),i=Math.max(this.x+this.width,t.x+t.width),r=Math.max(this.y+this.height,t.y+t.height);return new x(e,n,i-e,r-n)},include:function(){var t=p.read(arguments),e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),i=Math.max(this.x+this.width,t.x),r=Math.max(this.y+this.height,t.y);return new x(e,n,i-e,r-n)},expand:function(){var t=y.read(arguments),e=t.width,n=t.height;return new x(this.x-e/2,this.y-n/2,this.width+e,this.height+n)},scale:function(t,e){return this.expand(this.width*t-this.width,this.height*(e===o?t:e)-this.height)}},u.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(t,e){var n=t.join(""),i=/^[RL]/.test(n);e>=4&&(t[1]+=i?"Y":"X");var r=t[i?0:1],s=t[i?1:0],a="get"+r,o="get"+s,h="set"+r,l="set"+s,u,c="set"+n;this["get"+n]=function(t){var e;return new(t?p:m)(this[a](),this[o](),this,c)},this[c]=function(){var t=p.read(arguments);this[h](t.x),this[l](t.y)}},{beans:!0})),b=x.extend({initialize:function t(e,n,i,r,s,a){this._set(e,n,i,r,!0),this._owner=s,this._setter=a},_set:function(t,e,n,i,r){return this._x=t,this._y=e,this._width=n,this._height=i,r||this._owner[this._setter](this),this}},new function(){var t=x.prototype;return u.each(["x","y","width","height"],function(t){var e=u.capitalize(t),n="_"+t;this["get"+e]=function(){return this[n]},this["set"+e]=function(t){this[n]=t,this._dontNotify||this._owner[this._setter](this)}},u.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(e){var n="set"+e;this[n]=function(){this._dontNotify=!0,t[n].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(t){var e=this._owner;e._changeSelection&&e._changeSelection(2,t)}}))}),C=u.extend({_class:"Matrix",initialize:function t(e,n){var i=arguments.length,r=!0;if(i>=6?this._set.apply(this,arguments):1===i||2===i?e instanceof t?this._set(e._a,e._b,e._c,e._d,e._tx,e._ty,n):Array.isArray(e)?this._set.apply(this,n?e.concat([n]):e):r=!1:i?r=!1:this.reset(),!r)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(t,e,n,i,r,s,a){return this._a=t,this._b=e,this._c=n,this._d=i,this._tx=r,this._ty=s,a||this._changed(),this},_serialize:function(t,e){return u.serialize(this.getValues(),t,!0,e)},_changed:function(){var t=this._owner;t&&(t._applyMatrix?t.transform(null,!0):t._changed(9))},clone:function(){return new C(this._a,this._b,this._c,this._d,this._tx,this._ty)},equals:function(t){return t===this||t&&this._a===t._a&&this._b===t._b&&this._c===t._c&&this._d===t._d&&this._tx===t._tx&&this._ty===t._ty},toString:function(){var t=_.instance;return"[["+[t.number(this._a),t.number(this._c),t.number(this._tx)].join(", ")+"], ["+[t.number(this._b),t.number(this._d),t.number(this._ty)].join(", ")+"]]"},reset:function(t){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,t||this._changed(),this},apply:function(t,e){var n=this._owner;return!!n&&(n.transform(null,!0,u.pick(t,!0),e),this.isIdentity())},translate:function(){var t=p.read(arguments),e=t.x,n=t.y;return this._tx+=e*this._a+n*this._c,this._ty+=e*this._b+n*this._d,this._changed(),this},scale:function(){var t=p.read(arguments),e=p.read(arguments,0,{readNull:!0});return e&&this.translate(e),this._a*=t.x,this._b*=t.x,this._c*=t.y,this._d*=t.y,e&&this.translate(e.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=p.read(arguments,1),n=e.x,i=e.y,r=Math.cos(t),s=Math.sin(t),a=n-n*r+i*s,o=i-n*s-i*r,h=this._a,l=this._b,u=this._c,c=this._d;return this._a=r*h+s*u,this._b=r*l+s*c,this._c=-s*h+r*u,this._d=-s*l+r*c,this._tx+=a*h+o*u,this._ty+=a*l+o*c,this._changed(),this},shear:function(){var t=p.read(arguments),e=p.read(arguments,0,{readNull:!0});e&&this.translate(e);var n=this._a,i=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*n,this._d+=t.x*i,e&&this.translate(e.negate()),this._changed(),this},skew:function(){var t=p.read(arguments),e=p.read(arguments,0,{readNull:!0}),n=Math.PI/180,i=new p(Math.tan(t.x*n),Math.tan(t.y*n));return this.shear(i,e)},append:function(t,e){if(t){var n=this._a,i=this._b,r=this._c,s=this._d,a=t._a,o=t._c,h=t._b,l=t._d,u=t._tx,c=t._ty;this._a=a*n+h*r,this._c=o*n+l*r,this._b=a*i+h*s,this._d=o*i+l*s,this._tx+=u*n+c*r,this._ty+=u*i+c*s,e||this._changed()}return this},prepend:function(t,e){if(t){var n=this._a,i=this._b,r=this._c,s=this._d,a=this._tx,o=this._ty,h=t._a,l=t._c,u=t._b,c=t._d,d=t._tx,f=t._ty;this._a=h*n+l*i,this._c=h*r+l*s,this._b=u*n+c*i,this._d=u*r+c*s,this._tx=h*a+l*o+d,this._ty=u*a+c*o+f,e||this._changed()}return this},appended:function(t){return this.clone().append(t)},prepended:function(t){return this.clone().prepend(t)},invert:function(){var t=this._a,e=this._b,n=this._c,i=this._d,r=this._tx,s=this._ty,a=t*i-e*n,o=null;return a&&!isNaN(a)&&isFinite(r)&&isFinite(s)&&(this._a=i/a,this._b=-e/a,this._c=-n/a,this._d=t/a,this._tx=(n*s-i*r)/a,this._ty=(e*r-t*s)/a,o=this),o},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new C(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var t=this._a*this._d-this._c*this._b;return t&&!isNaN(t)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(t,e,n){return arguments.length<3?this._transformPoint(p.read(arguments)):this._transformCoordinates(t,e,n)},_transformPoint:function(t,e,n){var i=t.x,r=t.y;return e||(e=new p),e._set(i*this._a+r*this._c+this._tx,i*this._b+r*this._d+this._ty,n)},_transformCoordinates:function(t,e,n){for(var i=0,r=2*n;i<r;i+=2){var s=t[i],a=t[i+1];e[i]=s*this._a+a*this._c+this._tx,e[i+1]=s*this._b+a*this._d+this._ty}return e},_transformCorners:function(t){var e=t.x,n=t.y,i=e+t.width,r=n+t.height,s=[e,n,i,n,i,r,e,r];return this._transformCoordinates(s,s,4)},_transformBounds:function(t,e,n){for(var i=this._transformCorners(t),r=i.slice(0,2),s=r.slice(),a=2;a<8;a++){var o=i[a],h=1&a;o<r[h]?r[h]=o:o>s[h]&&(s[h]=o)}return e||(e=new x),e._set(r[0],r[1],s[0]-r[0],s[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(p.read(arguments))},_inverseTransform:function(t,e,n){var i=this._a,r=this._b,s=this._c,a=this._d,o=this._tx,h=this._ty,l=i*a-r*s,u=null;if(l&&!isNaN(l)&&isFinite(o)&&isFinite(h)){var c=t.x-this._tx,d=t.y-this._ty;e||(e=new p),u=e._set((c*a-d*s)/l,(d*i-c*r)/l,n)}return u},decompose:function(){var t=this._a,e=this._b,n=this._c,i=this._d,r=t*i-e*n,s=Math.sqrt,a=Math.atan2,o=180/Math.PI,h,l,u;if(0!==t||0!==e){var c=s(t*t+e*e);h=Math.acos(t/c)*(e>0?1:-1),l=[c,r/c],u=[a(t*n+e*i,c*c),0]}else if(0!==n||0!==i){var d=s(n*n+i*i);h=Math.asin(n/d)*(i>0?1:-1),l=[r/d,d],u=[0,a(t*n+e*i,d*d)]}else h=0,u=l=[0,0];return{translation:this.getTranslation(),rotation:h*o,scaling:new p(l),skewing:new p(u[0]*o,u[1]*o)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new p(this._tx,this._ty)},getScaling:function(){return(this.decompose()||{}).scaling},getRotation:function(){return(this.decompose()||{}).rotation},applyToContext:function(t){this.isIdentity()||t.transform(this._a,this._b,this._c,this._d,this._tx,this._ty)}},u.each(["a","b","c","d","tx","ty"],function(t){var e=u.capitalize(t),n="_"+t;this["get"+e]=function(){return this[n]},this["set"+e]=function(t){this[n]=t,this._changed()}},{})),S=u.extend({_class:"Line",initialize:function t(e,n,i,r,s){var a=!1;arguments.length>=4?(this._px=e,this._py=n,this._vx=i,this._vy=r,a=s):(this._px=e.x,this._py=e.y,this._vx=n.x,this._vy=n.y,a=i),a||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new p(this._px,this._py)},getVector:function(){return new p(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return S.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return S.getSide(this._px,this._py,this._vx,this._vy,t.x,t.y,!0,e)},getDistance:function(t){return Math.abs(this.getSignedDistance(t))},getSignedDistance:function(t){return S.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0)},isCollinear:function(t){return p.isCollinear(this._vx,this._vy,t._vx,t._vy)},isOrthogonal:function(t){return p.isOrthogonal(this._vx,this._vy,t._vx,t._vy)},statics:{intersect:function(t,e,n,i,r,s,a,o,h,l){h||(n-=t,i-=e,a-=r,o-=s);var u=n*o-i*a;if(!g.isZero(u)){var c=t-r,d=e-s,f=(a*d-o*c)/u,_=(n*d-i*c)/u,v=1e-12,m=-1e-12,y=1+1e-12;if(l||m<f&&f<y&&m<_&&_<y)return l||(f=f<=0?0:f>=1?1:f),new p(t+f*n,e+f*i)}},getSide:function(t,e,n,i,r,s,a,o){a||(n-=t,i-=e);var h=r-t,l,u=h*i-(s-e)*n;return!o&&g.isZero(u)&&(u=(h*n+h*n)/(n*n+i*i))>=0&&u<=1&&(u=0),u<0?-1:u>0?1:0},getSignedDistance:function(t,e,n,i,r,s,a){return a||(n-=t,i-=e),0===n?i>0?r-t:t-r:0===i?n<0?s-e:e-s:((r-t)*i-(s-e)*n)/Math.sqrt(n*n+i*i)},getDistance:function(t,e,n,i,r,s,a){return Math.abs(S.getSignedDistance(t,e,n,i,r,s,a))}}}),M=f.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function t(e){f.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new J(null,null,this),this._view=X.create(this,e||at.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(t,e){return u.serialize(this._children,t,!0,e)},_changed:function(t,e){if(1&t){var n=this._view;n&&(n._needsUpdate=!0,!n._requested&&n._autoUpdate&&n.requestUpdate())}var i=this._changes;if(i&&e){var r=this._changesById,s=e._id,a=r[s];a?a.flags|=t:i.push(r[s]={item:e,flags:t})}},clear:function(){for(var t=this._children,e=t.length-1;e>=0;e--)t[e].remove()},isEmpty:function(){return!this._children.length},remove:function t(){return!!t.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(t){this._currentStyle.set(t)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getLayers:function(){return this._children},getActiveLayer:function(){return this._activeLayer||new I({project:this,insert:!0})},getSymbolDefinitions:function(){var t=[],e={};return this.getItems({class:O,match:function(n){var i=n._definition,r=i._id;return e[r]||(e[r]=!0,t.push(i)),!1}}),t},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var t=this._selectionItems,e=[];for(var n in t){var i=t[n],r=i._selection;1&r&&i.isInserted()?e.push(i):r||this._updateSelection(i)}return e},_updateSelection:function(t){var e=t._id,n=this._selectionItems;t._selection?n[e]!==t&&(this._selectionCount++,n[e]=t):n[e]===t&&(this._selectionCount--,delete n[e])},selectAll:function(){for(var t=this._children,e=0,n=t.length;e<n;e++)t[e].setFullySelected(!0)},deselectAll:function(){var t=this._selectionItems;for(var e in t)t[e].setFullySelected(!1)},addLayer:function(t){return this.insertLayer(o,t)},insertLayer:function(t,e){if(e instanceof I){e._remove(!1,!0),u.splice(this._children,[e],t,0),e._setProject(this,!0);var n=e._name;n&&e.setName(n),this._changes&&e._changed(5),this._activeLayer||(this._activeLayer=e)}else e=null;return e},_insertItem:function(t,e,n){return e=this.insertLayer(t,e)||(this._activeLayer||this._insertItem(o,new I(P.NO_INSERT),!0)).insertChild(t,e),n&&e.activate&&e.activate(),e},getItems:function(t){return P._getItems(this,t)},getItem:function(t){return P._getItems(this,t,null,null,!0)[0]||null},importJSON:function(t){this.activate();var e=this._activeLayer;return u.importJSON(t,e&&e.isEmpty()&&e)},removeOn:function(t){var e=this._removeSets;if(e){"mouseup"===t&&(e.mousedrag=null);var n=e[t];if(n){for(var i in n){var r=n[i];for(var s in e){var a=e[s];a&&a!=n&&delete a[r._id]}r.remove()}e[t]=null}}},draw:function(t,e,n){this._updateVersion++,t.save(),e.applyToContext(t);for(var i=this._children,r=new u({offset:new p(0,0),pixelRatio:n,viewMatrix:e.isIdentity()?null:e,matrices:[new C],updateMatrix:!0}),s=0,a=i.length;s<a;s++)i[s].draw(t,r);if(t.restore(),this._selectionCount>0){t.save(),t.strokeWidth=1;var o=this._selectionItems,h=this._scope.settings.handleSize,l=this._updateVersion;for(var c in o)o[c]._drawSelection(t,e,h,o,l);t.restore()}}}),P=u.extend(c,{statics:{extend:function t(e){return e._serializeFields&&(e._serializeFields=u.set({},this.prototype._serializeFields,e._serializeFields)),t.base.apply(this,arguments)},NO_INSERT:{insert:!1}},_class:"Item",_name:null,_applyMatrix:!0,_canApplyMatrix:!0,_canScaleStroke:!1,_pivot:null,_visible:!0,_blendMode:"normal",_opacity:1,_locked:!1,_guide:!1,_clipMask:!1,_selection:0,_selectBounds:!0,_selectChildren:!1,_serializeFields:{name:null,applyMatrix:null,matrix:new C,pivot:null,visible:!0,blendMode:"normal",opacity:1,locked:!1,guide:!1,clipMask:!1,selected:!1,data:{}},_prioritize:["applyMatrix"]},new function(){var t=["onMouseDown","onMouseUp","onMouseDrag","onClick","onDoubleClick","onMouseMove","onMouseEnter","onMouseLeave"];return u.each(t,function(t){this._events[t]={install:function(t){this.getView()._countItemEvent(t,1)},uninstall:function(t){this.getView()._countItemEvent(t,-1)}}},{_events:{onFrame:{install:function(){this.getView()._animateItem(this,!0)},uninstall:function(){this.getView()._animateItem(this,!1)}},onLoad:{},onError:{}},statics:{_itemHandlers:t}})},{initialize:function t(){},_initialize:function(t,e){var n=t&&u.isPlainObject(t),i=n&&!0===t.internal,r=this._matrix=new C,a=n&&t.project||s.project,h=s.settings;return this._id=i?null:v.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&h.applyMatrix,e&&r.translate(e),r._owner=this,this._style=new J(a._currentStyle,this,a),i||n&&0==t.insert||!h.insertItems&&(!n||!0!==t.insert)?this._setProject(a):(n&&t.parent||a)._insertItem(o,this,!0),n&&t!==P.NO_INSERT&&this.set(t,{internal:!0,insert:!0,project:!0,parent:!0}),n},_serialize:function(t,e){var n={},i=this;function r(r){for(var s in r){var a=i[s];u.equals(a,"leading"===s?1.2*r.fontSize:r[s])||(n[s]=u.serialize(a,t,"data"!==s,e))}}return r(this._serializeFields),this instanceof k||r(this._style._defaults),[this._class,n]},_changed:function(t){var e=this._symbol,n=this._parent||e,i=this._project;8&t&&(this._bounds=this._position=this._decomposed=this._globalMatrix=o),n&&40&t&&P._clearBoundsCache(n),2&t&&P._clearBoundsCache(this),i&&i._changed(t,this),e&&e._changed(t)},getId:function(){return this._id},getName:function(){return this._name},setName:function(t){if(this._name&&this._removeNamed(),t===+t+"")throw new Error("Names consisting only of numbers are not supported.");var e=this._getOwner();if(t&&e){var n=e._children,i=e._namedChildren;(i[t]=i[t]||[]).push(this),t in n||(n[t]=this)}this._name=t||o,this._changed(128)},getStyle:function(){return this._style},setStyle:function(t){this.getStyle().set(t)}},u.each(["locked","visible","blendMode","opacity","guide"],function(t){var e=u.capitalize(t),n="_"+t,i={locked:128,visible:137};this["get"+e]=function(){return this[n]},this["set"+e]=function(e){e!=this[n]&&(this[n]=e,this._changed(i[t]||129))}},{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(t){if(t!==this._selection){this._selection=t;var e=this._project;e&&(e._updateSelection(this),this._changed(129))}},_changeSelection:function(t,e){var n=this._selection;this.setSelection(e?n|t:n&~t)},isSelected:function(){if(this._selectChildren)for(var t=this._children,e=0,n=t.length;e<n;e++)if(t[e].isSelected())return!0;return!!(1&this._selection)},setSelected:function(t){if(this._selectChildren)for(var e=this._children,n=0,i=e.length;n<i;n++)e[n].setSelected(t);this._changeSelection(1,t)},isFullySelected:function(){var t=this._children,e=!!(1&this._selection);if(t&&e){for(var n=0,i=t.length;n<i;n++)if(!t[n].isFullySelected())return!1;return!0}return e},setFullySelected:function(t){var e=this._children;if(e)for(var n=0,i=e.length;n<i;n++)e[n].setFullySelected(t);this._changeSelection(1,t)},isClipMask:function(){return this._clipMask},setClipMask:function(t){this._clipMask!=(t=!!t)&&(this._clipMask=t,t&&(this.setFillColor(null),this.setStrokeColor(null)),this._changed(129),this._parent&&this._parent._changed(1024))},getData:function(){return this._data||(this._data={}),this._data},setData:function(t){this._data=t},getPosition:function(t){var e=this._position,n=t?p:m;if(!e){var i=this._pivot;e=this._position=i?this._matrix._transformPoint(i):this.getBounds().getCenter(!0)}return new n(e.x,e.y,this,"setPosition")},setPosition:function(){this.translate(p.read(arguments).subtract(this.getPosition(!0)))},getPivot:function(){var t=this._pivot;return t?new m(t.x,t.y,this,"setPivot"):null},setPivot:function(){this._pivot=p.read(arguments,0,{clone:!0,readNull:!0}),this._position=o}},u.each({getStrokeBounds:{stroke:!0},getHandleBounds:{handle:!0},getInternalBounds:{internal:!0}},function(t,e){this[e]=function(e){return this.getBounds(e,t)}},{beans:!0,getBounds:function(t,e){var n=e||t instanceof C,i=u.set({},n?e:t,this._boundsOptions);i.stroke&&!this.getStrokeScaling()||(i.cacheItem=this);var r=this._getCachedBounds(n&&t,i).rect;return arguments.length?r:new b(r.x,r.y,r.width,r.height,this,"setBounds")},setBounds:function(){var t=x.read(arguments),e=this.getBounds(),n=this._matrix,i=new C,r=t.getCenter();i.translate(r),t.width==e.width&&t.height==e.height||(n.isInvertible()||(n.set(n._backup||(new C).translate(n.getTranslation())),e=this.getBounds()),i.scale(0!==e.width?t.width/e.width:0,0!==e.height?t.height/e.height:0)),r=e.getCenter(),i.translate(-r.x,-r.y),this.transform(i)},_getBounds:function(t,e){var n=this._children;return n&&n.length?(P._updateBoundsCache(this,e.cacheItem),P._getBounds(n,t,e)):new x},_getBoundsCacheKey:function(t,e){return[t.stroke?1:0,t.handle?1:0,e?1:0].join("")},_getCachedBounds:function(t,e,n){t=t&&t._orNullIfIdentity();var i=e.internal&&!n,r=e.cacheItem,s=i?null:this._matrix._orNullIfIdentity(),a=r&&(!t||t.equals(s))&&this._getBoundsCacheKey(e,i),o=this._bounds,h;if(P._updateBoundsCache(this._parent||this._symbol,r),a&&o&&a in o)return{rect:(h=o[a]).rect.clone(),nonscaling:h.nonscaling};var l=this._getBounds(t||s,e),u=l.rect||l,c=this._style,d=l.nonscaling||c.hasStroke()&&!c.getStrokeScaling();if(a){o||(this._bounds=o={});var h=o[a]={rect:u.clone(),nonscaling:d,internal:i}}return{rect:u,nonscaling:d}},_getStrokeMatrix:function(t,e){var n=this.getStrokeScaling()?null:e&&e.internal?this:this._parent||this._symbol&&this._symbol._item,i=n?n.getViewMatrix().invert():t;return i&&i._shiftless()},statics:{_updateBoundsCache:function(t,e){if(t&&e){var n=e._id,i=t._boundsCache=t._boundsCache||{ids:{},list:[]};i.ids[n]||(i.list.push(e),i.ids[n]=e)}},_clearBoundsCache:function(t){var e=t._boundsCache;if(e){t._bounds=t._position=t._boundsCache=o;for(var n=0,i=e.list,r=i.length;n<r;n++){var s=i[n];s!==t&&(s._bounds=s._position=o,s._boundsCache&&P._clearBoundsCache(s))}}},_getBounds:function(t,e,n){var i=1/0,r=-i,s=i,a=r,o=!1;n=n||{};for(var h=0,l=t.length;h<l;h++){var u=t[h];if(u._visible&&!u.isEmpty()){var c=u._getCachedBounds(e&&e.appended(u._matrix),n,!0),d=c.rect;i=Math.min(d.x,i),s=Math.min(d.y,s),r=Math.max(d.x+d.width,r),a=Math.max(d.y+d.height,a),c.nonscaling&&(o=!0)}}return{rect:isFinite(i)?new x(i,s,r-i,a-s):new x,nonscaling:o}}}}),{beans:!0,_decompose:function(){return this._applyMatrix?null:this._decomposed||(this._decomposed=this._matrix.decompose())},getRotation:function(){var t=this._decompose();return t?t.rotation:0},setRotation:function(t){var e=this.getRotation();if(null!=e&&null!=t){var n=this._decomposed;this.rotate(t-e),n&&(n.rotation=t,this._decomposed=n)}},getScaling:function(){var t=this._decompose(),e=t&&t.scaling;return new m(e?e.x:1,e?e.y:1,this,"setScaling")},setScaling:function(){var t=this.getScaling(),e=p.read(arguments,0,{clone:!0,readNull:!0});if(t&&e&&!t.equals(e)){var n=this.getRotation(),i=this._decomposed,r=new C,s=this.getPosition(!0);r.translate(s),n&&r.rotate(n),r.scale(e.x/t.x,e.y/t.y),n&&r.rotate(-n),r.translate(s.negate()),this.transform(r),i&&(i.scaling=e,this._decomposed=i)}},getMatrix:function(){return this._matrix},setMatrix:function(){var t=this._matrix;t.initialize.apply(t,arguments)},getGlobalMatrix:function(t){var e=this._globalMatrix,n=this._project._updateVersion;if(e&&e._updateVersion!==n&&(e=null),!e){e=this._globalMatrix=this._matrix.clone();var i=this._parent;i&&e.prepend(i.getGlobalMatrix(!0)),e._updateVersion=n}return t?e:e.clone()},getViewMatrix:function(){return this.getGlobalMatrix().prepend(this.getView()._matrix)},getApplyMatrix:function(){return this._applyMatrix},setApplyMatrix:function(t){(this._applyMatrix=this._canApplyMatrix&&!!t)&&this.transform(null,!0)},getTransformContent:"#getApplyMatrix",setTransformContent:"#setApplyMatrix"},{getProject:function(){return this._project},_setProject:function(t,e){if(this._project!==t){this._project&&this._installEvents(!1),this._project=t;for(var n=this._children,i=0,r=n&&n.length;i<r;i++)n[i]._setProject(t);e=!0}e&&this._installEvents(!0)},getView:function(){return this._project._view},_installEvents:function t(e){t.base.call(this,e);for(var n=this._children,i=0,r=n&&n.length;i<r;i++)n[i]._installEvents(e)},getLayer:function(){for(var t=this;t=t._parent;)if(t instanceof I)return t;return null},getParent:function(){return this._parent},setParent:function(t){return t.addChild(this)},_getOwner:"#getParent",getChildren:function(){return this._children},setChildren:function(t){this.removeChildren(),this.addChildren(t)},getFirstChild:function(){return this._children&&this._children[0]||null},getLastChild:function(){return this._children&&this._children[this._children.length-1]||null},getNextSibling:function(){var t=this._getOwner();return t&&t._children[this._index+1]||null},getPreviousSibling:function(){var t=this._getOwner();return t&&t._children[this._index-1]||null},getIndex:function(){return this._index},equals:function(t){return t===this||t&&this._class===t._class&&this._style.equals(t._style)&&this._matrix.equals(t._matrix)&&this._locked===t._locked&&this._visible===t._visible&&this._blendMode===t._blendMode&&this._opacity===t._opacity&&this._clipMask===t._clipMask&&this._guide===t._guide&&this._equals(t)||!1},_equals:function(t){return u.equals(this._children,t._children)},clone:function(t){var e=new this.constructor(P.NO_INSERT),n=this._children,i=u.pick(t?t.insert:o,t===o||!0===t),r=u.pick(t?t.deep:o,!0);n&&e.copyAttributes(this),n&&!r||e.copyContent(this),n||e.copyAttributes(this),i&&e.insertAbove(this);var s=this._name,a=this._parent;if(s&&a){for(var n=a._children,h=s,l=1;n[s];)s=h+" "+l++;s!==h&&e.setName(s)}return e},copyContent:function(t){for(var e=t._children,n=0,i=e&&e.length;n<i;n++)this.addChild(e[n].clone(!1),!0)},copyAttributes:function(t,e){this.setStyle(t._style);for(var n=["_locked","_visible","_blendMode","_opacity","_clipMask","_guide"],i=0,r=n.length;i<r;i++){var s=n[i];t.hasOwnProperty(s)&&(this[s]=t[s])}e||this._matrix.set(t._matrix,!0),this.setApplyMatrix(t._applyMatrix),this.setPivot(t._pivot),this.setSelection(t._selection);var a=t._data,o=t._name;this._data=a?u.clone(a):null,o&&this.setName(o)},rasterize:function(t,e){var n=this.getStrokeBounds(),i=(t||this.getView().getResolution())/72,r=n.getTopLeft().floor(),s=n.getBottomRight().ceil(),a=new y(s.subtract(r)),h=new T(P.NO_INSERT);if(!a.isZero()){var l=at.getCanvas(a.multiply(i)),c=l.getContext("2d"),d=(new C).scale(i).translate(r.negate());c.save(),d.applyToContext(c),this.draw(c,new u({matrices:[d]})),c.restore(),h.setCanvas(l)}return h.transform((new C).translate(r.add(a.divide(2))).scale(1/i)),(e===o||e)&&h.insertAbove(this),h},contains:function(){return!!this._contains(this._matrix._inverseTransform(p.read(arguments)))},_contains:function(t){var e=this._children;if(e){for(var n=e.length-1;n>=0;n--)if(e[n].contains(t))return!0;return!1}return t.isInside(this.getInternalBounds())},isInside:function(){return x.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new D.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(t,e){return t instanceof P&&this._asPathItem().getIntersections(t._asPathItem(),null,e,!0).length>0}},new function(){function t(){return this._hitTest(p.read(arguments),L.getOptions(arguments))}function e(){var t=p.read(arguments),e=L.getOptions(arguments),n=[];return this._hitTest(t,u.set({all:n},e)),n}function n(t,e,n,i){var r=this._children;if(r)for(var s=r.length-1;s>=0;s--){var a=r[s],o=a!==i&&a._hitTest(t,e,n);if(o&&!e.all)return o}return null}return M.inject({hitTest:t,hitTestAll:e,_hitTest:n}),{hitTest:t,hitTestAll:e,_hitTestChildren:n}},{_hitTest:function(t,e,n){if(this._locked||!this._visible||this._guide&&!e.guides||this.isEmpty())return null;var i=this._matrix,r=n?n.appended(i):this.getGlobalMatrix().prepend(this.getView()._matrix),s=Math.max(e.tolerance,1e-12),a=e._tolerancePadding=new y(D._getStrokePadding(s,i._shiftless().invert()));if(!(t=i._inverseTransform(t))||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(a.multiply(2))._containsPoint(t))return null;var o=!(e.guides&&!this._guide||e.selected&&!this.isSelected()||e.type&&e.type!==u.hyphenate(this._class)||e.class&&!(this instanceof e.class)),h=e.match,l=this,c,d;function f(t){return t&&h&&!h(t)&&(t=null),t&&e.all&&e.all.push(t),t}function _(e,n){var i=n?c["get"+n]():l.getPosition();if(t.subtract(i).divide(a).length<=1)return new L(e,l,{name:n?u.hyphenate(n):e,point:i})}var g=e.position,v=e.center,p=e.bounds;if(o&&this._parent&&(g||v||p)){if((v||p)&&(c=this.getInternalBounds()),!(d=g&&_("position")||v&&_("center","Center"))&&p)for(var m=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],w=0;w<8&&!d;w++)d=_("bounds",m[w]);d=f(d)}return d||(d=this._hitTestChildren(t,e,r)||o&&f(this._hitTestSelf(t,e,r,this.getStrokeScaling()?null:r._shiftless().invert()))||null),d&&d.point&&(d.point=i.transform(d.point)),d},_hitTestSelf:function(t,e){if(e.fill&&this.hasFill()&&this._contains(t))return new L("fill",this)},matches:function(t,e){function n(t,e){for(var i in t)if(t.hasOwnProperty(i)){var r=t[i],s=e[i];if(u.isPlainObject(r)&&u.isPlainObject(s)){if(!n(r,s))return!1}else if(!u.equals(r,s))return!1}return!0}var i=typeof t;if("object"===i){for(var r in t)if(t.hasOwnProperty(r)&&!this.matches(r,t[r]))return!1;return!0}if("function"===i)return t(this);if("match"===t)return e(this);var s=/^(empty|editable)$/.test(t)?this["is"+u.capitalize(t)]():"type"===t?u.hyphenate(this._class):this[t];if("class"===t){if("function"==typeof e)return this instanceof e;s=this._class}if("function"==typeof e)return!!e(s);if(e){if(e.test)return e.test(s);if(u.isPlainObject(e))return n(e,s)}return u.equals(s,e)},getItems:function(t){return P._getItems(this,t,this._matrix)},getItem:function(t){return P._getItems(this,t,this._matrix,null,!0)[0]||null},statics:{_getItems:function t(e,n,i,r,s){if(!r){var a="object"==typeof n&&n,o=a&&a.overlapping,h=a&&a.inside,l,c=(l=o||h)&&x.read([l]);r={items:[],recursive:a&&!1!==a.recursive,inside:!!h,overlapping:!!o,rect:c,path:o&&new D.Rectangle({rectangle:c,insert:!1})},a&&(n=u.filter({},n,{recursive:!0,inside:!0,overlapping:!0}))}var d=e._children,f=r.items,c;i=(c=r.rect)&&(i||new C);for(var _=0,g=d&&d.length;_<g;_++){var v=d[_],p=i&&i.appended(v._matrix),m=!0;if(c){var l=v.getBounds(p);if(!c.intersects(l))continue;c.contains(l)||r.overlapping&&(l.contains(c)||r.path.intersects(v,p))||(m=!1)}if(m&&v.matches(n)&&(f.push(v),s))break;if(!1!==r.recursive&&t(v,n,p,r,s),s&&f.length>0)break}return f}}},{importJSON:function(t){var e=u.importJSON(t,this);return e!==this?this.addChild(e):e},addChild:function(t){return this.insertChild(o,t)},insertChild:function(t,e){var n=e?this.insertChildren(t,[e]):null;return n&&n[0]},addChildren:function(t){return this.insertChildren(this._children.length,t)},insertChildren:function(t,e){var n=this._children;if(n&&e&&e.length>0){for(var i={},r=(e=u.slice(e)).length-1;r>=0;r--){var s,a=(s=e[r])&&s._id;!s||i[a]?e.splice(r,1):(s._remove(!1,!0),i[a]=!0)}u.splice(n,e,t,0);for(var o=this._project,h=o._changes,r=0,l=e.length;r<l;r++){var s,c=(s=e[r])._name;s._parent=this,s._setProject(o,!0),c&&s.setName(c),h&&s._changed(5)}this._changed(11)}else e=null;return e},_insertItem:"#insertChild",_insertAt:function(t,e){var n=t&&t._getOwner(),i=t!==this&&n?this:null;return i&&(i._remove(!1,!0),n._insertItem(t._index+e,i)),i},insertAbove:function(t){return this._insertAt(t,1)},insertBelow:function(t){return this._insertAt(t,0)},sendToBack:function(){var t=this._getOwner();return t?t._insertItem(0,this):null},bringToFront:function(){var t=this._getOwner();return t?t._insertItem(o,this):null},appendTop:"#addChild",appendBottom:function(t){return this.insertChild(0,t)},moveAbove:"#insertAbove",moveBelow:"#insertBelow",addTo:function(t){return t._insertItem(o,this)},copyTo:function(t){return this.clone(!1).addTo(t)},reduce:function(t){var e=this._children;if(e&&1===e.length){var n=e[0].reduce(t);return this._parent?(n.insertAbove(this),this.remove()):n.remove(),n}return this},_removeNamed:function(){var t=this._getOwner();if(t){var e=t._children,n=t._namedChildren,i=this._name,r=n[i],s=r?r.indexOf(this):-1;-1!==s&&(e[i]==this&&delete e[i],r.splice(s,1),r.length?e[i]=r[0]:delete n[i])}},_remove:function(t,e){var n=this._getOwner(),i=this._project,r=this._index;return!!n&&(this._name&&this._removeNamed(),null!=r&&(i._activeLayer===this&&(i._activeLayer=this.getNextSibling()||this.getPreviousSibling()),u.splice(n._children,null,r,1)),this._installEvents(!1),t&&i._changes&&this._changed(5),e&&n._changed(11,this),this._parent=null,!0)},remove:function(){return this._remove(!0,!0)},replaceWith:function(t){var e=t&&t.insertBelow(this);return e&&this.remove(),e},removeChildren:function(t,e){if(!this._children)return null;t=t||0,e=u.pick(e,this._children.length);for(var n=u.splice(this._children,null,t,e-t),i=n.length-1;i>=0;i--)n[i]._remove(!0,!1);return n.length>0&&this._changed(11),n},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var t=0,e=this._children.length;t<e;t++)this._children[t]._index=t;this._changed(11)}},isEmpty:function(){var t=this._children;return!t||!t.length},isEditable:function(){for(var t=this;t;){if(!t._visible||t._locked)return!1;t=t._parent}return!0},hasFill:function(){return this.getStyle().hasFill()},hasStroke:function(){return this.getStyle().hasStroke()},hasShadow:function(){return this.getStyle().hasShadow()},_getOrder:function(t){function e(t){var e=[];do{e.unshift(t)}while(t=t._parent);return e}for(var n=e(this),i=e(t),r=0,s=Math.min(n.length,i.length);r<s;r++)if(n[r]!=i[r])return n[r]._index<i[r]._index?1:-1;return 0},hasChildren:function(){return this._children&&this._children.length>0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(t){return-1===this._getOrder(t)},isBelow:function(t){return 1===this._getOrder(t)},isParent:function(t){return this._parent===t},isChild:function(t){return t&&t._parent===this},isDescendant:function(t){for(var e=this;e=e._parent;)if(e===t)return!0;return!1},isAncestor:function(t){return!!t&&t.isDescendant(this)},isSibling:function(t){return this._parent===t._parent},isGroupedWith:function(t){for(var e=this._parent;e;){if(e._parent&&/^(Group|Layer|CompoundPath)$/.test(e._class)&&t.isDescendant(e))return!0;e=e._parent}return!1}},u.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var n=(e?u:p).read(arguments),i=p.read(arguments,0,{readNull:!0});return this.transform((new C)[t](n,i||this.getPosition(!0)))}},{translate:function(){var t=new C;return this.transform(t.translate.apply(t,arguments))},transform:function(t,e,n,i){var r=this._matrix,s=t&&!t.isIdentity(),a=(e||this._applyMatrix)&&(!r.isIdentity()||s||e&&n&&this._children);if(!s&&!a)return this;if(s){!t.isInvertible()&&r.isInvertible()&&(r._backup=r.getValues()),r.prepend(t,!0);var o=this._style,h=o.getFillColor(!0),l=o.getStrokeColor(!0);h&&h.transform(t),l&&l.transform(t)}if(a&&(a=this._transformContent(r,n,i))){var u=this._pivot;u&&r._transformPoint(u,u,!0),r.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var c=this._bounds,d=this._position;(s||a)&&this._changed(9);var f=s&&c&&t.decompose();if(f&&f.skewing.isZero()&&f.rotation%90==0){for(var _ in c){var g=c[_];if(g.nonscaling)delete c[_];else if(a||!g.internal){var v=g.rect;t._transformBounds(v,v)}}this._bounds=c;var p=c[this._getBoundsCacheKey(this._boundsOptions||{})];p&&(this._position=p.rect.getCenter(!0))}else s&&d&&this._pivot&&(this._position=t._transformPoint(d,d));return this},_transformContent:function(t,e,n){var i=this._children;if(i){for(var r=0,s=i.length;r<s;r++)i[r].transform(t,!0,e,n);return!0}},globalToLocal:function(){return this.getGlobalMatrix(!0)._inverseTransform(p.read(arguments))},localToGlobal:function(){return this.getGlobalMatrix(!0)._transformPoint(p.read(arguments))},parentToLocal:function(){return this._matrix._inverseTransform(p.read(arguments))},localToParent:function(){return this._matrix._transformPoint(p.read(arguments))},fitBounds:function(t,e){t=x.read(arguments);var n=this.getBounds(),i=n.height/n.width,r=t.height/t.width,s=(e?i>r:i<r)?t.width/n.width:t.height/n.height,a=new x(new p,new y(n.width*s,n.height*s));a.setCenter(t.getCenter()),this.setBounds(a)}}),{_setStyles:function(t,e,n){var i=this._style,r=this._matrix;if(i.hasFill()&&(t.fillStyle=i.getFillColor().toCanvasStyle(t,r)),i.hasStroke()){t.strokeStyle=i.getStrokeColor().toCanvasStyle(t,r),t.lineWidth=i.getStrokeWidth();var a=i.getStrokeJoin(),o=i.getStrokeCap(),h=i.getMiterLimit();if(a&&(t.lineJoin=a),o&&(t.lineCap=o),h&&(t.miterLimit=h),s.support.nativeDash){var l=i.getDashArray(),u=i.getDashOffset();l&&l.length&&("setLineDash"in t?(t.setLineDash(l),t.lineDashOffset=u):(t.mozDash=l,t.mozDashOffset=u))}}if(i.hasShadow()){var c=e.pixelRatio||1,d=n._shiftless().prepend((new C).scale(c,c)),f=d.transform(new p(i.getShadowBlur(),0)),_=d.transform(this.getShadowOffset());t.shadowColor=i.getShadowColor().toCanvasStyle(t),t.shadowBlur=f.getLength(),t.shadowOffsetX=_.x,t.shadowOffsetY=_.y}},draw:function(t,e,n){var i=this._updateVersion=this._project._updateVersion;if(this._visible&&0!==this._opacity){var r=e.matrices,s=e.viewMatrix,a=this._matrix,o=r[r.length-1].appended(a);if(o.isInvertible()){s=s?s.appended(o):o,r.push(o),e.updateMatrix&&(o._updateVersion=i,this._globalMatrix=o);var h=this._blendMode,l=this._opacity,u="normal"===h,c=ot.nativeModes[h],d=u&&1===l||e.dontStart||e.clip||(c||u&&l<1)&&this._canComposite(),f=e.pixelRatio||1,_,g,v;if(!d){var p=this.getStrokeBounds(s);if(!p.width||!p.height)return;v=e.offset,g=e.offset=p.getTopLeft().floor(),_=t,t=at.getContext(p.getSize().ceil().add(1).multiply(f)),1!==f&&t.scale(f,f)}t.save();var m=n?n.appended(a):this._canScaleStroke&&!this.getStrokeScaling(!0)&&s,y=!d&&e.clipItem,w=!m||y;if(d?(t.globalAlpha=l,c&&(t.globalCompositeOperation=h)):w&&t.translate(-g.x,-g.y),w&&(d?a:s).applyToContext(t),y&&e.clipItem.draw(t,e.extend({clip:!0})),m){t.setTransform(f,0,0,f,0,0);var x=e.offset;x&&t.translate(-x.x,-x.y)}this._draw(t,e,s,m),t.restore(),r.pop(),e.clip&&!e.dontFinish&&t.clip(),d||(ot.process(h,t,_,l,g.subtract(v).multiply(f)),at.release(t),e.offset=v)}}},_isUpdated:function(t){var e=this._parent;if(e instanceof F)return e._isUpdated(t);var n=this._updateVersion===t;return!n&&e&&e._visible&&e._isUpdated(t)&&(this._updateVersion=t,n=!0),n},_drawSelection:function(t,e,n,i,r){var s=this._selection,a=1&s,o=2&s||a&&this._selectBounds,h=4&s;if(this._drawSelected||(a=!1),(a||o||h)&&this._isUpdated(r)){var l,u=this.getSelectedColor(!0)||(l=this.getLayer())&&l.getSelectedColor(!0),c=e.appended(this.getGlobalMatrix(!0)),d=n/2;if(t.strokeStyle=t.fillStyle=u?u.toCanvasStyle(t):"#009dec",a&&this._drawSelected(t,c,i),h){var f=this.getPosition(!0),_=f.x,g=f.y;t.beginPath(),t.arc(_,g,d,0,2*Math.PI,!0),t.stroke();for(var v=[[0,-1],[1,0],[0,1],[-1,0]],p=d,m=n+1,y=0;y<4;y++){var w=v[y],x=w[0],b=w[1];t.moveTo(_+x*p,g+b*p),t.lineTo(_+x*m,g+b*m),t.stroke()}}if(o){var C=c._transformCorners(this.getInternalBounds());t.beginPath();for(var y=0;y<8;y++)t[y?"lineTo":"moveTo"](C[y],C[++y]);t.closePath(),t.stroke();for(var y=0;y<8;y++)t.fillRect(C[y]-d,C[++y]-d,n,n)}}},_canComposite:function(){return!1}},u.each(["down","drag","up","move"],function(t){this["removeOn"+u.capitalize(t)]=function(){var e={};return e[t]=!0,this.removeOn(e)}},{removeOn:function(t){for(var e in t)if(t[e]){var n="mouse"+e,i=this._project,r=i._removeSets=i._removeSets||{};r[n]=r[n]||{},r[n][this._id]=this}return this}})),k=P.extend({_class:"Group",_selectBounds:!1,_selectChildren:!0,_serializeFields:{children:[]},initialize:function t(e){this._children=[],this._namedChildren={},this._initialize(e)||this.addChildren(Array.isArray(e)?e:arguments)},_changed:function t(e){t.base.call(this,e),1026&e&&(this._clipItem=o)},_getClipItem:function(){var t=this._clipItem;if(t===o){t=null;for(var e=this._children,n=0,i=e.length;n<i;n++)if(e[n]._clipMask){t=e[n];break}this._clipItem=t}return t},isClipped:function(){return!!this._getClipItem()},setClipped:function(t){var e=this.getFirstChild();e&&e.setClipMask(t)},_getBounds:function t(e,n){var i=this._getClipItem();return i?i._getCachedBounds(e&&e.appended(i._matrix),u.set({},n,{stroke:!1})):t.base.call(this,e,n)},_hitTestChildren:function t(e,n,i){var r=this._getClipItem();return(!r||r.contains(e))&&t.base.call(this,e,n,i,r)},_draw:function(t,e){var n=e.clip,i=!n&&this._getClipItem();e=e.extend({clipItem:i,clip:!1}),n?(t.beginPath(),e.dontStart=e.dontFinish=!0):i&&i.draw(t,e.extend({clip:!0}));for(var r=this._children,s=0,a=r.length;s<a;s++){var o=r[s];o!==i&&o.draw(t,e)}}}),I=k.extend({_class:"Layer",initialize:function t(){k.apply(this,arguments)},_getOwner:function(){return this._parent||null!=this._index&&this._project},isInserted:function t(){return this._parent?t.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_hitTestSelf:function(){}}),z=P.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_canScaleStroke:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function t(e,n){this._initialize(e,n)},_equals:function(t){return this._type===t._type&&this._size.equals(t._size)&&u.equals(this._radius,t._radius)},copyContent:function(t){this.setType(t._type),this.setSize(t._size),this.setRadius(t._radius)},getType:function(){return this._type},setType:function(t){this._type=t},getShape:"#getType",setShape:"#setType",getSize:function(){var t=this._size;return new w(t.width,t.height,this,"setSize")},setSize:function(){var t=y.read(arguments);if(this._size){if(!this._size.equals(t)){var e=this._type,n=t.width,i=t.height;"rectangle"===e?this._radius.set(y.min(this._radius,t.divide(2))):"circle"===e?(n=i=(n+i)/2,this._radius=n/2):"ellipse"===e&&this._radius._set(n/2,i/2),this._size._set(n,i),this._changed(9)}}else this._size=t.clone()},getRadius:function(){var t=this._radius;return"circle"===this._type?t:new w(t.width,t.height,this,"setRadius")},setRadius:function(t){var e=this._type;if("circle"===e){if(t===this._radius)return;var n=2*t;this._radius=t,this._size._set(n,n)}else if(t=y.read(arguments),this._radius){if(this._radius.equals(t))return;if(this._radius.set(t),"rectangle"===e){var n=y.max(this._size,t.multiply(2));this._size.set(n)}else"ellipse"===e&&this._size._set(2*t.width,2*t.height)}else this._radius=t.clone();this._changed(9)},isEmpty:function(){return!1},toPath:function(t){var e=new(D[u.capitalize(this._type)])({center:new p,size:this._size,radius:this._radius,insert:!1});return e.copyAttributes(this),s.settings.applyMatrix&&e.setApplyMatrix(!0),(t===o||t)&&e.insertAbove(this),e},toShape:"#clone",_asPathItem:function(){return this.toPath(!1)},_draw:function(t,e,n,i){var r=this._style,s=r.hasFill(),a=r.hasStroke(),o=e.dontFinish||e.clip,h=!i;if(s||a||o){var l=this._type,u=this._radius,c="circle"===l;if(e.dontStart||t.beginPath(),h&&c)t.arc(0,0,u,0,2*Math.PI,!0);else{var d=c?u:u.width,f=c?u:u.height,_=this._size,g=_.width,v=_.height;if(h&&"rectangle"===l&&0===d&&0===f)t.rect(-g/2,-v/2,g,v);else{var p=g/2,m=v/2,y=.44771525016920644,w=d*y,x=f*y,b=[-p,-m+f,-p,-m+x,-p+w,-m,-p+d,-m,p-d,-m,p-w,-m,p,-m+x,p,-m+f,p,m-f,p,m-x,p-w,m,p-d,m,-p+d,m,-p+w,m,-p,m-x,-p,m-f];i&&i.transform(b,b,32),t.moveTo(b[0],b[1]),t.bezierCurveTo(b[2],b[3],b[4],b[5],b[6],b[7]),p!==d&&t.lineTo(b[8],b[9]),t.bezierCurveTo(b[10],b[11],b[12],b[13],b[14],b[15]),m!==f&&t.lineTo(b[16],b[17]),t.bezierCurveTo(b[18],b[19],b[20],b[21],b[22],b[23]),p!==d&&t.lineTo(b[24],b[25]),t.bezierCurveTo(b[26],b[27],b[28],b[29],b[30],b[31])}}t.closePath()}o||!s&&!a||(this._setStyles(t,e,n),s&&(t.fill(r.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),a&&t.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(t,e){var n=new x(this._size).setCenter(0,0),i=this._style,r=e.stroke&&i.hasStroke()&&i.getStrokeWidth();return t&&(n=t._transformBounds(n)),r?n.expand(D._getStrokePadding(r,this._getStrokeMatrix(t,e))):n}},new function(){function t(t,e,n){var i=t._radius;if(!i.isZero())for(var r=t._size.divide(2),s=1;s<=4;s++){var a=new p(s>1&&s<4?-1:1,s>2?-1:1),o=a.multiply(r),h=o.subtract(a.multiply(i)),l;if(new x(n?o.add(a.multiply(n)):o,h).contains(e))return{point:h,quadrant:s}}}function e(t,e,n,i){var r=t.divide(e);return(!i||r.isInQuadrant(i))&&r.subtract(r.normalize()).multiply(e).divide(n).length<=1}return{_contains:function e(n){if("rectangle"===this._type){var i=t(this,n);return i?n.subtract(i.point).divide(this._radius).getLength()<=1:e.base.call(this,n)}return n.divide(this.size).getLength()<=.5},_hitTestSelf:function n(i,r,s,a){var o=!1,h=this._style,l=r.stroke&&h.hasStroke(),u=r.fill&&h.hasFill();if(l||u){var c=this._type,d=this._radius,f=l?h.getStrokeWidth()/2:0,_=r._tolerancePadding.add(D._getStrokePadding(f,!h.getStrokeScaling()&&a));if("rectangle"===c){var g=_.multiply(2),v=t(this,i,g);if(v)o=e(i.subtract(v.point),d,_,v.quadrant);else{var p=new x(this._size).setCenter(0,0),m=p.expand(g),y=p.expand(g.negate());o=m._containsPoint(i)&&!y._containsPoint(i)}}else o=e(i,d,_)}return o?new L(l?"stroke":"fill",this):n.base.apply(this,arguments)}}},{statics:new function(){function t(t,e,n,i,r){var s=new z(u.getNamed(r),e);return s._type=t,s._size=n,s._radius=i,s}return{Circle:function(){var e=p.readNamed(arguments,"center"),n=u.readNamed(arguments,"radius");return t("circle",e,new y(2*n),n,arguments)},Rectangle:function(){var e=x.readNamed(arguments,"rectangle"),n=y.min(y.readNamed(arguments,"radius"),e.getSize(!0).divide(2));return t("rectangle",e.getCenter(!0),e.getSize(!0),n,arguments)},Ellipse:function(){var e=z._readEllipse(arguments),n=e.radius;return t("ellipse",e.center,n.multiply(2),n,arguments)},_readEllipse:function(t){var e,n;if(u.hasNamed(t,"radius"))e=p.readNamed(t,"center"),n=y.readNamed(t,"radius");else{var i=x.readNamed(t,"rectangle");e=i.getCenter(!0),n=i.getSize(!0).divide(2)}return{center:e,radius:n}}}}}),T=P.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],initialize:function t(e,n){if(!this._initialize(e,n!==o&&p.read(arguments,1))){var i="string"==typeof e?l.getElementById(e):e;i?this.setImage(i):this.setSource(e)}this._size||(this._size=new y,this._loaded=!1)},_equals:function(t){return this.getSource()===t.getSource()},copyContent:function(t){var e=t._image,n=t._canvas;if(e)this._setImage(e);else if(n){var i=at.getCanvas(t._size);i.getContext("2d").drawImage(n,0,0),this._setImage(i)}this._crossOrigin=t._crossOrigin},getSize:function(){var t=this._size;return new w(t?t.width:0,t?t.height:0,this,"setSize")},setSize:function(){var t=y.read(arguments);if(!t.equals(this._size))if(t.width>0&&t.height>0){var e=this.getElement();this._setImage(at.getCanvas(t)),e&&this.getContext(!0).drawImage(e,0,0,t.width,t.height)}else this._canvas&&at.release(this._canvas),this._size=t.clone()},getWidth:function(){return this._size?this._size.width:0},setWidth:function(t){this.setSize(t,this.getHeight())},getHeight:function(){return this._size?this._size.height:0},setHeight:function(t){this.setSize(this.getWidth(),t)},getLoaded:function(){return this._loaded},isEmpty:function(){var t=this._size;return!t||0===t.width&&0===t.height},getResolution:function(){var t=this._matrix,e=new p(0,0).transform(t),n=new p(1,0).transform(t).subtract(e),i=new p(0,1).transform(t).subtract(e);return new y(72/n.getLength(),72/i.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(t){var e=this;function n(t){var n=e.getView(),i=t&&t.type||"load";n&&e.responds(i)&&(s=n._scope,e.emit(i,new Q(t)))}this._setImage(t),this._loaded?setTimeout(n,0):t&&K.add(t,{load:function(i){e._setImage(t),n(i)},error:n})},_setImage:function(t){this._canvas&&at.release(this._canvas),t&&t.getContext?(this._image=null,this._canvas=t,this._loaded=!0):(this._image=t,this._canvas=null,this._loaded=!!(t&&t.src&&t.complete)),this._size=new y(t?t.naturalWidth||t.width:0,t?t.naturalHeight||t.height:0),this._context=null,this._changed(521)},getCanvas:function(){if(!this._canvas){var t=at.getContext(this._size);try{this._image&&t.drawImage(this._image,0,0),this._canvas=t.canvas}catch(e){at.release(t)}}return this._canvas},setCanvas:"#setImage",getContext:function(t){return this._context||(this._context=this.getCanvas().getContext("2d")),t&&(this._image=null,this._changed(513)),this._context},setContext:function(t){this._context=t},getSource:function(){var t=this._image;return t&&t.src||this.toDataURL()},setSource:function(t){var e=new a.Image,n=this._crossOrigin;n&&(e.crossOrigin=n),e.src=t,this.setImage(e)},getCrossOrigin:function(){var t=this._image;return t&&t.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(t){this._crossOrigin=t;var e=this._image;e&&(e.crossOrigin=t)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var t=x.read(arguments),e=at.getContext(t.getSize());return e.drawImage(this.getCanvas(),t.x,t.y,t.width,t.height,0,0,t.width,t.height),e.canvas},getSubRaster:function(){var t=x.read(arguments),e=new T(P.NO_INSERT);return e._setImage(this.getSubCanvas(t)),e.translate(t.getCenter().subtract(this.getSize().divide(2))),e._matrix.prepend(this._matrix),e.insertAbove(this),e},toDataURL:function(){var t=this._image,e=t&&t.src;if(/^data:/.test(e))return e;var n=this.getCanvas();return n?n.toDataURL.apply(n,arguments):null},drawImage:function(t){var e=p.read(arguments,1);this.getContext(!0).drawImage(t,e.x,e.y)},getAverageColor:function(t){var e,n;if(t?t instanceof R?(n=t,e=t.getBounds()):"object"==typeof t&&("width"in t?e=new x(t):"x"in t&&(e=new x(t.x-.5,t.y-.5,1,1))):e=this.getBounds(),!e)return null;var i=32,r=Math.min(e.width,32),s=Math.min(e.height,32),a=T._sampleContext;a?a.clearRect(0,0,33,33):a=T._sampleContext=at.getContext(new y(32)),a.save();var o=(new C).scale(r/e.width,s/e.height).translate(-e.x,-e.y);o.applyToContext(a),n&&n.draw(a,new u({clip:!0,matrices:[o]})),this._matrix.applyToContext(a);var h=this.getElement(),l=this._size;h&&a.drawImage(h,-l.width/2,-l.height/2),a.restore();for(var c=a.getImageData(.5,.5,Math.ceil(r),Math.ceil(s)).data,d=[0,0,0],f=0,_=0,g=c.length;_<g;_+=4){var v=c[_+3];f+=v,v/=255,d[0]+=c[_]*v,d[1]+=c[_+1]*v,d[2]+=c[_+2]*v}for(var _=0;_<3;_++)d[_]/=f;return f?U.read(d):null},getPixel:function(){var t=p.read(arguments),e=this.getContext().getImageData(t.x,t.y,1,1).data;return new U("rgb",[e[0]/255,e[1]/255,e[2]/255],e[3]/255)},setPixel:function(){var t=p.read(arguments),e=U.read(arguments),n=e._convert("rgb"),i=e._alpha,r=this.getContext(!0),s=r.createImageData(1,1),a=s.data;a[0]=255*n[0],a[1]=255*n[1],a[2]=255*n[2],a[3]=null!=i?255*i:255,r.putImageData(s,t.x,t.y)},createImageData:function(){var t=y.read(arguments);return this.getContext().createImageData(t.width,t.height)},getImageData:function(){var t=x.read(arguments);return t.isEmpty()&&(t=new x(this._size)),this.getContext().getImageData(t.x,t.y,t.width,t.height)},setImageData:function(t){var e=p.read(arguments,1);this.getContext(!0).putImageData(t,e.x,e.y)},_getBounds:function(t,e){var n=new x(this._size).setCenter(0,0);return t?t._transformBounds(n):n},_hitTestSelf:function(t){if(this._contains(t)){var e=this;return new L("pixel",e,{offset:t.add(e._size.divide(2)).round(),color:{get:function(){return e.getPixel(this.offset)}}})}},_draw:function(t){var e=this.getElement();e&&(t.globalAlpha=this._opacity,t.drawImage(e,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),O=P.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function t(e,n){this._initialize(e,n!==o&&p.read(arguments,1))||this.setDefinition(e instanceof A?e:new A(e))},_equals:function(t){return this._definition===t._definition},copyContent:function(t){this.setDefinition(t._definition)},getDefinition:function(){return this._definition},setDefinition:function(t){this._definition=t,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(t,e){var n=this._definition._item;return n._getCachedBounds(n._matrix.prepended(t),e)},_hitTestSelf:function(t,e,n){var i=this._definition._item._hitTest(t,e,n);return i&&(i.item=this),i},_draw:function(t,e){this._definition._item.draw(t,e)}}),A=u.extend({_class:"SymbolDefinition",initialize:function t(e,n){this._id=v.get(),this.project=s.project,e&&this.setItem(e,n)},_serialize:function(t,e){return e.add(this,function(){return u.serialize([this._class,this._item],t,!1,e)})},_changed:function(t){8&t&&P._clearBoundsCache(this),1&t&&this.project._changed(t)},getItem:function(){return this._item},setItem:function(t,e){t._symbol&&(t=t.clone()),this._item&&(this._item._symbol=null),this._item=t,t.remove(),t.setSelected(!1),e||t.setPosition(new p),t._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(t){return new O(this,t)},clone:function(){return new A(this._item.clone(!1))},equals:function(t){return t===this||t&&this._item.equals(t._item)||!1}}),L=u.extend({_class:"HitResult",initialize:function t(e,n,i){this.type=e,this.item=n,i&&this.inject(i)},statics:{getOptions:function(t){var e=t&&u.read(t);return u.set({type:null,tolerance:s.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),E=u.extend({_class:"Segment",beans:!0,_selection:0,initialize:function t(e,n,i,r,s,a){var h=arguments.length,l,u,c,d;h>0&&(null==e||"object"==typeof e?1===h&&e&&"point"in e?(l=e.point,u=e.handleIn,c=e.handleOut,d=e.selection):(l=e,u=n,c=i,d=r):(l=[e,n],u=i!==o?[i,r]:null,c=s!==o?[s,a]:null)),new N(l,this,"_point"),new N(u,this,"_handleIn"),new N(c,this,"_handleOut"),d&&this.setSelection(d)},_serialize:function(t,e){var n=this._point,i=this._selection,r=i||this.hasHandles()?[n,this._handleIn,this._handleOut]:n;return i&&r.push(i),u.serialize(r,t,!0,e)},_changed:function(t){var e=this._path;if(e){var n=e._curves,i=this._index,r;n&&(t&&t!==this._point&&t!==this._handleIn||!(r=i>0?n[i-1]:e._closed?n[n.length-1]:null)||r._changed(),t&&t!==this._point&&t!==this._handleOut||!(r=n[i])||r._changed()),e._changed(25)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(p.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(p.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(p.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var t=this._handleIn,e=this._handleOut;return!t.isZero()&&!e.isZero()&&t.isCollinear(e)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(t){var e=this._selection,n=this._path;this._selection=t=t||0,n&&t!==e&&(n._updateSelection(this,e,t),n._changed(129))},_changeSelection:function(t,e){var n=this._selection;this.setSelection(e?n|t:n&~t)},isSelected:function(){return!!(7&this._selection)},setSelected:function(t){this._changeSelection(7,t)},getIndex:function(){return this._index!==o?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var t=this._path,e=this._index;return t?(e>0&&!t._closed&&e===t._segments.length-1&&e--,t.getCurves()[e]||null):null},getLocation:function(){var t=this.getCurve();return t?new j(t,this===t._segment1?0:1):null},getNext:function(){var t=this._path&&this._path._segments;return t&&(t[this._index+1]||this._path._closed&&t[0])||null},smooth:function(t,e,n){var i=t||{},r=i.type,s=i.factor,a=this.getPrevious(),h=this.getNext(),l=(a||this)._point,u=this._point,c=(h||this)._point,d=l.getDistance(u),f=u.getDistance(c);if(r&&"catmull-rom"!==r){if("geometric"!==r)throw new Error("Smoothing method '"+r+"' not supported.");if(a&&h){var _=l.subtract(c),g=s===o?.4:s,v=g*d/(d+f);e||this.setHandleIn(_.multiply(v)),n||this.setHandleOut(_.multiply(v-g))}}else{var m=s===o?.5:s,y=Math.pow(d,m),w=y*y,x=Math.pow(f,m),b=x*x;if(!e&&a){var C=2*b+3*x*y+w,S=3*x*(x+y);this.setHandleIn(0!==S?new p((b*l._x+C*u._x-w*c._x)/S-u._x,(b*l._y+C*u._y-w*c._y)/S-u._y):new p)}if(!n&&h){var C=2*w+3*y*x+b,S=3*y*(y+x);this.setHandleOut(0!==S?new p((w*c._x+C*u._x-b*l._x)/S-u._x,(w*c._y+C*u._y-b*l._y)/S-u._y):new p)}}},getPrevious:function(){var t=this._path&&this._path._segments;return t&&(t[this._index-1]||this._path._closed&&t[t.length-1])||null},isFirst:function(){return!this._index},isLast:function(){var t=this._path;return t&&this._index===t._segments.length-1||!1},reverse:function(){var t=this._handleIn,e=this._handleOut,n=t.clone();t.set(e),e.set(n)},reversed:function(){return new E(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new E(this._point,this._handleIn,this._handleOut)},equals:function(t){return t===this||t&&this._class===t._class&&this._point.equals(t._point)&&this._handleIn.equals(t._handleIn)&&this._handleOut.equals(t._handleOut)||!1},toString:function(){var t=["point: "+this._point];return this._handleIn.isZero()||t.push("handleIn: "+this._handleIn),this._handleOut.isZero()||t.push("handleOut: "+this._handleOut),"{ "+t.join(", ")+" }"},transform:function(t){this._transformCoordinates(t,new Array(6),!0),this._changed()},interpolate:function(t,e,n){var i=1-n,r=n,s=t._point,a=e._point,o=t._handleIn,h=e._handleIn,l=e._handleOut,u=t._handleOut;this._point._set(i*s._x+r*a._x,i*s._y+r*a._y,!0),this._handleIn._set(i*o._x+r*h._x,i*o._y+r*h._y,!0),this._handleOut._set(i*u._x+r*l._x,i*u._y+r*l._y,!0),this._changed()},_transformCoordinates:function(t,e,n){var i=this._point,r=n&&this._handleIn.isZero()?null:this._handleIn,s=n&&this._handleOut.isZero()?null:this._handleOut,a=i._x,o=i._y,h=2;return e[0]=a,e[1]=o,r&&(e[h++]=r._x+a,e[h++]=r._y+o),s&&(e[h++]=s._x+a,e[h++]=s._y+o),t&&(t._transformCoordinates(e,e,h/2),a=e[0],o=e[1],n?(i._x=a,i._y=o,h=2,r&&(r._x=e[h++]-a,r._y=e[h++]-o),s&&(s._x=e[h++]-a,s._y=e[h++]-o)):(r||(e[h++]=a,e[h++]=o),s||(e[h++]=a,e[h++]=o))),e}}),N=p.extend({initialize:function t(e,n,i){var r,s,a;if(e)if((r=e[0])!==o)s=e[1];else{var h=e;(r=h.x)===o&&(r=(h=p.read(arguments)).x),s=h.y,a=h.selected}else r=s=0;this._x=r,this._y=s,this._owner=n,n[i]=this,a&&this.setSelected(!0)},_set:function(t,e){return this._x=t,this._y=e,this._owner._changed(this),this},getX:function(){return this._x},setX:function(t){this._x=t,this._owner._changed(this)},getY:function(){return this._y},setY:function(t){this._y=t,this._owner._changed(this)},isZero:function(){var t=g.isZero;return t(this._x)&&t(this._y)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(t){this._owner._changeSelection(this._getSelection(),t)},_getSelection:function(){var t=this._owner;return this===t._point?1:this===t._handleIn?2:this===t._handleOut?4:0}}),B=u.extend({_class:"Curve",beans:!0,initialize:function t(e,n,i,r,s,a,o,h){var l=arguments.length,u,c,d,f,_,g;3===l?(this._path=e,u=n,c=i):l?1===l?"segment1"in e?(u=new E(e.segment1),c=new E(e.segment2)):"point1"in e?(d=e.point1,_=e.handle1,g=e.handle2,f=e.point2):Array.isArray(e)&&(d=[e[0],e[1]],f=[e[6],e[7]],_=[e[2]-e[0],e[3]-e[1]],g=[e[4]-e[6],e[5]-e[7]]):2===l?(u=new E(e),c=new E(n)):4===l?(d=e,_=n,g=i,f=r):8===l&&(d=[e,n],f=[o,h],_=[i-e,r-n],g=[s-o,a-h]):(u=new E,c=new E),this._segment1=u||new E(d,null,_),this._segment2=c||new E(f,g,null)},_serialize:function(t,e){return u.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],t,!0,e)},_changed:function(){this._length=this._bounds=o},clone:function(){return new B(this._segment1,this._segment2)},toString:function(){var t=["point1: "+this._segment1._point];return this._segment1._handleOut.isZero()||t.push("handle1: "+this._segment1._handleOut),this._segment2._handleIn.isZero()||t.push("handle2: "+this._segment2._handleIn),t.push("point2: "+this._segment2._point),"{ "+t.join(", ")+" }"},classify:function(){return B.classify(this.getValues())},remove:function(){var t=!1;if(this._path){var e=this._segment2,n=e._handleOut;(t=e.remove())&&this._segment1._handleOut.set(n)}return t},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(p.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(p.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(p.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(p.read(arguments))},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPath:function(){return this._path},getIndex:function(){return this._segment1._index},getNext:function(){var t=this._path&&this._path._curves;return t&&(t[this._segment1._index+1]||this._path._closed&&t[0])||null},getPrevious:function(){var t=this._path&&this._path._curves;return t&&(t[this._segment1._index-1]||this._path._closed&&t[t.length-1])||null},isFirst:function(){return!this._segment1._index},isLast:function(){var t=this._path;return t&&this._segment1._index===t._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle1().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(t){this.getPoint1().setSelected(t),this.getHandle1().setSelected(t),this.getHandle2().setSelected(t),this.getPoint2().setSelected(t)},getValues:function(t){return B.getValues(this._segment1,this._segment2,t)},getPoints:function(){for(var t=this.getValues(),e=[],n=0;n<8;n+=2)e.push(new p(t[n],t[n+1]));return e}},{getLength:function(){return null==this._length&&(this._length=B.getLength(this.getValues(),0,1)),this._length},getArea:function(){return B.getArea(this.getValues())},getLine:function(){return new S(this._segment1._point,this._segment2._point)},getPart:function(t,e){return new B(B.getPart(this.getValues(),t,e))},getPartLength:function(t,e){return B.getLength(this.getValues(),t,e)},divideAt:function(t){return this.divideAtTime(t&&t.curve===this?t.time:this.getTimeAt(t))},divideAtTime:function(t,e){var n=1e-8,i,r=null;if(t>=1e-8&&t<=1-1e-8){var s=B.subdivide(this.getValues(),t),a=s[0],o=s[1],h=e||this.hasHandles(),l=this._segment1,u=this._segment2,c=this._path;h&&(l._handleOut._set(a[2]-a[0],a[3]-a[1]),u._handleIn._set(o[4]-o[6],o[5]-o[7]));var d=a[6],f=a[7],_=new E(new p(d,f),h&&new p(a[4]-d,a[5]-f),h&&new p(o[2]-d,o[3]-f));c?(c.insert(l._index+1,_),r=this.getNext()):(this._segment2=_,this._changed(),r=new B(_,u))}return r},splitAt:function(t){var e=this._path;return e?e.splitAt(t):null},splitAtTime:function(t){return this.splitAt(this.getLocationAtTime(t))},divide:function(t,e){return this.divideAtTime(t===o?.5:e?t:this.getTimeAt(t))},split:function(t,e){return this.splitAtTime(t===o?.5:e?t:this.getTimeAt(t))},reversed:function(){return new B(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut._set(0,0),this._segment2._handleIn._set(0,0)},statics:{getValues:function(t,e,n,i){var r=t._point,s=t._handleOut,a=e._handleIn,o=e._point,h=r.x,l=r.y,u=o.x,c=o.y,d=i?[h,l,h,l,u,c,u,c]:[h,l,h+s._x,l+s._y,u+a._x,c+a._y,u,c];return n&&n._transformCoordinates(d,d,4),d},subdivide:function(t,e){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],h=t[5],l=t[6],u=t[7];e===o&&(e=.5);var c=1-e,d=c*n+e*r,f=c*i+e*s,_=c*r+e*a,g=c*s+e*h,v=c*a+e*l,p=c*h+e*u,m=c*d+e*_,y=c*f+e*g,w=c*_+e*v,x=c*g+e*p,b=c*m+e*w,C=c*y+e*x;return[[n,i,d,f,m,y,b,C],[b,C,w,x,v,p,l,u]]},getMonoCurves:function(t,e){var n=[],i=e?0:1,r=t[i+0],s=t[i+2],a=t[i+4],o=t[i+6];if(r>=s==s>=a&&s>=a==a>=o||B.isStraight(t))n.push(t);else{var h=3*(s-a)-r+o,l=2*(r+a)-4*s,u=s-r,c=1e-8,d=1-1e-8,f=[],_=g.solveQuadratic(h,l,u,f,1e-8,d);if(_){f.sort();var v=f[0],p=B.subdivide(t,v);n.push(p[0]),_>1&&(v=(f[1]-v)/(1-v),p=B.subdivide(p[1],v),n.push(p[0])),n.push(p[1])}else n.push(t)}return n},solveCubic:function(t,e,n,i,r,s){var a=t[e],o=t[e+2],h=t[e+4],l=t[e+6],u=0;if(!(a<n&&l<n&&o<n&&h<n||a>n&&l>n&&o>n&&h>n)){var c=3*(o-a),d=3*(h-o)-c,f=l-a-c-d;u=g.solveCubic(f,d,c,a-n,i,r,s)}return u},getTimeOf:function(t,e){var n=new p(t[0],t[1]),i=new p(t[6],t[7]),r=1e-12,s=1e-7,a;if(null===(e.isClose(n,1e-12)?0:e.isClose(i,1e-12)?1:null))for(var o=[e.x,e.y],h=[],l=0;l<2;l++)for(var u=B.solveCubic(t,l,o[l],h,0,1),c=0;c<u;c++){var d=h[c];if(e.isClose(B.getPoint(t,d),1e-7))return d}return e.isClose(n,1e-7)?0:e.isClose(i,1e-7)?1:null},getNearestTime:function(t,e){if(B.isStraight(t)){var n=t[0],i=t[1],r,s,a=t[6]-n,o=t[7]-i,h=a*a+o*o;if(0===h)return 0;var l=((e.x-n)*a+(e.y-i)*o)/h;return l<1e-12?0:l>.999999999999?1:B.getTimeOf(t,new p(n+l*a,i+l*o))}var u=100,c=1/0,d=0;function f(n){if(n>=0&&n<=1){var i=e.getDistance(B.getPoint(t,n),!0);if(i<c)return c=i,d=n,!0}}for(var _=0;_<=100;_++)f(_/100);for(var g=.005;g>1e-8;)f(d-g)||f(d+g)||(g/=2);return d},getPart:function(t,e,n){var i=e>n;if(i){var r=e;e=n,n=r}return e>0&&(t=B.subdivide(t,e)[1]),n<1&&(t=B.subdivide(t,(n-e)/(1-e))[0]),i?[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]]:t},isFlatEnough:function(t,e){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],h=t[6],l=t[7],u=3*r-2*n-h,c=3*s-2*i-l,d=3*a-2*h-n,f=3*o-2*l-i;return Math.max(u*u,d*d)+Math.max(c*c,f*f)<=16*e*e},getArea:function(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7];return 3*((h-n)*(i+s)-(o-e)*(r+a)+r*(e-s)-i*(n-a)+h*(s+e/3)-o*(a+n/3))/20},getBounds:function(t){for(var e=t.slice(0,2),n=e.slice(),i=[0,0],r=0;r<2;r++)B._addBounds(t[r],t[r+2],t[r+4],t[r+6],r,0,e,n,i);return new x(e[0],e[1],n[0]-e[0],n[1]-e[1])},_addBounds:function(t,e,n,i,r,s,a,o,h){function l(t,e){var n=t-e,i=t+e;n<a[r]&&(a[r]=n),i>o[r]&&(o[r]=i)}s/=2;var u=a[r]-s,c=o[r]+s;if(t<u||e<u||n<u||i<u||t>c||e>c||n>c||i>c)if(e<t!=e<i&&n<t!=n<i)l(t,s),l(i,s);else{var d=3*(e-n)-t+i,f=2*(t+n)-4*e,_=e-t,v=g.solveQuadratic(d,f,_,h),p=1e-8,m=1-1e-8;l(i,0);for(var y=0;y<v;y++){var w=h[y],x=1-w;1e-8<=w&&w<=m&&l(x*x*x*t+3*x*x*w*e+3*x*w*w*n+w*w*w*i,s)}}}}},u.each(["getBounds","getStrokeBounds","getHandleBounds"],function(t){this[t]=function(){this._bounds||(this._bounds={});var e=this._bounds[t];return e||(e=this._bounds[t]=D[t]([this._segment1,this._segment2],!1,this._path)),e.clone()}},{}),u.each({isStraight:function(t,e,n,i){if(e.isZero()&&n.isZero())return!0;var r=i.subtract(t);if(r.isZero())return!1;if(r.isCollinear(e)&&r.isCollinear(n)){var s=new S(t,i),a=1e-7;if(s.getDistance(t.add(e))<1e-7&&s.getDistance(i.add(n))<1e-7){var o=r.dot(r),h=r.dot(e)/o,l=r.dot(n)/o;return h>=0&&h<=1&&l<=0&&l>=-1}}return!1},isLinear:function(t,e,n,i){var r=i.subtract(t).divide(3);return e.equals(r)&&n.negate().equals(r)}},function(t,e){this[e]=function(e){var n=this._segment1,i=this._segment2;return t(n._point,n._handleOut,i._handleIn,i._point,e)},this.statics[e]=function(e,n){var i=e[0],r=e[1],s=e[6],a=e[7];return t(new p(i,r),new p(e[2]-i,e[3]-r),new p(e[4]-s,e[5]-a),new p(s,a),n)}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(t){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(t||0)},isCollinear:function(t){return t&&this.isStraight()&&t.isStraight()&&this.getLine().isCollinear(t.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).y)<1e-8},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).x)<1e-8}}),{beans:!1,getLocationAt:function(t,e){return this.getLocationAtTime(e?t:this.getTimeAt(t))},getLocationAtTime:function(t){return null!=t&&t>=0&&t<=1?new j(this,t):null},getTimeAt:function(t,e){return B.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(p.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return B.getTimeOf(this.getValues(),p.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=p.read(arguments),e=this.getValues(),n=B.getNearestTime(e,t),i=B.getPoint(e,n);return new j(this,n,i,null,t.getDistance(i))},getNearestPoint:function(){var t=this.getNearestLocation.apply(this,arguments);return t?t.getPoint():t}},new function(){var t=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return u.each(t,function(t){this[t+"At"]=function(e,n){var i=this.getValues();return B[t](i,n?e:B.getTimeAt(i,e))},this[t+"AtTime"]=function(e){return B[t](this.getValues(),e)}},{statics:{_evaluateMethods:t}})},new function(){function t(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o,h,l=9*(i-s)+3*(t[6]-e),u=6*(e+s)-12*i,c=3*(i-e),d=9*(r-a)+3*(t[7]-n),f=6*(n+a)-12*r,_=3*(r-n);return function(t){var e=(l*t+u)*t+c,n=(d*t+f)*t+_;return Math.sqrt(e*e+n*n)}}function e(t,e){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(e-t))))}function n(t,e,n,i){if(null==e||e<0||e>1)return null;var r=t[0],s=t[1],a=t[2],o=t[3],h=t[4],l=t[5],u=t[6],c=t[7],d=g.isZero;d(a-r)&&d(o-s)&&(a=r,o=s),d(h-u)&&d(l-c)&&(h=u,l=c);var f=3*(a-r),_=3*(h-a)-f,v=u-r-f-_,m=3*(o-s),y=3*(l-o)-m,w=c-s-m-y,x,b;if(0===n)x=0===e?r:1===e?u:((v*e+_)*e+f)*e+r,b=0===e?s:1===e?c:((w*e+y)*e+m)*e+s;else{var C=1e-8,S=1-1e-8;if(e<1e-8?(x=f,b=m):e>S?(x=3*(u-h),b=3*(c-l)):(x=(3*v*e+2*_)*e+f,b=(3*w*e+2*y)*e+m),i){0===x&&0===b&&(e<1e-8||e>S)&&(x=h-a,b=l-o);var M=Math.sqrt(x*x+b*b);M&&(x/=M,b/=M)}if(3===n){var h=6*v*e+2*_,l=6*w*e+2*y,P=Math.pow(x*x+b*b,1.5);x=0!==P?(x*l-b*h)/P:0,b=0}}return 2===n?new p(b,-x):new p(x,b)}return{statics:{classify:function(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],h=t[6],l=t[7],u,c=i*(n-l)+r*(h-e)+e*l-n*h,d,f=3*(s*(r-n)+a*(e-i)+i*n-r*e),_=f-c,v=_-c+(e*(l-a)+n*(s-h)+h*a-l*s),p=Math.sqrt(v*v+_*_+f*f),m=0!==p?1/p:0,y=g.isZero,w="serpentine";function x(t,e,n){var i=e!==o,r=i&&e>0&&e<1,s=i&&n>0&&n<1;return!i||(r||s)&&("loop"!==t||r&&s)||(t="arch",r=s=!1),{type:t,roots:r||s?r&&s?e<n?[e,n]:[n,e]:[r?e:n]:null}}if(_*=m,f*=m,y(v*=m))return y(_)?x(y(f)?"line":"quadratic"):x(w,f/(3*_));var b=3*_*_-4*v*f;if(y(b))return x("cusp",_/(2*v));var C=b>0?Math.sqrt(b/3):Math.sqrt(-b),S=2*v;return x(b>0?w:"loop",(_+C)/S,(_-C)/S)},getLength:function(n,i,r,s){if(i===o&&(i=0),r===o&&(r=1),B.isStraight(n)){var a=n;r<1&&(a=B.subdivide(a,r)[0],i/=r),i>0&&(a=B.subdivide(a,i)[1]);var h=a[6]-a[0],l=a[7]-a[1];return Math.sqrt(h*h+l*l)}return g.integrate(s||t(n),i,r,e(i,r))},getTimeAt:function(n,i,r){if(r===o&&(r=i<0?1:0),0===i)return r;var s=Math.abs,a=1e-12,h=i>0,l=h?r:0,u=h?1:r,c=t(n),d=B.getLength(n,l,u,c),f=s(i)-d;if(s(f)<1e-12)return h?u:l;if(f>1e-12)return null;var _=i/d,v=0;function p(t){return v+=g.integrate(c,r,t,e(r,t)),r=t,v-i}return g.findRoot(p,c,r+_,l,u,32,1e-12)},getPoint:function(t,e){return n(t,e,0,!1)},getTangent:function(t,e){return n(t,e,1,!0)},getWeightedTangent:function(t,e){return n(t,e,1,!1)},getNormal:function(t,e){return n(t,e,2,!0)},getWeightedNormal:function(t,e){return n(t,e,2,!1)},getCurvature:function(t,e){return n(t,e,3,!1).x},getPeaks:function(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o,h,l=3*i-e-3*s+t[6],u=3*e-6*i+3*s,c=-3*e+3*i,d=3*r-n-3*a+t[7],f=3*n-6*r+3*a,_=-3*n+3*r,v=1e-8,p=1-1e-8,m=[];return g.solveCubic(9*(l*l+d*d),9*(l*u+f*d),2*(u*u+f*f)+3*(c*l+_*d),c*u+f*_,m,1e-8,p),m.sort()}}}},new function(){function t(t,e,n,i,r,s,a){var o=!a&&n.getPrevious()===r,h=!a&&n!==r&&n.getNext()===r,l=1e-8,u=1-1e-8;if(null!==i&&i>=(o?1e-8:0)&&i<=(h?u:1)&&null!==s&&s>=(h?1e-8:0)&&s<=(o?u:1)){var c=new j(n,i,null,a),d=new j(r,s,null,a);c._intersection=d,d._intersection=c,e&&!e(c)||j.insert(t,c,!0)}}function e(r,s,a,o,h,l,u,c,d,f,_,g,v){if(++d>=4096||++c>=40)return d;var p=1e-9,m=s[0],y=s[1],w=s[6],x=s[7],b=S.getSignedDistance,C=b(m,y,w,x,s[2],s[3]),M=b(m,y,w,x,s[4],s[5]),P=C*M>0?.75:4/9,k=P*Math.min(0,C,M),I=P*Math.max(0,C,M),z=b(m,y,w,x,r[0],r[1]),T=b(m,y,w,x,r[2],r[3]),O=b(m,y,w,x,r[4],r[5]),A=b(m,y,w,x,r[6],r[7]),L=n(z,T,O,A),E=L[0],N=L[1],j,R;if(0===C&&0===M&&0===z&&0===T&&0===O&&0===A||null==(j=i(E,N,k,I))||null==(R=i(E.reverse(),N.reverse(),k,I)))return d;var D=f+(_-f)*j,F=f+(_-f)*R;if(Math.max(v-g,F-D)<1e-9){var q=(D+F)/2,V=(g+v)/2;t(h,l,u?o:a,u?V:q,u?a:o,u?q:V)}else if(r=B.getPart(r,j,R),R-j>.8)if(F-D>v-g){var H,q=(D+F)/2;d=e(s,(H=B.subdivide(r,.5))[0],o,a,h,l,!u,c,d,g,v,D,q),d=e(s,H[1],o,a,h,l,!u,c,d,g,v,q,F)}else{var H,V=(g+v)/2;d=e((H=B.subdivide(s,.5))[0],r,o,a,h,l,!u,c,d,g,V,D,F),d=e(H[1],r,o,a,h,l,!u,c,d,V,v,D,F)}else d=v-g>=1e-9?e(s,r,o,a,h,l,!u,c,d,g,v,D,F):e(r,s,a,o,h,l,u,c,d,D,F,g,v);return d}function n(t,e,n,i){var r=[0,t],s=[1/3,e],a=[2/3,n],o=[1,i],h=e-(2*t+i)/3,l=n-(t+2*i)/3,u;if(h*l<0)u=[[r,s,o],[r,a,o]];else{var c=h/l;u=[c>=2?[r,s,o]:c<=.5?[r,a,o]:[r,s,a,o],[r,o]]}return(h||l)<0?u.reverse():u}function i(t,e,n,i){return t[0][1]<n?r(t,!0,n):e[0][1]>i?r(e,!1,i):t[0][0]}function r(t,e,n){for(var i=t[0][0],r=t[0][1],s=1,a=t.length;s<a;s++){var o=t[s][0],h=t[s][1];if(e?h>=n:h<=n)return h===n?o:i+(n-r)*(o-i)/(h-r);i=o,r=h}return null}function s(t,e,n,i,r){var s=g.isZero;if(s(i)&&s(r)){var a=B.getTimeOf(t,new p(e,n));return null===a?[]:[a]}for(var o=Math.atan2(-r,i),h=Math.sin(o),l=Math.cos(o),u=[],c=[],d=0;d<8;d+=2){var f=t[d]-e,_=t[d+1]-n;u.push(f*l-_*h,f*h+_*l)}return B.solveCubic(u,1,0,c,0,1),c}function a(e,n,i,r,a,o,h){for(var l=n[0],u=n[1],c,d,f=s(e,l,u,n[6]-l,n[7]-u),_=0,g=f.length;_<g;_++){var v=f[_],p=B.getPoint(e,v),m=B.getTimeOf(n,p);null!==m&&t(a,o,h?r:i,h?m:v,h?i:r,h?v:m)}}function o(e,n,i,r,s,a){var o=S.intersect(e[0],e[1],e[6],e[7],n[0],n[1],n[6],n[7]);o&&t(s,a,i,B.getTimeOf(e,o),r,B.getTimeOf(n,o))}function h(n,i,r,s,h,l){var u=1e-12,d=Math.min,f=Math.max;if(f(n[0],n[2],n[4],n[6])+1e-12>d(i[0],i[2],i[4],i[6])&&d(n[0],n[2],n[4],n[6])-1e-12<f(i[0],i[2],i[4],i[6])&&f(n[1],n[3],n[5],n[7])+1e-12>d(i[1],i[3],i[5],i[7])&&d(n[1],n[3],n[5],n[7])-1e-12<f(i[1],i[3],i[5],i[7])){var _=c(n,i);if(_)for(var g=0;g<2;g++){var v=_[g];t(h,l,r,v[0],s,v[1],!0)}else{var m=B.isStraight(n),y=B.isStraight(i),w=m&&y,x=m&&!y,b=h.length;if((w?o:m||y?a:e)(x?i:n,x?n:i,x?s:r,x?r:s,h,l,x,0,0,0,1,0,1),!w||h.length===b)for(var g=0;g<4;g++){var C=g>>1,S=1&g,M=6*C,P=6*S,k=new p(n[M],n[M+1]),I=new p(i[P],i[P+1]);k.isClose(I,1e-12)&&t(h,l,r,C,s,S)}}}return h}function l(e,n,i,r){var s=B.classify(e);if("loop"===s.type){var a=s.roots;t(i,r,n,a[0],n,a[1])}return i}function u(t,e,n,i,r,s){var a=!e;a&&(e=t);for(var o=t.length,u=e.length,c=[],d=[],f,_,g=0;g<u;g++)c[g]=e[g].getValues(r);for(var g=0;g<o;g++){var v=t[g],p=a?c[g]:v.getValues(i),m=v.getPath();m!==_&&(_=m,f=[],d.push(f)),a&&l(p,v,f,n);for(var y=a?g+1:0;y<u;y++){if(s&&f.length)return f;h(p,c[y],v,e[y],f,n)}}f=[];for(var g=0,w=d.length;g<w;g++)f.push.apply(f,d[g]);return f}function c(t,e){function n(t){var e=t[6]-t[0],n=t[7]-t[1];return e*e+n*n}var i=Math.abs,r=S.getDistance,s=1e-8,a=1e-7,o=B.isStraight(t),h=B.isStraight(e),l=o&&h,u=n(t)<n(e),c=u?e:t,d=u?t:e,f=c[0],_=c[1],g=c[6]-f,v=c[7]-_;if(r(f,_,g,v,d[0],d[1],!0)<1e-7&&r(f,_,g,v,d[6],d[7],!0)<1e-7)!l&&r(f,_,g,v,c[2],c[3],!0)<1e-7&&r(f,_,g,v,c[4],c[5],!0)<1e-7&&r(f,_,g,v,d[2],d[3],!0)<1e-7&&r(f,_,g,v,d[4],d[5],!0)<1e-7&&(o=h=l=!0);else if(l)return null;if(o^h)return null;for(var m=[t,e],y=[],w=0;w<4&&y.length<2;w++){var x=1&w,b=1^x,C=w>>1,M=B.getTimeOf(m[x],new p(m[b][C?6:0],m[b][C?7:1]));if(null!=M){var P=x?[C,M]:[M,C];(!y.length||i(P[0]-y[0][0])>1e-8&&i(P[1]-y[0][1])>1e-8)&&y.push(P)}if(w>2&&!y.length)break}if(2!==y.length)y=null;else if(!l){var k=B.getPart(t,y[0][0],y[1][0]),I=B.getPart(e,y[0][1],y[1][1]);(i(I[2]-k[2])>1e-7||i(I[3]-k[3])>1e-7||i(I[4]-k[4])>1e-7||i(I[5]-k[5])>1e-7)&&(y=null)}return y}return{getIntersections:function(t){var e=this.getValues(),n=t&&t!==this&&t.getValues();return n?h(e,n,this,t,[]):l(e,this,[])},statics:{getOverlaps:c,getIntersections:u,getCurveLineIntersections:s}}}),j=u.extend({_class:"CurveLocation",initialize:function t(e,n,i,r,s){if(n>=.99999999){var a=e.getNext();a&&(n=0,e=a)}this._setCurve(e),this._time=n,this._point=i||e.getPointAtTime(n),this._overlap=r,this._distance=s,this._intersection=this._next=this._previous=null},_setCurve:function(t){var e=t._path;this._path=e,this._version=e?e._version:0,this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){this._setCurve(t.getCurve()),this._segment=t,this._time=t===this._segment1?0:1,this._point=t._point.clone()},getSegment:function(){var t=this._segment;if(!t){var e=this.getCurve(),n=this.getTime();0===n?t=e._segment1:1===n?t=e._segment2:null!=n&&(t=e.getPartLength(0,n)<e.getPartLength(n,1)?e._segment1:e._segment2),this._segment=t}return t},getCurve:function(){var t=this._path,e=this;function n(t){var n=t&&t.getCurve();if(n&&null!=(e._time=n.getTimeOf(e._point)))return e._setCurve(n),n}return t&&t._version!==this._version&&(this._time=this._offset=this._curveOffset=this._curve=null),this._curve||n(this._segment)||n(this._segment1)||n(this._segment2.getPrevious())},getPath:function(){var t=this.getCurve();return t&&t._path},getIndex:function(){var t=this.getCurve();return t&&t.getIndex()},getTime:function(){var t=this.getCurve(),e=this._time;return t&&null==e?this._time=t.getTimeOf(this._point):e},getParameter:"#getTime",getPoint:function(){return this._point},getOffset:function(){var t=this._offset;if(null==t){t=0;var e=this.getPath(),n=this.getIndex();if(e&&null!=n)for(var i=e.getCurves(),r=0;r<n;r++)t+=i[r].getLength();this._offset=t+=this.getCurveOffset()}return t},getCurveOffset:function(){var t=this._curveOffset;if(null==t){var e=this.getCurve(),n=this.getTime();this._curveOffset=t=null!=n&&e&&e.getPartLength(0,n)}return t},getIntersection:function(){return this._intersection},getDistance:function(){return this._distance},divide:function(){var t=this.getCurve(),e=t&&t.divideAtTime(this.getTime());return e&&this._setSegment(e._segment1),e},split:function(){var t=this.getCurve(),e=t._path,n=t&&t.splitAtTime(this.getTime());return n&&this._setSegment(e.getLastSegment()),n},equals:function(t,e){var n=this===t;if(!n&&t instanceof j){var i=this.getCurve(),r=t.getCurve(),s=i._path,a;if(s===r._path){var o=Math.abs,h=1e-7,l=o(this.getOffset()-t.getOffset()),u=!e&&this._intersection,c=!e&&t._intersection;n=(l<1e-7||s&&o(s.getLength()-l)<1e-7)&&(!u&&!c||u&&c&&u.equals(c,!0))}}return n},toString:function(){var t=[],e=this.getPoint(),n=_.instance;e&&t.push("point: "+e);var i=this.getIndex();null!=i&&t.push("index: "+i);var r=this.getTime();return null!=r&&t.push("time: "+n.number(r)),null!=this._distance&&t.push("distance: "+n.number(this._distance)),"{ "+t.join(", ")+" }"},isTouching:function(){var t=this._intersection;if(t&&this.getTangent().isCollinear(t.getTangent())){var e=this.getCurve(),n=t.getCurve();return!(e.isStraight()&&n.isStraight()&&e.getLine().intersect(n.getLine()))}return!1},isCrossing:function(){var t=this._intersection;if(!t)return!1;var e=this.getTime(),n=t.getTime(),i=1e-8,r=1-1e-8,s=e>=1e-8&&e<=r,a=n>=1e-8&&n<=r;if(s&&a)return!this.isTouching();var o=this.getCurve(),h=e<1e-8?o.getPrevious():o,l=t.getCurve(),u=n<1e-8?l.getPrevious():l;if(e>r&&(o=o.getNext()),n>r&&(l=l.getNext()),!(h&&o&&u&&l))return!1;var c=[];function d(t,e){var n=t.getValues(),i=B.classify(n).roots||B.getPeaks(n),r=i.length,s=e&&r>1?i[r-1]:r>0?i[0]:.5;c.push(B.getLength(n,e?s:0,e?1:s)/2)}function f(t,e,n){return e<n?t>e&&t<n:t>e||t<n}s||(d(h,!0),d(o,!1)),a||(d(u,!0),d(l,!1));var _=this.getPoint(),g=Math.min.apply(Math,c),v=s?o.getTangentAtTime(e):o.getPointAt(g).subtract(_),p=s?v.negate():h.getPointAt(-g).subtract(_),m=a?l.getTangentAtTime(n):l.getPointAt(g).subtract(_),y=a?m.negate():u.getPointAt(-g).subtract(_),w=p.getAngle(),x=v.getAngle(),b=y.getAngle(),C=m.getAngle();return!!(s?f(w,b,C)^f(x,b,C)&&f(w,C,b)^f(x,C,b):f(b,w,x)^f(C,w,x)&&f(b,x,w)^f(C,x,w))},hasOverlap:function(){return!!this._overlap}},u.each(B._evaluateMethods,function(t){var e=t+"At";this[t]=function(){var t=this.getCurve(),n=this.getTime();return null!=n&&t&&t[e](n,!0)}},{preserve:!0}),new function(){function t(t,e,n){var i=t.length,r=0,s=i-1;function a(n,r){for(var s=n+r;s>=-1&&s<=i;s+=r){var a=t[(s%i+i)%i];if(!e.getPoint().isClose(a.getPoint(),1e-7))break;if(e.equals(a))return a}return null}for(;r<=s;){var o=r+s>>>1,h=t[o],l;if(n&&(l=e.equals(h)?h:a(o,-1)||a(o,1)))return e._overlap&&(l._overlap=l._intersection._overlap=!0),l;var u=e.getPath(),c=h.getPath(),d;(u!==c?u._id-c._id:e.getIndex()+e.getTime()-(h.getIndex()+h.getTime()))<0?s=o-1:r=o+1}return t.splice(r,0,e),e}return{statics:{insert:t,expand:function(e){for(var n=e.slice(),i=e.length-1;i>=0;i--)t(n,e[i]._intersection,!1);return n}}}}),R=P.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function t(){},statics:{create:function(t){var e,n,i,r;if(u.isPlainObject(t)?(n=t.segments,e=t.pathData):Array.isArray(t)?n=t:"string"==typeof t&&(e=t),n){var s=n[0];i=s&&Array.isArray(s[0])}else e&&(i=(e.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(e));return new(i?F:D)(t)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(t){this.isClockwise()!=(t=!!t)&&this.reverse()},setPathData:function(t){var e=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),n,i=!1,r,s,a=new p,o=new p;function h(t,e){var r=+n[t];return i&&(r+=a[e]),r}function l(t){return new p(h(t,"x"),h(t+1,"y"))}this.clear();for(var u=0,c=e&&e.length;u<c;u++){var d=e[u],f=d[0],_=f.toLowerCase(),g=(n=d.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g))&&n.length;switch(i=f===_,"z"!==r||/[mz]/.test(_)||this.moveTo(a),_){case"m":case"l":for(var v="m"===_,m=0;m<g;m+=2)this[v?"moveTo":"lineTo"](a=l(m)),v&&(o=a,v=!1);s=a;break;case"h":case"v":var w="h"===_?"x":"y";a=a.clone();for(var m=0;m<g;m++)a[w]=h(m,w),this.lineTo(a);s=a;break;case"c":for(var m=0;m<g;m+=6)this.cubicCurveTo(l(m),s=l(m+2),a=l(m+4));break;case"s":for(var m=0;m<g;m+=4)this.cubicCurveTo(/[cs]/.test(r)?a.multiply(2).subtract(s):a,s=l(m),a=l(m+2)),r=_;break;case"q":for(var m=0;m<g;m+=4)this.quadraticCurveTo(s=l(m),a=l(m+2));break;case"t":for(var m=0;m<g;m+=2)this.quadraticCurveTo(s=/[qt]/.test(r)?a.multiply(2).subtract(s):a,a=l(m)),r=_;break;case"a":for(var m=0;m<g;m+=7)this.arcTo(a=l(m+5),new y(+n[m],+n[m+1]),+n[m+2],+n[m+4],+n[m+3]);break;case"z":this.closePath(1e-12),a=o}r=_}},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_contains:function(t){var e=t.isInside(this.getBounds({internal:!0,handle:!0}))?this._getWinding(t):{};return e.onPath||!!("evenodd"===this.getFillRule()?1&e.windingL||1&e.windingR:e.winding)},getIntersections:function(t,e,n,i){var r=this===t||!t,s=this._matrix._orNullIfIdentity(),a=r?s:(n||t._matrix)._orNullIfIdentity();return r||this.getBounds(s).intersects(t.getBounds(a),1e-12)?B.getIntersections(this.getCurves(),!r&&t.getCurves(),e,s,a,i):[]},getCrossings:function(t){return this.getIntersections(t,function(t){return t.hasOverlap()||t.isCrossing()})},getNearestLocation:function(){for(var t=p.read(arguments),e=this.getCurves(),n=1/0,i=null,r=0,s=e.length;r<s;r++){var a=e[r].getNearestLocation(t);a._distance<n&&(n=a._distance,i=a)}return i},getNearestPoint:function(){var t=this.getNearestLocation.apply(this,arguments);return t?t.getPoint():t},interpolate:function(t,e,n){var i=!this._children,r=i?"_segments":"_children",s=t[r],a=e[r],o=this[r];if(!s||!a||s.length!==a.length)throw new Error("Invalid operands in interpolate() call: "+t+", "+e);var h=o.length,l=a.length;if(h<l)for(var u=i?E:D,c=h;c<l;c++)this.add(new u);else h>l&&this[i?"removeSegments":"removeChildren"](l,h);for(var c=0;c<l;c++)o[c].interpolate(s[c],a[c],n);i&&(this.setClosed(t._closed),this._changed(9))},compare:function(t){var e=!1;if(t){var n=this._children||[this],i=t._children?t._children.slice():[t],r=n.length,s=i.length,a=[],o=0;e=!0;for(var h=r-1;h>=0&&e;h--){var l=n[h];e=!1;for(var u=s-1;u>=0&&!e;u--)l.compare(i[u])&&(a[u]||(a[u]=!0,o++),e=!0)}e=e&&o===s}return e}}),D=R.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function t(e){this._closed=!1,this._segments=[],this._version=0;var n=Array.isArray(e)?"object"==typeof e[0]?e:arguments:!e||e.size!==o||e.x===o&&e.point===o?null:arguments;n&&n.length>0?this.setSegments(n):(this._curves=o,this._segmentSelection=0,n||"string"!=typeof e||(this.setPathData(e),e=null)),this._initialize(!n&&e)},_equals:function(t){return this._closed===t._closed&&u.equals(this._segments,t._segments)},copyContent:function(t){this.setSegments(t._segments),this._closed=t._closed},_changed:function t(e){if(t.base.call(this,e),8&e){if(this._length=this._area=o,16&e)this._version++;else if(this._curves)for(var n=0,i=this._curves.length;n<i;n++)this._curves[n]._changed()}else 32&e&&(this._bounds=o)},getStyle:function(){var t=this._parent;return(t instanceof F?t:this)._style},getSegments:function(){return this._segments},setSegments:function(t){var e=this.isFullySelected(),n=t&&t.length;if(this._segments.length=0,this._segmentSelection=0,this._curves=o,n){var i=t[n-1];"boolean"==typeof i&&(this.setClosed(i),n--),this._add(E.readList(t,0,{},n))}e&&this.setFullySelected(!0)},getFirstSegment:function(){return this._segments[0]},getLastSegment:function(){return this._segments[this._segments.length-1]},getCurves:function(){var t=this._curves,e=this._segments;if(!t){var n=this._countCurves();t=this._curves=new Array(n);for(var i=0;i<n;i++)t[i]=new B(this,e[i],e[i+1]||e[0])}return t},getFirstCurve:function(){return this.getCurves()[0]},getLastCurve:function(){var t=this.getCurves();return t[t.length-1]},isClosed:function(){return this._closed},setClosed:function(t){if(this._closed!=(t=!!t)){if(this._closed=t,this._curves){var e=this._curves.length=this._countCurves();t&&(this._curves[e-1]=new B(this,this._segments[e-1],this._segments[0]))}this._changed(25)}}},{beans:!0,getPathData:function(t,e){var n=this._segments,i=n.length,r=new _(e),s=new Array(6),a=!0,o,h,l,u,c,d,f,g,v=[];function p(e,n){if(e._transformCoordinates(t,s),o=s[0],h=s[1],a)v.push("M"+r.pair(o,h)),a=!1;else if(c=s[2],d=s[3],c===o&&d===h&&f===l&&g===u){if(!n){var i=o-l,_=h-u;v.push(0===i?"v"+r.number(_):0===_?"h"+r.number(i):"l"+r.pair(i,_))}}else v.push("c"+r.pair(f-l,g-u)+" "+r.pair(c-l,d-u)+" "+r.pair(o-l,h-u));l=o,u=h,f=s[4],g=s[5]}if(!i)return"";for(var m=0;m<i;m++)p(n[m]);return this._closed&&i>0&&(p(n[0],!0),v.push("z")),v.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(t){for(var e=this._segments,n=new Array(6),i=0,r=e.length;i<r;i++)e[i]._transformCoordinates(t,n,!0);return!0},_add:function(t,e){for(var n=this._segments,i=this._curves,r=t.length,s=null==e,e=s?n.length:e,a=0;a<r;a++){var o=t[a];o._path&&(o=t[a]=o.clone()),o._path=this,o._index=e+a,o._selection&&this._updateSelection(o,0,o._selection)}if(s)n.push.apply(n,t);else{n.splice.apply(n,[e,0].concat(t));for(var a=e+r,h=n.length;a<h;a++)n[a]._index=a}if(i){var l=this._countCurves(),u=e>0&&e+r-1===l?e-1:e,c=u,d=Math.min(u+r,l);t._curves&&(i.splice.apply(i,[u,0].concat(t._curves)),c+=t._curves.length);for(var a=c;a<d;a++)i.splice(a,0,new B(this,null,null));this._adjustCurves(u,d)}return this._changed(25),t},_adjustCurves:function(t,e){for(var n=this._segments,i=this._curves,r,s=t;s<e;s++)(r=i[s])._path=this,r._segment1=n[s],r._segment2=n[s+1]||n[0],r._changed();(r=i[this._closed&&!t?n.length-1:t-1])&&(r._segment2=n[t]||n[0],r._changed()),(r=i[e])&&(r._segment1=n[e],r._changed())},_countCurves:function(){var t=this._segments.length;return!this._closed&&t>0?t-1:t},add:function(t){return arguments.length>1&&"number"!=typeof t?this._add(E.readList(arguments)):this._add([E.read(arguments)])[0]},insert:function(t,e){return arguments.length>2&&"number"!=typeof e?this._add(E.readList(arguments,1),t):this._add([E.read(arguments,1)],t)[0]},addSegment:function(){return this._add([E.read(arguments)])[0]},insertSegment:function(t){return this._add([E.read(arguments,1)],t)[0]},addSegments:function(t){return this._add(E.readList(t))},insertSegments:function(t,e){return this._add(E.readList(e),t)},removeSegment:function(t){return this.removeSegments(t,t+1)[0]||null},removeSegments:function(t,e,n){t=t||0,e=u.pick(e,this._segments.length);var i=this._segments,r=this._curves,s=i.length,a=i.splice(t,e-t),o=a.length;if(!o)return a;for(var h=0;h<o;h++){var l=a[h];l._selection&&this._updateSelection(l,l._selection,0),l._index=l._path=null}for(var h=t,c=i.length;h<c;h++)i[h]._index=h;if(r){for(var d=t>0&&e===s+(this._closed?1:0)?t-1:t,r,h=(r=r.splice(d,o)).length-1;h>=0;h--)r[h]._path=null;n&&(a._curves=r.slice(1)),this._adjustCurves(d,d)}return this._changed(25),a},clear:"#removeSegments",hasHandles:function(){for(var t=this._segments,e=0,n=t.length;e<n;e++)if(t[e].hasHandles())return!0;return!1},clearHandles:function(){for(var t=this._segments,e=0,n=t.length;e<n;e++)t[e].clearHandles()},getLength:function(){if(null==this._length){for(var t=this.getCurves(),e=0,n=0,i=t.length;n<i;n++)e+=t[n].getLength();this._length=e}return this._length},getArea:function(){var t=this._area;if(null==t){var e=this._segments,n=this._closed;t=0;for(var i=0,r=e.length;i<r;i++){var s=i+1===r;t+=B.getArea(B.getValues(e[i],e[s?0:i+1],null,s&&!n))}this._area=t}return t},isFullySelected:function(){var t=this._segments.length;return this.isSelected()&&t>0&&this._segmentSelection===7*t},setFullySelected:function(t){t&&this._selectSegments(!0),this.setSelected(t)},setSelection:function t(e){1&e||this._selectSegments(!1),t.base.call(this,e)},_selectSegments:function(t){var e=this._segments,n=e.length,i=t?7:0;this._segmentSelection=i*n;for(var r=0;r<n;r++)e[r]._selection=i},_updateSelection:function(t,e,n){var i;t._selection=n,(this._segmentSelection+=n-e)>0&&this.setSelected(!0)},divideAt:function(t){var e=this.getLocationAt(t),n;return e&&(n=e.getCurve().divideAt(e.getCurveOffset()))?n._segment1:null},splitAt:function(t){var e=this.getLocationAt(t),n=e&&e.index,i=e&&e.time,r=1e-8,s;i>1-1e-8&&(n++,i=0);var a=this.getCurves();if(n>=0&&n<a.length){i>=1e-8&&a[n++].divideAtTime(i);var o=this.removeSegments(n,this._segments.length,!0),h;return this._closed?(this.setClosed(!1),h=this):((h=new D(P.NO_INSERT)).insertAbove(this),h.copyAttributes(this)),h._add(o,0),this.addSegment(o[0]),h}return null},split:function(t,e){var n,i=e===o?t:(n=this.getCurves()[t])&&n.getLocationAtTime(e);return null!=i?this.splitAt(i):null},join:function(t,e){var n=e||0;if(t&&t!==this){var i=t._segments,r=this.getLastSegment(),s=t.getLastSegment();if(!s)return this;r&&r._point.isClose(s._point,n)&&t.reverse();var a=t.getFirstSegment();if(r&&r._point.isClose(a._point,n))r.setHandleOut(a._handleOut),this._add(i.slice(1));else{var o=this.getFirstSegment();o&&o._point.isClose(a._point,n)&&t.reverse(),s=t.getLastSegment(),o&&o._point.isClose(s._point,n)?(o.setHandleIn(s._handleIn),this._add(i.slice(0,i.length-1),0)):this._add(i.slice())}t._closed&&this._add([i[0]]),t.remove()}var h=this.getFirstSegment(),l=this.getLastSegment();return h!==l&&h._point.isClose(l._point,n)&&(h.setHandleIn(l._handleIn),l.remove(),this.setClosed(!0)),this},reduce:function(t){for(var e=this.getCurves(),n=t&&t.simplify,i=n?1e-7:0,r=e.length-1;r>=0;r--){var s=e[r];!s.hasHandles()&&(!s.hasLength(i)||n&&s.isCollinear(s.getNext()))&&s.remove()}return this},reverse:function(){this._segments.reverse();for(var t=0,e=this._segments.length;t<e;t++){var n=this._segments[t],i=n._handleIn;n._handleIn=n._handleOut,n._handleOut=i,n._index=t}this._curves=null,this._changed(9)},flatten:function(t){for(var e,n=new q(this,t||.25,256,!0).parts,i=n.length,r=[],s=0;s<i;s++)r.push(new E(n[s].curve.slice(0,2)));!this._closed&&i>0&&r.push(new E(n[i-1].curve.slice(6))),this.setSegments(r)},simplify:function(t){var e=new V(this).fit(t||2.5);return e&&this.setSegments(e),!!e},smooth:function(t){var e=this,n=t||{},i=n.type||"asymmetric",r=this._segments,s=r.length,a=this._closed;function h(t,n){var i=t&&t.index;if(null!=i){var r=t.path;if(r&&r!==e)throw new Error(t._class+" "+i+" of "+r+" is not part of "+e);n&&t instanceof B&&i++}else i="number"==typeof t?t:n;return Math.min(i<0&&a?i%s:i<0?i+s:i,s-1)}var l=a&&n.from===o&&n.to===o,u=h(n.from,0),c=h(n.to,s-1);if(u>c)if(a)u-=s;else{var d=u;u=c,c=d}if(/^(?:asymmetric|continuous)$/.test(i)){var f="asymmetric"===i,_=Math.min,g=c-u+1,v=g-1,p=l?_(g,4):1,m=p,y=p,w=[];if(a||(m=_(1,u),y=_(1,s-c-1)),(v+=m+y)<=1)return;for(var x=0,b=u-m;x<=v;x++,b++)w[x]=r[(b<0?b+s:b)%s]._point;for(var C=w[0]._x+2*w[1]._x,S=w[0]._y+2*w[1]._y,M=2,P=v-1,k=[C],I=[S],z=[M],T=[],O=[],x=1;x<v;x++){var A=x<P,L,E=A?4:f?2:7,N=A?4:f?3:8,j=A?2:f?0:1,R=(A?1:f?1:2)/M;M=z[x]=E-R,C=k[x]=N*w[x]._x+j*w[x+1]._x-R*C,S=I[x]=N*w[x]._y+j*w[x+1]._y-R*S}T[P]=k[P]/z[P],O[P]=I[P]/z[P];for(var x=v-2;x>=0;x--)T[x]=(k[x]-T[x+1])/z[x],O[x]=(I[x]-O[x+1])/z[x];T[v]=(3*w[v]._x-T[P])/2,O[v]=(3*w[v]._y-O[P])/2;for(var x=m,D=v-y,b=u;x<=D;x++,b++){var F=r[b<0?b+s:b],q=F._point,V=T[x]-q._x,H=O[x]-q._y;(l||x<D)&&F.setHandleOut(V,H),(l||x>m)&&F.setHandleIn(-V,-H)}}else for(var x=u;x<=c;x++)r[x<0?x+s:x].smooth(n,!l&&x===u,!l&&x===c)},toShape:function(t){if(!this._closed)return null;var e=this._segments,n,i,r,s;function a(t,n){var i=e[t],r=i.getNext(),s=e[n],a=s.getNext();return i._handleOut.isZero()&&r._handleIn.isZero()&&s._handleOut.isZero()&&a._handleIn.isZero()&&r._point.subtract(i._point).isCollinear(a._point.subtract(s._point))}function h(t){var n=e[t],i=n.getPrevious(),r=n.getNext();return i._handleOut.isZero()&&n._handleIn.isZero()&&n._handleOut.isZero()&&r._handleIn.isZero()&&n._point.subtract(i._point).isOrthogonal(r._point.subtract(n._point))}function l(t){var n=e[t],i=n.getNext(),r=n._handleOut,s=i._handleIn,a=.5522847498307936;if(r.isOrthogonal(s)){var o=n._point,h=i._point,l=new S(o,r,!0).intersect(new S(h,s,!0),!0);return l&&g.isZero(r.getLength()/l.subtract(o).getLength()-a)&&g.isZero(s.getLength()/l.subtract(h).getLength()-a)}return!1}function u(t,n){return e[t]._point.getDistance(e[n]._point)}if(!this.hasHandles()&&4===e.length&&a(0,2)&&a(1,3)&&h(1)?(n=z.Rectangle,i=new y(u(0,3),u(0,1)),s=e[1]._point.add(e[2]._point).divide(2)):8===e.length&&l(0)&&l(2)&&l(4)&&l(6)&&a(1,5)&&a(3,7)?(n=z.Rectangle,r=(i=new y(u(1,6),u(0,3))).subtract(new y(u(0,7),u(1,2))).divide(2),s=e[3]._point.add(e[4]._point).divide(2)):4===e.length&&l(0)&&l(1)&&l(2)&&l(3)&&(g.isZero(u(0,2)-u(1,3))?(n=z.Circle,r=u(0,2)/2):(n=z.Ellipse,r=new y(u(2,0)/2,u(3,1)/2)),s=e[1]._point),n){var c=this.getPosition(!0),d=new n({center:c,size:i,radius:r,insert:!1});return d.copyAttributes(this,!0),d._matrix.prepend(this._matrix),d.rotate(s.subtract(c).getAngle()+90),(t===o||t)&&d.insertAbove(this),d}return null},toPath:"#clone",compare:function t(e){if(!e||e instanceof F)return t.base.call(this,e);var n=this.getCurves(),i=e.getCurves(),r=n.length,s=i.length;if(!r||!s)return r==s;for(var a=n[0].getValues(),o=[],h=0,l,u=0,c,d=0;d<s;d++){var f=i[d].getValues(),_;if(o.push(f),_=B.getOverlaps(a,f)){l=!d&&_[0][0]>0?s-1:d,c=_[0][1];break}}for(var g=Math.abs,v=1e-8,f=o[l],p;a&&f;){var _,m;if(_=B.getOverlaps(a,f))if(g(_[0][0]-u)<1e-8){1===(u=_[1][0])&&(a=++h<r?n[h].getValues():null,u=0);var y=_[0][1];if(g(y-c)<1e-8){if(p||(p=[l,y]),1===(c=_[1][1])&&(++l>=s&&(l=0),f=o[l]||i[l].getValues(),c=0),!a)return p[0]===l&&p[1]===c;continue}}break}return!1},_hitTestSelf:function(t,e,n,i){var r=this,s=this.getStyle(),a=this._segments,o=a.length,h=this._closed,l=e._tolerancePadding,u=l,c,d,f,_,g,v,p=e.stroke&&s.hasStroke(),m=e.fill&&s.hasFill(),y=e.curves,w=p?s.getStrokeWidth()/2:m&&e.tolerance>0||y?0:null;function x(e,n){return t.subtract(e).divide(n).length<=1}function b(t,n,i){if(!e.selected||n.isSelected()){var s=t._point;if(n!==s&&(n=n.add(s)),x(n,u))return new L(i,r,{segment:t,point:n})}}function C(t,n){return(n||e.segments)&&b(t,t._point,"segment")||!n&&e.handles&&(b(t,t._handleIn,"handle-in")||b(t,t._handleOut,"handle-out"))}function S(t){_.add(t)}function M(e){var n=h||e._index>0&&e._index<o-1,r;return"round"===(n?c:d)?x(e._point,u):(_=new D({internal:!0,closed:!0}),n?e.isSmooth()||D._addBevelJoin(e,c,w,f,null,i,S,!0):"square"===d&&D._addSquareCap(e,d,w,null,i,S,!0),_.isEmpty()?void 0:_.contains(t)||(r=_.getNearestLocation(t))&&x(r.getPoint(),l))}if(null!==w&&(w>0?(c=s.getStrokeJoin(),d=s.getStrokeCap(),f=s.getMiterLimit(),u=u.add(D._getStrokePadding(w,i))):c=d="round"),!e.ends||e.segments||h){if(e.segments||e.handles)for(var P=0;P<o;P++)if(v=C(a[P]))return v}else if(v=C(a[0],!0)||C(a[o-1],!0))return v;if(null!==w){if(g=this.getNearestLocation(t)){var k=g.getTime();0===k||1===k&&o>1?M(g.getSegment())||(g=null):x(g.getPoint(),u)||(g=null)}if(!g&&"miter"===c&&o>1)for(var P=0;P<o;P++){var I=a[P];if(t.getDistance(I._point)<=f*w&&M(I)){g=I.getLocation();break}}}return!g&&m&&this._contains(t)||g&&!p&&!y?new L("fill",this):g?new L(p?"stroke":"curve",this,{location:g,point:g.getPoint()}):null}},u.each(B._evaluateMethods,function(t){this[t+"At"]=function(e){var n=this.getLocationAt(e);return n&&n[t]()}},{beans:!1,getLocationOf:function(){for(var t=p.read(arguments),e=this.getCurves(),n=0,i=e.length;n<i;n++){var r=e[n].getLocationOf(t);if(r)return r}return null},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getLocationAt:function(t){if("number"==typeof t){for(var e=this.getCurves(),n=0,i=0,r=e.length;i<r;i++){var s=n,a=e[i];if((n+=a.getLength())>t)return a.getLocationAt(t-s)}if(e.length>0&&t<=this.getLength())return new j(e[e.length-1],1)}else if(t&&t.getPath&&t.getPath()===this)return t;return null}}),new function(){function t(t,e,n,i){var r=i/2,s=new Array(6),a,o;function h(e){var n=s[e],i=s[e+1];a==n&&o==i||(t.beginPath(),t.moveTo(a,o),t.lineTo(n,i),t.stroke(),t.beginPath(),t.arc(n,i,r,0,2*Math.PI,!0),t.fill())}for(var l=0,u=e.length;l<u;l++){var c=e[l],d=c._selection;if(c._transformCoordinates(n,s),a=s[0],o=s[1],2&d&&h(2),4&d&&h(4),t.fillRect(a-r,o-r,i,i),!(1&d)){var f=t.fillStyle;t.fillStyle="#ffffff",t.fillRect(a-r+1,o-r+1,i-2,i-2),t.fillStyle=f}}}function e(t,e,n){var i=e._segments,r=i.length,s=new Array(6),a=!0,o,h,l,u,c,d,f,_;function g(e){if(n)e._transformCoordinates(n,s),o=s[0],h=s[1];else{var i=e._point;o=i._x,h=i._y}if(a)t.moveTo(o,h),a=!1;else{if(n)c=s[2],d=s[3];else{var r=e._handleIn;c=o+r._x,d=h+r._y}c===o&&d===h&&f===l&&_===u?t.lineTo(o,h):t.bezierCurveTo(f,_,c,d,o,h)}if(l=o,u=h,n)f=s[4],_=s[5];else{var r=e._handleOut;f=l+r._x,_=u+r._y}}for(var v=0;v<r;v++)g(i[v]);e._closed&&r>0&&g(i[0])}return{_draw:function(t,n,i,r){var a=n.dontStart,o=n.dontFinish||n.clip,h=this.getStyle(),l=h.hasFill(),u=h.hasStroke(),c=h.getDashArray(),d=!s.support.nativeDash&&u&&c&&c.length;function f(t){return c[(t%d+d)%d]}if(a||t.beginPath(),(l||u&&!d||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(l||u)&&(this._setStyles(t,n,i),l&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),u)){if(d){a||t.beginPath();var _=new q(this,.25,32,!1,r),g=_.length,v=-h.getDashOffset(),p,m=0;for(v%=g;v>0;)v-=f(m--)+f(m--);for(;v<g;)p=v+f(m++),(v>0||p>0)&&_.drawPart(t,Math.max(v,0),Math.max(p,0)),v=p+f(m++)}t.stroke()}},_drawSelected:function(n,i){n.beginPath(),e(n,this,i),n.stroke(),t(n,this._segments,i,s.settings.handleSize)}}},new function(){function t(t){var e=t._segments;if(!e.length)throw new Error("Use a moveTo() command first");return e[e.length-1]}return{moveTo:function(){var t=this._segments;1===t.length&&this.removeSegment(0),t.length||this._add([new E(p.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new E(p.read(arguments))])},cubicCurveTo:function(){var e=p.read(arguments),n=p.read(arguments),i=p.read(arguments),r=t(this);r.setHandleOut(e.subtract(r._point)),this._add([new E(i,n.subtract(i))])},quadraticCurveTo:function(){var e=p.read(arguments),n=p.read(arguments),i=t(this)._point;this.cubicCurveTo(e.add(i.subtract(e).multiply(1/3)),e.add(n.subtract(e).multiply(1/3)),n)},curveTo:function(){var e=p.read(arguments),n=p.read(arguments),i=u.pick(u.read(arguments),.5),r=1-i,s=t(this)._point,a=e.subtract(s.multiply(r*r)).subtract(n.multiply(i*i)).divide(2*i*r);if(a.isNaN())throw new Error("Cannot put a curve through points with parameter = "+i);this.quadraticCurveTo(a,n)},arcTo:function(){var e=Math.abs,n=Math.sqrt,i=t(this),r=i._point,s=p.read(arguments),a,o=u.peek(arguments),h,l,c,d,f;if("boolean"==typeof(h=u.pick(o,!0)))var _,a=(_=r.add(s).divide(2)).add(_.subtract(r).rotate(h?-90:90));else if(u.remain(arguments)<=2)a=s,s=p.read(arguments);else{var v=y.read(arguments),m=g.isZero;if(m(v.width)||m(v.height))return this.lineTo(s);var w=u.read(arguments),h=!!u.read(arguments),x=!!u.read(arguments),_=r.add(s).divide(2),b,M=(b=r.subtract(_).rotate(-w)).x,P=b.y,k=e(v.width),I=e(v.height),z=k*k,T=I*I,O=M*M,A=P*P,L=n(O/z+A/T);if(L>1&&(z=(k*=L)*k,T=(I*=L)*I),e(L=(z*T-z*A-T*O)/(z*A+T*O))<1e-12&&(L=0),L<0)throw new Error("Cannot create an arc with the given arguments");l=new p(k*P/I,-I*M/k).multiply((x===h?-1:1)*n(L)).rotate(w).add(_),c=(d=(f=(new C).translate(l).rotate(w).scale(k,I))._inverseTransform(r)).getDirectedAngle(f._inverseTransform(s)),!h&&c>0?c-=360:h&&c<0&&(c+=360)}if(a){var N=new S(r.add(a).divide(2),a.subtract(r).rotate(90),!0),B=new S(a.add(s).divide(2),s.subtract(a).rotate(90),!0),j=new S(r,s),R=j.getSide(a);if(!(l=N.intersect(B,!0))){if(!R)return this.lineTo(s);throw new Error("Cannot create an arc with the given arguments")}c=(d=r.subtract(l)).getDirectedAngle(s.subtract(l));var D=j.getSide(l);0===D?c=R*e(c):R===D&&(c+=c<0?360:-360)}for(var F=1e-7,q=e(c),V=q>=360?4:Math.ceil((q-1e-7)/90),H=c/V,Z=H*Math.PI/360,U=4/3*Math.sin(Z)/(1+Math.cos(Z)),W=[],G=0;G<=V;G++){var b=s,J=null;if(G<V&&(J=d.rotate(90).multiply(U),f?(b=f._transformPoint(d),J=f._transformPoint(d.add(J)).subtract(b)):b=l.add(d)),G){var $=d.rotate(-90).multiply(U);f&&($=f._transformPoint(d.add($)).subtract(b)),W.push(new E(b,$,J))}else i.setHandleOut(J);d=d.rotate(H)}this._add(W)},lineBy:function(){var e=p.read(arguments),n=t(this)._point;this.lineTo(n.add(e))},curveBy:function(){var e=p.read(arguments),n=p.read(arguments),i=u.read(arguments),r=t(this)._point;this.curveTo(r.add(e),r.add(n),i)},cubicCurveBy:function(){var e=p.read(arguments),n=p.read(arguments),i=p.read(arguments),r=t(this)._point;this.cubicCurveTo(r.add(e),r.add(n),r.add(i))},quadraticCurveBy:function(){var e=p.read(arguments),n=p.read(arguments),i=t(this)._point;this.quadraticCurveTo(i.add(e),i.add(n))},arcBy:function(){var e=t(this)._point,n=e.add(p.read(arguments)),i=u.pick(u.peek(arguments),!0);"boolean"==typeof i?this.arcTo(n,i):this.arcTo(n,e.add(p.read(arguments)))},closePath:function(t){this.setClosed(!0),this.join(this,t)}}},{_getBounds:function(t,e){var n=e.handle?"getHandleBounds":e.stroke?"getStrokeBounds":"getBounds";return D[n](this._segments,this._closed,this,t,e)},statics:{getBounds:function(t,e,n,i,r,s){var a=t[0];if(!a)return new x;var o=new Array(6),h=a._transformCoordinates(i,new Array(6)),l=h.slice(0,2),u=l.slice(),c=new Array(2);function d(t){t._transformCoordinates(i,o);for(var e=0;e<2;e++)B._addBounds(h[e],h[e+4],o[e+2],o[e],e,s?s[e]:0,l,u,c);var n=h;h=o,o=n}for(var f=1,_=t.length;f<_;f++)d(t[f]);return e&&d(a),new x(l[0],l[1],u[0]-l[0],u[1]-l[1])},getStrokeBounds:function(t,e,n,i,r){var s=n.getStyle(),a=s.hasStroke(),o=s.getStrokeWidth(),h=a&&n._getStrokeMatrix(i,r),l=a&&D._getStrokePadding(o,h),u=D.getBounds(t,e,n,i,r,l);if(!a)return u;var c=o/2,d=s.getStrokeJoin(),f=s.getStrokeCap(),_=s.getMiterLimit(),g=new x(new y(l));function v(t){u=u.include(t)}function p(t){u=u.unite(g.setCenter(t._point.transform(i)))}function m(t,e){"round"===e||t.isSmooth()?p(t):D._addBevelJoin(t,e,c,_,i,h,v)}function w(t,e){"round"===e?p(t):D._addSquareCap(t,e,c,i,h,v)}for(var b=t.length-(e?0:1),C=1;C<b;C++)m(t[C],d);return e?m(t[0],d):b>0&&(w(t[0],f),w(t[t.length-1],f)),u},_getStrokePadding:function(t,e){if(!e)return[t,t];var n=new p(t,0).transform(e),i=new p(0,t).transform(e),r=n.getAngleInRadians(),s=n.getLength(),a=i.getLength(),o=Math.sin(r),h=Math.cos(r),l=Math.tan(r),u=Math.atan2(a*l,s),c=Math.atan2(a,l*s);return[Math.abs(s*Math.cos(u)*h+a*Math.sin(u)*o),Math.abs(a*Math.sin(c)*h+s*Math.cos(c)*o)]},_addBevelJoin:function(t,e,n,i,r,s,a,o){var h=t.getCurve(),l=h.getPrevious(),u=h.getPoint1().transform(r),c=l.getNormalAtTime(1).multiply(n).transform(s),d=h.getNormalAtTime(0).multiply(n).transform(s);if(c.getDirectedAngle(d)<0&&(c=c.negate(),d=d.negate()),o&&a(u),a(u.add(c)),"miter"===e){var f=new S(u.add(c),new p(-c.y,c.x),!0).intersect(new S(u.add(d),new p(-d.y,d.x),!0),!0);f&&u.getDistance(f)<=i*n&&a(f)}a(u.add(d))},_addSquareCap:function(t,e,n,i,r,s,a){var o=t._point.transform(i),h=t.getLocation(),l=h.getNormal().multiply(0===h.getTime()?n:-n).transform(r);"square"===e&&(a&&(s(o.subtract(l)),s(o.add(l))),o=o.add(l.rotate(-90))),s(o.add(l)),s(o.subtract(l))},getHandleBounds:function(t,e,n,i,r){var s=n.getStyle(),a,o,h;if(r.stroke&&s.hasStroke()){var l=n._getStrokeMatrix(i,r),u=s.getStrokeWidth()/2,c=u;"miter"===s.getStrokeJoin()&&(c=u*s.getMiterLimit()),"square"===s.getStrokeCap()&&(c=Math.max(c,u*Math.SQRT2)),o=D._getStrokePadding(u,l),h=D._getStrokePadding(c,l)}for(var d=new Array(6),f=1/0,_=-f,g=f,v=_,p=0,m=t.length;p<m;p++){var y;t[p]._transformCoordinates(i,d);for(var w=0;w<6;w+=2){var b=w?o:h,C=b?b[0]:0,S=b?b[1]:0,M=d[w],P=d[w+1],k=M-C,I=M+C,z=P-S,T=P+S;k<f&&(f=k),I>_&&(_=I),z<g&&(g=z),T>v&&(v=T)}}return new x(f,g,_-f,v-g)}}});D.inject({statics:new function(){var t=.5522847498307936,e=[new E([-1,0],[0,t],[0,-t]),new E([0,-1],[-t,0],[t,0]),new E([1,0],[0,-t],[0,t]),new E([0,1],[t,0],[-t,0])];function n(t,e,n){var i=u.getNamed(n),r=new D(i&&0==i.insert&&P.NO_INSERT);return r._add(t),r._closed=e,r.set(i,{insert:!0})}function i(t,i,r){for(var s=new Array(4),a=0;a<4;a++){var o=e[a];s[a]=new E(o._point.multiply(i).add(t),o._handleIn.multiply(i),o._handleOut.multiply(i))}return n(s,!0,r)}return{Line:function(){return n([new E(p.readNamed(arguments,"from")),new E(p.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var t=p.readNamed(arguments,"center"),e=u.readNamed(arguments,"radius");return i(t,new y(e),arguments)},Rectangle:function(){var e=x.readNamed(arguments,"rectangle"),i=y.readNamed(arguments,"radius",0,{readNull:!0}),r=e.getBottomLeft(!0),s=e.getTopLeft(!0),a=e.getTopRight(!0),o=e.getBottomRight(!0),h;if(!i||i.isZero())h=[new E(r),new E(s),new E(a),new E(o)];else{var l=(i=y.min(i,e.getSize(!0).divide(2))).width,u=i.height,c=l*t,d=u*t;h=[new E(r.add(l,0),null,[-c,0]),new E(r.subtract(0,u),[0,d]),new E(s.add(0,u),null,[0,-d]),new E(s.add(l,0),[-c,0],null),new E(a.subtract(l,0),null,[c,0]),new E(a.add(0,u),[0,-d],null),new E(o.subtract(0,u),null,[0,d]),new E(o.subtract(l,0),[c,0])]}return n(h,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=z._readEllipse(arguments);return i(t.center,t.radius,arguments)},Oval:"#Ellipse",Arc:function(){var t=p.readNamed(arguments,"from"),e=p.readNamed(arguments,"through"),n=p.readNamed(arguments,"to"),i=u.getNamed(arguments),r=new D(i&&0==i.insert&&P.NO_INSERT);return r.moveTo(t),r.arcTo(e,n),r.set(i)},RegularPolygon:function(){for(var t=p.readNamed(arguments,"center"),e=u.readNamed(arguments,"sides"),i=u.readNamed(arguments,"radius"),r=360/e,s=e%3==0,a=new p(0,s?-i:i),o=s?-1:.5,h=new Array(e),l=0;l<e;l++)h[l]=new E(t.add(a.rotate((l+o)*r)));return n(h,!0,arguments)},Star:function(){for(var t=p.readNamed(arguments,"center"),e=2*u.readNamed(arguments,"points"),i=u.readNamed(arguments,"radius1"),r=u.readNamed(arguments,"radius2"),s=360/e,a=new p(0,-1),o=new Array(e),h=0;h<e;h++)o[h]=new E(t.add(a.rotate(s*h).multiply(h%2?r:i)));return n(o,!0,arguments)}}}});var F=R.extend({_class:"CompoundPath",_serializeFields:{children:[]},beans:!0,initialize:function t(e){this._children=[],this._namedChildren={},this._initialize(e)||("string"==typeof e?this.setPathData(e):this.addChildren(Array.isArray(e)?e:arguments))},insertChildren:function t(e,n){var i=n,r=i[0];r&&"number"==typeof r[0]&&(i=[i]);for(var s=n.length-1;s>=0;s--){var a=i[s];i!==n||a instanceof D||(i=u.slice(i)),Array.isArray(a)?i[s]=new D({segments:a,insert:!1}):a instanceof F&&(i.splice.apply(i,[s,1].concat(a.removeChildren())),a.remove())}return t.base.call(this,e,i)},reduce:function t(e){for(var n=this._children,i=n.length-1,r;i>=0;i--){var r;(r=n[i].reduce(e)).isEmpty()&&r.remove()}return n.length?t.base.call(this):((r=new D(P.NO_INSERT)).copyAttributes(this),r.insertAbove(this),this.remove(),r)},isClosed:function(){for(var t=this._children,e=0,n=t.length;e<n;e++)if(!t[e]._closed)return!1;return!0},setClosed:function(t){for(var e=this._children,n=0,i=e.length;n<i;n++)e[n].setClosed(t)},getFirstSegment:function(){var t=this.getFirstChild();return t&&t.getFirstSegment()},getLastSegment:function(){var t=this.getLastChild();return t&&t.getLastSegment()},getCurves:function(){for(var t=this._children,e=[],n=0,i=t.length;n<i;n++)e.push.apply(e,t[n].getCurves());return e},getFirstCurve:function(){var t=this.getFirstChild();return t&&t.getFirstCurve()},getLastCurve:function(){var t=this.getLastChild();return t&&t.getLastCurve()},getArea:function(){for(var t=this._children,e=0,n=0,i=t.length;n<i;n++)e+=t[n].getArea();return e},getLength:function(){for(var t=this._children,e=0,n=0,i=t.length;n<i;n++)e+=t[n].getLength();return e},getPathData:function(t,e){for(var n=this._children,i=[],r=0,s=n.length;r<s;r++){var a=n[r],o=a._matrix;i.push(a.getPathData(t&&!o.isIdentity()?t.appended(o):t,e))}return i.join("")},_hitTestChildren:function t(e,n,i){return t.base.call(this,e,n.class===D||"path"===n.type?n:u.set({},n,{fill:!1}),i)},_draw:function(t,e,n,i){var r=this._children;if(r.length){e=e.extend({dontStart:!0,dontFinish:!0}),t.beginPath();for(var s=0,a=r.length;s<a;s++)r[s].draw(t,e,i);if(!e.clip){this._setStyles(t,e,n);var o=this._style;o.hasFill()&&(t.fill(o.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),o.hasStroke()&&t.stroke()}}},_drawSelected:function(t,e,n){for(var i=this._children,r=0,s=i.length;r<s;r++){var a=i[r],o=a._matrix;n[a._id]||a._drawSelected(t,o.isIdentity()?e:e.appended(o))}}},new function(){function t(t,e){var n=t._children;if(e&&!n.length)throw new Error("Use a moveTo() command first");return n[n.length-1]}return u.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(e){this[e]=function(){var n=t(this,!0);n[e].apply(n,arguments)}},{moveTo:function(){var e=t(this),n=e&&e.isEmpty()?e:new D(P.NO_INSERT);n!==e&&this.addChild(n),n.moveTo.apply(n,arguments)},moveBy:function(){var e=t(this,!0),n=e&&e.getLastSegment(),i=p.read(arguments);this.moveTo(n?i.add(n._point):i)},closePath:function(e){t(this,!0).closePath(e)}})},u.each(["reverse","flatten","simplify","smooth"],function(t){this[t]=function(e){for(var n=this._children,i,r=0,s=n.length;r<s;r++)i=n[r][t](e)||i;return i}},{}));R.inject(new function(){var t=Math.min,e=Math.max,n=Math.abs,i={unite:{1:!0,2:!0},intersect:{2:!0},subtract:{1:!0},exclude:{1:!0,"-1":!0}};function r(t,e){var n=t.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);return e?n.resolveCrossings().reorient("nonzero"===n.getFillRule(),!0):n}function s(t,e,n,i,r){var s=new F(P.NO_INSERT);return s.addChildren(t,!0),s=s.reduce({simplify:e}),r&&0==r.insert||s.insertAbove(i&&n.isSibling(i)&&n.getIndex()<i.getIndex()?i:n),s.copyAttributes(n,!0),s}function a(t,e,n,a){if(a&&(0==a.trace||a.stroke)&&/^(subtract|intersect)$/.test(n))return h(t,e,n);var o=r(t,!0),l=e&&t!==e&&r(e,!0),u=i[n];u[n]=!0,l&&(u.subtract||u.exclude)^l.isClockwise()^o.isClockwise()&&l.reverse();var c=f(j.expand(o.getCrossings(l))),_=o._children||[o],g=l&&(l._children||[l]),m=[],y=[],w;function x(t){for(var e=0,n=t.length;e<n;e++){var i=t[e];m.push.apply(m,i._segments),y.push.apply(y,i.getCurves()),i._overlapsOnly=!0}}if(c.length){x(_),g&&x(g);for(var b=0,C=c.length;b<C;b++)v(c[b]._segment,o,l,y,u);for(var b=0,C=m.length;b<C;b++){var S=m[b],M=S._intersection;S._winding||v(S,o,l,y,u),M&&M._overlap||(S._path._overlapsOnly=!1)}w=p(m,u)}else w=d(g?_.concat(g):_.slice(),function(t){return!!u[t]});return s(w,!0,t,e,a)}function h(t,e,n){var i=r(t),a=r(e),o=i.getCrossings(a),h="subtract"===n,l="divide"===n,u={},c=[];function d(t){if(!u[t._id]&&(l||a.contains(t.getPointAt(t.getLength()/2))^h))return c.unshift(t),u[t._id]=!0}for(var f=o.length-1;f>=0;f--){var _=o[f].split();_&&(d(_)&&_.getFirstSegment().setHandleIn(0,0),i.getLastSegment().setHandleOut(0,0))}return d(i),s(c,!1,t,e)}function l(t,e){for(var n=t;n;){if(n===e)return;n=n._previous}for(;t._next&&t._next!==e;)t=t._next;if(!t._next){for(;e._previous;)e=e._previous;t._next=e,e._previous=t}}function c(t){for(var e=t.length-1;e>=0;e--)t[e].clearHandles()}function d(t,e,i){var r=t&&t.length;if(r){var s=u.each(t,function(t,e){this[t._id]={container:null,winding:t.isClockwise()?1:-1,index:e}},{}),a=t.slice().sort(function(t,e){return n(e.getArea())-n(t.getArea())}),o=a[0];null==i&&(i=o.isClockwise());for(var h=0;h<r;h++){for(var l=a[h],c=s[l._id],d=l.getInteriorPoint(),f=0,_=h-1;_>=0;_--){var g=a[_];if(g.contains(d)){var v=s[g._id];f=v.winding,c.winding+=f,c.container=v.exclude?v.container:g;break}}if(e(c.winding)===e(f))c.exclude=!0,t[c.index]=null;else{var p=c.container;l.setClockwise(p?!p.isClockwise():i)}}}return t}function f(t,e,n){var i=e&&[],r=1e-8,s=1-1e-8,a=!1,o=n||[],h=n&&{},u,d,f;function _(t){return t._path._id+"."+t._segment1._index}for(var g=(n&&n.length)-1;g>=0;g--){var v;(v=n[g])._path&&(h[_(v)]=!0)}for(var g=t.length-1;g>=0;g--){var p=t[g],m=p._time,y=m,w=e&&!e(p),v,x;if((v=p._curve)&&(v!==d?(a=!v.hasHandles()||h&&h[_(v)],u=[],f=null,d=v):f>=1e-8&&(m/=f)),w)u&&u.push(p);else{if(e&&i.unshift(p),f=y,m<1e-8)x=v._segment1;else if(m>s)x=v._segment2;else{var b=v.divideAtTime(m,!0);a&&o.push(v,b),x=b._segment1;for(var C=u.length-1;C>=0;C--){var S=u[C];S._time=(S._time-m)/(1-m)}}p._setSegment(x);var M=x._intersection,P=p._intersection;if(M){l(M,P);for(var k=M;k;)l(k._intersection,M),k=k._next}else x._intersection=P}}return n||c(o),i||t}function _(i,r,s,a,o){var h=s?1:0,l=1^h,u=[i.x,i.y],c=u[h],d=u[l],f=1e-9,g=1e-6,v=c-1e-9,p=c+1e-9,m=0,y=0,w=0,x=0,b=!1,C=!1,S=1,M=[],P,k;function I(n){var u=n[l+0],f=n[l+6];if(!(d<t(u,f)||d>e(u,f))){var m=n[h+0],y=n[h+2],C=n[h+4],k=n[h+6];if(u!==f){var I=d===u?0:d===f?1:v>e(m,y,C,k)||p<t(m,y,C,k)?1:B.solveCubic(n,l,d,M,0,1)>0?M[0]:1,z=0===I?m:1===I?k:B.getPoint(n,I)[s?"y":"x"],T=u>f?1:-1,O=P[l]>P[l+6]?1:-1,A=P[h+6];return d!==u?(z<v?w+=T:z>p?x+=T:b=!0,z>c-g&&z<c+g&&(S/=2)):(T!==O?m<v?w+=T:m>p&&(x+=T):m!=A&&(A<p&&z>p?(x+=T,b=!0):A>v&&z<v&&(w+=T,b=!0)),S=0),P=n,!o&&z>v&&z<p&&0===B.getTangent(n,I)[s?"x":"y"]&&_(i,r,!s,a,!0)}(m<p&&k>v||k<p&&m>v)&&(b=!0)}}function z(n){var i=n[l+0],r=n[l+2],a=n[l+4],o=n[l+6];if(d<=e(i,r,a,o)&&d>=t(i,r,a,o))for(var u=n[h+0],c=n[h+2],f=n[h+4],_=n[h+6],g=v>e(u,c,f,_)||p<t(u,c,f,_)?[n]:B.getMonoCurves(n,s),m,y=0,w=g.length;y<w;y++)if(m=I(g[y]))return m}for(var T=0,O=r.length;T<O;T++){var A=r[T],L=A._path,E=A.getValues(),N;if(!(T&&r[T-1]._path===L||(P=null,L._closed||(k=B.getValues(L.getLastCurve().getSegment2(),A.getSegment1(),null,!a))[l]!==k[l+6]&&(P=k),P))){P=E;for(var j=L.getLastCurve();j&&j!==A;){var R=j.getValues();if(R[l]!==R[l+6]){P=R;break}j=j.getPrevious()}}if(N=z(E))return N;if(T+1===O||r[T+1]._path!==L){if(k&&(N=z(k)))return N;!b||w||x||(w=x=L.isClockwise(a)^s?1:-1),m+=w,y+=x,w=x=0,b&&(C=!0,b=!1),k=null}}return m=n(m),y=n(y),{winding:e(m,y),windingL:m,windingR:y,quality:S,onPath:C}}function v(t,e,i,r,s){var a=[],o=t,h=0,l;do{var u,c=(u=t.getCurve()).getLength();a.push({segment:t,curve:u,length:c}),h+=c,t=t.getNext()}while(t&&!t._intersection&&t!==o);for(var d=[.5,.25,.75],l={winding:0,quality:-1},f=1e-8,v=1-1e-8,p=0;p<d.length&&l.quality<.5;p++)for(var c=h*d[p],m=0,y=a.length;m<y;m++){var w=a[m],x=w.length;if(c<=x){var u,b=(u=w.curve)._path,C=b._parent,S=C instanceof F?C:b,M=g.clamp(u.getTimeAt(c),1e-8,v),P=u.getPointAtTime(M),k=n(u.getTangentAtTime(M).y)<Math.SQRT1_2,I=s.subtract&&i&&(S===e&&i._getWinding(P,k,!0).winding||S===i&&!e._getWinding(P,k,!0).winding)?{winding:0,quality:1}:_(P,r,k,!0);I.quality>l.quality&&(l=I);break}c-=x}for(var m=a.length-1;m>=0;m--)a[m].segment._winding=l}function p(t,e){var n=[],i;function r(t){var n;return!(!t||t._visited||e&&(!e[(n=t._winding||{}).winding]||e.unite&&2===n.winding&&n.windingL&&n.windingR))}function s(t){if(t)for(var e=0,n=i.length;e<n;e++)if(t===i[e])return!0;return!1}function a(t){for(var e=t._segments,n=0,i=e.length;n<i;n++)e[n]._visited=!0}function o(t,e){var n=t._intersection,a=n,o=[];function h(n,a){for(;n&&n!==a;){var h=n._segment,l=h&&h._path;if(l){var u=h.getNext()||l.getFirstSegment(),c=u._intersection;h!==t&&(s(h)||s(u)||u&&r(h)&&(r(u)||c&&r(c._segment)))&&o.push(h),e&&i.push(h)}n=n._next}}if(e&&(i=[t]),n){for(h(n);n&&n._prev;)n=n._prev;h(n,a)}return o}t.sort(function(t,e){var n=t._intersection,i=e._intersection,r=!(!n||!n._overlap),s=!(!i||!i._overlap),a=t._path,o=e._path;return r^s?r?1:-1:!n^!i?n?1:-1:a!==o?a._id-o._id:t._index-e._index});for(var h=0,l=t.length;h<l;h++){var u=t[h],c=r(u),d=null,f=!1,_=!0,g=[],v,p,m;if(c&&u._path._overlapsOnly){var y=u._path,w=u._intersection._segment._path;y.compare(w)&&(y.getArea()&&n.push(y.clone(!1)),a(y),a(w),c=!1)}for(;c;){var x=!d,b=o(u,x),C=b.shift(),f,S=!(f=!x&&(s(u)||s(C)))&&C;if(x&&(d=new D(P.NO_INSERT),v=null),f){(u.isFirst()||u.isLast())&&(_=u._path._closed),u._visited=!0;break}if(S&&v&&(g.push(v),v=null),v||(S&&b.push(u),v={start:d._segments.length,crossings:b,visited:p=[],handleIn:m}),S&&(u=C),!r(u)){d.removeSegments(v.start);for(var M=0,k=p.length;M<k;M++)p[M]._visited=!1;p.length=0;do{(u=v&&v.crossings.shift())&&u._path||(u=null,(v=g.pop())&&(p=v.visited,m=v.handleIn))}while(v&&!r(u));if(!u)break}var I=u.getNext();d.add(new E(u._point,m,I&&u._handleOut)),u._visited=!0,p.push(u),u=I||u._path.getFirstSegment(),m=I&&I._handleIn}f&&(_&&(d.getFirstSegment().setHandleIn(m),d.setClosed(_)),0!==d.getArea()&&n.push(d))}return n}return{_getWinding:function(t,e,n){return _(t,this.getCurves(),e,n)},unite:function(t,e){return a(this,t,"unite",e)},intersect:function(t,e){return a(this,t,"intersect",e)},subtract:function(t,e){return a(this,t,"subtract",e)},exclude:function(t,e){return a(this,t,"exclude",e)},divide:function(t,e){return e&&(0==e.trace||e.stroke)?h(this,t,"divide"):s([this.subtract(t,e),this.intersect(t,e)],!0,this,t,e)},resolveCrossings:function(){var t=this._children,e=t||[this];function n(t,e){var n=t&&t._intersection;return n&&n._overlap&&n._path===e}var i=!1,r=!1,s=this.getIntersections(null,function(t){return t.hasOverlap()&&(i=!0)||t.isCrossing()&&(r=!0)}),a=i&&r&&[];if(s=j.expand(s),i)for(var o=f(s,function(t){return t.hasOverlap()},a),h=o.length-1;h>=0;h--){var l=o[h],d=l._path,_=l._segment,g=_.getPrevious(),v=_.getNext();n(g,d)&&n(v,d)&&(_.remove(),g._handleOut._set(0,0),v._handleIn._set(0,0),g===_||g.getCurve().hasLength()||(v._handleIn.set(g._handleIn),g.remove()))}r&&(f(s,i&&function(t){var e=t.getCurve(),n=t.getSegment(),i=t._intersection,r=i._curve,s=i._segment;if(e&&r&&e._path&&r._path)return!0;n&&(n._intersection=null),s&&(s._intersection=null)},a),a&&c(a),e=p(u.each(e,function(t){this.push.apply(this,t._segments)},[])));var m=e.length,y;return m>1&&t?(e!==t&&this.setChildren(e),y=this):1!==m||t||(e[0]!==this&&this.setSegments(e[0].removeSegments()),y=this),y||((y=new F(P.NO_INSERT)).addChildren(e),(y=y.reduce()).copyAttributes(this),this.replaceWith(y)),y},reorient:function(t,e){var n=this._children;return n&&n.length?this.setChildren(d(this.removeChildren(),function(e){return!!(t?e:1&e)},e)):e!==o&&this.setClockwise(e),this},getInteriorPoint:function(){var n,i=this.getBounds().getCenter(!0);if(!this.contains(i)){for(var r=this.getCurves(),s=i.y,a=[],o=[],h=0,l=r.length;h<l;h++){var u=r[h].getValues(),c=u[1],d=u[3],f=u[5],_=u[7];if(s>=t(c,d,f,_)&&s<=e(c,d,f,_))for(var g=B.getMonoCurves(u),v=0,p=g.length;v<p;v++){var m=g[v],y=m[1],w=m[7];if(y!==w&&(s>=y&&s<=w||s>=w&&s<=y)){var x=s===y?m[0]:s===w?m[6]:1===B.solveCubic(m,1,s,o,0,1)?B.getPoint(m,o[0]).x:(m[0]+m[6])/2;a.push(x)}}}a.length>1&&(a.sort(function(t,e){return t-e}),i.x=(a[0]+a[1])/2)}return i}}});var q=u.extend({_class:"PathFlattener",initialize:function(t,e,n,i,r){var s=[],a=[],o=0,h=1/(n||32),l=t._segments,u=l[0],c;function d(t,e){var n=B.getValues(t,e,r);s.push(n),f(n,t._index,0,1)}function f(t,n,r,s){if(!(s-r>h)||i&&B.isStraight(t)||B.isFlatEnough(t,e||.25)){var l=t[6]-t[0],u=t[7]-t[1],c=Math.sqrt(l*l+u*u);c>0&&(o+=c,a.push({offset:o,curve:t,index:n,time:s}))}else{var d=B.subdivide(t,.5),_=(r+s)/2;f(d[0],n,r,_),f(d[1],n,_,s)}}for(var _=1,g=l.length;_<g;_++)d(u,c=l[_]),u=c;t._closed&&d(c,l[0]),this.curves=s,this.parts=a,this.length=o,this.index=0},_get:function(t){for(var e=this.parts,n=e.length,i,r,s=this.index;r=s,s&&!(e[--s].offset<t););for(;r<n;r++){var a=e[r];if(a.offset>=t){this.index=r;var o=e[r-1],h=o&&o.index===a.index?o.time:0,l=o?o.offset:0;return{index:a.index,time:h+(a.time-h)*(t-l)/(a.offset-l)}}}return{index:e[n-1].index,time:1}},drawPart:function(t,e,n){for(var i=this._get(e),r=this._get(n),s=i.index,a=r.index;s<=a;s++){var o=B.getPart(this.curves[s],s===i.index?i.time:0,s===r.index?r.time:1);s===i.index&&t.moveTo(o[0],o[1]),t.bezierCurveTo.apply(t,o.slice(2))}}},u.each(B._evaluateMethods,function(t){this[t+"At"]=function(e){var n=this._get(e);return B[t](this.curves[n.index],n.time)}},{})),V=u.extend({initialize:function(t){for(var e=this.points=[],n=t._segments,i=t._closed,r=0,s,a=n.length;r<a;r++){var o=n[r].point;s&&s.equals(o)||e.push(s=o.clone())}i&&(e.unshift(e[e.length-1]),e.push(e[1])),this.closed=i},fit:function(t){var e=this.points,n=e.length,i=null;return n>0&&(i=[new E(e[0])],n>1&&(this.fitCubic(i,t,0,n-1,e[1].subtract(e[0]),e[n-2].subtract(e[n-1])),this.closed&&(i.shift(),i.pop()))),i},fitCubic:function(t,e,n,i,r,s){var a=this.points;if(i-n!=1){for(var o=this.chordLengthParameterize(n,i),h=Math.max(e,e*e),l,u=!0,c=0;c<=4;c++){var d=this.generateBezier(n,i,o,r,s),f=this.findMaxError(n,i,d,o);if(f.error<e&&u)return void this.addCurve(t,d);if(l=f.index,f.error>=h)break;u=this.reparameterize(n,i,o,d),h=f.error}var _=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,n,l,r,_),this.fitCubic(t,e,l,i,_.negate(),s)}else{var g=a[n],v=a[i],p=g.getDistance(v)/3;this.addCurve(t,[g,g.add(r.normalize(p)),v.add(s.normalize(p)),v])}},addCurve:function(t,e){var n;t[t.length-1].setHandleOut(e[1].subtract(e[0])),t.push(new E(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,n,i,r){for(var s=1e-12,a=Math.abs,o=this.points,h=o[t],l=o[e],u=[[0,0],[0,0]],c=[0,0],d=0,f=e-t+1;d<f;d++){var _=n[d],g=1-_,v=3*_*g,p=g*g*g,m=v*g,y=v*_,w=_*_*_,x=i.normalize(m),b=r.normalize(y),C=o[t+d].subtract(h.multiply(p+m)).subtract(l.multiply(y+w));u[0][0]+=x.dot(x),u[0][1]+=x.dot(b),u[1][0]=u[0][1],u[1][1]+=b.dot(b),c[0]+=x.dot(C),c[1]+=b.dot(C)}var S=u[0][0]*u[1][1]-u[1][0]*u[0][1],M,P;if(a(S)>1e-12){var k=u[0][0]*c[1]-u[1][0]*c[0],I;M=(c[0]*u[1][1]-c[1]*u[0][1])/S,P=k/S}else{var z=u[0][0]+u[0][1],T=u[1][0]+u[1][1];M=P=a(z)>1e-12?c[0]/z:a(T)>1e-12?c[1]/T:0}var O=l.getDistance(h),A=1e-12*O,L,E;if(M<A||P<A)M=P=O/3;else{var N=l.subtract(h);L=i.normalize(M),E=r.normalize(P),L.dot(N)-E.dot(N)>O*O&&(M=P=O/3,L=E=null)}return[h,h.add(L||i.normalize(M)),l.add(E||r.normalize(P)),l]},reparameterize:function(t,e,n,i){for(var r=t;r<=e;r++)n[r-t]=this.findRoot(i,this.points[r],n[r-t]);for(var r=1,s=n.length;r<s;r++)if(n[r]<=n[r-1])return!1;return!0},findRoot:function(t,e,n){for(var i=[],r=[],s=0;s<=2;s++)i[s]=t[s+1].subtract(t[s]).multiply(3);for(var s=0;s<=1;s++)r[s]=i[s+1].subtract(i[s]).multiply(2);var a=this.evaluate(3,t,n),o=this.evaluate(2,i,n),h=this.evaluate(1,r,n),l=a.subtract(e),u=o.dot(o)+l.dot(h);return g.isZero(u)?n:n-l.dot(o)/u},evaluate:function(t,e,n){for(var i=e.slice(),r=1;r<=t;r++)for(var s=0;s<=t-r;s++)i[s]=i[s].multiply(1-n).add(i[s+1].multiply(n));return i[0]},chordLengthParameterize:function(t,e){for(var n=[0],i=t+1;i<=e;i++)n[i-t]=n[i-t-1]+this.points[i].getDistance(this.points[i-1]);for(var i=1,r=e-t;i<=r;i++)n[i]/=n[r];return n},findMaxError:function(t,e,n,i){for(var r=Math.floor((e-t+1)/2),s=0,a=t+1;a<e;a++){var o,h=this.evaluate(3,n,i[a-t]).subtract(this.points[a]),l=h.x*h.x+h.y*h.y;l>=s&&(s=l,r=a)}return{error:s,index:r}}}),H=P.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function t(e){this._content="",this._lines=[];var n=e&&u.isPlainObject(e)&&e.x===o&&e.y===o;this._initialize(n&&e,!n&&p.read(arguments))},_equals:function(t){return this._content===t._content},copyContent:function(t){this.setContent(t._content)},getContent:function(){return this._content},setContent:function(t){this._content=""+t,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),Z=H.extend({_class:"PointText",initialize:function t(){H.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new m(t.x,t.y,this,"setPoint")},setPoint:function(){var t=p.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,n){if(this._content){this._setStyles(t,e,n);var i=this._lines,r=this._style,s=r.hasFill(),a=r.hasStroke(),o=r.getLeading(),h=t.shadowColor;t.font=r.getFontStyle(),t.textAlign=r.getJustification();for(var l=0,u=i.length;l<u;l++){t.shadowColor=h;var c=i[l];s&&(t.fillText(c,0,0),t.shadowColor="rgba(0,0,0,0)"),a&&t.strokeText(c,0,0),t.translate(0,o)}}},_getBounds:function(t,e){var n=this._style,i=this._lines,r=i.length,s=n.getJustification(),a=n.getLeading(),o=this.getView().getTextWidth(n.getFontStyle(),i),h=0;"left"!==s&&(h-=o/("center"===s?2:1));var l=new x(h,r?-.75*a:0,o,r*a);return t?t._transformBounds(l,l):l}}),U=u.extend(new function(){var t={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},e={},n={},i;function r(t){var e=t.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/),r;if(e){r=[0,0,0];for(var s=0;s<3;s++){var a=e[s+1];r[s]=parseInt(1==a.length?a+a:a,16)/255}}else if(e=t.match(/^rgba?\((.*)\)$/))for(var s=0,o=(r=e[1].split(",")).length;s<o;s++){var a=+r[s];r[s]=s<3?a/255:a}else if(h){var l=n[t];if(!l){i||((i=at.getContext(1,1)).globalCompositeOperation="copy"),i.fillStyle="rgba(0,0,0,0)",i.fillStyle=t,i.fillRect(0,0,1,1);var u=i.getImageData(0,0,1,1).data;l=n[t]=[u[0]/255,u[1]/255,u[2]/255]}r=l.slice()}else r=[0,0,0];return r}var s=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],a={"rgb-hsb":function(t,e,n){var i=Math.max(t,e,n),r,s=i-Math.min(t,e,n),a;return[0===s?0:60*(i==t?(e-n)/s+(e<n?6:0):i==e?(n-t)/s+2:(t-e)/s+4),0===i?0:s/i,i]},"hsb-rgb":function(t,e,n){var i,r=(t=(t/60%6+6)%6)-(i=Math.floor(t)),i,a=[n,n*(1-e),n*(1-e*r),n*(1-e*(1-r))];return[a[(i=s[i])[0]],a[i[1]],a[i[2]]]},"rgb-hsl":function(t,e,n){var i=Math.max(t,e,n),r=Math.min(t,e,n),s=i-r,a=0===s,o,h=(i+r)/2,l;return[a?0:60*(i==t?(e-n)/s+(e<n?6:0):i==e?(n-t)/s+2:(t-e)/s+4),a?0:h<.5?s/(i+r):s/(2-i-r),h]},"hsl-rgb":function(t,e,n){if(t=(t/360%1+1)%1,0===e)return[n,n,n];for(var i=[t+1/3,t,t-1/3],r=n<.5?n*(1+e):n+e-n*e,s=2*n-r,a=[],o=0;o<3;o++){var h=i[o];h<0&&(h+=1),h>1&&(h-=1),a[o]=6*h<1?s+6*(r-s)*h:2*h<1?r:3*h<2?s+(r-s)*(2/3-h)*6:s}return a},"rgb-gray":function(t,e,n){return[.2989*t+.587*e+.114*n]},"gray-rgb":function(t){return[t,t,t]},"gray-hsb":function(t){return[0,0,t]},"gray-hsl":function(t){return[0,0,t]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return u.each(t,function(n,i){e[i]=[],u.each(n,function(n,r){var s=u.capitalize(n),a=/^(hue|saturation)$/.test(n),o=e[i][r]="gradient"===n?function(t){var e=this._components[0];return e!==(t=W.read(Array.isArray(t)?t:arguments,0,{readNull:!0}))&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:"gradient"===i?function(){return p.read(arguments,0,{readNull:"highlight"===n,clone:!0})}:function(t){return null==t||isNaN(t)?0:t};this["get"+s]=function(){return this._type===i||a&&/^hs[bl]$/.test(this._type)?this._components[r]:this._convert(i)[r]},this["set"+s]=function(e){this._type===i||a&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(i),this._properties=t[i],this._type=i),this._components[r]=o.call(this,e),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function n(i){var s=arguments,a=this.__read,o=0,h,l,c,d;Array.isArray(i)&&(i=(s=i)[0]);var f=null!=i&&typeof i;if("string"===f&&i in t&&(h=i,i=s[1],Array.isArray(i)?(l=i,c=s[2]):(a&&(o=1),s=u.slice(s,1),f=typeof i)),!l){if(d="number"===f?s:"object"===f&&null!=i.length?i:null){h||(h=d.length>=3?"rgb":"gray");var _=t[h].length;c=d[_],a&&(o+=d===arguments?_+(null!=c?1:0):1),d.length>_&&(d=u.slice(d,0,_))}else if("string"===f)h="rgb",4===(l=r(i)).length&&(c=l[3],l.length--);else if("object"===f)if(i.constructor===n){if(h=i._type,l=i._components.slice(),c=i._alpha,"gradient"===h)for(var g=1,v=l.length;g<v;g++){var p=l[g];p&&(l[g]=p.clone())}}else if(i.constructor===W)h="gradient",d=s;else{var m=t[h="hue"in i?"lightness"in i?"hsl":"hsb":"gradient"in i||"stops"in i||"radial"in i?"gradient":"gray"in i?"gray":"rgb"],y=e[h];this._components=l=[];for(var g=0,v=m.length;g<v;g++){var w;null==(w=i[m[g]])&&!g&&"gradient"===h&&"stops"in i&&(w={stops:i.stops,radial:i.radial}),null!=(w=y[g].call(this,w))&&(l[g]=w)}c=i.alpha}a&&h&&(o=1)}if(this._type=h||"rgb",!l){this._components=l=[];for(var y,g=0,v=(y=e[this._type]).length;g<v;g++){var w;null!=(w=y[g].call(this,d&&d[g]))&&(l[g]=w)}}return this._components=l,this._properties=t[this._type],this._alpha=c,a&&(this.__read=o),this},set:"#initialize",_serialize:function(t,e){var n=this.getComponents();return u.serialize(/^(gray|rgb)$/.test(this._type)?n:[this._type].concat(n),t,!0,e)},_changed:function(){this._canvasStyle=null,this._owner&&this._owner._changed(65)},_convert:function(t){var e;return this._type===t?this._components.slice():(e=a[this._type+"-"+t])?e.apply(this,this._components):a["rgb-"+t].apply(this,a[this._type+"-rgb"].apply(this,this._components))},convert:function(t){return new U(t,this._convert(t),this._alpha)},getType:function(){return this._type},setType:function(e){this._components=this._convert(e),this._properties=t[e],this._type=e},getComponents:function(){var t=this._components.slice();return null!=this._alpha&&t.push(this._alpha),t},getAlpha:function(){return null!=this._alpha?this._alpha:1},setAlpha:function(t){this._alpha=null==t?null:Math.min(Math.max(t,0),1),this._changed()},hasAlpha:function(){return null!=this._alpha},equals:function(t){var e=u.isPlainValue(t,!0)?U.read(arguments):t;return e===this||e&&this._class===e._class&&this._type===e._type&&this.getAlpha()===e.getAlpha()&&u.equals(this._components,e._components)||!1},toString:function(){for(var t=this._properties,e=[],n="gradient"===this._type,i=_.instance,r=0,s=t.length;r<s;r++){var a=this._components[r];null!=a&&e.push(t[r]+": "+(n?a:i.number(a)))}return null!=this._alpha&&e.push("alpha: "+i.number(this._alpha)),"{ "+e.join(", ")+" }"},toCSS:function(t){var e=this._convert("rgb"),n=t||null==this._alpha?1:this._alpha;function i(t){return Math.round(255*(t<0?0:t>1?1:t))}return e=[i(e[0]),i(e[1]),i(e[2])],n<1&&e.push(n<0?0:n),t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):(4==e.length?"rgba(":"rgb(")+e.join(",")+")"},toCanvasStyle:function(t,e){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var n=this._components,i=n[0],r=i._stops,s=n[1],a=n[2],o=n[3],h=e&&e.inverted(),l;if(h&&(s=h._transformPoint(s),a=h._transformPoint(a),o&&(o=h._transformPoint(o))),i._radial){var u=a.getDistance(s);if(o){var c=o.subtract(s);c.getLength()>u&&(o=s.add(c.normalize(u-.1)))}var d=o||s;l=t.createRadialGradient(d.x,d.y,0,s.x,s.y,u)}else l=t.createLinearGradient(s.x,s.y,a.x,a.y);for(var f=0,_=r.length;f<_;f++){var g=r[f],v=g._offset;l.addColorStop(null==v?f/(_-1):v,g._color.toCanvasStyle())}return this._canvasStyle=l},transform:function(t){if("gradient"===this._type){for(var e=this._components,n=1,i=e.length;n<i;n++){var r=e[n];t._transformPoint(r,r,!0)}this._changed()}},statics:{_types:t,random:function(){var t=Math.random;return new U(t(),t(),t())}}})},new function(){var t={add:function(t,e){return t+e},subtract:function(t,e){return t-e},multiply:function(t,e){return t*e},divide:function(t,e){return t/e}};return u.each(t,function(t,e){this[e]=function(e){e=U.read(arguments);for(var n=this._type,i=this._components,r=e._convert(n),s=0,a=i.length;s<a;s++)r[s]=t(i[s],r[s]);return new U(n,r,null!=this._alpha?t(this._alpha,e.getAlpha()):null)}},{})}),W=u.extend({_class:"Gradient",initialize:function t(e,n){this._id=v.get(),e&&u.isPlainObject(e)&&(this.set(e),e=n=null),null==this._stops&&this.setStops(e||["white","black"]),null==this._radial&&this.setRadial("string"==typeof n&&"radial"===n||n||!1)},_serialize:function(t,e){return e.add(this,function(){return u.serialize([this._stops,this._radial],t,!0,e)})},_changed:function(){for(var t=0,e=this._owners&&this._owners.length;t<e;t++)this._owners[t]._changed()},_addOwner:function(t){this._owners||(this._owners=[]),this._owners.push(t)},_removeOwner:function(t){var e=this._owners?this._owners.indexOf(t):-1;-1!=e&&(this._owners.splice(e,1),this._owners.length||(this._owners=o))},clone:function(){for(var t=[],e=0,n=this._stops.length;e<n;e++)t[e]=this._stops[e].clone();return new W(t,this._radial)},getStops:function(){return this._stops},setStops:function(t){if(t.length<2)throw new Error("Gradient stop list needs to contain at least two stops.");var e=this._stops;if(e)for(var n=0,i=e.length;n<i;n++)e[n]._owner=o;for(var n=0,i=(e=this._stops=G.readList(t,0,{clone:!0})).length;n<i;n++)e[n]._owner=this;this._changed()},getRadial:function(){return this._radial},setRadial:function(t){this._radial=t,this._changed()},equals:function(t){if(t===this)return!0;if(t&&this._class===t._class){var e=this._stops,n=t._stops,i=e.length;if(i===n.length){for(var r=0;r<i;r++)if(!e[r].equals(n[r]))return!1;return!0}}return!1}}),G=u.extend({_class:"GradientStop",initialize:function t(e,n){var i=e,r=n;"object"==typeof e&&n===o&&(Array.isArray(e)&&"number"!=typeof e[0]?(i=e[0],r=e[1]):("color"in e||"offset"in e||"rampPoint"in e)&&(i=e.color,r=e.offset||e.rampPoint||0)),this.setColor(i),this.setOffset(r)},clone:function(){return new G(this._color.clone(),this._offset)},_serialize:function(t,e){var n=this._color,i=this._offset;return u.serialize(null==i?[n]:[n,i],t,!0,e)},_changed:function(){this._owner&&this._owner._changed(65)},getOffset:function(){return this._offset},setOffset:function(t){this._offset=t,this._changed()},getRampPoint:"#getOffset",setRampPoint:"#setOffset",getColor:function(){return this._color},setColor:function(){var t=U.read(arguments,0,{clone:!0});t&&(t._owner=this),this._color=t,this._changed()},equals:function(t){return t===this||t&&this._class===t._class&&this._color.equals(t._color)&&this._offset==t._offset||!1}}),J=u.extend(new function(){var t={fillColor:null,fillRule:"nonzero",strokeColor:null,strokeWidth:1,strokeCap:"butt",strokeJoin:"miter",strokeScaling:!0,miterLimit:10,dashOffset:0,dashArray:[],shadowColor:null,shadowBlur:0,shadowOffset:new p,selectedColor:null},e=u.set({},t,{fontFamily:"sans-serif",fontWeight:"normal",fontSize:12,leading:null,justification:"left"}),n=u.set({},e,{fillColor:new U}),i={strokeWidth:97,strokeCap:97,strokeJoin:97,strokeScaling:105,miterLimit:97,fontFamily:9,fontWeight:9,fontSize:9,font:9,leading:9,justification:9},r={beans:!0},a={_class:"Style",beans:!0,initialize:function i(r,a,o){this._values={},this._owner=a,this._project=a&&a._project||o||s.project,this._defaults=!a||a instanceof k?e:a instanceof H?n:t,r&&this.set(r)}};return u.each(e,function(t,e){var n=/Color$/.test(e),s="shadowOffset"===e,h=u.capitalize(e),l=i[e],c="set"+h,d="get"+h;a[c]=function(t){var i=this._owner,r=i&&i._children;if(r&&r.length>0&&!(i instanceof F))for(var s=0,a=r.length;s<a;s++)r[s]._style[c](t);else if(e in this._defaults){var h=this._values[e];h!==t&&(n&&(h&&h._owner!==o&&(h._owner=o),t&&t.constructor===U&&(t._owner&&(t=t.clone()),t._owner=i)),this._values[e]=t,i&&i._changed(l||65))}},a[d]=function(t){var i=this._owner,r=i&&i._children,a,a;if(e in this._defaults&&(!r||!r.length||t||i instanceof F))if((a=this._values[e])===o)(a=this._defaults[e])&&a.clone&&(a=a.clone());else{var h=n?U:s?p:null;!h||a&&a.constructor===h||(this._values[e]=a=h.read([a],0,{readNull:!0,clone:!0}),a&&n&&(a._owner=i))}else if(r)for(var l=0,c=r.length;l<c;l++){var f=r[l]._style[d]();if(l){if(!u.equals(a,f))return o}else a=f}return a},r[d]=function(t){return this._style[d](t)},r[c]=function(t){this._style[c](t)}}),u.each({Font:"FontFamily",WindingRule:"FillRule"},function(t,e){var n="get"+e,i="set"+e;a[n]=r[n]="#get"+t,a[i]=r[i]="#set"+t}),P.inject(r),a},{set:function(t){var e=t instanceof J,n=e?t._values:t;if(n)for(var i in n)if(i in this._defaults){var r=n[i];this[i]=r&&e&&r.clone?r.clone():r}},equals:function(t){function e(t,e,n){var i=t._values,r=e._values,s=e._defaults;for(var a in i){var h=i[a],l=r[a];if(!(n&&a in r||u.equals(h,l===o?s[a]:l)))return!1}return!0}return t===this||t&&this._class===t._class&&e(this,t)&&e(t,this,!0)||!1},hasFill:function(){var t=this.getFillColor();return!!t&&t.alpha>0},hasStroke:function(){var t=this.getStrokeColor();return!!t&&t.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var t=this.getShadowColor();return!!t&&t.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var t=this.getFontSize();return this.getFontWeight()+" "+t+(/[a-z]/i.test(t+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function t(){var e=t.base.call(this),n=this.getFontSize();return/pt|em|%|px/.test(n)&&(n=this.getView().getPixelSize(n)),null!=e?e:1.2*n}}),$=new function(){function t(t,e,n,i){for(var r=["","webkit","moz","Moz","ms","o"],s=e[0].toUpperCase()+e.substring(1),a=0;a<6;a++){var o=r[a],h=o?o+s:e;if(h in t){if(!n)return t[h];t[h]=i;break}}}return{getStyles:function(t){var e=t&&9!==t.nodeType?t.ownerDocument:t,n=e&&e.defaultView;return n&&n.getComputedStyle(t,"")},getBounds:function(t,e){var n=t.ownerDocument,i=n.body,r=n.documentElement,s;try{s=t.getBoundingClientRect()}catch(t){s={left:0,top:0,width:0,height:0}}var a=s.left-(r.clientLeft||i.clientLeft||0),o=s.top-(r.clientTop||i.clientTop||0);if(!e){var h=n.defaultView;a+=h.pageXOffset||r.scrollLeft||i.scrollLeft,o+=h.pageYOffset||r.scrollTop||i.scrollTop}return new x(a,o,s.width,s.height)},getViewportBounds:function(t){var e=t.ownerDocument,n=e.defaultView,i=e.documentElement;return new x(0,0,n.innerWidth||i.clientWidth,n.innerHeight||i.clientHeight)},getOffset:function(t,e){return $.getBounds(t,e).getPoint()},getSize:function(t){return $.getBounds(t,!0).getSize()},isInvisible:function(t){return $.getSize(t).equals(new y(0,0))},isInView:function(t){return!$.isInvisible(t)&&$.getViewportBounds(t).intersects($.getBounds(t,!0))},isInserted:function(t){return l.body.contains(t)},getPrefixed:function(e,n){return e&&t(e,n)},setPrefixed:function(e,n,i){if("object"==typeof n)for(var r in n)t(e,r,!0,n[r]);else t(e,n,!0,i)}}},K={add:function(t,e){if(t)for(var n in e)for(var i=e[n],r=n.split(/[\s,]+/g),s=0,a=r.length;s<a;s++)t.addEventListener(r[s],i,!1)},remove:function(t,e){if(t)for(var n in e)for(var i=e[n],r=n.split(/[\s,]+/g),s=0,a=r.length;s<a;s++)t.removeEventListener(r[s],i,!1)},getPoint:function(t){var e=t.targetTouches?t.targetTouches.length?t.targetTouches[0]:t.changedTouches[0]:t;return new p(e.pageX||e.clientX+l.documentElement.scrollLeft,e.pageY||e.clientY+l.documentElement.scrollTop)},getTarget:function(t){return t.target||t.srcElement},getRelatedTarget:function(t){return t.relatedTarget||t.toElement},getOffset:function(t,e){return K.getPoint(t).subtract($.getOffset(e||K.getTarget(t)))}};K.requestAnimationFrame=new function(){var t=$.getPrefixed(h,"requestAnimationFrame"),e=!1,n=[],i;function r(){var i=n;n=[];for(var s=0,a=i.length;s<a;s++)i[s]();(e=t&&n.length)&&t(r)}return function(s){n.push(s),t?e||(t(r),e=!0):i||(i=setInterval(r,1e3/60))}};var X=u.extend(c,{_class:"View",initialize:function t(e,n){function i(t){return n[t]||parseInt(n.getAttribute(t),10)}function r(){var t=$.getSize(n);return t.isNaN()||t.isZero()?new y(i("width"),i("height")):t}var a;if(h&&n){this._id=n.getAttribute("id"),null==this._id&&n.setAttribute("id",this._id="view-"+t._id++),K.add(n,this._viewEvents);var o="none";if($.setPrefixed(n.style,{userDrag:o,userSelect:o,touchCallout:o,contentZooming:o,tapHighlightColor:"rgba(0,0,0,0)"}),d.hasAttribute(n,"resize")){var u=this;K.add(h,this._windowEvents={resize:function(){u.setViewSize(r())}})}if(a=r(),d.hasAttribute(n,"stats")&&"undefined"!=typeof Stats){this._stats=new Stats;var c=this._stats.domElement,f=c.style,_=$.getOffset(n);f.position="absolute",f.left=_.x+"px",f.top=_.y+"px",l.body.appendChild(c)}}else a=new y(n),n=null;this._project=e,this._scope=e._scope,this._element=n,this._pixelRatio||(this._pixelRatio=h&&h.devicePixelRatio||1),this._setElementSize(a.width,a.height),this._viewSize=a,t._views.push(this),t._viewsById[this._id]=this,(this._matrix=new C)._owner=this,t._focused||(t._focused=this),this._frameItems={},this._frameItemCount=0,this._itemEvents={native:{},virtual:{}},this._autoUpdate=!s.agent.node,this._needsUpdate=!1},remove:function(){if(!this._project)return!1;X._focused===this&&(X._focused=null),X._views.splice(X._views.indexOf(this),1),delete X._viewsById[this._id];var t=this._project;return t._view===this&&(t._view=null),K.remove(this._element,this._viewEvents),K.remove(h,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0},_events:u.each(P._itemHandlers.concat(["onResize","onKeyDown","onKeyUp"]),function(t){this[t]={}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,getAutoUpdate:function(){return this._autoUpdate},setAutoUpdate:function(t){this._autoUpdate=t,t&&this.requestUpdate()},update:function(){},draw:function(){this.update()},requestUpdate:function(){if(!this._requested){var t=this;K.requestAnimationFrame(function(){if(t._requested=!1,t._animate){t.requestUpdate();var e=t._element;$.getPrefixed(l,"hidden")&&"true"!==d.getAttribute(e,"keepalive")||!$.isInView(e)||t._handleFrame()}t._autoUpdate&&t.update()}),this._requested=!0}},play:function(){this._animate=!0,this.requestUpdate()},pause:function(){this._animate=!1},_handleFrame:function(){s=this._scope;var t=Date.now()/1e3,e=this._last?t-this._last:0;this._last=t,this.emit("frame",new u({delta:e,time:this._time+=e,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(t,e){var n=this._frameItems;e?(n[t._id]={item:t,time:0,count:0},1==++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete n[t._id],0==--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(t){for(var e in this._frameItems){var n=this._frameItems[e];n.item.emit("frame",new u(t,{time:n.time+=t.delta,count:n.count++}))}},_changed:function(){this._project._changed(2049),this._bounds=this._decomposed=o},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var t=this._viewSize;return new w(t.width,t.height,this,"setViewSize")},setViewSize:function(){var t=y.read(arguments),e=t.subtract(this._viewSize);e.isZero()||(this._setElementSize(t.width,t.height),this._viewSize.set(t),this._changed(),this.emit("resize",{size:t,delta:e}),this._autoUpdate&&this.update())},_setElementSize:function(t,e){var n=this._element;n&&(n.width!==t&&(n.width=t),n.height!==e&&(n.height=e))},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new x(new p,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},isVisible:function(){return $.isInView(this._element)},isInserted:function(){return $.isInserted(this._element)},getPixelSize:function(t){var e=this._element,n;if(e){var i=e.parentNode,r=l.createElement("div");r.style.fontSize=t,i.appendChild(r),n=parseFloat($.getStyles(r).fontSize),i.removeChild(r)}else n=parseFloat(n);return n},getTextWidth:function(t,e){return 0}},u.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var n=(e?u:p).read(arguments),i=p.read(arguments,0,{readNull:!0});return this.transform((new C)[t](n,i||this.getCenter(!0)))}},{_decompose:function(){return this._decomposed||(this._decomposed=this._matrix.decompose())},translate:function(){var t=new C;return this.transform(t.translate.apply(t,arguments))},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var t=p.read(arguments);this.translate(this.getCenter().subtract(t))},getZoom:function(){var t=this._decompose(),e=t&&t.scaling;return e?(e.x+e.y)/2:0},setZoom:function(t){this.transform((new C).scale(t/this.getZoom(),this.getCenter()))},getRotation:function(){var t=this._decompose();return t&&t.rotation},setRotation:function(t){var e=this.getRotation();null!=e&&null!=t&&this.rotate(t-e)},getScaling:function(){var t=this._decompose(),e=t&&t.scaling;return e?new m(e.x,e.y,this,"setScaling"):o},setScaling:function(){var t=this.getScaling(),e=p.read(arguments,0,{clone:!0,readNull:!0});t&&e&&this.scale(e.x/t.x,e.y/t.y)},getMatrix:function(){return this._matrix},setMatrix:function(){var t=this._matrix;t.initialize.apply(t,arguments)},transform:function(t){this._matrix.append(t)},scrollBy:function(){this.translate(p.read(arguments).negate())}}),{projectToView:function(){return this._matrix._transformPoint(p.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(p.read(arguments))},getEventPoint:function(t){return this.viewToProject(K.getOffset(t,this._element))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(t,e){var n;return l&&"string"==typeof e&&(e=l.getElementById(e)),new(h?Y:X)(t,e)}}},new function(){if(h){var t,e,n=!1,i=!1,r=h.navigator,a,o,u;r.pointerEnabled||r.msPointerEnabled?(a="pointerdown MSPointerDown",o="pointermove MSPointerMove",u="pointerup pointercancel MSPointerUp MSPointerCancel"):(a="touchstart",o="touchmove",u="touchend touchcancel","ontouchstart"in h&&r.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(a+=" mousedown",o+=" mousemove",u+=" mouseup"));var c={},d={mouseout:function(t){var e=X._focused,n=K.getRelatedTarget(t);if(e&&(!n||"HTML"===n.nodeName)){var i=K.getOffset(t,e._element),r=i.x,s=Math.abs,a=s(r),o,h=a-(1<<25);i.x=s(h)<a?h*(r<0?-1:1):r,z(e,t,e.viewToProject(i))}},scroll:I};c[a]=function(t){var e=X._focused=k(t);n||(n=!0,e._handleMouseEvent("mousedown",t))},d[o]=function(n){var r=X._focused;if(!i){var s=k(n);s?r!==s&&(r&&z(r,n),t||(t=r),r=X._focused=e=s):e&&e===r&&(t&&!t.isInserted()&&(t=null),r=X._focused=t,t=null,I())}r&&z(r,n)},d[a]=function(){i=!0},d[u]=function(t){var e=X._focused;e&&n&&e._handleMouseEvent("mouseup",t),i=n=!1},K.add(l,d),K.add(h,{load:I});var f=!1,_=!1,g={doubleclick:"click",mousedrag:"mousemove"},v=!1,p,m,y,w,x,b,C,S,M,P={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}};return{_viewEvents:c,_handleMouseEvent:function(t,e,i){var r=this._itemEvents,s=r.native[t],a="mousemove"===t,o=this._scope.tool,h=this;function l(t){return r.virtual[t]||h.responds(t)||o&&o.responds(t)}a&&n&&l("mousedrag")&&(t="mousedrag"),i||(i=this.getEventPoint(e));var u=this.getBounds().contains(i),c=s&&u&&h._project.hitTest(i,{tolerance:0,fill:!0,stroke:!0}),d=c&&c.item||null,g=!1,P={};if(P[t.substr(5)]=!0,s&&d!==x&&(x&&T(x,null,"mouseleave",e,i),d&&T(d,null,"mouseenter",e,i),x=d),v^u&&(T(this,null,u?"mouseenter":"mouseleave",e,i),p=u?this:null,g=!0),!u&&!P.drag||i.equals(y)||(O(this,d,a?t:"mousemove",e,i,y),g=!0),v=u,P.down&&u||P.up&&m){if(O(this,d,t,e,i,m),P.down){if(M=d===C&&Date.now()-S<300,w=C=d,!_&&d){for(var k=d;k&&!k.responds("mousedrag");)k=k._parent;k&&(b=d)}m=i}else P.up&&(_||d!==w||(S=Date.now(),O(this,d,M?"doubleclick":"click",e,i,m),M=!1),w=b=null);v=!1,g=!0}y=i,g&&o&&(f=o._handleMouseEvent(t,e,i,P)||f),(f&&!P.move||P.down&&l("mouseup"))&&e.preventDefault()},_handleKeyEvent:function(t,e,n,i){var r=this._scope,a=r.tool,o;function h(a){a.responds(t)&&(s=r,a.emit(t,o=o||new tt(t,e,n,i)))}this.isVisible()&&(h(this),a&&a.responds(t)&&h(a))},_countItemEvent:function(t,e){var n=this._itemEvents,i=n.native,r=n.virtual;for(var s in P)i[s]=(i[s]||0)+(P[s][t]||0)*e;r[t]=(r[t]||0)+e},statics:{updateFocus:I}}}function k(t){var e=K.getTarget(t);return e.getAttribute&&X._viewsById[e.getAttribute("id")]}function I(){var t=X._focused;if(!t||!t.isVisible())for(var n=0,i=X._views.length;n<i;n++)if((t=X._views[n]).isVisible()){X._focused=e=t;break}}function z(t,e,n){t._handleMouseEvent("mousemove",e,n)}function T(t,e,n,i,r,s,a){var o=!1,h;function l(t,n){if(t.responds(n)){if(h||(h=new nt(n,i,r,e||t,s?r.subtract(s):null)),t.emit(n,h)&&(f=!0,h.prevented&&(_=!0),h.stopped))return o=!0}else{var a=g[n];if(a)return l(t,a)}}for(;t&&t!==a&&!l(t,n);)t=t._parent;return o}function O(t,e,n,i,r,s){return t._project.removeOn(n),_=f=!1,b&&T(b,null,n,i,r,s)||e&&e!==b&&!e.isDescendant(b)&&T(e,null,n,i,r,s,b)||T(t,b||e||t,n,i,r,s)}}),Y=X.extend({_class:"CanvasView",initialize:function t(e,n){if(!(n instanceof h.HTMLCanvasElement)){var i=y.read(arguments,1);if(i.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+u.slice(arguments,1));n=at.getCanvas(i)}var r=this._context=n.getContext("2d");if(r.save(),this._pixelRatio=1,!/^off|false$/.test(d.getAttribute(n,"hidpi"))){var s=h.devicePixelRatio||1,a=$.getPrefixed(r,"backingStorePixelRatio")||1;this._pixelRatio=s/a}X.call(this,e,n),this._needsUpdate=!0},remove:function t(){return this._context.restore(),t.base.call(this)},_setElementSize:function t(e,n){var i=this._pixelRatio;if(t.base.call(this,e*i,n*i),1!==i){var r=this._element,s=this._context;if(!d.hasAttribute(r,"resize")){var a=r.style;a.width=e+"px",a.height=n+"px"}s.restore(),s.save(),s.scale(i,i)}},getPixelSize:function t(e){var n=s.agent,i;if(n&&n.firefox)i=t.base.call(this,e);else{var r=this._context,a=r.font;r.font=e+" serif",i=parseFloat(r.font),r.font=a}return i},getTextWidth:function(t,e){var n=this._context,i=n.font,r=0;n.font=t;for(var s=0,a=e.length;s<a;s++)r=Math.max(r,n.measureText(e[s]).width);return n.font=i,r},update:function(){if(!this._needsUpdate)return!1;var t=this._project,e=this._context,n=this._viewSize;return e.clearRect(0,0,n.width+1,n.height+1),t&&t.draw(e,this._matrix,this._pixelRatio),this._needsUpdate=!1,!0}}),Q=u.extend({_class:"Event",initialize:function t(e){this.event=e,this.type=e&&e.type},prevented:!1,stopped:!1,preventDefault:function(){this.prevented=!0,this.event.preventDefault()},stopPropagation:function(){this.stopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getTimeStamp:function(){return this.event.timeStamp},getModifiers:function(){return et.modifiers}}),tt=Q.extend({_class:"KeyEvent",initialize:function t(e,n,i,r){this.type=e,this.event=n,this.key=i,this.character=r},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),et=new function(){var t={"\t":"tab"," ":"space","\b":"backspace","":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},e={tab:"\t",space:" ",enter:"\r"},n={},i={},r,a,c=new u({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var t=s&&s.agent;return t&&t.mac?this.meta:this.control}}});function d(e){var n=e.key||e.keyIdentifier;return n=/^U\+/.test(n)?String.fromCharCode(parseInt(n.substr(2),16)):/^Arrow[A-Z]/.test(n)?n.substr(5):"Unidentified"===n||n===o?String.fromCharCode(e.keyCode):n,t[n]||(n.length>1?u.hyphenate(n):n.toLowerCase())}function f(t,e,a,o){var h=t?"keydown":"keyup",l=X._focused,d;if(n[e]=t,t?i[e]=a:delete i[e],e.length>1&&(d=u.camelize(e))in c){c[d]=t;var _=s&&s.agent;if("meta"===d&&_&&_.mac)if(t)r={};else{for(var g in r)g in i&&f(!1,g,r[g],o);r=null}}else t&&r&&(r[e]=a);l&&l._handleKeyEvent(t?"keydown":"keyup",o,e,a)}return K.add(l,{keydown:function(t){var n=d(t),i=s&&s.agent;n.length>1||i&&i.chrome&&(t.altKey||i.mac&&t.metaKey||!i.mac&&t.ctrlKey)?f(!0,n,e[n]||(n.length>1?"":n),t):a=n},keypress:function(t){if(a){var e=d(t),n=t.charCode,i=n>=32?String.fromCharCode(n):e.length>1?"":e;e!==a&&(e=i.toLowerCase()),f(!0,e,i,t),a=null}},keyup:function(t){var e=d(t);e in i&&f(!1,e,i[e],t)}}),K.add(h,{blur:function(t){for(var e in i)f(!1,e,i[e],t)}}),{modifiers:c,isDown:function(t){return!!n[t]}}},nt=Q.extend({_class:"MouseEvent",initialize:function t(e,n,i,r,s){this.type=e,this.event=n,this.point=i,this.target=r,this.delta=s},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),it=Q.extend({_class:"ToolEvent",_item:null,initialize:function t(e,n,i){this.tool=e,this.type=n,this.event=i},_choosePoint:function(t,e){return t||(e?e.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(t){this._point=t},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(t){this._lastPoint=t},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(t){this._downPoint=t},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(t){this._middlePoint=t},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(t){this._delta=t},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(t){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=t},getItem:function(){if(!this._item){var t=this.tool._scope.project.hitTest(this.getPoint());if(t){for(var e=t.item,n=e._parent;/^(Group|CompoundPath)$/.test(n._class);)e=n,n=n._parent;this._item=e}}return this._item},setItem:function(t){this._item=t},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),rt=f.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function t(e){f.call(this),this._moveCount=-1,this._downCount=-1,this.set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(t){this._minDistance=t,null!=t&&null!=this._maxDistance&&t>this._maxDistance&&(this._maxDistance=t)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(t){this._maxDistance=t,null!=this._minDistance&&null!=t&&t<this._minDistance&&(this._minDistance=t)},getFixedDistance:function(){return this._minDistance==this._maxDistance?this._minDistance:null},setFixedDistance:function(t){this._minDistance=this._maxDistance=t},_handleMouseEvent:function(t,e,n,i){s=this._scope,i.drag&&!this.responds(t)&&(t="mousemove");var r=i.move||i.drag,a=this.responds(t),o=this.minDistance,h=this.maxDistance,l=!1,u=this;function c(t,e){var s=n,a=r?u._point:u._downPoint||s;if(r){if(u._moveCount&&s.equals(a))return!1;if(a&&(null!=t||null!=e)){var o=s.subtract(a),h=o.getLength();if(h<(t||0))return!1;e&&(s=a.add(o.normalize(Math.min(h,e))))}u._moveCount++}return u._point=s,u._lastPoint=a||s,i.down&&(u._moveCount=-1,u._downPoint=s,u._downCount++),!0}function d(){a&&(l=u.emit(t,new it(u,t,e))||l)}if(i.down)c(),d();else if(i.up)c(null,h),d();else if(a)for(;c(o,h);)d();return l}}),st={request:function(t){var e=new a.XMLHttpRequest;return e.open((t.method||"get").toUpperCase(),t.url,u.pick(t.async,!0)),t.mimeType&&e.overrideMimeType(t.mimeType),e.onload=function(){var n=e.status;0===n||200===n?t.onLoad&&t.onLoad.call(e,e.responseText):e.onerror()},e.onerror=function(){var n=e.status,i='Could not load "'+t.url+'" (Status: '+n+")";if(!t.onError)throw new Error(i);t.onError(i,n)},e.send(null)}},at={canvases:[],getCanvas:function(t,e){if(!h)return null;var n,i=!0;"object"==typeof t&&(e=t.height,t=t.width),this.canvases.length?n=this.canvases.pop():(n=l.createElement("canvas"),i=!1);var r=n.getContext("2d");if(!r)throw new Error("Canvas "+n+" is unable to provide a 2D context.");return n.width===t&&n.height===e?i&&r.clearRect(0,0,t+1,e+1):(n.width=t,n.height=e),r.save(),n},getContext:function(t,e){var n=this.getCanvas(t,e);return n?n.getContext("2d"):null},release:function(t){var e=t&&t.canvas?t.canvas:t;e&&e.getContext&&(e.getContext("2d").restore(),this.canvases.push(e))}},ot=new function(){var t=Math.min,e=Math.max,n=Math.abs,i,r,s,a,o,h,l,c,d,f,_;function g(t,e,n){return.2989*t+.587*e+.114*n}function v(n,i,r,s){var a=s-g(n,i,r),s=g(d=n+a,f=i+a,_=r+a),o=t(d,f,_),h=e(d,f,_);if(o<0){var l=s-o;d=s+(d-s)*s/l,f=s+(f-s)*s/l,_=s+(_-s)*s/l}if(h>255){var u=255-s,c=h-s;d=s+(d-s)*u/c,f=s+(f-s)*u/c,_=s+(_-s)*u/c}}function p(n,i,r){return e(n,i,r)-t(n,i,r)}function m(n,i,r,s){var a=[n,i,r],o=e(n,i,r),h=t(n,i,r),l;l=0===t(h=h===n?0:h===i?1:2,o=o===n?0:o===i?1:2)?1===e(h,o)?2:1:0,a[o]>a[h]?(a[l]=(a[l]-a[h])*s/(a[o]-a[h]),a[o]=s):a[l]=a[o]=0,a[h]=0,d=a[0],f=a[1],_=a[2]}var y={multiply:function(){d=o*i/255,f=h*r/255,_=l*s/255},screen:function(){d=o+i-o*i/255,f=h+r-h*r/255,_=l+s-l*s/255},overlay:function(){d=o<128?2*o*i/255:255-2*(255-o)*(255-i)/255,f=h<128?2*h*r/255:255-2*(255-h)*(255-r)/255,_=l<128?2*l*s/255:255-2*(255-l)*(255-s)/255},"soft-light":function(){var t=i*o/255;d=t+o*(255-(255-o)*(255-i)/255-t)/255,f=(t=r*h/255)+h*(255-(255-h)*(255-r)/255-t)/255,_=(t=s*l/255)+l*(255-(255-l)*(255-s)/255-t)/255},"hard-light":function(){d=i<128?2*i*o/255:255-2*(255-i)*(255-o)/255,f=r<128?2*r*h/255:255-2*(255-r)*(255-h)/255,_=s<128?2*s*l/255:255-2*(255-s)*(255-l)/255},"color-dodge":function(){d=0===o?0:255===i?255:t(255,255*o/(255-i)),f=0===h?0:255===r?255:t(255,255*h/(255-r)),_=0===l?0:255===s?255:t(255,255*l/(255-s))},"color-burn":function(){d=255===o?255:0===i?0:e(0,255-255*(255-o)/i),f=255===h?255:0===r?0:e(0,255-255*(255-h)/r),_=255===l?255:0===s?0:e(0,255-255*(255-l)/s)},darken:function(){d=o<i?o:i,f=h<r?h:r,_=l<s?l:s},lighten:function(){d=o>i?o:i,f=h>r?h:r,_=l>s?l:s},difference:function(){(d=o-i)<0&&(d=-d),(f=h-r)<0&&(f=-f),(_=l-s)<0&&(_=-_)},exclusion:function(){d=o+i*(255-o-o)/255,f=h+r*(255-h-h)/255,_=l+s*(255-l-l)/255},hue:function(){m(i,r,s,p(o,h,l)),v(d,f,_,g(o,h,l))},saturation:function(){m(o,h,l,p(i,r,s)),v(d,f,_,g(o,h,l))},luminosity:function(){v(o,h,l,g(i,r,s))},color:function(){v(i,r,s,g(o,h,l))},add:function(){d=t(o+i,255),f=t(h+r,255),_=t(l+s,255)},subtract:function(){d=e(o-i,0),f=e(h-r,0),_=e(l-s,0)},average:function(){d=(o+i)/2,f=(h+r)/2,_=(l+s)/2},negation:function(){d=255-n(255-i-o),f=255-n(255-r-h),_=255-n(255-s-l)}},w=this.nativeModes=u.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(t){this[t]=!0},{}),x=at.getContext(1,1);x&&(u.each(y,function(t,e){var n="darken"===e,i=!1;x.save();try{x.fillStyle=n?"#300":"#a00",x.fillRect(0,0,1,1),x.globalCompositeOperation=e,x.globalCompositeOperation===e&&(x.fillStyle=n?"#a00":"#300",x.fillRect(0,0,1,1),i=x.getImageData(0,0,1,1).data[0]!==n?170:51)}catch(t){}x.restore(),w[e]=i}),at.release(x)),this.process=function(t,e,n,u,g){var v=e.canvas,p="normal"===t;if(p||w[t])n.save(),n.setTransform(1,0,0,1,0,0),n.globalAlpha=u,p||(n.globalCompositeOperation=t),n.drawImage(v,g.x,g.y),n.restore();else{var m=y[t];if(!m)return;for(var x=n.getImageData(g.x,g.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,M=b.length;S<M;S+=4){i=C[S],o=b[S],r=C[S+1],h=b[S+1],s=C[S+2],l=b[S+2],a=C[S+3],c=b[S+3],m();var P=a*u/255,k=1-P;b[S]=P*d+k*o,b[S+1]=P*f+k*h,b[S+2]=P*_+k*l,b[S+3]=a*u+k*c}n.putImageData(x,g.x,g.y)}}},ht=new function(){var t="http://www.w3.org/2000/svg",e="http://www.w3.org/2000/xmlns",n="http://www.w3.org/1999/xlink",i={href:n,xlink:e,xmlns:e+"/","xmlns:xlink":e+"/"};function r(e,n,i){return a(l.createElementNS(t,e),n,i)}function s(t,e){var n=i[e],r=n?t.getAttributeNS(n,e):t.getAttribute(e);return"null"===r?null:r}function a(t,e,n){for(var r in e){var s=e[r],a=i[r];"number"==typeof s&&n&&(s=n.number(s)),a?t.setAttributeNS(a,r,s):t.setAttribute(r,s)}return t}return{svg:t,xmlns:e,xlink:n,create:r,get:s,set:a}},lt=u.each({fillColor:["fill","color"],fillRule:["fill-rule","string"],strokeColor:["stroke","color"],strokeWidth:["stroke-width","number"],strokeCap:["stroke-linecap","string"],strokeJoin:["stroke-linejoin","string"],strokeScaling:["vector-effect","lookup",{true:"none",false:"non-scaling-stroke"},function(t,e){return!e&&(t instanceof R||t instanceof z||t instanceof H)}],miterLimit:["stroke-miterlimit","number"],dashArray:["stroke-dasharray","array"],dashOffset:["stroke-dashoffset","number"],fontFamily:["font-family","string"],fontWeight:["font-weight","string"],fontSize:["font-size","number"],justification:["text-anchor","lookup",{left:"start",center:"middle",right:"end"}],opacity:["opacity","number"],blendMode:["mix-blend-mode","style"]},function(t,e){var n=u.capitalize(e),i=t[2];this[e]={type:t[1],property:e,attribute:t[0],toSVG:i,fromSVG:i&&u.each(i,function(t,e){this[t]=e},{}),exportFilter:t[3],get:"get"+n,set:"set"+n}},{});return new function(){var t;function e(e,n,i){var r=new u,s=e.getTranslation();if(n){var a=(e=e._shiftless())._inverseTransform(s);r[i?"cx":"x"]=a.x,r[i?"cy":"y"]=a.y,s=null}if(!e.isIdentity()){var o=e.decompose();if(o){var h=[],l=o.rotation,c=o.scaling,d=o.skewing;s&&!s.isZero()&&h.push("translate("+t.point(s)+")"),l&&h.push("rotate("+t.number(l)+")"),g.isZero(c.x-1)&&g.isZero(c.y-1)||h.push("scale("+t.point(c)+")"),d.x&&h.push("skewX("+t.number(d.x)+")"),d.y&&h.push("skewY("+t.number(d.y)+")"),r.transform=h.join(" ")}else r.transform="matrix("+e.getValues().join(",")+")"}return r}function n(n,i){for(var r=e(n._matrix),s=n._children,a=ht.create("g",r,t),o=0,h=s.length;o<h;o++){var l=s[o],u=b(l,i);if(u)if(l.isClipMask()){var c=ht.create("clipPath");c.appendChild(u),y(l,c,"clip"),ht.set(a,{"clip-path":"url(#"+c.id+")"})}else a.appendChild(u)}return a}function i(n,i){var r=e(n._matrix,!0),s=n.getSize(),a=n.getImage();return r.x-=s.width/2,r.y-=s.height/2,r.width=s.width,r.height=s.height,r.href=0==i.embedImages&&a&&a.src||n.toDataURL(),ht.create("image",r,t)}function r(n,i){var r=i.matchShapes;if(r){var a=n.toShape(!1);if(a)return s(a,i)}var o=n._segments,h=o.length,l,u=e(n._matrix);if(r&&h>=2&&!n.hasHandles())if(h>2){l=n._closed?"polygon":"polyline";for(var c=[],d=0;d<h;d++)c.push(t.point(o[d]._point));u.points=c.join(" ")}else{l="line";var f=o[0]._point,_=o[1]._point;u.set({x1:f.x,y1:f.y,x2:_.x,y2:_.y})}else l="path",u.d=n.getPathData(null,i.precision);return ht.create(l,u,t)}function s(n){var i=n._type,r=n._radius,s=e(n._matrix,!0,"rectangle"!==i);if("rectangle"===i){i="rect";var a=n._size,o=a.width,h=a.height;s.x-=o/2,s.y-=h/2,s.width=o,s.height=h,r.isZero()&&(r=null)}return r&&("circle"===i?s.r=r:(s.rx=r.width,s.ry=r.height)),ht.create(i,s,t)}function o(n,i){var r=e(n._matrix),s=n.getPathData(null,i.precision);return s&&(r.d=s),ht.create("path",r,t)}function h(n,i){var r=e(n._matrix,!0),s=n._definition,a=m(s,"symbol"),o=s._item,h=o.getBounds();return a||((a=ht.create("symbol",{viewBox:t.rectangle(h)})).appendChild(b(o,i)),y(s,a,"symbol")),r.href="#"+a.id,r.x+=h.x,r.y+=h.y,r.width=h.width,r.height=h.height,r.overflow="visible",ht.create("use",r,t)}function l(e){var n=m(e,"color");if(!n){var i=e.getGradient(),r=i._radial,s=e.getOrigin(),a=e.getDestination(),o;if(r){o={cx:s.x,cy:s.y,r:s.getDistance(a)};var h=e.getHighlight();h&&(o.fx=h.x,o.fy=h.y)}else o={x1:s.x,y1:s.y,x2:a.x,y2:a.y};o.gradientUnits="userSpaceOnUse",n=ht.create((r?"radial":"linear")+"Gradient",o,t);for(var l=i._stops,u=0,c=l.length;u<c;u++){var d=l[u],f=d._color,_=f.getAlpha(),g=d._offset;o={offset:null==g?u/(c-1):g},f&&(o["stop-color"]=f.toCSS(!0)),_<1&&(o["stop-opacity"]=_),n.appendChild(ht.create("stop",o,t))}y(e,n,"color")}return"url(#"+n.id+")"}function c(n){var i=ht.create("text",e(n._matrix,!0),t);return i.textContent=n._content,i}var d={Group:n,Layer:n,Raster:i,Path:r,Shape:s,CompoundPath:o,SymbolItem:h,PointText:c},f;function p(e,n,i){var r={},s=!i&&e.getParent(),a=[];return null!=e._name&&(r.id=e._name),u.each(lt,function(t){var n=t.get,i=t.type,o=e[n]();if(t.exportFilter?t.exportFilter(e,o):!s||!u.equals(s[n](),o)){if("color"===i&&null!=o){var h=o.getAlpha();h<1&&(r[t.attribute+"-opacity"]=h)}"style"===i?a.push(t.attribute+": "+o):r[t.attribute]=null==o?"none":"color"===i?o.gradient?l(o,e):o.toCSS(!0):"array"===i?o.join(","):"lookup"===i?t.toSVG[o]:o}}),a.length&&(r.style=a.join(";")),1===r.opacity&&delete r.opacity,e._visible||(r.visibility="hidden"),ht.set(n,r,t)}function m(t,e){return f||(f={ids:{},svgs:{}}),t&&f.svgs[e+"-"+(t._id||t.__id||(t.__id=v.get("svg")))]}function y(t,e,n){f||m();var i=f.ids[n]=(f.ids[n]||0)+1;e.id=n+"-"+i,f.svgs[n+"-"+(t._id||t.__id)]=e}function w(t,e){var n=t,i=null;if(f){for(var r in n="svg"===t.nodeName.toLowerCase()&&t,f.svgs)i||(n||(n=ht.create("svg")).appendChild(t),i=n.insertBefore(ht.create("defs"),n.firstChild)),i.appendChild(f.svgs[r]);f=null}return e.asString?(new a.XMLSerializer).serializeToString(n):n}function b(t,e,n){var i=d[t._class],r=i&&i(t,e);if(r){var s=e.onExport;s&&(r=s(t,r,e)||r);var a=JSON.stringify(t._data);a&&"{}"!==a&&"null"!==a&&r.setAttribute("data-paper-data",a)}return r&&p(t,r,n)}function S(e){return e||(e={}),t=new _(e.precision),e}P.inject({exportSVG:function(t){return w(b(this,t=S(t),!0),t)}}),M.inject({exportSVG:function(n){n=S(n);var i=this._children,r=this.getView(),s=u.pick(n.bounds,"view"),a=n.matrix||"view"===s&&r._matrix,o=a&&C.read([a]),h="view"===s?new x([0,0],r.getViewSize()):"content"===s?P._getBounds(i,o,{stroke:!0}).rect:x.read([s],0,{readNull:!0}),l={version:"1.1",xmlns:ht.svg,"xmlns:xlink":ht.xlink};h&&(l.width=h.width,l.height=h.height,(h.x||h.y)&&(l.viewBox=t.rectangle(h)));var c=ht.create("svg",l,t),d=c;o&&!o.isIdentity()&&(d=c.appendChild(ht.create("g",e(o),t)));for(var f=0,_=i.length;f<_;f++)d.appendChild(b(i[f],n,!0));return w(c,n)}})},new function(){var t={},e;function n(t,n,i,r,s){var a=ht.get(t,n),o=null==a?r?null:i?"":0:i?a:parseFloat(a);return/%\s*$/.test(a)?o/100*(s?1:e[/x|^width/.test(n)?"width":"height"]):o}function i(t,e,i,r,s){return e=n(t,e||"x",!1,r,s),i=n(t,i||"y",!1,r,s),!r||null!=e&&null!=i?new p(e,i):null}function r(t,e,i,r,s){return e=n(t,e||"width",!1,r,s),i=n(t,i||"height",!1,r,s),!r||null!=e&&null!=i?new y(e,i):null}function c(t,e,n){return"none"===t?null:"number"===e?parseFloat(t):"array"===e?t?t.split(/[\s,]+/g).map(parseFloat):[]:"color"===e?O(t)||t:"lookup"===e?n[t]:t}function d(t,e,n,i){var r=t.childNodes,s="clippath"===e,a="defs"===e,o=new k,h=o._project,l=h._currentStyle,u=[];if(s||a||(o=I(o,t,i),h._currentStyle=o._style.clone()),i)for(var c=t.querySelectorAll("defs"),d=0,f=c.length;d<f;d++)L(c[d],n,!1);for(var d=0,f=r.length;d<f;d++){var _=r[d],g;1!==_.nodeType||/^defs$/i.test(_.nodeName)||!(g=L(_,n,!1))||g instanceof A||u.push(g)}return o.addChildren(u),s&&(o=I(o.reduce(),t,i)),h._currentStyle=l,(s||a)&&(o.remove(),o=null),o}function f(t,e){for(var n=t.getAttribute("points").match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),i=[],r=0,s=n.length;r<s;r+=2)i.push(new p(parseFloat(n[r]),parseFloat(n[r+1])));var a=new D(i);return"polygon"===e&&a.closePath(),a}function _(t){return R.create(t.getAttribute("d"))}function g(e,r){var s=(n(e,"href",!0)||"").substring(1),a="radialgradient"===r,o;if(s)(o=t[s].getGradient())._radial^a&&((o=o.clone())._radial=a);else{for(var h=e.childNodes,l=[],u=0,c=h.length;u<c;u++){var d=h[u];1===d.nodeType&&l.push(I(new G,d))}o=new W(l,a)}var f,_,g,v="userSpaceOnUse"!==n(e,"gradientUnits",!0),p;return a?(_=(f=i(e,"cx","cy",!1,v)).add(n(e,"r",!1,!1,v),0),g=i(e,"fx","fy",!0,v)):(f=i(e,"x1","y1",!1,v),_=i(e,"x2","y2",!1,v)),I(new U(o,f,_,g),e)._scaleToBounds=v,null}var v={"#document":function(t,e,n,i){for(var r=t.childNodes,s=0,a=r.length;s<a;s++){var o=r[s];if(1===o.nodeType)return L(o,n,i)}},g:d,svg:d,clippath:d,polygon:f,polyline:f,path:_,lineargradient:g,radialgradient:g,image:function(t){var e=new T(n(t,"href",!0));return e.on("load",function(){var e=r(t);this.setSize(e);var n=this._matrix._transformPoint(i(t).add(e.divide(2)));this.translate(n)}),e},symbol:function(t,e,n,i){return new A(d(t,e,n,i),!0)},defs:d,use:function(e){var r=(n(e,"href",!0)||"").substring(1),s=t[r],a=i(e);return s?s instanceof A?s.place(a):s.clone().translate(a):null},circle:function(t){return new z.Circle(i(t,"cx","cy"),n(t,"r"))},ellipse:function(t){return new z.Ellipse({center:i(t,"cx","cy"),radius:r(t,"rx","ry")})},rect:function(t){return new z.Rectangle(new x(i(t),r(t)),r(t,"rx","ry"))},line:function(t){return new D.Line(i(t,"x1","y1"),i(t,"x2","y2"))},text:function(t){var e=new Z(i(t).add(i(t,"dx","dy")));return e.setContent(t.textContent.trim()||""),e}};function m(t,e,n,i){if(t.transform){for(var r=(i.getAttribute(n)||"").split(/\)\s*/g),s=new C,a=0,o=r.length;a<o;a++){var h=r[a];if(!h)break;for(var l=h.split(/\(\s*/),u=l[0],c=l[1].split(/[\s,]+/g),d=0,f=c.length;d<f;d++)c[d]=parseFloat(c[d]);switch(u){case"matrix":s.append(new C(c[0],c[1],c[2],c[3],c[4],c[5]));break;case"rotate":s.rotate(c[0],c[1],c[2]);break;case"translate":s.translate(c[0],c[1]);break;case"scale":s.scale(c);break;case"skewX":s.skew(c[0],0);break;case"skewY":s.skew(0,c[0])}}t.transform(s)}}function w(t,e,n){var i="fill-opacity"===n?"getFillColor":"getStrokeColor",r=t[i]&&t[i]();r&&r.setAlpha(parseFloat(e))}var b=u.set(u.each(lt,function(t){this[t.attribute]=function(e,n){if(e[t.set]&&(e[t.set](c(n,t.type,t.fromSVG)),"color"===t.type)){var i=e[t.get]();if(i&&i._scaleToBounds){var r=e.getBounds();i.transform((new C).translate(r.getPoint()).scale(r.getSize()))}}}},{}),{id:function(e,n){t[n]=e,e.setName&&e.setName(n)},"clip-path":function(t,e){var n=O(e);if(n){if((n=n.clone()).setClipMask(!0),!(t instanceof k))return new k(n,t);t.insertChild(0,n)}},gradientTransform:m,transform:m,"fill-opacity":w,"stroke-opacity":w,visibility:function(t,e){t.setVisible&&t.setVisible("visible"===e)},display:function(t,e){t.setVisible&&t.setVisible(null!==e)},"stop-color":function(t,e){t.setColor&&t.setColor(e)},"stop-opacity":function(t,e){t._color&&t._color.setAlpha(parseFloat(e))},offset:function(t,e){if(t.setOffset){var n=e.match(/(.*)%$/);t.setOffset(n?n[1]/100:parseFloat(e))}},viewBox:function(t,e,n,i,s){var a=new x(c(e,"array")),o=r(i,null,null,!0),h,l;if(t instanceof k){var u=o?o.divide(a.getSize()):1,l=(new C).scale(u).translate(a.getPoint().negate());h=t}else t instanceof A&&(o&&a.setSize(o),h=t._item);if(h){if("visible"!==S(i,"overflow",s)){var d=new z.Rectangle(a);d.setClipMask(!0),h.addChild(d)}l&&h.transform(l)}}});function S(t,e,n){var i=t.attributes[e],r=i&&i.value;if(!r){var s=u.camelize(e);(r=t.style[s])||n.node[s]===n.parent[s]||(r=n.node[s])}return r?"none"===r?null:r:o}function I(t,e,n){if(e.style){var i=e.parentNode,r={node:$.getStyles(e)||{},parent:!n&&!/^defs$/i.test(i.tagName)&&$.getStyles(i)||{}};u.each(b,function(n,i){var s=S(e,i,r);t=s!==o&&n(t,s,i,e,r)||t})}return t}function O(e){var n=e&&e.match(/\((?:["'#]*)([^"')]+)/),i=n&&n[1],r=i&&t[h?i.replace(h.location.href.split("#")[0]+"#",""):i];return r&&r._scaleToBounds&&((r=r.clone())._scaleToBounds=!0),r}function L(n,i,a){var o=n.nodeName.toLowerCase(),h="#document"!==o,c=l.body,d,f,_;a&&h&&(e=s.getView().getSize(),e=r(n,null,null,!0)||e,d=ht.create("svg",{style:"stroke-width: 1px; stroke-miterlimit: 10"}),f=n.parentNode,_=n.nextSibling,d.appendChild(n),c.appendChild(d));var g=s.settings,p=g.applyMatrix,m=g.insertItems;g.applyMatrix=!1,g.insertItems=!1;var y=v[o],w=y&&y(n,o,i,a)||null;if(g.insertItems=m,g.applyMatrix=p,w){!h||w instanceof k||(w=I(w,n,a));var x=i.onImport,b=h&&n.getAttribute("data-paper-data");x&&(w=x(n,w,i)||w),i.expandShapes&&w instanceof z&&(w.remove(),w=w.toPath()),b&&(w._data=JSON.parse(b))}return d&&(c.removeChild(d),f&&(_?f.insertBefore(n,_):f.appendChild(n))),a&&(t={},w&&u.pick(i.applyMatrix,p)&&w.matrix.apply(!0,!0)),w}function E(t,e,n){if(!t)return null;e="function"==typeof e?{onLoad:e}:e||{};var i=s,r=null;function h(h){try{var l="object"==typeof h?h:(new a.DOMParser).parseFromString(h,"image/svg+xml");if(!l.nodeName)throw l=null,new Error("Unsupported SVG source: "+t);s=i,r=L(l,e,!0),e&&!1===e.insert||n._insertItem(o,r);var c=e.onLoad;c&&c(r,h)}catch(t){u(t)}}function u(t,n){var i=e.onError;if(!i)throw new Error(t);i(t,n)}if("string"!=typeof t||/^.*</.test(t)){if("undefined"!=typeof File&&t instanceof File){var c=new FileReader;return c.onload=function(){h(c.result)},c.onerror=function(){u(c.error)},c.readAsText(t)}h(t)}else{var d=l.getElementById(t);d?h(d):st.request({url:t,async:!0,onLoad:h,onError:u})}return r}P.inject({importSVG:function(t,e){return E(t,e,this)}}),M.inject({importSVG:function(t,e){return this.activate(),E(t,e,this)}})},(s=new(d.inject(u.exports,{Base:u,Numerical:g,Key:et,DomEvent:K,DomElement:$,document:l,window:h,Symbol:A,PlacedSymbol:O}))).agent.node&&n(2)(s),(r="function"==typeof(i=s)?i.call(e,n,e,t):i)===o||(t.exports=r),s}.call(this,"object"==typeof self?self:null)},function(t,e){},function(t,e){},function(t,e,n){"use strict";n.r(e);var i=n(0),r="bd1087e";function s(t,e,n){var r=0,s=0,a,o=t.position._x-t.bounds.width/2-10*pt,h=t.position._y-t.bounds.height/2-10*pt,l=t.bounds.width+10*pt,u=t.bounds.height+10*pt,c=n?h+t.bounds.height+10*pt:o+t.bounds.width+10*pt;for(o<0&&(o=0),h<0&&(h=0);a=new i.Path.Rectangle(o+r,h+s,n?l:e,n?e:u),t=t.subtract(a),!(n&&s>=c||!n&&r>=c);)n?s+=2*e:r+=2*e;return t}function a(){var t=0;return Math.random()<.5&&(t+=90),Math.random()<.5&&(t+=180),t}function o(t){for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function h(t,e){return Math.random()*(e-t)+t}function l(t){var e=["black","grey","white"];return Math.random()>=.5&&(e=e.reverse()),{gradient:{stops:e},origin:new i.Point(t.position._x,t.position._y-t.bounds.height/2+Math.floor(h(0,t.bounds.height/3))),destination:new i.Point(t.position._x,t.position._y+t.bounds.height/2-Math.floor(h(0,t.bounds.height/3)))}}const u={Hyria:"1536444697076_squares_lines.json",Aulis:"1538081482591_lines.json",Schoenus:"1538088491370_irregular.json",Scolus:"1542977606271_plates_dots.json",Eteonus:"1543240789971_tech_squares.json",Thespeia:"1543421892210_pins_panels_outline.json"},c=23;var d=1;function f(t,e){var n="<b>Templates</b>";for(let t in bt)n+='<p><span id="t-'+t+'" class="link">'+bt[t].t+"</span></p>";n+='<p><span id="t-import" class="link">Import preset</span></p>';var i=document.getElementById("templates");i&&(i.innerHTML=n);for(let t in bt)document.getElementById("t-"+t).addEventListener("click",function(){g(w(t))});document.getElementById("t-import").addEventListener("click",function(){m()}),_(),t&&(d=Math.round(h(1,c))),z("<p style='text-indent:10px;margin-bottom:0px;'>Welcome to <b>shft</b> — a tool that allows you to create displacement/light/bump maps for 3d software of your choice, in up to 8k resolution! There are multiple generation algorithms ('templates') that can be arranged/layered on top of each other in a 'recipe'. Experiment and hit 'fire' button! After that you can save the result like any other image — ‘Save as...’, two images represent normal canvas and special light canvas (e.g. if you want to combine displacement map with the light one), only text and dots can be rendered there.<p style='text-indent:10px;margin-top:0px;'>Please contact me if you have any questions, suggestions, ideas, and I'll be happy to see your works utilizing <b>shft</b>, links and pictures are welcome!<br></p>",1),e&&O()}function _(){var t="",e=0;for(let e in Ct)t+='<p><span id="r-'+e+'" class="link">#'+(Number(e)+1)+": "+bt[Ct[e].type].t+'</span> <span id="r-r-'+e+'" class="linkb">✖</span> <span id="r-u-'+e+'" class="linkb">↑</span> <span id="r-d-'+e+'" class="linkb">↓</span></p>';t&&(t+='<p><span id="r-export" class="link">Export</span></p>',e++),t='<b>Current recipe</b> (<span id="recipe-menu" style="text-decoration:underline;font-size:small;cursor:pointer;">…</span>)<span class="loadm" id="load-menu"><b>Load a preset</b><br>'+Object.keys(u).map(t=>'<p><span style="text-decoration:underline;cursor:pointer;" id="l-'+t+'">'+t+"</span></p>").join("")+"</span>"+t;var n=document.getElementById("recipes");n&&(n.innerHTML=t),document.getElementById("recipe-menu").addEventListener("click",function(){var t=document.getElementById("load-menu");"visible"==t.style.visibility?(t.style.visibility="hidden",document.removeEventListener("click",b)):(t.style.visibility="visible",document.addEventListener("click",b))});for(let t in Ct)document.getElementById("r-"+t).addEventListener("click",function(){g(y(t))}),document.getElementById("r-r-"+t).addEventListener("click",function(){remove_recipe(t)}),document.getElementById("r-u-"+t).addEventListener("click",function(){S(t)}),document.getElementById("r-d-"+t).addEventListener("click",function(){M(t)});e&&document.getElementById("r-export").addEventListener("click",function(){Mt(null)}),Object.keys(u).map(t=>document.getElementById("l-"+t).addEventListener("click",function(){Pt(u[t])}))}function g(t){var e=[];if(t){var n="",i=document.getElementById("settings");if(i){n="<b>Template: "+t.t+'</b><br/><p><form id="settings_form">',n+=v("number","Number of iterations",t.number,t.d,{min:1,type:"numeric"}),e.push({id:"reset-number",cb:function(){p("number",t.number)}});for(let i in t.opts)n+=v(i,t.opts[i].t,t.opts[i].v,t.opts[i].d,t.opts[i].params,bt[t.type].options[i].h),"numeric"==t.opts[i].params.type&&e.push({id:"reset-"+i,cb:function(){p(i,t.opts[i].d)}});n+="</form>"+t.button.map(function(t){return t.t}).join(" ")+"</p>",i.innerHTML=n;for(let t of e)document.getElementById(t.id).addEventListener("click",t.cb);for(let e of t.button)document.getElementById(e.id).addEventListener("click",e.cb);t.help&&z(t.help)}}}function v(t,e,n,i,r,s){var a="";switch(r.type){case"boolean":a='<div><input type="checkbox" name="'+t+'" value="'+t+'" '+(n?" checked ":"")+'/><label class="cblabel" for="'+t+'"><span'+(s?' class="tooltip"':"")+"> — "+e+(s?'<span class="tooltiptext">'+s+"</span>":"")+"</span></label></div>";break;case"numeric":a='<input type="number" name="'+t+'" value="'+n+'" '+("min"in r?'min="'+r.min+'" ':"")+("max"in r?'max="'+r.max+'" ':"")+("step"in r?'step="'+r.step+'" ':"")+"> — <span"+(s?' class="tooltip">'+e+'<span class="tooltiptext">'+s+"</span>":">"+e)+'</span> (<span id="reset-'+t+'" style="text-decoration:underline;font-size:small;cursor:pointer;">reset to default: '+i+"</span>)</br>"}return a}function p(t,e){var n=document.getElementById("settings_form").elements[t];n&&(n.value=e)}function m(){var t="",e=document.getElementById("settings");e&&(t="<b>Import</b><br/><p>Paste preset data or select files, templates will be appended to your current recipe:<br/><form id='json_form'><textarea name='json_data' rows='10' cols='60'></textarea></form><br/><input type='file' id='jsonfiles' name='jsonfiles[]' multiple /><br/><div class='b' id='b-j-i'>Import</div></p>",e.innerHTML=t,document.getElementById("b-j-i").addEventListener("click",kt),document.getElementById("jsonfiles").addEventListener("change",zt,!1),z("<p>Please note, current format version is "+yt+", older presets won't work.</p>"))}function y(t){var e={};if(Ct[t]){var n=bt[Ct[t].type];e.t=n.t+" (#"+(Number(t)+1)+")",e.number=Ct[t].number,e.d=n.number,e.type=Ct[t].type,e.opts={};for(let i of Object.keys(n.options)){e.opts[i]={t:n.options[i].t,d:n.options[i].d},i in Ct[t].opts?e.opts[i].v=Ct[t].opts[i]:e.opts[i].v=e.opts[i].d,e.opts[i].params={};for(let t of["min","max","step","type"])t in n.options[i]&&(e.opts[i].params[t]=n.options[i][t])}return e.help="<p>"+n.h+"</p>",e.button=[x(t,null),{t:'<div class="b" id="b-export">Export preset</div>',cb:function(){Mt(t)},id:"b-export"}],e}}function w(t){var e={};if(t in bt){var n=bt[t];e.t=n.t,e.d=n.number,e.number=n.number,e.opts=n.options,e.type=t;for(let t in n.options){e.opts[t].v=e.opts[t].d,e.opts[t].params={};for(let i of["min","max","step","type"])i in n.options[t]&&(e.opts[t].params[i]=n.options[t][i])}return e.button=[x(null,t)],e.help="<p>"+n.h+"</p>",e}}function x(t,e){var n="b-"+(null!=t?t:"null");return{t:'<div id="'+n+'" class="b">'+(null!=t?"Save":"Add")+"</div>",cb:function(){C(null!=t?t:null,e)},id:n}}function b(t){var e=document.getElementById("load-menu");e.contains(t.target)||"recipe-menu"==t.target.id||e&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&(e.style.visibility="hidden",document.removeEventListener("click",b))}function C(t,e){var n={},i=document.getElementById("settings_form").elements,r;if(i){for(var s of(null!=t?n=Ct[t]:(n.type=e,n.opts={}),i))if(r=s.getAttribute("name"),"number"==s.type){var a=Number(s.value);"number"==r?n.number=a:n.opts[r]=a}else n.opts[r]=s.checked;var o;null!=t?Ct[t]=n:Ct.push(n),f(1,1),document.getElementById("settings").innerHTML=""}}function remove_recipe(t){var e;Ct.splice(t,1),f(null,1),document.getElementById("settings").innerHTML=""}function S(t){if(t=Number(t)){var e=Ct[t];Ct[t]=Ct[t-1],Ct[t-1]=e,f(null,1)}}function M(t){if(t!=Ct.length-1){t=Number(t);var e=Ct[t];Ct[t]=Ct[t+1],Ct[t+1]=e,f(null,1)}}function P(t){var e=document.getElementById("errors");t?(t+=' <span id="error-b" style="cursor:pointer;">✖</span>',e.style.display="inline-block",e.innerHTML=t,document.getElementById("error-b").addEventListener("click",function(){P()})):(e.innerHTML="",e.style.display="none")}function k(){if(Ct.length){var t=document.getElementById("loader");t.style.display="inline-block",(t=document.getElementById("fire-button")).style.visibility="hidden",setTimeout(Tt,500)}}function I(){var t=document.getElementById("hide-button"),e=document.getElementById("container");"▴"==t.innerHTML?(e.style.display="none",t.innerHTML="▾"):(e.style.display="inline",t.innerHTML="▴")}function z(t,e){var n=document.getElementById("helptext");n.innerHTML=t,n=document.getElementById("ex"),e?(n.innerHTML='Random image<p><img id="ex-image" src="./e/'+d+'.jpg"></p>',document.getElementById("ex-image").addEventListener("click",T)):n.innerHTML=""}function T(){var t;d=Math.round(h(1,c)),document.getElementById("ex-image").src="./e/"+d+".jpg"}function O(){var t,e;Ct.length?((t=new Date).setTime(t.getTime()+31536e6),e=JSON.stringify({commit:r,recipes:Ct})):(t=new Date(0),e="{}");var n="expires="+t.toUTCString();document.cookie="recipe="+e+";"+n+";path=/"}function A(t,e,n,r,s,a,o,h){var l=new i.PointText,u;l.content=s;var c=n>=.9?n-.1:n+.1;if(l.style={fontFamily:"monospace",fontSize:13*pt,fontAlign:"center",fillColor:c},l.opacity=r,(l.bounds.height>h||l.bounds.width>o)&&(u=Math.min(h/l.bounds.height,o/l.bounds.width),l.scale(u)),l.position=new i.Point(t,e),a){xt.activate();var d=new i.PointText([t,e]);d.content=s,d.style=l.style,d.opacity=r,u&&d.scale(u),wt.activate()}}function L(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",e="0123456789",n="-/: .",i=Math.round(h(0,4)),r="";for(let e=0;e<i;e++)r+=t.charAt(Math.round(h(0,t.length)));r+=n.charAt(Math.round(h(0,n.length))),i=Math.round(h(0,4));for(let t=0;t<i;t++)r+=e.charAt(Math.round(h(0,e.length)));return r}function E(t,e,n,r,s,a,o){xt.activate();var h=new i.PointText,l,u=L();h.content=u;var c=n>=.9?n-.1:n+.1;h.style={fontFamily:"BebasNeue",fontSize:72*pt,fontAlign:"center",fillColor:c},h.opacity=r;var d=1,f=1;h.bounds.height>o&&(f=o/h.bounds.height),h.bounds.width>a&&(d=o/h.bounds.width),1==d&&1==f||h.scale(d,f),h.position=new i.Point(t,e),wt.activate()}var N=["1838","アディクション","ダウンワドズ","サイレンス","アングザイエティー","フィア","フォービア","トライアル"];function B(t,e){var n,r,s,a,o;for(let c=0;c<t;c++){s=h(20,20*e.variation)*pt*e.multiplier,n=h(0,gt),r=h(0,vt),a=e.additive?1:h(.2,1);var l=new i.Path.Circle(n,r,s);if(e.extrusion&&h(0,100)<e.extrusion){var u=new i.Path.Circle(n,r,s-h(0,s-10));l=l.subtract(u)}e.p_gradient&&h(0,100)<e.p_gradient?l.fillColor={gradient:{stops:[[a,.01],[.9*a,.2],[0,1]],radial:!0},origin:l.position,destination:l.bounds.rightCenter}:e.p_outlined&&h(0,100)<e.p_outlined?(l.strokeWidth=pt*Math.floor(h(1,3)),l.strokeColor=a):l.fillColor=a,o=e.p_opaque&&h(0,100)<e.p_opaque?1:Math.random(),l.opacity=o,e.text&&h(0,100)<e.text&&A(n,r,a,o,N[Math.floor(h(0,N.length))],e.text_light,s,s)}}function j(t,e){var n,r,s,a,o,l,u,c,d,f,_,g,v,p,m;for(let y=0;y<t;y++){u=Math.floor(h(2,4)*pt)*e.multiplier,c=Math.floor(u*(e.rectangle&&h(0,100)<e.rectangle?1:Math.random()+.5)),(u*=e.w_multiplier?e.w_multiplier:1)<1&&(u=1),c<1&&(c=1),v=Math.floor(Math.max(u,c)/2),s=Math.round(h(1,e.in_set)),m=Math.min(u,c)+u,e.whole?(o=0-Math.floor(h(0,u)),l=0-Math.floor(h(0,c)),n=Math.floor(gt/m*s)+1,r=Math.floor(vt/(2*c))+1):(r=Math.round(h(1,e.sets_y)),n=Math.round(h(1,e.sets_x)),o=Math.floor(h(0,gt-m*s*n)),l=Math.floor(h(0,vt-c*r*2))),e.linear&&h(0,100)<e.linear&&(u=u*s*n*2,s=1,n=1,g=1,o=Math.round(h(-u/2,gt-u/2))),a=m*s,p=4*v*s,d=Math.random();for(let t=0;t<r;t++)for(let r=0;r<n;r++)if(!(e.p_skips&&h(0,100)<e.p_skips))for(let n=0;n<s;n++)e.p_skips&&h(0,100)<e.p_skips||(f=!g&&e.circle&&h(0,100)<e.circle?new i.Path.Circle(o+4*n*v+r*p,l+4*t*v,v):new i.Path.Rectangle(o+n*m+r*a,l+2*t*c,u,c),e.p_colorize&&h(0,100)<e.p_colorize?(f.fillColor={hue:Math.floor(h(e.hue_min,e.hue_max)),saturation:h(.5,1),brightness:1},d=1):e.p_tone&&h(0,100)<e.p_tone?f.fillColor=Math.random():f.fillColor="white",f.opacity=d,e.light_canvas&&(light_s.activate(),(_=new i.Path.Rectangle(0,0,u,c)).position=f.position,_.style=f.style,main_s.activate()))}}function R(t,e){var n,r,s,a,o,u,c;for(let o=0;o<t;o++){if(s=h(20,20*e.variation)*pt*e.multiplier,n=h(0,gt),r=h(0,vt),a=e.additive?1:h(.2,1),c=new i.Path.RegularPolygon(n,r,6,s),u=Math.random(),e.p_cubes&&h(0,100)<e.p_cubes)for(var d=0;d<2;d++){for(var f=new i.Path({closed:!0,fillColor:0==d?"white":"black",opacity:u}),_=0;_<3;_++){var g=(2*d+_)%c.segments.length;f.add(c.segments[g].clone())}f.add(c.bounds.center)}e.p_outlined&&h(0,100)<e.p_outlined?(c.strokeWidth=pt*Math.floor(h(1,3)),c.strokeColor=a):e.p_gradient&&h(0,100)<=e.p_gradient?c.fillColor=l(c):c.fillColor=a,c.opacity=u,e.text&&h(0,100)<e.text&&A(n,r,a,u,N[Math.floor(h(0,N.length))],e.text_light,c.bounds.width,c.bounds.height)}}function D(t,e){for(var n,r,s,a,o,u,c=0;c<t;c++){n=-h(0,20*pt),r=-h(0,20*pt),s=e.seamless?Math.round(gt/Math.round(h(3,10))):Math.round(h(e.w_min,e.w_max))*pt,o=Math.round(h(10*pt,s/10+1)),a=h(s/12,s/8),e.sharp&&h(0,100)<e.sharp&&(o=0);var d=[{type:"rhombus",params:{x:n,y:r,w:s,h:a,d:o,type:"rectangular"}},{type:"hexagon",params:{x:n,y:r,w:s,h:a,d:o,type:"rectangular"}},{type:"hexagon",params:{x:n,y:r,w:s,h:a,d:o,type:"rectangular",cubic:1}},{type:"circle",params:{x:n,y:r,w:s/4,type:"rectangular",scale:.7}},{type:"circle",params:{x:n,y:r,w:s/2,type:"rectangular",d:a,scale:h(.7,1)}},{type:"star",params:{x:n,y:r,w:s,h:a,type:"rectangular"}}],f=q(d[u=Math.floor(h(0,d.length))].type,d[u].params);(u=f.p).opacity=Math.random();var _=0;Math.random()>=.9&&(_=1),e.p_outlined&&h(0,100)<=e.p_outlined?(u.strokeColor="white",u.strokeWidth=pt*Math.round(h(1,4))):e.p_gradient&&h(0,100)<=e.p_gradient?u.fillColor=l(u):u.fillColor="white";for(var g=0;g<=1+vt/u.bounds.height;g++)for(var v=0;v<=1+gt/u.bounds.width;v++){var p=u.clone();p.position=new i.Point(n+v*f.xm,r+g*f.ym),_&&p.scale(.8)}u.visible=!1}}function F(t,e){for(var n,r,s,a,u,c,d,f,_,g=0;g<t;g++){s=Math.floor(h(e.w_min,e.w_max)*pt);var v=[{name:"circle",params:{x:n=Math.floor(h(0,s*pt/2)),y:r=Math.floor(h(0,s*pt/2)),w:s,h:a=Math.floor(h(s/12,s/4)),d:a,scale:Math.random()}},{name:"streak-1",params:{x:n,y:r,w:s,h:a}},{name:"streak-2",params:{x:n,y:r,w:s,h:a}},{name:"streak-2",params:{x:n,y:r,w:s,h:a,w_m:Math.floor(h(0,s))}},{name:"circle",params:{x:n+(pt+s+a/2)/2,y:r,w:s,h:a,d:a,scale:.5}},{name:"hexagon",params:{x:n,y:r,w:s,h:a,scale:0}},{name:"hexagon",params:{x:n,y:r,w:s,h:a,scale:1.3}},{name:"hexagon",params:{x:n,y:r,w:s,h:a,scale:0,maze:1}},{name:"hexagon",params:{x:n,y:r,w:s,h:a,scale:0,cubic:1}},{name:"triangle",params:{x:n,y:r,w:s,h:a,scale:0}},{name:"triangle-united",params:{x:n,y:r,w:s,h:a,scale:0}},{name:"rhombus",params:{x:n,y:r,w:s,h:a,d:Math.round(h(0,s/10))}},{name:"hexagon-subtracted",params:{x:n,y:r,w:s,h:a,scale:0}},{name:"star",params:{x:n,y:r,w:s,h:a}}];o(v);var p=[];for(let t=0,n=Math.floor(h(e.layers_min,e.layers_max));t<=n;t++){var m=Math.floor(h(0,v.length));p[t]=q(v[m].name,v[m].params),p[t]&&"p"in p[t]?(e.p_outlined&&h(0,100)<=e.p_outlined?(p[t].p.strokeColor="white",p[t].p.strokeWidth=pt*Math.floor(h(1,4))):e.p_gradient&&h(0,100)<=e.p_gradient?(p[t].p.fillColor=l(p[t].p),p[t].gradient=1):p[t].p.fillColor="white",f=Math.random(),p[t].p.opacity=f,p[t].ox-=p[t].dx):console.log("error")}for(var y=-1;y<vt/(.866*s);y++){for(var w=-1;w<gt/(.866*s);w++)for(m in p)(c=p[m].p.clone()).position=new i.Point(p[m].ox+p[m].xm*w,p[m].oy+p[m].ym*y);for(m in p)y%2?p[m].ox=p[m].p.position._x:p[m].ox-=p[m].dx}for(m in p)p[m].p.visible=!1}}function q(t,e){var n={},r=e.w,s=e.x,a=e.y,o=e.h,l,u,c;switch(t){case"streak-1":(l=new i.Path).add(new i.Point(s,a-o/2)),l.add(new i.Point(s+r-o,a-o/2)),l.add(new i.Point(s+r,a)),l.add(new i.Point(s+r-o,a+o/2)),l.add(new i.Point(s,a+o/2)),l.closed=!0,(u=l.clone()).rotate(120,new i.Point(s,a)),(c=l.clone()).rotate(240,new i.Point(s,a)),l=l.unite(u).unite(c),n.p=l,n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,n.ox=l.position._x,n.oy=l.position._y;break;case"streak-2":var d=e.w_m?e.w_m:r-o/2;(l=new i.Path).add(new i.Point(s,a)),l.add(new i.Point(s+d,a-o/2)),l.add(new i.Point(s+r,a)),l.add(new i.Point(s+d,a+o/2)),l.closed=!0,(u=l.clone()).rotate(120,new i.Point(s,a)),(c=l.clone()).rotate(240,new i.Point(s,a)),l=l.unite(u).unite(c),n.p=l,n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,n.ox=l.position._x,n.oy=l.position._y;break;case"circle":l=new i.Path.Circle(s,a,r),e.d&&(u=new i.Path.Circle(s,a,r-e.d),l=l.subtract(u)),"rectangular"==e.type?(n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0):(n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4),n.ox=l.position._x,n.oy=l.position._y,e.scale&&l.scale(e.scale),n.p=l;break;case"hexagon-subtracted":n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,r*=Math.sin(Math.PI/3),l=new i.Path.RegularPolygon(s,a,6,r),u=new i.Path.Circle(s-Math.sin(Math.PI/3)*r*1.5,a-Math.cos(Math.PI/3)*r*1.5,1.2*r),l=l.subtract(u),u=new i.Path.Circle(s+Math.sin(Math.PI/3)*r*1.5,a-Math.cos(Math.PI/3)*r*1.5,1.2*r),l=l.subtract(u),u=new i.Path.Circle(s,a+1.5*r,1.2*r),(l=l.subtract(u)).scale(.7,new i.Point(s,a)),e.scale&&l.scale(e.scale,new i.Point(s,a)),n.ox=l.position._x,n.oy=l.position._y,n.p=l;break;case"triangle-united":"rectangular"!=e.type&&(n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,r*=Math.sin(Math.PI/3)),(l=new i.Path.RegularPolygon(s,a,3,r)).scale(.6,new i.Point(s,a));var f=s-Math.sin(Math.PI/3)*r*.5,_=a+Math.cos(Math.PI/3)*r*.5;(u=new i.Path.RegularPolygon(f,_,3,r/3)).rotate(60,new i.Point(f,_)),l=l.unite(u),f=s+Math.sin(Math.PI/3)*r*.5,_=a+Math.cos(Math.PI/3)*r*.5,(u=new i.Path.RegularPolygon(f,_,3,r/3)).rotate(60,new i.Point(f,_)),l=l.unite(u),f=s,_=a-.5*r,(u=new i.Path.RegularPolygon(f,_,3,r/3)).rotate(60,new i.Point(f,_)),l=l.unite(u),"rectangular"==e.type?(n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0):l.scale(.7,new i.Point(s,a)),n.ox=l.position._x,n.oy=l.position._y,n.p=l;break;case"triangle":if("rectangular"!=e.type&&(n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,r*=Math.sin(Math.PI/3)),l=new i.Path.RegularPolygon(s,a,3,r),"rectangular"==e.type){var g=new i.Path.RegularPolygon(s,a,3,Math.floor(h(.5*r,.95*r)));l=l.subtract(g),n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0}else l.scale(.7,new i.Point(s,a));n.ox=l.position._x,n.oy=l.position._y,n.p=l;break;case"star":var u;(u=new i.Path).add(new i.Point(s,a-1.1*r)),u.add(new i.Point(s+1.1*r,a-1.1*r)),u.add(new i.Point(s+1.1*r,a)),u.add(new i.Point(s+r/2,a)),u.add(new i.Point(s+.1*r,a-.1*r)),u.add(new i.Point(s,a-r/2)),u.closed=!0,u.smooth(),(u=(l=(l=new i.Path.Rectangle(s,a-r,r,r)).subtract(u)).clone()).scale([-1,1],[s,a]),(u=(l=l.unite(u)).clone()).scale([1,-1],[s,a]),l=l.unite(u),"rectangular"==e.type?(n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0):(l.scale([1,1.7]),n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4),n.ox=l.position._x,n.oy=l.position._y,n.p=l;break;case"hexagon":if("rectangular"!=e.type&&(n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,r*=Math.sin(Math.PI/3)),l=new i.Path.RegularPolygon(s,a,6,r),e.maze)for(var v=Math.round(h(r/10,r/3)),p=r-v,m=!0,u;p>v/2;)u=new i.Path.RegularPolygon(s,a,6,p),l=m?l.subtract(u):l.unite(u),m=!m,p-=v;if("rectangular"==e.type){if(!e.cubic){var g=new i.Path.RegularPolygon(s,a,6,Math.floor(h(.5*r,.95*r)));l=l.subtract(g)}n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0}else l.scale(.7,new i.Point(s,a));if(n.ox=l.position._x,n.oy=l.position._y,e.cubic){for(var y=new i.Path({closed:!0,fillColor:"black"}),w=Math.floor(3*Math.random()),x=0;x<3;x++){var b=(x+2*w)%l.segments.length;y.add(l.segments[b].clone())}y.add(l.bounds.center),n.p=y}else e.scale&&l.scale(e.scale),n.p=l;break;case"rhombus":var C=e.d;l=new i.Path.RoundRectangle(new i.Rectangle(s,a,r,r),new i.Size(C,C));var S=new i.Path.RoundRectangle(new i.Rectangle(s+o,a+o,r-2*o,r-2*o),new i.Size(C,C));(l=l.subtract(S)).rotate(45),"rectangular"==e.type?(Math.random()>=.5?Math.random()>=.5?l.scale(.5,1):l.scale(Math.random()/2+.5,1):Math.random()>=.5?l.scale(1,.5):l.scale(1,Math.random()/2+.5),n.xm=l.bounds.width,n.ym=l.bounds.height,n.dx=0):(n.xm=pt+r+o/2,n.ym=pt+(r+o/2)*Math.sin(Math.PI/3),n.dx=r/2+o/4,l.scale(.7),l.scale([1,1.7])),l.position=new i.Point(s,a),n.ox=s,n.oy=a,n.p=l;break;default:console.log("unknown type")}return n}function V(t,e){for(var n,r,a,o,l,u,c,d,f,_=0;_<t;_++){if(a=Math.round(h(50,300))*pt,n=Math.round(h(0,gt-a)),r=0,o=h(100*pt,600*pt),l=Math.random(),u=h(.2,1),r+o+4*(c=h(50*pt,150*pt))+a/5+(f=Math.random()>=.5?Math.floor(h(a/5,4*a/5)):0)>vt&&(o-=r+o+4*c+a/5+f-vt),(d=new i.Path).add(new i.Point(n,r)),d.add(new i.Point(n,r+o)),d.add(new i.Point(n-c,r+o+2*c)),d.add(new i.Point(n-c,vt)),d.add(new i.Point(n-c+a-f/2,vt)),d.add(new i.Point(n-c+a-f/2,r+o+4*c+h(0,a/5)+f)),d.add(new i.Point(n+a,r+o+2*c)),d.add(new i.Point(n+a,r)),d.closed=!0,e.striped&&h(0,100)<e.striped)if(e.striped_partial&&h(0,100)<e.striped_partial){var g=new i.Path;g.add(new i.Point(n-2*c,o-2*c)),g.add(new i.Point(n-c/3,o+2*(c-c/3))),g.add(new i.Point(n-c/3,vt)),g.add(new i.Point(n-2*c,vt)),g.closed=!0,g=s(g,Math.floor(h(4*pt,10*pt)),1),d=d.subtract(g)}else d=s(d,Math.floor(h(4*pt,10*pt)),1);d.fillColor=u,d.opacity=l,Math.random()>=.5&&(d.scale(-1,1),d.position=new i.Point(Math.floor(h(0,gt)),vt/2)),Math.random()>=.5&&(d.rotate(90),d.position=new i.Point(gt/2,Math.floor(h(0,vt)))),Math.random()>=.5&&d.scale(1,-1)}}function H(t,e){var n,r,s,a,o,l,u,c,d,f,_,g,v,p,m,y;for(let p=0;p<t;p++){n=Math.floor(h(-40,1)*pt),r=Math.floor(h(-40,1)*pt),s=Math.random()>=.5?2*pt:Math.floor(h(1*pt,150*pt)),a=Math.random()>=.5?2*pt:Math.floor(h(1*pt,150*pt)),o=Math.floor(h(4,e.sets_x_max)),l=Math.floor(h(1,e.sets_y_max)),e.w_multiplier&&e.w_multiplier>1&&(s*=e.w_multiplier),e.h_multiplier&&e.h_multiplier>1&&(a*=e.h_multiplier),e.p_regular&&h(0,100)<e.p_regular?((y=new i.Path.Rectangle(100*pt,100*pt,s,a)).fillColor=Math.random(),y.opacity=Math.random()):((y=U(200*pt,200*pt,Math.floor(h(50,250))*pt,Math.floor(h(0,4)),Math.floor(h(2,5)),pt*Math.floor(h(1,7)))).opacity=Math.random(),y.fillColor=Math.random(),s=Math.floor(y.bounds.width),a=Math.floor(y.bounds.height)),u=Math.floor(h(s,4*s)),c=Math.floor(h(a,4*a)),f=(s+u)*o-u+(d=Math.floor(h(2*s,200*pt))),_=(a+c)*l-c+d,g=Math.floor((gt-n)/f)+1,v=Math.floor((vt-r)/_)+1;for(var w=0;w<v;w++)for(var x=0;x<g;x++)for(var b=0;b<l;b++)for(var C=0;C<o;C++){var S;y.clone().position=new i.Point(n+C*(s+u)+x*f,r+b*(a+c)+w*_)}y.visible=!1}}var Z=[[1,3],[0,2]];function U(t,e,n,r,s,a){var o=t,l=e,u=Math.floor(h(n/4,n)),c=u,d=u;switch(r){case 0:e-=u,o+=a,c=a;break;case 1:t-=u,l+=a,d=a;break;case 2:c=a,o+=a,l+=u;break;case 3:d=a,l+=a,o+=u}var f=new i.Path.Rectangle(t,e,c,d);return--s>0&&(Math.random()>=.5&&(f=f.unite(U(Math.floor(h(t,o)),Math.floor(h(e,l)),n,Z[r%2][Math.floor(h(0,2))],0,a)),s--),s>0&&(f=f.unite(U(Math.floor(h(t,o)),Math.floor(h(e,l)),n,Z[r%2][Math.floor(h(0,2))],s,a)))),f}function W(t,e){var n,r,s,o,l,u,c,d,f,_,g,v;for(let m=0;m<t;m++){for(l=h(1,e.m_max),d=h(50*pt,200*pt*l),n=u=h(0,gt),r=c=h(0,vt),s=!0,o=!0,f=new i.Path,_=h(.2,1),f.strokeWidth=0,f.add(new i.Point(u,c));;)if(s?n<u+d?(o?(n+=g=h(5,11)*pt*l*e.h_multiplier,r-=g):n+=g=h(10,51)*pt*l*e.w_multiplier,o=!o):(s=!s,r+=h(10,51)*pt*l*e.w_multiplier):(o?(n-=g=h(5,21)*pt*l*e.h_multiplier,r+=g):n-=g=h(20,51)*pt*l*e.w_multiplier,n<u&&(g=u-n,n=u,o&&(r-=g)),o=!o),f.add(new i.Point(n,r)),n==u&&!s){f.closed=!0;break}var p,p,p;if(e.p_outlined&&h(0,100)<e.p_outlined?(f.strokeWidth=pt*Math.floor(h(1,3)),f.strokeColor=_):f.fillColor=_,v=Math.random(),f.opacity=v,(g=a())&&f.rotate(g),e.text&&h(0,100)<e.text&&E(f.position._x,f.position._y,_,v,e.text_light,f.bounds.width,f.bounds.height),n=0,r=0,f.position._x+f.bounds.width>gt)n=f.position._x-gt,(p=f.clone()).position=new i.Point(n,f.position._y);if(f.position._y+f.bounds.height>vt)r=f.position._y-vt,(p=f.clone()).position=new i.Point(f.position._x,r);if(n&&r)(p=f.clone()).position=new i.Point(n,r)}}function G(t,e){for(var n,r,a,o,l,u,c,d,f,_,g,v,p,m,y=[[],[]],w=0,x=0,b,C=0;C<t;C++){if(w=0,n=Math.round(h(50,200))*pt,r=Math.round(h(50,200))*pt,e.w_multiplier&&(n=Math.round(n*e.w_multiplier)),e.h_multiplier&&(r=Math.round(r*e.h_multiplier))<1&&(r=1),a=Math.round(h(-n/2,gt-n/2)),o=Math.round(h(-r/2,vt-r/2)),l=new i.Path.Rectangle(a,o,n,r),d=e.additive?1:Math.random(),f=e.opaque&&h(0,100)<e.opaque?1:Math.random(),e.caves&&h(0,100)<e.caves){c=Math.random()>=.5,n<r?(u=n/10,y[0][0]=a+n/2,y[0][1]=o+u*(c?.3:-.3),y[1][0]=a+n/2,y[1][1]=o+r-u*(c?.3:-.3)):(u=r/10,y[0][0]=a+u*(c?.3:-.3),y[0][1]=o+r/2,y[1][0]=a+n-u*(c?.3:-.3),y[1][1]=o+r/2);var S=new i.Path.Circle({center:[y[0][0],y[0][1]],radius:u}),M=new i.Path.Circle({center:[y[1][0],y[1][1]],radius:u});l=c?l.unite(S).unite(M):l.subtract(S).subtract(M)}if(b=e.p_outlined&&h(0,100)<e.p_outlined?1:0,e.pins&&h(0,100)<e.pins){_=Math.round(h(2*pt,Math.max(n,r)/10)),g=Math.round(h(1*pt,_)),m=d<=.1?d/2:d-.1;var P=new i.Path,k=Math.round(h(1,3)*_),I=Math.round(h(.5,1.5)*_);if(P.add(new i.Point(0,0)),P.add(new i.Point(k-I,0)),P.add(new i.Point(k,_/4)),P.add(new i.Point(k,.75*_)),P.add(new i.Point(k-I,_)),P.add(new i.Point(0,_)),P.closed=!0,b){var z=_/6;z<1&&(z=1),P.strokeWidth=Math.round(pt*h(1,1.5)),P.strokeColor=d}else P.fillColor=d;if(P.opacity=f,n<r){v=Math.floor(r/(_+g)),p=Math.round((r-v*(_+g)+g)/2);var T=a+n+P.bounds.width/2,O=a-P.bounds.width/2,L=o+p+P.bounds.height/2;for(let t=0;t<v;t++){var E=P.clone(),B=P.clone().scale([-1,1]);E.position=new i.Point(T,L+t*(_+g)),B.position=new i.Point(O,L+t*(_+g))}P.visible=!1}else{P.rotate(90),v=Math.floor(n/(_+g));var j=a+(p=Math.floor((n-v*(_+g)+g)/2))+P.bounds.width/2,R=o+r+P.bounds.height/2,D=o-P.bounds.height/2;for(let t=0;t<v;t++){var E=P.clone(),B=P.clone().scale([1,-1]);E.position=new i.Point(j+t*(_+g),R),B.position=new i.Point(j+t*(_+g),D)}P.visible=!1}w=1}else if(e.beveled&&h(0,100)<e.beveled){var F=Math.round(h(n/8,n/6)),q=Math.round(h(r/8,r/6)),E;(E=new i.Path).add(new i.Point(a,o)),E.add(new i.Point(a+F,o)),E.add(new i.Point(a,o+q)),E.closed=!0;var B=E.clone().scale([1,-1],new i.Point(E.position.x,o+r/2));Math.random()>.5&&(l=l.subtract(E)),Math.random()>.5&&(l=l.subtract(B)),Math.random()>.5&&(E.scale([-1,1],new i.Point(a+n/2,E.position.y)),l=l.subtract(E)),Math.random()>.5&&(B.scale([-1,1],new i.Point(a+n/2,B.position.y)),l=l.subtract(B))}if(e.eroded&&h(0,100)<e.eroded)for(let t=0;t<Math.round(h(1,6));t++)(E=new i.Path.Rectangle(0,0,Math.round(.5*n),Math.round(.5*r))).position=new i.Point([h(a,a+n),h(o,o+r)]),l=l.subtract(E);if(e.striped&&h(0,100)<e.striped&&(l=s(l,Math.floor(h(2*pt,10*pt)),Math.random()>=.5?1:0)),b?(l.strokeWidth=pt*Math.floor(h(1,3)),l.strokeColor=d):l.fillColor=d,l.opacity=f,e.text&&h(0,100)<e.text&&(A(l.position._x,l.position._y,d,f,N[Math.floor(h(0,N.length))],e.text_light,n,r),w=1),e.rotate){var V=h(0,100);!w&&e.rotate&&(V<e.rotate||x)&&(x&&(V>e.rotate?x--:x++),l.rotate(45))}}}const J=["m 5619.866,3954.6024 c 0,-3.488 -2.825,-6.313 -6.313,-6.313 -3.485,0 -6.311,2.825 -6.311,6.313 0,3.486 2.826,6.312 6.311,6.312 3.488,0 6.313,-2.826 6.313,-6.312 z m 2.114,186.551 h -23.863 v -85.858 h 10.386 v -85.226 h -1.646 c -2.489,0 -4.508,-2.018 -4.508,-4.508 v -21.918 c 0,-2.489 2.019,-4.508 4.508,-4.508 h 13.392 c 2.49,0 4.508,2.019 4.508,4.508 v 21.918 c 0,2.49 -2.018,4.508 -4.508,4.508 h -1.644 v 85.226 h 3.375 c 23.612,0 42.929,19.316 42.929,42.927 v 0 c 0,23.612 -19.317,42.929 -42.929,42.929 m -57.007,-85.858 h 7.891 v 85.858 h -7.891 v -85.858 m -125.885,0 h 113.259 v 85.858 h -113.259 v -85.858 m -54.058,-100.693 c 0,-3.488 -2.826,-6.313 -6.312,-6.313 -3.487,0 -6.313,2.825 -6.313,6.313 0,3.486 2.826,6.312 6.313,6.312 3.486,0 6.312,-2.826 6.312,-6.312 z m -58.505,143.622 v -0 c 0,-23.611 19.318,-42.927 42.929,-42.927 h 4.213 v -85.226 h -1.645 c -2.489,0 -4.508,-2.018 -4.508,-4.508 v -21.918 c 0,-2.489 2.019,-4.508 4.508,-4.508 h 13.391 c 2.49,0 4.508,2.019 4.508,4.508 v 21.918 c 0,2.49 -2.018,4.508 -4.508,4.508 h -1.644 v 85.226 h 9.549 v 85.858 h -23.864 c -23.611,0 -42.929,-19.317 -42.929,-42.929 m 79.419,-42.929 h 7.892 v 85.858 h -7.892 v -85.858","m 5843.275,3928.2374 c 0,-3.487 -2.826,-6.313 -6.313,-6.313 -3.486,0 -6.313,2.826 -6.313,6.313 0,3.486 2.827,6.312 6.313,6.312 3.487,0 6.313,-2.826 6.313,-6.312 z m -39.82,0 c 0,-3.487 -2.826,-6.313 -6.312,-6.313 -3.487,0 -6.313,2.826 -6.313,6.313 0,3.486 2.826,6.312 6.313,6.312 3.486,0 6.312,-2.826 6.312,-6.312 z m -38.331,143.128 v -24.287 c 0,-19.53 10.928,-36.624 26.968,-45.487 v -57.888 h -1.645 c -2.49,0 -4.508,-2.018 -4.508,-4.508 v -21.918 c 0,-2.489 2.018,-4.508 4.508,-4.508 h 13.392 c 2.49,0 4.508,2.019 4.508,4.508 v 21.918 c 0,2.49 -2.018,4.508 -4.508,4.508 h -1.646 v 53.637 c 4.714,-1.418 9.699,-2.19 14.859,-2.19 5.16,0 10.146,0.772 14.859,2.19 v -53.637 h -1.644 c -2.49,0 -4.508,-2.018 -4.508,-4.508 v -21.918 c 0,-2.489 2.018,-4.508 4.508,-4.508 h 13.391 c 2.489,0 4.507,2.019 4.507,4.508 v 21.918 c 0,2.49 -2.018,4.508 -4.507,4.508 h -1.645 v 57.888 c 16.039,8.863 26.967,25.958 26.967,45.487 v 24.287 c -34.62,-7.017 -69.237,-7.215 -103.856,0 m 0,33.12 v -26.99 c 34.619,-7.994 69.236,-7.775 103.856,0 v 26.99 c -34.62,-7.017 -69.237,-7.214 -103.856,0 m 0,13.559 v -4.615 c 34.619,-7.996 69.236,-7.777 103.856,-0 v 4.616 c -34.62,-7.016 -69.237,-7.215 -103.856,0 m 51.928,83.662 c -28.56,0 -51.928,-23.367 -51.928,-51.928 v -13.848 c 34.619,-7.994 69.236,-7.775 103.856,0 v 13.848 c 0,28.561 -23.367,51.928 -51.928,51.928","m 5903.178,3820.1864 c -3.734,0 -6.761,3.028 -6.761,6.762 0,3.735 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.027 6.762,-6.762 0,-3.734 -3.027,-6.762 -6.762,-6.762 z m 6.762,-165.491 c 0,-3.734 -3.027,-6.761 -6.762,-6.761 -3.734,0 -6.761,3.027 -6.761,6.761 0,3.735 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.027 6.762,-6.762 z m -37.208,82.176 c -1.903,-27.588 -24.142,-49.827 -51.729,-51.729 -1.313,-0.09 -2.642,-0.137 -3.951,-0.137 -30.777,0 -55.816,25.039 -55.816,55.817 0,30.778 25.039,55.817 55.816,55.817 15.414,0 30.289,-6.465 40.811,-17.739 10.669,-11.431 15.95,-26.357 14.869,-42.029 z m -141.807,83.315 c -3.734,0 -6.761,3.028 -6.761,6.762 0,3.735 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.027 6.762,-6.762 0,-3.734 -3.027,-6.762 -6.762,-6.762 z m 0,-172.252 c -3.734,0 -6.761,3.027 -6.761,6.761 0,3.735 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.027 6.762,-6.762 0,-3.734 -3.027,-6.761 -6.762,-6.761 z m 180.467,140.199 h 14.13 v 38.62 c 0,12.397 -10.142,22.54 -22.539,22.54 h -38.62 v -14.132 c 0,-3.491 -2.855,-6.346 -6.346,-6.346 h -0 c -3.49,0 -6.346,2.855 -6.346,6.346 v 14.132 h -7.789 v -14.132 c 0,-3.491 -2.855,-6.346 -6.347,-6.346 -3.492,0 -6.347,2.855 -6.347,6.346 v 14.132 h -7.788 v -14.132 c 0,-3.491 -2.857,-6.346 -6.347,-6.346 h -10e-4 c -3.49,0 -6.346,2.855 -6.346,6.346 v 14.132 h -7.789 v -14.132 c 0,-3.491 -2.855,-6.346 -6.347,-6.346 -3.491,0 -6.347,2.855 -6.347,6.346 v 14.132 h -7.788 v -14.132 c 0,-3.491 -2.857,-6.346 -6.347,-6.346 h -0 c -3.491,0 -6.346,2.855 -6.346,6.346 v 14.132 h -38.619 c -12.397,0 -22.54,-10.143 -22.54,-22.54 v -38.621 h 14.132 c 3.489,0 6.346,-2.855 6.346,-6.345 v -0 c 0,-3.49 -2.857,-6.346 -6.346,-6.346 h -14.132 v -7.789 h 14.132 c 3.489,0 6.346,-2.855 6.346,-6.346 0,-3.492 -2.857,-6.347 -6.346,-6.347 h -14.132 v -7.789 h 14.132 c 3.489,0 6.346,-2.856 6.346,-6.346 v -0 c 0,-3.49 -2.857,-6.345 -6.346,-6.345 h -14.132 v -7.79 h 14.132 c 3.489,0 6.346,-2.855 6.346,-6.347 0,-3.491 -2.857,-6.347 -6.346,-6.347 h -14.132 v -7.788 h 14.132 c 3.489,0 6.346,-2.856 6.346,-6.347 v -0 c 0,-3.49 -2.857,-6.346 -6.346,-6.346 h -14.132 v -38.619 c 0,-12.397 10.143,-22.539 22.54,-22.539 h 38.619 v 14.131 c 0,3.49 2.856,6.346 6.347,6.346 h 10e-4 c 3.491,0 6.346,-2.856 6.346,-6.346 v -14.131 h 7.79 v 14.131 c 0,3.49 2.855,6.346 6.345,6.346 h 10e-4 c 3.491,0 6.347,-2.856 6.347,-6.346 v -14.131 h 7.788 v 14.131 c 0,3.49 2.856,6.346 6.347,6.346 3.492,0 6.347,-2.856 6.347,-6.346 v -14.131 h 7.79 v 14.131 c 0,3.49 2.854,6.346 6.345,6.346 h 0 c 3.49,0 6.346,-2.856 6.346,-6.346 v -14.131 h 7.789 v 14.131 c 0,3.49 2.855,6.346 6.346,6.346 3.492,0 6.348,-2.856 6.348,-6.346 v -14.131 h 38.618 c 12.397,0 22.539,10.142 22.539,22.539 v 38.619 h -14.13 c -3.491,0 -6.347,2.857 -6.347,6.347 v 10e-4 c 0,3.491 2.856,6.346 6.347,6.346 h 14.13 v 7.79 h -14.13 c -3.491,0 -6.347,2.855 -6.347,6.345 v 10e-4 c 0,3.491 2.856,6.347 6.347,6.347 h 14.13 v 7.789 h -14.13 c -3.491,0 -6.347,2.855 -6.347,6.347 0,3.491 2.856,6.346 6.347,6.346 h 14.13 v 7.79 h -14.13 c -3.491,0 -6.347,2.855 -6.347,6.346 v 0 c 0,3.49 2.856,6.347 6.347,6.347 h 14.13 v 7.788 h -14.13 c -3.491,0 -6.347,2.855 -6.347,6.347 0,3.491 2.856,6.346 6.347,6.346 m -94.34,0.555 c -26.393,0 -47.865,-21.472 -47.865,-47.866 0,-26.393 21.472,-47.865 47.865,-47.865 1.126,0 2.272,0.04 3.405,0.118 23.647,1.63 42.711,20.694 44.342,44.343 0.928,13.449 -3.599,26.254 -12.749,36.056 -9.023,9.668 -21.78,15.214 -34.998,15.214","m 5581.844,3820.1664 c -3.735,0 -6.762,3.027 -6.762,6.762 0,3.734 3.027,6.762 6.762,6.762 3.734,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.028,-6.762 -6.762,-6.762 z m 6.762,-165.491 c 0,-3.735 -3.028,-6.762 -6.762,-6.762 -3.735,0 -6.762,3.027 -6.762,6.762 0,3.734 3.027,6.762 6.762,6.762 3.734,0 6.762,-3.028 6.762,-6.762 z m -35.192,41.953 c 0,-7.469 -6.055,-13.523 -13.524,-13.523 h -88.346 c -7.469,0 -13.524,6.054 -13.524,13.523 v 60.149 c 0,5.978 2.375,11.711 6.602,15.938 l 19.181,19.181 c 4.227,4.227 9.96,6.602 15.938,6.602 h 60.149 c 7.469,0 13.524,-6.055 13.524,-13.524 z m -143.823,123.538 c -3.735,0 -6.762,3.027 -6.762,6.762 0,3.734 3.027,6.762 6.762,6.762 3.734,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.028,-6.762 -6.762,-6.762 z m 0,-172.253 c -3.735,0 -6.762,3.027 -6.762,6.762 0,3.734 3.027,6.762 6.762,6.762 3.734,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.028,-6.762 -6.762,-6.762 z m 180.466,140.2 h 14.131 v 38.62 c 0,12.396 -10.143,22.539 -22.54,22.539 h -38.619 v -14.131 c 0,-3.491 -2.856,-6.347 -6.347,-6.347 h -0 c -3.49,0 -6.346,2.856 -6.346,6.347 v 14.131 h -7.789 v -14.131 c 0,-3.491 -2.855,-6.347 -6.346,-6.347 h -0 c -3.49,0 -6.347,2.856 -6.347,6.347 v 14.131 h -7.788 v -14.131 c 0,-3.491 -2.856,-6.347 -6.347,-6.347 -3.491,0 -6.347,2.856 -6.347,6.347 v 14.131 h -7.789 v -14.131 c 0,-3.491 -2.856,-6.347 -6.346,-6.347 h -10e-4 c -3.491,0 -6.347,2.856 -6.347,6.347 v 14.131 h -7.788 v -14.131 c 0,-3.491 -2.855,-6.347 -6.347,-6.347 -3.492,0 -6.347,2.856 -6.347,6.347 v 14.131 h -38.619 c -12.397,0 -22.54,-10.143 -22.54,-22.539 v -38.621 h 14.131 c 3.492,0 6.347,-2.855 6.347,-6.346 v -10e-4 c 0,-3.49 -2.855,-6.346 -6.347,-6.346 h -14.131 v -7.789 h 14.131 c 3.492,0 6.347,-2.855 6.347,-6.347 0,-3.491 -2.855,-6.346 -6.347,-6.346 h -14.131 v -7.789 h 14.131 c 3.492,0 6.347,-2.856 6.347,-6.347 v -10e-4 c 0,-3.49 -2.855,-6.346 -6.347,-6.346 h -14.131 v -7.789 h 14.131 c 3.492,0 6.347,-2.855 6.347,-6.347 0,-3.492 -2.855,-6.347 -6.347,-6.347 h -14.131 v -7.788 h 14.131 c 3.492,0 6.347,-2.857 6.347,-6.347 v -0 c 0,-3.49 -2.855,-6.346 -6.347,-6.346 h -14.131 v -38.619 c 0,-12.397 10.143,-22.54 22.54,-22.54 h 38.62 v 14.131 c 0,3.491 2.856,6.347 6.346,6.347 h 10e-4 c 3.491,0 6.347,-2.856 6.347,-6.347 v -14.131 h 7.789 v 14.131 c 0,3.491 2.854,6.347 6.346,6.347 3.491,0 6.347,-2.856 6.347,-6.347 v -14.131 h 7.788 v 14.131 c 0,3.491 2.856,6.347 6.347,6.347 h 0 c 3.49,0 6.346,-2.856 6.346,-6.347 v -14.131 h 7.79 v 14.131 c 0,3.491 2.855,6.347 6.346,6.347 3.492,0 6.347,-2.856 6.347,-6.347 v -14.131 h 7.788 v 14.131 c 0,3.491 2.857,6.347 6.347,6.347 h 0 c 3.491,0 6.346,-2.856 6.346,-6.347 v -14.131 h 38.619 c 12.397,0 22.54,10.143 22.54,22.54 v 38.619 h -14.131 c -3.491,0 -6.347,2.857 -6.347,6.347 v 10e-4 c 0,3.491 2.856,6.346 6.347,6.346 h 14.131 v 7.789 h -14.131 c -3.491,0 -6.347,2.856 -6.347,6.346 v 10e-4 c 0,3.491 2.856,6.347 6.347,6.347 h 14.131 v 7.788 h -14.131 c -3.491,0 -6.347,2.856 -6.347,6.347 0,3.492 2.856,6.347 6.347,6.347 h 14.131 v 7.79 h -14.131 c -3.491,0 -6.347,2.855 -6.347,6.345 v 0 c 0,3.49 2.856,6.346 6.347,6.346 h 14.131 v 7.789 h -14.131 c -3.491,0 -6.347,2.855 -6.347,6.346 0,3.492 2.856,6.347 6.347,6.347","m 5229.281,3786.3364 c -3.734,0 -6.761,3.028 -6.761,6.762 0,3.735 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.027 6.762,-6.762 0,-3.734 -3.027,-6.762 -6.762,-6.762 z m 0,-109.797 c -3.734,0 -6.761,3.027 -6.761,6.762 0,3.734 3.027,6.762 6.761,6.762 3.735,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.027,-6.762 -6.762,-6.762 z m -54.899,3.675 c -32.025,0 -57.985,25.96 -57.985,57.985 0,32.024 25.96,57.986 57.985,57.986 32.026,0 57.986,-25.962 57.986,-57.986 0,-32.025 -25.96,-57.985 -57.986,-57.985 z m -54.898,-3.675 c -3.734,0 -6.762,3.027 -6.762,6.762 0,3.734 3.028,6.762 6.762,6.762 3.734,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.028,-6.762 -6.762,-6.762 z m 0,123.321 c 3.734,0 6.762,-3.027 6.762,-6.762 0,-3.734 -3.028,-6.762 -6.762,-6.762 -3.734,0 -6.762,3.028 -6.762,6.762 0,3.735 3.028,6.762 6.762,6.762 z m 188.459,-27.043 c 3.49,0 6.345,2.855 6.345,6.346 v 0 c 0,3.492 -2.855,6.346 -6.345,6.346 h -44.429 c -0.221,0 -0.431,-0.043 -0.646,-0.066 l -41.239,41.24 c 0.022,0.215 0.065,0.424 0.065,0.645 v 44.429 c 0,3.49 -2.855,6.346 -6.346,6.346 h -0 c -3.491,0 -6.346,-2.856 -6.346,-6.346 v -38.36 h -7.789 v 38.36 c 0,3.49 -2.855,6.346 -6.346,6.346 h -0 c -3.491,0 -6.345,-2.856 -6.345,-6.346 v -38.36 h -7.791 v 38.36 c 0,3.49 -2.855,6.346 -6.345,6.346 h -0 c -3.49,0 -6.346,-2.856 -6.346,-6.346 v -38.36 h -7.788 v 38.36 c 0,3.49 -2.856,6.346 -6.345,6.346 h -0 c -3.492,0 -6.346,-2.856 -6.346,-6.346 v -38.36 h -7.789 v 38.36 c 0,3.49 -2.854,6.346 -6.346,6.346 h -0 c -3.491,0 -6.346,-2.856 -6.346,-6.346 v -44.429 c 0,-0.221 0.043,-0.431 0.066,-0.647 l -41.24,-41.237 c -0.215,0.022 -0.424,0.065 -0.644,0.065 h -44.429 c -3.49,0 -6.345,-2.855 -6.345,-6.346 v -0 c 0,-3.492 2.855,-6.346 6.345,-6.346 h 38.358 v -7.789 h -38.358 c -3.49,0 -6.345,-2.854 -6.345,-6.346 v -0 c 0,-3.491 2.855,-6.346 6.345,-6.346 h 38.358 v -7.789 h -38.358 c -3.49,0 -6.345,-2.855 -6.345,-6.345 v -0 c 0,-3.491 2.855,-6.346 6.345,-6.346 h 38.358 v -7.79 h -38.358 c -3.49,0 -6.345,-2.854 -6.345,-6.345 v -0 c 0,-3.492 2.855,-6.346 6.345,-6.346 h 38.358 v -7.79 h -38.358 c -3.49,0 -6.345,-2.855 -6.345,-6.345 v -0 c 0,-3.49 2.855,-6.345 6.345,-6.345 h 44.429 c 0.221,0 0.43,0.043 0.645,0.065 l 41.24,-41.239 c -0.022,-0.215 -0.066,-0.424 -0.066,-0.645 v -44.4278 c 0,-3.4914 2.855,-6.3461 6.346,-6.3461 h 0 c 3.491,0 6.346,2.8547 6.346,6.3461 v 38.3578 h 7.788 v -38.3578 c 0,-3.4914 2.856,-6.3461 6.346,-6.3461 h 0 c 3.49,0 6.345,2.8547 6.345,6.3461 v 38.3578 h 7.789 v -38.3578 c 0,-3.4914 2.855,-6.3461 6.346,-6.3461 h 0 c 3.491,0 6.346,2.8547 6.346,6.3461 v 38.3578 h 7.789 v -38.3578 c 0,-3.4914 2.855,-6.3461 6.345,-6.3461 h 0 c 3.49,0 6.345,2.8547 6.345,6.3461 v 38.3578 h 7.79 v -38.3578 c 0,-3.4914 2.854,-6.3461 6.345,-6.3461 h 0 c 3.492,0 6.348,2.8547 6.348,6.3461 v 44.4278 c 0,0.222 -0.044,0.431 -0.066,0.647 l 41.238,41.239 c 0.215,-0.023 0.425,-0.066 0.646,-0.066 h 44.429 c 3.49,0 6.345,2.854 6.345,6.346 v 0 c 0,3.49 -2.855,6.346 -6.345,6.346 h -38.36 v 7.788 h 38.36 c 3.49,0 6.345,2.855 6.345,6.346 v 0 c 0,3.49 -2.855,6.345 -6.345,6.345 h -38.36 v 7.79 h 38.36 c 3.49,0 6.345,2.854 6.345,6.346 v 0 c 0,3.491 -2.855,6.345 -6.345,6.345 h -38.36 v 7.79 h 38.36 c 3.49,0 6.345,2.855 6.345,6.346 v 0 c 0,3.491 -2.855,6.346 -6.345,6.346 h -38.36 v 7.788 h 38.36","m 5268.892,4075.6184 h -7.584 v 87.196 h 7.584 z m -8.383,-128.523 c -3.734,0 -6.762,3.027 -6.762,6.762 0,3.734 3.028,6.762 6.762,6.762 3.735,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.027,-6.762 -6.762,-6.762 z m -13.695,215.719 h 9.231 v -55.275 h -9.231 z m -3.463,-75.075 h -9.231 v 75.075 h 9.231 z m -13.428,19.8 h -9.232 v 55.275 h 9.232 z m -12.694,-19.8 h -9.231 v 75.075 h 9.231 z m -13.2,27.095 h -9.231 v 47.98 h 9.231 z m -12.693,-39.216 h -9.231 v 87.196 h 9.231 z m -14.495,31.921 h -9.232 v 55.275 h 9.232 z m -12.694,-19.8 h -9.232 v 75.075 h 9.232 z m -13.429,19.8 h -9.231 v 55.275 h 9.231 z m -12.693,-19.8 h -9.232 v 71.188 l 3.887,3.887 h 5.345 z m -13.847,-13.27 h -9.232 v 70.611 l 9.232,9.232 z m -12.872,-12.88 h -9.231 v 70.621 l 9.231,9.231 z m -12.862,11.658 h -9.232 v 46.101 l 9.232,9.231 z m -10.188,-126.152 c -3.734,0 -6.762,3.027 -6.762,6.762 0,3.734 3.028,6.762 6.762,6.762 3.735,0 6.762,-3.028 6.762,-6.762 0,-3.735 -3.027,-6.762 -6.762,-6.762 z m -8.382,162.915 6.043,6.043 v -55.332 h -6.043 z m 186.571,63.882 h -129.018 c -5.978,0 -11.711,-2.375 -15.938,-6.602 l -46.09,-46.09 c -4.227,-4.227 -6.602,-9.96 -6.602,-15.938 v -161.328 c 0,-7.469 6.055,-13.524 13.524,-13.524 h 184.124 c 7.469,0 13.524,6.055 13.524,13.524 v 216.434 c 0,7.469 -6.055,13.524 -13.524,13.524"];var $={CrapPack:["altcrap-001b.svg","altcrap-001.svg","altcrap-002.svg","altcrap-003.svg","altcrap-004.svg","altcrap-005.svg","altcrap-006.svg","altcrap-007.svg","altcrap-008.svg","altcrap-009.svg","altcrap-010.svg","altcrap-011.svg","altcrap-012.svg","altcrap-013.svg","altcrap-014.svg","altcrap-015.svg","altcrap-016b.svg","altcrap-016.svg","crap-001.svg","crap-002.svg","crap-003.svg","crap-004.svg","crap-005.svg","crap-006.svg","crap-007b.svg","crap-007.svg"],JS2Classic:["001.svg","002.svg","003.svg","004.svg","005.svg","006.svg","007.svg","008.svg","009.svg","010.svg","011.svg","012.svg","013.svg","014.svg","015.svg","016.svg","017.svg","018.svg","019.svg"]},K={};function X(t,e){var n=Object.keys($)[Math.floor(2*Math.random())],r=Object.keys(K).filter(t=>t.includes("/"+n+"/")),s,o,l,u,c,d,f;for(let n=0;n<t;n++){var o;s=r[Math.floor(Math.random()*r.length)],l=h(0,gt),u=h(0,vt),c=a(),d=Math.random(),f=Math.random(),(o=wt.project.importSVG(K[s])).position=new i.Point(l,u),o.scale(h(.2,.6)),c&&o.rotate(c),e.p_opaque&&h(0,100)<e.p_opaque&&(f=1),o.opacity=f,e.p_outlined&&h(0,100)<e.p_outlined&&(o.strokeWidth=pt*Math.floor(h(1,3)),o.strokeColor=d),console.log(o)}}function Y(t,e){var n,r,s,a,o,u,c;for(let a=0;a<t;a++)for(u=0,o=Math.random();u<gt;){for(c=0,n=Math.round(h(50,50*e.variation))*e.w_multiplier*pt;c<vt;){r=Math.pow(2,Math.round(h(1,7)))*h(1,1.5)*pt*e.h_multiplier,s=Math.pow(2,Math.round(h(1,7)))*h(1,1.5)*pt*e.h_multiplier;var d=new i.Path.Rectangle(u,c,n,r);e.p_gradient&&h(0,100)<=e.p_gradient?d.fillColor=l(d):(d.fillColor=1,e.p_rcolor&&h(0,100)<=e.p_rcolor?d.fillColor=Math.random():d.fillColor=1),d.opacity=o,c+=r+s}u+=n}}function Q(t,e){var n,r,s,a,o,u,c,d=[];(a=new i.Path.Rectangle(0,0,gt,vt)).fillColor=Math.random(),a.opacity=Math.random(),d.push(a);for(let f=0;f<t;f++){n=Math.random(),r=Math.random(),c=16;do{s=Math.floor(Math.random()*d.length),c--}while(d[s].bounds.width<32*pt&&d[s].bounds.height<32*pt&&c);o=d[s].bounds.size.clone(),(u=f?o.width>o.height:Math.round(Math.random()))?o.width/=2:o.height/=2,a=new i.Path.Rectangle({point:d[s].bounds.topLeft.floor(),size:o.ceil()}),e.p_gradient&&h(0,100)<=e.p_gradient?a.fillColor=l(a):a.fillColor=n,a.opacity=r,e.p_missing&&h(0,100)<=e.p_missing&&(a.visible=!1),d.push(a),a=new i.Path.Rectangle({point:u?d[s].bounds.topCenter.ceil():d[s].bounds.leftCenter.ceil(),size:o.floor()}),e.p_gradient&&h(0,100)<=e.p_gradient?a.fillColor=l(a):a.fillColor=n,a.opacity=r,e.p_missing&&h(0,100)<=e.p_missing&&(a.visible=!1),d.push(a),d[s].remove(),d.splice(s,1)}}const tt=Math.pow(2,-52);class et{static from(t,e,n){e||(e=ct),n||(n=dt);const i=t.length,r=new Float64Array(2*i);for(let s=0;s<i;s++){const i=t[s];r[2*s]=e(i),r[2*s+1]=n(i)}return new et(r)}constructor(t){let e=1/0,n=1/0,i=-1/0,r=-1/0;const s=t.length>>1,a=this.ids=new Uint32Array(s);if(s>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;for(let o=0;o<s;o++){const s=t[2*o],h=t[2*o+1];s<e&&(e=s),h<n&&(n=h),s>i&&(i=s),h>r&&(r=h),a[o]=o}const o=(e+i)/2,h=(n+r)/2;let l=1/0,u,c,d;for(let e=0;e<s;e++){const n=it(o,h,t[2*e],t[2*e+1]);n<l&&(u=e,l=n)}const f=t[2*u],_=t[2*u+1];l=1/0;for(let e=0;e<s;e++){if(e===u)continue;const n=it(f,_,t[2*e],t[2*e+1]);n<l&&n>0&&(c=e,l=n)}let g=t[2*c],v=t[2*c+1],p=1/0;for(let e=0;e<s;e++){if(e===u||e===c)continue;const n=at(f,_,g,v,t[2*e],t[2*e+1]);n<p&&(d=e,p=n)}let m=t[2*d],y=t[2*d+1];if(p===1/0)throw new Error("No Delaunay triangulation exists for this input.");if(rt(f,_,g,v,m,y)){const t=c,e=g,n=v;c=d,g=m,v=y,d=t,m=e,y=n}const w=ot(f,_,g,v,m,y);this._cx=w.x,this._cy=w.y,ht(a,t,0,a.length-1,w.x,w.y),this._hashSize=Math.ceil(Math.sqrt(s)),this._hash=new Int32Array(this._hashSize).fill(-1);const x=this.hullPrev=new Uint32Array(s),b=this.hullNext=new Uint32Array(s),C=this.hullTri=new Uint32Array(s);this.hullStart=u;let S=3;b[u]=x[d]=c,b[c]=x[u]=d,b[d]=x[c]=u,C[u]=0,C[c]=1,C[d]=2,this._hash[this._hashKey(f,_)]=u,this._hash[this._hashKey(g,v)]=c,this._hash[this._hashKey(m,y)]=d;const M=2*s-5,P=this.triangles=new Uint32Array(3*M),k=this.halfedges=new Int32Array(3*M);this.trianglesLen=0,this._addTriangle(u,c,d,-1,-1,-1);for(let e=0,n,i;e<a.length;e++){const r=a[e],s=t[2*r],o=t[2*r+1];if(e>0&&Math.abs(s-n)<=tt&&Math.abs(o-i)<=tt)continue;if(n=s,i=o,r===u||r===c||r===d)continue;let h=0;for(let t=0,e=this._hashKey(s,o);t<this._hashSize&&(-1===(h=this._hash[(e+t)%this._hashSize])||h===b[h]);t++);let l=h=x[h],f;for(;f=b[l],!rt(s,o,t[2*l],t[2*l+1],t[2*f],t[2*f+1]);)if((l=f)===h){l=-1;break}if(-1===l)continue;let _=this._addTriangle(l,r,b[l],-1,-1,C[l]);C[r]=this._legalize(_+2),C[l]=_,S++;let g=b[l];for(;f=b[g],rt(s,o,t[2*g],t[2*g+1],t[2*f],t[2*f+1]);)_=this._addTriangle(g,r,f,C[r],-1,C[g]),C[r]=this._legalize(_+2),b[g]=g,S--,g=f;if(l===h)for(;rt(s,o,t[2*(f=x[l])],t[2*f+1],t[2*l],t[2*l+1]);)_=this._addTriangle(f,r,l,-1,C[l],C[f]),this._legalize(_+2),C[f]=_,b[l]=l,S--,l=f;this.hullStart=x[r]=l,b[l]=x[g]=r,b[r]=g,this._hash[this._hashKey(s,o)]=r,this._hash[this._hashKey(t[2*l],t[2*l+1])]=l}this.hull=new Uint32Array(S);for(let t=0,e=this.hullStart;t<S;t++)this.hull[t]=e,e=b[e];this.hullPrev=this.hullNext=this.hullTri=null,this.triangles=P.subarray(0,this.trianglesLen),this.halfedges=k.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(nt(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{triangles:e,coords:n,halfedges:i}=this,r=i[t],s=t-t%3,a=r-r%3,o=s+(t+1)%3,h=s+(t+2)%3,l=a+(r+2)%3;if(-1===r)return h;const u=e[h],c=e[t],d=e[o],f=e[l],_=st(n[2*u],n[2*u+1],n[2*c],n[2*c+1],n[2*d],n[2*d+1],n[2*f],n[2*f+1]);if(_){e[t]=f,e[r]=u;const n=i[l];if(-1===n){let e=this.hullStart;do{if(this.hullTri[e]===l){this.hullTri[e]=t;break}e=this.hullNext[e]}while(e!==this.hullStart)}this._link(t,n),this._link(r,i[h]),this._link(h,l);const s=a+(r+1)%3;return this._legalize(t),this._legalize(s)}return h}_link(t,e){this.halfedges[t]=e,-1!==e&&(this.halfedges[e]=t)}_addTriangle(t,e,n,i,r,s){const a=this.trianglesLen;return this.triangles[a]=t,this.triangles[a+1]=e,this.triangles[a+2]=n,this._link(a,i),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function nt(t,e){const n=t/(Math.abs(t)+Math.abs(e));return(e>0?3-n:1+n)/4}function it(t,e,n,i){const r=t-n,s=e-i;return r*r+s*s}function rt(t,e,n,i,r,s){return(i-e)*(r-n)-(n-t)*(s-i)<0}function st(t,e,n,i,r,s,a,o){const h=t-a,l=e-o,u=n-a,c=i-o,d=r-a,f=s-o,_=h*h+l*l,g=u*u+c*c,v=d*d+f*f;return h*(c*v-g*f)-l*(u*v-g*d)+_*(u*f-c*d)<0}function at(t,e,n,i,r,s){const a=n-t,o=i-e,h=r-t,l=s-e,u=a*a+o*o,c=h*h+l*l,d=a*l-o*h,f=.5*(l*u-o*c)/d,_=.5*(a*c-h*u)/d;return u&&c&&d&&f*f+_*_||1/0}function ot(t,e,n,i,r,s){const a=n-t,o=i-e,h=r-t,l=s-e,u=a*a+o*o,c=h*h+l*l,d=a*l-o*h,f=t+.5*(l*u-o*c)/d,_=e+.5*(a*c-h*u)/d;return{x:f,y:_}}function ht(t,e,n,i,r,s){let a,o,h;if(i-n<=20)for(a=n+1;a<=i;a++){for(h=t[a],o=a-1;o>=n&<(e,t[o],h,r,s)>0;)t[o+1]=t[o--];t[o+1]=h}else{const l=n+i>>1;for(o=i,ut(t,l,a=n+1),lt(e,t[n],t[i],r,s)>0&&ut(t,n,i),lt(e,t[a],t[i],r,s)>0&&ut(t,a,i),lt(e,t[n],t[a],r,s)>0&&ut(t,n,a),h=t[a];;){do{a++}while(lt(e,t[a],h,r,s)<0);do{o--}while(lt(e,t[o],h,r,s)>0);if(o<a)break;ut(t,a,o)}t[n+1]=t[o],t[o]=h,i-a+1>=o-n?(ht(t,e,a,i,r,s),ht(t,e,n,o-1,r,s)):(ht(t,e,n,o-1,r,s),ht(t,e,a,i,r,s))}}function lt(t,e,n,i,r){const s=it(t[2*e],t[2*e+1],i,r),a=it(t[2*n],t[2*n+1],i,r);return s-a||t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]}function ut(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function ct(t){return t[0]}function dt(t){return t[1]}function ft(t,e){var n=[],r,s,a;for(let e=0;e<t;e++)n.push([Math.round(h(0,gt)),Math.round(h(0,vt))]);n.push([0,0],[0,vt],[gt,vt],[gt,0]);var o=Math.round(Math.pow(t,.5))-1;o<1&&(o=1);for(let t=0;t<o;t++)n.push([0,Math.round(h(0,vt))]),n.push([gt,Math.round(h(0,vt))]),n.push([Math.round(h(0,gt)),0]),n.push([Math.round(h(0,vt)),0]);e.p_outlined&&(a=pt*Math.floor(h(1,3)));const u=et.from(n);var c=u.triangles;s=Math.random();for(let t=0;t<c.length;t+=3)(!e.p_missing||e.p_missing&&h(0,100)>e.p_missing)&&(r=new i.Path({segments:[n[c[t]],n[c[t+1]],n[c[t+2]],n[c[t+2]]],closed:!0,opacity:Math.random()}),e.p_outlined&&h(0,100)<e.p_outlined?(r.strokeWidth=a,r.strokeColor=s):e.p_gradient&&h(0,100)<=e.p_gradient?r.fillColor=l(r):r.fillColor=s)}function _t(t,e){var n,r=0,s=0,a,o,l,u;for(let c=0;c<t;c++)for(r=0,s=0,n=Math.round(h(40,200)*pt),o=h(.2,1),l=Math.random(),e.p_outlined&&(u=pt*Math.floor(h(1,3)));s<vt;){for(;r<gt;){switch(Math.floor(h(0,4))){case 0:break;case 1:a=new i.Path.Rectangle(r,s,n,n),e.p_outlined&&h(0,100)<e.p_outlined?(a.strokeWidth=u,a.strokeColor=o):a.fillColor=o,a.opacity=l;break;case 2:a=new i.Path({segments:[[r,s],[r+n,s],[r,s+n]],closed:!0,opacity:l}),e.p_outlined&&h(0,100)<e.p_outlined?(a.strokeWidth=u,a.strokeColor=o):a.fillColor=o;break;case 3:a=new i.Path({segments:[[r,s+n],[r+n,s+n],[r+n,s]],closed:!0,opacity:l}),e.p_outlined&&h(0,100)<e.p_outlined?(a.strokeWidth=u,a.strokeColor=o):a.fillColor=o}r+=n}s+=n,r=0}}n.d(e,"W",function(){return gt}),n.d(e,"H",function(){return vt}),n.d(e,"M",function(){return pt}),n.d(e,"MH",function(){return mt}),n.d(e,"V",function(){return yt}),n.d(e,"main_s",function(){return wt}),n.d(e,"light_s",function(){return xt}),n.d(e,"templates",function(){return bt}),n.d(e,"recipes",function(){return Ct}),n.d(e,"json_export",function(){return Mt}),n.d(e,"json_import_url",function(){return Pt}),n.d(e,"json_import",function(){return kt}),n.d(e,"json_import_file",function(){return zt}),n.d(e,"gen",function(){return Tt});var gt,vt,pt=1,mt=1,yt=1,wt,xt,bt={},Ct=[];const St={panels:V,triangular:F,patterns:H,square:D,svgs:X,dots:j,circles:B,hexagons:R,rectangles:G,plates:W,stack:Y,divisions:Q,polygons:ft,houndstooth:_t};function Mt(t){var e=Date.now()+".json",n=JSON.stringify({version:yt,data:null!=t?[Ct[t]]:Ct});if(n){var i=new Blob([n],{type:"application/json"});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(i,e);else{var r=document.createElement("a"),s=URL.createObjectURL(i);r.href=s,r.download=e,document.body.appendChild(r),r.click(),setTimeout(function(){document.body.removeChild(r),window.URL.revokeObjectURL(s)},0)}}}function Pt(t){var e=new XMLHttpRequest;e.open("GET","./t/"+t,!0),e.responseType="json",e.onload=function(){var t;It(e.response,1),f(1,1),document.getElementById("settings").innerHTML=""},e.send()}function kt(){var t={},e=document.getElementById("json_form").elements.json_data,n;if(e&&e.value){try{t=JSON.parse(e.value)}catch(t){return void P("Incorrect import data")}var i;It(t),f(1,1),document.getElementById("settings").innerHTML=""}}function It(t,e){if(t&&(t.version<yt&&P("Trying to import from the older version! Please re-export to avoid this message in future."),t=t.data))for(var n in e&&(Ct=[]),t){var i={};for(var r in i.type=t[n].type,i.opts={},i.number=t[n].number,bt[t[n].type].options)r in t[n].opts?i.opts[r]=t[n].opts[r]:i.opts[r]=bt[t[n].type].options[r].d;Ct.push(i)}}function zt(t){var e=[];for(let n of t.target.files)e.push(n);Promise.all(e.map(function(t){return new Promise((e,n)=>{var i=new FileReader;i.onload=function(t){try{It(JSON.parse(t.target.result))}catch(t){}e(!0)},i.readAsText(t)})})).then(function(){var t;f(1,1),document.getElementById("settings").innerHTML=""},function(t){console.log("failed")})}function Tt(){gt=1024*pt,vt=1024*pt*mt;var t=document.getElementById("main"),e;t.width=gt,t.height=vt,(wt=new i.PaperScope).setup(t),(e=new i.Path.Rectangle(0,0,gt,vt)).fillColor=new i.Color(0);var n=document.getElementById("light"),e;n.width=gt,n.height=vt,(xt=new i.PaperScope).setup(n),(e=new i.Path.Rectangle(0,0,gt,vt)).fillColor=new i.Color(0),wt.activate();for(let t of Ct)St[t.type](t.number,t.opts);wt.view.draw(),xt.view.draw();var r=document.getElementById("loader");r.style.display="none",(r=document.getElementById("fire-button")).style.visibility="visible"}function Ot(t){var e=Number(document.getElementById("global_settings").elements["M"==t?"multiplier":"vertical_multiplier"].value);"M"==t?pt=e:mt=e}function At(t){return new Promise(function(e,n){var i=new XMLHttpRequest;i.open("GET","./svgs/"+t),i.onload=e,i.onerror=n,i.send()})}function Lt(){for(var t="recipe=",e,n=decodeURIComponent(document.cookie).split(";"),i=0;i<n.length;i++){for(var r=n[i];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return""}window.onload=function(){var t;document.getElementById("fire-button").addEventListener("click",k),document.getElementById("multiplier").addEventListener("change",function(){Ot("M")}),document.getElementById("vertical_multiplier").addEventListener("change",function(){Ot("MH")}),document.getElementById("hide-button").addEventListener("click",I),document.getElementById("commit").innerHTML="build: "+r;var e=new XMLHttpRequest;e.open("GET","t.json",!0),e.responseType="json",e.onload=function(){var t=e.response;"templates"in t&&(bt=t.templates);var n=Lt(),i=1;if(n){var s=JSON.parse(n);s.commit==r&&(i=0,Ct=s.recipes)}i&&"recipes"in t&&(Ct=t.recipes);var a=[];Object.keys($).map(function(t){$[t].map(function(e){a.push(t+"/"+e)})}),Promise.all(a.map(At)).then(function(t){t.map(function(t){K[t.target.responseURL]=t.target.response}),f(1)})},e.send()}}]);