From 89ced3a01016d71ef42771e71524a6ff77da969c Mon Sep 17 00:00:00 2001 From: "Paper.js Bot" Date: Sat, 23 May 2020 12:58:07 +0000 Subject: [PATCH] Prebuilt module for commit 8d67d14e980c584fbfa351485ea6ac62f48907bf --- dist/docs/assets/js/paper.js | 19 +++++++++++-------- dist/paper-core.js | 19 +++++++++++-------- dist/paper-core.min.js | 4 ++-- dist/paper-full.js | 19 +++++++++++-------- dist/paper-full.min.js | 4 ++-- dist/paper.d.ts | 2 +- 6 files changed, 38 insertions(+), 29 deletions(-) diff --git a/dist/docs/assets/js/paper.js b/dist/docs/assets/js/paper.js index ea287d3c..51b31076 100644 --- a/dist/docs/assets/js/paper.js +++ b/dist/docs/assets/js/paper.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Sat May 23 14:48:39 2020 +0200 + * Date: Sat May 23 14:54:51 2020 +0200 * *** * @@ -9806,13 +9806,16 @@ statics: { } var length = segments.length - (closed ? 0 : 1); - for (var i = 1; i < length; i++) - addJoin(segments[i], join); - if (closed) { - addJoin(segments[0], join); - } else if (length > 0) { - addCap(segments[0], cap); - addCap(segments[segments.length - 1], cap); + if (length > 0) { + for (var i = 1; i < length; i++) { + addJoin(segments[i], join); + } + if (closed) { + addJoin(segments[0], join); + } else { + addCap(segments[0], cap); + addCap(segments[segments.length - 1], cap); + } } return bounds; }, diff --git a/dist/paper-core.js b/dist/paper-core.js index e0266ffd..1e5a67b7 100644 --- a/dist/paper-core.js +++ b/dist/paper-core.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Sat May 23 14:48:39 2020 +0200 + * Date: Sat May 23 14:54:51 2020 +0200 * *** * @@ -9803,13 +9803,16 @@ statics: { } var length = segments.length - (closed ? 0 : 1); - for (var i = 1; i < length; i++) - addJoin(segments[i], join); - if (closed) { - addJoin(segments[0], join); - } else if (length > 0) { - addCap(segments[0], cap); - addCap(segments[segments.length - 1], cap); + if (length > 0) { + for (var i = 1; i < length; i++) { + addJoin(segments[i], join); + } + if (closed) { + addJoin(segments[0], join); + } else { + addCap(segments[0], cap); + addCap(segments[segments.length - 1], cap); + } } return bounds; }, diff --git a/dist/paper-core.min.js b/dist/paper-core.min.js index 2bdc40ee..37bd9817 100644 --- a/dist/paper-core.min.js +++ b/dist/paper-core.min.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Sat May 23 14:48:39 2020 +0200 + * Date: Sat May 23 14:54:51 2020 +0200 * *** * @@ -33,6 +33,6 @@ var paper=function(t,e){t=t||require("./node/self.js");var i=t.window,n=t.docume this[i]=function(){this._dontNotify=!0,t[i].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)}}))}),m=r.extend({_class:"Matrix",initialize:function ut(t,e){var i=arguments,n=i.length,r=!0;if(n>=6?this._set.apply(this,i):1===n||2===n?t instanceof ut?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,e):Array.isArray(t)?this._set.apply(this,e?t.concat([e]):t):r=!1:n?r=!1:this.reset(),!r)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(t,e,i,n,r,s,a){return this._a=t,this._b=e,this._c=i,this._d=n,this._tx=r,this._ty=s,a||this._changed(),this},_serialize:function(t,e){return r.serialize(this.getValues(),t,!0,e)},_changed:function(){var t=this._owner;t&&(t._applyMatrix?t.transform(null,!0):t._changed(25))},clone:function(){return new m(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=u.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 i=this._owner;return!!i&&(i.transform(null,r.pick(t,!0),e),this.isIdentity())},translate:function(){var t=f.read(arguments),e=t.x,i=t.y;return this._tx+=e*this._a+i*this._c,this._ty+=e*this._b+i*this._d,this._changed(),this},scale:function(){var t=arguments,e=f.read(t),i=f.read(t,0,{readNull:!0});return i&&this.translate(i),this._a*=e.x,this._b*=e.x,this._c*=e.y,this._d*=e.y,i&&this.translate(i.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=f.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,c=this._d;return this._a=r*h+s*l,this._b=r*u+s*c,this._c=-s*h+r*l,this._d=-s*u+r*c,this._tx+=a*h+o*l,this._ty+=a*u+o*c,this._changed(),this},shear:function(){var t=arguments,e=f.read(t),i=f.read(t,0,{readNull:!0});i&&this.translate(i);var n=this._a,r=this._b;return this._a+=e.y*this._c,this._b+=e.y*this._d,this._c+=e.x*n,this._d+=e.x*r,i&&this.translate(i.negate()),this._changed(),this},skew:function(){var t=arguments,e=f.read(t),i=f.read(t,0,{readNull:!0}),n=Math.PI/180,r=new f(Math.tan(e.x*n),Math.tan(e.y*n));return this.shear(r,i)},append:function(t,e){if(t){var i=this._a,n=this._b,r=this._c,s=this._d,a=t._a,o=t._c,h=t._b,u=t._d,l=t._tx,c=t._ty;this._a=a*i+h*r,this._c=o*i+u*r,this._b=a*n+h*s,this._d=o*n+u*s,this._tx+=l*i+c*r,this._ty+=l*n+c*s,e||this._changed()}return this},prepend:function(t,e){if(t){var i=this._a,n=this._b,r=this._c,s=this._d,a=this._tx,o=this._ty,h=t._a,u=t._c,l=t._b,c=t._d,f=t._tx,d=t._ty;this._a=h*i+u*n,this._c=h*r+u*s,this._b=l*i+c*n,this._d=l*r+c*s,this._tx=h*a+u*o+f,this._ty=l*a+c*o+d,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,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 m(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(f.read(arguments)):this._transformCoordinates(t,e,i)},_transformPoint:function(t,e,i){var n=t.x,r=t.y;return e||(e=new f),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;ns[h]&&(s[h]=o)}return e||(e=new v),e._set(r[0],r[1],s[0]-r[0],s[1]-r[1],i)},inverseTransform:function(){return this._inverseTransform(f.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 c=t.x-this._tx,d=t.y-this._ty;e||(e=new f),l=e._set((c*a-d*s)/u,(d*n-c*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 c=h(n*n+r*r);t=Math.acos(n/c)*(r>0?1:-1),e=[c,o/c],i=[u(n*s+r*a,c*c),0]}else if(0!==s||0!==a){var d=h(s*s+a*a);t=Math.asin(s/d)*(a>0?1:-1),e=[o/d,d],i=[0,u(n*s+r*a,d*d)]}else t=0,i=e=[0,0];return{translation:this.getTranslation(),rotation:t*l,scaling:new f(e),skewing:new f(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 f(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)}},r.each(["a","b","c","d","tx","ty"],function(t){var e=r.capitalize(t),i="_"+t;this["get"+e]=function(){return this[i]},this["set"+e]=function(t){this[i]=t,this._changed()}},{})),y=r.extend({_class:"Line",initialize:function(t,e,i,n,r){var s=!1;arguments.length>=4?(this._px=t,this._py=e,this._vx=i,this._vy=n,s=r):(this._px=t.x,this._py=t.y,this._vx=e.x,this._vy=e.y,s=i),s||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new f(this._px,this._py)},getVector:function(){return new f(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return y.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return y.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 y.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0)},isCollinear:function(t){return f.isCollinear(this._vx,this._vy,t._vx,t._vy)},isOrthogonal:function(t){return f.isOrthogonal(this._vx,this._vy,t._vx,t._vy)},statics:{intersect:function(t,e,i,n,r,s,a,o,h,u){h||(i-=t,n-=e,a-=r,o-=s);var c=i*o-n*a;if(!l.isMachineZero(c)){var d=t-r,_=e-s,g=(a*_-o*d)/c,v=(i*_-n*d)/c,p=1e-12,m=-p,y=1+p;if(u||m=1?1:g),new f(t+g*i,e+g*n)}},getSide:function(t,e,i,n,r,s,a,o){a||(i-=t,n-=e);var h=r-t,u=s-e,c=h*n-u*i;return!o&&l.isMachineZero(c)&&(c=(h*i+h*i)/(i*i+n*n),c>=0&&c<=1&&(c=0)),c<0?-1:c>0?1:0},getSignedDistance:function(t,e,i,n,r,s,a){return a||(i-=t,n-=e),0===i?n>0?r-t:t-r:0===n?i<0?s-e:e-s:((r-t)*n-(s-e)*i)/(n>i?n*Math.sqrt(1+i*i/(n*n)):i*Math.sqrt(1+n*n/(i*i)))},getDistance:function(t,e,i,n,r,s,a){return Math.abs(y.getSignedDistance(t,e,i,n,r,s,a))}}}),w=o.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(t){o.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new H(null,null,this),this._view=W.create(this,t||et.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(t,e){return r.serialize(this._children,t,!0,e)},_changed:function(t,e){if(1&t){var i=this._view;i&&(i._needsUpdate=!0,!i._requested&&i._autoUpdate&&i.requestUpdate())}var n=this._changes;if(n&&e){var r=this._changesById,s=e._id,a=r[s];a?a.flags|=t:n.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 lt(){return!!lt.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 C({project:this,insert:!0})},getSymbolDefinitions:function(){var t=[],e={};return this.getItems({"class":I,match:function(i){var n=i._definition,r=n._id;return e[r]||(e[r]=!0,t.push(n)),!1}}),t},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var t=this._selectionItems,e=[];for(var i in t){var n=t[i],r=n._selection;1&r&&n.isInserted()?e.push(n):r||this._updateSelection(n)}return e},_updateSelection:function(t){var e=t._id,i=this._selectionItems;t._selection?i[e]!==t&&(this._selectionCount++,i[e]=t):i[e]===t&&(this._selectionCount--,delete i[e])},selectAll:function(){for(var t=this._children,e=0,i=t.length;e0){t.save(),t.strokeWidth=1;var h=this._selectionItems,u=this._scope.settings.handleSize,l=this._updateVersion;for(var c in h)h[c]._drawSelection(t,e,u,h,l);t.restore()}}}),x=r.extend(s,{statics:{extend:function ct(t){return t._serializeFields&&(t._serializeFields=r.set({},this.prototype._serializeFields,t._serializeFields)),ct.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 m,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 r.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(){},_initialize:function(t,i){var n=t&&r.isPlainObject(t),s=n&&t.internal===!0,a=this._matrix=new m,o=n&&t.project||st.project,h=st.settings;return this._id=s?null:c.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&h.applyMatrix,i&&a.translate(i),a._owner=this,this._style=new H(o._currentStyle,this,o),s||n&&0==t.insert||!h.insertItems&&(!n||t.insert!==!0)?this._setProject(o):(n&&t.parent||o)._insertItem(e,this,!0),n&&t!==x.NO_INSERT&&this.set(t,{internal:!0,insert:!0,project:!0,parent:!0}),n},_serialize:function(t,e){function i(i){for(var a in i){var o=s[a];r.equals(o,"leading"===a?1.2*i.fontSize:i[a])||(n[a]=r.serialize(o,t,"data"!==a,e))}}var n={},s=this;return i(this._serializeFields),this instanceof b||i(this._style._defaults),[this._class,n]},_changed:function(t){var i=this._symbol,n=this._parent||i,r=this._project;8&t&&(this._bounds=this._position=this._decomposed=e),16&t&&(this._globalMatrix=e),n&&72&t&&x._clearBoundsCache(n),2&t&&x._clearBoundsCache(this),r&&r._changed(t,this),i&&i._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 i=this._getOwner();if(t&&i){var n=i._children,r=i._namedChildren;(r[t]=r[t]||[]).push(this),t in n||(n[t]=this)}this._name=t||e,this._changed(256)},getStyle:function(){return this._style},setStyle:function(t){this.getStyle().set(t)}},r.each(["locked","visible","blendMode","opacity","guide"],function(t){var e=r.capitalize(t),i="_"+t,n={locked:256,visible:265};this["get"+e]=function(){return this[i]},this["set"+e]=function(e){e!=this[i]&&(this[i]=e,this._changed(n[t]||257))}},{}),{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(257))}},_changeSelection:function(t,e){var i=this._selection;this.setSelection(e?i|t:i&~t)},isSelected:function(){if(this._selectChildren)for(var t=this._children,e=0,i=t.length;e=0;i--)if(e[i].contains(t))return!0;return!1}return t.isInside(this.getInternalBounds())},isInside:function(){return v.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new N.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(t,e){return t instanceof x&&this._asPathItem().getIntersections(t._asPathItem(),null,e,!0).length>0}},new function(){function t(){var t=arguments;return this._hitTest(f.read(t),T.getOptions(t))}function e(){var t=arguments,e=f.read(t),i=T.getOptions(t),n=[];return this._hitTest(e,new r({all:n},i)),n}function i(t,e,i,n){var r=this._children;if(r)for(var s=r.length-1;s>=0;s--){var a=r[s],o=a!==n&&a._hitTest(t,e,i);if(o&&!e.all)return o}return null}return w.inject({hitTest:t,hitTestAll:e,_hitTest:i}),{hitTest:t,hitTestAll:e,_hitTestChildren:i}},{_hitTest:function(t,e,i){function n(t){return t&&d&&!d(t)&&(t=null),t&&e.all&&e.all.push(t),t}function s(e,i){var n=i?l["get"+i]():g.getPosition();if(t.subtract(n).divide(u).length<=1)return new T(e,g,{name:i?r.hyphenate(i):e,point:n})}if(this._locked||!this._visible||this._guide&&!e.guides||this.isEmpty())return null;var a=this._matrix,o=i?i.appended(a):this.getGlobalMatrix().prepend(this.getView()._matrix),h=Math.max(e.tolerance,1e-12),u=e._tolerancePadding=new _(N._getStrokePadding(h,a._shiftless().invert()));if(t=a._inverseTransform(t),!t||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(u.multiply(2))._containsPoint(t))return null;var l,c,f=!(e.guides&&!this._guide||e.selected&&!this.isSelected()||e.type&&e.type!==r.hyphenate(this._class)||e["class"]&&!(this instanceof e["class"])),d=e.match,g=this,v=e.position,p=e.center,m=e.bounds;if(f&&this._parent&&(v||p||m)){if((p||m)&&(l=this.getInternalBounds()),c=v&&s("position")||p&&s("center","Center"),!c&&m)for(var y=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],w=0;w<8&&!c;w++)c=s("bounds",y[w]);c=n(c)}return c||(c=this._hitTestChildren(t,e,o)||f&&n(this._hitTestSelf(t,e,o,this.getStrokeScaling()?null:o._shiftless().invert()))||null),c&&c.point&&(c.point=a.transform(c.point)),c},_hitTestSelf:function(t,e){if(e.fill&&this.hasFill()&&this._contains(t))return new T("fill",this)},matches:function(t,e){function i(t,e){for(var n in t)if(t.hasOwnProperty(n)){var s=t[n],a=e[n];if(r.isPlainObject(s)&&r.isPlainObject(a)){if(!i(s,a))return!1}else if(!r.equals(s,a))return!1}return!0}var n=typeof t;if("object"===n){for(var s in t)if(t.hasOwnProperty(s)&&!this.matches(s,t[s]))return!1;return!0}if("function"===n)return t(this);if("match"===t)return e(this);var a=/^(empty|editable)$/.test(t)?this["is"+r.capitalize(t)]():"type"===t?r.hyphenate(this._class):this[t];if("class"===t){if("function"==typeof e)return this instanceof e;a=this._class}if("function"==typeof e)return!!e(a);if(e){if(e.test)return e.test(a);if(r.isPlainObject(e))return i(e,a)}return r.equals(a,e)},getItems:function(t){return x._getItems(this,t,this._matrix)},getItem:function(t){return x._getItems(this,t,this._matrix,null,!0)[0]||null},statics:{_getItems:function dt(t,e,i,n,s){if(!n){var a="object"==typeof e&&e,o=a&&a.overlapping,h=a&&a.inside,u=o||h,l=u&&v.read([u]);n={items:[],recursive:a&&a.recursive!==!1,inside:!!h,overlapping:!!o,rect:l,path:o&&new N.Rectangle({rectangle:l,insert:!1})},a&&(e=r.filter({},e,{recursive:!0,inside:!0,overlapping:!0}))}var c=t._children,f=n.items,l=n.rect;i=l&&(i||new m);for(var d=0,_=c&&c.length;d<_;d++){var g=c[d],p=i&&i.appended(g._matrix),y=!0;if(l){var u=g.getBounds(p);if(!l.intersects(u))continue;l.contains(u)||n.overlapping&&(u.contains(l)||n.path.intersects(g,p))||(y=!1)}if(y&&g.matches(e)&&(f.push(g),s))break;if(n.recursive!==!1&&dt(g,e,p,n,s),s&&f.length>0)break}return f}}},{importJSON:function(t){var e=r.importJSON(t,this);return e!==this?this.addChild(e):e},addChild:function(t){return this.insertChild(e,t)},insertChild:function(t,e){var i=e?this.insertChildren(t,[e]):null;return i&&i[0]},addChildren:function(t){return this.insertChildren(this._children.length,t)},insertChildren:function(t,e){var i=this._children;if(i&&e&&e.length>0){e=r.slice(e);for(var n={},s=e.length-1;s>=0;s--){var a=e[s],o=a&&a._id;!a||n[o]?e.splice(s,1):(a._remove(!1,!0),n[o]=!0)}r.splice(i,e,t,0);for(var h=this._project,u=h._changes,s=0,l=e.length;s=0;n--)i[n]._remove(!0,!1);return i.length>0&&this._changed(11),i},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var t=0,e=this._children.length;t0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(t){return this._getOrder(t)===-1},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}},r.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var i=arguments,n=(e?r:f).read(i),s=f.read(i,0,{readNull:!0});return this.transform((new m)[t](n,s||this.getPosition(!0)))}},{translate:function(){var t=new m;return this.transform(t.translate.apply(t,arguments))},transform:function(t,e,i){var n=this._matrix,r=t&&!t.isIdentity(),s=i&&this._canApplyMatrix||this._applyMatrix&&(r||!n.isIdentity()||e&&this._children);if(!r&&!s)return this;if(r){!t.isInvertible()&&n.isInvertible()&&(n._backup=n.getValues()),n.prepend(t,!0);var a=this._style,o=a.getFillColor(!0),h=a.getStrokeColor(!0);o&&o.transform(t),h&&h.transform(t)}if(s&&(s=this._transformContent(n,e,i))){var u=this._pivot;u&&n._transformPoint(u,u,!0),n.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var l=this._bounds,c=this._position;(r||s)&&this._changed(25);var f=r&&l&&t.decompose();if(f&&f.skewing.isZero()&&f.rotation%90===0){for(var d in l){var _=l[d];if(_.nonscaling)delete l[d];else if(s||!_.internal){var g=_.rect;t._transformBounds(g,g)}}this._bounds=l;var v=l[this._getBoundsCacheKey(this._boundsOptions||{})];v&&(this._position=this._getPositionFromBounds(v.rect))}else r&&c&&this._pivot&&(this._position=t._transformPoint(c,c));return this},_transformContent:function(t,e,i){var n=this._children;if(n){for(var r=0,s=n.length;rr:n1&&s<4?-1:1,s>2?-1:1),o=a.multiply(r),h=o.subtract(a.multiply(n)),u=new v(i?o.add(a.multiply(i)):o,h);if(u.contains(e))return{point:h,quadrant:s}}}function e(t,e,i,n){var r=t.divide(e);return(!n||r.isInQuadrant(n))&&r.subtract(r.normalize()).multiply(e).divide(i).length<=1}return{_contains:function i(e){if("rectangle"===this._type){var n=t(this,e);return n?e.subtract(n.point).divide(this._radius).getLength()<=1:i.base.call(this,e)}return e.divide(this.size).getLength()<=.5},_hitTestSelf:function n(i,r,s,a){var o=!1,h=this._style,u=r.stroke&&h.hasStroke(),l=r.fill&&h.hasFill();if(u||l){var c=this._type,f=this._radius,d=u?h.getStrokeWidth()/2:0,_=r._tolerancePadding.add(N._getStrokePadding(d,!h.getStrokeScaling()&&a));if("rectangle"===c){var g=_.multiply(2),p=t(this,i,g);if(p)o=e(i.subtract(p.point),f,_,p.quadrant);else{var m=new v(this._size).setCenter(0,0),y=m.expand(g),w=m.expand(g.negate());o=y._containsPoint(i)&&!w._containsPoint(i)}}else o=e(i,f,_)}return o?new T(u?"stroke":"fill",this):n.base.apply(this,arguments)}}},{statics:new function(){function t(t,e,i,n,s){var a=r.create(S.prototype);return a._type=t,a._size=i,a._radius=n,a._initialize(r.getNamed(s),e),a}return{Circle:function(){var e=arguments,i=f.readNamed(e,"center"),n=r.readNamed(e,"radius");return t("circle",i,new _(2*n),n,e)},Rectangle:function(){var e=arguments,i=v.readNamed(e,"rectangle"),n=_.min(_.readNamed(e,"radius"),i.getSize(!0).divide(2));return t("rectangle",i.getCenter(!0),i.getSize(!0),n,e)},Ellipse:function(){var e=arguments,i=S._readEllipse(e),n=i.radius;return t("ellipse",i.center,n.multiply(2),n,e)},_readEllipse:function(t){var e,i;if(r.hasNamed(t,"radius"))e=f.readNamed(t,"center"),i=_.readNamed(t,"radius");else{var n=v.readNamed(t,"rectangle");e=n.getCenter(!0),i=n.getSize(!0).divide(2)}return{center:e,radius:i}}}}}),P=x.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:!0,beans:!0,initialize:function(t,i){if(!this._initialize(t,i!==e&&f.read(arguments))){var r,s=typeof t,a="string"===s?n.getElementById(t):"object"===s?t:null;if(a&&a!==x.NO_INSERT)if(a.getContext||null!=a.naturalHeight)r=a;else if(a){var o=_.read(arguments);o.isZero()||(r=et.getCanvas(o))}r?this.setImage(r):this.setSource(t)}this._size||(this._size=new _,this._loaded=!1)},_equals:function(t){return this.getSource()===t.getSource()},copyContent:function(t){var e=t._image,i=t._canvas;if(e)this._setImage(e);else if(i){var n=et.getCanvas(t._size);n.getContext("2d").drawImage(i,0,0),this._setImage(n)}this._crossOrigin=t._crossOrigin},getSize:function(){var t=this._size;return new g(t?t.width:0,t?t.height:0,this,"setSize")},setSize:function(){var t=_.read(arguments);if(!t.equals(this._size))if(t.width>0&&t.height>0){var e=this.getElement();this._setImage(et.getCanvas(t)),e&&this.getContext(!0).drawImage(e,0,0,t.width,t.height)}else this._canvas&&et.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 f(0,0).transform(t),i=new f(1,0).transform(t).subtract(e),n=new f(0,1).transform(t).subtract(e);return new _(72/i.getLength(),72/n.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(t){function e(t){var e=i.getView(),n=t&&t.type||"load";e&&i.responds(n)&&(st=e._scope,i.emit(n,new $(t)))}var i=this;this._setImage(t),this._loaded?setTimeout(e,0):t&&U.add(t,{load:function(n){i._setImage(t),e(n)},error:e})},_setImage:function(t){this._canvas&&et.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 _(t?t.naturalWidth||t.width:0,t?t.naturalHeight||t.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var t=et.getContext(this._size);try{this._image&&t.drawImage(this._image,0,0),this._canvas=t.canvas}catch(e){et.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(1025)),this._context},setContext:function(t){this._context=t},getSource:function(){var t=this._image;return t&&t.src||this.toDataURL()},setSource:function(e){var i=new t.Image,n=this._crossOrigin;n&&(i.crossOrigin=n),e&&(i.src=e),this.setImage(i)},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)},getSmoothing:function(){return this._smoothing},setSmoothing:function(t){this._smoothing=t,this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var t=v.read(arguments),e=et.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=v.read(arguments),e=new P(x.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 i=this.getCanvas();return i?i.toDataURL.apply(i,arguments):null},drawImage:function(t){var e=f.read(arguments,1);this.getContext(!0).drawImage(t,e.x,e.y)},getAverageColor:function(t){var e,i;if(t?t instanceof L?(i=t,e=t.getBounds()):"object"==typeof t&&("width"in t?e=new v(t):"x"in t&&(e=new v(t.x-.5,t.y-.5,1,1))):e=this.getBounds(),!e)return null;var n=32,s=Math.min(e.width,n),a=Math.min(e.height,n),o=P._sampleContext;o?o.clearRect(0,0,n+1,n+1):o=P._sampleContext=et.getContext(new _(n)),o.save();var h=(new m).scale(s/e.width,a/e.height).translate(-e.x,-e.y);h.applyToContext(o),i&&i.draw(o,new r({clip:!0,matrices:[h]})),this._matrix.applyToContext(o);var u=this.getElement(),l=this._size;u&&o.drawImage(u,-l.width/2,-l.height/2),o.restore();for(var c=o.getImageData(.5,.5,Math.ceil(s),Math.ceil(a)).data,f=[0,0,0],d=0,g=0,p=c.length;g0&&n.height>0&&(t.globalAlpha=this._opacity,this._setStyles(t,e,i),Z.setPrefixed(t,"imageSmoothingEnabled",this._smoothing),t.drawImage(n,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),I=x.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(t,i){this._initialize(t,i!==e&&f.read(arguments,1))||this.setDefinition(t instanceof M?t:new M(t))},_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 i=this._definition._item;return i._getCachedBounds(i._matrix.prepended(t),e)},_hitTestSelf:function(t,e,i){var n=e.extend({all:!1}),r=this._definition._item._hitTest(t,n,i);return r&&(r.item=this),r},_draw:function(t,e){this._definition._item.draw(t,e)}}),M=r.extend({_class:"SymbolDefinition",initialize:function(t,e){this._id=c.get(),this.project=st.project,t&&this.setItem(t,e)},_serialize:function(t,e){return e.add(this,function(){return r.serialize([this._class,this._item],t,!1,e)})},_changed:function(t){8&t&&x._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 f),t._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(t){return new I(this,t)},clone:function(){return new M(this._item.clone(!1))},equals:function(t){return t===this||t&&this._item.equals(t._item)||!1}}),T=r.extend({_class:"HitResult",initialize:function(t,e,i){this.type=t,this.item=e,i&&this.inject(i)},statics:{getOptions:function(t){var e=t&&r.read(t);return new r({type:null,tolerance:st.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),O=r.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(t,i,n,r,s,a){var o,h,u,l,c=arguments.length;c>0&&(null==t||"object"==typeof t?1===c&&t&&"point"in t?(o=t.point,h=t.handleIn,u=t.handleOut,l=t.selection):(o=t,h=i,u=n,l=r):(o=[t,i],h=n!==e?[n,r]:null,u=s!==e?[s,a]:null)),new z(o,this,"_point"),new z(h,this,"_handleIn"),new z(u,this,"_handleOut"),l&&this.setSelection(l)},_serialize:function(t,e){var i=this._point,n=this._selection,s=n||this.hasHandles()?[i,this._handleIn,this._handleOut]:i;return n&&s.push(n),r.serialize(s,t,!0,e)},_changed:function(t){var e=this._path;if(e){var i,n=e._curves,r=this._index;n&&(t&&t!==this._point&&t!==this._handleIn||!(i=r>0?n[r-1]:e._closed?n[n.length-1]:null)||i._changed(),t&&t!==this._point&&t!==this._handleOut||!(i=n[r])||i._changed()),e._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(f.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(f.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(f.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,i=this._path;this._selection=t=t||0,i&&t!==e&&(i._updateSelection(this,e,t),i._changed(257))},_changeSelection:function(t,e){var i=this._selection;this.setSelection(e?i|t:i&~t)},isSelected:function(){return!!(7&this._selection)},setSelected:function(t){this._changeSelection(7,t)},getIndex:function(){return this._index!==e?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 A(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,i,n){var r=t||{},s=r.type,a=r.factor,o=this.getPrevious(),h=this.getNext(),u=(o||this)._point,l=this._point,c=(h||this)._point,d=u.getDistance(l),_=l.getDistance(c);if(s&&"catmull-rom"!==s){if("geometric"!==s)throw new Error("Smoothing method '"+s+"' not supported.");if(o&&h){var g=u.subtract(c),v=a===e?.4:a,p=v*d/(d+_);i||this.setHandleIn(g.multiply(p)),n||this.setHandleOut(g.multiply(p-v))}}else{var m=a===e?.5:a,y=Math.pow(d,m),w=y*y,x=Math.pow(_,m),b=x*x;if(!i&&o){var C=2*b+3*x*y+w,S=3*x*(x+y);this.setHandleIn(0!==S?new f((b*u._x+C*l._x-w*c._x)/S-l._x,(b*u._y+C*l._y-w*c._y)/S-l._y):new f)}if(!n&&h){var C=2*w+3*y*x+b,S=3*y*(y+x);this.setHandleOut(0!==S?new f((w*c._x+C*l._x-b*u._x)/S-l._x,(w*c._y+C*l._y-b*u._y)/S-l._y):new f)}}},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,i=t.clone();t.set(e),e.set(i)},reversed:function(){return new O(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new O(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,i){var n=1-i,r=i,s=t._point,a=e._point,o=t._handleIn,h=e._handleIn,u=e._handleOut,l=t._handleOut;this._point._set(n*s._x+r*a._x,n*s._y+r*a._y,!0),this._handleIn._set(n*o._x+r*h._x,n*o._y+r*h._y,!0),this._handleOut._set(n*l._x+r*u._x,n*l._y+r*u._y,!0),this._changed()},_transformCoordinates:function(t,e,i){var n=this._point,r=i&&this._handleIn.isZero()?null:this._handleIn,s=i&&this._handleOut.isZero()?null:this._handleOut,a=n._x,o=n._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],i?(n._x=a,n._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}}),z=f.extend({initialize:function(t,i,n){var r,s,a;if(t)if((r=t[0])!==e)s=t[1];else{var o=t;(r=o.x)===e&&(o=f.read(arguments),r=o.x),s=o.y,a=o.selected}else r=s=0;this._x=r,this._y=s,this._owner=i,i[n]=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=l.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}}),k=r.extend({_class:"Curve",beans:!0,initialize:function(t,e,i,n,r,s,a,o){var h,u,l,c,f,d,_=arguments.length;3===_?(this._path=t,h=e,u=i):_?1===_?"segment1"in t?(h=new O(t.segment1),u=new O(t.segment2)):"point1"in t?(l=t.point1,f=t.handle1,d=t.handle2,c=t.point2):Array.isArray(t)&&(l=[t[0],t[1]],c=[t[6],t[7]],f=[t[2]-t[0],t[3]-t[1]],d=[t[4]-t[6],t[5]-t[7]]):2===_?(h=new O(t),u=new O(e)):4===_?(l=t,f=e,d=i,c=n):8===_&&(l=[t,e],c=[a,o],f=[i-t,n-e],d=[r-a,s-o]):(h=new O,u=new O),this._segment1=h||new O(l,null,f),this._segment2=u||new O(c,d,null)},_serialize:function(t,e){return r.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],t,!0,e)},_changed:function(){this._length=this._bounds=e},clone:function(){return new k(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 k.classify(this.getValues())},remove:function(){var t=!1;if(this._path){var e=this._segment2,i=e._handleOut;t=e.remove(),t&&this._segment1._handleOut.set(i)}return t},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(f.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(f.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(f.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(f.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 k.getValues(this._segment1,this._segment2,t)},getPoints:function(){for(var t=this.getValues(),e=[],i=0;i<8;i+=2)e.push(new f(t[i],t[i+1]));return e}},{getLength:function(){return null==this._length&&(this._length=k.getLength(this.getValues(),0,1)),this._length},getArea:function(){return k.getArea(this.getValues())},getLine:function(){return new y(this._segment1._point,this._segment2._point)},getPart:function(t,e){return new k(k.getPart(this.getValues(),t,e))},getPartLength:function(t,e){return k.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 i=1e-8,n=1-i,r=null;if(t>=i&&t<=n){var s=k.subdivide(this.getValues(),t),a=s[0],o=s[1],h=e||this.hasHandles(),u=this._segment1,l=this._segment2,c=this._path;h&&(u._handleOut._set(a[2]-a[0],a[3]-a[1]),l._handleIn._set(o[4]-o[6],o[5]-o[7]));var d=a[6],_=a[7],g=new O(new f(d,_),h&&new f(a[4]-d,a[5]-_),h&&new f(o[2]-d,o[3]-_));c?(c.insert(u._index+1,g),r=this.getNext()):(this._segment2=g,this._changed(),r=new k(g,l))}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,i){return this.divideAtTime(t===e?.5:i?t:this.getTimeAt(t))},split:function(t,i){return this.splitAtTime(t===e?.5:i?t:this.getTimeAt(t))},reversed:function(){return new k(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,i,n){var r=t._point,s=t._handleOut,a=e._handleIn,o=e._point,h=r.x,u=r.y,l=o.x,c=o.y,f=n?[h,u,h,u,l,c,l,c]:[h,u,h+s._x,u+s._y,l+a._x,c+a._y,l,c];return i&&i._transformCoordinates(f,f,4),f},subdivide:function(t,i){var n=t[0],r=t[1],s=t[2],a=t[3],o=t[4],h=t[5],u=t[6],l=t[7];i===e&&(i=.5);var c=1-i,f=c*n+i*s,d=c*r+i*a,_=c*s+i*o,g=c*a+i*h,v=c*o+i*u,p=c*h+i*l,m=c*f+i*_,y=c*d+i*g,w=c*_+i*v,x=c*g+i*p,b=c*m+i*w,C=c*y+i*x;return[[n,r,f,d,m,y,b,C],[b,C,w,x,v,p,u,l]]},getMonoCurves:function(t,e){var i=[],n=e?0:1,r=t[n+0],s=t[n+2],a=t[n+4],o=t[n+6];if(r>=s==s>=a&&s>=a==a>=o||k.isStraight(t))i.push(t);else{var h=3*(s-a)-r+o,u=2*(r+a)-4*s,c=s-r,f=1e-8,d=1-f,_=[],g=l.solveQuadratic(h,u,c,_,f,d);if(g){_.sort();var v=_[0],p=k.subdivide(t,v);i.push(p[0]),g>1&&(v=(_[1]-v)/(1-v),p=k.subdivide(p[1],v),i.push(p[0])),i.push(p[1])}else i.push(t)}return i},solveCubic:function(t,e,i,n,r,s){var a=t[e],o=t[e+2],h=t[e+4],u=t[e+6],c=0;if(!(ai&&u>i&&o>i&&h>i)){var f=3*(o-a),d=3*(h-o)-f,_=u-a-f-d;c=l.solveCubic(_,d,f,a-i,n,r,s)}return c},getTimeOf:function(t,e){var i=new f(t[0],t[1]),n=new f(t[6],t[7]),r=1e-12,s=1e-7,a=e.isClose(i,r)?0:e.isClose(n,r)?1:null;if(null===a)for(var o=[e.x,e.y],h=[],u=0;u<2;u++)for(var l=k.solveCubic(t,u,o[u],h,0,1),c=0;c=0&&i<=1){var n=e.getDistance(k.getPoint(t,i),!0);if(n.999999999999?1:k.getTimeOf(t,new f(n+l*o,r+l*h))}for(var c=100,d=1/0,_=0,g=0;g<=c;g++)i(g/c);for(var v=1/(2*c);v>1e-8;)i(_-v)||i(_+v)||(v/=2);return _},getPart:function(t,e,i){var n=e>i;if(n){var r=e;e=i,i=r}return e>0&&(t=k.subdivide(t,e)[1]),i<1&&(t=k.subdivide(t,(i-e)/(1-e))[0]),n?[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]]:t},isFlatEnough:function(t,e){var i=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],h=t[6],u=t[7],l=3*r-2*i-h,c=3*s-2*n-u,f=3*a-2*h-i,d=3*o-2*u-n;return Math.max(l*l,f*f)+Math.max(c*c,d*d)<=16*e*e},getArea:function(t){var e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7];return 3*((h-i)*(n+s)-(o-e)*(r+a)+r*(e-s)-n*(i-a)+h*(s+e/3)-o*(a+i/3))/20},getBounds:function(t){for(var e=t.slice(0,2),i=e.slice(),n=[0,0],r=0;r<2;r++)k._addBounds(t[r],t[r+2],t[r+4],t[r+6],r,0,e,i,n);return new v(e[0],e[1],i[0]-e[0],i[1]-e[1])},_addBounds:function(t,e,i,n,r,s,a,o,h){function u(t,e){var i=t-e,n=t+e;io[r]&&(o[r]=n)}s/=2;var c=a[r]-s,f=o[r]+s;if(tf||e>f||i>f||n>f)if(e=0&&h<=1&&u<=0&&u>=-1}}return!1},isLinear:function(t,e,i,n){var r=n.subtract(t).divide(3);return e.equals(r)&&i.negate().equals(r)}},function(t,e){this[e]=function(e){var i=this._segment1,n=this._segment2;return t(i._point,i._handleOut,n._handleIn,n._point,e)},this.statics[e]=function(e,i){var n=e[0],r=e[1],s=e[6],a=e[7];return t(new f(n,r),new f(e[2]-n,e[3]-r),new f(e[4]-s,e[5]-a),new f(s,a),i)}},{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 A(this,t):null},getTimeAt:function(t,e){return k.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var t=f.read(arguments);return t.isZero()?[]:k.getTimesWithTangent(this.getValues(),t)},getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(f.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return k.getTimeOf(this.getValues(),f.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=f.read(arguments),e=this.getValues(),i=k.getNearestTime(e,t),n=k.getPoint(e,i);return new A(this,i,n,null,t.getDistance(n))},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 r.each(t,function(t){this[t+"At"]=function(e,i){var n=this.getValues();return k[t](n,i?e:k.getTimeAt(n,e))},this[t+"AtTime"]=function(e){return k[t](this.getValues(),e)}},{statics:{_evaluateMethods:t}})},new function(){function t(t){var e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],u=9*(n-s)+3*(o-e),l=6*(e+s)-12*n,c=3*(n-e),f=9*(r-a)+3*(h-i),d=6*(i+a)-12*r,_=3*(r-i);return function(t){var e=(u*t+l)*t+c,i=(f*t+d)*t+_;return Math.sqrt(e*e+i*i)}}function i(t,e){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(e-t))))}function n(t,e,i,n){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],u=t[5],c=t[6],d=t[7],_=l.isZero;_(a-r)&&_(o-s)&&(a=r,o=s),_(h-c)&&_(u-d)&&(h=c,u=d);var g,v,p=3*(a-r),m=3*(h-a)-p,y=c-r-p-m,w=3*(o-s),x=3*(u-o)-w,b=d-s-w-x;if(0===i)g=0===e?r:1===e?c:((y*e+m)*e+p)*e+r,v=0===e?s:1===e?d:((b*e+x)*e+w)*e+s;else{var C=1e-8,S=1-C;if(eS?(g=3*(c-h),v=3*(d-u)):(g=(3*y*e+2*m)*e+p,v=(3*b*e+2*x)*e+w),n){0===g&&0===v&&(eS)&&(g=h-a,v=u-o);var P=Math.sqrt(g*g+v*v);P&&(g/=P,v/=P)}if(3===i){var h=6*y*e+2*m,u=6*b*e+2*x,I=Math.pow(g*g+v*v,1.5);g=0!==I?(g*u-v*h)/I:0,v=0}}return 2===i?new f(v,(-g)):new f(g,v)}return{statics:{classify:function(t){function i(t,i,n){var r=i!==e,s=r&&i>0&&i<1,a=r&&n>0&&n<1;return!r||(s||a)&&("loop"!==t||s&&a)||(t="arch",s=a=!1),{type:t,roots:s||a?s&&a?i0?Math.sqrt(b/3):Math.sqrt(-b),S=2*p;return i(b>0?x:"loop",(v+C)/S,(v-C)/S)},getLength:function(n,r,s,a){if(r===e&&(r=0),s===e&&(s=1),k.isStraight(n)){var o=n;s<1&&(o=k.subdivide(o,s)[0],r/=s),r>0&&(o=k.subdivide(o,r)[1]);var h=o[6]-o[0],u=o[7]-o[1];return Math.sqrt(h*h+u*u)}return l.integrate(a||t(n),r,s,i(r,s))},getTimeAt:function(n,r,s){function a(t){return p+=l.integrate(d,s,t,i(s,t)),s=t,p-r}if(s===e&&(s=r<0?1:0),0===r)return s;var o=Math.abs,h=1e-12,u=r>0,c=u?s:0,f=u?1:s,d=t(n),_=k.getLength(n,c,f,d),g=o(r)-_;if(o(g)h)return null;var v=r/_,p=0;return l.findRoot(a,d,s+v,c,f,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],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],u=-e+3*n-3*s+o,c=3*e-6*n+3*s,f=-3*e+3*n,d=-i+3*r-3*a+h,_=3*i-6*r+3*a,g=-3*i+3*r,v=1e-8,p=1-v,m=[];return l.solveCubic(9*(u*u+d*d),9*(u*c+_*d),2*(c*c+_*_)+3*(f*u+g*d),f*c+_*g,m,v,p),m.sort()}}}},new function(){function t(t,e,i,n,r,s,a){var o=!a&&i.getPrevious()===r,h=!a&&i!==r&&i.getNext()===r,u=1e-8,l=1-u;if(null!==n&&n>=(o?u:0)&&n<=(h?l:1)&&null!==s&&s>=(h?u:0)&&s<=(o?l:1)){var c=new A(i,n,null,a),f=new A(r,s,null,a);c._intersection=f,f._intersection=c,e&&!e(c)||A.insert(t,c,!0)}}function e(r,s,a,o,h,u,l,c,f,d,_,g,v){if(++f>=4096||++c>=40)return f;var p,m,w=1e-9,x=s[0],b=s[1],C=s[6],S=s[7],P=y.getSignedDistance,I=P(x,b,C,S,s[2],s[3]),M=P(x,b,C,S,s[4],s[5]),T=I*M>0?.75:4/9,O=T*Math.min(0,I,M),z=T*Math.max(0,I,M),A=P(x,b,C,S,r[0],r[1]),L=P(x,b,C,S,r[2],r[3]),N=P(x,b,C,S,r[4],r[5]),B=P(x,b,C,S,r[6],r[7]),E=i(A,L,N,B),j=E[0],F=E[1];if(0===I&&0===M&&0===A&&0===L&&0===N&&0===B||null==(p=n(j,F,O,z))||null==(m=n(j.reverse(),F.reverse(),O,z)))return f;var D=d+(_-d)*p,R=d+(_-d)*m;if(Math.max(v-g,R-D).8)if(R-D>H){var Z=k.subdivide(r,.5),q=(D+R)/2;f=e(s,Z[0],o,a,h,u,!l,c,f,g,v,D,q),f=e(s,Z[1],o,a,h,u,!l,c,f,g,v,q,R)}else{var Z=k.subdivide(s,.5),V=(g+v)/2;f=e(Z[0],r,o,a,h,u,!l,c,f,g,V,D,R),f=e(Z[1],r,o,a,h,u,!l,c,f,V,v,D,R)}else f=0===H||H>=w?e(s,r,o,a,h,u,!l,c,f,g,v,D,R):e(r,s,a,o,h,u,l,c,f,D,R,g,v)}return f}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]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=i:h<=i)return h===i?o:n+(i-r)*(o-n)/(h-r);n=o,r=h}return null}function s(t,e,i,n,r){var s=l.isZero;if(s(n)&&s(r)){var a=k.getTimeOf(t,new f(e,i));return null===a?[]:[a]}for(var o=Math.atan2(-r,n),h=Math.sin(o),u=Math.cos(o),c=[],d=[],_=0;_<8;_+=2){var g=t[_]-e,v=t[_+1]-i;c.push(g*u-v*h,g*h+v*u)}return k.solveCubic(c,1,0,d,0,1),d}function a(e,i,n,r,a,o,h){for(var u=i[0],l=i[1],c=i[6],f=i[7],d=s(e,u,l,c-u,f-l),_=0,g=d.length;_c(n[0],n[2],n[4],n[6])&&c(i[0],i[2],i[4],i[6])-lc(n[1],n[3],n[5],n[7])&&c(i[1],i[3],i[5],i[7])-l>1,S=1&v,P=6*C,I=6*S,M=new f(i[P],i[P+1]),T=new f(n[I],n[I+1]);M.isClose(T,l)&&t(h,u,r,C,s,S)}}}return h}function c(e,i,n,r){var s=k.classify(e);if("loop"===s.type){var a=s.roots;t(n,r,i,a[0],i,a[1])}return n}function d(t,e,i,n,r,s){var a=1e-7,o=!e;o&&(e=t);for(var l=t.length,f=e.length,d=new Array(l),_=o?d:new Array(f),g=[],v=0;vm){var S=e[C],P=_[C];u(w,P,y,S,g,i)}}}return g}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=y.getDistance,s=1e-8,a=1e-7,o=k.isStraight(t),h=k.isStraight(e),u=o&&h,l=i(t)>1,P=k.getTimeOf(m[b],new f(m[C][S?6:0],m[C][S?7:1]));if(null!=P){var I=b?[S,P]:[P,S];(!w.length||n(I[0]-w[0][0])>s&&n(I[1]-w[0][1])>s)&&w.push(I)}if(x>2&&!w.length)break}if(2!==w.length)w=null;else if(!u){var M=k.getPart(t,w[0][0],w[1][0]),T=k.getPart(e,w[0][1],w[1][1]);(n(T[2]-M[2])>a||n(T[3]-M[3])>a||n(T[4]-M[4])>a||n(T[5]-M[5])>a)&&(w=null)}return w}function g(t,e){var i=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],h=t[6],u=t[7],c=e.normalize(),f=c.x,d=c.y,_=3*h-9*a+9*r-3*i,g=3*u-9*o+9*s-3*n,v=6*a-12*r+6*i,p=6*o-12*s+6*n,m=3*r-3*i,y=3*s-3*n,w=2*_*d-2*g*f,x=[];if(Math.abs(w)=0&&C<=1&&x.push(C)}}else{var S=(v*v-4*_*m)*d*d+(-2*v*p+4*g*m+4*_*y)*f*d+(p*p-4*g*y)*f*f,P=v*d-p*f;if(S>=0&&0!=w){var I=Math.sqrt(S),M=-(P+I)/w,T=(-P+I)/w;M>=0&&M<=1&&x.push(M),T>=0&&T<=1&&x.push(T)}}return x}return{getIntersections:function(t){var e=this.getValues(),i=t&&t!==this&&t.getValues();return i?u(e,i,this,t,[]):c(e,this,[])},statics:{getOverlaps:_,getIntersections:d,getCurveLineIntersections:s,getTimesWithTangent:g}}}),A=r.extend({_class:"CurveLocation",initialize:function(t,e,i,n,r){if(e>=.99999999){var s=t.getNext();s&&(e=0,t=s)}this._setCurve(t),this._time=e,this._point=i||t.getPointAtTime(e),this._overlap=n,this._distance=r,this._intersection=this._next=this._previous=null},_setPath:function(t){this._path=t,this._version=t?t._version:0},_setCurve:function(t){this._setPath(t._path),this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){var e=t.getCurve();e?this._setCurve(e):(this._setPath(t._path),this._segment1=t,this._segment2=null),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(),i=this.getTime();0===i?t=e._segment1:1===i?t=e._segment2:null!=i&&(t=e.getPartLength(0,i)e&&te||t=s&&n<=a,h=r>=s&&r<=a;if(o&&h)return!this.isTouching();var u=this.getCurve(),l=u&&na&&(u=u.getNext()),r>a&&(c=c.getNext()),!(l&&u&&f&&c))return!1;var d=[];o||(t(l,!0),t(u,!1)),h||(t(f,!0),t(c,!1));var _=this.getPoint(),g=Math.min.apply(Math,d),v=o?u.getTangentAtTime(n):u.getPointAt(g).subtract(_),p=o?v.negate():l.getPointAt(-g).subtract(_),m=h?c.getTangentAtTime(r):c.getPointAt(g).subtract(_),y=h?m.negate():f.getPointAt(-g).subtract(_),w=p.getAngle(),x=v.getAngle(),b=y.getAngle(),C=m.getAngle();return!!(o?e(w,b,C)^e(x,b,C)&&e(w,C,b)^e(x,C,b):e(b,w,x)^e(C,w,x)&&e(b,x,w)^e(C,x,w))},hasOverlap:function(){return!!this._overlap}},r.each(k._evaluateMethods,function(t){var e=t+"At";this[t]=function(){var t=this.getCurve(),i=this.getTime();return null!=i&&t&&t[e](i,!0)}},{preserve:!0}),new function(){function t(t,e,i){function n(i,n){for(var s=i+n;s>=-1&&s<=r;s+=n){var a=t[(s%r+r)%r];if(!e.getPoint().isClose(a.getPoint(),1e-7))break;if(e.equals(a))return a}return null}for(var r=t.length,s=0,a=r-1;s<=a;){var o,h=s+a>>>1,u=t[h];if(i&&(o=e.equals(u)?u:n(h,-1)||n(h,1)))return e._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=e.getPath(),c=u.getPath(),f=l!==c?l._id-c._id:e.getIndex()+e.getTime()-(u.getIndex()+u.getTime());f<0?a=h-1:s=h+1}return t.splice(s,0,e),e}return{statics:{insert:t,expand:function(e){for(var i=e.slice(),n=e.length-1;n>=0;n--)t(i,e[n]._intersection,!1);return i}}}}),L=x.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(t){var e,i,n;if(r.isPlainObject(t)?(i=t.segments,e=t.pathData):Array.isArray(t)?i=t:"string"==typeof t&&(e=t),i){var s=i[0];n=s&&Array.isArray(s[0])}else e&&(n=(e.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(e));var a=n?B:N;return new a(t)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(t){this.isClockwise()!=(t=!!t)&&this.reverse()},setPathData:function(t){function e(t,e){var i=+n[t];return o&&(i+=h[e]),i}function i(t){return new f(e(t,"x"),e(t+1,"y"))}var n,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new f,u=new f;this.clear();for(var l=0,c=a&&a.length;lu&&this[n?"removeSegments":"removeChildren"](u,h);for(var c=0;c=0&&e;c--){var f=i[c];e=!1;var d=u[c];if(d)for(var _=d.length-1;_>=0&&!e;_--)f.compare(n[d[_]])&&(a[d[_]]||(a[d[_]]=!0,o++),e=!0)}e=e&&o===s}return e}}),N=L.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(t){this._closed=!1,this._segments=[],this._version=0;var i=arguments,n=Array.isArray(t)?"object"==typeof t[0]?t:i:!t||t.size!==e||t.x===e&&t.point===e?null:i;n&&n.length>0?this.setSegments(n):(this._curves=e,this._segmentSelection=0,n||"string"!=typeof t||(this.setPathData(t),t=null)),this._initialize(!n&&t)},_equals:function(t){return this._closed===t._closed&&r.equals(this._segments,t._segments)},copyContent:function(t){this.setSegments(t._segments),this._closed=t._closed},_changed:function mt(t){if(mt.base.call(this,t),8&t){if(this._length=this._area=e,32&t)this._version++;else if(this._curves)for(var i=0,n=this._curves.length;i0&&(i(f[0],!0),p.push("z")),p.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(t){for(var e=this._segments,i=new Array(6),n=0,r=e.length;n0&&e+s-1===l?e-1:e,f=c,d=Math.min(c+s,l);t._curves&&(n.splice.apply(n,[c,0].concat(t._curves)),f+=t._curves.length);for(var o=f;o0?t-1:t},add:function(t){var e=arguments;return e.length>1&&"number"!=typeof t?this._add(O.readList(e)):this._add([O.read(e)])[0]},insert:function(t,e){var i=arguments;return i.length>2&&"number"!=typeof e?this._add(O.readList(i,1),t):this._add([O.read(i,1)],t)[0]},addSegment:function(){return this._add([O.read(arguments)])[0]},insertSegment:function(t){return this._add([O.read(arguments,1)],t)[0]},addSegments:function(t){return this._add(O.readList(t))},insertSegments:function(t,e){return this._add(O.readList(e),t)},removeSegment:function(t){return this.removeSegments(t,t+1)[0]||null},removeSegments:function(t,e,i){t=t||0,e=r.pick(e,this._segments.length);var n=this._segments,s=this._curves,a=n.length,o=n.splice(t,e-t),h=o.length;if(!h)return o;for(var u=0;u0&&e===a+(this._closed?1:0)?t-1:t,s=s.splice(f,h),u=s.length-1;u>=0;u--)s[u]._path=null;i&&(o._curves=s.slice(1)),this._adjustCurves(f,f)}return this._changed(41),o},clear:"#removeSegments",hasHandles:function(){for(var t=this._segments,e=0,i=t.length;e0&&this._segmentSelection===7*t},setFullySelected:function(t){t&&this._selectSegments(!0),this.setSelected(t)},setSelection:function yt(t){1&t||this._selectSegments(!1),yt.base.call(this,t)},_selectSegments:function(t){var e=this._segments,i=e.length,n=t?7:0;this._segmentSelection=n*i;for(var r=0;r0&&this.setSelected(!0)},divideAt:function(t){var e,i=this.getLocationAt(t);return i&&(e=i.getCurve().divideAt(i.getCurveOffset()))?e._segment1:null},splitAt:function(t){var e=this.getLocationAt(t),i=e&&e.index,n=e&&e.time,r=1e-8,s=1-r;n>s&&(i++,n=0);var a=this.getCurves();if(i>=0&&i=r&&a[i++].divideAtTime(n);var o,h=this.removeSegments(i,this._segments.length,!0);return this._closed?(this.setClosed(!1),o=this):(o=new N(x.NO_INSERT),o.insertAbove(this),o.copyAttributes(this)),o._add(h,0),this.addSegment(h[0]),o}return null},split:function(t,i){var n,r=i===e?t:(n=this.getCurves()[t])&&n.getLocationAtTime(i);return null!=r?this.splitAt(r):null},join:function(t,e){var i=e||0;if(t&&t!==this){var n=t._segments,r=this.getLastSegment(),s=t.getLastSegment();if(!s)return this;r&&r._point.isClose(s._point,i)&&t.reverse();var a=t.getFirstSegment();if(r&&r._point.isClose(a._point,i))r.setHandleOut(a._handleOut),this._add(n.slice(1));else{var o=this.getFirstSegment();o&&o._point.isClose(a._point,i)&&t.reverse(),s=t.getLastSegment(),o&&o._point.isClose(s._point,i)?(o.setHandleIn(s._handleIn),this._add(n.slice(0,n.length-1),0)):this._add(n.slice())}t._closed&&this._add([n[0]]),t.remove()}var h=this.getFirstSegment(),u=this.getLastSegment();return h!==u&&h._point.isClose(u._point,i)&&(h.setHandleIn(u._handleIn),u.remove(),this.setClosed(!0)),this},reduce:function(t){for(var e=this.getCurves(),i=t&&t.simplify,n=i?1e-7:0,r=e.length-1;r>=0;r--){var s=e[r];!s.hasHandles()&&(!s.hasLength(n)||i&&s.isCollinear(s.getNext()))&&s.remove()}return this},reverse:function(){this._segments.reverse();for(var t=0,e=this._segments.length;t0&&r.push(new O(i[n-1].curve.slice(6))),this.setSegments(r)},simplify:function(t){var e=new j(this).fit(t||2.5);return e&&this.setSegments(e),!!e},smooth:function(t){function i(t,e){var i=t&&t.index;if(null!=i){var r=t.path;if(r&&r!==n)throw new Error(t._class+" "+i+" of "+r+" is not part of "+n);e&&t instanceof k&&i++}else i="number"==typeof t?t:e;return Math.min(i<0&&h?i%o:i<0?i+o:i,o-1)}var n=this,r=t||{},s=r.type||"asymmetric",a=this._segments,o=a.length,h=this._closed,u=h&&r.from===e&&r.to===e,l=i(r.from,0),c=i(r.to,o-1);if(l>c)if(h)l-=o;else{var f=l;l=c,c=f}if(/^(?:asymmetric|continuous)$/.test(s)){var d="asymmetric"===s,_=Math.min,g=c-l+1,v=g-1,p=u?_(g,4):1,m=p,y=p,w=[];if(h||(m=_(1,l),y=_(1,o-c-1)),v+=m+y,v<=1)return;for(var x=0,b=l-m;x<=v;x++,b++)w[x]=a[(b<0?b+o:b)%o]._point;for(var C=w[0]._x+2*w[1]._x,S=w[0]._y+2*w[1]._y,P=2,I=v-1,M=[C],T=[S],O=[P],z=[],A=[],x=1;x=0;x--)z[x]=(M[x]-z[x+1])/O[x],A[x]=(T[x]-A[x+1])/O[x];z[v]=(3*w[v]._x-z[I])/2,A[v]=(3*w[v]._y-A[I])/2;for(var x=m,D=v-y,b=l;x<=D;x++,b++){var R=a[b<0?b+o:b],q=R._point,V=z[x]-q._x,H=A[x]-q._y;(u||xm)&&R.setHandleIn(-V,-H)}}else for(var x=l;x<=c;x++)a[x<0?x+o:x].smooth(r,!u&&x===l,!u&&x===c)},toShape:function(t){function i(t,e){var i=c[t],n=i.getNext(),r=c[e],s=r.getNext();return i._handleOut.isZero()&&n._handleIn.isZero()&&r._handleOut.isZero()&&s._handleIn.isZero()&&n._point.subtract(i._point).isCollinear(s._point.subtract(r._point))}function n(t){var e=c[t],i=e.getPrevious(),n=e.getNext();return i._handleOut.isZero()&&e._handleIn.isZero()&&e._handleOut.isZero()&&n._handleIn.isZero()&&e._point.subtract(i._point).isOrthogonal(n._point.subtract(e._point))}function r(t){var e=c[t],i=e.getNext(),n=e._handleOut,r=i._handleIn,s=.5522847498307936;if(n.isOrthogonal(r)){var a=e._point,o=i._point,h=new y(a,n,(!0)).intersect(new y(o,r,(!0)),!0);return h&&l.isZero(n.getLength()/h.subtract(a).getLength()-s)&&l.isZero(r.getLength()/h.subtract(o).getLength()-s)}return!1}function s(t,e){return c[t]._point.getDistance(c[e]._point)}if(!this._closed)return null;var a,o,h,u,c=this._segments;if(!this.hasHandles()&&4===c.length&&i(0,2)&&i(1,3)&&n(1)?(a=S.Rectangle,o=new _(s(0,3),s(0,1)),u=c[1]._point.add(c[2]._point).divide(2)):8===c.length&&r(0)&&r(2)&&r(4)&&r(6)&&i(1,5)&&i(3,7)?(a=S.Rectangle,o=new _(s(1,6),s(0,3)),h=o.subtract(new _(s(0,7),s(1,2))).divide(2),u=c[3]._point.add(c[4]._point).divide(2)):4===c.length&&r(0)&&r(1)&&r(2)&&r(3)&&(l.isZero(s(0,2)-s(1,3))?(a=S.Circle,h=s(0,2)/2):(a=S.Ellipse,h=new _(s(2,0)/2,s(3,1)/2)),u=c[1]._point),a){var f=this.getPosition(!0),d=new a({center:f,size:o,radius:h,insert:!1});return d.copyAttributes(this,!0),d._matrix.prepend(this._matrix),d.rotate(u.subtract(f).getAngle()+90),(t===e||t)&&d.insertAbove(this),d}return null},toPath:"#clone",compare:function wt(t){if(!t||t instanceof B)return wt.base.call(this,t);var e=this.getCurves(),i=t.getCurves(),n=e.length,r=i.length;if(!n||!r)return n==r;for(var s,a,o=e[0].getValues(),h=[],u=0,l=0,c=0;c0?r-1:c,a=d[0][1];break}}for(var _,g=Math.abs,v=1e-8,f=h[s];o&&f;){var d=k.getOverlaps(o,f);if(d){var p=d[0][0];if(g(p-l)=r&&(s=0),f=h[s]||i[s].getValues(),a=0),!o)return _[0]===s&&_[1]===a;continue}}}break}return!1},_hitTestSelf:function(t,e,i,n){function r(e,i){return t.subtract(e).divide(i).length<=1}function s(t,i,n){if(!e.selected||i.isSelected()){var s=t._point;if(i!==s&&(i=i.add(s)),r(i,x))return new T(n,g,{segment:t,point:i})}}function a(t,i){return(i||e.segments)&&s(t,t._point,"segment")||!i&&e.handles&&(s(t,t._handleIn,"handle-in")||s(t,t._handleOut,"handle-out"))}function o(t){f.add(t)}function h(e){var i=y||e._index>0&&e._index0||S?0:null;if(null!==P&&(P>0?(u=v.getStrokeJoin(),l=v.getStrokeCap(),c=v.getMiterLimit(),x=x.add(N._getStrokePadding(P,n))):u=l="round"),!e.ends||e.segments||y){if(e.segments||e.handles)for(var I=0;I1?h(d.getSegment())||(d=null):r(d.getPoint(),x)||(d=null)}if(!d&&"miter"===u&&m>1)for(var I=0;It)return a.getLocationAt(t-s)}if(e.length>0&&t<=this.getLength())return new A(e[e.length-1],1)}else if(t&&t.getPath&&t.getPath()===this)return t;return null},getOffsetsWithTangent:function(){var t=f.read(arguments);if(t.isZero())return[];for(var e=[],i=0,n=this.getCurves(),r=0,s=n.length;r0&&!(1&_)){var g=t.fillStyle;t.fillStyle="#ffffff",t.fillRect(s-u,a-u,h,h),t.fillStyle=g}}}function e(t,e,i){function n(e){if(i)e._transformCoordinates(i,_),r=_[0],s=_[1];else{var n=e._point;r=n._x,s=n._y}if(g)t.moveTo(r,s),g=!1;else{if(i)h=_[2],u=_[3];else{var f=e._handleIn;h=r+f._x,u=s+f._y}h===r&&u===s&&l===a&&c===o?t.lineTo(r,s):t.bezierCurveTo(l,c,h,u,r,s)}if(a=r,o=s,i)l=_[4],c=_[5];else{var f=e._handleOut;l=a+f._x,c=o+f._y}}for(var r,s,a,o,h,u,l,c,f=e._segments,d=f.length,_=new Array(6),g=!0,v=0;v0&&n(f[0])}return{_draw:function(t,i,n,r){function s(t){return c[(t%f+f)%f]}var a=i.dontStart,o=i.dontFinish||i.clip,h=this.getStyle(),u=h.hasFill(),l=h.hasStroke(),c=h.getDashArray(),f=!st.support.nativeDash&&l&&c&&c.length;if(a||t.beginPath(),(u||l&&!f||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(u||l)&&(this._setStyles(t,i,n),u&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(f){a||t.beginPath();var d,_=new E(this,.25,32,(!1),r),g=_.length,v=-h.getDashOffset(),p=0;for(v%=g;v>0;)v-=s(p--)+s(p--);for(;v0||d>0)&&_.drawPart(t,Math.max(v,0),Math.max(d,0)),v=d+s(p++)}t.stroke()}},_drawSelected:function(i,n){i.beginPath(),e(i,this,n),i.stroke(),t(i,this._segments,n,st.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 O(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new O(f.read(arguments))])},cubicCurveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),r=f.read(e),s=t(this);s.setHandleOut(i.subtract(s._point)),this._add([new O(r,n.subtract(r))])},quadraticCurveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),r=t(this)._point;this.cubicCurveTo(i.add(r.subtract(i).multiply(1/3)),i.add(n.subtract(i).multiply(1/3)),n)},curveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),s=r.pick(r.read(e),.5),a=1-s,o=t(this)._point,h=i.subtract(o.multiply(a*a)).subtract(n.multiply(s*s)).divide(2*s*a);if(h.isNaN())throw new Error("Cannot put a curve through points with parameter = "+s);this.quadraticCurveTo(h,n)},arcTo:function(){var e,i,n,s,a,o=arguments,h=Math.abs,u=Math.sqrt,c=t(this),d=c._point,g=f.read(o),v=r.peek(o),p=r.pick(v,!0);if("boolean"==typeof p)var w=d.add(g).divide(2),e=w.add(w.subtract(d).rotate(p?-90:90));else if(r.remain(o)<=2)e=g,g=f.read(o);else if(!d.equals(g)){var x=_.read(o),b=l.isZero;if(b(x.width)||b(x.height))return this.lineTo(g);var C=r.read(o),p=!!r.read(o),S=!!r.read(o),w=d.add(g).divide(2),P=d.subtract(w).rotate(-C),I=P.x,M=P.y,T=h(x.width),z=h(x.height),k=T*T,A=z*z,L=I*I,N=M*M,B=u(L/k+N/A);if(B>1&&(T*=B,z*=B,k=T*T,A=z*z),B=(k*A-k*N-A*L)/(k*N+A*L),h(B)<1e-12&&(B=0),B<0)throw new Error("Cannot create an arc with the given arguments");i=new f(T*M/z,-z*I/T).multiply((S===p?-1:1)*u(B)).rotate(C).add(w),a=(new m).translate(i).rotate(C).scale(T,z),s=a._inverseTransform(d),n=s.getDirectedAngle(a._inverseTransform(g)),!p&&n>0?n-=360:p&&n<0&&(n+=360)}if(e){var E=new y(d.add(e).divide(2),e.subtract(d).rotate(90),(!0)),j=new y(e.add(g).divide(2),g.subtract(e).rotate(90),(!0)),F=new y(d,g),D=F.getSide(e);if(i=E.intersect(j,!0),!i){if(!D)return this.lineTo(g);throw new Error("Cannot create an arc with the given arguments")}s=d.subtract(i),n=s.getDirectedAngle(g.subtract(i));var R=F.getSide(i,!0);0===R?n=D*h(n):D===R&&(n+=n<0?360:-360)}if(n){for(var q=1e-7,V=h(n),H=V>=360?4:Math.ceil((V-q)/90),Z=n/H,U=Z*Math.PI/360,W=4/3*Math.sin(U)/(1+Math.cos(U)),G=[],$=0;$<=H;$++){var P=g,J=null;if($0&&(h(t[0],y),h(t[t.length-1],y)),g},_getStrokePadding:function(t,e){if(!e)return[t,t];var i=new f(t,0).transform(e),n=new f(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),c=Math.atan2(a,u*s);return[Math.abs(s*Math.cos(l)*h+a*Math.sin(l)*o),Math.abs(a*Math.sin(c)*h+s*Math.cos(c)*o)]},_addBevelJoin:function(t,e,i,n,r,s,a,o){var h=t.getCurve(),u=h.getPrevious(),l=h.getPoint1().transform(r),c=u.getNormalAtTime(1).multiply(i).transform(s),d=h.getNormalAtTime(0).multiply(i).transform(s),_=c.getDirectedAngle(d);if((_<0||_>=180)&&(c=c.negate(),d=d.negate()),o&&a(l),a(l.add(c)),"miter"===e){var g=new y(l.add(c),new f((-c.y),c.x),(!0)).intersect(new y(l.add(d),new f((-d.y),d.x),(!0)),!0);g&&l.getDistance(g)<=n*i&&a(g)}a(l.add(d))},_addSquareCap:function(t,e,i,n,r,s,a){var o=t._point.transform(n),h=t.getLocation(),u=h.getNormal().multiply(0===h.getTime()?i:-i).transform(r);"square"===e&&(a&&(s(o.subtract(u)),s(o.add(u))),o=o.add(u.rotate(-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.SQRT2)),s=N._getStrokePadding(l,u),a=N._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,g=d,p=_,m=0,y=t.length;m_&&(_=T),Op&&(p=z)}}return new v(d,g,_-d,p-g)}}});N.inject({statics:new function(){function t(t,e,i){var n=r.getNamed(i),s=new N(n&&0==n.insert&&x.NO_INSERT);return s._add(t),s._closed=e,s.set(n,{insert:!0})}function e(e,i,r){for(var s=new Array(4),a=0;a<4;a++){var o=n[a];s[a]=new O(o._point.multiply(i).add(e),o._handleIn.multiply(i),o._handleOut.multiply(i))}return t(s,!0,r)}var i=.5522847498307936,n=[new O([-1,0],[0,i],[0,-i]),new O([0,-1],[-i,0],[i,0]),new O([1,0],[0,-i],[0,i]),new O([0,1],[i,0],[-i,0])];return{Line:function(){var e=arguments;return t([new O(f.readNamed(e,"from")),new O(f.readNamed(e,"to"))],!1,e)},Circle:function(){var t=arguments,i=f.readNamed(t,"center"),n=r.readNamed(t,"radius");return e(i,new _(n),t)},Rectangle:function(){var e,n=arguments,r=v.readNamed(n,"rectangle"),s=_.readNamed(n,"radius",0,{readNull:!0}),a=r.getBottomLeft(!0),o=r.getTopLeft(!0),h=r.getTopRight(!0),u=r.getBottomRight(!0);if(!s||s.isZero())e=[new O(a),new O(o),new O(h),new O(u)];else{s=_.min(s,r.getSize(!0).divide(2));var l=s.width,c=s.height,f=l*i,d=c*i;e=[new O(a.add(l,0),null,[-f,0]),new O(a.subtract(0,c),[0,d]),new O(o.add(0,c),null,[0,-d]),new O(o.add(l,0),[-f,0],null),new O(h.subtract(l,0),null,[f,0]),new O(h.add(0,c),[0,-d],null),new O(u.subtract(0,c),null,[0,d]),new O(u.subtract(l,0),[f,0])]}return t(e,!0,n)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=arguments,i=S._readEllipse(t);return e(i.center,i.radius,t)},Oval:"#Ellipse",Arc:function(){var t=arguments,e=f.readNamed(t,"from"),i=f.readNamed(t,"through"),n=f.readNamed(t,"to"),s=r.getNamed(t),a=new N(s&&0==s.insert&&x.NO_INSERT);return a.moveTo(e),a.arcTo(i,n),a.set(s)},RegularPolygon:function(){for(var e=arguments,i=f.readNamed(e,"center"),n=r.readNamed(e,"sides"),s=r.readNamed(e,"radius"),a=360/n,o=n%3===0,h=new f(0,o?-s:s),u=o?-1:.5,l=new Array(n),c=0;c=0;s--){var a=i[s];i!==e||a instanceof N||(i=r.slice(i)),Array.isArray(a)?i[s]=new N({segments:a,insert:!1}):a instanceof B&&(i.splice.apply(i,[s,1].concat(a.removeChildren())),a.remove())}return xt.base.call(this,t,i)},reduce:function bt(t){for(var e=this._children,i=e.length-1;i>=0;i--){var n=e[i].reduce(t);n.isEmpty()&&n.remove()}if(!e.length){var n=new N(x.NO_INSERT);return n.copyAttributes(this),n.insertAbove(this),this.remove(),n}return bt.base.call(this)},isClosed:function(){for(var t=this._children,e=0,i=t.length;e=0;_--){var g=u[_].split();g&&(a(g)&&g.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}return a(o),n(d,!1,t,e)}function u(t,e){for(var i=t;i;){if(i===e)return;i=i._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 f(t,e,i){var n=t&&t.length;if(n){var s=r.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 y(e.getArea())-y(t.getArea())}),o=a[0],u=h.findItemBoundsCollisions(a,null,l.GEOMETRIC_EPSILON);null==i&&(i=o.isClockwise());for(var c=0;c=0;p--)if(g[p]=0;g--){var v=i[g];v._path&&(_[n(v)]=!0)}for(var g=t.length-1;g>=0;g--){var p,m=t[g],y=m._time,w=y,x=e&&!e(m),v=m._curve;if(v&&(v!==s?(f=!v.hasHandles()||_&&_[n(v)],r=[],a=null,s=v):a>=h&&(y/=a)),x)r&&r.push(m);else{if(e&&o.unshift(m),a=w,yl)p=v._segment2;else{var b=v.divideAtTime(y,!0);f&&d.push(v,b),p=b._segment1;for(var C=r.length-1;C>=0;C--){var S=r[C];S._time=(S._time-y)/(1-y)}}m._setSegment(p);var P=p._intersection,I=m._intersection;if(P){u(P,I);for(var M=P;M;)u(M._intersection,P),M=M._next}else p._intersection=I}}return i||c(d),o||t}function _(t,e,i,n,r){function s(s){var a=s[c+0],h=s[c+6];if(!(gm(a,h))){var u=s[l+0],f=s[l+2],v=s[l+4],y=s[l+6];if(a===h)return void((ux||yx)&&(M=!0));var C=g===a?0:g===h?1:x>m(u,f,v,y)||b0?z[0]:1,S=0===C?u:1===C?y:k.getPoint(s,C)[i?"y":"x"],T=a>h?1:-1,A=o[c]>o[c+6]?1:-1,L=o[l+6];return g!==a?(Sb?I+=T:M=!0,S>d-w&&Sb&&(I+=T):u!=L&&(Lb?(I+=T,M=!0):L>x&&Sx&&S=p(e,n,r,a))for(var o,h=t[l+0],u=t[l+2],f=t[l+4],d=t[l+6],_=x>m(h,u,f,d)||bs.quality&&(s=T);break}c-=x}for(var p=a.length-1;p>=0;p--)a[p].segment._winding=s}function v(t,e){function i(t){var i;return!(!t||t._visited||e&&(!e[(i=t._winding||{}).winding]||e.unite&&2===i.winding&&i.windingL&&i.windingR))}function n(t){if(t)for(var e=0,i=a.length;e=0;u--){var l=h[u],f=l._path,_=l._segment,g=_.getPrevious(),p=_.getNext();t(g,f)&&t(p,f)&&(_.remove(),g._handleOut._set(0,0),p._handleIn._set(0,0),g===_||g.getCurve().hasLength()||(p._handleIn.set(g._handleIn),g.remove()))}s&&(d(a,n&&function(t){var e=t.getCurve(),i=t.getSegment(),n=t._intersection,r=n._curve,s=n._segment;return!!(e&&r&&e._path&&r._path)||(i&&(i._intersection=null),void(s&&(s._intersection=null)))},o),o&&c(o),i=v(r.each(i,function(t){r.push(this,t._segments)},[])));var m,y=i.length;return y>1&&e?(i!==e&&this.setChildren(i),m=this):1!==y||e||(i[0]!==this&&this.setSegments(i[0].removeSegments()),m=this),m||(m=new B(x.NO_INSERT),m.addChildren(i),m=m.reduce(),m.copyAttributes(this),this.replaceWith(m)),m},reorient:function(t,i){var n=this._children;return n&&n.length?this.setChildren(f(this.removeChildren(),function(e){return!!(t?e:1&e)},i)):i!==e&&this.setClockwise(i),this},getInteriorPoint:function(){var t=this.getBounds(),e=t.getCenter(!0);if(!this.contains(e)){for(var i=this.getCurves(),n=e.y,r=[],s=[],a=0,o=i.length;a=p(u,l,c,f)&&n<=m(u,l,c,f))for(var d=k.getMonoCurves(h),_=0,g=d.length;_=y&&n<=w||n>=w&&n<=y)){var x=n===y?v[0]:n===w?v[6]:1===k.solveCubic(v,1,n,s,0,1)?k.getPoint(v,s[0]).x:(v[0]+v[6])/2;r.push(x)}}}r.length>1&&(r.sort(function(t,e){return t-e}),e.x=(r[0]+r[1])/2)}return e}}});var E=r.extend({_class:"PathFlattener",initialize:function(t,e,i,n,r){function s(t,e){var i=k.getValues(t,e,r);h.push(i),a(i,t._index,0,1)}function a(t,i,r,s){if(!(s-r>c)||n&&k.isStraight(t)||k.isFlatEnough(t,e||.25)){var o=t[6]-t[0],h=t[7]-t[1],f=Math.sqrt(o*o+h*h);f>0&&(l+=f,u.push({offset:l,curve:t,index:i,time:s}))}else{var d=k.subdivide(t,.5),_=(r+s)/2;a(d[0],i,r,_),a(d[1],i,_,s)}}for(var o,h=[],u=[],l=0,c=1/(i||32),f=t._segments,d=f[0],_=1,g=f.length;_=t){this.index=e;var a=i[e-1],o=a&&a.index===s.index?a.time:0,h=a?a.offset:0;return{index:s.index,time:o+(s.time-o)*(t-h)/(s.offset-h)}}}return{index:i[n-1].index,time:1}},drawPart:function(t,e,i){for(var n=this._get(e),r=this._get(i),s=n.index,a=r.index;s<=a;s++){var o=k.getPart(this.curves[s],s===n.index?n.time:0,s===r.index?r.time:1);s===n.index&&t.moveTo(o[0],o[1]),t.bezierCurveTo.apply(t,o.slice(2))}}},r.each(k._evaluateMethods,function(t){this[t+"At"]=function(e){var i=this._get(e);return k[t](this.curves[i.index],i.time)}},{})),j=r.extend({initialize:function(t){for(var e,i=this.points=[],n=t._segments,r=t._closed,s=0,a=n.length;s0&&(n=[new O(e[0])],i>1&&(this.fitCubic(n,t,0,i-1,e[1].subtract(e[0]),e[i-2].subtract(e[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(t,e,i,n,r,s){var a=this.points;if(n-i===1){var o=a[i],h=a[n],u=o.getDistance(h)/3;return void this.addCurve(t,[o,o.add(r.normalize(u)),h.add(s.normalize(u)),h])}for(var l,c=this.chordLengthParameterize(i,n),f=Math.max(e,e*e),d=!0,_=0;_<=4;_++){var g=this.generateBezier(i,n,c,r,s),v=this.findMaxError(i,n,g,c);if(v.error=f)break;d=this.reparameterize(i,n,c,g),f=v.error}var p=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,i,l,r,p),this.fitCubic(t,e,l,n,p.negate(),s)},addCurve:function(t,e){var i=t[t.length-1];i.setHandleOut(e[1].subtract(e[0])),t.push(new O(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,i,n,r){for(var s=1e-12,a=Math.abs,o=this.points,h=o[t],u=o[e],l=[[0,0],[0,0]],c=[0,0],f=0,d=e-t+1;fs){var M=l[0][0]*c[1]-l[1][0]*c[0],T=c[0]*l[1][1]-c[1]*l[0][1];S=T/I,P=M/I}else{var O=l[0][0]+l[0][1],z=l[1][0]+l[1][1];S=P=a(O)>s?c[0]/O:a(z)>s?c[1]/z:0}var k,A,L=u.getDistance(h),N=s*L;if(SL*L&&(S=P=L/3,k=A=null)}return[h,h.add(k||n.normalize(S)),u.add(A||r.normalize(P)),u]},reparameterize:function(t,e,i,n){for(var r=t;r<=e;r++)i[r-t]=this.findRoot(n,this.points[r],i[r-t]);for(var r=1,s=i.length;r=s&&(s=u,r=a)}return{error:s,index:r}}}),F=x.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var i=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(i&&t,!i&&f.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(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),D=F.extend({_class:"PointText",initialize:function(){F.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new d(t.x,t.y,this,"setPoint")},setPoint:function(){var t=f.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=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 u=0,l=n.length;u1&&(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,i){return[.2989*t+.587*e+.114*i]},"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 r.each(n,function(t,e){s[e]=[],r.each(t,function(t,i){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][i]="gradient"===e?"gradient"===t?function(t){var e=this._components[0];return t=q.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:function(){return f.read(arguments,0,{readNull:"highlight"===t,clone:!0})}:function(t){return null==t||isNaN(t)?0:+t};this["get"+a]=function(){return this._type===e||o&&/^hs[bl]$/.test(this._type)?this._components[i]:this._convert(e)[i]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=n[e],this._type=e),this._components[i]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function l(e){var i,a,o,h,u=arguments,c=this.__read,f=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e; +}i+=a.length}return e}}),new function(){function t(t,e,i,n){function r(e){var i=l[e],n=l[e+1];s==i&&a==n||(t.beginPath(),t.moveTo(s,a),t.lineTo(i,n),t.stroke(),t.beginPath(),t.arc(i,n,o,0,2*Math.PI,!0),t.fill())}if(!(n<=0))for(var s,a,o=n/2,h=n-2,u=o-1,l=new Array(6),c=0,f=e.length;c0&&!(1&_)){var g=t.fillStyle;t.fillStyle="#ffffff",t.fillRect(s-u,a-u,h,h),t.fillStyle=g}}}function e(t,e,i){function n(e){if(i)e._transformCoordinates(i,_),r=_[0],s=_[1];else{var n=e._point;r=n._x,s=n._y}if(g)t.moveTo(r,s),g=!1;else{if(i)h=_[2],u=_[3];else{var f=e._handleIn;h=r+f._x,u=s+f._y}h===r&&u===s&&l===a&&c===o?t.lineTo(r,s):t.bezierCurveTo(l,c,h,u,r,s)}if(a=r,o=s,i)l=_[4],c=_[5];else{var f=e._handleOut;l=a+f._x,c=o+f._y}}for(var r,s,a,o,h,u,l,c,f=e._segments,d=f.length,_=new Array(6),g=!0,v=0;v0&&n(f[0])}return{_draw:function(t,i,n,r){function s(t){return c[(t%f+f)%f]}var a=i.dontStart,o=i.dontFinish||i.clip,h=this.getStyle(),u=h.hasFill(),l=h.hasStroke(),c=h.getDashArray(),f=!st.support.nativeDash&&l&&c&&c.length;if(a||t.beginPath(),(u||l&&!f||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(u||l)&&(this._setStyles(t,i,n),u&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(f){a||t.beginPath();var d,_=new E(this,.25,32,(!1),r),g=_.length,v=-h.getDashOffset(),p=0;for(v%=g;v>0;)v-=s(p--)+s(p--);for(;v0||d>0)&&_.drawPart(t,Math.max(v,0),Math.max(d,0)),v=d+s(p++)}t.stroke()}},_drawSelected:function(i,n){i.beginPath(),e(i,this,n),i.stroke(),t(i,this._segments,n,st.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 O(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new O(f.read(arguments))])},cubicCurveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),r=f.read(e),s=t(this);s.setHandleOut(i.subtract(s._point)),this._add([new O(r,n.subtract(r))])},quadraticCurveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),r=t(this)._point;this.cubicCurveTo(i.add(r.subtract(i).multiply(1/3)),i.add(n.subtract(i).multiply(1/3)),n)},curveTo:function(){var e=arguments,i=f.read(e),n=f.read(e),s=r.pick(r.read(e),.5),a=1-s,o=t(this)._point,h=i.subtract(o.multiply(a*a)).subtract(n.multiply(s*s)).divide(2*s*a);if(h.isNaN())throw new Error("Cannot put a curve through points with parameter = "+s);this.quadraticCurveTo(h,n)},arcTo:function(){var e,i,n,s,a,o=arguments,h=Math.abs,u=Math.sqrt,c=t(this),d=c._point,g=f.read(o),v=r.peek(o),p=r.pick(v,!0);if("boolean"==typeof p)var w=d.add(g).divide(2),e=w.add(w.subtract(d).rotate(p?-90:90));else if(r.remain(o)<=2)e=g,g=f.read(o);else if(!d.equals(g)){var x=_.read(o),b=l.isZero;if(b(x.width)||b(x.height))return this.lineTo(g);var C=r.read(o),p=!!r.read(o),S=!!r.read(o),w=d.add(g).divide(2),P=d.subtract(w).rotate(-C),I=P.x,M=P.y,T=h(x.width),z=h(x.height),k=T*T,A=z*z,L=I*I,N=M*M,B=u(L/k+N/A);if(B>1&&(T*=B,z*=B,k=T*T,A=z*z),B=(k*A-k*N-A*L)/(k*N+A*L),h(B)<1e-12&&(B=0),B<0)throw new Error("Cannot create an arc with the given arguments");i=new f(T*M/z,-z*I/T).multiply((S===p?-1:1)*u(B)).rotate(C).add(w),a=(new m).translate(i).rotate(C).scale(T,z),s=a._inverseTransform(d),n=s.getDirectedAngle(a._inverseTransform(g)),!p&&n>0?n-=360:p&&n<0&&(n+=360)}if(e){var E=new y(d.add(e).divide(2),e.subtract(d).rotate(90),(!0)),j=new y(e.add(g).divide(2),g.subtract(e).rotate(90),(!0)),F=new y(d,g),D=F.getSide(e);if(i=E.intersect(j,!0),!i){if(!D)return this.lineTo(g);throw new Error("Cannot create an arc with the given arguments")}s=d.subtract(i),n=s.getDirectedAngle(g.subtract(i));var R=F.getSide(i,!0);0===R?n=D*h(n):D===R&&(n+=n<0?360:-360)}if(n){for(var q=1e-7,V=h(n),H=V>=360?4:Math.ceil((V-q)/90),Z=n/H,U=Z*Math.PI/360,W=4/3*Math.sin(U)/(1+Math.cos(U)),G=[],$=0;$<=H;$++){var P=g,J=null;if($0){for(var C=1;C=180)&&(c=c.negate(),d=d.negate()),o&&a(l),a(l.add(c)),"miter"===e){var g=new y(l.add(c),new f((-c.y),c.x),(!0)).intersect(new y(l.add(d),new f((-d.y),d.x),(!0)),!0);g&&l.getDistance(g)<=n*i&&a(g)}a(l.add(d))},_addSquareCap:function(t,e,i,n,r,s,a){var o=t._point.transform(n),h=t.getLocation(),u=h.getNormal().multiply(0===h.getTime()?i:-i).transform(r);"square"===e&&(a&&(s(o.subtract(u)),s(o.add(u))),o=o.add(u.rotate(-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.SQRT2)),s=N._getStrokePadding(l,u),a=N._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,g=d,p=_,m=0,y=t.length;m_&&(_=T),Op&&(p=z)}}return new v(d,g,_-d,p-g)}}});N.inject({statics:new function(){function t(t,e,i){var n=r.getNamed(i),s=new N(n&&0==n.insert&&x.NO_INSERT);return s._add(t),s._closed=e,s.set(n,{insert:!0})}function e(e,i,r){for(var s=new Array(4),a=0;a<4;a++){var o=n[a];s[a]=new O(o._point.multiply(i).add(e),o._handleIn.multiply(i),o._handleOut.multiply(i))}return t(s,!0,r)}var i=.5522847498307936,n=[new O([-1,0],[0,i],[0,-i]),new O([0,-1],[-i,0],[i,0]),new O([1,0],[0,-i],[0,i]),new O([0,1],[i,0],[-i,0])];return{Line:function(){var e=arguments;return t([new O(f.readNamed(e,"from")),new O(f.readNamed(e,"to"))],!1,e)},Circle:function(){var t=arguments,i=f.readNamed(t,"center"),n=r.readNamed(t,"radius");return e(i,new _(n),t)},Rectangle:function(){var e,n=arguments,r=v.readNamed(n,"rectangle"),s=_.readNamed(n,"radius",0,{readNull:!0}),a=r.getBottomLeft(!0),o=r.getTopLeft(!0),h=r.getTopRight(!0),u=r.getBottomRight(!0);if(!s||s.isZero())e=[new O(a),new O(o),new O(h),new O(u)];else{s=_.min(s,r.getSize(!0).divide(2));var l=s.width,c=s.height,f=l*i,d=c*i;e=[new O(a.add(l,0),null,[-f,0]),new O(a.subtract(0,c),[0,d]),new O(o.add(0,c),null,[0,-d]),new O(o.add(l,0),[-f,0],null),new O(h.subtract(l,0),null,[f,0]),new O(h.add(0,c),[0,-d],null),new O(u.subtract(0,c),null,[0,d]),new O(u.subtract(l,0),[f,0])]}return t(e,!0,n)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=arguments,i=S._readEllipse(t);return e(i.center,i.radius,t)},Oval:"#Ellipse",Arc:function(){var t=arguments,e=f.readNamed(t,"from"),i=f.readNamed(t,"through"),n=f.readNamed(t,"to"),s=r.getNamed(t),a=new N(s&&0==s.insert&&x.NO_INSERT);return a.moveTo(e),a.arcTo(i,n),a.set(s)},RegularPolygon:function(){for(var e=arguments,i=f.readNamed(e,"center"),n=r.readNamed(e,"sides"),s=r.readNamed(e,"radius"),a=360/n,o=n%3===0,h=new f(0,o?-s:s),u=o?-1:.5,l=new Array(n),c=0;c=0;s--){var a=i[s];i!==e||a instanceof N||(i=r.slice(i)),Array.isArray(a)?i[s]=new N({segments:a,insert:!1}):a instanceof B&&(i.splice.apply(i,[s,1].concat(a.removeChildren())),a.remove())}return xt.base.call(this,t,i)},reduce:function bt(t){for(var e=this._children,i=e.length-1;i>=0;i--){var n=e[i].reduce(t);n.isEmpty()&&n.remove()}if(!e.length){var n=new N(x.NO_INSERT);return n.copyAttributes(this),n.insertAbove(this),this.remove(),n}return bt.base.call(this)},isClosed:function(){for(var t=this._children,e=0,i=t.length;e=0;_--){var g=u[_].split();g&&(a(g)&&g.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}return a(o),n(d,!1,t,e)}function u(t,e){for(var i=t;i;){if(i===e)return;i=i._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 f(t,e,i){var n=t&&t.length;if(n){var s=r.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 y(e.getArea())-y(t.getArea())}),o=a[0],u=h.findItemBoundsCollisions(a,null,l.GEOMETRIC_EPSILON);null==i&&(i=o.isClockwise());for(var c=0;c=0;p--)if(g[p]=0;g--){var v=i[g];v._path&&(_[n(v)]=!0)}for(var g=t.length-1;g>=0;g--){var p,m=t[g],y=m._time,w=y,x=e&&!e(m),v=m._curve;if(v&&(v!==s?(f=!v.hasHandles()||_&&_[n(v)],r=[],a=null,s=v):a>=h&&(y/=a)),x)r&&r.push(m);else{if(e&&o.unshift(m),a=w,yl)p=v._segment2;else{var b=v.divideAtTime(y,!0);f&&d.push(v,b),p=b._segment1;for(var C=r.length-1;C>=0;C--){var S=r[C];S._time=(S._time-y)/(1-y)}}m._setSegment(p);var P=p._intersection,I=m._intersection;if(P){u(P,I);for(var M=P;M;)u(M._intersection,P),M=M._next}else p._intersection=I}}return i||c(d),o||t}function _(t,e,i,n,r){function s(s){var a=s[c+0],h=s[c+6];if(!(gm(a,h))){var u=s[l+0],f=s[l+2],v=s[l+4],y=s[l+6];if(a===h)return void((ux||yx)&&(M=!0));var C=g===a?0:g===h?1:x>m(u,f,v,y)||b0?z[0]:1,S=0===C?u:1===C?y:k.getPoint(s,C)[i?"y":"x"],T=a>h?1:-1,A=o[c]>o[c+6]?1:-1,L=o[l+6];return g!==a?(Sb?I+=T:M=!0,S>d-w&&Sb&&(I+=T):u!=L&&(Lb?(I+=T,M=!0):L>x&&Sx&&S=p(e,n,r,a))for(var o,h=t[l+0],u=t[l+2],f=t[l+4],d=t[l+6],_=x>m(h,u,f,d)||bs.quality&&(s=T);break}c-=x}for(var p=a.length-1;p>=0;p--)a[p].segment._winding=s}function v(t,e){function i(t){var i;return!(!t||t._visited||e&&(!e[(i=t._winding||{}).winding]||e.unite&&2===i.winding&&i.windingL&&i.windingR))}function n(t){if(t)for(var e=0,i=a.length;e=0;u--){var l=h[u],f=l._path,_=l._segment,g=_.getPrevious(),p=_.getNext();t(g,f)&&t(p,f)&&(_.remove(),g._handleOut._set(0,0),p._handleIn._set(0,0),g===_||g.getCurve().hasLength()||(p._handleIn.set(g._handleIn),g.remove()))}s&&(d(a,n&&function(t){var e=t.getCurve(),i=t.getSegment(),n=t._intersection,r=n._curve,s=n._segment;return!!(e&&r&&e._path&&r._path)||(i&&(i._intersection=null),void(s&&(s._intersection=null)))},o),o&&c(o),i=v(r.each(i,function(t){r.push(this,t._segments)},[])));var m,y=i.length;return y>1&&e?(i!==e&&this.setChildren(i),m=this):1!==y||e||(i[0]!==this&&this.setSegments(i[0].removeSegments()),m=this),m||(m=new B(x.NO_INSERT),m.addChildren(i),m=m.reduce(),m.copyAttributes(this),this.replaceWith(m)),m},reorient:function(t,i){var n=this._children;return n&&n.length?this.setChildren(f(this.removeChildren(),function(e){return!!(t?e:1&e)},i)):i!==e&&this.setClockwise(i),this},getInteriorPoint:function(){var t=this.getBounds(),e=t.getCenter(!0);if(!this.contains(e)){for(var i=this.getCurves(),n=e.y,r=[],s=[],a=0,o=i.length;a=p(u,l,c,f)&&n<=m(u,l,c,f))for(var d=k.getMonoCurves(h),_=0,g=d.length;_=y&&n<=w||n>=w&&n<=y)){var x=n===y?v[0]:n===w?v[6]:1===k.solveCubic(v,1,n,s,0,1)?k.getPoint(v,s[0]).x:(v[0]+v[6])/2;r.push(x)}}}r.length>1&&(r.sort(function(t,e){return t-e}),e.x=(r[0]+r[1])/2)}return e}}});var E=r.extend({_class:"PathFlattener",initialize:function(t,e,i,n,r){function s(t,e){var i=k.getValues(t,e,r);h.push(i),a(i,t._index,0,1)}function a(t,i,r,s){if(!(s-r>c)||n&&k.isStraight(t)||k.isFlatEnough(t,e||.25)){var o=t[6]-t[0],h=t[7]-t[1],f=Math.sqrt(o*o+h*h);f>0&&(l+=f,u.push({offset:l,curve:t,index:i,time:s}))}else{var d=k.subdivide(t,.5),_=(r+s)/2;a(d[0],i,r,_),a(d[1],i,_,s)}}for(var o,h=[],u=[],l=0,c=1/(i||32),f=t._segments,d=f[0],_=1,g=f.length;_=t){this.index=e;var a=i[e-1],o=a&&a.index===s.index?a.time:0,h=a?a.offset:0;return{index:s.index,time:o+(s.time-o)*(t-h)/(s.offset-h)}}}return{index:i[n-1].index,time:1}},drawPart:function(t,e,i){for(var n=this._get(e),r=this._get(i),s=n.index,a=r.index;s<=a;s++){var o=k.getPart(this.curves[s],s===n.index?n.time:0,s===r.index?r.time:1);s===n.index&&t.moveTo(o[0],o[1]),t.bezierCurveTo.apply(t,o.slice(2))}}},r.each(k._evaluateMethods,function(t){this[t+"At"]=function(e){var i=this._get(e);return k[t](this.curves[i.index],i.time)}},{})),j=r.extend({initialize:function(t){for(var e,i=this.points=[],n=t._segments,r=t._closed,s=0,a=n.length;s0&&(n=[new O(e[0])],i>1&&(this.fitCubic(n,t,0,i-1,e[1].subtract(e[0]),e[i-2].subtract(e[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(t,e,i,n,r,s){var a=this.points;if(n-i===1){var o=a[i],h=a[n],u=o.getDistance(h)/3;return void this.addCurve(t,[o,o.add(r.normalize(u)),h.add(s.normalize(u)),h])}for(var l,c=this.chordLengthParameterize(i,n),f=Math.max(e,e*e),d=!0,_=0;_<=4;_++){var g=this.generateBezier(i,n,c,r,s),v=this.findMaxError(i,n,g,c);if(v.error=f)break;d=this.reparameterize(i,n,c,g),f=v.error}var p=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,i,l,r,p),this.fitCubic(t,e,l,n,p.negate(),s)},addCurve:function(t,e){var i=t[t.length-1];i.setHandleOut(e[1].subtract(e[0])),t.push(new O(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,i,n,r){for(var s=1e-12,a=Math.abs,o=this.points,h=o[t],u=o[e],l=[[0,0],[0,0]],c=[0,0],f=0,d=e-t+1;fs){var M=l[0][0]*c[1]-l[1][0]*c[0],T=c[0]*l[1][1]-c[1]*l[0][1];S=T/I,P=M/I}else{var O=l[0][0]+l[0][1],z=l[1][0]+l[1][1];S=P=a(O)>s?c[0]/O:a(z)>s?c[1]/z:0}var k,A,L=u.getDistance(h),N=s*L;if(SL*L&&(S=P=L/3,k=A=null)}return[h,h.add(k||n.normalize(S)),u.add(A||r.normalize(P)),u]},reparameterize:function(t,e,i,n){for(var r=t;r<=e;r++)i[r-t]=this.findRoot(n,this.points[r],i[r-t]);for(var r=1,s=i.length;r=s&&(s=u,r=a)}return{error:s,index:r}}}),F=x.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var i=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(i&&t,!i&&f.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(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),D=F.extend({_class:"PointText",initialize:function(){F.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new d(t.x,t.y,this,"setPoint")},setPoint:function(){var t=f.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=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 u=0,l=n.length;u1&&(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,i){return[.2989*t+.587*e+.114*i]},"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 r.each(n,function(t,e){s[e]=[],r.each(t,function(t,i){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][i]="gradient"===e?"gradient"===t?function(t){var e=this._components[0];return t=q.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:function(){return f.read(arguments,0,{readNull:"highlight"===t,clone:!0})}:function(t){return null==t||isNaN(t)?0:+t};this["get"+a]=function(){return this._type===e||o&&/^hs[bl]$/.test(this._type)?this._components[i]:this._convert(e)[i]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=n[e],this._type=e),this._components[i]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function l(e){var i,a,o,h,u=arguments,c=this.__read,f=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e; if("string"===d&&e in n&&(i=e,e=u[1],Array.isArray(e)?(a=e,o=u[2]):(c&&(f=1),u=r.slice(u,1),d=typeof e)),!a){if(h="number"===d?u:"object"===d&&null!=e.length?e:null){i||(i=h.length>=3?"rgb":"gray");var _=n[i].length;o=h[_],c&&(f+=h===arguments?_+(null!=o?1:0):1),h.length>_&&(h=r.slice(h,0,_))}else if("string"===d){var g=t(e);i=g[0],a=g[1],4===a.length&&(o=a[3],a.length--)}else if("object"===d)if(e.constructor===l){if(i=e._type,a=e._components.slice(),o=e._alpha,"gradient"===i)for(var v=1,p=a.length;v1?1:t))}var i=this._convert("rgb"),n=t||null==this._alpha?1:this._alpha;return i=[e(i[0]),e(i[1]),e(i[2])],n<1&&i.push(n<0?0:n),t?"#"+((1<<24)+(i[0]<<16)+(i[1]<<8)+i[2]).toString(16).slice(1):(4==i.length?"rgba(":"rgb(")+i.join(",")+")"},toCanvasStyle:function(t,e){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var i,n=this._components,r=n[0],s=r._stops,a=n[1],o=n[2],h=n[3],u=e&&e.inverted();if(u&&(a=u._transformPoint(a),o=u._transformPoint(o),h&&(h=u._transformPoint(h))),r._radial){var l=o.getDistance(a);if(h){var c=h.subtract(a);c.getLength()>l&&(h=a.add(c.normalize(l-.1)))}var f=h||a;i=t.createRadialGradient(f.x,f.y,0,a.x,a.y,l)}else i=t.createLinearGradient(a.x,a.y,o.x,o.y);for(var d=0,_=s.length;d<_;d++){var g=s[d],v=g._offset;i.addColorStop(null==v?d/(_-1):v,g._color.toCanvasStyle())}return this._canvasStyle=i},transform:function(t){if("gradient"===this._type){for(var e=this._components,i=1,n=e.length;i0&&!(e instanceof B);if(s)for(var a=0,o=r.length;a0&&!(a instanceof B);if(u&&!t)for(var l=0,_=o.length;l<_;l++){var g=o[l]._style[d]();if(l){if(!r.equals(s,g))return e}else s=g}else if(i in this._defaults){var s=this._values[i];if(s===e)s=this._defaults[i],s&&s.clone&&(s=s.clone());else{var v=n?R:h?f:null;!v||s&&s.constructor===v||(this._values[i]=s=v.read([s],0,{readNull:!0,clone:!0}))}}return s&&n&&(s=R._setOwner(s,a,u&&c)),s},a[d]=function(t){return this._style[d](t)},a[c]=function(t){this._style[c](t)}}),r.each({Font:"FontFamily",WindingRule:"FillRule"},function(t,e){var i="get"+e,n="set"+e;o[i]=a[i]="#get"+t,o[n]=a[n]="#set"+t}),x.inject(a),o},{set:function(t){var e=t instanceof H,i=e?t._values:t;if(i)for(var n in i)if(n in this._defaults){var r=i[n];this[n]=r&&e&&r.clone?r.clone():r}},equals:function(t){function i(t,i,n){var s=t._values,a=i._values,o=i._defaults;for(var h in s){var u=s[h],l=a[h];if(!(n&&h in a||r.equals(u,l===e?o[h]:l)))return!1}return!0}return t===this||t&&this._class===t._class&&i(this,t)&&i(t,this,!0)||!1},_dispose:function(){var t;t=this.getFillColor(),t&&(t._canvasStyle=null),t=this.getStrokeColor(),t&&(t._canvasStyle=null),t=this.getShadowColor(),t&&(t._canvasStyle=null)},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 St(){var t=St.base.call(this),e=this.getFontSize();return/pt|em|%|px/.test(e)&&(e=this.getView().getPixelSize(e)),null!=t?t:1.2*e}}),Z=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 v(o,h,i.width,i.height)},getViewportBounds:function(t){var e=t.ownerDocument,i=e.defaultView,n=e.documentElement;return new v(0,0,i.innerWidth||n.clientWidth,i.innerHeight||n.clientHeight)},getOffset:function(t,e){return Z.getBounds(t,e).getPoint()},getSize:function(t){return Z.getBounds(t,!0).getSize()},isInvisible:function(t){return Z.getSize(t).equals(new _(0,0))},isInView:function(t){return!Z.isInvisible(t)&&Z.getViewportBounds(t).intersects(Z.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)}}},U={add:function(t,e){if(t)for(var i in e)for(var r=e[i],s=i.split(/[\s,]+/g),a=0,o=s.length;a1?r.hyphenate(i):i.toLowerCase())}function s(t,e,i,n){var o,h=W._focused;if(l[e]=t,t?c[e]=i:delete c[e],e.length>1&&(o=r.camelize(e))in f){f[o]=t;var u=st&&st.agent;if("meta"===o&&u&&u.mac)if(t)a={};else{for(var d in a)d in c&&s(!1,d,a[d],n);a=null}}else t&&a&&(a[e]=i);h&&h._handleKeyEvent(t?"keydown":"keyup",n,e,i)}var a,o,h={"\t":"tab"," ":"space","\b":"backspace","\x7f":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},u={tab:"\t",space:" ",enter:"\r"},l={},c={},f=new r({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var t=st&&st.agent;return t&&t.mac?this.meta:this.control}}});return U.add(n,{keydown:function(e){var i=t(e),n=st&&st.agent;i.length>1||n&&n.chrome&&(e.altKey||n.mac&&e.metaKey||!n.mac&&e.ctrlKey)?s(!0,i,u[i]||(i.length>1?"":i),e):o=i},keypress:function(e){if(o){var i=t(e),n=e.charCode,r=n>=32?String.fromCharCode(n):i.length>1?"":i;i!==o&&(i=r.toLowerCase()),s(!0,i,r,e),o=null}},keyup:function(e){var i=t(e);i in c&&s(!1,i,c[i],e)}}),U.add(i,{blur:function(t){for(var e in c)s(!1,e,c[e],t)}}),{modifiers:f,isDown:function(t){return!!l[t]}}},Q=$.extend({_class:"MouseEvent",initialize:function(t,e,i,n,r){this.type=t,this.event=e,this.point=i,this.target=n,this.delta=r},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),X=$.extend({_class:"ToolEvent",_item:null,initialize:function(t,e,i){this.tool=t,this.type=e,this.event=i},_choosePoint:function(t,e){return t?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,i=e._parent;/^(Group|CompoundPath)$/.test(i._class);)e=i,i=i._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()+" }"}}),Y=(o.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(t){o.call(this),this._moveCount=-1,this._downCount=-1,this.set(t)},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=0&&r.equals(s))return!1;if(s&&(null!=t||null!=e)){var o=r.subtract(s),h=o.getLength();if(h<(t||0))return!1;e&&(r=s.add(o.normalize(Math.min(h,e))))}c._moveCount++}return c._point=r,c._lastPoint=s||r,n.down&&(c._moveCount=-1,c._downPoint=r,c._downCount++),!0}function s(){o&&(l=c.emit(t,new X(c,t,e))||l)}st=this._scope,n.drag&&!this.responds(t)&&(t="mousemove");var a=n.move||n.drag,o=this.responds(t),h=this.minDistance,u=this.maxDistance,l=!1,c=this;if(n.down)r(),s();else if(n.up)r(null,u),s();else if(o)for(;r(h,u);)s();return l}}),r.extend(s,{_class:"Tween",statics:{easings:{linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:-1+2*(2-t)*t},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}}},initialize:function Ot(t,e,i,n,r,s){this.object=t;var a=typeof r,o="function"===a;this.type=o?a:"string"===a?r:"linear",this.easing=o?r:Ot.easings[this.type],this.duration=n,this.running=!1,this._then=null,this._startTime=null;var h=e||i;this._keys=h?Object.keys(h):[],this._parsedKeys=this._parseKeys(this._keys),this._from=h&&this._getState(e),this._to=h&&this._getState(i),s!==!1&&this.start()},then:function(t){return this._then=t,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(t){if(this.running){t>1&&(t=1,this.running=!1);for(var e=this.easing(t),i=this._keys,n=function(i){return"function"==typeof i?i(e,t):i},s=0,a=i&&i.length;s255){var u=255-r,l=o-r;d=r+(d-r)*u/l,_=r+(_-r)*u/l,g=r+(g-r)*u/l}}function i(t,e,i){return p(t,e,i)-v(t,e,i)}function n(t,e,i,n){var r,s=[t,e,i],a=p(t,e,i),o=v(t,e,i);o=o===t?0:o===e?1:2,a=a===t?0:a===e?1:2,r=0===v(o,a)?1===p(o,a)?2:1:0,s[a]>s[o]?(s[r]=(s[r]-s[o])*n/(s[a]-s[o]),s[a]=n):s[r]=s[a]=0,s[o]=0,d=s[0],_=s[1],g=s[2]}var s,a,o,h,u,l,c,f,d,_,g,v=Math.min,p=Math.max,m=Math.abs,y={multiply:function(){d=u*s/255,_=l*a/255,g=c*o/255},screen:function(){d=u+s-u*s/255,_=l+a-l*a/255,g=c+o-c*o/255},overlay:function(){d=u<128?2*u*s/255:255-2*(255-u)*(255-s)/255,_=l<128?2*l*a/255:255-2*(255-l)*(255-a)/255,g=c<128?2*c*o/255:255-2*(255-c)*(255-o)/255},"soft-light":function(){var t=s*u/255;d=t+u*(255-(255-u)*(255-s)/255-t)/255,t=a*l/255,_=t+l*(255-(255-l)*(255-a)/255-t)/255,t=o*c/255,g=t+c*(255-(255-c)*(255-o)/255-t)/255},"hard-light":function(){d=s<128?2*s*u/255:255-2*(255-s)*(255-u)/255,_=a<128?2*a*l/255:255-2*(255-a)*(255-l)/255,g=o<128?2*o*c/255:255-2*(255-o)*(255-c)/255},"color-dodge":function(){d=0===u?0:255===s?255:v(255,255*u/(255-s)),_=0===l?0:255===a?255:v(255,255*l/(255-a)),g=0===c?0:255===o?255:v(255,255*c/(255-o))},"color-burn":function(){d=255===u?255:0===s?0:p(0,255-255*(255-u)/s),_=255===l?255:0===a?0:p(0,255-255*(255-l)/a),g=255===c?255:0===o?0:p(0,255-255*(255-c)/o)},darken:function(){d=us?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,d<0&&(d=-d),_=l-a,_<0&&(_=-_),g=c-o,g<0&&(g=-g)},exclusion:function(){d=u+s*(255-u-u)/255,_=l+a*(255-l-l)/255,g=c+o*(255-c-c)/255},hue:function(){n(s,a,o,i(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){n(u,l,c,i(s,a,o)),e(d,_,g,t(u,l,c))},luminosity:function(){e(u,l,c,t(s,a,o))},color:function(){e(s,a,o,t(u,l,c))},add:function(){d=v(u+s,255),_=v(l+a,255),g=v(c+o,255)},subtract:function(){d=p(u-s,0),_=p(l-a,0),g=p(c-o,0)},average:function(){d=(u+s)/2,_=(l+a)/2,g=(c+o)/2},negation:function(){d=255-m(255-s-u),_=255-m(255-a-l),g=255-m(255-o-c)}},w=this.nativeModes=r.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=et.getContext(1,1);x&&(r.each(y,function(t,e){var i="darken"===e,n=!1;x.save();try{x.fillStyle=i?"#300":"#a00",x.fillRect(0,0,1,1),x.globalCompositeOperation=e,x.globalCompositeOperation===e&&(x.fillStyle=i?"#a00":"#300",x.fillRect(0,0,1,1),n=x.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(r){}x.restore(),w[e]=n}),et.release(x)),this.process=function(t,e,i,n,r){var v=e.canvas,p="normal"===t;if(p||w[t])i.save(),i.setTransform(1,0,0,1,0,0),i.globalAlpha=n,p||(i.globalCompositeOperation=t),i.drawImage(v,r.x,r.y),i.restore();else{var m=y[t];if(!m)return;for(var x=i.getImageData(r.x,r.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,P=b.length;S=2&&!t.hasHandles())if(h>2){s=t._closed?"polygon":"polyline";for(var l=[],c=0;c 0) { - addCap(segments[0], cap); - addCap(segments[segments.length - 1], cap); + if (length > 0) { + for (var i = 1; i < length; i++) { + addJoin(segments[i], join); + } + if (closed) { + addJoin(segments[0], join); + } else { + addCap(segments[0], cap); + addCap(segments[segments.length - 1], cap); + } } return bounds; }, diff --git a/dist/paper-full.min.js b/dist/paper-full.min.js index faa22683..b28b5960 100644 --- a/dist/paper-full.min.js +++ b/dist/paper-full.min.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Sat May 23 14:48:39 2020 +0200 + * Date: Sat May 23 14:54:51 2020 +0200 * *** * @@ -33,7 +33,7 @@ var paper=function(t,e){t=t||require("./node/self.js");var n=t.window,i=t.docume 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)}}))}),m=r.extend({_class:"Matrix",initialize:function lt(t,e){var n=arguments,i=n.length,r=!0;if(i>=6?this._set.apply(this,n):1===i||2===i?t instanceof lt?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,e):Array.isArray(t)?this._set.apply(this,e?t.concat([e]):t):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 r.serialize(this.getValues(),t,!0,e)},_changed:function(){var t=this._owner;t&&(t._applyMatrix?t.transform(null,!0):t._changed(25))},clone:function(){return new m(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=u.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,r.pick(t,!0),e),this.isIdentity())},translate:function(){var t=f.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=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0});return n&&this.translate(n),this._a*=e.x,this._b*=e.x,this._c*=e.y,this._d*=e.y,n&&this.translate(n.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=f.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,u=this._b,l=this._c,c=this._d;return this._a=r*h+s*l,this._b=r*u+s*c,this._c=-s*h+r*l,this._d=-s*u+r*c,this._tx+=a*h+o*l,this._ty+=a*u+o*c,this._changed(),this},shear:function(){var t=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0});n&&this.translate(n);var i=this._a,r=this._b;return this._a+=e.y*this._c,this._b+=e.y*this._d,this._c+=e.x*i,this._d+=e.x*r,n&&this.translate(n.negate()),this._changed(),this},skew:function(){var t=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0}),i=Math.PI/180,r=new f(Math.tan(e.x*i),Math.tan(e.y*i));return this.shear(r,n)},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,u=t._d,l=t._tx,c=t._ty;this._a=a*n+h*r,this._c=o*n+u*r,this._b=a*i+h*s,this._d=o*i+u*s,this._tx+=l*n+c*r,this._ty+=l*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,u=t._c,l=t._b,c=t._d,f=t._tx,d=t._ty;this._a=h*n+u*i,this._c=h*r+u*s,this._b=l*n+c*i,this._d=l*r+c*s,this._tx=h*a+u*o+f,this._ty=l*a+c*o+d,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 m(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(f.read(arguments)):this._transformCoordinates(t,e,n)},_transformPoint:function(t,e,n){var i=t.x,r=t.y;return e||(e=new f),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;is[h]&&(s[h]=o)}return e||(e=new v),e._set(r[0],r[1],s[0]-r[0],s[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(f.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,u=i*a-r*s,l=null;if(u&&!isNaN(u)&&isFinite(o)&&isFinite(h)){var c=t.x-this._tx,d=t.y-this._ty;e||(e=new f),l=e._set((c*a-d*s)/u,(d*i-c*r)/u,n)}return l},decompose:function(){var t,e,n,i=this._a,r=this._b,s=this._c,a=this._d,o=i*a-r*s,h=Math.sqrt,u=Math.atan2,l=180/Math.PI;if(0!==i||0!==r){var c=h(i*i+r*r);t=Math.acos(i/c)*(r>0?1:-1),e=[c,o/c],n=[u(i*s+r*a,c*c),0]}else if(0!==s||0!==a){var d=h(s*s+a*a);t=Math.asin(s/d)*(a>0?1:-1),e=[o/d,d],n=[0,u(i*s+r*a,d*d)]}else t=0,n=e=[0,0];return{translation:this.getTranslation(),rotation:t*l,scaling:new f(e),skewing:new f(n[0]*l,n[1]*l)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new f(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)}},r.each(["a","b","c","d","tx","ty"],function(t){var e=r.capitalize(t),n="_"+t;this["get"+e]=function(){return this[n]},this["set"+e]=function(t){this[n]=t,this._changed()}},{})),y=r.extend({_class:"Line",initialize:function(t,e,n,i,r){var s=!1;arguments.length>=4?(this._px=t,this._py=e,this._vx=n,this._vy=i,s=r):(this._px=t.x,this._py=t.y,this._vx=e.x,this._vy=e.y,s=n),s||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new f(this._px,this._py)},getVector:function(){return new f(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return y.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return y.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 y.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0)},isCollinear:function(t){return f.isCollinear(this._vx,this._vy,t._vx,t._vy)},isOrthogonal:function(t){return f.isOrthogonal(this._vx,this._vy,t._vx,t._vy)},statics:{intersect:function(t,e,n,i,r,s,a,o,h,u){h||(n-=t,i-=e,a-=r,o-=s);var c=n*o-i*a;if(!l.isMachineZero(c)){var d=t-r,_=e-s,g=(a*_-o*d)/c,v=(n*_-i*d)/c,p=1e-12,m=-p,y=1+p;if(u||m=1?1:g),new f(t+g*n,e+g*i)}},getSide:function(t,e,n,i,r,s,a,o){a||(n-=t,i-=e);var h=r-t,u=s-e,c=h*i-u*n;return!o&&l.isMachineZero(c)&&(c=(h*n+h*n)/(n*n+i*i),c>=0&&c<=1&&(c=0)),c<0?-1:c>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)/(i>n?i*Math.sqrt(1+n*n/(i*i)):n*Math.sqrt(1+i*i/(n*n)))},getDistance:function(t,e,n,i,r,s,a){return Math.abs(y.getSignedDistance(t,e,n,i,r,s,a))}}}),w=o.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(t){o.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new U(null,null,this),this._view=W.create(this,t||nt.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(t,e){return r.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 ct(){return!!ct.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 C({project:this,insert:!0})},getSymbolDefinitions:function(){var t=[],e={};return this.getItems({"class":I,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;e0){t.save(),t.strokeWidth=1;var h=this._selectionItems,u=this._scope.settings.handleSize,l=this._updateVersion;for(var c in h)h[c]._drawSelection(t,e,u,h,l);t.restore()}}}),x=r.extend(s,{statics:{extend:function ft(t){return t._serializeFields&&(t._serializeFields=r.set({},this.prototype._serializeFields,t._serializeFields)),ft.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 m,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 r.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(){},_initialize:function(t,n){var i=t&&r.isPlainObject(t),s=i&&t.internal===!0,a=this._matrix=new m,o=i&&t.project||at.project,h=at.settings;return this._id=s?null:c.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&h.applyMatrix,n&&a.translate(n),a._owner=this,this._style=new U(o._currentStyle,this,o),s||i&&0==t.insert||!h.insertItems&&(!i||t.insert!==!0)?this._setProject(o):(i&&t.parent||o)._insertItem(e,this,!0),i&&t!==x.NO_INSERT&&this.set(t,{internal:!0,insert:!0,project:!0,parent:!0}),i},_serialize:function(t,e){function n(n){for(var a in n){var o=s[a];r.equals(o,"leading"===a?1.2*n.fontSize:n[a])||(i[a]=r.serialize(o,t,"data"!==a,e))}}var i={},s=this;return n(this._serializeFields),this instanceof b||n(this._style._defaults),[this._class,i]},_changed:function(t){var n=this._symbol,i=this._parent||n,r=this._project;8&t&&(this._bounds=this._position=this._decomposed=e),16&t&&(this._globalMatrix=e),i&&72&t&&x._clearBoundsCache(i),2&t&&x._clearBoundsCache(this),r&&r._changed(t,this),n&&n._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 n=this._getOwner();if(t&&n){var i=n._children,r=n._namedChildren;(r[t]=r[t]||[]).push(this),t in i||(i[t]=this)}this._name=t||e,this._changed(256)},getStyle:function(){return this._style},setStyle:function(t){this.getStyle().set(t)}},r.each(["locked","visible","blendMode","opacity","guide"],function(t){var e=r.capitalize(t),n="_"+t,i={locked:256,visible:265};this["get"+e]=function(){return this[n]},this["set"+e]=function(e){e!=this[n]&&(this[n]=e,this._changed(i[t]||257))}},{}),{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(257))}},_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=0;n--)if(e[n].contains(t))return!0;return!1}return t.isInside(this.getInternalBounds())},isInside:function(){return v.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new E.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(t,e){return t instanceof x&&this._asPathItem().getIntersections(t._asPathItem(),null,e,!0).length>0}},new function(){function t(){var t=arguments;return this._hitTest(f.read(t),M.getOptions(t))}function e(){var t=arguments,e=f.read(t),n=M.getOptions(t),i=[];return this._hitTest(e,new r({all:i},n)),i}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 w.inject({hitTest:t,hitTestAll:e,_hitTest:n}),{hitTest:t,hitTestAll:e,_hitTestChildren:n}},{_hitTest:function(t,e,n){function i(t){return t&&d&&!d(t)&&(t=null),t&&e.all&&e.all.push(t),t}function s(e,n){var i=n?l["get"+n]():g.getPosition();if(t.subtract(i).divide(u).length<=1)return new M(e,g,{name:n?r.hyphenate(n):e,point:i})}if(this._locked||!this._visible||this._guide&&!e.guides||this.isEmpty())return null;var a=this._matrix,o=n?n.appended(a):this.getGlobalMatrix().prepend(this.getView()._matrix),h=Math.max(e.tolerance,1e-12),u=e._tolerancePadding=new _(E._getStrokePadding(h,a._shiftless().invert()));if(t=a._inverseTransform(t),!t||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(u.multiply(2))._containsPoint(t))return null;var l,c,f=!(e.guides&&!this._guide||e.selected&&!this.isSelected()||e.type&&e.type!==r.hyphenate(this._class)||e["class"]&&!(this instanceof e["class"])),d=e.match,g=this,v=e.position,p=e.center,m=e.bounds;if(f&&this._parent&&(v||p||m)){if((p||m)&&(l=this.getInternalBounds()),c=v&&s("position")||p&&s("center","Center"),!c&&m)for(var y=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],w=0;w<8&&!c;w++)c=s("bounds",y[w]);c=i(c)}return c||(c=this._hitTestChildren(t,e,o)||f&&i(this._hitTestSelf(t,e,o,this.getStrokeScaling()?null:o._shiftless().invert()))||null),c&&c.point&&(c.point=a.transform(c.point)),c},_hitTestSelf:function(t,e){if(e.fill&&this.hasFill()&&this._contains(t))return new M("fill",this)},matches:function(t,e){function n(t,e){for(var i in t)if(t.hasOwnProperty(i)){var s=t[i],a=e[i];if(r.isPlainObject(s)&&r.isPlainObject(a)){if(!n(s,a))return!1}else if(!r.equals(s,a))return!1}return!0}var i=typeof t;if("object"===i){for(var s in t)if(t.hasOwnProperty(s)&&!this.matches(s,t[s]))return!1;return!0}if("function"===i)return t(this);if("match"===t)return e(this);var a=/^(empty|editable)$/.test(t)?this["is"+r.capitalize(t)]():"type"===t?r.hyphenate(this._class):this[t];if("class"===t){if("function"==typeof e)return this instanceof e;a=this._class}if("function"==typeof e)return!!e(a);if(e){if(e.test)return e.test(a);if(r.isPlainObject(e))return n(e,a)}return r.equals(a,e)},getItems:function(t){return x._getItems(this,t,this._matrix)},getItem:function(t){return x._getItems(this,t,this._matrix,null,!0)[0]||null},statics:{_getItems:function _t(t,e,n,i,s){if(!i){var a="object"==typeof e&&e,o=a&&a.overlapping,h=a&&a.inside,u=o||h,l=u&&v.read([u]);i={items:[],recursive:a&&a.recursive!==!1,inside:!!h,overlapping:!!o,rect:l,path:o&&new E.Rectangle({rectangle:l,insert:!1})},a&&(e=r.filter({},e,{recursive:!0,inside:!0,overlapping:!0}))}var c=t._children,f=i.items,l=i.rect;n=l&&(n||new m);for(var d=0,_=c&&c.length;d<_;d++){var g=c[d],p=n&&n.appended(g._matrix),y=!0;if(l){var u=g.getBounds(p);if(!l.intersects(u))continue;l.contains(u)||i.overlapping&&(u.contains(l)||i.path.intersects(g,p))||(y=!1)}if(y&&g.matches(e)&&(f.push(g),s))break;if(i.recursive!==!1&&_t(g,e,p,i,s),s&&f.length>0)break}return f}}},{importJSON:function(t){var e=r.importJSON(t,this);return e!==this?this.addChild(e):e},addChild:function(t){return this.insertChild(e,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){e=r.slice(e);for(var i={},s=e.length-1;s>=0;s--){var a=e[s],o=a&&a._id;!a||i[o]?e.splice(s,1):(a._remove(!1,!0),i[o]=!0)}r.splice(n,e,t,0);for(var h=this._project,u=h._changes,s=0,l=e.length;s=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;t0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(t){return this._getOrder(t)===-1},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}},r.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var n=arguments,i=(e?r:f).read(n),s=f.read(n,0,{readNull:!0});return this.transform((new m)[t](i,s||this.getPosition(!0)))}},{translate:function(){var t=new m;return this.transform(t.translate.apply(t,arguments))},transform:function(t,e,n){var i=this._matrix,r=t&&!t.isIdentity(),s=n&&this._canApplyMatrix||this._applyMatrix&&(r||!i.isIdentity()||e&&this._children);if(!r&&!s)return this;if(r){!t.isInvertible()&&i.isInvertible()&&(i._backup=i.getValues()),i.prepend(t,!0);var a=this._style,o=a.getFillColor(!0),h=a.getStrokeColor(!0);o&&o.transform(t),h&&h.transform(t)}if(s&&(s=this._transformContent(i,e,n))){var u=this._pivot;u&&i._transformPoint(u,u,!0),i.reset(!0),n&&this._canApplyMatrix&&(this._applyMatrix=!0)}var l=this._bounds,c=this._position;(r||s)&&this._changed(25);var f=r&&l&&t.decompose();if(f&&f.skewing.isZero()&&f.rotation%90===0){for(var d in l){var _=l[d];if(_.nonscaling)delete l[d];else if(s||!_.internal){var g=_.rect;t._transformBounds(g,g)}}this._bounds=l;var v=l[this._getBoundsCacheKey(this._boundsOptions||{})];v&&(this._position=this._getPositionFromBounds(v.rect))}else r&&c&&this._pivot&&(this._position=t._transformPoint(c,c));return this},_transformContent:function(t,e,n){var i=this._children;if(i){for(var r=0,s=i.length;rr:i1&&s<4?-1:1,s>2?-1:1),o=a.multiply(r),h=o.subtract(a.multiply(i)),u=new v(n?o.add(a.multiply(n)):o,h);if(u.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 n(e){if("rectangle"===this._type){var i=t(this,e);return i?e.subtract(i.point).divide(this._radius).getLength()<=1:n.base.call(this,e)}return e.divide(this.size).getLength()<=.5},_hitTestSelf:function i(n,r,s,a){var o=!1,h=this._style,u=r.stroke&&h.hasStroke(),l=r.fill&&h.hasFill();if(u||l){var c=this._type,f=this._radius,d=u?h.getStrokeWidth()/2:0,_=r._tolerancePadding.add(E._getStrokePadding(d,!h.getStrokeScaling()&&a));if("rectangle"===c){var g=_.multiply(2),p=t(this,n,g);if(p)o=e(n.subtract(p.point),f,_,p.quadrant);else{var m=new v(this._size).setCenter(0,0),y=m.expand(g),w=m.expand(g.negate());o=y._containsPoint(n)&&!w._containsPoint(n)}}else o=e(n,f,_)}return o?new M(u?"stroke":"fill",this):i.base.apply(this,arguments)}}},{statics:new function(){function t(t,e,n,i,s){var a=r.create(S.prototype);return a._type=t,a._size=n,a._radius=i,a._initialize(r.getNamed(s),e),a}return{Circle:function(){var e=arguments,n=f.readNamed(e,"center"),i=r.readNamed(e,"radius");return t("circle",n,new _(2*i),i,e)},Rectangle:function(){var e=arguments,n=v.readNamed(e,"rectangle"),i=_.min(_.readNamed(e,"radius"),n.getSize(!0).divide(2));return t("rectangle",n.getCenter(!0),n.getSize(!0),i,e)},Ellipse:function(){var e=arguments,n=S._readEllipse(e),i=n.radius;return t("ellipse",n.center,i.multiply(2),i,e)},_readEllipse:function(t){var e,n;if(r.hasNamed(t,"radius"))e=f.readNamed(t,"center"),n=_.readNamed(t,"radius");else{var i=v.readNamed(t,"rectangle");e=i.getCenter(!0),n=i.getSize(!0).divide(2)}return{center:e,radius:n}}}}}),k=x.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:!0,beans:!0,initialize:function(t,n){if(!this._initialize(t,n!==e&&f.read(arguments))){var r,s=typeof t,a="string"===s?i.getElementById(t):"object"===s?t:null;if(a&&a!==x.NO_INSERT)if(a.getContext||null!=a.naturalHeight)r=a;else if(a){var o=_.read(arguments);o.isZero()||(r=nt.getCanvas(o))}r?this.setImage(r):this.setSource(t)}this._size||(this._size=new _,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=nt.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 g(t?t.width:0,t?t.height:0,this,"setSize")},setSize:function(){var t=_.read(arguments);if(!t.equals(this._size))if(t.width>0&&t.height>0){var e=this.getElement();this._setImage(nt.getCanvas(t)),e&&this.getContext(!0).drawImage(e,0,0,t.width,t.height)}else this._canvas&&nt.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 f(0,0).transform(t),n=new f(1,0).transform(t).subtract(e),i=new f(0,1).transform(t).subtract(e);return new _(72/n.getLength(),72/i.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(t){function e(t){var e=n.getView(),i=t&&t.type||"load";e&&n.responds(i)&&(at=e._scope,n.emit(i,new G(t)))}var n=this;this._setImage(t),this._loaded?setTimeout(e,0):t&&Z.add(t,{load:function(i){n._setImage(t),e(i)},error:e})},_setImage:function(t){this._canvas&&nt.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 _(t?t.naturalWidth||t.width:0,t?t.naturalHeight||t.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var t=nt.getContext(this._size);try{this._image&&t.drawImage(this._image,0,0),this._canvas=t.canvas}catch(e){nt.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(1025)),this._context},setContext:function(t){this._context=t},getSource:function(){var t=this._image;return t&&t.src||this.toDataURL()},setSource:function(e){var n=new t.Image,i=this._crossOrigin;i&&(n.crossOrigin=i),e&&(n.src=e),this.setImage(n)},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)},getSmoothing:function(){return this._smoothing},setSmoothing:function(t){this._smoothing=t,this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var t=v.read(arguments),e=nt.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=v.read(arguments),e=new k(x.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=f.read(arguments,1);this.getContext(!0).drawImage(t,e.x,e.y)},getAverageColor:function(t){var e,n;if(t?t instanceof L?(n=t,e=t.getBounds()):"object"==typeof t&&("width"in t?e=new v(t):"x"in t&&(e=new v(t.x-.5,t.y-.5,1,1))):e=this.getBounds(),!e)return null;var i=32,s=Math.min(e.width,i),a=Math.min(e.height,i),o=k._sampleContext;o?o.clearRect(0,0,i+1,i+1):o=k._sampleContext=nt.getContext(new _(i)),o.save();var h=(new m).scale(s/e.width,a/e.height).translate(-e.x,-e.y);h.applyToContext(o),n&&n.draw(o,new r({clip:!0,matrices:[h]})),this._matrix.applyToContext(o);var u=this.getElement(),l=this._size;u&&o.drawImage(u,-l.width/2,-l.height/2),o.restore();for(var c=o.getImageData(.5,.5,Math.ceil(s),Math.ceil(a)).data,f=[0,0,0],d=0,g=0,p=c.length;g0&&i.height>0&&(t.globalAlpha=this._opacity,this._setStyles(t,e,n),H.setPrefixed(t,"imageSmoothingEnabled",this._smoothing),t.drawImage(i,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),I=x.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(t,n){this._initialize(t,n!==e&&f.read(arguments,1))||this.setDefinition(t instanceof P?t:new P(t))},_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=e.extend({all:!1}),r=this._definition._item._hitTest(t,i,n);return r&&(r.item=this),r},_draw:function(t,e){this._definition._item.draw(t,e)}}),P=r.extend({_class:"SymbolDefinition",initialize:function(t,e){this._id=c.get(),this.project=at.project,t&&this.setItem(t,e)},_serialize:function(t,e){return e.add(this,function(){return r.serialize([this._class,this._item],t,!1,e)})},_changed:function(t){8&t&&x._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 f),t._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(t){return new I(this,t)},clone:function(){return new P(this._item.clone(!1))},equals:function(t){return t===this||t&&this._item.equals(t._item)||!1}}),M=r.extend({_class:"HitResult",initialize:function(t,e,n){this.type=t,this.item=e,n&&this.inject(n)},statics:{getOptions:function(t){var e=t&&r.read(t);return new r({type:null,tolerance:at.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),A=r.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(t,n,i,r,s,a){var o,h,u,l,c=arguments.length;c>0&&(null==t||"object"==typeof t?1===c&&t&&"point"in t?(o=t.point,h=t.handleIn,u=t.handleOut,l=t.selection):(o=t,h=n,u=i,l=r):(o=[t,n],h=i!==e?[i,r]:null,u=s!==e?[s,a]:null)),new T(o,this,"_point"),new T(h,this,"_handleIn"),new T(u,this,"_handleOut"),l&&this.setSelection(l)},_serialize:function(t,e){var n=this._point,i=this._selection,s=i||this.hasHandles()?[n,this._handleIn,this._handleOut]:n;return i&&s.push(i),r.serialize(s,t,!0,e)},_changed:function(t){var e=this._path;if(e){var n,i=e._curves,r=this._index;i&&(t&&t!==this._point&&t!==this._handleIn||!(n=r>0?i[r-1]:e._closed?i[i.length-1]:null)||n._changed(),t&&t!==this._point&&t!==this._handleOut||!(n=i[r])||n._changed()),e._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(f.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(f.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(f.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(257))},_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!==e?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 z(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,n,i){var r=t||{},s=r.type,a=r.factor,o=this.getPrevious(),h=this.getNext(),u=(o||this)._point,l=this._point,c=(h||this)._point,d=u.getDistance(l),_=l.getDistance(c);if(s&&"catmull-rom"!==s){if("geometric"!==s)throw new Error("Smoothing method '"+s+"' not supported.");if(o&&h){var g=u.subtract(c),v=a===e?.4:a,p=v*d/(d+_);n||this.setHandleIn(g.multiply(p)),i||this.setHandleOut(g.multiply(p-v))}}else{var m=a===e?.5:a,y=Math.pow(d,m),w=y*y,x=Math.pow(_,m),b=x*x;if(!n&&o){var C=2*b+3*x*y+w,S=3*x*(x+y);this.setHandleIn(0!==S?new f((b*u._x+C*l._x-w*c._x)/S-l._x,(b*u._y+C*l._y-w*c._y)/S-l._y):new f)}if(!i&&h){var C=2*w+3*y*x+b,S=3*y*(y+x);this.setHandleOut(0!==S?new f((w*c._x+C*l._x-b*u._x)/S-l._x,(w*c._y+C*l._y-b*u._y)/S-l._y):new f)}}},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 A(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new A(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,u=e._handleOut,l=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*l._x+r*u._x,i*l._y+r*u._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}}),T=f.extend({initialize:function(t,n,i){var r,s,a;if(t)if((r=t[0])!==e)s=t[1];else{var o=t;(r=o.x)===e&&(o=f.read(arguments),r=o.x),s=o.y,a=o.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=l.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}}),O=r.extend({_class:"Curve",beans:!0,initialize:function(t,e,n,i,r,s,a,o){var h,u,l,c,f,d,_=arguments.length;3===_?(this._path=t,h=e,u=n):_?1===_?"segment1"in t?(h=new A(t.segment1),u=new A(t.segment2)):"point1"in t?(l=t.point1,f=t.handle1,d=t.handle2,c=t.point2):Array.isArray(t)&&(l=[t[0],t[1]],c=[t[6],t[7]],f=[t[2]-t[0],t[3]-t[1]],d=[t[4]-t[6],t[5]-t[7]]):2===_?(h=new A(t),u=new A(e)):4===_?(l=t,f=e,d=n,c=i):8===_&&(l=[t,e],c=[a,o],f=[n-t,i-e],d=[r-a,s-o]):(h=new A,u=new A),this._segment1=h||new A(l,null,f),this._segment2=u||new A(c,d,null)},_serialize:function(t,e){return r.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],t,!0,e)},_changed:function(){this._length=this._bounds=e},clone:function(){return new O(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 O.classify(this.getValues())},remove:function(){var t=!1;if(this._path){var e=this._segment2,n=e._handleOut;t=e.remove(),t&&this._segment1._handleOut.set(n)}return t},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(f.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(f.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(f.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(f.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 O.getValues(this._segment1,this._segment2,t)},getPoints:function(){for(var t=this.getValues(),e=[],n=0;n<8;n+=2)e.push(new f(t[n],t[n+1]));return e}},{getLength:function(){return null==this._length&&(this._length=O.getLength(this.getValues(),0,1)),this._length},getArea:function(){return O.getArea(this.getValues())},getLine:function(){return new y(this._segment1._point,this._segment2._point)},getPart:function(t,e){return new O(O.getPart(this.getValues(),t,e))},getPartLength:function(t,e){return O.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=1-n,r=null;if(t>=n&&t<=i){var s=O.subdivide(this.getValues(),t),a=s[0],o=s[1],h=e||this.hasHandles(),u=this._segment1,l=this._segment2,c=this._path;h&&(u._handleOut._set(a[2]-a[0],a[3]-a[1]),l._handleIn._set(o[4]-o[6],o[5]-o[7]));var d=a[6],_=a[7],g=new A(new f(d,_),h&&new f(a[4]-d,a[5]-_),h&&new f(o[2]-d,o[3]-_));c?(c.insert(u._index+1,g),r=this.getNext()):(this._segment2=g,this._changed(),r=new O(g,l))}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,n){return this.divideAtTime(t===e?.5:n?t:this.getTimeAt(t))},split:function(t,n){return this.splitAtTime(t===e?.5:n?t:this.getTimeAt(t))},reversed:function(){return new O(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,u=r.y,l=o.x,c=o.y,f=i?[h,u,h,u,l,c,l,c]:[h,u,h+s._x,u+s._y,l+a._x,c+a._y,l,c];return n&&n._transformCoordinates(f,f,4),f},subdivide:function(t,n){var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],h=t[5],u=t[6],l=t[7];n===e&&(n=.5);var c=1-n,f=c*i+n*s,d=c*r+n*a,_=c*s+n*o,g=c*a+n*h,v=c*o+n*u,p=c*h+n*l,m=c*f+n*_,y=c*d+n*g,w=c*_+n*v,x=c*g+n*p,b=c*m+n*w,C=c*y+n*x;return[[i,r,f,d,m,y,b,C],[b,C,w,x,v,p,u,l]]},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||O.isStraight(t))n.push(t);else{var h=3*(s-a)-r+o,u=2*(r+a)-4*s,c=s-r,f=1e-8,d=1-f,_=[],g=l.solveQuadratic(h,u,c,_,f,d);if(g){_.sort();var v=_[0],p=O.subdivide(t,v);n.push(p[0]),g>1&&(v=(_[1]-v)/(1-v),p=O.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],u=t[e+6],c=0;if(!(an&&u>n&&o>n&&h>n)){var f=3*(o-a),d=3*(h-o)-f,_=u-a-f-d;c=l.solveCubic(_,d,f,a-n,i,r,s)}return c},getTimeOf:function(t,e){var n=new f(t[0],t[1]),i=new f(t[6],t[7]),r=1e-12,s=1e-7,a=e.isClose(n,r)?0:e.isClose(i,r)?1:null;if(null===a)for(var o=[e.x,e.y],h=[],u=0;u<2;u++)for(var l=O.solveCubic(t,u,o[u],h,0,1),c=0;c=0&&n<=1){var i=e.getDistance(O.getPoint(t,n),!0);if(i.999999999999?1:O.getTimeOf(t,new f(i+l*o,r+l*h))}for(var c=100,d=1/0,_=0,g=0;g<=c;g++)n(g/c);for(var v=1/(2*c);v>1e-8;)n(_-v)||n(_+v)||(v/=2);return _},getPart:function(t,e,n){var i=e>n;if(i){var r=e;e=n,n=r}return e>0&&(t=O.subdivide(t,e)[1]),n<1&&(t=O.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],u=t[7],l=3*r-2*n-h,c=3*s-2*i-u,f=3*a-2*h-n,d=3*o-2*u-i;return Math.max(l*l,f*f)+Math.max(c*c,d*d)<=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++)O._addBounds(t[r],t[r+2],t[r+4],t[r+6],r,0,e,n,i);return new v(e[0],e[1],n[0]-e[0],n[1]-e[1])},_addBounds:function(t,e,n,i,r,s,a,o,h){function u(t,e){var n=t-e,i=t+e;no[r]&&(o[r]=i)}s/=2;var c=a[r]-s,f=o[r]+s;if(tf||e>f||n>f||i>f)if(e=0&&h<=1&&u<=0&&u>=-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 f(i,r),new f(e[2]-i,e[3]-r),new f(e[4]-s,e[5]-a),new f(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 z(this,t):null},getTimeAt:function(t,e){return O.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var t=f.read(arguments);return t.isZero()?[]:O.getTimesWithTangent(this.getValues(),t)},getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(f.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return O.getTimeOf(this.getValues(),f.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=f.read(arguments),e=this.getValues(),n=O.getNearestTime(e,t),i=O.getPoint(e,n);return new z(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 r.each(t,function(t){this[t+"At"]=function(e,n){var i=this.getValues();return O[t](i,n?e:O.getTimeAt(i,e))},this[t+"AtTime"]=function(e){return O[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=t[6],h=t[7],u=9*(i-s)+3*(o-e),l=6*(e+s)-12*i,c=3*(i-e),f=9*(r-a)+3*(h-n),d=6*(n+a)-12*r,_=3*(r-n);return function(t){var e=(u*t+l)*t+c,n=(f*t+d)*t+_;return Math.sqrt(e*e+n*n)}}function n(t,e){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(e-t))))}function i(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],u=t[5],c=t[6],d=t[7],_=l.isZero;_(a-r)&&_(o-s)&&(a=r,o=s),_(h-c)&&_(u-d)&&(h=c,u=d);var g,v,p=3*(a-r),m=3*(h-a)-p,y=c-r-p-m,w=3*(o-s),x=3*(u-o)-w,b=d-s-w-x;if(0===n)g=0===e?r:1===e?c:((y*e+m)*e+p)*e+r,v=0===e?s:1===e?d:((b*e+x)*e+w)*e+s;else{var C=1e-8,S=1-C;if(eS?(g=3*(c-h),v=3*(d-u)):(g=(3*y*e+2*m)*e+p,v=(3*b*e+2*x)*e+w),i){0===g&&0===v&&(eS)&&(g=h-a,v=u-o);var k=Math.sqrt(g*g+v*v);k&&(g/=k,v/=k)}if(3===n){var h=6*y*e+2*m,u=6*b*e+2*x,I=Math.pow(g*g+v*v,1.5);g=0!==I?(g*u-v*h)/I:0,v=0}}return 2===n?new f(v,(-g)):new f(g,v)}return{statics:{classify:function(t){function n(t,n,i){var r=n!==e,s=r&&n>0&&n<1,a=r&&i>0&&i<1;return!r||(s||a)&&("loop"!==t||s&&a)||(t="arch",s=a=!1),{type:t,roots:s||a?s&&a?n0?Math.sqrt(b/3):Math.sqrt(-b),S=2*p;return n(b>0?x:"loop",(v+C)/S,(v-C)/S)},getLength:function(i,r,s,a){if(r===e&&(r=0),s===e&&(s=1),O.isStraight(i)){var o=i;s<1&&(o=O.subdivide(o,s)[0],r/=s),r>0&&(o=O.subdivide(o,r)[1]);var h=o[6]-o[0],u=o[7]-o[1];return Math.sqrt(h*h+u*u)}return l.integrate(a||t(i),r,s,n(r,s))},getTimeAt:function(i,r,s){function a(t){return p+=l.integrate(d,s,t,n(s,t)),s=t,p-r}if(s===e&&(s=r<0?1:0),0===r)return s;var o=Math.abs,h=1e-12,u=r>0,c=u?s:0,f=u?1:s,d=t(i),_=O.getLength(i,c,f,d),g=o(r)-_;if(o(g)h)return null;var v=r/_,p=0;return l.findRoot(a,d,s+v,c,f,32,1e-12)},getPoint:function(t,e){return i(t,e,0,!1)},getTangent:function(t,e){return i(t,e,1,!0)},getWeightedTangent:function(t,e){return i(t,e,1,!1)},getNormal:function(t,e){return i(t,e,2,!0)},getWeightedNormal:function(t,e){return i(t,e,2,!1)},getCurvature:function(t,e){return i(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=t[6],h=t[7],u=-e+3*i-3*s+o,c=3*e-6*i+3*s,f=-3*e+3*i,d=-n+3*r-3*a+h,_=3*n-6*r+3*a,g=-3*n+3*r,v=1e-8,p=1-v,m=[];return l.solveCubic(9*(u*u+d*d),9*(u*c+_*d),2*(c*c+_*_)+3*(f*u+g*d),f*c+_*g,m,v,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,u=1e-8,l=1-u;if(null!==i&&i>=(o?u:0)&&i<=(h?l:1)&&null!==s&&s>=(h?u:0)&&s<=(o?l:1)){var c=new z(n,i,null,a),f=new z(r,s,null,a);c._intersection=f,f._intersection=c,e&&!e(c)||z.insert(t,c,!0)}}function e(r,s,a,o,h,u,l,c,f,d,_,g,v){if(++f>=4096||++c>=40)return f;var p,m,w=1e-9,x=s[0],b=s[1],C=s[6],S=s[7],k=y.getSignedDistance,I=k(x,b,C,S,s[2],s[3]),P=k(x,b,C,S,s[4],s[5]),M=I*P>0?.75:4/9,A=M*Math.min(0,I,P),T=M*Math.max(0,I,P),z=k(x,b,C,S,r[0],r[1]),L=k(x,b,C,S,r[2],r[3]),E=k(x,b,C,S,r[4],r[5]),N=k(x,b,C,S,r[6],r[7]),B=n(z,L,E,N),F=B[0],j=B[1];if(0===I&&0===P&&0===z&&0===L&&0===E&&0===N||null==(p=i(F,j,A,T))||null==(m=i(F.reverse(),j.reverse(),A,T)))return f;var R=d+(_-d)*p,D=d+(_-d)*m;if(Math.max(v-g,D-R).8)if(D-R>U){var H=O.subdivide(r,.5),q=(R+D)/2;f=e(s,H[0],o,a,h,u,!l,c,f,g,v,R,q),f=e(s,H[1],o,a,h,u,!l,c,f,g,v,q,D)}else{var H=O.subdivide(s,.5),V=(g+v)/2;f=e(H[0],r,o,a,h,u,!l,c,f,g,V,R,D),f=e(H[1],r,o,a,h,u,!l,c,f,V,v,R,D)}else f=0===U||U>=w?e(s,r,o,a,h,u,!l,c,f,g,v,R,D):e(r,s,a,o,h,u,l,c,f,R,D,g,v)}return f}function n(t,e,n,i){var r,s=[0,t],a=[1/3,e],o=[2/3,n],h=[1,i],u=e-(2*t+i)/3,l=n-(t+2*i)/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 i(t,e,n,i){return t[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=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=l.isZero;if(s(i)&&s(r)){var a=O.getTimeOf(t,new f(e,n));return null===a?[]:[a]}for(var o=Math.atan2(-r,i),h=Math.sin(o),u=Math.cos(o),c=[],d=[],_=0;_<8;_+=2){var g=t[_]-e,v=t[_+1]-n;c.push(g*u-v*h,g*h+v*u)}return O.solveCubic(c,1,0,d,0,1),d}function a(e,n,i,r,a,o,h){for(var u=n[0],l=n[1],c=n[6],f=n[7],d=s(e,u,l,c-u,f-l),_=0,g=d.length;_c(i[0],i[2],i[4],i[6])&&c(n[0],n[2],n[4],n[6])-lc(i[1],i[3],i[5],i[7])&&c(n[1],n[3],n[5],n[7])-l>1,S=1&v,k=6*C,I=6*S,P=new f(n[k],n[k+1]),M=new f(i[I],i[I+1]);P.isClose(M,l)&&t(h,u,r,C,s,S)}}}return h}function c(e,n,i,r){var s=O.classify(e);if("loop"===s.type){var a=s.roots;t(i,r,n,a[0],n,a[1])}return i}function d(t,e,n,i,r,s){var a=1e-7,o=!e;o&&(e=t);for(var l=t.length,f=e.length,d=new Array(l),_=o?d:new Array(f),g=[],v=0;vm){var S=e[C],k=_[C];u(w,k,y,S,g,n)}}}return g}function _(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=y.getDistance,s=1e-8,a=1e-7,o=O.isStraight(t),h=O.isStraight(e),u=o&&h,l=n(t)>1,k=O.getTimeOf(m[b],new f(m[C][S?6:0],m[C][S?7:1]));if(null!=k){var I=b?[S,k]:[k,S];(!w.length||i(I[0]-w[0][0])>s&&i(I[1]-w[0][1])>s)&&w.push(I)}if(x>2&&!w.length)break}if(2!==w.length)w=null;else if(!u){var P=O.getPart(t,w[0][0],w[1][0]),M=O.getPart(e,w[0][1],w[1][1]);(i(M[2]-P[2])>a||i(M[3]-P[3])>a||i(M[4]-P[4])>a||i(M[5]-P[5])>a)&&(w=null)}return w}function g(t,e){var n=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],h=t[6],u=t[7],c=e.normalize(),f=c.x,d=c.y,_=3*h-9*a+9*r-3*n,g=3*u-9*o+9*s-3*i,v=6*a-12*r+6*n,p=6*o-12*s+6*i,m=3*r-3*n,y=3*s-3*i,w=2*_*d-2*g*f,x=[];if(Math.abs(w)=0&&C<=1&&x.push(C)}}else{var S=(v*v-4*_*m)*d*d+(-2*v*p+4*g*m+4*_*y)*f*d+(p*p-4*g*y)*f*f,k=v*d-p*f;if(S>=0&&0!=w){var I=Math.sqrt(S),P=-(k+I)/w,M=(-k+I)/w;P>=0&&P<=1&&x.push(P),M>=0&&M<=1&&x.push(M)}}return x}return{getIntersections:function(t){var e=this.getValues(),n=t&&t!==this&&t.getValues();return n?u(e,n,this,t,[]):c(e,this,[])},statics:{getOverlaps:_,getIntersections:d,getCurveLineIntersections:s,getTimesWithTangent:g}}}),z=r.extend({_class:"CurveLocation",initialize:function(t,e,n,i,r){if(e>=.99999999){var s=t.getNext();s&&(e=0,t=s)}this._setCurve(t),this._time=e,this._point=n||t.getPointAtTime(e),this._overlap=i,this._distance=r,this._intersection=this._next=this._previous=null},_setPath:function(t){this._path=t,this._version=t?t._version:0},_setCurve:function(t){this._setPath(t._path),this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){var e=t.getCurve();e?this._setCurve(e):(this._setPath(t._path),this._segment1=t,this._segment2=null),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&&te||t=s&&i<=a,h=r>=s&&r<=a;if(o&&h)return!this.isTouching();var u=this.getCurve(),l=u&&ia&&(u=u.getNext()),r>a&&(c=c.getNext()),!(l&&u&&f&&c))return!1;var d=[];o||(t(l,!0),t(u,!1)),h||(t(f,!0),t(c,!1));var _=this.getPoint(),g=Math.min.apply(Math,d),v=o?u.getTangentAtTime(i):u.getPointAt(g).subtract(_),p=o?v.negate():l.getPointAt(-g).subtract(_),m=h?c.getTangentAtTime(r):c.getPointAt(g).subtract(_),y=h?m.negate():f.getPointAt(-g).subtract(_),w=p.getAngle(),x=v.getAngle(),b=y.getAngle(),C=m.getAngle();return!!(o?e(w,b,C)^e(x,b,C)&&e(w,C,b)^e(x,C,b):e(b,w,x)^e(C,w,x)&&e(b,x,w)^e(C,x,w))},hasOverlap:function(){return!!this._overlap}},r.each(O._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){function i(n,i){for(var s=n+i;s>=-1&&s<=r;s+=i){var a=t[(s%r+r)%r];if(!e.getPoint().isClose(a.getPoint(),1e-7))break;if(e.equals(a))return a}return null}for(var r=t.length,s=0,a=r-1;s<=a;){var o,h=s+a>>>1,u=t[h];if(n&&(o=e.equals(u)?u:i(h,-1)||i(h,1)))return e._overlap&&(o._overlap=o._intersection._overlap=!0),o;var l=e.getPath(),c=u.getPath(),f=l!==c?l._id-c._id:e.getIndex()+e.getTime()-(u.getIndex()+u.getTime());f<0?a=h-1:s=h+1}return t.splice(s,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}}}}),L=x.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(t){var e,n,i;if(r.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));var a=i?N:E;return new a(t)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(t){this.isClockwise()!=(t=!!t)&&this.reverse()},setPathData:function(t){function e(t,e){var n=+i[t];return o&&(n+=h[e]),n}function n(t){return new f(e(t,"x"),e(t+1,"y"))}var i,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new f,u=new f;this.clear();for(var l=0,c=a&&a.length;lu&&this[i?"removeSegments":"removeChildren"](u,h);for(var c=0;c=0&&e;c--){var f=n[c];e=!1;var d=u[c];if(d)for(var _=d.length-1;_>=0&&!e;_--)f.compare(i[d[_]])&&(a[d[_]]||(a[d[_]]=!0,o++),e=!0)}e=e&&o===s}return e}}),E=L.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(t){this._closed=!1,this._segments=[],this._version=0;var n=arguments,i=Array.isArray(t)?"object"==typeof t[0]?t:n:!t||t.size!==e||t.x===e&&t.point===e?null:n;i&&i.length>0?this.setSegments(i):(this._curves=e,this._segmentSelection=0,i||"string"!=typeof t||(this.setPathData(t),t=null)),this._initialize(!i&&t)},_equals:function(t){return this._closed===t._closed&&r.equals(this._segments,t._segments)},copyContent:function(t){this.setSegments(t._segments),this._closed=t._closed},_changed:function yt(t){if(yt.base.call(this,t),8&t){if(this._length=this._area=e,32&t)this._version++;else if(this._curves)for(var n=0,i=this._curves.length;n0&&(n(f[0],!0),p.push("z")),p.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(t){for(var e=this._segments,n=new Array(6),i=0,r=e.length;i0&&e+s-1===l?e-1:e,f=c,d=Math.min(c+s,l);t._curves&&(i.splice.apply(i,[c,0].concat(t._curves)),f+=t._curves.length);for(var o=f;o0?t-1:t},add:function(t){var e=arguments;return e.length>1&&"number"!=typeof t?this._add(A.readList(e)):this._add([A.read(e)])[0]},insert:function(t,e){var n=arguments;return n.length>2&&"number"!=typeof e?this._add(A.readList(n,1),t):this._add([A.read(n,1)],t)[0]},addSegment:function(){return this._add([A.read(arguments)])[0]},insertSegment:function(t){return this._add([A.read(arguments,1)],t)[0]},addSegments:function(t){return this._add(A.readList(t))},insertSegments:function(t,e){return this._add(A.readList(e),t)},removeSegment:function(t){return this.removeSegments(t,t+1)[0]||null},removeSegments:function(t,e,n){t=t||0,e=r.pick(e,this._segments.length);var i=this._segments,s=this._curves,a=i.length,o=i.splice(t,e-t),h=o.length;if(!h)return o;for(var u=0;u0&&e===a+(this._closed?1:0)?t-1:t,s=s.splice(f,h),u=s.length-1;u>=0;u--)s[u]._path=null;n&&(o._curves=s.slice(1)),this._adjustCurves(f,f)}return this._changed(41),o},clear:"#removeSegments",hasHandles:function(){for(var t=this._segments,e=0,n=t.length;e0&&this._segmentSelection===7*t},setFullySelected:function(t){t&&this._selectSegments(!0),this.setSelected(t)},setSelection:function wt(t){1&t||this._selectSegments(!1),wt.base.call(this,t)},_selectSegments:function(t){var e=this._segments,n=e.length,i=t?7:0;this._segmentSelection=i*n;for(var r=0;r0&&this.setSelected(!0)},divideAt:function(t){var e,n=this.getLocationAt(t);return n&&(e=n.getCurve().divideAt(n.getCurveOffset()))?e._segment1:null},splitAt:function(t){var e=this.getLocationAt(t),n=e&&e.index,i=e&&e.time,r=1e-8,s=1-r;i>s&&(n++,i=0);var a=this.getCurves();if(n>=0&&n=r&&a[n++].divideAtTime(i);var o,h=this.removeSegments(n,this._segments.length,!0);return this._closed?(this.setClosed(!1),o=this):(o=new E(x.NO_INSERT),o.insertAbove(this),o.copyAttributes(this)),o._add(h,0),this.addSegment(h[0]),o}return null},split:function(t,n){var i,r=n===e?t:(i=this.getCurves()[t])&&i.getLocationAtTime(n);return null!=r?this.splitAt(r):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(),u=this.getLastSegment();return h!==u&&h._point.isClose(u._point,n)&&(h.setHandleIn(u._handleIn),u.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;t0&&r.push(new A(n[i-1].curve.slice(6))),this.setSegments(r)},simplify:function(t){var e=new F(this).fit(t||2.5);return e&&this.setSegments(e),!!e},smooth:function(t){function n(t,e){var n=t&&t.index;if(null!=n){var r=t.path;if(r&&r!==i)throw new Error(t._class+" "+n+" of "+r+" is not part of "+i);e&&t instanceof O&&n++}else n="number"==typeof t?t:e;return Math.min(n<0&&h?n%o:n<0?n+o:n,o-1)}var i=this,r=t||{},s=r.type||"asymmetric",a=this._segments,o=a.length,h=this._closed,u=h&&r.from===e&&r.to===e,l=n(r.from,0),c=n(r.to,o-1);if(l>c)if(h)l-=o;else{var f=l;l=c,c=f}if(/^(?:asymmetric|continuous)$/.test(s)){var d="asymmetric"===s,_=Math.min,g=c-l+1,v=g-1,p=u?_(g,4):1,m=p,y=p,w=[];if(h||(m=_(1,l),y=_(1,o-c-1)),v+=m+y,v<=1)return;for(var x=0,b=l-m;x<=v;x++,b++)w[x]=a[(b<0?b+o:b)%o]._point;for(var C=w[0]._x+2*w[1]._x,S=w[0]._y+2*w[1]._y,k=2,I=v-1,P=[C],M=[S],A=[k],T=[],z=[],x=1;x=0;x--)T[x]=(P[x]-T[x+1])/A[x],z[x]=(M[x]-z[x+1])/A[x];T[v]=(3*w[v]._x-T[I])/2,z[v]=(3*w[v]._y-z[I])/2;for(var x=m,R=v-y,b=l;x<=R;x++,b++){var D=a[b<0?b+o:b],q=D._point,V=T[x]-q._x,U=z[x]-q._y;(u||xm)&&D.setHandleIn(-V,-U)}}else for(var x=l;x<=c;x++)a[x<0?x+o:x].smooth(r,!u&&x===l,!u&&x===c)},toShape:function(t){function n(t,e){var n=c[t],i=n.getNext(),r=c[e],s=r.getNext();return n._handleOut.isZero()&&i._handleIn.isZero()&&r._handleOut.isZero()&&s._handleIn.isZero()&&i._point.subtract(n._point).isCollinear(s._point.subtract(r._point))}function i(t){var e=c[t],n=e.getPrevious(),i=e.getNext();return n._handleOut.isZero()&&e._handleIn.isZero()&&e._handleOut.isZero()&&i._handleIn.isZero()&&e._point.subtract(n._point).isOrthogonal(i._point.subtract(e._point))}function r(t){var e=c[t],n=e.getNext(),i=e._handleOut,r=n._handleIn,s=.5522847498307936;if(i.isOrthogonal(r)){var a=e._point,o=n._point,h=new y(a,i,(!0)).intersect(new y(o,r,(!0)),!0);return h&&l.isZero(i.getLength()/h.subtract(a).getLength()-s)&&l.isZero(r.getLength()/h.subtract(o).getLength()-s)}return!1}function s(t,e){return c[t]._point.getDistance(c[e]._point)}if(!this._closed)return null;var a,o,h,u,c=this._segments;if(!this.hasHandles()&&4===c.length&&n(0,2)&&n(1,3)&&i(1)?(a=S.Rectangle,o=new _(s(0,3),s(0,1)),u=c[1]._point.add(c[2]._point).divide(2)):8===c.length&&r(0)&&r(2)&&r(4)&&r(6)&&n(1,5)&&n(3,7)?(a=S.Rectangle,o=new _(s(1,6),s(0,3)),h=o.subtract(new _(s(0,7),s(1,2))).divide(2),u=c[3]._point.add(c[4]._point).divide(2)):4===c.length&&r(0)&&r(1)&&r(2)&&r(3)&&(l.isZero(s(0,2)-s(1,3))?(a=S.Circle,h=s(0,2)/2):(a=S.Ellipse,h=new _(s(2,0)/2,s(3,1)/2)),u=c[1]._point),a){var f=this.getPosition(!0),d=new a({center:f,size:o,radius:h,insert:!1});return d.copyAttributes(this,!0),d._matrix.prepend(this._matrix),d.rotate(u.subtract(f).getAngle()+90),(t===e||t)&&d.insertAbove(this),d}return null},toPath:"#clone",compare:function xt(t){if(!t||t instanceof N)return xt.base.call(this,t);var e=this.getCurves(),n=t.getCurves(),i=e.length,r=n.length;if(!i||!r)return i==r;for(var s,a,o=e[0].getValues(),h=[],u=0,l=0,c=0;c0?r-1:c,a=d[0][1];break}}for(var _,g=Math.abs,v=1e-8,f=h[s];o&&f;){var d=O.getOverlaps(o,f);if(d){var p=d[0][0];if(g(p-l)=r&&(s=0),f=h[s]||n[s].getValues(),a=0),!o)return _[0]===s&&_[1]===a;continue}}}break}return!1},_hitTestSelf:function(t,e,n,i){function r(e,n){return t.subtract(e).divide(n).length<=1}function s(t,n,i){if(!e.selected||n.isSelected()){var s=t._point;if(n!==s&&(n=n.add(s)),r(n,x))return new M(i,g,{segment:t,point:n})}}function a(t,n){return(n||e.segments)&&s(t,t._point,"segment")||!n&&e.handles&&(s(t,t._handleIn,"handle-in")||s(t,t._handleOut,"handle-out"))}function o(t){f.add(t)}function h(e){var n=y||e._index>0&&e._index0||S?0:null;if(null!==k&&(k>0?(u=v.getStrokeJoin(),l=v.getStrokeCap(),c=v.getMiterLimit(),x=x.add(E._getStrokePadding(k,i))):u=l="round"),!e.ends||e.segments||y){if(e.segments||e.handles)for(var I=0;I1?h(d.getSegment())||(d=null):r(d.getPoint(),x)||(d=null)}if(!d&&"miter"===u&&m>1)for(var I=0;It)return a.getLocationAt(t-s)}if(e.length>0&&t<=this.getLength())return new z(e[e.length-1],1)}else if(t&&t.getPath&&t.getPath()===this)return t;return null},getOffsetsWithTangent:function(){var t=f.read(arguments);if(t.isZero())return[];for(var e=[],n=0,i=this.getCurves(),r=0,s=i.length;r0&&!(1&_)){var g=t.fillStyle;t.fillStyle="#ffffff",t.fillRect(s-u,a-u,h,h),t.fillStyle=g}}}function e(t,e,n){function i(e){if(n)e._transformCoordinates(n,_),r=_[0],s=_[1];else{var i=e._point;r=i._x,s=i._y}if(g)t.moveTo(r,s),g=!1;else{if(n)h=_[2],u=_[3];else{var f=e._handleIn;h=r+f._x,u=s+f._y}h===r&&u===s&&l===a&&c===o?t.lineTo(r,s):t.bezierCurveTo(l,c,h,u,r,s)}if(a=r,o=s,n)l=_[4],c=_[5];else{var f=e._handleOut;l=a+f._x,c=o+f._y}}for(var r,s,a,o,h,u,l,c,f=e._segments,d=f.length,_=new Array(6),g=!0,v=0;v0&&i(f[0])}return{_draw:function(t,n,i,r){function s(t){return c[(t%f+f)%f]}var a=n.dontStart,o=n.dontFinish||n.clip,h=this.getStyle(),u=h.hasFill(),l=h.hasStroke(),c=h.getDashArray(),f=!at.support.nativeDash&&l&&c&&c.length;if(a||t.beginPath(),(u||l&&!f||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(u||l)&&(this._setStyles(t,n,i),u&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(f){a||t.beginPath();var d,_=new B(this,.25,32,(!1),r),g=_.length,v=-h.getDashOffset(),p=0;for(v%=g;v>0;)v-=s(p--)+s(p--);for(;v0||d>0)&&_.drawPart(t,Math.max(v,0),Math.max(d,0)),v=d+s(p++)}t.stroke()}},_drawSelected:function(n,i){n.beginPath(),e(n,this,i),n.stroke(),t(n,this._segments,i,at.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 A(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new A(f.read(arguments))])},cubicCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=f.read(e),s=t(this);s.setHandleOut(n.subtract(s._point)),this._add([new A(r,i.subtract(r))])},quadraticCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=t(this)._point;this.cubicCurveTo(n.add(r.subtract(n).multiply(1/3)),n.add(i.subtract(n).multiply(1/3)),i)},curveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),s=r.pick(r.read(e),.5),a=1-s,o=t(this)._point,h=n.subtract(o.multiply(a*a)).subtract(i.multiply(s*s)).divide(2*s*a);if(h.isNaN())throw new Error("Cannot put a curve through points with parameter = "+s);this.quadraticCurveTo(h,i)},arcTo:function(){var e,n,i,s,a,o=arguments,h=Math.abs,u=Math.sqrt,c=t(this),d=c._point,g=f.read(o),v=r.peek(o),p=r.pick(v,!0);if("boolean"==typeof p)var w=d.add(g).divide(2),e=w.add(w.subtract(d).rotate(p?-90:90));else if(r.remain(o)<=2)e=g,g=f.read(o);else if(!d.equals(g)){var x=_.read(o),b=l.isZero;if(b(x.width)||b(x.height))return this.lineTo(g);var C=r.read(o),p=!!r.read(o),S=!!r.read(o),w=d.add(g).divide(2),k=d.subtract(w).rotate(-C),I=k.x,P=k.y,M=h(x.width),T=h(x.height),O=M*M,z=T*T,L=I*I,E=P*P,N=u(L/O+E/z);if(N>1&&(M*=N,T*=N,O=M*M,z=T*T),N=(O*z-O*E-z*L)/(O*E+z*L),h(N)<1e-12&&(N=0),N<0)throw new Error("Cannot create an arc with the given arguments");n=new f(M*P/T,-T*I/M).multiply((S===p?-1:1)*u(N)).rotate(C).add(w),a=(new m).translate(n).rotate(C).scale(M,T),s=a._inverseTransform(d),i=s.getDirectedAngle(a._inverseTransform(g)),!p&&i>0?i-=360:p&&i<0&&(i+=360)}if(e){var B=new y(d.add(e).divide(2),e.subtract(d).rotate(90),(!0)),F=new y(e.add(g).divide(2),g.subtract(e).rotate(90),(!0)),j=new y(d,g),R=j.getSide(e);if(n=B.intersect(F,!0),!n){if(!R)return this.lineTo(g);throw new Error("Cannot create an arc with the given arguments")}s=d.subtract(n),i=s.getDirectedAngle(g.subtract(n));var D=j.getSide(n,!0);0===D?i=R*h(i):R===D&&(i+=i<0?360:-360)}if(i){for(var q=1e-7,V=h(i),U=V>=360?4:Math.ceil((V-q)/90),H=i/U,Z=H*Math.PI/360,W=4/3*Math.sin(Z)/(1+Math.cos(Z)),$=[],G=0;G<=U;G++){var k=g,J=null;if(G0&&(h(t[0],y),h(t[t.length-1],y)),g},_getStrokePadding:function(t,e){if(!e)return[t,t];var n=new f(t,0).transform(e),i=new f(0,t).transform(e),r=n.getAngleInRadians(),s=n.getLength(),a=i.getLength(),o=Math.sin(r),h=Math.cos(r),u=Math.tan(r),l=Math.atan2(a*u,s),c=Math.atan2(a,u*s);return[Math.abs(s*Math.cos(l)*h+a*Math.sin(l)*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(),u=h.getPrevious(),l=h.getPoint1().transform(r),c=u.getNormalAtTime(1).multiply(n).transform(s),d=h.getNormalAtTime(0).multiply(n).transform(s),_=c.getDirectedAngle(d);if((_<0||_>=180)&&(c=c.negate(),d=d.negate()),o&&a(l),a(l.add(c)),"miter"===e){var g=new y(l.add(c),new f((-c.y),c.x),(!0)).intersect(new y(l.add(d),new f((-d.y),d.x),(!0)),!0);g&&l.getDistance(g)<=i*n&&a(g)}a(l.add(d))},_addSquareCap:function(t,e,n,i,r,s,a){var o=t._point.transform(i),h=t.getLocation(),u=h.getNormal().multiply(0===h.getTime()?n:-n).transform(r);"square"===e&&(a&&(s(o.subtract(u)),s(o.add(u))),o=o.add(u.rotate(-90))),s(o.add(u)),s(o.subtract(u))},getHandleBounds:function(t,e,n,i,r){var s,a,o=n.getStyle(),h=r.stroke&&o.hasStroke();if(h){var u=n._getStrokeMatrix(i,r),l=o.getStrokeWidth()/2,c=l;"miter"===o.getStrokeJoin()&&(c=l*o.getMiterLimit()),"square"===o.getStrokeCap()&&(c=Math.max(c,l*Math.SQRT2)),s=E._getStrokePadding(l,u),a=E._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,g=d,p=_,m=0,y=t.length;m_&&(_=M),Ap&&(p=T)}}return new v(d,g,_-d,p-g)}}});E.inject({statics:new function(){function t(t,e,n){var i=r.getNamed(n),s=new E(i&&0==i.insert&&x.NO_INSERT);return s._add(t),s._closed=e,s.set(i,{insert:!0})}function e(e,n,r){for(var s=new Array(4),a=0;a<4;a++){var o=i[a];s[a]=new A(o._point.multiply(n).add(e),o._handleIn.multiply(n),o._handleOut.multiply(n))}return t(s,!0,r)}var n=.5522847498307936,i=[new A([-1,0],[0,n],[0,-n]),new A([0,-1],[-n,0],[n,0]),new A([1,0],[0,-n],[0,n]),new A([0,1],[n,0],[-n,0])];return{Line:function(){var e=arguments;return t([new A(f.readNamed(e,"from")),new A(f.readNamed(e,"to"))],!1,e)},Circle:function(){var t=arguments,n=f.readNamed(t,"center"),i=r.readNamed(t,"radius");return e(n,new _(i),t)},Rectangle:function(){var e,i=arguments,r=v.readNamed(i,"rectangle"),s=_.readNamed(i,"radius",0,{readNull:!0}),a=r.getBottomLeft(!0),o=r.getTopLeft(!0),h=r.getTopRight(!0),u=r.getBottomRight(!0);if(!s||s.isZero())e=[new A(a),new A(o),new A(h),new A(u)];else{s=_.min(s,r.getSize(!0).divide(2));var l=s.width,c=s.height,f=l*n,d=c*n;e=[new A(a.add(l,0),null,[-f,0]),new A(a.subtract(0,c),[0,d]),new A(o.add(0,c),null,[0,-d]),new A(o.add(l,0),[-f,0],null),new A(h.subtract(l,0),null,[f,0]),new A(h.add(0,c),[0,-d],null),new A(u.subtract(0,c),null,[0,d]),new A(u.subtract(l,0),[f,0])]}return t(e,!0,i)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=arguments,n=S._readEllipse(t);return e(n.center,n.radius,t)},Oval:"#Ellipse",Arc:function(){var t=arguments,e=f.readNamed(t,"from"),n=f.readNamed(t,"through"),i=f.readNamed(t,"to"),s=r.getNamed(t),a=new E(s&&0==s.insert&&x.NO_INSERT);return a.moveTo(e),a.arcTo(n,i),a.set(s)},RegularPolygon:function(){for(var e=arguments,n=f.readNamed(e,"center"),i=r.readNamed(e,"sides"),s=r.readNamed(e,"radius"),a=360/i,o=i%3===0,h=new f(0,o?-s:s),u=o?-1:.5,l=new Array(i),c=0;c=0;s--){var a=n[s];n!==e||a instanceof E||(n=r.slice(n)),Array.isArray(a)?n[s]=new E({segments:a,insert:!1}):a instanceof N&&(n.splice.apply(n,[s,1].concat(a.removeChildren())),a.remove())}return bt.base.call(this,t,n)},reduce:function Ct(t){for(var e=this._children,n=e.length-1;n>=0;n--){var i=e[n].reduce(t);i.isEmpty()&&i.remove()}if(!e.length){var i=new E(x.NO_INSERT);return i.copyAttributes(this),i.insertAbove(this),this.remove(),i}return Ct.base.call(this)},isClosed:function(){for(var t=this._children,e=0,n=t.length;e=0;_--){var g=u[_].split();g&&(a(g)&&g.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}return a(o),i(d,!1,t,e)}function u(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 f(t,e,n){var i=t&&t.length;if(i){var s=r.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 y(e.getArea())-y(t.getArea())}),o=a[0],u=h.findItemBoundsCollisions(a,null,l.GEOMETRIC_EPSILON);null==n&&(n=o.isClockwise());for(var c=0;c=0;p--)if(g[p]=0;g--){var v=n[g];v._path&&(_[i(v)]=!0)}for(var g=t.length-1;g>=0;g--){var p,m=t[g],y=m._time,w=y,x=e&&!e(m),v=m._curve;if(v&&(v!==s?(f=!v.hasHandles()||_&&_[i(v)],r=[],a=null,s=v):a>=h&&(y/=a)),x)r&&r.push(m);else{if(e&&o.unshift(m),a=w,yl)p=v._segment2;else{var b=v.divideAtTime(y,!0);f&&d.push(v,b),p=b._segment1;for(var C=r.length-1;C>=0;C--){var S=r[C];S._time=(S._time-y)/(1-y)}}m._setSegment(p);var k=p._intersection,I=m._intersection;if(k){u(k,I);for(var P=k;P;)u(P._intersection,k),P=P._next}else p._intersection=I}}return n||c(d),o||t}function _(t,e,n,i,r){function s(s){var a=s[c+0],h=s[c+6];if(!(gm(a,h))){var u=s[l+0],f=s[l+2],v=s[l+4],y=s[l+6];if(a===h)return void((ux||yx)&&(P=!0));var C=g===a?0:g===h?1:x>m(u,f,v,y)||b0?T[0]:1,S=0===C?u:1===C?y:O.getPoint(s,C)[n?"y":"x"],M=a>h?1:-1,z=o[c]>o[c+6]?1:-1,L=o[l+6];return g!==a?(Sb?I+=M:P=!0,S>d-w&&Sb&&(I+=M):u!=L&&(Lb?(I+=M,P=!0):L>x&&Sx&&S=p(e,i,r,a))for(var o,h=t[l+0],u=t[l+2],f=t[l+4],d=t[l+6],_=x>m(h,u,f,d)||bs.quality&&(s=M);break}c-=x}for(var p=a.length-1;p>=0;p--)a[p].segment._winding=s}function v(t,e){function n(t){var n;return!(!t||t._visited||e&&(!e[(n=t._winding||{}).winding]||e.unite&&2===n.winding&&n.windingL&&n.windingR))}function i(t){if(t)for(var e=0,n=a.length;e=0;u--){var l=h[u],f=l._path,_=l._segment,g=_.getPrevious(),p=_.getNext();t(g,f)&&t(p,f)&&(_.remove(),g._handleOut._set(0,0),p._handleIn._set(0,0),g===_||g.getCurve().hasLength()||(p._handleIn.set(g._handleIn),g.remove()))}s&&(d(a,i&&function(t){var e=t.getCurve(),n=t.getSegment(),i=t._intersection,r=i._curve,s=i._segment;return!!(e&&r&&e._path&&r._path)||(n&&(n._intersection=null),void(s&&(s._intersection=null)))},o),o&&c(o),n=v(r.each(n,function(t){r.push(this,t._segments)},[])));var m,y=n.length;return y>1&&e?(n!==e&&this.setChildren(n),m=this):1!==y||e||(n[0]!==this&&this.setSegments(n[0].removeSegments()),m=this),m||(m=new N(x.NO_INSERT),m.addChildren(n),m=m.reduce(),m.copyAttributes(this),this.replaceWith(m)),m},reorient:function(t,n){var i=this._children;return i&&i.length?this.setChildren(f(this.removeChildren(),function(e){return!!(t?e:1&e)},n)):n!==e&&this.setClockwise(n),this},getInteriorPoint:function(){var t=this.getBounds(),e=t.getCenter(!0);if(!this.contains(e)){for(var n=this.getCurves(),i=e.y,r=[],s=[],a=0,o=n.length;a=p(u,l,c,f)&&i<=m(u,l,c,f))for(var d=O.getMonoCurves(h),_=0,g=d.length;_=y&&i<=w||i>=w&&i<=y)){var x=i===y?v[0]:i===w?v[6]:1===O.solveCubic(v,1,i,s,0,1)?O.getPoint(v,s[0]).x:(v[0]+v[6])/2;r.push(x)}}}r.length>1&&(r.sort(function(t,e){return t-e}),e.x=(r[0]+r[1])/2)}return e}}});var B=r.extend({_class:"PathFlattener",initialize:function(t,e,n,i,r){function s(t,e){var n=O.getValues(t,e,r);h.push(n),a(n,t._index,0,1)}function a(t,n,r,s){if(!(s-r>c)||i&&O.isStraight(t)||O.isFlatEnough(t,e||.25)){var o=t[6]-t[0],h=t[7]-t[1],f=Math.sqrt(o*o+h*h);f>0&&(l+=f,u.push({offset:l,curve:t,index:n,time:s}))}else{var d=O.subdivide(t,.5),_=(r+s)/2;a(d[0],n,r,_),a(d[1],n,_,s)}}for(var o,h=[],u=[],l=0,c=1/(n||32),f=t._segments,d=f[0],_=1,g=f.length;_=t){this.index=e;var a=n[e-1],o=a&&a.index===s.index?a.time:0,h=a?a.offset:0;return{index:s.index,time:o+(s.time-o)*(t-h)/(s.offset-h)}}}return{index:n[i-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=O.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))}}},r.each(O._evaluateMethods,function(t){this[t+"At"]=function(e){var n=this._get(e);return O[t](this.curves[n.index],n.time)}},{})),F=r.extend({initialize:function(t){for(var e,n=this.points=[],i=t._segments,r=t._closed,s=0,a=i.length;s0&&(i=[new A(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){var o=a[n],h=a[i],u=o.getDistance(h)/3;return void this.addCurve(t,[o,o.add(r.normalize(u)),h.add(s.normalize(u)),h])}for(var l,c=this.chordLengthParameterize(n,i),f=Math.max(e,e*e),d=!0,_=0;_<=4;_++){var g=this.generateBezier(n,i,c,r,s),v=this.findMaxError(n,i,g,c);if(v.error=f)break;d=this.reparameterize(n,i,c,g),f=v.error}var p=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,n,l,r,p),this.fitCubic(t,e,l,i,p.negate(),s)},addCurve:function(t,e){var n=t[t.length-1];n.setHandleOut(e[1].subtract(e[0])),t.push(new A(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],u=o[e],l=[[0,0],[0,0]],c=[0,0],f=0,d=e-t+1;fs){var P=l[0][0]*c[1]-l[1][0]*c[0],M=c[0]*l[1][1]-c[1]*l[0][1];S=M/I,k=P/I}else{var A=l[0][0]+l[0][1],T=l[1][0]+l[1][1];S=k=a(A)>s?c[0]/A:a(T)>s?c[1]/T:0}var O,z,L=u.getDistance(h),E=s*L;if(SL*L&&(S=k=L/3,O=z=null)}return[h,h.add(O||i.normalize(S)),u.add(z||r.normalize(k)),u]},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&&(s=u,r=a)}return{error:s,index:r}}}),j=x.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var n=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(n&&t,!n&&f.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(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),R=j.extend({_class:"PointText",initialize:function(){j.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new d(t.x,t.y,this,"setPoint")},setPoint:function(){var t=f.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 u=0,l=i.length;u1&&(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 r.each(i,function(t,e){s[e]=[],r.each(t,function(t,n){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][n]="gradient"===e?"gradient"===t?function(t){var e=this._components[0];return t=q.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:function(){return f.read(arguments,0,{readNull:"highlight"===t,clone:!0})}:function(t){return null==t||isNaN(t)?0:+t};this["get"+a]=function(){return this._type===e||o&&/^hs[bl]$/.test(this._type)?this._components[n]:this._convert(e)[n]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=i[e],this._type=e),this._components[n]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function l(e){var n,a,o,h,u=arguments,c=this.__read,f=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e; +}n+=a.length}return e}}),new function(){function t(t,e,n,i){function r(e){var n=l[e],i=l[e+1];s==n&&a==i||(t.beginPath(),t.moveTo(s,a),t.lineTo(n,i),t.stroke(),t.beginPath(),t.arc(n,i,o,0,2*Math.PI,!0),t.fill())}if(!(i<=0))for(var s,a,o=i/2,h=i-2,u=o-1,l=new Array(6),c=0,f=e.length;c0&&!(1&_)){var g=t.fillStyle;t.fillStyle="#ffffff",t.fillRect(s-u,a-u,h,h),t.fillStyle=g}}}function e(t,e,n){function i(e){if(n)e._transformCoordinates(n,_),r=_[0],s=_[1];else{var i=e._point;r=i._x,s=i._y}if(g)t.moveTo(r,s),g=!1;else{if(n)h=_[2],u=_[3];else{var f=e._handleIn;h=r+f._x,u=s+f._y}h===r&&u===s&&l===a&&c===o?t.lineTo(r,s):t.bezierCurveTo(l,c,h,u,r,s)}if(a=r,o=s,n)l=_[4],c=_[5];else{var f=e._handleOut;l=a+f._x,c=o+f._y}}for(var r,s,a,o,h,u,l,c,f=e._segments,d=f.length,_=new Array(6),g=!0,v=0;v0&&i(f[0])}return{_draw:function(t,n,i,r){function s(t){return c[(t%f+f)%f]}var a=n.dontStart,o=n.dontFinish||n.clip,h=this.getStyle(),u=h.hasFill(),l=h.hasStroke(),c=h.getDashArray(),f=!at.support.nativeDash&&l&&c&&c.length;if(a||t.beginPath(),(u||l&&!f||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(u||l)&&(this._setStyles(t,n,i),u&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(f){a||t.beginPath();var d,_=new B(this,.25,32,(!1),r),g=_.length,v=-h.getDashOffset(),p=0;for(v%=g;v>0;)v-=s(p--)+s(p--);for(;v0||d>0)&&_.drawPart(t,Math.max(v,0),Math.max(d,0)),v=d+s(p++)}t.stroke()}},_drawSelected:function(n,i){n.beginPath(),e(n,this,i),n.stroke(),t(n,this._segments,i,at.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 A(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new A(f.read(arguments))])},cubicCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=f.read(e),s=t(this);s.setHandleOut(n.subtract(s._point)),this._add([new A(r,i.subtract(r))])},quadraticCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=t(this)._point;this.cubicCurveTo(n.add(r.subtract(n).multiply(1/3)),n.add(i.subtract(n).multiply(1/3)),i)},curveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),s=r.pick(r.read(e),.5),a=1-s,o=t(this)._point,h=n.subtract(o.multiply(a*a)).subtract(i.multiply(s*s)).divide(2*s*a);if(h.isNaN())throw new Error("Cannot put a curve through points with parameter = "+s);this.quadraticCurveTo(h,i)},arcTo:function(){var e,n,i,s,a,o=arguments,h=Math.abs,u=Math.sqrt,c=t(this),d=c._point,g=f.read(o),v=r.peek(o),p=r.pick(v,!0);if("boolean"==typeof p)var w=d.add(g).divide(2),e=w.add(w.subtract(d).rotate(p?-90:90));else if(r.remain(o)<=2)e=g,g=f.read(o);else if(!d.equals(g)){var x=_.read(o),b=l.isZero;if(b(x.width)||b(x.height))return this.lineTo(g);var C=r.read(o),p=!!r.read(o),S=!!r.read(o),w=d.add(g).divide(2),k=d.subtract(w).rotate(-C),I=k.x,P=k.y,M=h(x.width),T=h(x.height),O=M*M,z=T*T,L=I*I,E=P*P,N=u(L/O+E/z);if(N>1&&(M*=N,T*=N,O=M*M,z=T*T),N=(O*z-O*E-z*L)/(O*E+z*L),h(N)<1e-12&&(N=0),N<0)throw new Error("Cannot create an arc with the given arguments");n=new f(M*P/T,-T*I/M).multiply((S===p?-1:1)*u(N)).rotate(C).add(w),a=(new m).translate(n).rotate(C).scale(M,T),s=a._inverseTransform(d),i=s.getDirectedAngle(a._inverseTransform(g)),!p&&i>0?i-=360:p&&i<0&&(i+=360)}if(e){var B=new y(d.add(e).divide(2),e.subtract(d).rotate(90),(!0)),F=new y(e.add(g).divide(2),g.subtract(e).rotate(90),(!0)),j=new y(d,g),R=j.getSide(e);if(n=B.intersect(F,!0),!n){if(!R)return this.lineTo(g);throw new Error("Cannot create an arc with the given arguments")}s=d.subtract(n),i=s.getDirectedAngle(g.subtract(n));var D=j.getSide(n,!0);0===D?i=R*h(i):R===D&&(i+=i<0?360:-360)}if(i){for(var q=1e-7,V=h(i),U=V>=360?4:Math.ceil((V-q)/90),H=i/U,Z=H*Math.PI/360,W=4/3*Math.sin(Z)/(1+Math.cos(Z)),$=[],G=0;G<=U;G++){var k=g,J=null;if(G0){for(var C=1;C=180)&&(c=c.negate(),d=d.negate()),o&&a(l),a(l.add(c)),"miter"===e){var g=new y(l.add(c),new f((-c.y),c.x),(!0)).intersect(new y(l.add(d),new f((-d.y),d.x),(!0)),!0);g&&l.getDistance(g)<=i*n&&a(g)}a(l.add(d))},_addSquareCap:function(t,e,n,i,r,s,a){var o=t._point.transform(i),h=t.getLocation(),u=h.getNormal().multiply(0===h.getTime()?n:-n).transform(r);"square"===e&&(a&&(s(o.subtract(u)),s(o.add(u))),o=o.add(u.rotate(-90))),s(o.add(u)),s(o.subtract(u))},getHandleBounds:function(t,e,n,i,r){var s,a,o=n.getStyle(),h=r.stroke&&o.hasStroke();if(h){var u=n._getStrokeMatrix(i,r),l=o.getStrokeWidth()/2,c=l;"miter"===o.getStrokeJoin()&&(c=l*o.getMiterLimit()),"square"===o.getStrokeCap()&&(c=Math.max(c,l*Math.SQRT2)),s=E._getStrokePadding(l,u),a=E._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,g=d,p=_,m=0,y=t.length;m_&&(_=M),Ap&&(p=T)}}return new v(d,g,_-d,p-g)}}});E.inject({statics:new function(){function t(t,e,n){var i=r.getNamed(n),s=new E(i&&0==i.insert&&x.NO_INSERT);return s._add(t),s._closed=e,s.set(i,{insert:!0})}function e(e,n,r){for(var s=new Array(4),a=0;a<4;a++){var o=i[a];s[a]=new A(o._point.multiply(n).add(e),o._handleIn.multiply(n),o._handleOut.multiply(n))}return t(s,!0,r)}var n=.5522847498307936,i=[new A([-1,0],[0,n],[0,-n]),new A([0,-1],[-n,0],[n,0]),new A([1,0],[0,-n],[0,n]),new A([0,1],[n,0],[-n,0])];return{Line:function(){var e=arguments;return t([new A(f.readNamed(e,"from")),new A(f.readNamed(e,"to"))],!1,e)},Circle:function(){var t=arguments,n=f.readNamed(t,"center"),i=r.readNamed(t,"radius");return e(n,new _(i),t)},Rectangle:function(){var e,i=arguments,r=v.readNamed(i,"rectangle"),s=_.readNamed(i,"radius",0,{readNull:!0}),a=r.getBottomLeft(!0),o=r.getTopLeft(!0),h=r.getTopRight(!0),u=r.getBottomRight(!0);if(!s||s.isZero())e=[new A(a),new A(o),new A(h),new A(u)];else{s=_.min(s,r.getSize(!0).divide(2));var l=s.width,c=s.height,f=l*n,d=c*n;e=[new A(a.add(l,0),null,[-f,0]),new A(a.subtract(0,c),[0,d]),new A(o.add(0,c),null,[0,-d]),new A(o.add(l,0),[-f,0],null),new A(h.subtract(l,0),null,[f,0]),new A(h.add(0,c),[0,-d],null),new A(u.subtract(0,c),null,[0,d]),new A(u.subtract(l,0),[f,0])]}return t(e,!0,i)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=arguments,n=S._readEllipse(t);return e(n.center,n.radius,t)},Oval:"#Ellipse",Arc:function(){var t=arguments,e=f.readNamed(t,"from"),n=f.readNamed(t,"through"),i=f.readNamed(t,"to"),s=r.getNamed(t),a=new E(s&&0==s.insert&&x.NO_INSERT);return a.moveTo(e),a.arcTo(n,i),a.set(s)},RegularPolygon:function(){for(var e=arguments,n=f.readNamed(e,"center"),i=r.readNamed(e,"sides"),s=r.readNamed(e,"radius"),a=360/i,o=i%3===0,h=new f(0,o?-s:s),u=o?-1:.5,l=new Array(i),c=0;c=0;s--){var a=n[s];n!==e||a instanceof E||(n=r.slice(n)),Array.isArray(a)?n[s]=new E({segments:a,insert:!1}):a instanceof N&&(n.splice.apply(n,[s,1].concat(a.removeChildren())),a.remove())}return bt.base.call(this,t,n)},reduce:function Ct(t){for(var e=this._children,n=e.length-1;n>=0;n--){var i=e[n].reduce(t);i.isEmpty()&&i.remove()}if(!e.length){var i=new E(x.NO_INSERT);return i.copyAttributes(this),i.insertAbove(this),this.remove(),i}return Ct.base.call(this)},isClosed:function(){for(var t=this._children,e=0,n=t.length;e=0;_--){var g=u[_].split();g&&(a(g)&&g.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}return a(o),i(d,!1,t,e)}function u(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 f(t,e,n){var i=t&&t.length;if(i){var s=r.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 y(e.getArea())-y(t.getArea())}),o=a[0],u=h.findItemBoundsCollisions(a,null,l.GEOMETRIC_EPSILON);null==n&&(n=o.isClockwise());for(var c=0;c=0;p--)if(g[p]=0;g--){var v=n[g];v._path&&(_[i(v)]=!0)}for(var g=t.length-1;g>=0;g--){var p,m=t[g],y=m._time,w=y,x=e&&!e(m),v=m._curve;if(v&&(v!==s?(f=!v.hasHandles()||_&&_[i(v)],r=[],a=null,s=v):a>=h&&(y/=a)),x)r&&r.push(m);else{if(e&&o.unshift(m),a=w,yl)p=v._segment2;else{var b=v.divideAtTime(y,!0);f&&d.push(v,b),p=b._segment1;for(var C=r.length-1;C>=0;C--){var S=r[C];S._time=(S._time-y)/(1-y)}}m._setSegment(p);var k=p._intersection,I=m._intersection;if(k){u(k,I);for(var P=k;P;)u(P._intersection,k),P=P._next}else p._intersection=I}}return n||c(d),o||t}function _(t,e,n,i,r){function s(s){var a=s[c+0],h=s[c+6];if(!(gm(a,h))){var u=s[l+0],f=s[l+2],v=s[l+4],y=s[l+6];if(a===h)return void((ux||yx)&&(P=!0));var C=g===a?0:g===h?1:x>m(u,f,v,y)||b0?T[0]:1,S=0===C?u:1===C?y:O.getPoint(s,C)[n?"y":"x"],M=a>h?1:-1,z=o[c]>o[c+6]?1:-1,L=o[l+6];return g!==a?(Sb?I+=M:P=!0,S>d-w&&Sb&&(I+=M):u!=L&&(Lb?(I+=M,P=!0):L>x&&Sx&&S=p(e,i,r,a))for(var o,h=t[l+0],u=t[l+2],f=t[l+4],d=t[l+6],_=x>m(h,u,f,d)||bs.quality&&(s=M);break}c-=x}for(var p=a.length-1;p>=0;p--)a[p].segment._winding=s}function v(t,e){function n(t){var n;return!(!t||t._visited||e&&(!e[(n=t._winding||{}).winding]||e.unite&&2===n.winding&&n.windingL&&n.windingR))}function i(t){if(t)for(var e=0,n=a.length;e=0;u--){var l=h[u],f=l._path,_=l._segment,g=_.getPrevious(),p=_.getNext();t(g,f)&&t(p,f)&&(_.remove(),g._handleOut._set(0,0),p._handleIn._set(0,0),g===_||g.getCurve().hasLength()||(p._handleIn.set(g._handleIn),g.remove()))}s&&(d(a,i&&function(t){var e=t.getCurve(),n=t.getSegment(),i=t._intersection,r=i._curve,s=i._segment;return!!(e&&r&&e._path&&r._path)||(n&&(n._intersection=null),void(s&&(s._intersection=null)))},o),o&&c(o),n=v(r.each(n,function(t){r.push(this,t._segments)},[])));var m,y=n.length;return y>1&&e?(n!==e&&this.setChildren(n),m=this):1!==y||e||(n[0]!==this&&this.setSegments(n[0].removeSegments()),m=this),m||(m=new N(x.NO_INSERT),m.addChildren(n),m=m.reduce(),m.copyAttributes(this),this.replaceWith(m)),m},reorient:function(t,n){var i=this._children;return i&&i.length?this.setChildren(f(this.removeChildren(),function(e){return!!(t?e:1&e)},n)):n!==e&&this.setClockwise(n),this},getInteriorPoint:function(){var t=this.getBounds(),e=t.getCenter(!0);if(!this.contains(e)){for(var n=this.getCurves(),i=e.y,r=[],s=[],a=0,o=n.length;a=p(u,l,c,f)&&i<=m(u,l,c,f))for(var d=O.getMonoCurves(h),_=0,g=d.length;_=y&&i<=w||i>=w&&i<=y)){var x=i===y?v[0]:i===w?v[6]:1===O.solveCubic(v,1,i,s,0,1)?O.getPoint(v,s[0]).x:(v[0]+v[6])/2;r.push(x)}}}r.length>1&&(r.sort(function(t,e){return t-e}),e.x=(r[0]+r[1])/2)}return e}}});var B=r.extend({_class:"PathFlattener",initialize:function(t,e,n,i,r){function s(t,e){var n=O.getValues(t,e,r);h.push(n),a(n,t._index,0,1)}function a(t,n,r,s){if(!(s-r>c)||i&&O.isStraight(t)||O.isFlatEnough(t,e||.25)){var o=t[6]-t[0],h=t[7]-t[1],f=Math.sqrt(o*o+h*h);f>0&&(l+=f,u.push({offset:l,curve:t,index:n,time:s}))}else{var d=O.subdivide(t,.5),_=(r+s)/2;a(d[0],n,r,_),a(d[1],n,_,s)}}for(var o,h=[],u=[],l=0,c=1/(n||32),f=t._segments,d=f[0],_=1,g=f.length;_=t){this.index=e;var a=n[e-1],o=a&&a.index===s.index?a.time:0,h=a?a.offset:0;return{index:s.index,time:o+(s.time-o)*(t-h)/(s.offset-h)}}}return{index:n[i-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=O.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))}}},r.each(O._evaluateMethods,function(t){this[t+"At"]=function(e){var n=this._get(e);return O[t](this.curves[n.index],n.time)}},{})),F=r.extend({initialize:function(t){for(var e,n=this.points=[],i=t._segments,r=t._closed,s=0,a=i.length;s0&&(i=[new A(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){var o=a[n],h=a[i],u=o.getDistance(h)/3;return void this.addCurve(t,[o,o.add(r.normalize(u)),h.add(s.normalize(u)),h])}for(var l,c=this.chordLengthParameterize(n,i),f=Math.max(e,e*e),d=!0,_=0;_<=4;_++){var g=this.generateBezier(n,i,c,r,s),v=this.findMaxError(n,i,g,c);if(v.error=f)break;d=this.reparameterize(n,i,c,g),f=v.error}var p=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,n,l,r,p),this.fitCubic(t,e,l,i,p.negate(),s)},addCurve:function(t,e){var n=t[t.length-1];n.setHandleOut(e[1].subtract(e[0])),t.push(new A(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],u=o[e],l=[[0,0],[0,0]],c=[0,0],f=0,d=e-t+1;fs){var P=l[0][0]*c[1]-l[1][0]*c[0],M=c[0]*l[1][1]-c[1]*l[0][1];S=M/I,k=P/I}else{var A=l[0][0]+l[0][1],T=l[1][0]+l[1][1];S=k=a(A)>s?c[0]/A:a(T)>s?c[1]/T:0}var O,z,L=u.getDistance(h),E=s*L;if(SL*L&&(S=k=L/3,O=z=null)}return[h,h.add(O||i.normalize(S)),u.add(z||r.normalize(k)),u]},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&&(s=u,r=a)}return{error:s,index:r}}}),j=x.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var n=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(n&&t,!n&&f.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(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),R=j.extend({_class:"PointText",initialize:function(){j.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new d(t.x,t.y,this,"setPoint")},setPoint:function(){var t=f.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 u=0,l=i.length;u1&&(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 r.each(i,function(t,e){s[e]=[],r.each(t,function(t,n){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][n]="gradient"===e?"gradient"===t?function(t){var e=this._components[0];return t=q.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:function(){return f.read(arguments,0,{readNull:"highlight"===t,clone:!0})}:function(t){return null==t||isNaN(t)?0:+t};this["get"+a]=function(){return this._type===e||o&&/^hs[bl]$/.test(this._type)?this._components[n]:this._convert(e)[n]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=i[e],this._type=e),this._components[n]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function l(e){var n,a,o,h,u=arguments,c=this.__read,f=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e; if("string"===d&&e in i&&(n=e,e=u[1],Array.isArray(e)?(a=e,o=u[2]):(c&&(f=1),u=r.slice(u,1),d=typeof e)),!a){if(h="number"===d?u:"object"===d&&null!=e.length?e:null){n||(n=h.length>=3?"rgb":"gray");var _=i[n].length;o=h[_],c&&(f+=h===arguments?_+(null!=o?1:0):1),h.length>_&&(h=r.slice(h,0,_))}else if("string"===d){var g=t(e);n=g[0],a=g[1],4===a.length&&(o=a[3],a.length--)}else if("object"===d)if(e.constructor===l){if(n=e._type,a=e._components.slice(),o=e._alpha,"gradient"===n)for(var v=1,p=a.length;v1?1:t))}var n=this._convert("rgb"),i=t||null==this._alpha?1:this._alpha;return n=[e(n[0]),e(n[1]),e(n[2])],i<1&&n.push(i<0?0:i),t?"#"+((1<<24)+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).slice(1):(4==n.length?"rgba(":"rgb(")+n.join(",")+")"},toCanvasStyle:function(t,e){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var n,i=this._components,r=i[0],s=r._stops,a=i[1],o=i[2],h=i[3],u=e&&e.inverted();if(u&&(a=u._transformPoint(a),o=u._transformPoint(o),h&&(h=u._transformPoint(h))),r._radial){var l=o.getDistance(a);if(h){var c=h.subtract(a);c.getLength()>l&&(h=a.add(c.normalize(l-.1)))}var f=h||a;n=t.createRadialGradient(f.x,f.y,0,a.x,a.y,l)}else n=t.createLinearGradient(a.x,a.y,o.x,o.y);for(var d=0,_=s.length;d<_;d++){var g=s[d],v=g._offset;n.addColorStop(null==v?d/(_-1):v,g._color.toCanvasStyle())}return this._canvasStyle=n},transform:function(t){if("gradient"===this._type){for(var e=this._components,n=1,i=e.length;n0&&!(e instanceof N);if(s)for(var a=0,o=r.length;a0&&!(a instanceof N);if(u&&!t)for(var l=0,_=o.length;l<_;l++){var g=o[l]._style[d]();if(l){if(!r.equals(s,g))return e}else s=g}else if(n in this._defaults){var s=this._values[n];if(s===e)s=this._defaults[n],s&&s.clone&&(s=s.clone());else{var v=i?D:h?f:null;!v||s&&s.constructor===v||(this._values[n]=s=v.read([s],0,{readNull:!0,clone:!0}))}}return s&&i&&(s=D._setOwner(s,a,u&&c)),s},a[d]=function(t){return this._style[d](t)},a[c]=function(t){this._style[c](t)}}),r.each({Font:"FontFamily",WindingRule:"FillRule"},function(t,e){var n="get"+e,i="set"+e;o[n]=a[n]="#get"+t,o[i]=a[i]="#set"+t}),x.inject(a),o},{set:function(t){var e=t instanceof U,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 n(t,n,i){var s=t._values,a=n._values,o=n._defaults;for(var h in s){var u=s[h],l=a[h];if(!(i&&h in a||r.equals(u,l===e?o[h]:l)))return!1}return!0}return t===this||t&&this._class===t._class&&n(this,t)&&n(t,this,!0)||!1},_dispose:function(){var t;t=this.getFillColor(),t&&(t._canvasStyle=null),t=this.getStrokeColor(),t&&(t._canvasStyle=null),t=this.getShadowColor(),t&&(t._canvasStyle=null)},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 kt(){var t=kt.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,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,i=t.ownerDocument,r=i.body,s=i.documentElement;try{n=t.getBoundingClientRect()}catch(a){n={left:0,top:0,width:0,height:0}}var o=n.left-(s.clientLeft||r.clientLeft||0),h=n.top-(s.clientTop||r.clientTop||0);if(!e){var u=i.defaultView;o+=u.pageXOffset||s.scrollLeft||r.scrollLeft,h+=u.pageYOffset||s.scrollTop||r.scrollTop}return new v(o,h,n.width,n.height)},getViewportBounds:function(t){var e=t.ownerDocument,n=e.defaultView,i=e.documentElement;return new v(0,0,n.innerWidth||i.clientWidth,n.innerHeight||i.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 _(0,0))},isInView:function(t){return!H.isInvisible(t)&&H.getViewportBounds(t).intersects(H.getBounds(t,!0))},isInserted:function(t){return i.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)}}},Z={add:function(t,e){if(t)for(var n in e)for(var r=e[n],s=n.split(/[\s,]+/g),a=0,o=s.length;a1?r.hyphenate(n):n.toLowerCase())}function s(t,e,n,i){var o,h=W._focused;if(l[e]=t,t?c[e]=n:delete c[e],e.length>1&&(o=r.camelize(e))in f){f[o]=t;var u=at&&at.agent;if("meta"===o&&u&&u.mac)if(t)a={};else{for(var d in a)d in c&&s(!1,d,a[d],i);a=null}}else t&&a&&(a[e]=n);h&&h._handleKeyEvent(t?"keydown":"keyup",i,e,n)}var a,o,h={"\t":"tab"," ":"space","\b":"backspace","\x7f":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},u={tab:"\t",space:" ",enter:"\r"},l={},c={},f=new r({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var t=at&&at.agent;return t&&t.mac?this.meta:this.control}}});return Z.add(i,{keydown:function(e){var n=t(e),i=at&&at.agent;n.length>1||i&&i.chrome&&(e.altKey||i.mac&&e.metaKey||!i.mac&&e.ctrlKey)?s(!0,n,u[n]||(n.length>1?"":n),e):o=n},keypress:function(e){if(o){var n=t(e),i=e.charCode,r=i>=32?String.fromCharCode(i):n.length>1?"":n;n!==o&&(n=r.toLowerCase()),s(!0,n,r,e),o=null}},keyup:function(e){var n=t(e);n in c&&s(!1,n,c[n],e)}}),Z.add(n,{blur:function(t){for(var e in c)s(!1,e,c[e],t)}}),{modifiers:f,isDown:function(t){return!!l[t]}}},K=G.extend({_class:"MouseEvent",initialize:function(t,e,n,i,r){this.type=t,this.event=e,this.point=n,this.target=i,this.delta=r},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),Q=G.extend({_class:"ToolEvent",_item:null,initialize:function(t,e,n){this.tool=t,this.type=e,this.event=n},_choosePoint:function(t,e){return t?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()+" }"}}),Y=o.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(t){o.call(this),this._moveCount=-1,this._downCount=-1,this.set(t)},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=0&&r.equals(s))return!1;if(s&&(null!=t||null!=e)){var o=r.subtract(s),h=o.getLength();if(h<(t||0))return!1;e&&(r=s.add(o.normalize(Math.min(h,e))))}c._moveCount++}return c._point=r,c._lastPoint=s||r,i.down&&(c._moveCount=-1,c._downPoint=r,c._downCount++),!0}function s(){o&&(l=c.emit(t,new Q(c,t,e))||l)}at=this._scope,i.drag&&!this.responds(t)&&(t="mousemove");var a=i.move||i.drag,o=this.responds(t),h=this.minDistance,u=this.maxDistance,l=!1,c=this;if(i.down)r(),s();else if(i.up)r(null,u),s();else if(o)for(;r(h,u);)s();return l}}),tt=r.extend(s,{_class:"Tween",statics:{easings:{linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:-1+2*(2-t)*t},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}}},initialize:function Tt(t,e,n,i,r,s){this.object=t;var a=typeof r,o="function"===a;this.type=o?a:"string"===a?r:"linear",this.easing=o?r:Tt.easings[this.type],this.duration=i,this.running=!1,this._then=null,this._startTime=null;var h=e||n;this._keys=h?Object.keys(h):[],this._parsedKeys=this._parseKeys(this._keys),this._from=h&&this._getState(e),this._to=h&&this._getState(n),s!==!1&&this.start()},then:function(t){return this._then=t,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(t){if(this.running){t>1&&(t=1,this.running=!1);for(var e=this.easing(t),n=this._keys,i=function(n){return"function"==typeof n?n(e,t):n},s=0,a=n&&n.length;s255){var u=255-r,l=o-r;d=r+(d-r)*u/l,_=r+(_-r)*u/l,g=r+(g-r)*u/l}}function n(t,e,n){return p(t,e,n)-v(t,e,n)}function i(t,e,n,i){var r,s=[t,e,n],a=p(t,e,n),o=v(t,e,n);o=o===t?0:o===e?1:2,a=a===t?0:a===e?1:2,r=0===v(o,a)?1===p(o,a)?2:1:0,s[a]>s[o]?(s[r]=(s[r]-s[o])*i/(s[a]-s[o]),s[a]=i):s[r]=s[a]=0,s[o]=0,d=s[0],_=s[1],g=s[2]}var s,a,o,h,u,l,c,f,d,_,g,v=Math.min,p=Math.max,m=Math.abs,y={multiply:function(){d=u*s/255,_=l*a/255,g=c*o/255},screen:function(){d=u+s-u*s/255,_=l+a-l*a/255,g=c+o-c*o/255},overlay:function(){d=u<128?2*u*s/255:255-2*(255-u)*(255-s)/255,_=l<128?2*l*a/255:255-2*(255-l)*(255-a)/255,g=c<128?2*c*o/255:255-2*(255-c)*(255-o)/255},"soft-light":function(){var t=s*u/255;d=t+u*(255-(255-u)*(255-s)/255-t)/255,t=a*l/255,_=t+l*(255-(255-l)*(255-a)/255-t)/255,t=o*c/255,g=t+c*(255-(255-c)*(255-o)/255-t)/255},"hard-light":function(){d=s<128?2*s*u/255:255-2*(255-s)*(255-u)/255,_=a<128?2*a*l/255:255-2*(255-a)*(255-l)/255,g=o<128?2*o*c/255:255-2*(255-o)*(255-c)/255},"color-dodge":function(){d=0===u?0:255===s?255:v(255,255*u/(255-s)),_=0===l?0:255===a?255:v(255,255*l/(255-a)),g=0===c?0:255===o?255:v(255,255*c/(255-o))},"color-burn":function(){d=255===u?255:0===s?0:p(0,255-255*(255-u)/s),_=255===l?255:0===a?0:p(0,255-255*(255-l)/a),g=255===c?255:0===o?0:p(0,255-255*(255-c)/o)},darken:function(){d=us?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,d<0&&(d=-d),_=l-a,_<0&&(_=-_),g=c-o,g<0&&(g=-g)},exclusion:function(){d=u+s*(255-u-u)/255,_=l+a*(255-l-l)/255,g=c+o*(255-c-c)/255},hue:function(){i(s,a,o,n(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){i(u,l,c,n(s,a,o)),e(d,_,g,t(u,l,c))},luminosity:function(){e(u,l,c,t(s,a,o))},color:function(){e(s,a,o,t(u,l,c))},add:function(){d=v(u+s,255),_=v(l+a,255),g=v(c+o,255)},subtract:function(){d=p(u-s,0),_=p(l-a,0),g=p(c-o,0)},average:function(){d=(u+s)/2,_=(l+a)/2,g=(c+o)/2},negation:function(){d=255-m(255-s-u),_=255-m(255-a-l),g=255-m(255-o-c)}},w=this.nativeModes=r.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=nt.getContext(1,1);x&&(r.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(r){}x.restore(),w[e]=i}),nt.release(x)),this.process=function(t,e,n,i,r){var v=e.canvas,p="normal"===t;if(p||w[t])n.save(),n.setTransform(1,0,0,1,0,0),n.globalAlpha=i,p||(n.globalCompositeOperation=t),n.drawImage(v,r.x,r.y),n.restore();else{var m=y[t];if(!m)return;for(var x=n.getImageData(r.x,r.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,k=b.length;S=2&&!t.hasHandles())if(h>2){s=t._closed?"polygon":"polyline";for(var l=[],c=0;c=t)break;t+=i[1]}return t}function o(t){return r.substring(a(t.range[0]),a(t.range[1]))}function h(t,e){return r.substring(a(t.range[1]),a(e.range[0]))}function u(t,e){for(var n=a(t.range[0]),i=a(t.range[1]),s=0,o=d.length-1;o>=0;o--)if(n>d[o][0]){s=o+1;break}d.splice(s,0,[n,e.length-i+n]),r=r.substring(0,n)+e+r.substring(i)}function l(t,e){if(t){for(var n in t)if("range"!==n&&"loc"!==n){var i=t[n];if(Array.isArray(i))for(var r=0,s=i.length;r]/.test(e.operator)||"MemberExpression"===g&&e.computed))if("UpdateExpression"===t.type){var a=o(t.argument),v="__$__("+a+', "'+t.operator[0]+'", 1)',p=a+" = "+v;t.prefix?p="("+p+")":"AssignmentExpression"!==g&&"VariableDeclarator"!==g&&"BinaryExpression"!==g||(o(e.left||e.id)===a&&(p=v),p=a+"; "+p),u(t,p)}else if(/^.=$/.test(t.operator)&&"Literal"!==t.left.type){var c=o(t.left),f=o(t.right),v=c+" = __$__("+c+', "'+t.operator[0]+'", '+f+")";u(t,/^\(.*\)$/.test(o(t))?"("+v+")":v)}break;case"ExportDefaultDeclaration":u({range:[t.start,t.declaration.start]},"module.exports = ");break;case"ExportNamedDeclaration":var m=t.declaration,y=t.specifiers;if(m){var b=m.declarations;b&&(b.forEach(function(t){u(t,"module.exports."+o(t))}),u({range:[t.start,m.start+m.kind.length]},""))}else if(y){var C=y.map(function(t){var e=o(t);return"module.exports."+e+" = "+e+"; "}).join("");C&&u(t,C)}}}}function c(t){var e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=(Math.abs(t)<<1)+(t<0?1:0);t||!e;){var i=31&t;t>>=5,t&&(i|=32),e+=n[i]}return e}if(!r)return"";s=s||{};var f,d=[],_=s.url||"",g=s.sourceMaps,v=s.paperFeatures||{},p=s.source||r,m=s.offset||0,y=at.agent,b=y.versionNumber,C=!1,S=/\r\n|\n|\r/gm;if(g&&(y.chrome&&b>=30||y.webkit&&b>=537.76||y.firefox&&b>=23||y.node)){if(y.node)m-=2;else if(n&&_&&!n.location.href.indexOf(_)){var k=i.getElementsByTagName("html")[0].innerHTML;m=k.substr(0,k.indexOf(r)+1).match(S).length+1}C=m>0&&!(y.chrome&&b>=36||y.safari&&b>=600||y.firefox&&b>=40||y.node);var I=["AA"+c(C?0:m)+"A"];I.length=(r.match(S)||[]).length+1+(C?m:0),f={version:3,file:_,names:[],mappings:I.join(";AACA"),sourceRoot:"",sources:[_],sourcesContent:[p]}}return v.operatorOverloading!==!1&&l(e(r,{ranges:!0,preserveParens:!0,sourceType:"module"})),f&&(C&&(r=new Array(m+1).join("\n")+r),/^(inline|both)$/.test(g)&&(r+="\n//# sourceMappingURL=data:application/json;base64,"+t.btoa(unescape(encodeURIComponent(JSON.stringify(f))))),r+="\n//# sourceURL="+(_||"paperscript")),{url:_,source:p,code:r,map:f}}function u(t,e,n){function a(e,n){for(var i in e)!n&&/^_/.test(i)||!new RegExp("([\\b\\s\\W]|^)"+i.replace(/\$/g,"\\$")+"\\b").test(t)||(g.push(i),v.push(e[i]))}at=e;var u,l=e.getView(),c=/\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(t)&&!/\bnew\s+Tool\b/.test(t)?new Y:null,d=c?c._events:[],_=["onFrame","onResize"].concat(d),g=[],v=[],p="object"==typeof t?t:h(t,n);t=p.code,a({__$__:s,$__:o,paper:e,tool:c},!0),a(e),t="var module = { exports: {} }; "+t;var m=r.each(_,function(e){new RegExp("\\s+"+e+"\\b").test(t)&&(g.push(e),this.push("module.exports."+e+" = "+e+";"))},[]).join("\n");m&&(t+="\n"+m),t+="\nreturn module.exports;";var y=at.agent;if(i&&(y.chrome||y.firefox&&y.versionNumber<40)){var w=i.createElement("script"),x=i.head||i.getElementsByTagName("head")[0];y.firefox&&(t="\n"+t),w.appendChild(i.createTextNode("document.__paperscript__ = function("+g+") {"+t+"\n}")),x.appendChild(w),u=i.__paperscript__,delete i.__paperscript__,x.removeChild(w)}else u=Function(g,t);var m=u&&u.apply(e,v),b=m||{};return r.each(d,function(t){var e=b[t];e&&(c[t]=e)}),l&&(b.onResize&&l.setOnResize(b.onResize),l.emit("resize",{size:l.size,delta:new f}),b.onFrame&&l.setOnFrame(b.onFrame),l.requestUpdate()),m}function l(t){if(/^text\/(?:x-|)paperscript$/.test(t.type)&&"true"!==a.getAttribute(t,"ignore")){var e=a.getAttribute(t,"canvas"),n=i.getElementById(e),r=t.src||t.getAttribute("data-src"),s=a.hasAttribute(t,"async"),o="data-paper-scope";if(!n)throw new Error('Unable to find canvas with id "'+e+'"');var h=a.get(n.getAttribute(o))||(new a).setup(n);return n.setAttribute(o,h._id),r?et.request({url:r,async:s,mimeType:"text/plain",onLoad:function(t){u(t,h,r)}}):u(t.innerHTML,h,t.baseURI),t.setAttribute("data-paper-ignore","true"),h}}function c(){r.each(i&&i.getElementsByTagName("script"),l)}function d(t){return t?l(t):c()}var g=this,v=g.acorn;if(!v&&"undefined"!=typeof require)try{v=require("acorn")}catch(p){}if(!v){var m,y;v=m=y={},function(t,e){return"object"==typeof m&&"object"==typeof y?e(m):"function"==typeof define&&define.amd?define(["exports"],e):void e(t.acorn||(t.acorn={}))}(this,function(t){"use strict";function e(t){ct=t||{};for(var e in gt)Object.prototype.hasOwnProperty.call(ct,e)||(ct[e]=gt[e]);_t=ct.sourceFile||null}function n(t,e){var n=vt(ft,t);e+=" ("+n.line+":"+n.column+")";var i=new SyntaxError(e);throw i.pos=t,i.loc=n,i.raisedAt=pt,i}function i(t){function e(t){if(1==t.length)return n+="return str === "+JSON.stringify(t[0])+";";n+="switch(str){";for(var e=0;e3){i.sort(function(t,e){return e.length-t.length}),n+="switch(str.length){";for(var r=0;r8&&t<14)++pt;else if(47===t){var e=ft.charCodeAt(pt+1);if(42===e)o();else{if(47!==e)break;h()}}else if(160===t)++pt;else{if(!(t>=5760&&He.test(String.fromCharCode(t))))break;++pt}}}function l(){var t=ft.charCodeAt(pt+1);return t>=48&&t<=57?S(!0):(++pt,a(we))}function c(){var t=ft.charCodeAt(pt+1);return St?(++pt,x()):61===t?w(Se,2):w(be,1)}function f(){var t=ft.charCodeAt(pt+1);return 61===t?w(Se,2):w(Be,1)}function d(t){var e=ft.charCodeAt(pt+1);return e===t?w(124===t?Pe:Me,2):61===e?w(Se,2):w(124===t?Ae:Oe,1)}function _(){var t=ft.charCodeAt(pt+1);return 61===t?w(Se,2):w(Te,1)}function g(t){var e=ft.charCodeAt(pt+1);return e===t?45==e&&62==ft.charCodeAt(pt+2)&&Je.test(ft.slice(Mt,pt))?(pt+=3,h(),u(),y()):w(ke,2):61===e?w(Se,2):w(Ne,1)}function v(t){var e=ft.charCodeAt(pt+1),n=1;return e===t?(n=62===t&&62===ft.charCodeAt(pt+2)?3:2,61===ft.charCodeAt(pt+n)?w(Se,n+1):w(Ee,n)):33==e&&60==t&&45==ft.charCodeAt(pt+2)&&45==ft.charCodeAt(pt+3)?(pt+=4,h(),u(),y()):(61===e&&(n=61===ft.charCodeAt(pt+2)?3:2),w(Le,n))}function p(t){var e=ft.charCodeAt(pt+1);return 61===e?w(ze,61===ft.charCodeAt(pt+2)?3:2):w(61===t?Ce:Ie,1)}function m(t){switch(t){case 46:return l();case 40:return++pt,a(ge);case 41:return++pt,a(ve);case 59:return++pt,a(me);case 44:return++pt,a(pe);case 91:return++pt,a(ce);case 93:return++pt,a(fe);case 123:return++pt,a(de);case 125:return++pt,a(_e);case 58:return++pt,a(ye);case 63:return++pt,a(xe);case 48:var e=ft.charCodeAt(pt+1);if(120===e||88===e)return C();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return S(!1);case 34:case 39:return k(t);case 47:return c(t);case 37:case 42:return f();case 124:case 38:return d(t);case 94:return _();case 43:case 45:return g(t);case 60:case 62:return v(t);case 61:case 33:return p(t);case 126:return w(Ie,1)}return!1}function y(t){if(t?pt=mt+1:mt=pt,ct.locations&&(wt=new r),t)return x();if(pt>=dt)return a(jt);var e=ft.charCodeAt(pt);if(Ke(e)||92===e)return M();var i=m(e);if(i===!1){var s=String.fromCharCode(e);if("\\"===s||$e.test(s))return M();n(pt,"Unexpected character '"+s+"'")}return i}function w(t,e){var n=ft.slice(pt,pt+e);pt+=e,a(t,n)}function x(){for(var t,e,i="",r=pt;;){pt>=dt&&n(r,"Unterminated regular expression");var s=ft.charAt(pt);if(Je.test(s)&&n(r,"Unterminated regular expression"),t)t=!1;else{if("["===s)e=!0;else if("]"===s&&e)e=!1;else if("/"===s&&!e)break;t="\\"===s}++pt}var i=ft.slice(r,pt);++pt;var o=P();o&&!/^[gmsiy]*$/.test(o)&&n(r,"Invalid regexp flag");try{var h=new RegExp(i,o)}catch(u){u instanceof SyntaxError&&n(r,u.message),n(u)}return a(Nt,h)}function b(t,e){for(var n=pt,i=0,r=0,s=null==e?1/0:e;r=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,a>=t)break;++pt,i=i*t+a}return pt===n||null!=e&&pt-n!==e?null:i}function C(){pt+=2;var t=b(16);return null==t&&n(mt+2,"Expected hexadecimal number"),Ke(ft.charCodeAt(pt))&&n(pt,"Identifier directly after number"),a(Et,t)}function S(t){var e=pt,i=!1,r=48===ft.charCodeAt(pt);t||null!==b(10)||n(e,"Invalid number"),46===ft.charCodeAt(pt)&&(++pt,b(10),i=!0);var s=ft.charCodeAt(pt);69!==s&&101!==s||(s=ft.charCodeAt(++pt),43!==s&&45!==s||++pt,null===b(10)&&n(e,"Invalid number"),i=!0),Ke(ft.charCodeAt(pt))&&n(pt,"Identifier directly after number");var o,h=ft.slice(e,pt);return i?o=parseFloat(h):r&&1!==h.length?/[89]/.test(h)||zt?n(e,"Invalid number"):o=parseInt(h,8):o=parseInt(h,10),a(Et,o)}function k(t){pt++;for(var e="";;){pt>=dt&&n(mt,"Unterminated string constant");var i=ft.charCodeAt(pt);if(i===t)return++pt,a(Bt,e);if(92===i){i=ft.charCodeAt(++pt);var r=/^[0-7]+/.exec(ft.slice(pt,pt+3));for(r&&(r=r[0]);r&&parseInt(r,8)>255;)r=r.slice(0,-1);if("0"===r&&(r=null),++pt,r)zt&&n(pt-2,"Octal literal in strict mode"),e+=String.fromCharCode(parseInt(r,8)),pt+=r.length-1;else switch(i){case 110:e+="\n";break;case 114:e+="\r";break;case 120:e+=String.fromCharCode(I(2));break;case 117:e+=String.fromCharCode(I(4));break;case 85:e+=String.fromCharCode(I(8));break;case 116:e+="\t";break;case 98:e+="\b";break;case 118:e+="\x0B";break;case 102:e+="\f";break;case 48:e+="\0";break;case 13:10===ft.charCodeAt(pt)&&++pt;case 10:ct.locations&&(It=pt,++kt);break;default:e+=String.fromCharCode(i)}}else 13!==i&&10!==i&&8232!==i&&8233!==i||n(mt,"Unterminated string constant"),e+=String.fromCharCode(i),++pt}}function I(t){var e=b(16,t);return null===e&&n(mt,"Bad character escape sequence"),e}function P(){je=!1;for(var t,e=!0,i=pt;;){var r=ft.charCodeAt(pt);if(Qe(r))je&&(t+=ft.charAt(pt)),++pt;else{if(92!==r)break;je||(t=ft.slice(i,pt)),je=!0,117!=ft.charCodeAt(++pt)&&n(pt,"Expecting Unicode escape sequence \\uXXXX"),++pt;var s=I(4),a=String.fromCharCode(s);a||n(pt-1,"Invalid Unicode escape"),(e?Ke(s):Qe(s))||n(pt-4,"Invalid Unicode escape"),t+=a}e=!1}return je?t:ft.slice(i,pt)}function M(){var t=P(),e=Ft;return!je&&Ue(t)&&(e=le[t]),a(e,t)}function A(){Pt=mt,Mt=yt,At=xt,y()}function T(t){if(zt=t,pt=mt,ct.locations)for(;pt=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"use strict"===t.expression.value}function F(t){if(bt===t)return A(),!0}function j(){return!ct.strictSemicolons&&(bt===jt||bt===_e||Je.test(ft.slice(Mt,mt)))}function R(){F(me)||j()||q()}function D(t){bt===t?A():q()}function q(){n(mt,"Unexpected token")}function V(t){"Identifier"!==t.type&&"MemberExpression"!==t.type&&n(t.start,"Assigning to rvalue"),zt&&"Identifier"===t.type&&Ve(t.name)&&n(t.start,"Assigning to "+t.name+" in strict mode")}function U(t){Pt=Mt=pt,ct.locations&&(At=new r),Tt=zt=null,Ot=[],y();var e=t||L(),n=!0;for(t||(e.body=[]);bt!==jt;){var i=H();e.body.push(i),n&&B(i)&&T(!0),n=!1}return N(e,"Program")}function H(){(bt===be||bt===Se&&"/="==Ct)&&y(!0);var t=bt,e=L();switch(t){case Rt:case Vt:A();var i=t===Rt;F(me)||j()?e.label=null:bt!==Ft?q():(e.label=lt(),R());for(var r=0;re){var r=E(t);r.left=t,r.operator=Ct;var s=bt;A(),r.right=tt(et(),i,n);var a=N(r,s===Pe||s===Me?"LogicalExpression":"BinaryExpression");return tt(a,e,n)}return t}function et(){if(bt.prefix){var t=L(),e=bt.isUpdate;return t.operator=Ct,t.prefix=!0,St=!0,A(),t.argument=et(),e?V(t.argument):zt&&"delete"===t.operator&&"Identifier"===t.argument.type&&n(t.start,"Deleting local variable in strict mode"),N(t,e?"UpdateExpression":"UnaryExpression")}for(var i=nt();bt.postfix&&!j();){var t=E(i);t.operator=Ct,t.prefix=!1,t.argument=i,V(i),A(),i=N(t,"UpdateExpression")}return i}function nt(){return it(rt())}function it(t,e){if(F(we)){var n=E(t);return n.object=t,n.property=lt(!0),n.computed=!1,it(N(n,"MemberExpression"),e)}if(F(ce)){var n=E(t);return n.object=t,n.property=X(),n.computed=!0,D(fe),it(N(n,"MemberExpression"),e)}if(!e&&F(ge)){var n=E(t);return n.callee=t,n.arguments=ut(ve,!1),it(N(n,"CallExpression"),e)}return t}function rt(){switch(bt){case se:var t=L();return A(),N(t,"ThisExpression");case Ft:return lt();case Et:case Bt:case Nt:var t=L();return t.value=Ct,t.raw=ft.slice(mt,yt),A(),N(t,"Literal");case ae:case oe:case he:var t=L();return t.value=bt.atomValue,t.raw=bt.keyword,A(),N(t,"Literal");case ge:var e=wt,n=mt;A();var i=X();return i.start=n,i.end=yt,ct.locations&&(i.loc.start=e,i.loc.end=xt),ct.ranges&&(i.range=[n,yt]),D(ve),i;case ce:var t=L();return A(),t.elements=ut(fe,!0,!0),N(t,"ArrayExpression");case de:return at();case Jt:var t=L();return A(),ht(t,!1);case re:return st();default:q()}}function st(){var t=L();return A(),t.callee=it(rt(),!0),F(ge)?t.arguments=ut(ve,!1):t.arguments=Lt,N(t,"NewExpression")}function at(){var t=L(),e=!0,i=!1;for(t.properties=[],A();!F(_e);){if(e)e=!1;else if(D(pe),ct.allowTrailingCommas&&F(_e))break;var r,s={key:ot()},a=!1;if(F(ye)?(s.value=X(!0),r=s.kind="init"):ct.ecmaVersion>=5&&"Identifier"===s.key.type&&("get"===s.key.name||"set"===s.key.name)?(a=i=!0,r=s.kind=s.key.name,s.key=ot(),bt!==ge&&q(),s.value=ht(L(),!1)):q(),"Identifier"===s.key.type&&(zt||i))for(var o=0;o=0)for(var h=0;h=170&&$e.test(String.fromCharCode(t)))},Qe=t.isIdentifierChar=function(t){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||t>=170&&Ge.test(String.fromCharCode(t))))},Ye={kind:"loop"},tn={kind:"switch"}}),v.version||(v=null)}var w={"+":"__add","-":"__subtract","*":"__multiply","/":"__divide","%":"__modulo","==":"__equals","!=":"__equals"},x={"-":"__negate","+":"__self"},b=r.each(["add","subtract","multiply","divide","modulo","equals","negate"],function(t){this["__"+t]="#"+t},{__self:function(){return this}});return f.inject(b),_.inject(b),D.inject(b),n&&("complete"===i.readyState?setTimeout(c):Z.add(n,{load:c})),{compile:h,execute:u,load:d,parse:e,calculateBinary:s,calculateUnary:o}}.call(this);var at=new(a.inject(r.exports,{Base:r,Numerical:l,Key:X,DomEvent:Z,DomElement:H,document:i,window:n,Symbol:P,PlacedSymbol:I}));return at.agent.node&&require("./node/extend.js")(at),"function"==typeof define&&define.amd?define("paper",at):"object"==typeof module&&module&&(module.exports=at),at}.call(this,"object"==typeof self?self:null); \ No newline at end of file diff --git a/dist/paper.d.ts b/dist/paper.d.ts index 4dddce28..ee400759 100644 --- a/dist/paper.d.ts +++ b/dist/paper.d.ts @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Sat May 23 14:48:39 2020 +0200 + * Date: Sat May 23 14:54:51 2020 +0200 * * This is an auto-generated type definition. */