}}),K=s.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onActivate","onDeactivate","onEditOptions","onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onKeyDown","onKeyUp"],initialize:function(t){s.call(this),this._firstMove=!0,this._count=0,this._downCount=0,this._set(t)},getMinDistance:function(){returnthis._minDistance},setMinDistance:function(t){this._minDistance=t,null!=this._minDistance&&null!=this._maxDistance&&this._minDistance>this._maxDistance&&(this._maxDistance=this._minDistance)},getMaxDistance:function(){returnthis._maxDistance},setMaxDistance:function(t){this._maxDistance=t,null!=this._minDistance&&null!=this._maxDistance&&this._maxDistance<this._minDistance&&(this._minDistance=t)},getFixedDistance:function(){returnthis._minDistance==this._maxDistance?this._minDistance:null},setFixedDistance:function(t){this._minDistance=t,this._maxDistance=t},_updateEvent:function(t,e,n,i,r,s,a){if(!r){if(null!=n||null!=i){varo=null!=n?n:0,h=e.subtract(this._point),u=h.getLength();if(o>u)return!1;varl=null!=i?i:0;if(0!=l)if(u>l)e=this._point.add(h.normalize(l));elseif(a)return!1}if(s&&e.equals(this._point))return!1}switch(this._lastPoint=r&&"mousemove"==t?e:this._point,this._point=e,t){case"mousedown":this._lastPoint=this._downPoint,this._downPoint=this._point,this._downCount++;break;case"mouseup":this._lastPoint=this._downPoint}returnthis._count=r?0:this._count+1,!0},_fireEvent:function(t,e){varn=paper.project._removeSets;if(n){"mouseup"===t&&(n.mousedrag=null);vari=n[t];if(i){for(varrini){vars=i[r];for(varainn){varo=n[a];o&&o!=i&&deleteo[s._id]}s.remove()}n[t]=null}}returnthis.responds(t)&&this.emit(t,newY(this,t,e))},_handleEvent:function(t,e,n){paper=this._scope;vari=!1;switch(t){case"mousedown":this._updateEvent(t,e,null,null,!0,!1,!1),i=this._fireEvent(t,n);break;case"mousedrag":for(varr=!1,s=!1;this._updateEvent(t,e,this.minDistance,this.maxDistance,!1,r,s);)i=this._fireEvent(t,n)||i,r=!0,s=!0;break;case"mouseup":!e.equals(this._point)&&this._updateEvent("mousedrag",e,this.minDistance,this.maxDistance,!1,!1,!1)&&(i=this._fireEvent("mousedrag",n)),this._updateEvent(t,e,null,this.maxDistance,!1,!1,!1),i=this._fireEvent(t,n)||i,this._updateEvent(t,e,null,null,!0,!1,!1),this._firstMove=!0;break;case"mousemove":for(;this._updateEvent(t,e,this.minDistance,this.maxDistance,this._firstMove,!0,!1);)i=this._fireEvent(t,n)||i,this._firstMove=!1}returni&&n.preventDefault(),i}}),Q={request:function(t,e,n){vari=new(window.ActiveXObject||XMLHttpRequest)("Microsoft.XMLHTTP");returni.open(t.toUpperCase(),e,!0),"overrideMimeType"ini&&i.overrideMimeType("text/plain"),i.onreadystatechange=function(){if(4===i.readyState){vart=i.status;if(0!==t&&200!==t)throwError("Could not load "+e+" (Error "+t+")");n.call(i,i.responseText)}},i.send(null)}},te={canvases:[],getCanvas:function(t,e){varn,i=!0;"object"==typeoft&&(e=t.height,t=t.width),n=this.canvases.length?this.canvases.pop():document.createElement("canvas");varr=n.getContext("2d");returnn.width===t&&n.height===e?i&&r.clearRect(0,0,t+1,e+1):(n.width=t,n.height=e),r.save(),n},getContext:function(t,e){returnthis.getCanvas(t,e).getContext("2d")},release:function(t){vare=t.canvas?t.canvas:t;e.getContext("2d").restore(),this.canvases.push(e)}},ee=newfunction(){functiont(t,e,n){return.2989*t+.587*e+.114*n}functionn(e,n,i,r){vars=r-t(e,n,i);f=e+s,_=n+s,g=i+s;varr=t(f,_,g),a=p(f,_,g),o=v(f,_,g);if(0>a){varh=r-a;f=r+(f-r)*r/h,_=r+(_-r)*r/h,g=r+(g-r)*r/h}if(o>255){varu=255-r,l=o-r;f=r+(f-r)*u/l,_=r+(_-r)*u/l,g=r+(g-r)*u/l}}functioni(t,e,n){returnv(t,e,n)-p(t,e,n)}functionr(t,e,n,i){varr,s=[t,e,n],a=v(t,e,n),o=p(t,e,n);o=o===t?0:o===e?1:2,a=a===t?0:a===e?1:2,r=0===p(o,a)?1===v(o,a)?2:1:0,s[a]>s[o]?(s[r]=(s[r]-s[o])*i/(s[a]-s[o]),s[a]=i):s[r]=s[a]=0,s[o]=0,f=s[0],_=s[1],g=s[2]}vars,a,o,h,u,l,c,d,f,_,g,p=Math.min,v=Math.max,m=Math.abs,y={multiply:function(){f=u*s/255,_=l*a/255,g=c*o/255},screen:function(){f=u+s-u*s/255,_=l+a-l*a/255,g=c+o-c*o/255},overlay:function(){f=128>u?2*u*s/255:255-2*(255-u)*(255-s)/255,_=128>l?2*l*a/255:255-2*(2
casetn:if(z(),e.block=W(),e.handler=null,be===qe){varl=L();z(),F(pn),l.param=le(),Te&&Zn(l.param.name)&&n(l.param.start,"Binding "+l.param.name+" in strict mode"),F(vn),l.guard=null,l.body=W(),e.handler=N(l,"CatchClause")}returne.guardedHandlers=Le,e.finalizer=B(Ge)?W():null,e.handler||e.finalizer||n(e.start,"Missing catch or finally clause"),N(e,"TryStatement");caseen:returnz(),X(e),R(),N(e,"VariableDeclaration");casenn:returnz(),e.test=H(),Oe.push(ti),e.body=U(),Oe.pop(),N(e,"WhileStatement");casern:returnTe&&n(me,"'with' in strict mode"),z(),e.object=H(),e.body=U(),N(e,"WithStatement");case_n:returnW();caseyn:returnz(),N(e,"EmptyStatement");default:varc=Ce,d=J();if(t===Be&&"Identifier"===d.type&&B(wn)){for(varr=0;r<Oe.length;++r)Oe[r].name===c&&n(d.start,"Label '"+c+"' is already declared");varf=be.isLoop?"loop":be===Ke?"switch":null;returnOe.push({name:c,kind:f}),e.body=U(),Oe.pop(),e.label=d,N(e,"LabeledStatement")}returne.expression=d,R(),N(e,"ExpressionStatement")}}functionH(){F(pn);vart=J();returnF(vn),t}functionW(t){vare,n=L(),i=!0,r=!1;for(n.body=[],F(_n);!B(gn);){vars=U();n.body.push(s),i&&t&&j(s)&&(e=r,A(r=!0)),i=!1}returnr&&!e&&A(!1),N(n,"BlockStatement")}functionG(t,e){returnt.init=e,F(yn),t.test=be===yn?null:J(),F(yn),t.update=be===vn?null:J(),F(vn),t.body=U(),Oe.pop(),N(t,"ForStatement")}function$(t,e){returnt.left=e,t.right=J(),F(vn),t.body=U(),Oe.pop(),N(t,"ForInStatement")}functionX(t,e){for(t.declarations=[],t.kind="var";;){vari=L();if(i.id=le(),Te&&Zn(i.id.name)&&n(i.id.start,"Binding "+i.id.name+" in strict mode"),i.init=B(Sn)?J(!0,e):null,t.declarations.push(N(i,"VariableDeclarator")),!B(mn))break}returnt}functionJ(t,e){varn=Y(e);if(!t&&be===mn){vari=E(n);for(i.expressions=[n];B(mn);)i.expressions.push(Y(e));returnN(i,"SequenceExpression")}returnn}functionY(t){vare=K(t);if(be.isAssign){varn=E(e);returnn.operator=Ce,n.left=e,z(),n.right=Y(t),V(e),N(n,"AssignmentExpression")}returne}functionK(t){vare=Q(t);if(B(bn)){varn=E(e);returnn.test=e,n.consequent=J(!0),F(wn),n.alternate=J(!0,t),N(n,"ConditionalExpression")}returne}functionQ(t){returnte(ee(),-1,t)}functionte(t,e,n){vari=be.binop;if(null!=i&&(!n||be!==ln)&&i>e){varr=E(t);r.left=t,r.operator=Ce,z(),r.right=te(ee(),i,n);vars=N(r,/&&|\|\|/.test(r.operator)?"LogicalExpression":"BinaryExpression");returnte(s,e,n)}returnt}functionee(){if(be.prefix){vart=L(),e=be.isUpdate;returnt.operator=Ce,t.prefix=!0,Se=!0,z(),t.argument=ee(),e?V(t.argument):Te&&"delete"===t.operator&&"Identifier"===t.argument.type&&n(t.start,"Deleting local variable in strict mode"),N(t,e?"UpdateExpression":"UnaryExpression")}for(vari=ne();be.postfix&&!D();){vart=E(i);t.operator=Ce,t.prefix=!1,t.argument=i,V(i),z(),i=N(t,"UpdateExpression")}returni}functionne(){returnie(re())}functionie(t,e){if(B(xn)){varn=E(t);returnn.object=t,n.property=le(!0),n.computed=!1,ie(N(n,"MemberExpression"),e)}if(B(dn)){varn=E(t);returnn.object=t,n.property=J(),n.computed=!0,F(fn),ie(N(n,"MemberExpression"),e)}if(!e&&B(pn)){varn=E(t);returnn.callee=t,n.arguments=ue(vn,!1),ie(N(n,"CallExpression"),e)}returnt}functionre(){switch(be){casean:vart=L();returnz(),N(t,"ThisExpression");caseBe:returnle();caseEe:caseje:caseNe:vart=L();returnt.value=Ce,t.raw=de.slice(me,ye),z(),N(t,"Literal");caseon:casehn:caseun:vart=L();returnt.value=be.atomValue,t.raw=be.keyword,z(),N(t,"Literal");casepn:vare=we,n=me;z();vari=J();returni.start=n,i.end=ye,ce.locations&&(i.loc.start=e,i.loc.end=xe),ce.ranges&&(i.range=[n,ye]),F(vn),i;casedn:vart=L();returnz(),t.elements=ue(fn,!0,!0),N(t,"ArrayExpression");case_n:returnae();caseXe:vart=L();returnz(),he(t,!1);casesn:returnse();default:q()}}functionse(){vart=L();returnz(),t.callee=ie(re(),!0),t.arguments=B(pn)?ue(vn,!1):Le,N(t,"NewExpression")}functionae(){vart=L(),e=!0,i=!1;for(t.properties=[],z();!B(gn);){if(e)e=!1;elseif(F(mn),ce.allowTrailingCommas&&B(gn))break;varr,s={key:oe()},a=!1;if(B(wn)?(s.value=J(!0),r=s.kind="init"):ce.ecmaVersion>=5&&"Identifier"===s.key.type&&("g