paper.js/dist/paper-core.min.js

38 lines
193 KiB
JavaScript
Raw Normal View History

2016-07-09 15:04:37 -04:00
/*!
* Paper.js v0.10.2 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
* http://scratchdisk.com/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*
* Date: Sat Jul 9 20:56:58 2016 +0200
*
***
*
* Straps.js - Class inheritance library with support for bean-style accessors
*
* Copyright (c) 2006 - 2016 Juerg Lehni
* http://scratchdisk.com/
*
* Distributed under the MIT license.
*
***
*
* Acorn.js
* http://marijnhaverbeke.nl/acorn/
*
* Acorn is a tiny, fast JavaScript parser written in JavaScript,
* created by Marijn Haverbeke and released under an MIT license.
*
*/
var paper=function(t,e){var i=t?t.window:require("./node/window"),n=i&&i.document;t=t||i;var r=new function(){function t(t,e,i,n,a){function o(s,o){o=o||(o=u(e,s))&&(o.get?o:o.value),"string"==typeof o&&"#"===o[0]&&(o=t[o.substring(1)]||o);var l,d="function"==typeof o,f=o,_=a||d&&!o.base?o&&o.get?s in t:t[s]:null;a&&_||(d&&_&&(o.base=_),d&&n!==!1&&(l=s.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(h[l[3].toLowerCase()+l[4]]=l[2]),f&&!d&&f.get&&"function"==typeof f.get&&r.isPlainObject(f)||(f={value:f,writable:!0}),(u(t,s)||{configurable:!0}).configurable&&(f.configurable=!0,f.enumerable=i),c(t,s,f))}var h={};if(e){for(var l in e)e.hasOwnProperty(l)&&!s.test(l)&&o(l);for(var l in h){var d=h[l],f=t["set"+d],_=t["get"+d]||f&&t["is"+d];!_||n!==!0&&0!==_.length||o(l,{get:_,set:f})}}return t}function i(t,e,i){return t&&("length"in t&&!t.getLength&&"number"==typeof t.length?a:o).call(t,e,i=i||t),i}function n(t,e,i){for(var n=i,r=e.length;n<r;n++){var s=e[n];for(var a in s)s.hasOwnProperty(a)&&(t[a]=s[a])}return t}var s=/^(statics|enumerable|beans|preserve)$/,a=[].forEach||function(t,e){for(var i=0,n=this.length;i<n;i++)t.call(e,this[i],i,this)},o=function(t,e){for(var i in this)this.hasOwnProperty(i)&&t.call(e,this[i],i,this)},h=Object.create||function(t){return{__proto__:t}},u=Object.getOwnPropertyDescriptor||function(t,e){var i=t.__lookupGetter__&&t.__lookupGetter__(e);return i?{get:i,set:t.__lookupSetter__(e),enumerable:!0,configurable:!0}:t.hasOwnProperty(e)?{value:t[e],enumerable:!0,configurable:!0,writable:!0}:null},l=Object.defineProperty||function(t,e,i){return(i.get||i.set)&&t.__defineGetter__?(i.get&&t.__defineGetter__(e,i.get),i.set&&t.__defineSetter__(e,i.set)):t[e]=i.value,t},c=function(t,e,i){return delete t[e],l(t,e,i)};return t(function(){n(this,arguments,0)},{inject:function(e){if(e){var i=e.statics===!0?e:e.statics,n=e.beans,r=e.preserve;i!==e&&t(this.prototype,e,e.enumerable,n,r),t(this,i,!0,n,r)}for(var s=1,a=arguments.length;s<a;s++)this.inject(arguments[s]);return this},extend:function(){for(var e,i,n,r=this,s=0,a=arguments.length;s<a&&(!e||!i);s++)n=arguments[s],e=e||n.initialize,i=i||n.prototype;return e=e||function(){r.apply(this,arguments)},i=e.prototype=i||h(this.prototype),c(i,"constructor",{value:e,writable:!0,configurable:!0}),t(e,this,!0),arguments.length&&this.inject.apply(e,arguments),e.base=r,e}},!0).inject({inject:function(){for(var e=0,i=arguments.length;e<i;e++){var n=arguments[e];n&&t(this,n,n.enumerable,n.beans,n.preserve)}return this},extend:function(){var t=h(this);return t.inject.apply(t,arguments)},each:function(t,e){return i(this,t,e)},set:function(){return n(this,arguments,0)},clone:function(){return new this.constructor(this)},statics:{each:i,create:h,define:c,describe:u,set:function(t){return n(t,arguments,1)},clone:function(t){return n(new t.constructor,arguments,0)},isPlainObject:function(t){var e=null!=t&&t.constructor;return e&&(e===Object||e===r||"Object"===e.name)},pick:function(t,i){return t!==e?t:i}}})};"undefined"!=typeof module&&(module.exports=r),r.inject({toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+r.each(this,function(t,e){if(!/^_/.test(e)){var i=typeof t;this.push(e+": "+("number"===i?h.instance.number(t):"string"===i?"'"+t+"'":t))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(t){return r.importJSON(t,this)},exportJSON:function(t){return r.exportJSON(this,t)},toJSON:function(){return r.serialize(this)},_set:function(t){if(t&&r.isPlainObject(t))return r.filter(this,t)},statics:{exports:{enumerable:!0},extend:function nt(){var t=nt.base.apply(this,arguments),e=t.prototype._class;return e&&!r.exports[e]&&(r.exports[e]=t),t},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 i=t.length;if(i!==e.length)return!1;for(;i--;)if(!r.equals(t[i],e[i]))return!1}else{var n=Object.keys(t),i=n.length;if(i!==Object.keys(e).lengt
this._ty+=e*this._b+i*this._d,this._changed(),this},scale:function(){var t=c.read(arguments),e=c.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=c.read(arguments,1),i=e.x,n=e.y,r=Math.cos(t),s=Math.sin(t),a=i-i*r+n*s,o=n-i*s-n*r,h=this._a,u=this._b,l=this._c,d=this._d;return this._a=r*h+s*l,this._b=r*u+s*d,this._c=-s*h+r*l,this._d=-s*u+r*d,this._tx+=a*h+o*l,this._ty+=a*u+o*d,this._changed(),this},shear:function(){var t=c.read(arguments),e=c.read(arguments,0,{readNull:!0});e&&this.translate(e);var i=this._a,n=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*i,this._d+=t.x*n,e&&this.translate(e.negate()),this._changed(),this},skew:function(){var t=c.read(arguments),e=c.read(arguments,0,{readNull:!0}),i=Math.PI/180,n=new c(Math.tan(t.x*i),Math.tan(t.y*i));return this.shear(n,e)},append:function(t){if(t){var e=this._a,i=this._b,n=this._c,r=this._d,s=t._a,a=t._c,o=t._b,h=t._d,u=t._tx,l=t._ty;this._a=s*e+o*n,this._c=a*e+h*n,this._b=s*i+o*r,this._d=a*i+h*r,this._tx+=u*e+l*n,this._ty+=u*i+l*r,this._changed()}return this},prepend:function(t){if(t){var e=this._a,i=this._b,n=this._c,r=this._d,s=this._tx,a=this._ty,o=t._a,h=t._c,u=t._b,l=t._d,c=t._tx,d=t._ty;this._a=o*e+h*i,this._c=o*n+h*r,this._b=u*e+l*i,this._d=u*n+l*r,this._tx=o*s+h*a+c,this._ty=u*s+l*a+d,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,i=this._c,n=this._d,r=this._tx,s=this._ty,a=t*n-e*i,o=null;return a&&!isNaN(a)&&isFinite(r)&&isFinite(s)&&(this._a=n/a,this._b=-e/a,this._c=-i/a,this._d=t/a,this._tx=(i*s-n*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 p(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,i){return arguments.length<3?this._transformPoint(c.read(arguments)):this._transformCoordinates(t,e,i)},_transformPoint:function(t,e,i){var n=t.x,r=t.y;return e||(e=new c),e.set(n*this._a+r*this._c+this._tx,n*this._b+r*this._d+this._ty,i)},_transformCoordinates:function(t,e,i){for(var n=0,r=2*i;n<r;n+=2){var s=t[n],a=t[n+1];e[n]=s*this._a+a*this._c+this._tx,e[n+1]=s*this._b+a*this._d+this._ty}return e},_transformCorners:function(t){var e=t.x,i=t.y,n=e+t.width,r=i+t.height,s=[e,i,n,i,n,r,e,r];return this._transformCoordinates(s,s,4)},_transformBounds:function(t,e,i){for(var n=this._transformCorners(t),r=n.slice(0,2),s=r.slice(),a=2;a<8;a++){var o=n[a],h=1&a;o<r[h]?r[h]=o:o>s[h]&&(s[h]=o)}return e||(e=new g),e.set(r[0],r[1],s[0]-r[0],s[1]-r[1],i)},inverseTransform:function(){return this._inverseTransform(c.read(arguments))},_inverseTransform:function(t,e,i){var n=this._a,r=this._b,s=this._c,a=this._d,o=this._tx,h=this._ty,u=n*a-r*s,l=null;if(u&&!isNaN(u)&&isFinite(o)&&isFinite(h)){var d=t.x-this._tx,f=t.y-this._ty;e||(e=new c),l=e.set((d*a-f*s)/u,(f*n-d*r)/u,i)}return l},decompose:function(){var t,e,i,n=this._a,r=this._b,s=this._c,a=this._d,o=n*a-r*s,h=Math.sqrt,u=Math.atan2,l=180/Math.PI;if(0!==n||0!==r){var d=h(n*n+r*r);t=Math.acos(n/d)*(r>0?1:-1),e=[d,o/d],i=[u(n*s+r*a,d*d),0]}else if(0!==s||0!==a){var f=h(s*s+a*a);t=Math.asin(s/f)*(a>0?1:-1),e=[o/f,f],i=[0,u(n*s+r*a,f*f)]}else t=0,i=e=[0,0];return{translation:this.getTranslation(),rotation:t*l,scaling:new c(e),skewing:new c(i[0]*l,i[1]*l)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new c(this._tx,this._ty)},getScaling:function(){return(this.decompose()||{
(a||o||h)&&this._isUpdated(r)){var u,l=this.getSelectedColor(!0)||(u=this.getLayer())&&u.getSelectedColor(!0),c=e.appended(this.getGlobalMatrix(!0)),d=i/2;if(t.strokeStyle=t.fillStyle=l?l.toCanvasStyle(t):"#009dec",a&&this._drawSelected(t,c,n),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=i+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[0===y?"moveTo":"lineTo"](C[y],C[++y]);t.closePath(),t.stroke();for(var y=0;y<8;y++)t.fillRect(C[y]-d,C[++y]-d,i,i)}}},_canComposite:function(){return!1}},r.each(["down","drag","up","move"],function(t){this["removeOn"+r.capitalize(t)]=function(){var e={};return e[t]=!0,this.removeOn(e)}},{removeOn:function(t){for(var e in t)if(t[e]){var i="mouse"+e,n=this._project,r=n._removeSets=n._removeSets||{};r[i]=r[i]||{},r[i][this._id]=this}return this}})),x=w.extend({_class:"Group",_selectBounds:!1,_selectChildren:!0,_serializeFields:{children:[]},initialize:function(t){this._children=[],this._namedChildren={},this._initialize(t)||this.addChildren(Array.isArray(t)?t:arguments)},_changed:function ct(t){ct.base.call(this,t),1026&t&&(this._clipItem=e)},_getClipItem:function(){var t=this._clipItem;if(t===e){t=null;for(var i=this._children,n=0,r=i.length;n<r;n++)if(i[n]._clipMask){t=i[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 dt(t,e){var i=this._getClipItem();return i?i._getCachedBounds(t&&t.appended(i._matrix),r.set({},e,{stroke:!1})):dt.base.call(this,t,e)},_hitTestChildren:function ft(t,e,i){var n=this._getClipItem();return(!n||n.contains(t))&&ft.base.call(this,t,e,i,n)},_draw:function(t,e){var i=e.clip,n=!i&&this._getClipItem();e=e.extend({clipItem:n,clip:!1}),i?(t.beginPath(),e.dontStart=e.dontFinish=!0):n&&n.draw(t,e.extend({clip:!0}));for(var r=this._children,s=0,a=r.length;s<a;s++){var o=r[s];o!==n&&o.draw(t,e)}}}),b=x.extend({_class:"Layer",initialize:function(){x.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(){}}),C=w.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_canScaleStroke:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function(t){this._initialize(t)},_equals:function(t){return this._type===t._type&&this._size.equals(t._size)&&r.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 _(t.width,t.height,this,"setSize")},setSize:function(){var t=f.read(arguments);if(this._size){if(!this._size.equals(t)){var e=this._type,i=t.width,n=t.height;if("rectangle"===e){var r=f.min(this._radius,t.divide(2));this._radius.set(r.width,r.height)}else"circle"===e?(i=n=(i+n)/2,this._radius=i/2):"ellipse"===e&&this._radius.set(i/2,n/2);this._size.set(i,n),this._changed(9)}}else this._size=t.clone()},getRadius:function(){var t=this._radius;return"circle"===this._type?t:new _(t.width,t.height,this,"setRadius")},setRadius:function(t){var e=this._type;if("circle"===e){if(t===this._radius)return;var i=2*t;this._radius=t,this._size.set(i,i)}else if(t=f.read(arguments),this._radius){if(this._radius.equals(t))return;if(this._radius.set(t.width,t.height),"rectangle"===e){var i=f.max(this._size,t.multiply(2));this._size.set(i.width,i.height)}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 i=new(L[r.capitalize(this._type)])({center:new c,size:this._size,radius:this._radius,insert:!1});r
var v=g(r,h);r=v[0],h=v[1]}var p=new O(n,r,s||z.getPoint(i,r),l),m=new O(o,h,u||z.getPoint(a,h),l),y=p.getPath()===m.getPath()&&p.getIndex()>m.getIndex(),w=y?m:p,x=e.include;p._intersection=m,m._intersection=p,x&&!x(w)||O.insert(t,w,!0)}}function e(r,s,a,o,h,u,l,c,d,f,_,g,v){if(++g>=48||++v>4096)return v;var p,y,w=s[0],x=s[1],b=s[6],C=s[7],S=m.getSignedDistance,P=S(w,x,b,C,s[2],s[3]),I=S(w,x,b,C,s[4],s[5]),M=P*I>0?.75:4/9,T=M*Math.min(0,P,I),k=M*Math.max(0,P,I),O=S(w,x,b,C,r[0],r[1]),A=S(w,x,b,C,r[2],r[3]),L=S(w,x,b,C,r[4],r[5]),N=S(w,x,b,C,r[6],r[7]),B=i(O,A,L,N),E=B[0],D=B[1];if(0===P&&0===I&&0===O&&0===A&&0===L&&0===N||null==(p=n(E,D,T,k))||null==(y=n(E.reverse(),D.reverse(),T,k)))return v;var j=l+(c-l)*p,F=l+(c-l)*y;if(Math.max(f-d,F-j)<1e-9){var R=(j+F)/2,q=(d+f)/2;r=a.getValues(),s=o.getValues(),t(h,u,_?s:r,_?o:a,_?q:R,null,_?r:s,_?a:o,_?R:q,null)}else if(r=z.getPart(r,p,y),y-p>.8)if(F-j>f-d){var V=z.subdivide(r,.5),R=(j+F)/2;v=e(s,V[0],o,a,h,u,d,f,j,R,!_,g,v),v=e(s,V[1],o,a,h,u,d,f,R,F,!_,g,v)}else{var V=z.subdivide(s,.5),q=(d+f)/2;v=e(V[0],r,o,a,h,u,d,q,j,F,!_,g,v),v=e(V[1],r,o,a,h,u,q,f,j,F,!_,g,v)}else v=e(s,r,o,a,h,u,d,f,j,F,!_,g,v);return v}function i(t,e,i,n){var r,s=[0,t],a=[1/3,e],o=[2/3,i],h=[1,n],u=e-(2*t+n)/3,l=i-(t+2*n)/3;if(u*l<0)r=[[s,a,h],[s,o,h]];else{var c=u/l;r=[c>=2?[s,a,h]:c<=.5?[s,o,h]:[s,a,o,h],[s,h]]}return(u||l)<0?r.reverse():r}function n(t,e,i,n){return t[0][1]<i?r(t,!0,i):e[0][1]>n?r(e,!1,n):t[0][0]}function r(t,e,i){for(var n=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>=i:h<=i)return h===i?o:n+(i-r)*(o-n)/(h-r);n=o,r=h}return null}function s(e,i,n,r,s,a){for(var o=z.isStraight(e),h=o?i:e,l=o?e:i,c=l[0],d=l[1],f=l[6],_=l[7],g=f-c,v=_-d,p=Math.atan2(-v,g),m=Math.sin(p),y=Math.cos(p),w=[],x=0;x<8;x+=2){var b=h[x]-c,C=h[x+1]-d;w.push(b*y-C*m,b*m+C*y)}for(var S=[],P=z.solveCubic(w,1,0,S,0,1),x=0;x<P;x++){var I=S[x],M=z.getPoint(h,I),T=z.getTimeOf(l,M);if(null!==T){var k=z.getPoint(l,T),O=o?T:I,A=o?I:T;(!a.excludeEnd||A>u.CURVETIME_EPSILON)&&t(s,a,e,n,O,o?k:M,i,r,A,o?M:k)}}}function a(e,i,n,r,s,a){var o=m.intersect(e[0],e[1],e[6],e[7],i[0],i[1],i[6],i[7]);o&&t(s,a,e,n,null,o,i,r,null,o)}return{statics:{_getIntersections:function(i,n,r,o,h,u){if(!n)return z._getSelfIntersection(i,r,h,u);var l=2e-7,d=i[0],f=i[1],_=i[6],g=i[7],v=n[0],p=n[1],m=n[6],y=n[7],w=(3*i[2]+d)/4,x=(3*i[3]+f)/4,b=(3*i[4]+_)/4,C=(3*i[5]+g)/4,S=(3*n[2]+v)/4,P=(3*n[3]+p)/4,I=(3*n[4]+m)/4,M=(3*n[5]+y)/4,T=Math.min,k=Math.max;if(!(k(d,w,b,_)+l>T(v,S,I,m)&&T(d,w,b,_)-l<k(v,S,I,m)&&k(f,x,C,g)+l>T(p,P,M,y)&&T(f,x,C,g)-l<k(p,P,M,y)))return h;var O=z.getOverlaps(i,n);if(O){for(var A=0;A<2;A++){var L=O[A];t(h,u,i,r,L[0],null,n,o,L[1],null,!0)}return h}var N=z.isStraight(i),B=z.isStraight(n),E=N&&B,D=h.length;if((E?a:N||B?s:e)(i,n,r,o,h,u,0,1,0,1,0,0,0),E&&h.length>D)return h;var j=new c(d,f),F=new c(_,g),R=new c(v,p),q=new c(m,y);return j.isClose(R,l)&&t(h,u,i,r,0,j,n,o,0,R),!u.excludeStart&&j.isClose(q,l)&&t(h,u,i,r,0,j,n,o,1,q),!u.excludeEnd&&F.isClose(R,l)&&t(h,u,i,r,1,F,n,o,0,R),F.isClose(q,l)&&t(h,u,i,r,1,F,n,o,1,q),h},_getSelfIntersection:function(t,e,i,n){var r=t[0],s=t[1],a=t[2],o=t[3],h=t[4],l=t[5],d=t[6],f=t[7],_=new m(r,s,d,f,(!1)),g=_.getSide(new c(a,o),!0),v=_.getSide(new c(h,l),!0);if(g===v){var p=(r-h)*(o-f)+(a-d)*(l-s);if(p*g>0)return i}var y=d-3*h+3*a-r,w=h-2*a+r,x=a-r,b=f-3*l+3*o-s,C=l-2*o+s,S=o-s,P=b*x-y*S,I=b*w-y*C,M=C*x-w*S;if(P*P-4*I*M<0){var T,k=[],O=u.solveCubic(y*y+b*b,3*(y*w+b*C),2*(w*w+C*C)+y*x+b*S,w*x+C*S,k,0,1);if(O>0){for(var A=0,L=0;A<O;A++){var N=Math.abs(e.getCurvatureAtTime(k[A]));N>L&&(L=N,T=k[A])}var B=z.subdivide(t,T);n.excludeEnd=!0,n.renormalize=function(t,e){return[t*T,e*(1-T)+T]},z._getIntersections(B[0],B[1],e,e,i,n)}}return i},getOverlaps:function(t,e){function i(t){var e=t[6]-t[0],i=t[7]-t[1];return e*e+i*i}var n=Math.abs,r=4e-7,s=2e-7,a=z.isStraight(t),o=z.isStraight(e),h=a&&o,u=i(t)<i(e),l=u?e:t,d=u?t:e,f=new m(l[0],l[1],l[6],l[7]);if(f.getDistance(new c(d[0],d[1]))<s&&f.getDistance(new c(d[6],d[7]))<s)!h&&f.getDistance(new c(l[2],l[3]))<s&&f.getDistance(new c
var i=new c(t,0).transform(e),n=new c(0,t).transform(e),r=i.getAngleInRadians(),s=i.getLength(),a=n.getLength(),o=Math.sin(r),h=Math.cos(r),u=Math.tan(r),l=Math.atan2(a*u,s),d=Math.atan2(a,u*s);return[Math.abs(s*Math.cos(l)*h+a*Math.sin(l)*o),Math.abs(a*Math.sin(d)*h+s*Math.cos(d)*o)]},_addBevelJoin:function(t,e,i,n,r,s,a,o){var h=t.getCurve(),u=h.getPrevious(),l=h.getPointAtTime(0),d=u.getNormalAtTime(1),f=h.getNormalAtTime(0),_=d.getDirectedAngle(f)<0?-i:i;if(d.setLength(_),f.setLength(_),r&&r._transformPoint(l,l),s&&(s._transformPoint(d,d),s._transformPoint(f,f)),o&&(a(l),a(l.add(d))),"miter"===e){var g=new m(l.add(d),new c((-d.y),d.x),(!0)).intersect(new m(l.add(f),new c((-f.y),f.x),(!0)),!0);if(g&&l.getDistance(g)<=n&&(a(g),!o))return}o||a(l.add(d)),a(l.add(f))},_addSquareCap:function(t,e,i,n,r,s,a){var o=t._point,h=t.getLocation(),u=h.getNormal().multiply(i);n&&n._transformPoint(o,o),r&&r._transformPoint(u,u),a&&(s(o.subtract(u)),s(o.add(u))),"square"===e&&(o=o.add(u.rotate(0===h.getTime()?-90:90))),s(o.add(u)),s(o.subtract(u))},getHandleBounds:function(t,e,i,n,r){var s,a,o=i.getStyle(),h=r.stroke&&o.hasStroke();if(h){var u=i._getStrokeMatrix(n,r),l=o.getStrokeWidth()/2,c=l;"miter"===o.getStrokeJoin()&&(c=l*o.getMiterLimit()),"square"===o.getStrokeCap()&&(c=Math.max(c,l*Math.sqrt(2))),s=L._getStrokePadding(l,u),a=L._getStrokePadding(c,u)}for(var d=new Array(6),f=1/0,_=-f,v=f,p=_,m=0,y=t.length;m<y;m++){var w=t[m];w._transformCoordinates(n,d);for(var x=0;x<6;x+=2){var b=0===x?a:s,C=b?b[0]:0,S=b?b[1]:0,P=d[x],I=d[x+1],M=P-C,T=P+C,k=I-S,z=I+S;M<f&&(f=M),T>_&&(_=T),k<v&&(v=k),z>p&&(p=z)}}return new g(f,v,_-f,p-v)}}});L.inject({statics:new function(){function t(t,e,i){var n=r.getNamed(i),s=new L(n&&n.insert===!1&&w.NO_INSERT);return s._add(t),s._closed=e,s.set(n)}function e(e,i,r){for(var s=new Array(4),a=0;a<4;a++){var o=n[a];s[a]=new T(o._point.multiply(i).add(e),o._handleIn.multiply(i),o._handleOut.multiply(i))}return t(s,!0,r)}var i=.5522847498307936,n=[new T([-1,0],[0,i],[0,-i]),new T([0,-1],[-i,0],[i,0]),new T([1,0],[0,-i],[0,i]),new T([0,1],[i,0],[-i,0])];return{Line:function(){return t([new T(c.readNamed(arguments,"from")),new T(c.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var t=c.readNamed(arguments,"center"),i=r.readNamed(arguments,"radius");return e(t,new f(i),arguments)},Rectangle:function(){var e,n=g.readNamed(arguments,"rectangle"),r=f.readNamed(arguments,"radius",0,{readNull:!0}),s=n.getBottomLeft(!0),a=n.getTopLeft(!0),o=n.getTopRight(!0),h=n.getBottomRight(!0);if(!r||r.isZero())e=[new T(s),new T(a),new T(o),new T(h)];else{r=f.min(r,n.getSize(!0).divide(2));var u=r.width,l=r.height,c=u*i,d=l*i;e=[new T(s.add(u,0),null,[-c,0]),new T(s.subtract(0,l),[0,d]),new T(a.add(0,l),null,[0,-d]),new T(a.add(u,0),[-c,0],null),new T(o.subtract(u,0),null,[c,0]),new T(o.add(0,l),[0,-d],null),new T(h.subtract(0,l),null,[0,d]),new T(h.subtract(u,0),[c,0])]}return t(e,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=C._readEllipse(arguments);return e(t.center,t.radius,arguments)},Oval:"#Ellipse",Arc:function(){var t=c.readNamed(arguments,"from"),e=c.readNamed(arguments,"through"),i=c.readNamed(arguments,"to"),n=r.getNamed(arguments),s=new L(n&&n.insert===!1&&w.NO_INSERT);return s.moveTo(t),s.arcTo(e,i),s.set(n)},RegularPolygon:function(){for(var e=c.readNamed(arguments,"center"),i=r.readNamed(arguments,"sides"),n=r.readNamed(arguments,"radius"),s=360/i,a=i%3===0,o=new c(0,a?-n:n),h=a?-1:.5,u=new Array(i),l=0;l<i;l++)u[l]=new T(e.add(o.rotate((l+h)*s)));return t(u,!0,arguments)},Star:function(){for(var e=c.readNamed(arguments,"center"),i=2*r.readNamed(arguments,"points"),n=r.readNamed(arguments,"radius1"),s=r.readNamed(arguments,"radius2"),a=360/i,o=new c(0,(-1)),h=new Array(i),u=0;u<i;u++)h[u]=new T(e.add(o.rotate(a*u).multiply(u%2?s:n)));return t(h,!0,arguments)}}}});var N=A.extend({_class:"CompoundPath",_serializeFields:{children:[]},initialize:function(t){this._children=[],this._namedChildren={},this._initialize(t)||("string"==typeof t?this.setPathData(t):this.addChildren(Array.isAr
this[n]=r&&e&&r.clone?r.clone():r}},equals:function(t){return t===this||t&&this._class===t._class&&r.equals(this._values,t._values)||!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 wt(){var t=wt.base.call(this),e=this.getFontSize();return/pt|em|%|px/.test(e)&&(e=this.getView().getPixelSize(e)),null!=t?t:1.2*e}}),H=new function(){function t(t,e,i,n){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(!i)return t[h];t[h]=n;break}}}return{getStyles:function(t){var e=t&&9!==t.nodeType?t.ownerDocument:t,i=e&&e.defaultView;return i&&i.getComputedStyle(t,"")},getBounds:function(t,e){var i,n=t.ownerDocument,r=n.body,s=n.documentElement;try{i=t.getBoundingClientRect()}catch(a){i={left:0,top:0,width:0,height:0}}var o=i.left-(s.clientLeft||r.clientLeft||0),h=i.top-(s.clientTop||r.clientTop||0);if(!e){var u=n.defaultView;o+=u.pageXOffset||s.scrollLeft||r.scrollLeft,h+=u.pageYOffset||s.scrollTop||r.scrollTop}return new g(o,h,i.width,i.height)},getViewportBounds:function(t){var e=t.ownerDocument,i=e.defaultView,n=e.documentElement;return new g(0,0,i.innerWidth||n.clientWidth,i.innerHeight||n.clientHeight)},getOffset:function(t,e){return H.getBounds(t,e).getPoint()},getSize:function(t){return H.getBounds(t,!0).getSize()},isInvisible:function(t){return H.getSize(t).equals(new f(0,0))},isInView:function(t){return!H.isInvisible(t)&&H.getViewportBounds(t).intersects(H.getBounds(t,!0))},isInserted:function(t){return n.body.contains(t)},getPrefixed:function(e,i){return e&&t(e,i)},setPrefixed:function(e,i,n){if("object"==typeof i)for(var r in i)t(e,r,!0,i[r]);else t(e,i,!0,n)}}},Z={add:function(t,e){if(t)for(var i in e)for(var n=e[i],r=i.split(/[\s,]+/g),s=0,a=r.length;s<a;s++)t.addEventListener(r[s],n,!1)},remove:function(t,e){if(t)for(var i in e)for(var n=e[i],r=i.split(/[\s,]+/g),s=0,a=r.length;s<a;s++)t.removeEventListener(r[s],n,!1)},getPoint:function(t){var e=t.targetTouches?t.targetTouches.length?t.targetTouches[0]:t.changedTouches[0]:t;return new c(e.pageX||e.clientX+n.documentElement.scrollLeft,e.pageY||e.clientY+n.documentElement.scrollTop)},getTarget:function(t){return t.target||t.srcElement},getRelatedTarget:function(t){return t.relatedTarget||t.toElement},getOffset:function(t,e){return Z.getPoint(t).subtract(H.getOffset(e||Z.getTarget(t)))}};Z.requestAnimationFrame=new function(){function t(){var e=s;s=[];for(var i=0,a=e.length;i<a;i++)e[i]();r=n&&s.length,r&&n(t)}var e,n=H.getPrefixed(i,"requestAnimationFrame"),r=!1,s=[];return function(i){s.push(i),n?r||(n(t),r=!0):e||(e=setInterval(t,1e3/60))}};var U=r.extend(s,{_class:"View",initialize:function xt(t,e){function r(t){return e[t]||parseInt(e.getAttribute(t),10)}function s(){var t=H.getSize(e);return t.isNaN()||t.isZero()?new f(r("width"),r("height")):t}var o;if(i&&e){this._id=e.getAttribute("id"),null==this._id&&e.setAttribute("id",this._id="view-"+xt._id++),Z.add(e,this._viewEvents);var h="none";if(H.setPrefixed(e.style,{userDrag:h,userSelect:h,touchCallout:h,contentZooming:h,tapHighlightColor:"rgba(0,0,0,0)"}),a.hasAttribute(e,"resize")){var u=this;Z.add(i,this._windowEvents={resize:function(){u.setViewSize(s())}})}if(o=s(),a.hasAttribute(e,"stats")&&"undefined"!=typeof Stats){this._stats=new Stats;var l=this._stats.domElement,c=l.style,d=H.getOffset(e);c.position="absolute",c.left=d.x+"px",c.top=d.y+"px",n.body.appendChild(l)}}else o=new f(e),e=null;this._project=t,this._scope=t._scope,this._element=e,this._pixelRatio||(this._pixelRatio=i&&i.devicePixelRatio||1),this._setElementSize(o.width,o.height),thi
}),t}function P(t){var e=t&&t.match(/\((?:["'#]*)([^"')]+)/),n=e&&z[e[1].replace(i.location.href.split("#")[0]+"#","")];return n&&n._scaleToBounds&&(n=n.clone(),n._scaleToBounds=!0),n}function M(t,e,i){var s,o,h,u=t.nodeName.toLowerCase(),l="#document"!==u,c=n.body;i&&l&&(k=a(t,null,null,!0)||paper.getView().getSize(),s=et.create("svg",{style:"stroke-width: 1px; stroke-miterlimit: 10"}),o=t.parentNode,h=t.nextSibling,s.appendChild(t),c.appendChild(s));var d=paper.settings,f=d.applyMatrix,_=d.insertItems;d.applyMatrix=!1,d.insertItems=!1;var g=O[u],v=g&&g(t,u,e,i)||null;if(d.insertItems=_,d.applyMatrix=f,v){!l||v instanceof x||(v=b(v,t,i));var p=e.onImport,m=l&&t.getAttribute("data-paper-data");p&&(v=p(t,v,e)||v),e.expandShapes&&v instanceof C&&(v.remove(),v=v.toPath()),m&&(v._data=JSON.parse(m))}return s&&(c.removeChild(s),o&&(h?o.insertBefore(t,h):o.appendChild(t))),i&&(z={},v&&r.pick(e.applyMatrix,f)&&v.matrix.apply(!0,!0)),v}function T(t,r,s){function a(n){try{var a="object"==typeof n?n:(new i.DOMParser).parseFromString(n,"image/svg+xml");if(!a.nodeName)throw a=null,new Error("Unsupported SVG source: "+t);paper=h,u=M(a,r,!0),r&&r.insert===!1||s._insertItem(e,u);var l=r.onLoad;l&&l(u,n)}catch(c){o(c)}}function o(t,e){var i=r.onError;if(!i)throw new Error(t);i(t,e)}if(!t)return null;r="function"==typeof r?{onLoad:r}:r||{};var h=paper,u=null;if("string"!=typeof t||/^.*</.test(t)){if("undefined"!=typeof File&&t instanceof File){var l=new FileReader;return l.onload=function(){a(l.result)},l.onerror=function(){o(l.error)},l.readAsText(t)}a(t)}else{var c=n.getElementById(t);c?a(c):K.request({url:t,async:!0,onLoad:a,onError:o})}return u}var k,z={},O={"#document":function(t,e,i,n){for(var r=t.childNodes,s=0,a=r.length;s<a;s++){var o=r[s];if(1===o.nodeType)return M(o,i,n)}},g:h,svg:h,clippath:h,polygon:u,polyline:u,path:l,lineargradient:d,radialgradient:d,image:function(e){var i=new S(t(e,"href",!0));return i.on("load",function(){var t=a(e);this.setSize(t);var i=this._matrix._transformPoint(s(e).add(t.divide(2)));this.translate(i)}),i},symbol:function(t,e,i,n){return new I(h(t,e,i,n),(!0))},defs:h,use:function(e){var i=(t(e,"href",!0)||"").substring(1),n=z[i],r=s(e);return n?n instanceof I?n.place(r):n.clone().translate(r):null},circle:function(e){return new C.Circle(s(e,"cx","cy"),t(e,"r"))},ellipse:function(t){return new C.Ellipse({center:s(t,"cx","cy"),radius:a(t,"rx","ry")})},rect:function(t){return new C.Rectangle(new g(s(t),a(t)),a(t,"rx","ry"))},line:function(t){return new L.Line(s(t,"x1","y1"),s(t,"x2","y2"))},text:function(t){var e=new j(s(t).add(s(t,"dx","dy")));return e.setContent(t.textContent.trim()||""),e}},N=r.set(r.each(it,function(t){this[t.attribute]=function(e,i){if(e[t.set]&&(e[t.set](o(i,t.type,t.fromSVG)),"color"===t.type)){var n=e[t.get]();if(n){if(n._scaleToBounds){var r=e.getBounds();n.transform((new p).translate(r.getPoint()).scale(r.getSize()))}e instanceof C&&n.transform((new p).translate(e.getPosition(!0).negate()))}}}},{}),{id:function(t,e){z[e]=t,t.setName&&t.setName(e)},"clip-path":function(t,e){var i=P(e);if(i){if(i=i.clone(),i.setClipMask(!0),!(t instanceof x))return new x(i,t);t.insertChild(0,i)}},gradientTransform:_,transform:_,"fill-opacity":v,"stroke-opacity":v,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 i=e.match(/(.*)%$/);t.setOffset(i?i[1]/100:parseFloat(e))}},viewBox:function(t,e,i,n,r){var s,h,u=new g(o(e,"array")),l=a(n,null,null,!0);if(t instanceof x){var c=l?l.divide(u.getSize()):1,h=(new p).scale(c).translate(u.getPoint().negate());s=t}else t instanceof I&&(l&&u.setSize(l),s=t._item);if(s){if("visible"!==m(n,"overflow",r)){var d=new C.Rectangle(u);d.setClipMask(!0),s.addChild(d)}h&&s.transform(h)}}});w.inject({importSVG:function(t,e){return T(t,e,this)}}),y.inject({importSVG:function(t,e){return this.activate(),T(t,e,this)}})},paper=