255){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=Q.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}),Q.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; i--)
projects[i].remove();
for (var i = tools.length - 1; i >= 0; i--)
tools[i].remove();
- for (var i = palettes.length - 1; i >= 0; i--)
- palettes[i].remove();
},
remove: function() {
@@ -1807,16 +1802,24 @@ var Rectangle = Base.extend({
return new ctor(this.width, this.height, this, 'setSize');
},
+ _fw: 1,
+ _fh: 1,
+
setSize: function() {
- var size = Size.read(arguments);
- if (this._fixX)
- this.x += (this.width - size.width) * this._fixX;
- if (this._fixY)
- this.y += (this.height - size.height) * this._fixY;
- this.width = size.width;
- this.height = size.height;
- this._fixW = 1;
- this._fixH = 1;
+ var size = Size.read(arguments),
+ sx = this._sx,
+ sy = this._sy,
+ w = size.width,
+ h = size.height;
+ if (sx) {
+ this.x += (this.width - w) * sx;
+ }
+ if (sy) {
+ this.y += (this.height - h) * sy;
+ }
+ this.width = w;
+ this.height = h;
+ this._fw = this._fh = 1;
},
getLeft: function() {
@@ -1824,10 +1827,12 @@ var Rectangle = Base.extend({
},
setLeft: function(left) {
- if (!this._fixW)
- this.width -= left - this.x;
+ if (!this._fw) {
+ var amount = left - this.x;
+ this.width -= this._sx === 0.5 ? amount * 2 : amount;
+ }
this.x = left;
- this._fixX = 0;
+ this._sx = this._fw = 0;
},
getTop: function() {
@@ -1835,10 +1840,12 @@ var Rectangle = Base.extend({
},
setTop: function(top) {
- if (!this._fixH)
- this.height -= top - this.y;
+ if (!this._fh) {
+ var amount = top - this.y;
+ this.height -= this._sy === 0.5 ? amount * 2 : amount;
+ }
this.y = top;
- this._fixY = 0;
+ this._sy = this._fh = 0;
},
getRight: function() {
@@ -1846,13 +1853,13 @@ var Rectangle = Base.extend({
},
setRight: function(right) {
- if (this._fixX !== undefined && this._fixX !== 1)
- this._fixW = 0;
- if (this._fixW)
- this.x = right - this.width;
- else
- this.width = right - this.x;
- this._fixX = 1;
+ if (!this._fw) {
+ var amount = right - this.x;
+ this.width = this._sx === 0.5 ? amount * 2 : amount;
+ }
+ this.x = right - this.width;
+ this._sx = 1;
+ this._fw = 0;
},
getBottom: function() {
@@ -1860,31 +1867,47 @@ var Rectangle = Base.extend({
},
setBottom: function(bottom) {
- if (this._fixY !== undefined && this._fixY !== 1)
- this._fixH = 0;
- if (this._fixH)
- this.y = bottom - this.height;
- else
- this.height = bottom - this.y;
- this._fixY = 1;
+ if (!this._fh) {
+ var amount = bottom - this.y;
+ this.height = this._sy === 0.5 ? amount * 2 : amount;
+ }
+ this.y = bottom - this.height;
+ this._sy = 1;
+ this._fh = 0;
},
getCenterX: function() {
- return this.x + this.width * 0.5;
+ return this.x + this.width / 2;
},
setCenterX: function(x) {
- this.x = x - this.width * 0.5;
- this._fixX = 0.5;
+ if (this._fw || this._sx === 0.5) {
+ this.x = x - this.width / 2;
+ } else {
+ if (this._sx) {
+ this.x += (x - this.x) * 2 * this._sx;
+ }
+ this.width = (x - this.x) * 2;
+ }
+ this._sx = 0.5;
+ this._fw = 0;
},
getCenterY: function() {
- return this.y + this.height * 0.5;
+ return this.y + this.height / 2;
},
setCenterY: function(y) {
- this.y = y - this.height * 0.5;
- this._fixY = 0.5;
+ if (this._fh || this._sy === 0.5) {
+ this.y = y - this.height / 2;
+ } else {
+ if (this._sy) {
+ this.y += (y - this.y) * 2 * this._sy;
+ }
+ this.height = (y - this.y) * 2;
+ }
+ this._sy = 0.5;
+ this._fh = 0;
},
getCenter: function(_dontLink) {
@@ -1931,19 +1954,12 @@ var Rectangle = Base.extend({
},
intersects: function() {
- var rect = Rectangle.read(arguments);
- return rect.x + rect.width > this.x
- && rect.y + rect.height > this.y
- && rect.x < this.x + this.width
- && rect.y < this.y + this.height;
- },
-
- touches: function() {
- var rect = Rectangle.read(arguments);
- return rect.x + rect.width >= this.x
- && rect.y + rect.height >= this.y
- && rect.x <= this.x + this.width
- && rect.y <= this.y + this.height;
+ var rect = Rectangle.read(arguments),
+ epsilon = Base.read(arguments) || 0;
+ return rect.x + rect.width > this.x - epsilon
+ && rect.y + rect.height > this.y - epsilon
+ && rect.x < this.x + this.width + epsilon
+ && rect.y < this.y + this.height + epsilon;
},
intersect: function() {
@@ -2552,9 +2568,12 @@ var Line = Base.extend({
},
getDistance: function(point) {
- return Math.abs(Line.getSignedDistance(
- this._px, this._py, this._vx, this._vy,
- point.x, point.y, true));
+ return Math.abs(this.getSignedDistance(point));
+ },
+
+ getSignedDistance: function(point) {
+ return Line.getSignedDistance(this._px, this._py, this._vx, this._vy,
+ point.x, point.y, true);
},
isCollinear: function(line) {
@@ -2745,7 +2764,7 @@ var Project = PaperScopeItem.extend({
for (var id in selectionItems) {
var item = selectionItems[id],
selection = item._selection;
- if (selection & 1 && item.isInserted()) {
+ if ((selection & 1) && item.isInserted()) {
items.push(item);
} else if (!selection) {
this._updateSelection(item);
@@ -2972,7 +2991,7 @@ new function() {
matrix.translate(point);
matrix._owner = this;
this._style = new Style(project._currentStyle, this, project);
- if (internal || hasProps && props.insert === false
+ if (internal || hasProps && props.insert == false
|| !settings.insertItems && !(hasProps && props.insert === true)) {
this._setProject(project);
} else {
@@ -3066,15 +3085,18 @@ new function() {
}, Base.each(['locked', 'visible', 'blendMode', 'opacity', 'guide'],
function(name) {
var part = Base.capitalize(name),
- name = '_' + name;
+ key = '_' + name,
+ flags = {
+ locked: 128,
+ visible: 137
+ };
this['get' + part] = function() {
- return this[name];
+ return this[key];
};
this['set' + part] = function(value) {
- if (value != this[name]) {
- this[name] = value;
- this._changed(name === '_locked'
- ? 128 : 129);
+ if (value != this[key]) {
+ this[key] = value;
+ this._changed(flags[name] || 129);
}
};
},
@@ -3251,9 +3273,9 @@ new function() {
return Item._getBounds(children, matrix, options);
},
- _getCachedBounds: function(matrix, options) {
+ _getCachedBounds: function(matrix, options, noInternal) {
matrix = matrix && matrix._orNullIfIdentity();
- var internal = options.internal,
+ var internal = options.internal && !noInternal,
cacheItem = options.cacheItem,
_matrix = internal ? null : this._matrix._orNullIfIdentity(),
cacheKey = cacheItem && (!matrix || matrix.equals(_matrix)) && [
@@ -3270,7 +3292,7 @@ new function() {
this._bounds = {};
var cached = this._bounds[cacheKey] = {
rect: bounds.clone(),
- internal: options.internal
+ internal: internal
};
}
return bounds;
@@ -3324,7 +3346,7 @@ new function() {
var item = items[i];
if (item._visible && !item.isEmpty()) {
var rect = item._getCachedBounds(
- matrix && matrix.appended(item._matrix), options);
+ matrix && matrix.appended(item._matrix), options, true);
x1 = Math.min(rect.x, x1);
y1 = Math.min(rect.y, y1);
x2 = Math.max(rect.x + rect.width, x2);
@@ -3691,7 +3713,7 @@ new function() {
tolerance = Math.max(options.tolerance, 1e-12),
tolerancePadding = options._tolerancePadding = new Size(
Path._getStrokePadding(tolerance,
- matrix.inverted()._shiftless()));
+ matrix._shiftless().invert()));
point = matrix._inverseTransform(point);
if (!point || !this._children &&
!this.getBounds({ internal: true, stroke: true, handle: true })
@@ -3716,26 +3738,33 @@ new function() {
return hit;
}
- function checkBounds(type, part) {
- var pt = bounds['get' + part]();
+ function checkPoint(type, part) {
+ var pt = part ? bounds['get' + part]() : that.getPosition();
if (point.subtract(pt).divide(tolerancePadding).length <= 1) {
- return new HitResult(type, that,
- { name: Base.hyphenate(part), point: pt });
+ return new HitResult(type, that, {
+ name: part ? Base.hyphenate(part) : type,
+ point: pt
+ });
}
}
- if (checkSelf && (options.center || options.bounds) && this._parent) {
- bounds = this.getInternalBounds();
- if (options.center) {
- res = checkBounds('center', 'Center');
+ var checkPosition = options.position,
+ checkCenter = options.center,
+ checkBounds = options.bounds;
+ if (checkSelf && this._parent
+ && (checkPosition || checkCenter || checkBounds)) {
+ if (checkCenter || checkBounds) {
+ bounds = this.getInternalBounds();
}
- if (!res && options.bounds) {
+ res = checkPosition && checkPoint('position') ||
+ checkCenter && checkPoint('center', 'Center');
+ if (!res && checkBounds) {
var points = [
'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight',
'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'
];
for (var i = 0; i < 8 && !res; i++) {
- res = checkBounds('bounds', points[i]);
+ res = checkPoint('bounds', points[i]);
}
}
res = filter(res);
@@ -3746,7 +3775,7 @@ new function() {
|| checkSelf
&& filter(this._hitTestSelf(point, options, viewMatrix,
this.getStrokeScaling() ? null
- : viewMatrix.inverted()._shiftless()))
+ : viewMatrix._shiftless().invert()))
|| null;
}
if (res && res.point) {
@@ -3900,12 +3929,15 @@ new function() {
var children = this._children;
if (children && items && items.length > 0) {
items = Base.slice(items);
+ var inserted = {};
for (var i = items.length - 1; i >= 0; i--) {
- var item = items[i];
- if (!item) {
+ var item = items[i],
+ id = item && item._id;
+ if (!item || inserted[id]) {
items.splice(i, 1);
} else {
item._remove(false, true);
+ inserted[id] = true;
}
}
Base.splice(children, items, index, 0);
@@ -3919,7 +3951,7 @@ new function() {
if (name)
item.setName(name);
if (notifySelf)
- this._changed(5);
+ item._changed(5);
}
this._changed(11);
} else {
@@ -3968,8 +4000,12 @@ new function() {
moveBelow: '#insertBelow',
+ addTo: function(owner) {
+ return owner._insertItem(undefined, this);
+ },
+
copyTo: function(owner) {
- return owner._insertItem(undefined, this.clone(false));
+ return this.clone(false).addTo(owner);
},
reduce: function(options) {
@@ -4185,31 +4221,38 @@ new function() {
if (matrix && matrix.isIdentity())
matrix = null;
var _matrix = this._matrix,
+ transform = matrix && !matrix.isIdentity(),
applyMatrix = (_applyMatrix || this._applyMatrix)
- && ((!_matrix.isIdentity() || matrix)
+ && ((!_matrix.isIdentity() || transform)
|| _applyMatrix && _applyRecursively && this._children);
- if (!matrix && !applyMatrix)
+ if (!transform && !applyMatrix)
return this;
- if (matrix) {
+ if (transform) {
if (!matrix.isInvertible() && _matrix.isInvertible())
_matrix._backup = _matrix.getValues();
_matrix.prepend(matrix);
}
- if (applyMatrix = applyMatrix && this._transformContent(_matrix,
- _applyRecursively, _setApplyMatrix)) {
- var pivot = this._pivot,
- style = this._style,
+ if (applyMatrix) {
+ if (this._transformContent(_matrix, _applyRecursively,
+ _setApplyMatrix)) {
+ var pivot = this._pivot;
+ if (pivot)
+ _matrix._transformPoint(pivot, pivot, true);
+ _matrix.reset(true);
+ if (_setApplyMatrix && this._canApplyMatrix)
+ this._applyMatrix = true;
+ } else {
+ applyMatrix = transform = false;
+ }
+ }
+ if (transform) {
+ var style = this._style,
fillColor = style.getFillColor(true),
strokeColor = style.getStrokeColor(true);
- if (pivot)
- _matrix._transformPoint(pivot, pivot, true);
if (fillColor)
- fillColor.transform(_matrix);
+ fillColor.transform(matrix);
if (strokeColor)
- strokeColor.transform(_matrix);
- _matrix.reset(true);
- if (_setApplyMatrix && this._canApplyMatrix)
- this._applyMatrix = true;
+ strokeColor.transform(matrix);
}
var bounds = this._bounds,
position = this._position;
@@ -4278,12 +4321,13 @@ new function() {
}), {
_setStyles: function(ctx, param, viewMatrix) {
- var style = this._style;
+ var style = this._style,
+ matrix = this._matrix;
if (style.hasFill()) {
- ctx.fillStyle = style.getFillColor().toCanvasStyle(ctx);
+ ctx.fillStyle = style.getFillColor().toCanvasStyle(ctx, matrix);
}
if (style.hasStroke()) {
- ctx.strokeStyle = style.getStrokeColor().toCanvasStyle(ctx);
+ ctx.strokeStyle = style.getStrokeColor().toCanvasStyle(ctx, matrix);
ctx.lineWidth = style.getStrokeWidth();
var strokeJoin = style.getStrokeJoin(),
strokeCap = style.getStrokeCap(),
@@ -4612,8 +4656,8 @@ var Shape = Item.extend({
radius: null
},
- initialize: function Shape(props) {
- this._initialize(props);
+ initialize: function Shape(props, point) {
+ this._initialize(props, point);
},
_equals: function(item) {
@@ -4720,6 +4764,10 @@ var Shape = Item.extend({
toShape: '#clone',
+ _asPathItem: function() {
+ return this.toPath(false);
+ },
+
_draw: function(ctx, param, viewMatrix, strokeMatrix) {
var style = this._style,
hasFill = style.hasFill(),
@@ -4887,11 +4935,11 @@ new function() {
statics: new function() {
function createShape(type, point, size, radius, args) {
- var item = new Shape(Base.getNamed(args));
+ var item = new Shape(Base.getNamed(args), point);
item._type = type;
item._size = size;
item._radius = radius;
- return item.translate(point);
+ return item;
}
return {
@@ -5356,7 +5404,7 @@ var SymbolItem = Item.extend({
return item._getCachedBounds(item._matrix.prepended(matrix), options);
},
- _hitTestSelf: function(point, options, viewMatrix, strokeMatrix) {
+ _hitTestSelf: function(point, options, viewMatrix) {
var res = this._definition._item._hitTest(point, options, viewMatrix);
if (res)
res.item = this;
@@ -5452,6 +5500,7 @@ var HitResult = Base.extend({
segments: !options,
handles: false,
ends: false,
+ position: false,
center: false,
bounds: false,
guides: false,
@@ -6806,23 +6855,17 @@ new function() {
},
new function() {
- function addLocation(locations, include, c1, t1, p1, c2, t2, p2, overlap) {
+ function addLocation(locations, include, c1, t1, c2, t2, overlap) {
var excludeStart = !overlap && c1.getPrevious() === c2,
excludeEnd = !overlap && c1 !== c2 && c1.getNext() === c2,
tMin = 1e-8,
tMax = 1 - tMin;
- if (t1 == null)
- t1 = c1.getTimeOf(p1);
if (t1 !== null && t1 >= (excludeStart ? tMin : 0) &&
t1 <= (excludeEnd ? tMax : 1)) {
- if (t2 == null)
- t2 = c2.getTimeOf(p2);
if (t2 !== null && t2 >= (excludeEnd ? tMin : 0) &&
t2 <= (excludeStart ? tMax : 1)) {
- var loc1 = new CurveLocation(c1, t1,
- p1 || c1.getPointAtTime(t1), overlap),
- loc2 = new CurveLocation(c2, t2,
- p2 || c2.getPointAtTime(t2), overlap);
+ var loc1 = new CurveLocation(c1, t1, null, overlap),
+ loc2 = new CurveLocation(c2, t2, null, overlap);
loc1._intersection = loc2;
loc2._intersection = loc1;
if (!include || include(loc1)) {
@@ -6865,8 +6908,8 @@ new function() {
var t = (tMinNew + tMaxNew) / 2,
u = (uMin + uMax) / 2;
addLocation(locations, include,
- flip ? c2 : c1, flip ? u : t, null,
- flip ? c1 : c2, flip ? t : u, null);
+ flip ? c2 : c1, flip ? u : t,
+ flip ? c1 : c2, flip ? t : u);
} else {
v1 = Curve.getPart(v1, tMinClip, tMaxClip);
if (tMaxClip - tMinClip > 0.8) {
@@ -6984,10 +7027,9 @@ new function() {
p1 = Curve.getPoint(v1, t1),
t2 = Curve.getTimeOf(v2, p1);
if (t2 !== null) {
- var p2 = Curve.getPoint(v2, t2);
addLocation(locations, include,
- flip ? c2 : c1, flip ? t2 : t1, flip ? p2 : p1,
- flip ? c1 : c2, flip ? t1 : t2, flip ? p1 : p2);
+ flip ? c2 : c1, flip ? t2 : t1,
+ flip ? c1 : c2, flip ? t1 : t2);
}
}
}
@@ -6997,7 +7039,9 @@ new function() {
v1[0], v1[1], v1[6], v1[7],
v2[0], v2[1], v2[6], v2[7]);
if (pt) {
- addLocation(locations, include, c1, null, pt, c2, null, pt);
+ addLocation(locations, include,
+ c1, Curve.getTimeOf(v1, pt),
+ c2, Curve.getTimeOf(v2, pt));
}
}
@@ -7019,14 +7063,15 @@ new function() {
for (var i = 0; i < 2; i++) {
var overlap = overlaps[i];
addLocation(locations, include,
- c1, overlap[0], null,
- c2, overlap[1], null, true);
+ c1, overlap[0],
+ c2, overlap[1], true);
}
} else {
var straight1 = Curve.isStraight(v1),
straight2 = Curve.isStraight(v2),
straight = straight1 && straight2,
- flip = straight1 && !straight2;
+ flip = straight1 && !straight2,
+ before = locations.length;
(straight
? addLineIntersection
: straight1 || straight2
@@ -7036,6 +7081,21 @@ new function() {
flip ? c2 : c1, flip ? c1 : c2,
locations, include, flip,
0, 0, 0, 1, 0, 1);
+ if (!straight || locations.length === before) {
+ for (var i = 0; i < 4; i++) {
+ var t1 = i >> 1,
+ t2 = i & 1,
+ i1 = t1 * 6,
+ i2 = t2 * 6,
+ p1 = new Point(v1[i1], v1[i1 + 1]),
+ p2 = new Point(v2[i2], v2[i2 + 1]);
+ if (p1.isClose(p2, epsilon)) {
+ addLocation(locations, include,
+ c1, t1,
+ c2, t2);
+ }
+ }
+ }
}
}
return locations;
@@ -7046,8 +7106,8 @@ new function() {
if (info.type === 'loop') {
var roots = info.roots;
addLocation(locations, include,
- c1, roots[0], null,
- c1, roots[1], null);
+ c1, roots[0],
+ c1, roots[1]);
}
return locations;
}
@@ -7699,7 +7759,8 @@ var PathItem = Item.extend({
matrix1 = this._matrix._orNullIfIdentity(),
matrix2 = self ? matrix1
: (_matrix || path._matrix)._orNullIfIdentity();
- return self || this.getBounds(matrix1).touches(path.getBounds(matrix2))
+ return self || this.getBounds(matrix1).intersects(
+ path.getBounds(matrix2), 1e-12)
? Curve.getIntersections(
this.getCurves(), !self && path.getCurves(), include,
matrix1, matrix2, _returnFirst)
@@ -9084,7 +9145,7 @@ new function() {
extent += extent < 0 ? 360 : -360;
}
}
- var epsilon = 1e-12,
+ var epsilon = 1e-7,
ext = abs(extent),
count = ext >= 360 ? 4 : Math.ceil((ext - epsilon) / 90),
inc = extent / count,
@@ -9315,14 +9376,15 @@ statics: {
addPoint, isArea) {
var point = segment._point.transform(matrix),
loc = segment.getLocation(),
- normal = loc.getNormal().multiply(radius).transform(strokeMatrix);
+ normal = loc.getNormal()
+ .multiply(loc.getTime() === 0 ? radius : -radius)
+ .transform(strokeMatrix);
if (cap === 'square') {
if (isArea) {
addPoint(point.subtract(normal));
addPoint(point.add(normal));
}
- point = point.add(normal.rotate(
- loc.getTime() === 0 ? -90 : 90));
+ point = point.add(normal.rotate(-90));
}
addPoint(point.add(normal));
addPoint(point.subtract(normal));
@@ -9384,10 +9446,10 @@ Path.inject({ statics: new function() {
function createPath(segments, closed, args) {
var props = Base.getNamed(args),
- path = new Path(props && props.insert === false && Item.NO_INSERT);
+ path = new Path(props && props.insert == false && Item.NO_INSERT);
path._add(segments);
path._closed = closed;
- return path.set(props);
+ return path.set(props, { insert: true });
}
function createEllipse(center, radius, args) {
@@ -9467,7 +9529,7 @@ Path.inject({ statics: new function() {
through = Point.readNamed(arguments, 'through'),
to = Point.readNamed(arguments, 'to'),
props = Base.getNamed(arguments),
- path = new Path(props && props.insert === false
+ path = new Path(props && props.insert == false
&& Item.NO_INSERT);
path.moveTo(from);
path.arcTo(through, to);
@@ -9742,12 +9804,11 @@ PathItem.inject(new function() {
: res;
}
- function createResult(ctor, paths, reduce, path1, path2, options) {
- var result = new ctor(Item.NO_INSERT);
+ function createResult(paths, simplify, path1, path2, options) {
+ var result = new CompoundPath(Item.NO_INSERT);
result.addChildren(paths, true);
- if (reduce)
- result = result.reduce({ simplify: true });
- if (!(options && options.insert === false)) {
+ result = result.reduce({ simplify: simplify });
+ if (!(options && options.insert == false)) {
result.insertAbove(path2 && path1.isSibling(path2)
&& path1.getIndex() < path2.getIndex() ? path2 : path1);
}
@@ -9755,10 +9816,10 @@ PathItem.inject(new function() {
return result;
}
- function computeBoolean(path1, path2, operation, options) {
- if (options && options.stroke &&
+ function traceBoolean(path1, path2, operation, options) {
+ if (options && (options.trace == false || options.stroke) &&
/^(subtract|intersect)$/.test(operation))
- return computeStrokeBoolean(path1, path2, operation === 'subtract');
+ return splitBoolean(path1, path2, operation);
var _path1 = preparePath(path1, true),
_path2 = path2 && path1 !== path2 && preparePath(path2, true),
operator = operators[operation];
@@ -9809,20 +9870,24 @@ PathItem.inject(new function() {
});
}
- return createResult(CompoundPath, paths, true, path1, path2, options);
+ return createResult(paths, true, path1, path2, options);
}
- function computeStrokeBoolean(path1, path2, subtract) {
+ function splitBoolean(path1, path2, operation) {
var _path1 = preparePath(path1),
_path2 = preparePath(path2),
crossings = _path1.getCrossings(_path2),
+ subtract = operation === 'subtract',
+ divide = operation === 'divide',
+ added = {},
paths = [];
function addPath(path) {
- if (_path2.contains(path.getPointAt(path.getLength() / 2))
- ^ subtract) {
+ if (!added[path._id] && (divide ||
+ _path2.contains(path.getPointAt(path.getLength() / 2))
+ ^ subtract)) {
paths.unshift(path);
- return true;
+ return added[path._id] = true;
}
}
@@ -9835,7 +9900,7 @@ PathItem.inject(new function() {
}
}
addPath(_path1);
- return createResult(Group, paths, false, path1, path2);
+ return createResult(paths, false, path1, path2);
}
function linkIntersections(from, to) {
@@ -9997,7 +10062,10 @@ PathItem.inject(new function() {
paR = pa + windingEpsilon,
windingL = 0,
windingR = 0,
+ pathWindingL = 0,
+ pathWindingR = 0,
onPath = false,
+ onAnyPath = false,
quality = 1,
roots = [],
vPrev,
@@ -10023,9 +10091,9 @@ PathItem.inject(new function() {
: po === o3 ? 1
: paL > max(a0, a1, a2, a3) || paR < min(a0, a1, a2, a3)
? 1
- : Curve.solveCubic(v, io, po, roots, 0, 1) === 1
+ : Curve.solveCubic(v, io, po, roots, 0, 1) > 0
? roots[0]
- : 0.5,
+ : 1,
a = t === 0 ? a0
: t === 1 ? a3
: Curve.getPoint(v, t)[dir ? 'y' : 'x'],
@@ -10034,9 +10102,9 @@ PathItem.inject(new function() {
a3Prev = vPrev[ia + 6];
if (po !== o0) {
if (a < paL) {
- windingL += winding;
+ pathWindingL += winding;
} else if (a > paR) {
- windingR += winding;
+ pathWindingR += winding;
} else {
onPath = true;
}
@@ -10045,16 +10113,16 @@ PathItem.inject(new function() {
} else {
if (winding !== windingPrev) {
if (a0 < paL) {
- windingL += winding;
+ pathWindingL += winding;
} else if (a0 > paR) {
- windingR += winding;
+ pathWindingR += winding;
}
} else if (a0 != a3Prev) {
if (a3Prev < paR && a > paR) {
- windingR += winding;
+ pathWindingR += winding;
onPath = true;
} else if (a3Prev > paL && a < paL) {
- windingL += winding;
+ pathWindingL += winding;
onPath = true;
}
}
@@ -10063,7 +10131,7 @@ PathItem.inject(new function() {
vPrev = v;
return !dontFlip && a > paL && a < paR
&& Curve.getTangent(v, t)[dir ? 'x' : 'y'] === 0
- && getWinding(point, curves, dir ? 0 : 1, closed, true);
+ && getWinding(point, curves, !dir, closed, true);
}
function handleCurve(v) {
@@ -10124,6 +10192,17 @@ PathItem.inject(new function() {
if (i + 1 === l || curves[i + 1]._path !== path) {
if (vClose && (res = handleCurve(vClose)))
return res;
+ if (onPath && !pathWindingL && !pathWindingR) {
+ pathWindingL = pathWindingR = path.isClockwise(closed) ^ dir
+ ? 1 : -1;
+ }
+ windingL += pathWindingL;
+ windingR += pathWindingR;
+ pathWindingL = pathWindingR = 0;
+ if (onPath) {
+ onAnyPath = true;
+ onPath = false;
+ }
vClose = null;
}
}
@@ -10134,7 +10213,7 @@ PathItem.inject(new function() {
windingL: windingL,
windingR: windingR,
quality: quality,
- onPath: onPath
+ onPath: onAnyPath
};
}
@@ -10151,8 +10230,7 @@ PathItem.inject(new function() {
segment = segment.getNext();
} while (segment && !segment._intersection && segment !== start);
var offsets = [0.5, 0.25, 0.75],
- windingZero = { winding: 0, quality: 0 },
- winding = windingZero,
+ winding = { winding: 0, quality: -1 },
tMin = 1e-8,
tMax = 1 - tMin;
for (var i = 0; i < offsets.length && winding.quality < 0.5; i++) {
@@ -10164,19 +10242,17 @@ PathItem.inject(new function() {
var curve = entry.curve,
path = curve._path,
parent = path._parent,
+ operand = parent instanceof CompoundPath ? parent : path,
t = Numerical.clamp(curve.getTimeAt(length), tMin, tMax),
pt = curve.getPointAtTime(t),
- dir = abs(curve.getTangentAtTime(t).normalize().y)
- < Math.SQRT1_2 ? 1 : 0;
- if (parent instanceof CompoundPath)
- path = parent;
+ dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
var wind = !(operator.subtract && path2 && (
- path === path1 &&
+ operand === path1 &&
path2._getWinding(pt, dir, true).winding ||
- path === path2 &&
+ operand === path2 &&
!path1._getWinding(pt, dir, true).winding))
? getWinding(pt, curves, dir, true)
- : windingZero;
+ : { winding: 0, quality: 1 };
if (wind.quality > winding.quality)
winding = wind;
break;
@@ -10366,26 +10442,28 @@ PathItem.inject(new function() {
},
unite: function(path, options) {
- return computeBoolean(this, path, 'unite', options);
+ return traceBoolean(this, path, 'unite', options);
},
intersect: function(path, options) {
- return computeBoolean(this, path, 'intersect', options);
+ return traceBoolean(this, path, 'intersect', options);
},
- subtract: function(path) {
- return computeBoolean(this, path, 'subtract');
+ subtract: function(path, options) {
+ return traceBoolean(this, path, 'subtract', options);
},
exclude: function(path, options) {
- return computeBoolean(this, path, 'exclude', options);
+ return traceBoolean(this, path, 'exclude', options);
},
divide: function(path, options) {
- return createResult(Group, [
- this.subtract(path, options),
- this.intersect(path, options)
- ], true, this, path, options);
+ return options && (options.trace == false || options.stroke)
+ ? splitBoolean(this, path, 'divide')
+ : createResult([
+ this.subtract(path, options),
+ this.intersect(path, options)
+ ], true, this, path, options);
},
resolveCrossings: function() {
@@ -11378,7 +11456,7 @@ var Color = Base.extend(new function() {
+ components.join(',') + ')';
},
- toCanvasStyle: function(ctx) {
+ toCanvasStyle: function(ctx, matrix) {
if (this._canvasStyle)
return this._canvasStyle;
if (this._type !== 'gradient')
@@ -11388,10 +11466,17 @@ var Color = Base.extend(new function() {
stops = gradient._stops,
origin = components[1],
destination = components[2],
+ highlight = components[3],
+ inverse = matrix && matrix.inverted(),
canvasGradient;
+ if (inverse) {
+ origin = inverse._transformPoint(origin);
+ destination = inverse._transformPoint(destination);
+ if (highlight)
+ highlight = inverse._transformPoint(highlight);
+ }
if (gradient._radial) {
- var radius = destination.getDistance(origin),
- highlight = components[3];
+ var radius = destination.getDistance(origin);
if (highlight) {
var vector = highlight.subtract(origin);
if (vector.getLength() > radius)
@@ -11791,7 +11876,6 @@ var Style = Base.extend(new function() {
return fields;
}, {
set: function(style) {
- this._values = {};
var isStyle = style instanceof Style,
values = isStyle ? style._values : style;
if (values) {
@@ -12695,7 +12779,13 @@ new function() {
dblClick = hitItem === clickItem
&& (Date.now() - clickTime < 300);
downItem = clickItem = hitItem;
- dragItem = !prevented && hitItem;
+ if (!prevented && hitItem) {
+ var item = hitItem;
+ while (item && !item.responds('mousedrag'))
+ item = item._parent;
+ if (item)
+ dragItem = hitItem;
+ }
downPoint = point;
} else if (mouse.up) {
if (!prevented && hitItem === downItem) {
@@ -13760,7 +13850,7 @@ new function() {
attrs.y -= size.height / 2;
attrs.width = size.width;
attrs.height = size.height;
- attrs.href = options.embedImages === false && image && image.src
+ attrs.href = options.embedImages == false && image && image.src
|| item.toDataURL();
return SvgElement.create('image', attrs, formatter);
}
@@ -14357,10 +14447,6 @@ new function() {
.translate(bounds.getPoint())
.scale(bounds.getSize()));
}
- if (item instanceof Shape) {
- color.transform(new Matrix().translate(
- item.getPosition(true).negate()));
- }
}
}
}
@@ -14460,17 +14546,19 @@ new function() {
}
function applyAttributes(item, node, isRoot) {
- var parent = node.parentNode,
- styles = {
- node: DomElement.getStyles(node) || {},
- parent: !isRoot && !/^defs$/i.test(parent.tagName)
- && DomElement.getStyles(parent) || {}
- };
- Base.each(attributes, function(apply, name) {
- var value = getAttribute(node, name, styles);
- item = value !== undefined && apply(item, value, name, node, styles)
- || item;
- });
+ if (node.style) {
+ var parent = node.parentNode,
+ styles = {
+ node: DomElement.getStyles(node) || {},
+ parent: !isRoot && !/^defs$/i.test(parent.tagName)
+ && DomElement.getStyles(parent) || {}
+ };
+ Base.each(attributes, function(apply, name) {
+ var value = getAttribute(node, name, styles);
+ item = value !== undefined
+ && apply(item, value, name, node, styles) || item;
+ });
+ }
return item;
}
@@ -14495,8 +14583,8 @@ new function() {
parent,
next;
if (isRoot && isElement) {
- rootSize = getSize(node, null, null, true)
- || paper.getView().getSize();
+ rootSize = paper.getView().getSize();
+ rootSize = getSize(node, null, null, true) || rootSize;
container = SvgElement.create('svg', {
style: 'stroke-width: 1px; stroke-miterlimit: 10'
});
@@ -14627,9 +14715,1331 @@ new function() {
};
Base.exports.PaperScript = function() {
- var exports, define,
- scope = this;
-!function(e,r){return"object"==typeof exports&&"object"==typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):void r(e.acorn||(e.acorn={}))}(this,function(e){"use strict";function r(e){fe=e||{};for(var r in he)Object.prototype.hasOwnProperty.call(fe,r)||(fe[r]=he[r]);me=fe.sourceFile||null}function t(e,r){var t=ve(de,e);r+=" ("+t.line+":"+t.column+")";var n=new SyntaxError(r);throw n.pos=e,n.loc=t,n.raisedAt=be,n}function n(e){function r(e){if(1==e.length)return t+="return str === "+JSON.stringify(e[0])+";";t+="switch(str){";for(var r=0;r3){n.sort(function(e,r){return r.length-e.length}),t+="switch(str.length){";for(var a=0;a8&&e<14)++be;else if(47===e){var r=de.charCodeAt(be+1);if(42===r)s();else{if(47!==r)break;c()}}else if(160===e)++be;else{if(!(e>=5760&&Jr.test(String.fromCharCode(e))))break;++be}}}function l(){var e=de.charCodeAt(be+1);return e>=48&&e<=57?E(!0):(++be,i(xr))}function f(){var e=de.charCodeAt(be+1);return Ee?(++be,k()):61===e?x(Er,2):x(wr,1)}function d(){var e=de.charCodeAt(be+1);return 61===e?x(Er,2):x(jr,1)}function p(e){var r=de.charCodeAt(be+1);return r===e?x(124===e?Ir:Lr,2):61===r?x(Er,2):x(124===e?Ur:Rr,1)}function m(){var e=de.charCodeAt(be+1);return 61===e?x(Er,2):x(Fr,1)}function h(e){var r=de.charCodeAt(be+1);return r===e?45==r&&62==de.charCodeAt(be+2)&&Gr.test(de.slice(Le,be))?(be+=3,c(),u(),g()):x(Ar,2):61===r?x(Er,2):x(qr,1)}function v(e){var r=de.charCodeAt(be+1),t=1;return r===e?(t=62===e&&62===de.charCodeAt(be+2)?3:2,61===de.charCodeAt(be+t)?x(Er,t+1):x(Tr,t)):33==r&&60==e&&45==de.charCodeAt(be+2)&&45==de.charCodeAt(be+3)?(be+=4,c(),u(),g()):(61===r&&(t=61===de.charCodeAt(be+2)?3:2),x(Vr,t))}function b(e){var r=de.charCodeAt(be+1);return 61===r?x(Or,61===de.charCodeAt(be+2)?3:2):x(61===e?Cr:Sr,1)}function y(e){switch(e){case 46:return l();case 40:return++be,i(hr);case 41:return++be,i(vr);case 59:return++be,i(yr);case 44:return++be,i(br);case 91:return++be,i(fr);case 93:return++be,i(dr);case 123:return++be,i(pr);case 125:return++be,i(mr);case 58:return++be,i(gr);case 63:return++be,i(kr);case 48:var r=de.charCodeAt(be+1);if(120===r||88===r)return C();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return E(!1);case 34:case 39:return A(e);case 47:return f(e);case 37:case 42:return d();case 124:case 38:return p(e);case 94:return m();case 43:case 45:return h(e);case 60:case 62:return v(e);case 61:case 33:return b(e);case 126:return x(Sr,1)}return!1}function g(e){if(e?be=ye+1:ye=be,fe.locations&&(xe=new a),e)return k();if(be>=pe)return i(Be);var r=de.charCodeAt(be);if(Qr(r)||92===r)return L();var n=y(r);if(n===!1){var o=String.fromCharCode(r);if("\\"===o||$r.test(o))return L();t(be,"Unexpected character '"+o+"'")}return n}function x(e,r){var t=de.slice(be,be+r);be+=r,i(e,t)}function k(){for(var e,r,n="",a=be;;){be>=pe&&t(a,"Unterminated regular expression");var o=de.charAt(be);if(Gr.test(o)&&t(a,"Unterminated regular expression"),e)e=!1;else{if("["===o)r=!0;else if("]"===o&&r)r=!1;else if("/"===o&&!r)break;e="\\"===o}++be}var n=de.slice(a,be);++be;var s=I();s&&!/^[gmsiy]*$/.test(s)&&t(a,"Invalid regexp flag");try{var c=new RegExp(n,s)}catch(u){u instanceof SyntaxError&&t(a,u.message),t(u)}return i(qe,c)}function w(e,r){for(var t=be,n=0,a=0,o=null==r?1/0:r;a=97?s-97+10:s>=65?s-65+10:s>=48&&s<=57?s-48:1/0,i>=e)break;++be,n=n*e+i}return be===t||null!=r&&be-t!==r?null:n}function C(){be+=2;var e=w(16);return null==e&&t(ye+2,"Expected hexadecimal number"),Qr(de.charCodeAt(be))&&t(be,"Identifier directly after number"),i(Te,e)}function E(e){var r=be,n=!1,a=48===de.charCodeAt(be);e||null!==w(10)||t(r,"Invalid number"),46===de.charCodeAt(be)&&(++be,w(10),n=!0);var o=de.charCodeAt(be);69!==o&&101!==o||(o=de.charCodeAt(++be),43!==o&&45!==o||++be,null===w(10)&&t(r,"Invalid number"),n=!0),Qr(de.charCodeAt(be))&&t(be,"Identifier directly after number");var s,c=de.slice(r,be);return n?s=parseFloat(c):a&&1!==c.length?/[89]/.test(c)||Oe?t(r,"Invalid number"):s=parseInt(c,8):s=parseInt(c,10),i(Te,s)}function A(e){be++;for(var r="";;){be>=pe&&t(ye,"Unterminated string constant");var n=de.charCodeAt(be);if(n===e)return++be,i(je,r);if(92===n){n=de.charCodeAt(++be);var a=/^[0-7]+/.exec(de.slice(be,be+3));for(a&&(a=a[0]);a&&parseInt(a,8)>255;)a=a.slice(0,-1);if("0"===a&&(a=null),++be,a)Oe&&t(be-2,"Octal literal in strict mode"),r+=String.fromCharCode(parseInt(a,8)),be+=a.length-1;else switch(n){case 110:r+="\n";break;case 114:r+="\r";break;case 120:r+=String.fromCharCode(S(2));break;case 117:r+=String.fromCharCode(S(4));break;case 85:r+=String.fromCharCode(S(8));break;case 116:r+="\t";break;case 98:r+="\b";break;case 118:r+="\x0B";break;case 102:r+="\f";break;case 48:r+="\0";break;case 13:10===de.charCodeAt(be)&&++be;case 10:fe.locations&&(Se=be,++Ae);break;default:r+=String.fromCharCode(n)}}else 13!==n&&10!==n&&8232!==n&&8233!==n||t(ye,"Unterminated string constant"),r+=String.fromCharCode(n),++be}}function S(e){var r=w(16,e);return null===r&&t(ye,"Bad character escape sequence"),r}function I(){Br=!1;for(var e,r=!0,n=be;;){var a=de.charCodeAt(be);if(Yr(a))Br&&(e+=de.charAt(be)),++be;else{if(92!==a)break;Br||(e=de.slice(n,be)),Br=!0,117!=de.charCodeAt(++be)&&t(be,"Expecting Unicode escape sequence \\uXXXX"),++be;var o=S(4),i=String.fromCharCode(o);i||t(be-1,"Invalid Unicode escape"),(r?Qr(o):Yr(o))||t(be-4,"Invalid Unicode escape"),e+=i}r=!1}return Br?e:de.slice(n,be)}function L(){var e=I(),r=De;return!Br&&Wr(e)&&(r=lr[e]),i(r,e)}function U(){Ie=ye,Le=ge,Ue=ke,g()}function F(e){if(Oe=e,be=ye,fe.locations)for(;be=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}function D(e){if(we===e)return U(),!0}function B(){return!fe.strictSemicolons&&(we===Be||we===mr||Gr.test(de.slice(Le,ye)))}function M(){D(yr)||B()||X()}function z(e){we===e?U():X()}function X(){t(ye,"Unexpected token")}function N(e){"Identifier"!==e.type&&"MemberExpression"!==e.type&&t(e.start,"Assigning to rvalue"),Oe&&"Identifier"===e.type&&Nr(e.name)&&t(e.start,"Assigning to "+e.name+" in strict mode")}function W(e){Ie=Le=be,fe.locations&&(Ue=new a),Fe=Oe=null,Re=[],g();var r=e||V(),t=!0;for(e||(r.body=[]);we!==Be;){var n=J();r.body.push(n),t&&j(n)&&F(!0),t=!1}return q(r,"Program")}function J(){(we===wr||we===Er&&"/="==Ce)&&g(!0);var e=we,r=V();switch(e){case Me:case Ne:U();var n=e===Me;D(yr)||B()?r.label=null:we!==De?X():(r.label=le(),M());for(var a=0;ar){var a=T(e);a.left=e,a.operator=Ce;var o=we;U(),a.right=ee(re(),n,t);var i=q(a,o===Ir||o===Lr?"LogicalExpression":"BinaryExpression");return ee(i,r,t)}return e}function re(){if(we.prefix){var e=V(),r=we.isUpdate;return e.operator=Ce,e.prefix=!0,Ee=!0,U(),e.argument=re(),r?N(e.argument):Oe&&"delete"===e.operator&&"Identifier"===e.argument.type&&t(e.start,"Deleting local variable in strict mode"),q(e,r?"UpdateExpression":"UnaryExpression")}for(var n=te();we.postfix&&!B();){var e=T(n);e.operator=Ce,e.prefix=!1,e.argument=n,N(n),U(),n=q(e,"UpdateExpression")}return n}function te(){return ne(ae())}function ne(e,r){if(D(xr)){var t=T(e);return t.object=e,t.property=le(!0),t.computed=!1,ne(q(t,"MemberExpression"),r)}if(D(fr)){var t=T(e);return t.object=e,t.property=K(),t.computed=!0,z(dr),ne(q(t,"MemberExpression"),r)}if(!r&&D(hr)){var t=T(e);return t.callee=e,t.arguments=ue(vr,!1),ne(q(t,"CallExpression"),r)}return e}function ae(){switch(we){case or:var e=V();return U(),q(e,"ThisExpression");case De:return le();case Te:case je:case qe:var e=V();return e.value=Ce,e.raw=de.slice(ye,ge),U(),q(e,"Literal");case ir:case sr:case cr:var e=V();return e.value=we.atomValue,e.raw=we.keyword,U(),q(e,"Literal");case hr:var r=xe,t=ye;U();var n=K();return n.start=t,n.end=ge,fe.locations&&(n.loc.start=r,n.loc.end=ke),fe.ranges&&(n.range=[t,ge]),z(vr),n;case fr:var e=V();return U(),e.elements=ue(dr,!0,!0),q(e,"ArrayExpression");case pr:return ie();case Ge:var e=V();return U(),ce(e,!1);case ar:return oe();default:X()}}function oe(){var e=V();return U(),e.callee=ne(ae(),!0),D(hr)?e.arguments=ue(vr,!1):e.arguments=Ve,q(e,"NewExpression")}function ie(){var e=V(),r=!0,n=!1;for(e.properties=[],U();!D(mr);){if(r)r=!1;else if(z(br),fe.allowTrailingCommas&&D(mr))break;var a,o={key:se()},i=!1;if(D(gr)?(o.value=K(!0),a=o.kind="init"):fe.ecmaVersion>=5&&"Identifier"===o.key.type&&("get"===o.key.name||"set"===o.key.name)?(i=n=!0,a=o.kind=o.key.name,o.key=se(),we!==hr&&X(),o.value=ce(V(),!1)):X(),"Identifier"===o.key.type&&(Oe||n))for(var s=0;s=0)for(var c=0;c=170&&$r.test(String.fromCharCode(e)))},Yr=e.isIdentifierChar=function(e){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||e>=170&&_r.test(String.fromCharCode(e))))},Zr={kind:"loop"},et={kind:"switch"}});
+ var global = this,
+ acorn = global.acorn;
+ if (!acorn && typeof require !== 'undefined') {
+ try { acorn = require('acorn'); } catch(e) {}
+ }
+ if (!acorn) {
+ var exports, module;
+ acorn = exports = module = {};
+
+(function(root, mod) {
+ if (typeof exports == "object" && typeof module == "object") return mod(exports);
+ if (typeof define == "function" && define.amd) return define(["exports"], mod);
+ mod(root.acorn || (root.acorn = {}));
+})(this, function(exports) {
+ "use strict";
+
+ exports.version = "0.5.0";
+
+ var options, input, inputLen, sourceFile;
+
+ exports.parse = function(inpt, opts) {
+ input = String(inpt); inputLen = input.length;
+ setOptions(opts);
+ initTokenState();
+ return parseTopLevel(options.program);
+ };
+
+ var defaultOptions = exports.defaultOptions = {
+ ecmaVersion: 5,
+ strictSemicolons: false,
+ allowTrailingCommas: true,
+ forbidReserved: false,
+ allowReturnOutsideFunction: false,
+ locations: false,
+ onComment: null,
+ ranges: false,
+ program: null,
+ sourceFile: null,
+ directSourceFile: null
+ };
+
+ function setOptions(opts) {
+ options = opts || {};
+ for (var opt in defaultOptions) if (!Object.prototype.hasOwnProperty.call(options, opt))
+ options[opt] = defaultOptions[opt];
+ sourceFile = options.sourceFile || null;
+ }
+
+ var getLineInfo = exports.getLineInfo = function(input, offset) {
+ for (var line = 1, cur = 0;;) {
+ lineBreak.lastIndex = cur;
+ var match = lineBreak.exec(input);
+ if (match && match.index < offset) {
+ ++line;
+ cur = match.index + match[0].length;
+ } else break;
+ }
+ return {line: line, column: offset - cur};
+ };
+
+ exports.tokenize = function(inpt, opts) {
+ input = String(inpt); inputLen = input.length;
+ setOptions(opts);
+ initTokenState();
+
+ var t = {};
+ function getToken(forceRegexp) {
+ lastEnd = tokEnd;
+ readToken(forceRegexp);
+ t.start = tokStart; t.end = tokEnd;
+ t.startLoc = tokStartLoc; t.endLoc = tokEndLoc;
+ t.type = tokType; t.value = tokVal;
+ return t;
+ }
+ getToken.jumpTo = function(pos, reAllowed) {
+ tokPos = pos;
+ if (options.locations) {
+ tokCurLine = 1;
+ tokLineStart = lineBreak.lastIndex = 0;
+ var match;
+ while ((match = lineBreak.exec(input)) && match.index < pos) {
+ ++tokCurLine;
+ tokLineStart = match.index + match[0].length;
+ }
+ }
+ tokRegexpAllowed = reAllowed;
+ skipSpace();
+ };
+ return getToken;
+ };
+
+ var tokPos;
+
+ var tokStart, tokEnd;
+
+ var tokStartLoc, tokEndLoc;
+
+ var tokType, tokVal;
+
+ var tokRegexpAllowed;
+
+ var tokCurLine, tokLineStart;
+
+ var lastStart, lastEnd, lastEndLoc;
+
+ var inFunction, labels, strict;
+
+ function raise(pos, message) {
+ var loc = getLineInfo(input, pos);
+ message += " (" + loc.line + ":" + loc.column + ")";
+ var err = new SyntaxError(message);
+ err.pos = pos; err.loc = loc; err.raisedAt = tokPos;
+ throw err;
+ }
+
+ var empty = [];
+
+ var _num = {type: "num"}, _regexp = {type: "regexp"}, _string = {type: "string"};
+ var _name = {type: "name"}, _eof = {type: "eof"};
+
+ var _break = {keyword: "break"}, _case = {keyword: "case", beforeExpr: true}, _catch = {keyword: "catch"};
+ var _continue = {keyword: "continue"}, _debugger = {keyword: "debugger"}, _default = {keyword: "default"};
+ var _do = {keyword: "do", isLoop: true}, _else = {keyword: "else", beforeExpr: true};
+ var _finally = {keyword: "finally"}, _for = {keyword: "for", isLoop: true}, _function = {keyword: "function"};
+ var _if = {keyword: "if"}, _return = {keyword: "return", beforeExpr: true}, _switch = {keyword: "switch"};
+ var _throw = {keyword: "throw", beforeExpr: true}, _try = {keyword: "try"}, _var = {keyword: "var"};
+ var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true};
+ var _this = {keyword: "this"};
+
+ var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true};
+ var _false = {keyword: "false", atomValue: false};
+
+ var _in = {keyword: "in", binop: 7, beforeExpr: true};
+
+ var keywordTypes = {"break": _break, "case": _case, "catch": _catch,
+ "continue": _continue, "debugger": _debugger, "default": _default,
+ "do": _do, "else": _else, "finally": _finally, "for": _for,
+ "function": _function, "if": _if, "return": _return, "switch": _switch,
+ "throw": _throw, "try": _try, "var": _var, "while": _while, "with": _with,
+ "null": _null, "true": _true, "false": _false, "new": _new, "in": _in,
+ "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this,
+ "typeof": {keyword: "typeof", prefix: true, beforeExpr: true},
+ "void": {keyword: "void", prefix: true, beforeExpr: true},
+ "delete": {keyword: "delete", prefix: true, beforeExpr: true}};
+
+ var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
+ var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
+ var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
+ var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};
+
+ var _slash = {binop: 10, beforeExpr: true}, _eq = {isAssign: true, beforeExpr: true};
+ var _assign = {isAssign: true, beforeExpr: true};
+ var _incDec = {postfix: true, prefix: true, isUpdate: true}, _prefix = {prefix: true, beforeExpr: true};
+ var _logicalOR = {binop: 1, beforeExpr: true};
+ var _logicalAND = {binop: 2, beforeExpr: true};
+ var _bitwiseOR = {binop: 3, beforeExpr: true};
+ var _bitwiseXOR = {binop: 4, beforeExpr: true};
+ var _bitwiseAND = {binop: 5, beforeExpr: true};
+ var _equality = {binop: 6, beforeExpr: true};
+ var _relational = {binop: 7, beforeExpr: true};
+ var _bitShift = {binop: 8, beforeExpr: true};
+ var _plusMin = {binop: 9, prefix: true, beforeExpr: true};
+ var _multiplyModulo = {binop: 10, beforeExpr: true};
+
+ exports.tokTypes = {bracketL: _bracketL, bracketR: _bracketR, braceL: _braceL, braceR: _braceR,
+ parenL: _parenL, parenR: _parenR, comma: _comma, semi: _semi, colon: _colon,
+ dot: _dot, question: _question, slash: _slash, eq: _eq, name: _name, eof: _eof,
+ num: _num, regexp: _regexp, string: _string};
+ for (var kw in keywordTypes) exports.tokTypes["_" + kw] = keywordTypes[kw];
+
+ function makePredicate(words) {
+ words = words.split(" ");
+ var f = "", cats = [];
+ out: for (var i = 0; i < words.length; ++i) {
+ for (var j = 0; j < cats.length; ++j)
+ if (cats[j][0].length == words[i].length) {
+ cats[j].push(words[i]);
+ continue out;
+ }
+ cats.push([words[i]]);
+ }
+ function compareTo(arr) {
+ if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";";
+ f += "switch(str){";
+ for (var i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":";
+ f += "return true}return false;";
+ }
+
+ if (cats.length > 3) {
+ cats.sort(function(a, b) {return b.length - a.length;});
+ f += "switch(str.length){";
+ for (var i = 0; i < cats.length; ++i) {
+ var cat = cats[i];
+ f += "case " + cat[0].length + ":";
+ compareTo(cat);
+ }
+ f += "}";
+
+ } else {
+ compareTo(words);
+ }
+ return new Function("str", f);
+ }
+
+ var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");
+
+ var isReservedWord5 = makePredicate("class enum extends super const export import");
+
+ var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");
+
+ var isStrictBadIdWord = makePredicate("eval arguments");
+
+ var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this");
+
+ var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
+ var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
+ var nonASCIIidentifierChars = "\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
+ var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
+ var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
+
+ var newline = /[\n\r\u2028\u2029]/;
+
+ var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;
+
+ var isIdentifierStart = exports.isIdentifierStart = function(code) {
+ if (code < 65) return code === 36;
+ if (code < 91) return true;
+ if (code < 97) return code === 95;
+ if (code < 123)return true;
+ return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
+ };
+
+ var isIdentifierChar = exports.isIdentifierChar = function(code) {
+ if (code < 48) return code === 36;
+ if (code < 58) return true;
+ if (code < 65) return false;
+ if (code < 91) return true;
+ if (code < 97) return code === 95;
+ if (code < 123)return true;
+ return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
+ };
+
+ function line_loc_t() {
+ this.line = tokCurLine;
+ this.column = tokPos - tokLineStart;
+ }
+
+ function initTokenState() {
+ tokCurLine = 1;
+ tokPos = tokLineStart = 0;
+ tokRegexpAllowed = true;
+ skipSpace();
+ }
+
+ function finishToken(type, val) {
+ tokEnd = tokPos;
+ if (options.locations) tokEndLoc = new line_loc_t;
+ tokType = type;
+ skipSpace();
+ tokVal = val;
+ tokRegexpAllowed = type.beforeExpr;
+ }
+
+ function skipBlockComment() {
+ var startLoc = options.onComment && options.locations && new line_loc_t;
+ var start = tokPos, end = input.indexOf("*/", tokPos += 2);
+ if (end === -1) raise(tokPos - 2, "Unterminated comment");
+ tokPos = end + 2;
+ if (options.locations) {
+ lineBreak.lastIndex = start;
+ var match;
+ while ((match = lineBreak.exec(input)) && match.index < tokPos) {
+ ++tokCurLine;
+ tokLineStart = match.index + match[0].length;
+ }
+ }
+ if (options.onComment)
+ options.onComment(true, input.slice(start + 2, end), start, tokPos,
+ startLoc, options.locations && new line_loc_t);
+ }
+
+ function skipLineComment() {
+ var start = tokPos;
+ var startLoc = options.onComment && options.locations && new line_loc_t;
+ var ch = input.charCodeAt(tokPos+=2);
+ while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
+ ++tokPos;
+ ch = input.charCodeAt(tokPos);
+ }
+ if (options.onComment)
+ options.onComment(false, input.slice(start + 2, tokPos), start, tokPos,
+ startLoc, options.locations && new line_loc_t);
+ }
+
+ function skipSpace() {
+ while (tokPos < inputLen) {
+ var ch = input.charCodeAt(tokPos);
+ if (ch === 32) {
+ ++tokPos;
+ } else if (ch === 13) {
+ ++tokPos;
+ var next = input.charCodeAt(tokPos);
+ if (next === 10) {
+ ++tokPos;
+ }
+ if (options.locations) {
+ ++tokCurLine;
+ tokLineStart = tokPos;
+ }
+ } else if (ch === 10 || ch === 8232 || ch === 8233) {
+ ++tokPos;
+ if (options.locations) {
+ ++tokCurLine;
+ tokLineStart = tokPos;
+ }
+ } else if (ch > 8 && ch < 14) {
+ ++tokPos;
+ } else if (ch === 47) {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === 42) {
+ skipBlockComment();
+ } else if (next === 47) {
+ skipLineComment();
+ } else break;
+ } else if (ch === 160) {
+ ++tokPos;
+ } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
+ ++tokPos;
+ } else {
+ break;
+ }
+ }
+ }
+
+ function readToken_dot() {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next >= 48 && next <= 57) return readNumber(true);
+ ++tokPos;
+ return finishToken(_dot);
+ }
+
+ function readToken_slash() {
+ var next = input.charCodeAt(tokPos + 1);
+ if (tokRegexpAllowed) {++tokPos; return readRegexp();}
+ if (next === 61) return finishOp(_assign, 2);
+ return finishOp(_slash, 1);
+ }
+
+ function readToken_mult_modulo() {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === 61) return finishOp(_assign, 2);
+ return finishOp(_multiplyModulo, 1);
+ }
+
+ function readToken_pipe_amp(code) {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === code) return finishOp(code === 124 ? _logicalOR : _logicalAND, 2);
+ if (next === 61) return finishOp(_assign, 2);
+ return finishOp(code === 124 ? _bitwiseOR : _bitwiseAND, 1);
+ }
+
+ function readToken_caret() {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === 61) return finishOp(_assign, 2);
+ return finishOp(_bitwiseXOR, 1);
+ }
+
+ function readToken_plus_min(code) {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === code) {
+ if (next == 45 && input.charCodeAt(tokPos + 2) == 62 &&
+ newline.test(input.slice(lastEnd, tokPos))) {
+ tokPos += 3;
+ skipLineComment();
+ skipSpace();
+ return readToken();
+ }
+ return finishOp(_incDec, 2);
+ }
+ if (next === 61) return finishOp(_assign, 2);
+ return finishOp(_plusMin, 1);
+ }
+
+ function readToken_lt_gt(code) {
+ var next = input.charCodeAt(tokPos + 1);
+ var size = 1;
+ if (next === code) {
+ size = code === 62 && input.charCodeAt(tokPos + 2) === 62 ? 3 : 2;
+ if (input.charCodeAt(tokPos + size) === 61) return finishOp(_assign, size + 1);
+ return finishOp(_bitShift, size);
+ }
+ if (next == 33 && code == 60 && input.charCodeAt(tokPos + 2) == 45 &&
+ input.charCodeAt(tokPos + 3) == 45) {
+ tokPos += 4;
+ skipLineComment();
+ skipSpace();
+ return readToken();
+ }
+ if (next === 61)
+ size = input.charCodeAt(tokPos + 2) === 61 ? 3 : 2;
+ return finishOp(_relational, size);
+ }
+
+ function readToken_eq_excl(code) {
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === 61) return finishOp(_equality, input.charCodeAt(tokPos + 2) === 61 ? 3 : 2);
+ return finishOp(code === 61 ? _eq : _prefix, 1);
+ }
+
+ function getTokenFromCode(code) {
+ switch(code) {
+ case 46:
+ return readToken_dot();
+
+ case 40: ++tokPos; return finishToken(_parenL);
+ case 41: ++tokPos; return finishToken(_parenR);
+ case 59: ++tokPos; return finishToken(_semi);
+ case 44: ++tokPos; return finishToken(_comma);
+ case 91: ++tokPos; return finishToken(_bracketL);
+ case 93: ++tokPos; return finishToken(_bracketR);
+ case 123: ++tokPos; return finishToken(_braceL);
+ case 125: ++tokPos; return finishToken(_braceR);
+ case 58: ++tokPos; return finishToken(_colon);
+ case 63: ++tokPos; return finishToken(_question);
+
+ case 48:
+ var next = input.charCodeAt(tokPos + 1);
+ if (next === 120 || next === 88) return readHexNumber();
+ case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57:
+ return readNumber(false);
+
+ case 34: case 39:
+ return readString(code);
+
+ case 47:
+ return readToken_slash(code);
+
+ case 37: case 42:
+ return readToken_mult_modulo();
+
+ case 124: case 38:
+ return readToken_pipe_amp(code);
+
+ case 94:
+ return readToken_caret();
+
+ case 43: case 45:
+ return readToken_plus_min(code);
+
+ case 60: case 62:
+ return readToken_lt_gt(code);
+
+ case 61: case 33:
+ return readToken_eq_excl(code);
+
+ case 126:
+ return finishOp(_prefix, 1);
+ }
+
+ return false;
+ }
+
+ function readToken(forceRegexp) {
+ if (!forceRegexp) tokStart = tokPos;
+ else tokPos = tokStart + 1;
+ if (options.locations) tokStartLoc = new line_loc_t;
+ if (forceRegexp) return readRegexp();
+ if (tokPos >= inputLen) return finishToken(_eof);
+
+ var code = input.charCodeAt(tokPos);
+ if (isIdentifierStart(code) || code === 92 ) return readWord();
+
+ var tok = getTokenFromCode(code);
+
+ if (tok === false) {
+ var ch = String.fromCharCode(code);
+ if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord();
+ raise(tokPos, "Unexpected character '" + ch + "'");
+ }
+ return tok;
+ }
+
+ function finishOp(type, size) {
+ var str = input.slice(tokPos, tokPos + size);
+ tokPos += size;
+ finishToken(type, str);
+ }
+
+ function readRegexp() {
+ var content = "", escaped, inClass, start = tokPos;
+ for (;;) {
+ if (tokPos >= inputLen) raise(start, "Unterminated regular expression");
+ var ch = input.charAt(tokPos);
+ if (newline.test(ch)) raise(start, "Unterminated regular expression");
+ if (!escaped) {
+ if (ch === "[") inClass = true;
+ else if (ch === "]" && inClass) inClass = false;
+ else if (ch === "/" && !inClass) break;
+ escaped = ch === "\\";
+ } else escaped = false;
+ ++tokPos;
+ }
+ var content = input.slice(start, tokPos);
+ ++tokPos;
+ var mods = readWord1();
+ if (mods && !/^[gmsiy]*$/.test(mods)) raise(start, "Invalid regexp flag");
+ try {
+ var value = new RegExp(content, mods);
+ } catch (e) {
+ if (e instanceof SyntaxError) raise(start, e.message);
+ raise(e);
+ }
+ return finishToken(_regexp, value);
+ }
+
+ function readInt(radix, len) {
+ var start = tokPos, total = 0;
+ for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
+ var code = input.charCodeAt(tokPos), val;
+ if (code >= 97) val = code - 97 + 10;
+ else if (code >= 65) val = code - 65 + 10;
+ else if (code >= 48 && code <= 57) val = code - 48;
+ else val = Infinity;
+ if (val >= radix) break;
+ ++tokPos;
+ total = total * radix + val;
+ }
+ if (tokPos === start || len != null && tokPos - start !== len) return null;
+
+ return total;
+ }
+
+ function readHexNumber() {
+ tokPos += 2;
+ var val = readInt(16);
+ if (val == null) raise(tokStart + 2, "Expected hexadecimal number");
+ if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
+ return finishToken(_num, val);
+ }
+
+ function readNumber(startsWithDot) {
+ var start = tokPos, isFloat = false, octal = input.charCodeAt(tokPos) === 48;
+ if (!startsWithDot && readInt(10) === null) raise(start, "Invalid number");
+ if (input.charCodeAt(tokPos) === 46) {
+ ++tokPos;
+ readInt(10);
+ isFloat = true;
+ }
+ var next = input.charCodeAt(tokPos);
+ if (next === 69 || next === 101) {
+ next = input.charCodeAt(++tokPos);
+ if (next === 43 || next === 45) ++tokPos;
+ if (readInt(10) === null) raise(start, "Invalid number");
+ isFloat = true;
+ }
+ if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
+
+ var str = input.slice(start, tokPos), val;
+ if (isFloat) val = parseFloat(str);
+ else if (!octal || str.length === 1) val = parseInt(str, 10);
+ else if (/[89]/.test(str) || strict) raise(start, "Invalid number");
+ else val = parseInt(str, 8);
+ return finishToken(_num, val);
+ }
+
+ function readString(quote) {
+ tokPos++;
+ var out = "";
+ for (;;) {
+ if (tokPos >= inputLen) raise(tokStart, "Unterminated string constant");
+ var ch = input.charCodeAt(tokPos);
+ if (ch === quote) {
+ ++tokPos;
+ return finishToken(_string, out);
+ }
+ if (ch === 92) {
+ ch = input.charCodeAt(++tokPos);
+ var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3));
+ if (octal) octal = octal[0];
+ while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, -1);
+ if (octal === "0") octal = null;
+ ++tokPos;
+ if (octal) {
+ if (strict) raise(tokPos - 2, "Octal literal in strict mode");
+ out += String.fromCharCode(parseInt(octal, 8));
+ tokPos += octal.length - 1;
+ } else {
+ switch (ch) {
+ case 110: out += "\n"; break;
+ case 114: out += "\r"; break;
+ case 120: out += String.fromCharCode(readHexChar(2)); break;
+ case 117: out += String.fromCharCode(readHexChar(4)); break;
+ case 85: out += String.fromCharCode(readHexChar(8)); break;
+ case 116: out += "\t"; break;
+ case 98: out += "\b"; break;
+ case 118: out += "\u000b"; break;
+ case 102: out += "\f"; break;
+ case 48: out += "\0"; break;
+ case 13: if (input.charCodeAt(tokPos) === 10) ++tokPos;
+ case 10:
+ if (options.locations) { tokLineStart = tokPos; ++tokCurLine; }
+ break;
+ default: out += String.fromCharCode(ch); break;
+ }
+ }
+ } else {
+ if (ch === 13 || ch === 10 || ch === 8232 || ch === 8233) raise(tokStart, "Unterminated string constant");
+ out += String.fromCharCode(ch);
+ ++tokPos;
+ }
+ }
+ }
+
+ function readHexChar(len) {
+ var n = readInt(16, len);
+ if (n === null) raise(tokStart, "Bad character escape sequence");
+ return n;
+ }
+
+ var containsEsc;
+
+ function readWord1() {
+ containsEsc = false;
+ var word, first = true, start = tokPos;
+ for (;;) {
+ var ch = input.charCodeAt(tokPos);
+ if (isIdentifierChar(ch)) {
+ if (containsEsc) word += input.charAt(tokPos);
+ ++tokPos;
+ } else if (ch === 92) {
+ if (!containsEsc) word = input.slice(start, tokPos);
+ containsEsc = true;
+ if (input.charCodeAt(++tokPos) != 117)
+ raise(tokPos, "Expecting Unicode escape sequence \\uXXXX");
+ ++tokPos;
+ var esc = readHexChar(4);
+ var escStr = String.fromCharCode(esc);
+ if (!escStr) raise(tokPos - 1, "Invalid Unicode escape");
+ if (!(first ? isIdentifierStart(esc) : isIdentifierChar(esc)))
+ raise(tokPos - 4, "Invalid Unicode escape");
+ word += escStr;
+ } else {
+ break;
+ }
+ first = false;
+ }
+ return containsEsc ? word : input.slice(start, tokPos);
+ }
+
+ function readWord() {
+ var word = readWord1();
+ var type = _name;
+ if (!containsEsc && isKeyword(word))
+ type = keywordTypes[word];
+ return finishToken(type, word);
+ }
+
+ function next() {
+ lastStart = tokStart;
+ lastEnd = tokEnd;
+ lastEndLoc = tokEndLoc;
+ readToken();
+ }
+
+ function setStrict(strct) {
+ strict = strct;
+ tokPos = tokStart;
+ if (options.locations) {
+ while (tokPos < tokLineStart) {
+ tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
+ --tokCurLine;
+ }
+ }
+ skipSpace();
+ readToken();
+ }
+
+ function node_t() {
+ this.type = null;
+ this.start = tokStart;
+ this.end = null;
+ }
+
+ function node_loc_t() {
+ this.start = tokStartLoc;
+ this.end = null;
+ if (sourceFile !== null) this.source = sourceFile;
+ }
+
+ function startNode() {
+ var node = new node_t();
+ if (options.locations)
+ node.loc = new node_loc_t();
+ if (options.directSourceFile)
+ node.sourceFile = options.directSourceFile;
+ if (options.ranges)
+ node.range = [tokStart, 0];
+ return node;
+ }
+
+ function startNodeFrom(other) {
+ var node = new node_t();
+ node.start = other.start;
+ if (options.locations) {
+ node.loc = new node_loc_t();
+ node.loc.start = other.loc.start;
+ }
+ if (options.ranges)
+ node.range = [other.range[0], 0];
+
+ return node;
+ }
+
+ function finishNode(node, type) {
+ node.type = type;
+ node.end = lastEnd;
+ if (options.locations)
+ node.loc.end = lastEndLoc;
+ if (options.ranges)
+ node.range[1] = lastEnd;
+ return node;
+ }
+
+ function isUseStrict(stmt) {
+ return options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" &&
+ stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
+ }
+
+ function eat(type) {
+ if (tokType === type) {
+ next();
+ return true;
+ }
+ }
+
+ function canInsertSemicolon() {
+ return !options.strictSemicolons &&
+ (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
+ }
+
+ function semicolon() {
+ if (!eat(_semi) && !canInsertSemicolon()) unexpected();
+ }
+
+ function expect(type) {
+ if (tokType === type) next();
+ else unexpected();
+ }
+
+ function unexpected() {
+ raise(tokStart, "Unexpected token");
+ }
+
+ function checkLVal(expr) {
+ if (expr.type !== "Identifier" && expr.type !== "MemberExpression")
+ raise(expr.start, "Assigning to rvalue");
+ if (strict && expr.type === "Identifier" && isStrictBadIdWord(expr.name))
+ raise(expr.start, "Assigning to " + expr.name + " in strict mode");
+ }
+
+ function parseTopLevel(program) {
+ lastStart = lastEnd = tokPos;
+ if (options.locations) lastEndLoc = new line_loc_t;
+ inFunction = strict = null;
+ labels = [];
+ readToken();
+
+ var node = program || startNode(), first = true;
+ if (!program) node.body = [];
+ while (tokType !== _eof) {
+ var stmt = parseStatement();
+ node.body.push(stmt);
+ if (first && isUseStrict(stmt)) setStrict(true);
+ first = false;
+ }
+ return finishNode(node, "Program");
+ }
+
+ var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
+
+ function parseStatement() {
+ if (tokType === _slash || tokType === _assign && tokVal == "/=")
+ readToken(true);
+
+ var starttype = tokType, node = startNode();
+
+ switch (starttype) {
+ case _break: case _continue:
+ next();
+ var isBreak = starttype === _break;
+ if (eat(_semi) || canInsertSemicolon()) node.label = null;
+ else if (tokType !== _name) unexpected();
+ else {
+ node.label = parseIdent();
+ semicolon();
+ }
+
+ for (var i = 0; i < labels.length; ++i) {
+ var lab = labels[i];
+ if (node.label == null || lab.name === node.label.name) {
+ if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
+ if (node.label && isBreak) break;
+ }
+ }
+ if (i === labels.length) raise(node.start, "Unsyntactic " + starttype.keyword);
+ return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
+
+ case _debugger:
+ next();
+ semicolon();
+ return finishNode(node, "DebuggerStatement");
+
+ case _do:
+ next();
+ labels.push(loopLabel);
+ node.body = parseStatement();
+ labels.pop();
+ expect(_while);
+ node.test = parseParenExpression();
+ semicolon();
+ return finishNode(node, "DoWhileStatement");
+
+ case _for:
+ next();
+ labels.push(loopLabel);
+ expect(_parenL);
+ if (tokType === _semi) return parseFor(node, null);
+ if (tokType === _var) {
+ var init = startNode();
+ next();
+ parseVar(init, true);
+ finishNode(init, "VariableDeclaration");
+ if (init.declarations.length === 1 && eat(_in))
+ return parseForIn(node, init);
+ return parseFor(node, init);
+ }
+ var init = parseExpression(false, true);
+ if (eat(_in)) {checkLVal(init); return parseForIn(node, init);}
+ return parseFor(node, init);
+
+ case _function:
+ next();
+ return parseFunction(node, true);
+
+ case _if:
+ next();
+ node.test = parseParenExpression();
+ node.consequent = parseStatement();
+ node.alternate = eat(_else) ? parseStatement() : null;
+ return finishNode(node, "IfStatement");
+
+ case _return:
+ if (!inFunction && !options.allowReturnOutsideFunction)
+ raise(tokStart, "'return' outside of function");
+ next();
+
+ if (eat(_semi) || canInsertSemicolon()) node.argument = null;
+ else { node.argument = parseExpression(); semicolon(); }
+ return finishNode(node, "ReturnStatement");
+
+ case _switch:
+ next();
+ node.discriminant = parseParenExpression();
+ node.cases = [];
+ expect(_braceL);
+ labels.push(switchLabel);
+
+ for (var cur, sawDefault; tokType != _braceR;) {
+ if (tokType === _case || tokType === _default) {
+ var isCase = tokType === _case;
+ if (cur) finishNode(cur, "SwitchCase");
+ node.cases.push(cur = startNode());
+ cur.consequent = [];
+ next();
+ if (isCase) cur.test = parseExpression();
+ else {
+ if (sawDefault) raise(lastStart, "Multiple default clauses"); sawDefault = true;
+ cur.test = null;
+ }
+ expect(_colon);
+ } else {
+ if (!cur) unexpected();
+ cur.consequent.push(parseStatement());
+ }
+ }
+ if (cur) finishNode(cur, "SwitchCase");
+ next();
+ labels.pop();
+ return finishNode(node, "SwitchStatement");
+
+ case _throw:
+ next();
+ if (newline.test(input.slice(lastEnd, tokStart)))
+ raise(lastEnd, "Illegal newline after throw");
+ node.argument = parseExpression();
+ semicolon();
+ return finishNode(node, "ThrowStatement");
+
+ case _try:
+ next();
+ node.block = parseBlock();
+ node.handler = null;
+ if (tokType === _catch) {
+ var clause = startNode();
+ next();
+ expect(_parenL);
+ clause.param = parseIdent();
+ if (strict && isStrictBadIdWord(clause.param.name))
+ raise(clause.param.start, "Binding " + clause.param.name + " in strict mode");
+ expect(_parenR);
+ clause.guard = null;
+ clause.body = parseBlock();
+ node.handler = finishNode(clause, "CatchClause");
+ }
+ node.guardedHandlers = empty;
+ node.finalizer = eat(_finally) ? parseBlock() : null;
+ if (!node.handler && !node.finalizer)
+ raise(node.start, "Missing catch or finally clause");
+ return finishNode(node, "TryStatement");
+
+ case _var:
+ next();
+ parseVar(node);
+ semicolon();
+ return finishNode(node, "VariableDeclaration");
+
+ case _while:
+ next();
+ node.test = parseParenExpression();
+ labels.push(loopLabel);
+ node.body = parseStatement();
+ labels.pop();
+ return finishNode(node, "WhileStatement");
+
+ case _with:
+ if (strict) raise(tokStart, "'with' in strict mode");
+ next();
+ node.object = parseParenExpression();
+ node.body = parseStatement();
+ return finishNode(node, "WithStatement");
+
+ case _braceL:
+ return parseBlock();
+
+ case _semi:
+ next();
+ return finishNode(node, "EmptyStatement");
+
+ default:
+ var maybeName = tokVal, expr = parseExpression();
+ if (starttype === _name && expr.type === "Identifier" && eat(_colon)) {
+ for (var i = 0; i < labels.length; ++i)
+ if (labels[i].name === maybeName) raise(expr.start, "Label '" + maybeName + "' is already declared");
+ var kind = tokType.isLoop ? "loop" : tokType === _switch ? "switch" : null;
+ labels.push({name: maybeName, kind: kind});
+ node.body = parseStatement();
+ labels.pop();
+ node.label = expr;
+ return finishNode(node, "LabeledStatement");
+ } else {
+ node.expression = expr;
+ semicolon();
+ return finishNode(node, "ExpressionStatement");
+ }
+ }
+ }
+
+ function parseParenExpression() {
+ expect(_parenL);
+ var val = parseExpression();
+ expect(_parenR);
+ return val;
+ }
+
+ function parseBlock(allowStrict) {
+ var node = startNode(), first = true, strict = false, oldStrict;
+ node.body = [];
+ expect(_braceL);
+ while (!eat(_braceR)) {
+ var stmt = parseStatement();
+ node.body.push(stmt);
+ if (first && allowStrict && isUseStrict(stmt)) {
+ oldStrict = strict;
+ setStrict(strict = true);
+ }
+ first = false;
+ }
+ if (strict && !oldStrict) setStrict(false);
+ return finishNode(node, "BlockStatement");
+ }
+
+ function parseFor(node, init) {
+ node.init = init;
+ expect(_semi);
+ node.test = tokType === _semi ? null : parseExpression();
+ expect(_semi);
+ node.update = tokType === _parenR ? null : parseExpression();
+ expect(_parenR);
+ node.body = parseStatement();
+ labels.pop();
+ return finishNode(node, "ForStatement");
+ }
+
+ function parseForIn(node, init) {
+ node.left = init;
+ node.right = parseExpression();
+ expect(_parenR);
+ node.body = parseStatement();
+ labels.pop();
+ return finishNode(node, "ForInStatement");
+ }
+
+ function parseVar(node, noIn) {
+ node.declarations = [];
+ node.kind = "var";
+ for (;;) {
+ var decl = startNode();
+ decl.id = parseIdent();
+ if (strict && isStrictBadIdWord(decl.id.name))
+ raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
+ decl.init = eat(_eq) ? parseExpression(true, noIn) : null;
+ node.declarations.push(finishNode(decl, "VariableDeclarator"));
+ if (!eat(_comma)) break;
+ }
+ return node;
+ }
+
+ function parseExpression(noComma, noIn) {
+ var expr = parseMaybeAssign(noIn);
+ if (!noComma && tokType === _comma) {
+ var node = startNodeFrom(expr);
+ node.expressions = [expr];
+ while (eat(_comma)) node.expressions.push(parseMaybeAssign(noIn));
+ return finishNode(node, "SequenceExpression");
+ }
+ return expr;
+ }
+
+ function parseMaybeAssign(noIn) {
+ var left = parseMaybeConditional(noIn);
+ if (tokType.isAssign) {
+ var node = startNodeFrom(left);
+ node.operator = tokVal;
+ node.left = left;
+ next();
+ node.right = parseMaybeAssign(noIn);
+ checkLVal(left);
+ return finishNode(node, "AssignmentExpression");
+ }
+ return left;
+ }
+
+ function parseMaybeConditional(noIn) {
+ var expr = parseExprOps(noIn);
+ if (eat(_question)) {
+ var node = startNodeFrom(expr);
+ node.test = expr;
+ node.consequent = parseExpression(true);
+ expect(_colon);
+ node.alternate = parseExpression(true, noIn);
+ return finishNode(node, "ConditionalExpression");
+ }
+ return expr;
+ }
+
+ function parseExprOps(noIn) {
+ return parseExprOp(parseMaybeUnary(), -1, noIn);
+ }
+
+ function parseExprOp(left, minPrec, noIn) {
+ var prec = tokType.binop;
+ if (prec != null && (!noIn || tokType !== _in)) {
+ if (prec > minPrec) {
+ var node = startNodeFrom(left);
+ node.left = left;
+ node.operator = tokVal;
+ var op = tokType;
+ next();
+ node.right = parseExprOp(parseMaybeUnary(), prec, noIn);
+ var exprNode = finishNode(node, (op === _logicalOR || op === _logicalAND) ? "LogicalExpression" : "BinaryExpression");
+ return parseExprOp(exprNode, minPrec, noIn);
+ }
+ }
+ return left;
+ }
+
+ function parseMaybeUnary() {
+ if (tokType.prefix) {
+ var node = startNode(), update = tokType.isUpdate;
+ node.operator = tokVal;
+ node.prefix = true;
+ tokRegexpAllowed = true;
+ next();
+ node.argument = parseMaybeUnary();
+ if (update) checkLVal(node.argument);
+ else if (strict && node.operator === "delete" &&
+ node.argument.type === "Identifier")
+ raise(node.start, "Deleting local variable in strict mode");
+ return finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
+ }
+ var expr = parseExprSubscripts();
+ while (tokType.postfix && !canInsertSemicolon()) {
+ var node = startNodeFrom(expr);
+ node.operator = tokVal;
+ node.prefix = false;
+ node.argument = expr;
+ checkLVal(expr);
+ next();
+ expr = finishNode(node, "UpdateExpression");
+ }
+ return expr;
+ }
+
+ function parseExprSubscripts() {
+ return parseSubscripts(parseExprAtom());
+ }
+
+ function parseSubscripts(base, noCalls) {
+ if (eat(_dot)) {
+ var node = startNodeFrom(base);
+ node.object = base;
+ node.property = parseIdent(true);
+ node.computed = false;
+ return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
+ } else if (eat(_bracketL)) {
+ var node = startNodeFrom(base);
+ node.object = base;
+ node.property = parseExpression();
+ node.computed = true;
+ expect(_bracketR);
+ return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
+ } else if (!noCalls && eat(_parenL)) {
+ var node = startNodeFrom(base);
+ node.callee = base;
+ node.arguments = parseExprList(_parenR, false);
+ return parseSubscripts(finishNode(node, "CallExpression"), noCalls);
+ } else return base;
+ }
+
+ function parseExprAtom() {
+ switch (tokType) {
+ case _this:
+ var node = startNode();
+ next();
+ return finishNode(node, "ThisExpression");
+ case _name:
+ return parseIdent();
+ case _num: case _string: case _regexp:
+ var node = startNode();
+ node.value = tokVal;
+ node.raw = input.slice(tokStart, tokEnd);
+ next();
+ return finishNode(node, "Literal");
+
+ case _null: case _true: case _false:
+ var node = startNode();
+ node.value = tokType.atomValue;
+ node.raw = tokType.keyword;
+ next();
+ return finishNode(node, "Literal");
+
+ case _parenL:
+ var tokStartLoc1 = tokStartLoc, tokStart1 = tokStart;
+ next();
+ var val = parseExpression();
+ val.start = tokStart1;
+ val.end = tokEnd;
+ if (options.locations) {
+ val.loc.start = tokStartLoc1;
+ val.loc.end = tokEndLoc;
+ }
+ if (options.ranges)
+ val.range = [tokStart1, tokEnd];
+ expect(_parenR);
+ return val;
+
+ case _bracketL:
+ var node = startNode();
+ next();
+ node.elements = parseExprList(_bracketR, true, true);
+ return finishNode(node, "ArrayExpression");
+
+ case _braceL:
+ return parseObj();
+
+ case _function:
+ var node = startNode();
+ next();
+ return parseFunction(node, false);
+
+ case _new:
+ return parseNew();
+
+ default:
+ unexpected();
+ }
+ }
+
+ function parseNew() {
+ var node = startNode();
+ next();
+ node.callee = parseSubscripts(parseExprAtom(), true);
+ if (eat(_parenL)) node.arguments = parseExprList(_parenR, false);
+ else node.arguments = empty;
+ return finishNode(node, "NewExpression");
+ }
+
+ function parseObj() {
+ var node = startNode(), first = true, sawGetSet = false;
+ node.properties = [];
+ next();
+ while (!eat(_braceR)) {
+ if (!first) {
+ expect(_comma);
+ if (options.allowTrailingCommas && eat(_braceR)) break;
+ } else first = false;
+
+ var prop = {key: parsePropertyName()}, isGetSet = false, kind;
+ if (eat(_colon)) {
+ prop.value = parseExpression(true);
+ kind = prop.kind = "init";
+ } else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
+ (prop.key.name === "get" || prop.key.name === "set")) {
+ isGetSet = sawGetSet = true;
+ kind = prop.kind = prop.key.name;
+ prop.key = parsePropertyName();
+ if (tokType !== _parenL) unexpected();
+ prop.value = parseFunction(startNode(), false);
+ } else unexpected();
+
+ if (prop.key.type === "Identifier" && (strict || sawGetSet)) {
+ for (var i = 0; i < node.properties.length; ++i) {
+ var other = node.properties[i];
+ if (other.key.name === prop.key.name) {
+ var conflict = kind == other.kind || isGetSet && other.kind === "init" ||
+ kind === "init" && (other.kind === "get" || other.kind === "set");
+ if (conflict && !strict && kind === "init" && other.kind === "init") conflict = false;
+ if (conflict) raise(prop.key.start, "Redefinition of property");
+ }
+ }
+ }
+ node.properties.push(prop);
+ }
+ return finishNode(node, "ObjectExpression");
+ }
+
+ function parsePropertyName() {
+ if (tokType === _num || tokType === _string) return parseExprAtom();
+ return parseIdent(true);
+ }
+
+ function parseFunction(node, isStatement) {
+ if (tokType === _name) node.id = parseIdent();
+ else if (isStatement) unexpected();
+ else node.id = null;
+ node.params = [];
+ var first = true;
+ expect(_parenL);
+ while (!eat(_parenR)) {
+ if (!first) expect(_comma); else first = false;
+ node.params.push(parseIdent());
+ }
+
+ var oldInFunc = inFunction, oldLabels = labels;
+ inFunction = true; labels = [];
+ node.body = parseBlock(true);
+ inFunction = oldInFunc; labels = oldLabels;
+
+ if (strict || node.body.body.length && isUseStrict(node.body.body[0])) {
+ for (var i = node.id ? -1 : 0; i < node.params.length; ++i) {
+ var id = i < 0 ? node.id : node.params[i];
+ if (isStrictReservedWord(id.name) || isStrictBadIdWord(id.name))
+ raise(id.start, "Defining '" + id.name + "' in strict mode");
+ if (i >= 0) for (var j = 0; j < i; ++j) if (id.name === node.params[j].name)
+ raise(id.start, "Argument name clash in strict mode");
+ }
+ }
+
+ return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
+ }
+
+ function parseExprList(close, allowTrailingComma, allowEmpty) {
+ var elts = [], first = true;
+ while (!eat(close)) {
+ if (!first) {
+ expect(_comma);
+ if (allowTrailingComma && options.allowTrailingCommas && eat(close)) break;
+ } else first = false;
+
+ if (allowEmpty && tokType === _comma) elts.push(null);
+ else elts.push(parseExpression(true));
+ }
+ return elts;
+ }
+
+ function parseIdent(liberal) {
+ var node = startNode();
+ if (liberal && options.forbidReserved == "everywhere") liberal = false;
+ if (tokType === _name) {
+ if (!liberal &&
+ (options.forbidReserved &&
+ (options.ecmaVersion === 3 ? isReservedWord3 : isReservedWord5)(tokVal) ||
+ strict && isStrictReservedWord(tokVal)) &&
+ input.slice(tokStart, tokEnd).indexOf("\\") == -1)
+ raise(tokStart, "The keyword '" + tokVal + "' is reserved");
+ node.name = tokVal;
+ } else if (liberal && tokType.keyword) {
+ node.name = tokType.keyword;
+ } else {
+ unexpected();
+ }
+ tokRegexpAllowed = false;
+ next();
+ return finishNode(node, "Identifier");
+ }
+
+});
+
+ if (!acorn.version)
+ acorn = null;
+ }
+
+ function parse(code, options) {
+ return (global.acorn || acorn).parse(code, options);
+ }
var binaryOperators = {
'+': '__add',
@@ -14643,7 +16053,7 @@ Base.exports.PaperScript = function() {
var unaryOperators = {
'-': '__negate',
- '+': null
+ '+': '__self'
};
var fields = Base.each(
@@ -14651,7 +16061,11 @@ Base.exports.PaperScript = function() {
function(name) {
this['__' + name] = '#' + name;
},
- {}
+ {
+ __self: function() {
+ return this;
+ }
+ }
);
Point.inject(fields);
Size.inject(fields);
@@ -14676,7 +16090,7 @@ Base.exports.PaperScript = function() {
function $__(operator, value) {
var handler = unaryOperators[operator];
- if (handler && value && value[handler])
+ if (value && value[handler])
return value[handler]();
switch (operator) {
case '+': return +value;
@@ -14684,10 +16098,6 @@ Base.exports.PaperScript = function() {
}
}
- function parse(code, options) {
- return scope.acorn.parse(code, options);
- }
-
function compile(code, options) {
if (!code)
return '';
@@ -14712,7 +16122,7 @@ Base.exports.PaperScript = function() {
function getBetween(left, right) {
return code.substring(getOffset(left.range[1]),
- getOffset(right.range[0]));
+ getOffset(right.range[0]) - 1);
}
function replaceCode(node, str) {
@@ -14855,7 +16265,7 @@ Base.exports.PaperScript = function() {
sourcesContent: [source]
};
}
- walkAST(parse(code, { ranges: true }));
+ walkAST(parse(code, { ranges: true, preserveParens: true }));
if (map) {
if (offsetCode) {
code = new Array(offset + 1).join('\n') + code;
@@ -15015,8 +16425,9 @@ paper = new (PaperScope.inject(Base.exports, {
PlacedSymbol: SymbolItem
}))();
-if (paper.agent.node)
+if (paper.agent.node) {
require('./node/extend.js')(paper);
+}
if (typeof define === 'function' && define.amd) {
define('paper', paper);
diff --git a/dist/paper-full.min.js b/dist/paper-full.min.js
index 4e29cfbc..72fa9f2d 100644
--- a/dist/paper-full.min.js
+++ b/dist/paper-full.min.js
@@ -1,5 +1,5 @@
/*!
- * Paper.js v0.10.3 - The Swiss Army Knife of Vector Graphics Scripting.
+ * Paper.js v0.10.4 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
@@ -9,7 +9,7 @@
*
* All rights reserved.
*
- * Date: Wed Mar 8 10:43:28 2017 +0100
+ * Date: Wed Apr 19 19:53:39 2017 +0200
*
***
*
@@ -29,11 +29,11 @@
* created by Marijn Haverbeke and released under an MIT license.
*
*/
-var paper=function(t,e){t=t||require("./node/window.js");var n=t.window,i=t.document,r=new function(){function t(t,e,r,s,a){function u(i,u){u=u||(u=o(e,i))&&(u.get?u:u.value),"string"==typeof u&&"#"===u[0]&&(u=t[u.substring(1)]||u);var c,f="function"==typeof u,d=u,_=a||f&&!u.base?u&&u.get?i in t:t[i]:null;a&&_||(f&&_&&(u.base=_),f&&s!==!1&&(c=i.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[c[3].toLowerCase()+c[4]]=c[2]),d&&!f&&d.get&&"function"==typeof d.get&&n.isPlainObject(d)||(d={value:d,writable:!0}),(o(t,i)||{configurable:!0}).configurable&&(d.configurable=!0,d.enumerable=r),h(t,i,d))}var l={};if(e){for(var c in e)e.hasOwnProperty(c)&&!i.test(c)&&u(c);for(var c in l){var f=l[c],d=t["set"+f],_=t["get"+f]||d&&t["is"+f];!_||s!==!0&&0!==_.length||u(c,{get:_,set:d})}}return t}function n(){for(var t=0,e=arguments.length;t0||u+s0?[["dictionary",i.definitions],s]:s},deserialize:function(t,e,n,i,s){var a=t,o=!n,h=o&&t&&t.length&&"dictionary"===t[0][0];if(n=n||{},Array.isArray(t)){var u=t[0],l="dictionary"===u;if(1==t.length&&/^#/.test(u))return n.dictionary[u];u=r.exports[u],a=[];for(var c=u?1:0,f=t.length;ct.length&&(i=t.length);for(var o=0;o0){var s=e[r],a=s&&s[i];a&&a.call(this,r)}},statics:{inject:function st(t){var e=t._events;if(e){var n={};r.each(e,function(e,i){var s="string"==typeof e,a=s?e:i,o=r.capitalize(a),h=a.substring(2).toLowerCase();n[h]=s?{}:e,a="_"+a,t["get"+o]=function(){return this[a]},t["set"+o]=function(t){var e=this[a];e&&this.off(h,e),t&&this.on(h,t),this[a]=t}}),t._eventTypes=n}return st.base.apply(this,arguments)}}},a=r.extend({_class:"PaperScope",initialize:function at(){paper=this,this.settings=new r({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this.palettes=[],this._id=at._id++,at._scopes[this._id]=this;var e=at.prototype;if(!this.support){var n=tt.getContext(1,1)||{};e.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:et.nativeModes},tt.release(n)}if(!this.agent){var i=t.navigator.userAgent.toLowerCase(),s=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(i)||[])[0],a="darwin"===s?"mac":s,o=e.agent=e.browser={platform:a};a&&(o[a]=!0),i.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(t,e,n,i,r){if(!o.chrome){var s="opera"===e?i:/^(node|trident)$/.test(e)?r:n;o.version=s,o.versionNumber=parseFloat(s),e="trident"===e?"msie":e,o.name=e,o[e]=!0}}),o.chrome&&delete o.webkit,o.atom&&delete o.chrome}},version:"0.10.3",getView:function(){var t=this.project;return t&&t._view},getPaper:function(){return this},execute:function(t,e){paper.PaperScript.execute(t,this,e),Z.updateFocus()},install:function(t){var e=this;r.each(["project","view","tool"],function(n){r.define(t,n,{configurable:!0,get:function(){return e[n]}})});for(var n in this)!/^_/.test(n)&&this[n]&&(t[n]=this[n])},setup:function(t){return paper=this,this.project=new y(t),this},createCanvas:function(t,e){return tt.getCanvas(t,e)},activate:function(){paper=this},clear:function(){for(var t=this.projects,e=this.tools,n=this.palettes,i=t.length-1;i>=0;i--)t[i].remove();for(var i=e.length-1;i>=0;i--)e[i].remove();for(var i=n.length-1;i>=0;i--)n[i].remove()},remove:function(){this.clear(),delete a._scopes[this._id]},statics:new function(){function t(t){return t+="Attribute",function(e,n){return e[t](n)||e[t]("data-paper-"+n)}}return{_scopes:{},_id:0,get:function(t){return this._scopes[t]||null},getAttribute:t("get"),hasAttribute:t("has")}}}),o=r.extend(s,{initialize:function(t){this._scope=paper,this._index=this._scope[this._list].push(this)-1,!t&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var t=this._scope[this._reference];return t&&t!==this&&t.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",t),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(r.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),h=r.extend({initialize:function(t){this.precision=r.pick(t,5),this.multiplier=Math.pow(10,this.precision)},number:function(t){return this.precision<16?Math.round(t*this.multiplier)/this.multiplier:t},pair:function(t,e,n){return this.number(t)+(n||",")+this.number(e)},point:function(t,e){return this.number(t.x)+(e||",")+this.number(t.y)},size:function(t,e){return this.number(t.width)+(e||",")+this.number(t.height)},rectangle:function(t,e){return this.point(t,e)+(e||",")+this.size(t,e)}});h.instance=new h;var u=new function(){function t(t,e,n){return tn?n:t}function e(t,e,n){function i(t){var e=134217729*t,n=t-e,i=n+e,r=t-i;return[i,r]}var r=e*e-t*n,a=e*e+t*n;if(3*s(r)1e8)?o(2,-Math.round(h(t))):0}var i=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],r=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],s=Math.abs,a=Math.sqrt,o=Math.pow,h=Math.log2||function(t){return Math.log(t)*Math.LOG2E},l=1e-12,c=1.12e-16;return{EPSILON:l,MACHINE_EPSILON:c,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,KAPPA:4*(a(2)-1)/3,isZero:function(t){return t>=-l&&t<=l},clamp:t,integrate:function(t,e,n,s){for(var a=i[s-2],o=r[s-2],h=.5*(n-e),u=h+e,l=0,c=s+1>>1,f=1&s?o[l++]*t(u):0;l0?(a=i,i=f<=r?.5*(r+a):f):(r=i,i=f>=a?.5*(r+a):f)}return t(i,r,a)},solveQuadratic:function(i,r,o,h,u,f){var d,_=1/0;if(s(i)=-c){var p=g<0?0:a(g),m=r+(r<0?-p:p);0===m?(d=o/i,_=-d):(d=m/i,_=o/m)}}var y=0,w=null==u,x=u-l,b=f+l;return isFinite(d)&&(w||d>x&&dx&&_0?1.324717957244746*Math.max(C,a(k)):C,P=v-S*I;if(P!==v){do g(P),P=0===y?v:v-w/y/(1+c);while(S*P>S*v);s(e)*v*v>s(h/v)&&(m=-h/v,p=(m-r)/v)}}var A=u.solveQuadratic(e,p,m,f,d,_),M=null==d;return isFinite(v)&&(0===A||A>0&&v!==f[0]&&v!==f[1])&&(M||v>d-l&&v<_+l)&&(f[A++]=M?v:t(v,d,_)),A}}},l={_id:1,_pools:{},get:function(t){if(t){var e=this._pools[t];return e||(e=this._pools[t]={_id:1}),e._id++}return this._id++}},c=r.extend({_class:"Point",_readIndex:!0,initialize:function(t,e){var n=typeof t,i=this.__read,r=0;if("number"===n){var s="number"==typeof e;this._set(t,s?e:t),i&&(r=s?2:1)}else if("undefined"===n||null===t)this._set(0,0),i&&(r=null===t?1:0);else{var a="string"===n?t.split(/[\s,]+/)||[]:t;r=1,Array.isArray(a)?this._set(+a[0],+(a.length>1?a[1]:a[0])):"x"in a?this._set(a.x||0,a.y||0):"width"in a?this._set(a.width||0,a.height||0):"angle"in a?(this._set(a.length||0,0),this.setAngle(a.angle||0)):(this._set(0,0),r=0)}return i&&(this.__read=r),this},set:"#initialize",_set:function(t,e){return this.x=t,this.y=e,this},equals:function(t){return this===t||t&&(this.x===t.x&&this.y===t.y||Array.isArray(t)&&this.x===t[0]&&this.y===t[1])||!1},clone:function(){return new c(this.x,this.y)},toString:function(){var t=h.instance;return"{ x: "+t.number(this.x)+", y: "+t.number(this.y)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.x),e.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(t){if(this.isZero()){var e=this._angle||0;this._set(Math.cos(e)*t,Math.sin(e)*t)}else{var n=t/this.getLength();u.isZero(n)&&this.getAngle(),this._set(this.x*n,this.y*n)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(t){this.setAngleInRadians.call(this,t*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var t=c.read(arguments),e=this.getLength()*t.getLength();if(u.isZero(e))return NaN;var n=this.dot(t)/e;return Math.acos(n<-1?-1:n>1?1:n)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(t){if(this._angle=t,!this.isZero()){var e=this.getLength();this._set(Math.cos(t)*e,Math.sin(t)*e)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var t=c.read(arguments);return 180*Math.atan2(this.cross(t),this.dot(t))/Math.PI},getDistance:function(){var t=c.read(arguments),e=t.x-this.x,n=t.y-this.y,i=e*e+n*n,s=r.read(arguments);return s?i:Math.sqrt(i)},normalize:function(t){t===e&&(t=1);var n=this.getLength(),i=0!==n?t/n:0,r=new c(this.x*i,this.y*i);return i>=0&&(r._angle=this._angle),r},rotate:function(t,e){if(0===t)return this.clone();t=t*Math.PI/180;var n=e?this.subtract(e):this,i=Math.sin(t),r=Math.cos(t);return n=new c(n.x*r-n.y*i,n.x*i+n.y*r),e?n.add(e):n},transform:function(t){return t?t._transformPoint(this):this},add:function(){var t=c.read(arguments);return new c(this.x+t.x,this.y+t.y)},subtract:function(){var t=c.read(arguments);return new c(this.x-t.x,this.y-t.y)},multiply:function(){var t=c.read(arguments);return new c(this.x*t.x,this.y*t.y)},divide:function(){var t=c.read(arguments);return new c(this.x/t.x,this.y/t.y)},modulo:function(){var t=c.read(arguments);return new c(this.x%t.x,this.y%t.y)},negate:function(){return new c((-this.x),(-this.y))},isInside:function(){return g.read(arguments).contains(this)},isClose:function(){var t=c.read(arguments),e=r.read(arguments);return this.getDistance(t)<=e},isCollinear:function(){var t=c.read(arguments);return c.isCollinear(this.x,this.y,t.x,t.y)},isColinear:"#isCollinear",isOrthogonal:function(){var t=c.read(arguments);return c.isOrthogonal(this.x,this.y,t.x,t.y)},isZero:function(){var t=u.isZero;return t(this.x)&&t(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},isInQuadrant:function(t){return this.x*(t>1&&t<4?-1:1)>=0&&this.y*(t>2?-1:1)>=0},dot:function(){var t=c.read(arguments);return this.x*t.x+this.y*t.y},cross:function(){var t=c.read(arguments);return this.x*t.y-this.y*t.x},project:function(){var t=c.read(arguments),e=t.isZero()?0:this.dot(t)/t.dot(t);return new c(t.x*e,t.y*e)},statics:{min:function(){var t=c.read(arguments),e=c.read(arguments);return new c(Math.min(t.x,e.x),Math.min(t.y,e.y))},max:function(){var t=c.read(arguments),e=c.read(arguments);return new c(Math.max(t.x,e.x),Math.max(t.y,e.y))},random:function(){return new c(Math.random(),Math.random())},isCollinear:function(t,e,n,i){return Math.abs(t*i-e*n)<=1e-8*Math.sqrt((t*t+e*e)*(n*n+i*i))},isOrthogonal:function(t,e,n,i){return Math.abs(t*n+e*i)<=1e-8*Math.sqrt((t*t+e*e)*(n*n+i*i))}}},r.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new c(e(this.x),e(this.y))}},{})),f=c.extend({initialize:function(t,e,n,i){this._x=t,this._y=e,this._owner=n,this._setter=i},_set:function(t,e,n){return this._x=t,this._y=e,n||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(t){this._x=t,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(t){this._y=t,this._owner[this._setter](this)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(t){this._owner.changeSelection(this._getSelection(),t)},_getSelection:function(){return"setPosition"===this._setter?4:0}}),d=r.extend({_class:"Size",_readIndex:!0,initialize:function(t,e){var n=typeof t,i=this.__read,r=0;if("number"===n){var s="number"==typeof e;this._set(t,s?e:t),i&&(r=s?2:1)}else if("undefined"===n||null===t)this._set(0,0),i&&(r=null===t?1:0);else{var a="string"===n?t.split(/[\s,]+/)||[]:t;r=1,Array.isArray(a)?this._set(+a[0],+(a.length>1?a[1]:a[0])):"width"in a?this._set(a.width||0,a.height||0):"x"in a?this._set(a.x||0,a.y||0):(this._set(0,0),r=0)}return i&&(this.__read=r),this},set:"#initialize",_set:function(t,e){return this.width=t,this.height=e,this},equals:function(t){return t===this||t&&(this.width===t.width&&this.height===t.height||Array.isArray(t)&&this.width===t[0]&&this.height===t[1])||!1},clone:function(){return new d(this.width,this.height)},toString:function(){var t=h.instance;return"{ width: "+t.number(this.width)+", height: "+t.number(this.height)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.width),e.number(this.height)]},add:function(){var t=d.read(arguments);return new d(this.width+t.width,this.height+t.height)},subtract:function(){var t=d.read(arguments);return new d(this.width-t.width,this.height-t.height)},multiply:function(){var t=d.read(arguments);return new d(this.width*t.width,this.height*t.height)},divide:function(){var t=d.read(arguments);return new d(this.width/t.width,this.height/t.height)},modulo:function(){var t=d.read(arguments);return new d(this.width%t.width,this.height%t.height)},negate:function(){return new d((-this.width),(-this.height))},isZero:function(){var t=u.isZero;return t(this.width)&&t(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(t,e){return new d(Math.min(t.width,e.width),Math.min(t.height,e.height))},max:function(t,e){return new d(Math.max(t.width,e.width),Math.max(t.height,e.height))},random:function(){return new d(Math.random(),Math.random())}}},r.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new d(e(this.width),e(this.height))}},{})),_=d.extend({initialize:function(t,e,n,i){this._width=t,this._height=e,this._owner=n,this._setter=i},_set:function(t,e,n){return this._width=t,this._height=e,n||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(t){this._width=t,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(t){this._height=t,this._owner[this._setter](this)}}),g=r.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(t,n,i,s){var a,o=typeof t;if("number"===o?(this._set(t,n,i,s),a=4):"undefined"===o||null===t?(this._set(0,0,0,0),a=null===t?1:0):1===arguments.length&&(Array.isArray(t)?(this._set.apply(this,t),a=1):t.x!==e||t.width!==e?(this._set(t.x||0,t.y||0,t.width||0,t.height||0),a=1):t.from===e&&t.to===e&&(this._set(0,0,0,0),r.filter(this,t),a=1)),a===e){var h,u,l=c.readNamed(arguments,"from"),f=r.peek(arguments),_=l.x,g=l.y;if(f&&f.x!==e||r.hasNamed(arguments,"to")){var v=c.readNamed(arguments,"to");h=v.x-_,u=v.y-g,h<0&&(_=v.x,h=-h),u<0&&(g=v.y,u=-u)}else{var p=d.read(arguments);h=p.width,u=p.height}this._set(_,g,h,u),a=arguments.__index}return this.__read&&(this.__read=a),this},set:"#initialize",_set:function(t,e,n,i){return this.x=t,this.y=e,this.width=n,this.height=i,this},clone:function(){return new g(this.x,this.y,this.width,this.height)},equals:function(t){var e=r.isPlainValue(t)?g.read(arguments):t;return e===this||e&&this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height||!1},toString:function(){var t=h.instance;return"{ x: "+t.number(this.x)+", y: "+t.number(this.y)+", width: "+t.number(this.width)+", height: "+t.number(this.height)+" }"},_serialize:function(t){var e=t.formatter;return[e.number(this.x),e.number(this.y),e.number(this.width),e.number(this.height)]},getPoint:function(t){var e=t?c:f;return new e(this.x,this.y,this,"setPoint")},setPoint:function(){var t=c.read(arguments);this.x=t.x,this.y=t.y},getSize:function(t){var e=t?d:_;return new e(this.width,this.height,this,"setSize")},setSize:function(){var t=d.read(arguments);this._fixX&&(this.x+=(this.width-t.width)*this._fixX),this._fixY&&(this.y+=(this.height-t.height)*this._fixY),this.width=t.width,this.height=t.height,this._fixW=1,this._fixH=1},getLeft:function(){return this.x},setLeft:function(t){this._fixW||(this.width-=t-this.x),this.x=t,this._fixX=0},getTop:function(){return this.y},setTop:function(t){this._fixH||(this.height-=t-this.y),this.y=t,this._fixY=0},getRight:function(){return this.x+this.width},setRight:function(t){this._fixX!==e&&1!==this._fixX&&(this._fixW=0),this._fixW?this.x=t-this.width:this.width=t-this.x,this._fixX=1},getBottom:function(){return this.y+this.height},setBottom:function(t){this._fixY!==e&&1!==this._fixY&&(this._fixH=0),this._fixH?this.y=t-this.height:this.height=t-this.y,this._fixY=1},getCenterX:function(){return this.x+.5*this.width},setCenterX:function(t){this.x=t-.5*this.width,this._fixX=.5},getCenterY:function(){return this.y+.5*this.height},setCenterY:function(t){this.y=t-.5*this.height,this._fixY=.5},getCenter:function(t){var e=t?c:f;return new e(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var t=c.read(arguments);return this.setCenterX(t.x),this.setCenterY(t.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(t){return t&&t.width!==e||4===(Array.isArray(t)?t:arguments).length?this._containsRectangle(g.read(arguments)):this._containsPoint(c.read(arguments))},_containsPoint:function(t){var e=t.x,n=t.y;return e>=this.x&&n>=this.y&&e<=this.x+this.width&&n<=this.y+this.height},_containsRectangle:function(t){var e=t.x,n=t.y;return e>=this.x&&n>=this.y&&e+t.width<=this.x+this.width&&n+t.height<=this.y+this.height},intersects:function(){var t=g.read(arguments);return t.x+t.width>this.x&&t.y+t.height>this.y&&t.x=this.x&&t.y+t.height>=this.y&&t.x<=this.x+this.width&&t.y<=this.y+this.height},intersect:function(){var t=g.read(arguments),e=Math.max(this.x,t.x),n=Math.max(this.y,t.y),i=Math.min(this.x+this.width,t.x+t.width),r=Math.min(this.y+this.height,t.y+t.height);return new g(e,n,i-e,r-n)},unite:function(){var t=g.read(arguments),e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),i=Math.max(this.x+this.width,t.x+t.width),r=Math.max(this.y+this.height,t.y+t.height);return new g(e,n,i-e,r-n)},include:function(){var t=c.read(arguments),e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),i=Math.max(this.x+this.width,t.x),r=Math.max(this.y+this.height,t.y);return new g(e,n,i-e,r-n)},expand:function(){var t=d.read(arguments),e=t.width,n=t.height;return new g(this.x-e/2,this.y-n/2,this.width+e,this.height+n)},scale:function(t,n){return this.expand(this.width*t-this.width,this.height*(n===e?t:n)-this.height)}},r.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(t,e){var n=t.join(""),i=/^[RL]/.test(n);e>=4&&(t[1]+=i?"Y":"X");var r=t[i?0:1],s=t[i?1:0],a="get"+r,o="get"+s,h="set"+r,u="set"+s,l="get"+n,d="set"+n;this[l]=function(t){var e=t?c:f;return new e(this[a](),this[o](),this,d)},this[d]=function(){var t=c.read(arguments);this[h](t.x),this[u](t.y)}},{beans:!0})),v=g.extend({initialize:function(t,e,n,i,r,s){this._set(t,e,n,i,!0),this._owner=r,this._setter=s},_set:function(t,e,n,i,r){return this._x=t,this._y=e,this._width=n,this._height=i,r||this._owner[this._setter](this),this}},new function(){var t=g.prototype;return r.each(["x","y","width","height"],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._dontNotify||this._owner[this._setter](this)}},r.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(e){var n="set"+e;this[n]=function(){this._dontNotify=!0,t[n].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(t){var e=this._owner;e.changeSelection&&e.changeSelection(2,t)}}))}),p=r.extend({_class:"Matrix",initialize:function ot(t,e){var n=arguments.length,i=!0;if(n>=6?this._set.apply(this,arguments):1===n||2===n?t instanceof ot?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):i=!1:n?i=!1:this.reset(),!i)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(9))},clone:function(){return new p(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=h.instance;return"[["+[t.number(this._a),t.number(this._c),t.number(this._tx)].join(", ")+"], ["+[t.number(this._b),t.number(this._d),t.number(this._ty)].join(", ")+"]]"},reset:function(t){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,t||this._changed(),this},apply:function(t,e){var n=this._owner;return!!n&&(n.transform(null,!0,r.pick(t,!0),e),this.isIdentity())},translate:function(){var t=c.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=c.read(arguments),e=c.read(arguments,0,{readNull:!0});return e&&this.translate(e),this._a*=t.x,this._b*=t.x,this._c*=t.y,this._d*=t.y,e&&this.translate(e.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=c.read(arguments,1),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,f=this._d;return this._a=r*h+s*l,this._b=r*u+s*f,this._c=-s*h+r*l,this._d=-s*u+r*f,
-this._tx+=a*h+o*l,this._ty+=a*u+o*f,this._changed(),this},shear:function(){var t=c.read(arguments),e=c.read(arguments,0,{readNull:!0});e&&this.translate(e);var n=this._a,i=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*n,this._d+=t.x*i,e&&this.translate(e.negate()),this._changed(),this},skew:function(){var t=c.read(arguments),e=c.read(arguments,0,{readNull:!0}),n=Math.PI/180,i=new c(Math.tan(t.x*n),Math.tan(t.y*n));return this.shear(i,e)},append:function(t){if(t){var e=this._a,n=this._b,i=this._c,r=this._d,s=t._a,a=t._c,o=t._b,h=t._d,u=t._tx,l=t._ty;this._a=s*e+o*i,this._c=a*e+h*i,this._b=s*n+o*r,this._d=a*n+h*r,this._tx+=u*e+l*i,this._ty+=u*n+l*r,this._changed()}return this},prepend:function(t){if(t){var e=this._a,n=this._b,i=this._c,r=this._d,s=this._tx,a=this._ty,o=t._a,h=t._c,u=t._b,l=t._d,c=t._tx,f=t._ty;this._a=o*e+h*n,this._c=o*i+h*r,this._b=u*e+l*n,this._d=u*i+l*r,this._tx=o*s+h*a+c,this._ty=u*s+l*a+f,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 p(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var t=this._a*this._d-this._c*this._b;return t&&!isNaN(t)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(t,e,n){return arguments.length<3?this._transformPoint(c.read(arguments)):this._transformCoordinates(t,e,n)},_transformPoint:function(t,e,n){var i=t.x,r=t.y;return e||(e=new c),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 g),e._set(r[0],r[1],s[0]-r[0],s[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(c.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 f=t.x-this._tx,d=t.y-this._ty;e||(e=new c),l=e._set((f*a-d*s)/u,(d*i-f*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 f=h(i*i+r*r);t=Math.acos(i/f)*(r>0?1:-1),e=[f,o/f],n=[u(i*s+r*a,f*f),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 c(e),skewing:new c(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 c(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()}},{})),m=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 c(this._px,this._py)},getVector:function(){return new c(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return m.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return m.getSide(this._px,this._py,this._vx,this._vy,t.x,t.y,!0,e)},getDistance:function(t){return Math.abs(m.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0))},isCollinear:function(t){return c.isCollinear(this._vx,this._vy,t._vx,t._vy)},isOrthogonal:function(t){return c.isOrthogonal(this._vx,this._vy,t._vx,t._vy)},statics:{intersect:function(t,e,n,i,r,s,a,o,h,l){h||(n-=t,i-=e,a-=r,o-=s);var f=n*o-i*a;if(!u.isZero(f)){var d=t-r,_=e-s,g=(a*_-o*d)/f,v=(n*_-i*d)/f,p=1e-12,m=-p,y=1+p;if(l||m=1?1:g),new c(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,l=s-e,c=h*i-l*n;return!o&&u.isZero(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)/Math.sqrt(n*n+i*i)},getDistance:function(t,e,n,i,r,s,a){return Math.abs(m.getSignedDistance(t,e,n,i,r,s,a))}}}),y=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 V(null,null,this),this._view=Z.create(this,t||tt.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 ht(){return!!ht.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 b({project:this,insert:!0})},getSymbolDefinitions:function(){var t=[],e={};return this.getItems({"class":k,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 f in h)h[f]._drawSelection(t,e,u,h,l);t.restore()}}}),w=r.extend(s,{statics:{extend:function ut(t){return t._serializeFields&&(t._serializeFields=r.set({},this.prototype._serializeFields,t._serializeFields)),ut.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 p,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 p,o=i&&t.project||paper.project,h=paper.settings;return this._id=s?null:l.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&h.applyMatrix,n&&a.translate(n),a._owner=this,this._style=new V(o._currentStyle,this,o),s||i&&t.insert===!1||!h.insertItems&&(!i||t.insert!==!0)?this._setProject(o):(i&&t.parent||o)._insertItem(e,this,!0),i&&t!==w.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 x||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=this._globalMatrix=e),i&&40&t&&w._clearBoundsCache(i),2&t&&w._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(128)},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),t="_"+t;this["get"+e]=function(){return this[t]},this["set"+e]=function(e){e!=this[t]&&(this[t]=e,this._changed("_locked"===t?128:129))}},{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(t){if(t!==this._selection){this._selection=t;var e=this._project;e&&(e._updateSelection(this),this._changed(129))}},changeSelection:function(t,e){var n=this._selection;this.setSelection(e?n|t:n&~t)},isSelected:function(){if(this._selectChildren)for(var t=this._children,e=0,n=t.length;e=0;n--)if(e[n].contains(t))return!0;return!1}return t.isInside(this.getInternalBounds())},isInside:function(){return g.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new L.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(t,e){return t instanceof w&&this._asPathItem().getIntersections(t._asPathItem(),null,e,!0).length>0}},new function(){function t(){return this._hitTest(c.read(arguments),P.getOptions(arguments))}function e(){var t=c.read(arguments),e=P.getOptions(arguments),n=[];return this._hitTest(t,r.set({all:n},e)),n}function n(t,e,n,i){var r=this._children;if(r)for(var s=r.length-1;s>=0;s--){var a=r[s],o=a!==i&&a._hitTest(t,e,n);if(o&&!e.all)return o}return null}return y.inject({hitTest:t,hitTestAll:e,_hitTest:n}),{hitTest:t,hitTestAll:e,_hitTestChildren:n}},{_hitTest:function(t,e,n){function i(t){return t&&_&&!_(t)&&(t=null),t&&e.all&&e.all.push(t),t}function s(e,n){var i=l["get"+n]();if(t.subtract(i).divide(u).length<=1)return new P(e,g,{name:r.hyphenate(n),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 d(L._getStrokePadding(h,a.inverted()._shiftless()));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"])),_=e.match,g=this;if(f&&(e.center||e.bounds)&&this._parent){if(l=this.getInternalBounds(),e.center&&(c=s("center","Center")),!c&&e.bounds)for(var v=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],p=0;p<8&&!c;p++)c=s("bounds",v[p]);c=i(c)}return c||(c=this._hitTestChildren(t,e,o)||f&&i(this._hitTestSelf(t,e,o,this.getStrokeScaling()?null:o.inverted()._shiftless()))||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 P("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 w._getItems(this,t,this._matrix)},getItem:function(t){return w._getItems(this,t,this._matrix,null,!0)[0]||null},statics:{_getItems:function ct(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&&g.read([u]);i={items:[],recursive:a&&a.recursive!==!1,inside:!!h,overlapping:!!o,rect:l,path:o&&new L.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 p);for(var d=0,_=c&&c.length;d<_;d++){var v=c[d],m=n&&n.appended(v._matrix),y=!0;if(l){var u=v.getBounds(m);if(!l.intersects(u))continue;l.contains(u)||i.overlapping&&(u.contains(l)||i.path.intersects(v,m))||(y=!1)}if(y&&v.matches(e)&&(f.push(v),s))break;if(i.recursive!==!1&&ct(v,e,m,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=e.length-1;i>=0;i--){var s=e[i];s?s._remove(!1,!0):e.splice(i,1)}r.splice(n,e,t,0);for(var a=this._project,o=a._changes,i=0,h=e.length;i=0;i--)n[i]._remove(!0,!1);return n.length>0&&this._changed(11),n},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var t=0,e=this._children.length;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=(e?r:c).read(arguments),i=c.read(arguments,0,{readNull:!0});return this.transform((new p)[t](n,i||this.getPosition(!0)))}},{translate:function(){var t=new p;return this.transform(t.translate.apply(t,arguments))},transform:function(t,e,n,i){t&&t.isIdentity()&&(t=null);var r=this._matrix,s=(e||this._applyMatrix)&&(!r.isIdentity()||t||e&&n&&this._children);if(!t&&!s)return this;if(t&&(!t.isInvertible()&&r.isInvertible()&&(r._backup=r.getValues()),r.prepend(t)),s=s&&this._transformContent(r,n,i)){var a=this._pivot,o=this._style,h=o.getFillColor(!0),u=o.getStrokeColor(!0);a&&r._transformPoint(a,a,!0),h&&h.transform(r),u&&u.transform(r),r.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var l=this._bounds,c=this._position;this._changed(9);var f=l&&t&&t.decompose();if(f&&!f.shearing&&f.rotation%90===0){for(var d in l){var _=l[d];if(s||!_.internal){var g=_.rect;t._transformBounds(g,g)}}var v=this._boundsGetter,g=l[v&&v.getBounds||v||"getBounds"];g&&(this._position=g.getCenter(!0)),this._bounds=l}else t&&c&&(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 g(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(L._getStrokePadding(d,!h.getStrokeScaling()&&a));if("rectangle"===c){var v=_.multiply(2),p=t(this,n,v);if(p)o=e(n.subtract(p.point),f,_,p.quadrant);else{var m=new g(this._size).setCenter(0,0),y=m.expand(v),w=m.expand(v.negate());o=y._containsPoint(n)&&!w._containsPoint(n)}}else o=e(n,f,_)}return o?new P(u?"stroke":"fill",this):i.base.apply(this,arguments)}}},{statics:new function(){function t(t,e,n,i,s){var a=new C(r.getNamed(s));return a._type=t,a._size=n,a._radius=i,a.translate(e)}return{Circle:function(){var e=c.readNamed(arguments,"center"),n=r.readNamed(arguments,"radius");return t("circle",e,new d(2*n),n,arguments)},Rectangle:function(){var e=g.readNamed(arguments,"rectangle"),n=d.min(d.readNamed(arguments,"radius"),e.getSize(!0).divide(2));return t("rectangle",e.getCenter(!0),e.getSize(!0),n,arguments)},Ellipse:function(){var e=C._readEllipse(arguments),n=e.radius;return t("ellipse",e.center,n.multiply(2),n,arguments)},_readEllipse:function(t){var e,n;if(r.hasNamed(t,"radius"))e=c.readNamed(t,"center"),n=d.readNamed(t,"radius");else{var i=g.readNamed(t,"rectangle");e=i.getCenter(!0),n=i.getSize(!0).divide(2)}return{center:e,radius:n}}}}}),S=w.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],initialize:function(t,n){if(!this._initialize(t,n!==e&&c.read(arguments,1))){var r="string"==typeof t?i.getElementById(t):t;r?this.setImage(r):this.setSource(t)}this._size||(this._size=new d,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=tt.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 _(t?t.width:0,t?t.height:0,this,"setSize")},setSize:function(){var t=d.read(arguments);if(!t.equals(this._size))if(t.width>0&&t.height>0){var e=this.getElement();this._setImage(tt.getCanvas(t)),e&&this.getContext(!0).drawImage(e,0,0,t.width,t.height)}else this._canvas&&tt.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 c(0,0).transform(t),n=new c(1,0).transform(t).subtract(e),i=new c(0,1).transform(t).subtract(e);return new d(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)&&(paper=e._scope,n.emit(i,new $(t)))}var n=this;this._setImage(t),this._loaded?setTimeout(e,0):t&&U.add(t,{load:function(i){n._setImage(t),e(i)},error:e})},_setImage:function(t){this._canvas&&tt.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 d(t?t.naturalWidth||t.width:0,t?t.naturalHeight||t.height:0),this._context=null,this._changed(521)},getCanvas:function(){if(!this._canvas){var t=tt.getContext(this._size);try{this._image&&t.drawImage(this._image,0,0),this._canvas=t.canvas}catch(e){tt.release(t)}}return this._canvas},setCanvas:"#setImage",getContext:function(t){return this._context||(this._context=this.getCanvas().getContext("2d")),t&&(this._image=null,this._changed(513)),this._context},setContext:function(t){this._context=t},getSource:function(){var t=this._image;return t&&t.src||this.toDataURL()},setSource:function(e){var n=new t.Image,i=this._crossOrigin;i&&(n.crossOrigin=i),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)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var t=g.read(arguments),e=tt.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=g.read(arguments),e=new S(w.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=c.read(arguments,1);this.getContext(!0).drawImage(t,e.x,e.y)},getAverageColor:function(t){var e,n;if(t?t instanceof O?(n=t,e=t.getBounds()):"object"==typeof t&&("width"in t?e=new g(t):"x"in t&&(e=new g(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=S._sampleContext;o?o.clearRect(0,0,i+1,i+1):o=S._sampleContext=tt.getContext(new d(i)),o.save();var h=(new p).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],_=0,v=0,m=c.length;v0&&(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 M(o,this,"_point"),new M(h,this,"_handleIn"),new M(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(25)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(c.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(c.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(c.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var t=this._handleIn,e=this._handleOut;return!t.isZero()&&!e.isZero()&&t.isCollinear(e)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(t){var e=this._selection,n=this._path;this._selection=t=t||0,n&&t!==e&&(n._updateSelection(this,e,t),n._changed(129))},changeSelection:function(t,e){var n=this._selection;this.setSelection(e?n|t:n&~t)},isSelected:function(){return!!(7&this._selection)},setSelected:function(t){this.changeSelection(7,t)},getIndex:function(){return this._index!==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,f=(h||this)._point,d=u.getDistance(l),_=l.getDistance(f);if(s&&"catmull-rom"!==s){if("geometric"!==s)throw new Error("Smoothing method '"+s+"' not supported.");if(o&&h){var g=u.subtract(f),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 c((b*u._x+C*l._x-w*f._x)/S-l._x,(b*u._y+C*l._y-w*f._y)/S-l._y):new c)}if(!i&&h){var C=2*w+3*y*x+b,S=3*y*(y+x);this.setHandleOut(0!==S?new c((w*f._x+C*l._x-b*u._x)/S-l._x,(w*f._y+C*l._y-b*u._y)/S-l._y):new c)}}},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}}),M=c.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=c.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=u.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}}),T=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 T(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 T.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(c.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(c.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(c.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(c.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.getHandle2().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 T.getValues(this._segment1,this._segment2,t)},getPoints:function(){for(var t=this.getValues(),e=[],n=0;n<8;n+=2)e.push(new c(t[n],t[n+1]));return e}},{getLength:function(){return null==this._length&&(this._length=T.getLength(this.getValues(),0,1)),this._length},getArea:function(){return T.getArea(this.getValues())},getLine:function(){return new m(this._segment1._point,this._segment2._point)},getPart:function(t,e){return new T(T.getPart(this.getValues(),t,e))},getPartLength:function(t,e){return T.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=T.subdivide(this.getValues(),t),a=s[0],o=s[1],h=e||this.hasHandles(),u=this._segment1,l=this._segment2,f=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 c(d,_),h&&new c(a[4]-d,a[5]-_),h&&new c(o[2]-d,o[3]-_));f?(f.insert(u._index+1,g),r=this.getNext()):(this._segment2=g,this._changed(),r=new T(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 T(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||T.isStraight(t))n.push(t);else{var h=3*(s-a)-r+o,l=2*(r+a)-4*s,c=s-r,f=1e-8,d=1-f,_=[],g=u.solveQuadratic(h,l,c,_,f,d);if(g){_.sort();var v=_[0],p=T.subdivide(t,v);n.push(p[0]),g>1&&(v=(_[1]-v)/(1-v),p=T.subdivide(p[1],v),n.push(p[0])),n.push(p[1])}else n.push(t)}return n},solveCubic:function(t,e,n,i,r,s){var a=t[e],o=t[e+2],h=t[e+4],l=t[e+6],c=0;if(!(an&&l>n&&o>n&&h>n)){var f=3*(o-a),d=3*(h-o)-f,_=l-a-f-d;c=u.solveCubic(_,d,f,a-n,i,r,s)}return c},getTimeOf:function(t,e){var n=new c(t[0],t[1]),i=new c(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=T.solveCubic(t,u,o[u],h,0,1),f=0;f=0&&n<=1){var i=e.getDistance(T.getPoint(t,n),!0);if(i.999999999999?1:T.getTimeOf(t,new c(i+l*o,r+l*h))}for(var f=100,d=1/0,_=0,g=0;g<=f;g++)n(g/f);for(var v=1/(2*f);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=T.subdivide(t,e)[1]),n<1&&(t=T.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++)T._addBounds(t[r],t[r+2],t[r+4],t[r+6],r,0,e,n,i);return new g(e[0],e[1],n[0]-e[0],n[1]-e[1])},_addBounds:function(t,e,n,i,r,s,a,o,h){function l(t,e){var n=t-e,i=t+e;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 c(i,r),new c(e[2]-i,e[3]-r),new c(e[4]-s,e[5]-a),new c(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 T.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(c.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return T.getTimeOf(this.getValues(),c.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=c.read(arguments),e=this.getValues(),n=T.getNearestTime(e,t),i=T.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 T[t](i,n?e:T.getTimeAt(i,e))},this[t+"AtTime"]=function(e){return T[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],l=t[5],f=t[6],d=t[7],_=u.isZero;_(a-r)&&_(o-s)&&(a=r,o=s),_(h-f)&&_(l-d)&&(h=f,l=d);var g,v,p=3*(a-r),m=3*(h-a)-p,y=f-r-p-m,w=3*(o-s),x=3*(l-o)-w,b=d-s-w-x;if(0===n)g=0===e?r:1===e?f:((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*(f-h),v=3*(d-l)):(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=l-o);var k=Math.sqrt(g*g+v*v);k&&(g/=k,v/=k)}if(3===n){var h=6*y*e+2*m,l=6*b*e+2*x,I=Math.pow(g*g+v*v,1.5);g=0!==I?(g*l-v*h)/I:0,v=0}}return 2===n?new c(v,(-g)):new c(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),T.isStraight(i)){var o=i;s<1&&(o=T.subdivide(o,s)[0],r/=s),r>0&&(o=T.subdivide(o,r)[1]);var h=o[6]-o[0],l=o[7]-o[1];return Math.sqrt(h*h+l*l)}return u.integrate(a||t(i),r,s,n(r,s))},getTimeAt:function(i,r,s){function a(t){return p+=u.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,l=r>0,c=l?s:0,f=l?1:s,d=t(i),_=T.getLength(i,c,f,d),g=o(r)-_;if(o(g)h)return null;var v=r/_,p=0;return u.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],l=-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 u.solveCubic(9*(l*l+d*d),9*(l*c+_*d),2*(c*c+_*_)+3*(f*l+g*d),f*c+_*g,m,v,p),m.sort()}}}},new function(){function t(t,e,n,i,r,s,a,o,h){var u=!h&&n.getPrevious()===s,l=!h&&n!==s&&n.getNext()===s,c=1e-8,f=1-c;if(null==i&&(i=n.getTimeOf(r)),null!==i&&i>=(u?c:0)&&i<=(l?f:1)&&(null==a&&(a=s.getTimeOf(o)),null!==a&&a>=(l?c:0)&&a<=(u?f:1))){var d=new z(n,i,r||n.getPointAtTime(i),h),_=new z(s,a,o||s.getPointAtTime(a),h);d._intersection=_,_._intersection=d,e&&!e(d)||z.insert(t,d,!0)}}function e(r,s,a,o,h,u,l,c,f,d,_,g,v){if(++f>=4096||++c>=40)return f;var p,y,w=1e-9,x=s[0],b=s[1],C=s[6],S=s[7],k=m.getSignedDistance,I=k(x,b,C,S,s[2],s[3]),P=k(x,b,C,S,s[4],s[5]),A=I*P>0?.75:4/9,M=A*Math.min(0,I,P),z=A*Math.max(0,I,P),O=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(O,L,E,N),j=B[0],F=B[1];if(0===I&&0===P&&0===O&&0===L&&0===E&&0===N||null==(p=i(j,F,M,z))||null==(y=i(j.reverse(),F.reverse(),M,z)))return f;var R=d+(_-d)*p,D=d+(_-d)*y;if(Math.max(v-g,D-R).8)if(D-R>v-g){var H=T.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=T.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=v-g>=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=u.isZero;if(s(i)&&s(r)){var a=T.getTimeOf(t,new c(e,n));return null===a?[]:[a]}for(var o=Math.atan2(-r,i),h=Math.sin(o),l=Math.cos(o),f=[],d=[],_=0;_<8;_+=2){var g=t[_]-e,v=t[_+1]-n;f.push(g*l-v*h,g*h+v*l)}return T.solveCubic(f,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,k=T.getTimeOf(y[b],new c(y[C][S?6:0],y[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=T.getPart(t,w[0][0],w[1][0]),A=T.getPart(e,w[0][1],w[1][1]);(i(A[2]-P[2])>a||i(A[3]-P[3])>a||i(A[4]-P[4])>a||i(A[5]-P[5])>a)&&(w=null)}return w}return{getIntersections:function(t){var e=this.getValues(),n=t&&t!==this&&t.getValues();return n?h(e,n,this,t,[]):l(e,this,[])},statics:{getOverlaps:d,getIntersections:f,getCurveLineIntersections:s}}}),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},_setCurve:function(t){var e=t._path;this._path=e,this._version=e?e._version:0,this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){this._setCurve(t.getCurve()),this._segment=t,this._time=t===this._segment1?0:1,this._point=t._point.clone()},getSegment:function(){var t=this._segment;if(!t){var e=this.getCurve(),n=this.getTime();0===n?t=e._segment1:1===n?t=e._segment2:null!=n&&(t=e.getPartLength(0,n)1?i[r-1]:r>0?i[0]:.5;d.push(T.getLength(n,e?s:0,e?1:s)/2)}function e(t,e,n){return ee&&te||t=s&&i<=a,h=r>=s&&r<=a;if(o&&h)return!this.isTouching();var u=this.getCurve(),l=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(T._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}}}}),O=w.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?E:L;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 c(e(t,"x"),e(t+1,"y"))}var i,r,s,a=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),o=!1,h=new c,u=new c;this.clear();for(var l=0,f=a&&a.length;lu&&this[i?"removeSegments":"removeChildren"](u,h);for(var c=0;c=0&&e;h--){var u=n[h];e=!1;for(var l=s-1;l>=0&&!e;l--)u.compare(i[l])&&(a[l]||(a[l]=!0,o++),e=!0)}e=e&&o===s}return e}}),L=O.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(t){this._closed=!1,this._segments=[],this._version=0;var n=Array.isArray(t)?"object"==typeof t[0]?t:arguments:!t||t.size!==e||t.x===e&&t.point===e?null:arguments;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 vt(t){if(vt.base.call(this,t),8&t){if(this._length=this._area=e,16&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+r-1===u?e-1:e,c=l,f=Math.min(l+r,u);t._curves&&(i.splice.apply(i,[l,0].concat(t._curves)),c+=t._curves.length);for(var a=c;a0?t-1:t},add:function(t){return arguments.length>1&&"number"!=typeof t?this._add(A.readList(arguments)):this._add([A.read(arguments)])[0]},insert:function(t,e){return arguments.length>2&&"number"!=typeof e?this._add(A.readList(arguments,1),t):this._add([A.read(arguments,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(25),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 pt(t){1&t||this._selectSegments(!1),pt.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 L(w.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 B(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 T&&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],A=[S],M=[k],z=[],O=[],x=1;x=0;x--)z[x]=(P[x]-z[x+1])/M[x],O[x]=(A[x]-O[x+1])/M[x];z[v]=(3*w[v]._x-z[I])/2,O[v]=(3*w[v]._y-O[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=z[x]-q._x,H=O[x]-q._y;(u||xm)&&D.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 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 m(a,i,(!0)).intersect(new m(o,r,(!0)),!0);return h&&u.isZero(i.getLength()/h.subtract(a).getLength()-s)&&u.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,l,c=this._segments;if(!this.hasHandles()&&4===c.length&&n(0,2)&&n(1,3)&&i(1)?(a=C.Rectangle,o=new d(s(0,3),s(0,1)),l=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=C.Rectangle,o=new d(s(1,6),s(0,3)),h=o.subtract(new d(s(0,7),s(1,2))).divide(2),l=c[3]._point.add(c[4]._point).divide(2)):4===c.length&&r(0)&&r(1)&&r(2)&&r(3)&&(u.isZero(s(0,2)-s(1,3))?(a=C.Circle,h=s(0,2)/2):(a=C.Ellipse,h=new d(s(2,0)/2,s(3,1)/2)),l=c[1]._point),a){var f=this.getPosition(!0),_=new a({center:f,size:o,radius:h,insert:!1});return _.copyAttributes(this,!0),_._matrix.prepend(this._matrix),_.rotate(l.subtract(f).getAngle()+90),(t===e||t)&&_.insertAbove(this),_}return null},toPath:"#clone",compare:function mt(t){if(!t||t instanceof E)return mt.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=T.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 P(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(L._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}}),new function(){function t(t,e,n,i){function r(e){var n=h[e],i=h[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())}for(var s,a,o=i/2,h=new Array(6),u=0,l=e.length;u0&&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=!paper.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 N(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,paper.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(c.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new A(c.read(arguments))])},cubicCurveTo:function(){var e=c.read(arguments),n=c.read(arguments),i=c.read(arguments),r=t(this);r.setHandleOut(e.subtract(r._point)),this._add([new A(i,n.subtract(i))])},quadraticCurveTo:function(){var e=c.read(arguments),n=c.read(arguments),i=t(this)._point;this.cubicCurveTo(e.add(i.subtract(e).multiply(1/3)),e.add(n.subtract(e).multiply(1/3)),n)},curveTo:function(){var e=c.read(arguments),n=c.read(arguments),i=r.pick(r.read(arguments),.5),s=1-i,a=t(this)._point,o=e.subtract(a.multiply(s*s)).subtract(n.multiply(i*i)).divide(2*i*s);if(o.isNaN())throw new Error("Cannot put a curve through points with parameter = "+i);this.quadraticCurveTo(o,n)},arcTo:function(){var e,n,i,s,a,o=Math.abs,h=Math.sqrt,l=t(this),f=l._point,_=c.read(arguments),g=r.peek(arguments),v=r.pick(g,!0);if("boolean"==typeof v)var y=f.add(_).divide(2),e=y.add(y.subtract(f).rotate(v?-90:90));else if(r.remain(arguments)<=2)e=_,_=c.read(arguments);else{var w=d.read(arguments),x=u.isZero;if(x(w.width)||x(w.height))return this.lineTo(_);var b=r.read(arguments),v=!!r.read(arguments),C=!!r.read(arguments),y=f.add(_).divide(2),S=f.subtract(y).rotate(-b),k=S.x,I=S.y,P=o(w.width),M=o(w.height),T=P*P,z=M*M,O=k*k,L=I*I,E=h(O/T+L/z);if(E>1&&(P*=E,M*=E,T=P*P,z=M*M),E=(T*z-T*L-z*O)/(T*L+z*O),o(E)<1e-12&&(E=0),E<0)throw new Error("Cannot create an arc with the given arguments");n=new c(P*I/M,-M*k/P).multiply((C===v?-1:1)*h(E)).rotate(b).add(y),a=(new p).translate(n).rotate(b).scale(P,M),s=a._inverseTransform(f),i=s.getDirectedAngle(a._inverseTransform(_)),!v&&i>0?i-=360:v&&i<0&&(i+=360)}if(e){var N=new m(f.add(e).divide(2),e.subtract(f).rotate(90),(!0)),B=new m(e.add(_).divide(2),_.subtract(e).rotate(90),(!0)),j=new m(f,_),F=j.getSide(e);if(n=N.intersect(B,!0),!n){if(!F)return this.lineTo(_);throw new Error("Cannot create an arc with the given arguments")}s=f.subtract(n),i=s.getDirectedAngle(_.subtract(n));var R=j.getSide(n);0===R?i=F*o(i):F===R&&(i+=i<0?360:-360)}for(var D=1e-12,q=o(i),V=q>=360?4:Math.ceil((q-D)/90),H=i/V,U=H*Math.PI/360,Z=4/3*Math.sin(U)/(1+Math.cos(U)),W=[],$=0;$<=V;$++){var S=_,G=null;if($0&&(h(t[0],y),h(t[t.length-1],y)),v},_getStrokePadding:function(t,e){if(!e)return[t,t];var n=new c(t,0).transform(e),i=new c(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),f=Math.atan2(a,u*s);return[Math.abs(s*Math.cos(l)*h+a*Math.sin(l)*o),Math.abs(a*Math.sin(f)*h+s*Math.cos(f)*o)]},_addBevelJoin:function(t,e,n,i,r,s,a,o){var h=t.getCurve(),u=h.getPrevious(),l=h.getPoint1().transform(r),f=u.getNormalAtTime(1).multiply(n).transform(s),d=h.getNormalAtTime(0).multiply(n).transform(s);if(f.getDirectedAngle(d)<0&&(f=f.negate(),d=d.negate()),o&&a(l),a(l.add(f)),"miter"===e){var _=new m(l.add(f),new c((-f.y),f.x),(!0)).intersect(new m(l.add(d),new c((-d.y),d.x),(!0)),!0);_&&l.getDistance(_)<=i*n&&a(_)}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(n).transform(r);"square"===e&&(a&&(s(o.subtract(u)),s(o.add(u))),o=o.add(u.rotate(0===h.getTime()?-90: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=L._getStrokePadding(l,u),a=L._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,v=d,p=_,m=0,y=t.length;m_&&(_=A),Mp&&(p=T)}}return new g(d,v,_-d,p-v)}}});L.inject({statics:new function(){function t(t,e,n){var i=r.getNamed(n),s=new L(i&&i.insert===!1&&w.NO_INSERT);return s._add(t),s._closed=e,s.set(i)}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(){return t([new A(c.readNamed(arguments,"from")),new A(c.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var t=c.readNamed(arguments,"center"),n=r.readNamed(arguments,"radius");return e(t,new d(n),arguments)},Rectangle:function(){var e,i=g.readNamed(arguments,"rectangle"),r=d.readNamed(arguments,"radius",0,{readNull:!0}),s=i.getBottomLeft(!0),a=i.getTopLeft(!0),o=i.getTopRight(!0),h=i.getBottomRight(!0);if(!r||r.isZero())e=[new A(s),new A(a),new A(o),new A(h)];else{r=d.min(r,i.getSize(!0).divide(2));var u=r.width,l=r.height,c=u*n,f=l*n;e=[new A(s.add(u,0),null,[-c,0]),new A(s.subtract(0,l),[0,f]),new A(a.add(0,l),null,[0,-f]),new A(a.add(u,0),[-c,0],null),new A(o.subtract(u,0),null,[c,0]),new A(o.add(0,l),[0,-f],null),new A(h.subtract(0,l),null,[0,f]),new A(h.subtract(u,0),[c,0])]}return t(e,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=C._readEllipse(arguments);return e(t.center,t.radius,arguments)},Oval:"#Ellipse",Arc:function(){var t=c.readNamed(arguments,"from"),e=c.readNamed(arguments,"through"),n=c.readNamed(arguments,"to"),i=r.getNamed(arguments),s=new L(i&&i.insert===!1&&w.NO_INSERT);return s.moveTo(t),s.arcTo(e,n),s.set(i)},RegularPolygon:function(){for(var e=c.readNamed(arguments,"center"),n=r.readNamed(arguments,"sides"),i=r.readNamed(arguments,"radius"),s=360/n,a=n%3===0,o=new c(0,a?-i:i),h=a?-1:.5,u=new Array(n),l=0;l=0;s--){var a=n[s];n!==e||a instanceof L||(n=r.slice(n)),Array.isArray(a)?n[s]=new L({segments:a,insert:!1}):a instanceof E&&(n.splice.apply(n,[s,1].concat(a.removeChildren())),a.remove())}return yt.base.call(this,t,n)},reduce:function wt(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 L(w.NO_INSERT);return i.copyAttributes(this),i.insertAbove(this),this.remove(),i}return wt.base.call(this)},isClosed:function(){for(var t=this._children,e=0,n=t.length;e=0;l--){var c=h[l].split();c&&(s(c)&&c.getFirstSegment().setHandleIn(0,0),a.getLastSegment().setHandleOut(0,0))}return s(a),n(x,u,!1,e,i)}function a(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 o(t){for(var e=t.length-1;e>=0;e--)t[e].clearHandles()}function h(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 v(e.getArea())-v(t.getArea())}),o=a[0];null==n&&(n=o.isClockwise());for(var h=0;h