try{let Ct=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},kt=new Ct.Error().stack;kt&&(Ct._sentryDebugIds=Ct._sentryDebugIds||{},Ct._sentryDebugIds[kt]="a28a3bbe-652a-41de-8b03-8762780ed294",Ct._sentryDebugIdIdentifier="sentry-dbid-a28a3bbe-652a-41de-8b03-8762780ed294")}catch(Ct){}{let Ct=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};Ct.SENTRY_RELEASE={id:"20.13.2"}}(self.webpackChunk_mb2024_mb_proto=self.webpackChunk_mb2024_mb_proto||[]).push([[214],{68671:(Ct,kt,Et)=>{"use strict";Et.r(kt),Et.d(kt,{paper:()=>Ut.a});var Ht=Et(64458),Ut=Et.n(Ht)},64458:function(Ct,kt,Et){var Ht,Ut;/*! * Paper.js v0.12.18 - The Swiss Army Knife of Vector Graphics Scripting. * http://paperjs.org/ * * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey * http://juerglehni.com/ & https://puckey.studio/ * * Distributed under the MIT license. See LICENSE file for details. * * All rights reserved. * * Date: Wed Jul 17 14:57:24 2024 +0200 * *** * * Straps.js - Class inheritance library with support for bean-style accessors * * Copyright (c) 2006 - 2020 Jürg Lehni * http://juerglehni.com/ * * Distributed under the MIT license. * *** * * Acorn.js * https://marijnhaverbeke.nl/acorn/ * * Acorn is a tiny, fast JavaScript parser written in JavaScript, * created by Marijn Haverbeke and released under an MIT license. * */var Ce=(function(zt,D){zt=zt||Et(2965);var lt=zt.window,vt=zt.document,T=new function(){var t=/^(statics|enumerable|beans|preserve)$/,e=[],i=e.slice,n=Object.create,r=Object.getOwnPropertyDescriptor,s=Object.defineProperty,h=e.forEach||function(c,l){for(var p=0,y=this.length;p0||a+n0?[["dictionary",n.definitions],s]:s},deserialize:function(t,e,i,n,r){var s=t,h=!i,a=h&&t&&t.length&&t[0][0]==="dictionary";if(i=i||{},Array.isArray(t)){var o=t[0],u=o==="dictionary";if(t.length==1&&/^#/.test(o))return i.dictionary[o];o=T.exports[o],s=[];for(var _=o?1:0,d=t.length;_t.length&&(i=t.length);for(var h=0;h0){var s=e[r],h=s&&s[n];h&&h.call(this,r)}}},statics:{inject:function t(e){var i=e._events;if(i){var n={};T.each(i,function(r,s){var h=typeof r=="string",a=h?r:s,o=T.capitalize(a),u=a.substring(2).toLowerCase();n[u]=h?{}:r,a="_"+a,e["get"+o]=function(){return this[a]},e["set"+o]=function(_){var d=this[a];d&&this.off(u,d),_&&this.on(u,_),this[a]=_}}),e._eventTypes=n}return t.base.apply(this,arguments)}}},Rt=T.extend({_class:"PaperScope",initialize:function t(){Q=this,this.settings=new T({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this._id=t._id++,t._scopes[this._id]=this;var e=t.prototype;if(!this.support){var i=ft.getContext(1,1)||{};e.support={nativeDash:"setLineDash"in i||"mozDash"in i,nativeBlendModes:oe.nativeModes},ft.release(i)}if(!this.agent){var n=zt.navigator.userAgent.toLowerCase(),r=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(n)||[])[0],s=r==="darwin"?"mac":r,h=e.agent=e.browser={platform:s};s&&(h[s]=!0),n.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node|jsdom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(a,o,u,_,d){if(!h.chrome){var c=o==="opera"?_:/^(node|trident)$/.test(o)?d:u;h.version=c,h.versionNumber=parseFloat(c),o={trident:"msie",jsdom:"node"}[o]||o,h.name=o,h[o]=!0}}),h.chrome&&delete h.webkit,h.atom&&delete h.chrome}},version:"0.12.18",getView:function(){var t=this.project;return t&&t._view},getPaper:function(){return this},execute:function(t,e){},install:function(t){var e=this;T.each(["project","view","tool"],function(n){T.define(t,n,{configurable:!0,get:function(){return e[n]}})});for(var i in this)!/^_/.test(i)&&this[i]&&(t[i]=this[i])},setup:function(t){return Q=this,this.project=new Qt(t),this},createCanvas:function(t,e){return ft.getCanvas(t,e)},activate:function(){Q=this},clear:function(){for(var t=this.projects,e=this.tools,i=t.length-1;i>=0;i--)t[i].remove();for(var i=e.length-1;i>=0;i--)e[i].remove()},remove:function(){this.clear(),delete Rt._scopes[this._id]},statics:new function(){function t(e){return e+="Attribute",function(i,n){return i[e](n)||i[e]("data-paper-"+n)}}return{_scopes:{},_id:0,get:function(e){return this._scopes[e]||null},getAttribute:t("get"),hasAttribute:t("has")}}}),$t=T.extend(Xt,{initialize:function(t){this._scope=Q,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 this._index==null?!1:(T.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()}}),Yt={findItemBoundsCollisions:function(t,e,i){function n(h){for(var a=new Array(h.length),o=0;o>>1;h[F[q]][V]=a;(r||(w&&k||S&&M)&&O>=z[c]-i&&A<=z[l]+i)&&(w&&k&&x.push(s?I:I-a),S&&M&&v[I].push(g))}}if(w&&(t===e&&x.push(m),v[m]=x),C.length){var E=f[d],N=u(C,d,E);C.splice(N+1,0,m)}else C.push(m)}for(var y=0;yl?l:d}function u(d,c,l){function p(b){var P=b*134217729,I=b-P,O=I+P,A=b-O;return[O,A]}var y=c*c-d*l,C=c*c+d*l;if(i(y)*31e8)?r(2,-Math.round(s(d))):0}return{EPSILON:h,MACHINE_EPSILON:a,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,ANGULAR_EPSILON:1e-5,KAPPA:4*(n(2)-1)/3,isZero:function(d){return d>=-h&&d<=h},isMachineZero:function(d){return d>=-a&&d<=a},clamp:o,integrate:function(d,c,l,p){for(var y=t[p-2],C=e[p-2],v=(l-c)*.5,m=v+c,f=0,g=p+1>>1,w=p&1?C[f++]*d(m):0;f0?(y=l,l=w<=p?(p+y)*.5:w):(p=l,l=w>=y?(p+y)*.5:w)}return o(l,p,y)},solveQuadratic:function(d,c,l,p,y,C){var v,m=1/0;if(i(d)=-a){var w=f<0?0:n(f),S=c+(c<0?-w:w);S===0?(v=l/d,m=-v):(v=S/d,m=l/S)}}var x=0,b=y==null,P=y-h,I=C+h;return isFinite(v)&&(b||v>P&&vP&&m0?1.324717957244746*Math.max(I,n(A)):I,M=f-O*z;if(M!==f){do b(M),M=S===0?f:f-x/S/(1+a);while(O*M>O*f);i(d)*f*f>i(p/f)&&(w=-p/f,g=(w-l)/f)}}var k=et.solveQuadratic(d,g,w,y,C,v),E=C==null;return isFinite(f)&&(k===0||k>0&&f!==y[0]&&f!==y[1])&&(E||f>C-h&&f1?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),s=0)}return r&&(this.__read=s),this},set:"#initialize",_set:function(t,e){return this.x=t,this.y=e,this},equals:function(t){return this===t||t&&(this.x===t.x&&this.y===t.y||Array.isArray(t)&&this.x===t[0]&&this.y===t[1])||!1},clone:function(){return new L(this.x,this.y)},toString:function(){var t=bt.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 i=t/this.getLength();et.isZero(i)&&this.getAngle(),this._set(this.x*i,this.y*i)}},getAngle:function(){return this.getAngleInRadians.apply(this,arguments)*180/Math.PI},setAngle:function(t){this.setAngleInRadians.call(this,t*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var t=L.read(arguments),e=this.getLength()*t.getLength();if(et.isZero(e))return NaN;var i=this.dot(t)/e;return Math.acos(i<-1?-1:i>1?1:i)}else 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=L.read(arguments);return Math.atan2(this.cross(t),this.dot(t))*180/Math.PI},getDistance:function(){var t=arguments,e=L.read(t),i=e.x-this.x,n=e.y-this.y,r=i*i+n*n,s=T.read(t);return s?r:Math.sqrt(r)},normalize:function(t){t===D&&(t=1);var e=this.getLength(),i=e!==0?t/e:0,n=new L(this.x*i,this.y*i);return i>=0&&(n._angle=this._angle),n},rotate:function(t,e){if(t===0)return this.clone();t=t*Math.PI/180;var i=e?this.subtract(e):this,n=Math.sin(t),r=Math.cos(t);return i=new L(i.x*r-i.y*n,i.x*n+i.y*r),e?i.add(e):i},transform:function(t){return t?t._transformPoint(this):this},add:function(){var t=L.read(arguments);return new L(this.x+t.x,this.y+t.y)},subtract:function(){var t=L.read(arguments);return new L(this.x-t.x,this.y-t.y)},multiply:function(){var t=L.read(arguments);return new L(this.x*t.x,this.y*t.y)},divide:function(){var t=L.read(arguments);return new L(this.x/t.x,this.y/t.y)},modulo:function(){var t=L.read(arguments);return new L(this.x%t.x,this.y%t.y)},negate:function(){return new L(-this.x,-this.y)},isInside:function(){return K.read(arguments).contains(this)},isClose:function(){var t=arguments,e=L.read(t),i=T.read(t);return this.getDistance(e)<=i},isCollinear:function(){var t=L.read(arguments);return L.isCollinear(this.x,this.y,t.x,t.y)},isColinear:"#isCollinear",isOrthogonal:function(){var t=L.read(arguments);return L.isOrthogonal(this.x,this.y,t.x,t.y)},isZero:function(){var t=et.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=L.read(arguments);return this.x*t.x+this.y*t.y},cross:function(){var t=L.read(arguments);return this.x*t.y-this.y*t.x},project:function(){var t=L.read(arguments),e=t.isZero()?0:this.dot(t)/t.dot(t);return new L(t.x*e,t.y*e)},statics:{min:function(){var t=arguments,e=L.read(t),i=L.read(t);return new L(Math.min(e.x,i.x),Math.min(e.y,i.y))},max:function(){var t=arguments,e=L.read(t),i=L.read(t);return new L(Math.max(e.x,i.x),Math.max(e.y,i.y))},random:function(){return new L(Math.random(),Math.random())},isCollinear:function(t,e,i,n){return Math.abs(t*n-e*i)<=Math.sqrt((t*t+e*e)*(i*i+n*n))*1e-8},isOrthogonal:function(t,e,i,n){return Math.abs(t*i+e*n)<=Math.sqrt((t*t+e*e)*(i*i+n*n))*1e-8}}},T.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new L(e(this.x),e(this.y))}},{})),Nt=L.extend({initialize:function(e,i,n,r){this._x=e,this._y=i,this._owner=n,this._setter=r},_set:function(t,e,i){return this._x=t,this._y=e,i||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 this._setter==="setPosition"?4:0}}),Z=T.extend({_class:"Size",_readIndex:!0,initialize:function(e,i){var n=typeof e,r=this.__read,s=0;if(n==="number"){var h=typeof i=="number";this._set(e,h?i:e),r&&(s=h?2:1)}else if(n==="undefined"||e===null)this._set(0,0),r&&(s=e===null?1:0);else{var a=n==="string"?e.split(/[\s,]+/)||[]:e;s=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),s=0)}return r&&(this.__read=s),this},set:"#initialize",_set:function(t,e){return this.width=t,this.height=e,this},equals:function(t){return t===this||t&&(this.width===t.width&&this.height===t.height||Array.isArray(t)&&this.width===t[0]&&this.height===t[1])||!1},clone:function(){return new Z(this.width,this.height)},toString:function(){var t=bt.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=Z.read(arguments);return new Z(this.width+t.width,this.height+t.height)},subtract:function(){var t=Z.read(arguments);return new Z(this.width-t.width,this.height-t.height)},multiply:function(){var t=Z.read(arguments);return new Z(this.width*t.width,this.height*t.height)},divide:function(){var t=Z.read(arguments);return new Z(this.width/t.width,this.height/t.height)},modulo:function(){var t=Z.read(arguments);return new Z(this.width%t.width,this.height%t.height)},negate:function(){return new Z(-this.width,-this.height)},isZero:function(){var t=et.isZero;return t(this.width)&&t(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(t,e){return new Z(Math.min(t.width,e.width),Math.min(t.height,e.height))},max:function(t,e){return new Z(Math.max(t.width,e.width),Math.max(t.height,e.height))},random:function(){return new Z(Math.random(),Math.random())}}},T.each(["round","ceil","floor","abs"],function(t){var e=Math[t];this[t]=function(){return new Z(e(this.width),e(this.height))}},{})),Wt=Z.extend({initialize:function(e,i,n,r){this._width=e,this._height=i,this._owner=n,this._setter=r},_set:function(t,e,i){return this._width=t,this._height=e,i||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)}}),K=T.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(e,i,n,r){var s=arguments,h=typeof e,a;if(h==="number"?(this._set(e,i,n,r),a=4):h==="undefined"||e===null?(this._set(0,0,0,0),a=e===null?1:0):s.length===1&&(Array.isArray(e)?(this._set.apply(this,e),a=1):e.x!==D||e.width!==D?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),a=1):e.from===D&&e.to===D&&(this._set(0,0,0,0),T.readSupported(s,this)&&(a=1))),a===D){var o=L.readNamed(s,"from"),u=T.peek(s),_=o.x,d=o.y,c,l;if(u&&u.x!==D||T.hasNamed(s,"to")){var p=L.readNamed(s,"to");c=p.x-_,l=p.y-d,c<0&&(_=p.x,c=-c),l<0&&(d=p.y,l=-l)}else{var y=Z.read(s);c=y.width,l=y.height}this._set(_,d,c,l),a=s.__index}var C=s.__filtered;return C&&(this.__filtered=C),this.__read&&(this.__read=a),this},set:"#initialize",_set:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},clone:function(){return new K(this.x,this.y,this.width,this.height)},equals:function(t){var e=T.isPlainValue(t)?K.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=bt.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?L:Nt;return new e(this.x,this.y,this,"setPoint")},setPoint:function(){var t=L.read(arguments);this.x=t.x,this.y=t.y},getSize:function(t){var e=t?Z:Wt;return new e(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var t=Z.read(arguments),e=this._sx,i=this._sy,n=t.width,r=t.height;e&&(this.x+=(this.width-n)*e),i&&(this.y+=(this.height-r)*i),this.width=n,this.height=r,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(t){if(!this._fw){var e=t-this.x;this.width-=this._sx===.5?e*2:e}this.x=t,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(t){if(!this._fh){var e=t-this.y;this.height-=this._sy===.5?e*2:e}this.y=t,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(t){if(!this._fw){var e=t-this.x;this.width=this._sx===.5?e*2:e}this.x=t-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(t){if(!this._fh){var e=t-this.y;this.height=this._sy===.5?e*2:e}this.y=t-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(t){this._fw||this._sx===.5?this.x=t-this.width/2:(this._sx&&(this.x+=(t-this.x)*2*this._sx),this.width=(t-this.x)*2),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(t){this._fh||this._sy===.5?this.y=t-this.height/2:(this._sy&&(this.y+=(t-this.y)*2*this._sy),this.height=(t-this.y)*2),this._sy=.5,this._fh=0},getCenter:function(t){var e=t?L:Nt;return new e(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var t=L.read(arguments);return this.setCenterX(t.x),this.setCenterY(t.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return this.width===0||this.height===0},contains:function(t){return t&&t.width!==D||(Array.isArray(t)?t:arguments).length===4?this._containsRectangle(K.read(arguments)):this._containsPoint(L.read(arguments))},_containsPoint:function(t){var e=t.x,i=t.y;return e>=this.x&&i>=this.y&&e<=this.x+this.width&&i<=this.y+this.height},_containsRectangle:function(t){var e=t.x,i=t.y;return e>=this.x&&i>=this.y&&e+t.width<=this.x+this.width&&i+t.height<=this.y+this.height},intersects:function(){var t=K.read(arguments),e=T.read(arguments)||0;return t.x+t.width>this.x-e&&t.y+t.height>this.y-e&&t.x=4&&(t[1]+=n?"Y":"X");var r=t[n?0:1],s=t[n?1:0],h="get"+r,a="get"+s,o="set"+r,u="set"+s,_="get"+i,d="set"+i;this[_]=function(c){var l=c?L:Nt;return new l(this[h](),this[a](),this,d)},this[d]=function(){var c=L.read(arguments);this[o](c.x),this[u](c.y)}},{beans:!0})),ce=K.extend({initialize:function(e,i,n,r,s,h){this._set(e,i,n,r,!0),this._owner=s,this._setter=h},_set:function(t,e,i,n,r){return this._x=t,this._y=e,this._width=i,this._height=n,r||this._owner[this._setter](this),this}},new function(){var t=K.prototype;return T.each(["x","y","width","height"],function(e){var i=T.capitalize(e),n="_"+e;this["get"+i]=function(){return this[n]},this["set"+i]=function(r){this[n]=r,this._dontNotify||this._owner[this._setter](this)}},T.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(e){var i="set"+e;this[i]=function(){this._dontNotify=!0,t[i].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(this._owner._selection&2)},setSelected:function(e){var i=this._owner;i._changeSelection&&i._changeSelection(2,e)}}))}),st=T.extend({_class:"Matrix",initialize:function t(e,i){var n=arguments,r=n.length,s=!0;if(r>=6?this._set.apply(this,n):r===1||r===2?e instanceof t?this._set(e._a,e._b,e._c,e._d,e._tx,e._ty,i):Array.isArray(e)?this._set.apply(this,i?e.concat([i]):e):s=!1:r?s=!1:this.reset(),!s)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(t,e,i,n,r,s,h){return this._a=t,this._b=e,this._c=i,this._d=n,this._tx=r,this._ty=s,h||this._changed(),this},_serialize:function(t,e){return T.serialize(this.getValues(),t,!0,e)},_changed:function(){var t=this._owner;t&&(t._applyMatrix?t.transform(null,!0):t._changed(25))},clone:function(){return new st(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=bt.instance;return"[["+[t.number(this._a),t.number(this._c),t.number(this._tx)].join(", ")+"], ["+[t.number(this._b),t.number(this._d),t.number(this._ty)].join(", ")+"]]"},reset:function(t){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,t||this._changed(),this},apply:function(t,e){var i=this._owner;return i?(i.transform(null,T.pick(t,!0),e),this.isIdentity()):!1},translate:function(){var t=L.read(arguments),e=t.x,i=t.y;return this._tx+=e*this._a+i*this._c,this._ty+=e*this._b+i*this._d,this._changed(),this},scale:function(){var t=arguments,e=L.read(t),i=L.read(t,0,{readNull:!0});return i&&this.translate(i),this._a*=e.x,this._b*=e.x,this._c*=e.y,this._d*=e.y,i&&this.translate(i.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=L.read(arguments,1),i=e.x,n=e.y,r=Math.cos(t),s=Math.sin(t),h=i-i*r+n*s,a=n-i*s-n*r,o=this._a,u=this._b,_=this._c,d=this._d;return this._a=r*o+s*_,this._b=r*u+s*d,this._c=-s*o+r*_,this._d=-s*u+r*d,this._tx+=h*o+a*_,this._ty+=h*u+a*d,this._changed(),this},shear:function(){var t=arguments,e=L.read(t),i=L.read(t,0,{readNull:!0});i&&this.translate(i);var n=this._a,r=this._b;return this._a+=e.y*this._c,this._b+=e.y*this._d,this._c+=e.x*n,this._d+=e.x*r,i&&this.translate(i.negate()),this._changed(),this},skew:function(){var t=arguments,e=L.read(t),i=L.read(t,0,{readNull:!0}),n=Math.PI/180,r=new L(Math.tan(e.x*n),Math.tan(e.y*n));return this.shear(r,i)},append:function(t,e){if(t){var i=this._a,n=this._b,r=this._c,s=this._d,h=t._a,a=t._c,o=t._b,u=t._d,_=t._tx,d=t._ty;this._a=h*i+o*r,this._c=a*i+u*r,this._b=h*n+o*s,this._d=a*n+u*s,this._tx+=_*i+d*r,this._ty+=_*n+d*s,e||this._changed()}return this},prepend:function(t,e){if(t){var i=this._a,n=this._b,r=this._c,s=this._d,h=this._tx,a=this._ty,o=t._a,u=t._c,_=t._b,d=t._d,c=t._tx,l=t._ty;this._a=o*i+u*n,this._c=o*r+u*s,this._b=_*i+d*n,this._d=_*r+d*s,this._tx=o*h+u*a+c,this._ty=_*h+d*a+l,e||this._changed()}return this},appended:function(t){return this.clone().append(t)},prepended:function(t){return this.clone().prepend(t)},invert:function(){var t=this._a,e=this._b,i=this._c,n=this._d,r=this._tx,s=this._ty,h=t*n-e*i,a=null;return h&&!isNaN(h)&&isFinite(r)&&isFinite(s)&&(this._a=n/h,this._b=-e/h,this._c=-i/h,this._d=t/h,this._tx=(i*s-n*r)/h,this._ty=(e*r-t*s)/h,a=this),a},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new st(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return this._a===1&&this._b===0&&this._c===0&&this._d===1&&this._tx===0&&this._ty===0},isInvertible:function(){var t=this._a*this._d-this._c*this._b;return t&&!isNaN(t)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(t,e,i){return arguments.length<3?this._transformPoint(L.read(arguments)):this._transformCoordinates(t,e,i)},_transformPoint:function(t,e,i){var n=t.x,r=t.y;return e||(e=new L),e._set(n*this._a+r*this._c+this._tx,n*this._b+r*this._d+this._ty,i)},_transformCoordinates:function(t,e,i){for(var n=0,r=2*i;ns[o]&&(s[o]=a)}return e||(e=new K),e._set(r[0],r[1],s[0]-r[0],s[1]-r[1],i)},inverseTransform:function(){return this._inverseTransform(L.read(arguments))},_inverseTransform:function(t,e,i){var n=this._a,r=this._b,s=this._c,h=this._d,a=this._tx,o=this._ty,u=n*h-r*s,_=null;if(u&&!isNaN(u)&&isFinite(a)&&isFinite(o)){var d=t.x-this._tx,c=t.y-this._ty;e||(e=new L),_=e._set((d*h-c*s)/u,(c*n-d*r)/u,i)}return _},decompose:function(){var t=this._a,e=this._b,i=this._c,n=this._d,r=t*n-e*i,s=Math.sqrt,h=Math.atan2,a=180/Math.PI,o,u,_;if(t!==0||e!==0){var d=s(t*t+e*e);o=Math.acos(t/d)*(e>0?1:-1),u=[d,r/d],_=[h(t*i+e*n,d*d),0]}else if(i!==0||n!==0){var c=s(i*i+n*n);o=Math.asin(i/c)*(n>0?1:-1),u=[r/c,c],_=[0,h(t*i+e*n,c*c)]}else o=0,_=u=[0,0];return{translation:this.getTranslation(),rotation:o*a,scaling:new L(u),skewing:new L(_[0]*a,_[1]*a)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new L(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)}},T.each(["a","b","c","d","tx","ty"],function(t){var e=T.capitalize(t),i="_"+t;this["get"+e]=function(){return this[i]},this["set"+e]=function(n){this[i]=n,this._changed()}},{})),pt=T.extend({_class:"Line",initialize:function(e,i,n,r,s){var h=!1;arguments.length>=4?(this._px=e,this._py=i,this._vx=n,this._vy=r,h=s):(this._px=e.x,this._py=e.y,this._vx=i.x,this._vy=i.y,h=n),h||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new L(this._px,this._py)},getVector:function(){return new L(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(t,e){return pt.intersect(this._px,this._py,this._vx,this._vy,t._px,t._py,t._vx,t._vy,!0,e)},getSide:function(t,e){return pt.getSide(this._px,this._py,this._vx,this._vy,t.x,t.y,!0,e)},getDistance:function(t){return Math.abs(this.getSignedDistance(t))},getSignedDistance:function(t){return pt.getSignedDistance(this._px,this._py,this._vx,this._vy,t.x,t.y,!0)},isCollinear:function(t){return L.isCollinear(this._vx,this._vy,t._vx,t._vy)},isOrthogonal:function(t){return L.isOrthogonal(this._vx,this._vy,t._vx,t._vy)},statics:{intersect:function(t,e,i,n,r,s,h,a,o,u){o||(i-=t,n-=e,h-=r,a-=s);var _=i*a-n*h;if(!et.isMachineZero(_)){var d=t-r,c=e-s,l=(h*c-a*d)/_,p=(i*c-n*d)/_,y=1e-12,C=-y,v=1+y;if(u||C=1?1:l),new L(t+l*i,e+l*n)}},getSide:function(t,e,i,n,r,s,h,a){h||(i-=t,n-=e);var o=r-t,u=s-e,_=o*n-u*i;return!a&&et.isMachineZero(_)&&(_=(o*i+o*i)/(i*i+n*n),_>=0&&_<=1&&(_=0)),_<0?-1:_>0?1:0},getSignedDistance:function(t,e,i,n,r,s,h){return h||(i-=t,n-=e),i===0?n>0?r-t:t-r:n===0?i<0?s-e:e-s:((r-t)*n-(s-e)*i)/(n>i?n*Math.sqrt(1+i*i/(n*n)):i*Math.sqrt(1+n*n/(i*i)))},getDistance:function(t,e,i,n,r,s,h){return Math.abs(pt.getSignedDistance(t,e,i,n,r,s,h))}}}),Qt=$t.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(e){$t.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new he(null,null,this),this._view=ot.create(this,e||ft.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(t,e){return T.serialize(this._children,t,!0,e)},_changed:function(t,e){if(t&1){var i=this._view;i&&(i._needsUpdate=!0,!i._requested&&i._autoUpdate&&i.requestUpdate())}var n=this._changes;if(n&&e){var r=this._changesById,s=e._id,h=r[s];h?h.flags|=t:n.push(r[s]={item:e,flags:t})}},clear:function(){for(var t=this._children,e=t.length-1;e>=0;e--)t[e].remove()},isEmpty:function(){return!this._children.length},remove:function t(){return t.base.call(this)?(this._view&&this._view.remove(),!0):!1},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 Gt({project:this,insert:!0})},getSymbolDefinitions:function(){var t=[],e={};return this.getItems({class:re,match:function(i){var n=i._definition,r=n._id;return e[r]||(e[r]=!0,t.push(n)),!1}}),t},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var t=this._selectionItems,e=[];for(var i in t){var n=t[i],r=n._selection;r&1&&n.isInserted()?e.push(n):r||this._updateSelection(n)}return e},_updateSelection:function(t){var e=t._id,i=this._selectionItems;t._selection?i[e]!==t&&(this._selectionCount++,i[e]=t):i[e]===t&&(this._selectionCount--,delete i[e])},selectAll:function(){for(var t=this._children,e=0,i=t.length;e0){t.save(),t.strokeWidth=1;var a=this._selectionItems,o=this._scope.settings.handleSize,u=this._updateVersion;for(var _ in a)a[_]._drawSelection(t,e,o,a,u);t.restore()}}}),X=T.extend(Xt,{statics:{extend:function t(e){return e._serializeFields&&(e._serializeFields=T.set({},this.prototype._serializeFields,e._serializeFields)),t.base.apply(this,arguments)},INSERT:{insert:!0},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 st,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 T.each(t,function(e){this._events[e]={install:function(i){this.getView()._countItemEvent(i,1)},uninstall:function(i){this.getView()._countItemEvent(i,-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,e){var i=t&&T.isPlainObject(t),n=i&&t.internal===!0,r=this._matrix=new st,s=i&&t.project||Q.project,h=Q.settings;return this._id=n?null:jt.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&h.applyMatrix,e&&r.translate(e),r._owner=this,this._style=new he(s._currentStyle,this,s),n||i&&t.insert==!1||!h.insertItems&&!(i&&t.insert==!0)?this._setProject(s):(i&&t.parent||s)._insertItem(D,this,!0),i&&t!==X.NO_INSERT&&t!==X.INSERT&&this.set(t,{internal:!0,insert:!0,project:!0,parent:!0}),i},_serialize:function(t,e){var i={},n=this;function r(s){for(var h in s){var a=n[h];T.equals(a,h==="leading"?s.fontSize*1.2:s[h])||(i[h]=T.serialize(a,t,h!=="data",e))}}return r(this._serializeFields),this instanceof At||r(this._style._defaults),[this._class,i]},_changed:function(t){var e=this._symbol,i=this._parent||e,n=this._project;t&8&&(this._bounds=this._position=this._decomposed=D),t&16&&(this._globalMatrix=D),i&&t&72&&X._clearBoundsCache(i),t&2&&X._clearBoundsCache(this),n&&n._changed(t,this),e&&e._changed(t)},getId:function(){return this._id},getName:function(){return this._name},setName:function(t){if(this._name&&this._removeNamed(),t===+t+"")throw new Error("Names consisting only of numbers are not supported.");var e=this._getOwner();if(t&&e){var i=e._children,n=e._namedChildren;(n[t]=n[t]||[]).push(this),t in i||(i[t]=this)}this._name=t||D,this._changed(256)},getStyle:function(){return this._style},setStyle:function(t){this.getStyle().set(t)}},T.each(["locked","visible","blendMode","opacity","guide"],function(t){var e=T.capitalize(t),i="_"+t,n={locked:256,visible:265};this["get"+e]=function(){return this[i]},this["set"+e]=function(r){r!=this[i]&&(this[i]=r,this._changed(n[t]||257))}},{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(t){if(t!==this._selection){this._selection=t;var e=this._project;e&&(e._updateSelection(this),this._changed(257))}},_changeSelection:function(t,e){var i=this._selection;this.setSelection(e?i|t:i&~t)},isSelected:function(){if(this._selectChildren){for(var t=this._children,e=0,i=t.length;e=0;i--)if(e[i].contains(t))return!0;return!1}return t.isInside(this.getInternalBounds())},isInside:function(){return K.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new nt.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(t,e){return t instanceof X?this._asPathItem().getIntersections(t._asPathItem(),null,e,!0).length>0:!1}},new function(){function t(){var n=arguments;return this._hitTest(L.read(n),Lt.getOptions(n))}function e(){var n=arguments,r=L.read(n),s=Lt.getOptions(n),h=[];return this._hitTest(r,new T({all:h},s)),h}function i(n,r,s,h){var a=this._children;if(a)for(var o=a.length-1;o>=0;o--){var u=a[o],_=u!==h&&u._hitTest(n,r,s);if(_&&!r.all)return _}return null}return Qt.inject({hitTest:t,hitTestAll:e,_hitTest:i}),{hitTest:t,hitTestAll:e,_hitTestChildren:i}},{_hitTest:function(t,e,i){if(this._locked||!this._visible||this._guide&&!e.guides||this.isEmpty())return null;var n=this._matrix,r=i?i.appended(n):this.getGlobalMatrix().prepend(this.getView()._matrix),s=Math.max(e.tolerance,1e-12),h=e._tolerancePadding=new Z(nt._getStrokePadding(s,n._shiftless().invert()));if(t=n._inverseTransform(t),!t||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(h.multiply(2))._containsPoint(t))return null;var a=!(e.guides&&!this._guide||e.selected&&!this.isSelected()||e.type&&e.type!==T.hyphenate(this._class)||e.class&&!(this instanceof e.class)),o=e.match,u=this,_,d;function c(f){return f&&o&&!o(f)&&(f=null),f&&e.all&&e.all.push(f),f}function l(f,g){var w=g?_["get"+g]():u.getPosition();if(t.subtract(w).divide(h).length<=1)return new Lt(f,u,{name:g?T.hyphenate(g):f,point:w})}var p=e.position,y=e.center,C=e.bounds;if(a&&this._parent&&(p||y||C)){if((y||C)&&(_=this.getInternalBounds()),d=p&&l("position")||y&&l("center","Center"),!d&&C)for(var v=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],m=0;m<8&&!d;m++)d=l("bounds",v[m]);d=c(d)}return d||(d=this._hitTestChildren(t,e,r)||a&&c(this._hitTestSelf(t,e,r,this.getStrokeScaling()?null:r._shiftless().invert()))||null),d&&d.point&&(d.point=n.transform(d.point)),d},_hitTestSelf:function(t,e){if(e.fill&&this.hasFill()&&this._contains(t))return new Lt("fill",this)},matches:function(t,e){function i(h,a){for(var o in h)if(h.hasOwnProperty(o)){var u=h[o],_=a[o];if(T.isPlainObject(u)&&T.isPlainObject(_)){if(!i(u,_))return!1}else if(!T.equals(u,_))return!1}return!0}var n=typeof t;if(n==="object"){for(var r in t)if(t.hasOwnProperty(r)&&!this.matches(r,t[r]))return!1;return!0}else{if(n==="function")return t(this);if(t==="match")return e(this);var s=/^(empty|editable)$/.test(t)?this["is"+T.capitalize(t)]():t==="type"?T.hyphenate(this._class):this[t];if(t==="class"){if(typeof e=="function")return this instanceof e;s=this._class}if(typeof e=="function")return!!e(s);if(e){if(e.test)return e.test(s);if(T.isPlainObject(e))return i(e,s)}return T.equals(s,e)}},getItems:function(t){return X._getItems(this,t,this._matrix)},getItem:function(t){return X._getItems(this,t,this._matrix,null,!0)[0]||null},statics:{_getItems:function t(e,i,n,r,s){if(!r){var h=typeof i=="object"&&i,a=h&&h.overlapping,o=h&&h.inside,u=a||o,c=u&&K.read([u]);r={items:[],recursive:h&&h.recursive!==!1,inside:!!o,overlapping:!!a,rect:c,path:a&&new nt.Rectangle({rectangle:c,insert:!1})},h&&(i=T.filter({},i,{recursive:!0,inside:!0,overlapping:!0}))}var _=e._children,d=r.items,c=r.rect;n=c&&(n||new st);for(var l=0,p=_&&_.length;l0))break}return d}}},{importJSON:function(t){var e=T.importJSON(t,this);return e!==this?this.addChild(e):e},addChild:function(t){return this.insertChild(D,t)},insertChild:function(t,e){var i=e?this.insertChildren(t,[e]):null;return i&&i[0]},addChildren:function(t){return this.insertChildren(this._children.length,t)},insertChildren:function(t,e){var i=this._children;if(i&&e&&e.length>0){e=T.slice(e);for(var n={},r=e.length-1;r>=0;r--){var s=e[r],h=s&&s._id;!s||n[h]?e.splice(r,1):(s._remove(!1,!0),n[h]=!0)}T.splice(i,e,t,0);for(var a=this._project,o=a._changes,r=0,u=e.length;r=0;n--)i[n]._remove(!0,!1);return i.length>0&&this._changed(11),i},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var t=0,e=this._children.length;t0},isInserted:function(){return this._parent?this._parent.isInserted():!1},isAbove:function(t){return this._getOrder(t)===-1},isBelow:function(t){return this._getOrder(t)===1},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):!1},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}},T.each(["rotate","scale","shear","skew"],function(t){var e=t==="rotate";this[t]=function(){var i=arguments,n=(e?T:L).read(i),r=L.read(i,0,{readNull:!0});return this.transform(new st()[t](n,r||this.getPosition(!0)))}},{translate:function(){var t=new st;return this.transform(t.translate.apply(t,arguments))},transform:function(t,e,i){var n=this._matrix,r=t&&!t.isIdentity(),s=i&&this._canApplyMatrix||this._applyMatrix&&(r||!n.isIdentity()||e&&this._children);if(!r&&!s)return this;if(r){!t.isInvertible()&&n.isInvertible()&&(n._backup=n.getValues()),n.prepend(t,!0);var h=this._style,a=h.getFillColor(!0),o=h.getStrokeColor(!0);a&&a.transform(t),o&&o.transform(t)}if(s&&(s=this._transformContent(n,e,i))){var u=this._pivot;u&&n._transformPoint(u,u,!0),n.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var _=this._bounds,d=this._position;(r||s)&&this._changed(25);var c=r&&_&&t.decompose();if(c&&c.skewing.isZero()&&c.rotation%90===0){for(var l in _){var p=_[l];if(p.nonscaling)delete _[l];else if(s||!p.internal){var y=p.rect;t._transformBounds(y,y)}}this._bounds=_;var C=_[this._getBoundsCacheKey(this._boundsOptions||{})];C&&(this._position=this._getPositionFromBounds(C.rect))}else r&&d&&this._pivot&&(this._position=t._transformPoint(d,d));return this},_transformContent:function(t,e,i){var n=this._children;if(n){for(var r=0,s=n.length;rr:n1&&a<4?-1:1,a>2?-1:1),u=o.multiply(h),_=u.subtract(o.multiply(s)),d=new K(r?u.add(o.multiply(r)):u,_);if(d.contains(n))return{point:_,quadrant:a}}}function e(i,n,r,s){var h=i.divide(n);return(!s||h.isInQuadrant(s))&&h.subtract(h.normalize()).multiply(n).divide(r).length<=1}return{_contains:function i(n){if(this._type==="rectangle"){var r=t(this,n);return r?n.subtract(r.point).divide(this._radius).getLength()<=1:i.base.call(this,n)}else return n.divide(this.size).getLength()<=.5},_hitTestSelf:function i(n,r,s,h){var a=!1,o=this._style,u=r.stroke&&o.hasStroke(),_=r.fill&&o.hasFill();if(u||_){var d=this._type,c=this._radius,l=u?o.getStrokeWidth()/2:0,p=r._tolerancePadding.add(nt._getStrokePadding(l,!o.getStrokeScaling()&&h));if(d==="rectangle"){var y=p.multiply(2),C=t(this,n,y);if(C)a=e(n.subtract(C.point),c,p,C.quadrant);else{var v=new K(this._size).setCenter(0,0),m=v.expand(y),f=v.expand(y.negate());a=m._containsPoint(n)&&!f._containsPoint(n)}}else a=e(n,c,p)}return a?new Lt(u?"stroke":"fill",this):i.base.apply(this,arguments)}}},{statics:new function(){function t(e,i,n,r,s){var h=T.create(xt.prototype);return h._type=e,h._size=n,h._radius=r,h._initialize(T.getNamed(s),i),h}return{Circle:function(){var e=arguments,i=L.readNamed(e,"center"),n=T.readNamed(e,"radius");return t("circle",i,new Z(n*2),n,e)},Rectangle:function(){var e=arguments,i=K.readNamed(e,"rectangle"),n=Z.min(Z.readNamed(e,"radius"),i.getSize(!0).divide(2));return t("rectangle",i.getCenter(!0),i.getSize(!0),n,e)},Ellipse:function(){var e=arguments,i=xt._readEllipse(e),n=i.radius;return t("ellipse",i.center,n.multiply(2),n,e)},_readEllipse:function(e){var i,n;if(T.hasNamed(e,"radius"))i=L.readNamed(e,"center"),n=Z.readNamed(e,"radius");else{var r=K.readNamed(e,"rectangle");i=r.getCenter(!0),n=r.getSize(!0).divide(2)}return{center:i,radius:n}}}}}),Kt=X.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:"low",beans:!0,initialize:function(e,i){if(!this._initialize(e,i!==D&&L.read(arguments))){var n,r=typeof e,s=r==="string"?vt.getElementById(e):r==="object"?e:null;if(s&&s!==X.NO_INSERT){if(s.getContext||s.naturalHeight!=null)n=s;else if(s){var h=Z.read(arguments);h.isZero()||(n=ft.getCanvas(h))}}n?this.setImage(n):this.setSource(e)}this._size||(this._size=new Z,this._loaded=!1)},_equals:function(t){return this.getSource()===t.getSource()},copyContent:function(t){var e=t._image,i=t._canvas;if(e)this._setImage(e);else if(i){var n=ft.getCanvas(t._size);n.getContext("2d").drawImage(i,0,0),this._setImage(n)}this._crossOrigin=t._crossOrigin},getSize:function(){var t=this._size;return new Wt(t?t.width:0,t?t.height:0,this,"setSize")},setSize:function(t,e){var i=Z.read(arguments);if(i.equals(this._size))e&&this.clear();else if(i.width>0&&i.height>0){var n=!e&&this.getElement();this._setImage(ft.getCanvas(i)),n&&this.getContext(!0).drawImage(n,0,0,i.width,i.height)}else this._canvas&&ft.release(this._canvas),this._size=i.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||t.width===0&&t.height===0},getResolution:function(){var t=this._matrix,e=new L(0,0).transform(t),i=new L(1,0).transform(t).subtract(e),n=new L(0,1).transform(t).subtract(e);return new Z(72/i.getLength(),72/n.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(t){var e=this;function i(n){var r=e.getView(),s=n&&n.type||"load";r&&e.responds(s)&&(Q=r._scope,e.emit(s,new ie(n)))}this._setImage(t),this._loaded?setTimeout(i,0):t&&_t.add(t,{load:function(n){e._setImage(t),i(n)},error:i})},_setImage:function(t){this._canvas&&ft.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 Z(t?t.naturalWidth||t.width:0,t?t.naturalHeight||t.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var t=ft.getContext(this._size);try{this._image&&t.drawImage(this._image,0,0),this._canvas=t.canvas}catch(e){ft.release(t)}}return this._canvas},setCanvas:"#setImage",getContext:function(t){return this._context||(this._context=this.getCanvas().getContext("2d")),t&&(this._image=null,this._changed(1025)),this._context},setContext:function(t){this._context=t},getSource:function(){var t=this._image;return t&&t.src||this.toDataURL()},setSource:function(t){var e=new zt.Image,i=this._crossOrigin;i&&(e.crossOrigin=i),t&&(e.src=t),this.setImage(e)},getCrossOrigin:function(){var t=this._image;return t&&t.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(t){this._crossOrigin=t;var e=this._image;e&&(e.crossOrigin=t)},getSmoothing:function(){return this._smoothing},setSmoothing:function(t){this._smoothing=typeof t=="string"?t:t?"low":"off",this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var t=K.read(arguments),e=ft.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=K.read(arguments),e=new Kt(X.NO_INSERT);return e._setImage(this.getSubCanvas(t)),e.translate(t.getCenter().subtract(this.getSize().divide(2))),e._matrix.prepend(this._matrix),e.insertAbove(this),e},toDataURL:function(){var t=this._image,e=t&&t.src;if(/^data:/.test(e))return e;var i=this.getCanvas();return i?i.toDataURL.apply(i,arguments):null},drawImage:function(t){var e=L.read(arguments,1);this.getContext(!0).drawImage(t,e.x,e.y)},getAverageColor:function(t){var e,i;if(t?t instanceof Zt?(i=t,e=t.getBounds()):typeof t=="object"&&("width"in t?e=new K(t):"x"in t&&(e=new K(t.x-.5,t.y-.5,1,1))):e=this.getBounds(),!e)return null;var n=32,r=Math.min(e.width,n),s=Math.min(e.height,n),h=Kt._sampleContext;h?h.clearRect(0,0,n+1,n+1):h=Kt._sampleContext=ft.getContext(new Z(n)),h.save();var a=new st().scale(r/e.width,s/e.height).translate(-e.x,-e.y);a.applyToContext(h),i&&i.draw(h,new T({clip:!0,matrices:[a]})),this._matrix.applyToContext(h);var o=this.getElement(),u=this._size;o&&h.drawImage(o,-u.width/2,-u.height/2),h.restore();for(var _=h.getImageData(.5,.5,Math.ceil(r),Math.ceil(s)).data,d=[0,0,0],c=0,l=0,p=_.length;l0&&n.height>0){t.globalAlpha=et.clamp(this._opacity,0,1),this._setStyles(t,e,i);var r=this._smoothing,s=r==="off";ht.setPrefixed(t,s?"imageSmoothingEnabled":"imageSmoothingQuality",s?!1:r),t.drawImage(n,-this._size.width/2,-this._size.height/2)}},_canComposite:function(){return!0}}),re=X.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(e,i){this._initialize(e,i!==D&&L.read(arguments,1))||this.setDefinition(e instanceof Bt?e:new Bt(e))},_equals:function(t){return this._definition===t._definition},copyContent:function(t){this.setDefinition(t._definition)},getDefinition:function(){return this._definition},setDefinition:function(t){this._definition=t,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(t,e){var i=this._definition._item;return i._getCachedBounds(i._matrix.prepended(t),e)},_hitTestSelf:function(t,e,i){var n=e.extend({all:!1}),r=this._definition._item._hitTest(t,n,i);return r&&(r.item=this),r},_draw:function(t,e){this._definition._item.draw(t,e)}}),Bt=T.extend({_class:"SymbolDefinition",initialize:function(e,i){this._id=jt.get(),this.project=Q.project,e&&this.setItem(e,i)},_serialize:function(t,e){return e.add(this,function(){return T.serialize([this._class,this._item],t,!1,e)})},_changed:function(t){t&8&&X._clearBoundsCache(this),t&1&&this.project._changed(t)},getItem:function(){return this._item},setItem:function(t,e){t._symbol&&(t=t.clone()),this._item&&(this._item._symbol=null),this._item=t,t.remove(),t.setSelected(!1),e||t.setPosition(new L),t._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(t){return new re(this,t)},clone:function(){return new Bt(this._item.clone(!1))},equals:function(t){return t===this||t&&this._item.equals(t._item)||!1}}),Lt=T.extend({_class:"HitResult",initialize:function(e,i,n){this.type=e,this.item=i,n&&this.inject(n)},statics:{getOptions:function(t){var e=t&&T.read(t);return new T({type:null,tolerance:Q.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),G=T.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(e,i,n,r,s,h){var a=arguments.length,o,u,_,d;a>0&&(e==null||typeof e=="object"?a===1&&e&&"point"in e?(o=e.point,u=e.handleIn,_=e.handleOut,d=e.selection):(o=e,u=i,_=n,d=r):(o=[e,i],u=n!==D?[n,r]:null,_=s!==D?[s,h]:null)),new se(o,this,"_point"),new se(u,this,"_handleIn"),new se(_,this,"_handleOut"),d&&this.setSelection(d)},_serialize:function(t,e){var i=this._point,n=this._selection,r=n||this.hasHandles()?[i,this._handleIn,this._handleOut]:i;return n&&r.push(n),T.serialize(r,t,!0,e)},_changed:function(t){var e=this._path;if(e){var i=e._curves,n=this._index,r;i&&((!t||t===this._point||t===this._handleIn)&&(r=n>0?i[n-1]:e._closed?i[i.length-1]:null)&&r._changed(),(!t||t===this._point||t===this._handleOut)&&(r=i[n])&&r._changed()),e._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(L.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(L.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(L.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var t=this._handleIn,e=this._handleOut;return!t.isZero()&&!e.isZero()&&t.isCollinear(e)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(t){var e=this._selection,i=this._path;this._selection=t=t||0,i&&t!==e&&(i._updateSelection(this,e,t),i._changed(257))},_changeSelection:function(t,e){var i=this._selection;this.setSelection(e?i|t:i&~t)},isSelected:function(){return!!(this._selection&7)},setSelected:function(t){this._changeSelection(7,t)},getIndex:function(){return this._index!==D?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 Tt(t,this===t._segment1?0:1):null},getNext:function(){var t=this._path&&this._path._segments;return t&&(t[this._index+1]||this._path._closed&&t[0])||null},smooth:function(t,e,i){var n=t||{},r=n.type,s=n.factor,h=this.getPrevious(),a=this.getNext(),o=(h||this)._point,u=this._point,_=(a||this)._point,d=o.getDistance(u),c=u.getDistance(_);if(!r||r==="catmull-rom"){var l=s===D?.5:s,p=Math.pow(d,l),y=p*p,C=Math.pow(c,l),v=C*C;if(!e&&h){var m=2*v+3*C*p+y,f=3*C*(C+p);this.setHandleIn(f!==0?new L((v*o._x+m*u._x-y*_._x)/f-u._x,(v*o._y+m*u._y-y*_._y)/f-u._y):new L)}if(!i&&a){var m=2*y+3*p*C+v,f=3*p*(p+C);this.setHandleOut(f!==0?new L((y*_._x+m*u._x-v*o._x)/f-u._x,(y*_._y+m*u._y-v*o._y)/f-u._y):new L)}}else if(r==="geometric"){if(h&&a){var g=o.subtract(_),w=s===D?.4:s,S=w*d/(d+c);e||this.setHandleIn(g.multiply(S)),i||this.setHandleOut(g.multiply(S-w))}}else throw new Error("Smoothing method '"+r+"' not supported.")},getPrevious:function(){var t=this._path&&this._path._segments;return t&&(t[this._index-1]||this._path._closed&&t[t.length-1])||null},isFirst:function(){return!this._index},isLast:function(){var t=this._path;return t&&this._index===t._segments.length-1||!1},reverse:function(){var t=this._handleIn,e=this._handleOut,i=t.clone();t.set(e),e.set(i)},reversed:function(){return new G(this._point,this._handleOut,this._handleIn)},remove:function(){return this._path?!!this._path.removeSegment(this._index):!1},clone:function(){return new G(this._point,this._handleIn,this._handleOut)},equals:function(t){return t===this||t&&this._class===t._class&&this._point.equals(t._point)&&this._handleIn.equals(t._handleIn)&&this._handleOut.equals(t._handleOut)||!1},toString:function(){var t=["point: "+this._point];return this._handleIn.isZero()||t.push("handleIn: "+this._handleIn),this._handleOut.isZero()||t.push("handleOut: "+this._handleOut),"{ "+t.join(", ")+" }"},transform:function(t){this._transformCoordinates(t,new Array(6),!0),this._changed()},interpolate:function(t,e,i){var n=1-i,r=i,s=t._point,h=e._point,a=t._handleIn,o=e._handleIn,u=e._handleOut,_=t._handleOut;this._point._set(n*s._x+r*h._x,n*s._y+r*h._y,!0),this._handleIn._set(n*a._x+r*o._x,n*a._y+r*o._y,!0),this._handleOut._set(n*_._x+r*u._x,n*_._y+r*u._y,!0),this._changed()},_transformCoordinates:function(t,e,i){var n=this._point,r=!i||!this._handleIn.isZero()?this._handleIn:null,s=!i||!this._handleOut.isZero()?this._handleOut:null,h=n._x,a=n._y,o=2;return e[0]=h,e[1]=a,r&&(e[o++]=r._x+h,e[o++]=r._y+a),s&&(e[o++]=s._x+h,e[o++]=s._y+a),t&&(t._transformCoordinates(e,e,o/2),h=e[0],a=e[1],i?(n._x=h,n._y=a,o=2,r&&(r._x=e[o++]-h,r._y=e[o++]-a),s&&(s._x=e[o++]-h,s._y=e[o++]-a)):(r||(e[o++]=h,e[o++]=a),s||(e[o++]=h,e[o++]=a))),e}}),se=L.extend({initialize:function(e,i,n){var r,s,h;if(!e)r=s=0;else if((r=e[0])!==D)s=e[1];else{var a=e;(r=a.x)===D&&(a=L.read(arguments),r=a.x),s=a.y,h=a.selected}this._x=r,this._y=s,this._owner=i,i[n]=this,h&&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=et.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}}),R=T.extend({_class:"Curve",beans:!0,initialize:function(e,i,n,r,s,h,a,o){var u=arguments.length,_,d,c,l,p,y;u===3?(this._path=e,_=i,d=n):u?u===1?"segment1"in e?(_=new G(e.segment1),d=new G(e.segment2)):"point1"in e?(c=e.point1,p=e.handle1,y=e.handle2,l=e.point2):Array.isArray(e)&&(c=[e[0],e[1]],l=[e[6],e[7]],p=[e[2]-e[0],e[3]-e[1]],y=[e[4]-e[6],e[5]-e[7]]):u===2?(_=new G(e),d=new G(i)):u===4?(c=e,p=i,y=n,l=r):u===8&&(c=[e,i],l=[a,o],p=[n-e,r-i],y=[s-a,h-o]):(_=new G,d=new G),this._segment1=_||new G(c,null,p),this._segment2=d||new G(l,y,null)},_serialize:function(t,e){return T.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],t,!0,e)},_changed:function(){this._length=this._bounds=D},clone:function(){return new R(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 R.classify(this.getValues())},remove:function(){var t=!1;if(this._path){var e=this._segment2,i=e._handleOut;t=e.remove(),t&&this._segment1._handleOut.set(i)}return t},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(L.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(L.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(L.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(L.read(arguments))},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPath:function(){return this._path},getIndex:function(){return this._segment1._index},getNext:function(){var t=this._path&&this._path._curves;return t&&(t[this._segment1._index+1]||this._path._closed&&t[0])||null},getPrevious:function(){var t=this._path&&this._path._curves;return t&&(t[this._segment1._index-1]||this._path._closed&&t[t.length-1])||null},isFirst:function(){return!this._segment1._index},isLast:function(){var t=this._path;return t&&this._segment1._index===t._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle1().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(t){this.getPoint1().setSelected(t),this.getHandle1().setSelected(t),this.getHandle2().setSelected(t),this.getPoint2().setSelected(t)},getValues:function(t){return R.getValues(this._segment1,this._segment2,t)},getPoints:function(){for(var t=this.getValues(),e=[],i=0;i<8;i+=2)e.push(new L(t[i],t[i+1]));return e}},{getLength:function(){return this._length==null&&(this._length=R.getLength(this.getValues(),0,1)),this._length},getArea:function(){return R.getArea(this.getValues())},getLine:function(){return new pt(this._segment1._point,this._segment2._point)},getPart:function(t,e){return new R(R.getPart(this.getValues(),t,e))},getPartLength:function(t,e){return R.getLength(this.getValues(),t,e)},divideAt:function(t){return this.divideAtTime(t&&t.curve===this?t.time:this.getTimeAt(t))},divideAtTime:function(t,e){var i=1e-8,n=1-i,r=null;if(t>=i&&t<=n){var s=R.subdivide(this.getValues(),t),h=s[0],a=s[1],o=e||this.hasHandles(),u=this._segment1,_=this._segment2,d=this._path;o&&(u._handleOut._set(h[2]-h[0],h[3]-h[1]),_._handleIn._set(a[4]-a[6],a[5]-a[7]));var c=h[6],l=h[7],p=new G(new L(c,l),o&&new L(h[4]-c,h[5]-l),o&&new L(a[2]-c,a[3]-l));d?(d.insert(u._index+1,p),r=this.getNext()):(this._segment2=p,this._changed(),r=new R(p,_))}return r},splitAt:function(t){var e=this._path;return e?e.splitAt(t):null},splitAtTime:function(t){return this.splitAt(this.getLocationAtTime(t))},divide:function(t,e){return this.divideAtTime(t===D?.5:e?t:this.getTimeAt(t))},split:function(t,e){return this.splitAtTime(t===D?.5:e?t:this.getTimeAt(t))},reversed:function(){return new R(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut._set(0,0),this._segment2._handleIn._set(0,0)},statics:{getValues:function(t,e,i,n){var r=t._point,s=t._handleOut,h=e._handleIn,a=e._point,o=r.x,u=r.y,_=a.x,d=a.y,c=n?[o,u,o,u,_,d,_,d]:[o,u,o+s._x,u+s._y,_+h._x,d+h._y,_,d];return i&&i._transformCoordinates(c,c,4),c},subdivide:function(t,e){var i=t[0],n=t[1],r=t[2],s=t[3],h=t[4],a=t[5],o=t[6],u=t[7];e===D&&(e=.5);var _=1-e,d=_*i+e*r,c=_*n+e*s,l=_*r+e*h,p=_*s+e*a,y=_*h+e*o,C=_*a+e*u,v=_*d+e*l,m=_*c+e*p,f=_*l+e*y,g=_*p+e*C,w=_*v+e*f,S=_*m+e*g;return[[i,n,d,c,v,m,w,S],[w,S,f,g,y,C,o,u]]},getMonoCurves:function(t,e){var i=[],n=e?0:1,r=t[n+0],s=t[n+2],h=t[n+4],a=t[n+6];if(r>=s==s>=h&&s>=h==h>=a||R.isStraight(t))i.push(t);else{var o=3*(s-h)-r+a,u=2*(r+h)-4*s,_=s-r,d=1e-8,c=1-d,l=[],p=et.solveQuadratic(o,u,_,l,d,c);if(!p)i.push(t);else{l.sort();var y=l[0],C=R.subdivide(t,y);i.push(C[0]),p>1&&(y=(l[1]-y)/(1-y),C=R.subdivide(C[1],y),i.push(C[0])),i.push(C[1])}}return i},solveCubic:function(t,e,i,n,r,s){var h=t[e],a=t[e+2],o=t[e+4],u=t[e+6],_=0;if(!(hi&&u>i&&a>i&&o>i)){var d=3*(a-h),c=3*(o-a)-d,l=u-h-d-c;_=et.solveCubic(l,c,d,h-i,n,r,s)}return _},getTimeOf:function(t,e){var i=new L(t[0],t[1]),n=new L(t[6],t[7]),r=1e-12,s=1e-7,h=e.isClose(i,r)?0:e.isClose(n,r)?1:null;if(h===null)for(var a=[e.x,e.y],o=[],u=0;u<2;u++)for(var _=R.solveCubic(t,u,a[u],o,0,1),d=0;d<_;d++){var c=o[d];if(e.isClose(R.getPoint(t,c),s))return c}return e.isClose(i,s)?0:e.isClose(n,s)?1:null},getNearestTime:function(t,e){if(R.isStraight(t)){var i=t[0],n=t[1],r=t[6],s=t[7],h=r-i,a=s-n,o=h*h+a*a;if(o===0)return 0;var u=((e.x-i)*h+(e.y-n)*a)/o;return u<1e-12?0:u>.999999999999?1:R.getTimeOf(t,new L(i+u*h,n+u*a))}var _=100,d=1/0,c=0;function l(C){if(C>=0&&C<=1){var v=e.getDistance(R.getPoint(t,C),!0);if(v1e-8;)!l(c-y)&&!l(c+y)&&(y/=2);return c},getPart:function(t,e,i){var n=e>i;if(n){var r=e;e=i,i=r}return e>0&&(t=R.subdivide(t,e)[1]),i<1&&(t=R.subdivide(t,(i-e)/(1-e))[0]),n?[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]]:t},isFlatEnough:function(t,e){var i=t[0],n=t[1],r=t[2],s=t[3],h=t[4],a=t[5],o=t[6],u=t[7],_=3*r-2*i-o,d=3*s-2*n-u,c=3*h-2*o-i,l=3*a-2*u-n;return Math.max(_*_,c*c)+Math.max(d*d,l*l)<=16*e*e},getArea:function(t){var e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],h=t[5],a=t[6],o=t[7];return 3*((o-i)*(n+s)-(a-e)*(r+h)+r*(e-s)-n*(i-h)+o*(s+e/3)-a*(h+i/3))/20},getBounds:function(t){for(var e=t.slice(0,2),i=e.slice(),n=[0,0],r=0;r<2;r++)R._addBounds(t[r],t[r+2],t[r+4],t[r+6],r,0,e,i,n);return new K(e[0],e[1],i[0]-e[0],i[1]-e[1])},_addBounds:function(t,e,i,n,r,s,h,a,o){function u(w,S){var x=w-S,b=w+S;xa[r]&&(a[r]=b)}s/=2;var _=h[r]+s,d=a[r]-s;if(t<_||e<_||i<_||n<_||t>d||e>d||i>d||n>d)if(e=0&&o<=1&&u<=0&&u>=-1}}return!1},isLinear:function(t,e,i,n){var r=n.subtract(t).divide(3);return e.equals(r)&&i.negate().equals(r)}},function(t,e){this[e]=function(i){var n=this._segment1,r=this._segment2;return t(n._point,n._handleOut,r._handleIn,r._point,i)},this.statics[e]=function(i,n){var r=i[0],s=i[1],h=i[6],a=i[7];return t(new L(r,s),new L(i[2]-r,i[3]-s),new L(i[4]-h,i[5]-a),new L(h,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 t!=null&&t>=0&&t<=1?new Tt(this,t):null},getTimeAt:function(t,e){return R.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var t=L.read(arguments);return t.isZero()?[]:R.getTimesWithTangent(this.getValues(),t)},getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(L.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return R.getTimeOf(this.getValues(),L.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=L.read(arguments),e=this.getValues(),i=R.getNearestTime(e,t),n=R.getPoint(e,i);return new Tt(this,i,n,null,t.getDistance(n))},getNearestPoint:function(){var t=this.getNearestLocation.apply(this,arguments);return t&&t.getPoint()}},new function(){var t=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return T.each(t,function(e){this[e+"At"]=function(i,n){var r=this.getValues();return R[e](r,n?i:R.getTimeAt(r,i))},this[e+"AtTime"]=function(i){return R[e](this.getValues(),i)}},{statics:{_evaluateMethods:t}})},new function(){function t(n){var r=n[0],s=n[1],h=n[2],a=n[3],o=n[4],u=n[5],_=n[6],d=n[7],c=9*(h-o)+3*(_-r),l=6*(r+o)-12*h,p=3*(h-r),y=9*(a-u)+3*(d-s),C=6*(s+u)-12*a,v=3*(a-s);return function(m){var f=(c*m+l)*m+p,g=(y*m+C)*m+v;return Math.sqrt(f*f+g*g)}}function e(n,r){return Math.max(2,Math.min(16,Math.ceil(Math.abs(r-n)*32)))}function i(n,r,s,h){if(r==null||r<0||r>1)return null;var a=n[0],o=n[1],u=n[2],_=n[3],d=n[4],c=n[5],l=n[6],p=n[7],y=et.isZero;y(u-a)&&y(_-o)&&(u=a,_=o),y(d-l)&&y(c-p)&&(d=l,c=p);var C=3*(u-a),v=3*(d-u)-C,m=l-a-C-v,f=3*(_-o),g=3*(c-_)-f,w=p-o-f-g,S,x;if(s===0)S=r===0?a:r===1?l:((m*r+v)*r+C)*r+a,x=r===0?o:r===1?p:((w*r+g)*r+f)*r+o;else{var b=1e-8,P=1-b;if(rP?(S=3*(l-d),x=3*(p-c)):(S=(3*m*r+2*v)*r+C,x=(3*w*r+2*g)*r+f),h){S===0&&x===0&&(rP)&&(S=d-u,x=c-_);var I=Math.sqrt(S*S+x*x);I&&(S/=I,x/=I)}if(s===3){var d=6*m*r+2*v,c=6*w*r+2*g,O=Math.pow(S*S+x*x,3/2);S=O!==0?(S*c-x*d)/O:0,x=0}}return s===2?new L(x,-S):new L(S,x)}return{statics:{classify:function(n){var r=n[0],s=n[1],h=n[2],a=n[3],o=n[4],u=n[5],_=n[6],d=n[7],c=r*(d-u)+s*(o-_)+_*u-d*o,l=h*(s-d)+a*(_-r)+r*d-s*_,p=o*(a-s)+u*(r-h)+h*s-a*r,y=3*p,C=y-l,v=C-l+c,m=Math.sqrt(v*v+C*C+y*y),f=m!==0?1/m:0,g=et.isZero,w="serpentine";v*=f,C*=f,y*=f;function S(I,O,A){var z=O!==D,M=z&&O>0&&O<1,k=z&&A>0&&A<1;return z&&(!(M||k)||I==="loop"&&!(M&&k))&&(I="arch",M=k=!1),{type:I,roots:M||k?M&&k?O0?Math.sqrt(x/3):Math.sqrt(-x),P=2*v;return S(x>0?w:"loop",(C+b)/P,(C-b)/P)},getLength:function(n,r,s,h){if(r===D&&(r=0),s===D&&(s=1),R.isStraight(n)){var a=n;s<1&&(a=R.subdivide(a,s)[0],r/=s),r>0&&(a=R.subdivide(a,r)[1]);var o=a[6]-a[0],u=a[7]-a[1];return Math.sqrt(o*o+u*u)}return et.integrate(h||t(n),r,s,e(r,s))},getTimeAt:function(n,r,s){if(s===D&&(s=r<0?1:0),r===0)return s;var h=Math.abs,a=1e-12,o=r>0,u=o?s:0,_=o?1:s,d=t(n),c=R.getLength(n,u,_,d),l=h(r)-c;if(h(l)a)return null;var p=r/c,y=0;function C(v){return y+=et.integrate(d,s,v,e(s,v)),s=v,y-r}return et.findRoot(C,d,s+p,u,_,32,1e-12)},getPoint:function(n,r){return i(n,r,0,!1)},getTangent:function(n,r){return i(n,r,1,!0)},getWeightedTangent:function(n,r){return i(n,r,1,!1)},getNormal:function(n,r){return i(n,r,2,!0)},getWeightedNormal:function(n,r){return i(n,r,2,!1)},getCurvature:function(n,r){return i(n,r,3,!1).x},getPeaks:function(n){var r=n[0],s=n[1],h=n[2],a=n[3],o=n[4],u=n[5],_=n[6],d=n[7],c=-r+3*h-3*o+_,l=3*r-6*h+3*o,p=-3*r+3*h,y=-s+3*a-3*u+d,C=3*s-6*a+3*u,v=-3*s+3*a,m=1e-8,f=1-m,g=[];return et.solveCubic(9*(c*c+y*y),9*(c*l+C*y),2*(l*l+C*C)+3*(p*c+v*y),p*l+C*v,g,m,f),g.sort()}}}},new function(){function t(l,p,y,C,v,m,f){var g=!f&&y.getPrevious()===v,w=!f&&y!==v&&y.getNext()===v,S=1e-8,x=1-S;if(C!==null&&C>=(g?S:0)&&C<=(w?x:1)&&m!==null&&m>=(w?S:0)&&m<=(g?x:1)){var b=new Tt(y,C,null,f),P=new Tt(v,m,null,f);b._intersection=P,P._intersection=b,(!p||p(b))&&Tt.insert(l,b,!0)}}function e(l,p,y,C,v,m,f,g,w,S,x,b,P){if(++w>=4096||++g>=40)return w;var I=1e-9,O=p[0],A=p[1],z=p[6],M=p[7],k=pt.getSignedDistance,E=k(O,A,z,M,p[2],p[3]),N=k(O,A,z,M,p[4],p[5]),B=E*N>0?3/4:4/9,F=B*Math.min(0,E,N),V=B*Math.max(0,E,N),W=k(O,A,z,M,l[0],l[1]),H=k(O,A,z,M,l[2],l[3]),J=k(O,A,z,M,l[4],l[5]),q=k(O,A,z,M,l[6],l[7]),$=i(W,H,J,q),U=$[0],rt=$[1],Y,tt;if(E===0&&N===0&&W===0&&H===0&&J===0&&q===0||(Y=n(U,rt,F,V))==null||(tt=n(U.reverse(),rt.reverse(),F,V))==null)return w;var it=S+(x-S)*Y,j=S+(x-S)*tt;if(Math.max(P-b,j-it).8)if(j-it>St){var dt=R.subdivide(l,.5),mt=(it+j)/2;w=e(p,dt[0],C,y,v,m,!f,g,w,b,P,it,mt),w=e(p,dt[1],C,y,v,m,!f,g,w,b,P,mt,j)}else{var dt=R.subdivide(p,.5),wt=(b+P)/2;w=e(dt[0],l,C,y,v,m,!f,g,w,b,wt,it,j),w=e(dt[1],l,C,y,v,m,!f,g,w,wt,P,it,j)}else St===0||St>=I?w=e(p,l,C,y,v,m,!f,g,w,b,P,it,j):w=e(l,p,y,C,v,m,f,g,w,it,j,b,P)}return w}function i(l,p,y,C){var v=[0,l],m=[1/3,p],f=[2/3,y],g=[1,C],w=p-(2*l+C)/3,S=y-(l+2*C)/3,x;if(w*S<0)x=[[v,m,g],[v,f,g]];else{var b=w/S;x=[b>=2?[v,m,g]:b<=.5?[v,f,g]:[v,m,f,g],[v,g]]}return(w||S)<0?x.reverse():x}function n(l,p,y,C){return l[0][1]C?r(p,!1,C):l[0][0]}function r(l,p,y){for(var C=l[0][0],v=l[0][1],m=1,f=l.length;m=y:w<=y)return w===y?g:C+(y-v)*(g-C)/(w-v);C=g,v=w}return null}function s(l,p,y,C,v){var m=et.isZero;if(m(C)&&m(v)){var f=R.getTimeOf(l,new L(p,y));return f===null?[]:[f]}for(var g=Math.atan2(-v,C),w=Math.sin(g),S=Math.cos(g),x=[],b=[],P=0;P<8;P+=2){var I=l[P]-p,O=l[P+1]-y;x.push(I*S-O*w,I*w+O*S)}return R.solveCubic(x,1,0,b,0,1),b}function h(l,p,y,C,v,m,f){for(var g=p[0],w=p[1],S=p[6],x=p[7],b=s(l,g,w,S-g,x-w),P=0,I=b.length;Pg(p[0],p[2],p[4],p[6])&&g(l[0],l[2],l[4],l[6])-fg(p[1],p[3],p[5],p[7])&&g(l[1],l[3],l[5],l[7])-f>1,k=x&1,E=M*6,N=k*6,B=new L(l[E],l[E+1]),F=new L(p[N],p[N+1]);B.isClose(F,f)&&t(v,m,y,M,C,k)}}}return v}function u(l,p,y,C){var v=R.classify(l);if(v.type==="loop"){var m=v.roots;t(y,C,p,m[0],p,m[1])}return y}function _(l,p,y,C,v,m){var f=1e-7,g=!p;g&&(p=l);for(var w=l.length,S=p.length,x=new Array(w),b=g?x:new Array(S),P=[],I=0;IA){var B=p[N],F=b[N];o(M,F,z,B,P,y)}}}return P}function d(l,p){function y(q){var $=q[6]-q[0],U=q[7]-q[1];return $*$+U*U}var C=Math.abs,v=pt.getDistance,m=1e-8,f=1e-7,g=R.isStraight(l),w=R.isStraight(p),S=g&&w,x=y(l)>1,V=R.getTimeOf(M[N],new L(M[B][F?6:0],M[B][F?7:1]));if(V!=null){var W=N?[F,V]:[V,F];(!k.length||C(W[0]-k[0][0])>m&&C(W[1]-k[0][1])>m)&&k.push(W)}if(E>2&&!k.length)break}if(k.length!==2)k=null;else if(!S){var H=R.getPart(l,k[0][0],k[1][0]),J=R.getPart(p,k[0][1],k[1][1]);(C(J[2]-H[2])>f||C(J[3]-H[3])>f||C(J[4]-H[4])>f||C(J[5]-H[5])>f)&&(k=null)}return k}function c(l,p){var y=l[0],C=l[1],v=l[2],m=l[3],f=l[4],g=l[5],w=l[6],S=l[7],x=p.normalize(),b=x.x,P=x.y,I=3*w-9*f+9*v-3*y,O=3*S-9*g+9*m-3*C,A=6*f-12*v+6*y,z=6*g-12*m+6*C,M=3*v-3*y,k=3*m-3*C,E=2*I*P-2*O*b,N=[];if(Math.abs(E)=0&&F<=1&&N.push(F)}}else{var V=(A*A-4*I*M)*P*P+(-2*A*z+4*O*M+4*I*k)*b*P+(z*z-4*O*k)*b*b,W=A*P-z*b;if(V>=0&&E!=0){var H=Math.sqrt(V),J=-(W+H)/E,q=(-W+H)/E;J>=0&&J<=1&&N.push(J),q>=0&&q<=1&&N.push(q)}}return N}return{getIntersections:function(l){var p=this.getValues(),y=l&&l!==this&&l.getValues();return y?o(p,y,this,l,[]):u(p,this,[])},statics:{getOverlaps:d,getIntersections:_,getCurveLineIntersections:s,getTimesWithTangent:c}}}),Tt=T.extend({_class:"CurveLocation",initialize:function(e,i,n,r,s){if(i>=.99999999){var h=e.getNext();h&&(i=0,e=h)}this._setCurve(e),this._time=i,this._point=n||e.getPointAtTime(i),this._overlap=r,this._distance=s,this._intersection=this._next=this._previous=null},_setPath:function(t){this._path=t,this._version=t?t._version:0},_setCurve:function(t){this._setPath(t._path),this._curve=t,this._segment=null,this._segment1=t._segment1,this._segment2=t._segment2},_setSegment:function(t){var e=t.getCurve();e?this._setCurve(e):(this._setPath(t._path),this._segment1=t,this._segment2=null),this._segment=t,this._time=t===this._segment1?0:1,this._point=t._point.clone()},getSegment:function(){var t=this._segment;if(!t){var e=this.getCurve(),i=this.getTime();i===0?t=e._segment1:i===1?t=e._segment2:i!=null&&(t=e.getPartLength(0,i)=n&&e<=r,h=i>=n&&i<=r;if(s&&h)return!this.isTouching();var a=this.getCurve(),o=a&&er&&(a=a.getNext()),i>r&&(u=u.getNext()),!o||!a||!_||!u)return!1;var d=[];function c(b,P){var I=b.getValues(),O=R.classify(I).roots||R.getPeaks(I),A=O.length,z=R.getLength(I,P&&A?O[A-1]:0,!P&&A?O[0]:1);d.push(A?z:z/32)}function l(b,P,I){return PP&&bP||b=-1&&C<=r;C+=y){var v=e[(C%r+r)%r];if(!i.getPoint().isClose(v.getPoint(),1e-7))break;if(i.equals(v))return v}return null}for(;s<=h;){var o=s+h>>>1,u=e[o],_;if(n&&(_=i.equals(u)?u:a(o,-1)||a(o,1)))return i._overlap&&(_._overlap=_._intersection._overlap=!0),_;var d=i.getPath(),c=u.getPath(),l=d!==c?d._id-c._id:i.getIndex()+i.getTime()-(u.getIndex()+u.getTime());l<0?h=o-1:s=o+1}return e.splice(s,0,i),i}return{statics:{insert:t,expand:function(e){for(var i=e.slice(),n=e.length-1;n>=0;n--)t(i,e[n]._intersection,!1);return i}}}}),Zt=X.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(t){var e,i,n;if(T.isPlainObject(t)?(i=t.segments,e=t.pathData):Array.isArray(t)?i=t:typeof t=="string"&&(e=t),i){var r=i[0];n=r&&Array.isArray(r[0])}else e&&(n=(e.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(e));var s=n?Mt:nt;return new s(t)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(t){this.isClockwise()!=(t=!!t)&&this.reverse()},setPathData:function(t){var e=t&&t.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/ig),i,n=!1,r,s,h=new L,a=new L;function o(f,g){var w=+i[f];return n&&(w+=h[g]),w}function u(f){return new L(o(f,"x"),o(f+1,"y"))}this.clear();for(var _=0,d=e&&e.length;_u&&this[n?"removeSegments":"removeChildren"](u,o);for(var d=0;d=0&&e;u--){var _=i[u];e=!1;var d=o[u];if(d)for(var c=d.length-1;c>=0&&!e;c--)_.compare(n[d[c]])&&(h[d[c]]||(h[d[c]]=!0,a++),e=!0)}e=e&&a===s}return e}}),nt=Zt.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(e){this._closed=!1,this._segments=[],this._version=0;var i=arguments,n=Array.isArray(e)?typeof e[0]=="object"?e:i:e&&e.size===D&&(e.x!==D||e.point!==D)?i:null;n&&n.length>0?this.setSegments(n):(this._curves=D,this._segmentSelection=0,!n&&typeof e=="string"&&(this.setPathData(e),e=null)),this._initialize(!n&&e)},_equals:function(t){return this._closed===t._closed&&T.equals(this._segments,t._segments)},copyContent:function(t){this.setSegments(t._segments),this._closed=t._closed},_changed:function t(e){if(t.base.call(this,e),e&8){if(this._length=this._area=D,e&32)this._version++;else if(this._curves)for(var i=0,n=this._curves.length;i0&&(C(i[0],!0),y.push("z")),y.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(t){for(var e=this._segments,i=new Array(6),n=0,r=e.length;n0&&h+r-1===_?h-1:h,c=d,l=Math.min(d+r,_);t._curves&&(n.splice.apply(n,[d,0].concat(t._curves)),c+=t._curves.length);for(var a=c;a0?t-1:t},add:function(t){var e=arguments;return e.length>1&&typeof t!="number"?this._add(G.readList(e)):this._add([G.read(e)])[0]},insert:function(t,e){var i=arguments;return i.length>2&&typeof e!="number"?this._add(G.readList(i,1),t):this._add([G.read(i,1)],t)[0]},addSegment:function(){return this._add([G.read(arguments)])[0]},insertSegment:function(t){return this._add([G.read(arguments,1)],t)[0]},addSegments:function(t){return this._add(G.readList(t))},insertSegments:function(t,e){return this._add(G.readList(e),t)},removeSegment:function(t){return this.removeSegments(t,t+1)[0]||null},removeSegments:function(t,e,i){t=t||0,e=T.pick(e,this._segments.length);var n=this._segments,r=this._curves,s=n.length,h=n.splice(t,e-t),a=h.length;if(!a)return h;for(var o=0;o0&&e===s+(this._closed?1:0)?t-1:t,r=r.splice(d,a),o=r.length-1;o>=0;o--)r[o]._path=null;i&&(h._curves=r.slice(1)),this._adjustCurves(d,d)}return this._changed(41),h},clear:"#removeSegments",hasHandles:function(){for(var t=this._segments,e=0,i=t.length;e0&&this._segmentSelection===t*7},setFullySelected:function(t){t&&this._selectSegments(!0),this.setSelected(t)},setSelection:function t(e){e&1||this._selectSegments(!1),t.base.call(this,e)},_selectSegments:function(t){var e=this._segments,i=e.length,n=t?7:0;this._segmentSelection=n*i;for(var r=0;r0&&this.setSelected(!0)},divideAt:function(t){var e=this.getLocationAt(t),i;return e&&(i=e.getCurve().divideAt(e.getCurveOffset()))?i._segment1:null},splitAt:function(t){var e=this.getLocationAt(t),i=e&&e.index,n=e&&e.time,r=1e-8,s=1-r;n>s&&(i++,n=0);var h=this.getCurves();if(i>=0&&i=r&&h[i++].divideAtTime(n);var a=this.removeSegments(i,this._segments.length,!0),o;return this._closed?(this.setClosed(!1),o=this):(o=new nt(X.NO_INSERT),o.insertAbove(this),o.copyAttributes(this)),o._add(a,0),this.addSegment(a[0]),o}return null},split:function(t,e){var i,n=e===D?t:(i=this.getCurves()[t])&&i.getLocationAtTime(e);return n!=null?this.splitAt(n):null},join:function(t,e){var i=e||0;if(t&&t!==this){var n=t._segments,r=this.getLastSegment(),s=t.getLastSegment();if(!s)return this;r&&r._point.isClose(s._point,i)&&t.reverse();var h=t.getFirstSegment();if(r&&r._point.isClose(h._point,i))r.setHandleOut(h._handleOut),this._add(n.slice(1));else{var a=this.getFirstSegment();a&&a._point.isClose(h._point,i)&&t.reverse(),s=t.getLastSegment(),a&&a._point.isClose(s._point,i)?(a.setHandleIn(s._handleIn),this._add(n.slice(0,n.length-1),0)):this._add(n.slice())}t._closed&&this._add([n[0]]),t.remove()}var o=this.getFirstSegment(),u=this.getLastSegment();return o!==u&&o._point.isClose(u._point,i)&&(o.setHandleIn(u._handleIn),u.remove(),this.setClosed(!0)),this},reduce:function(t){for(var e=this.getCurves(),i=t&&t.simplify,n=i?1e-7:0,r=e.length-1;r>=0;r--){var s=e[r];!s.hasHandles()&&(!s.hasLength(n)||i&&s.isCollinear(s.getNext()))&&s.remove()}return this},reverse:function(){this._segments.reverse();for(var t=0,e=this._segments.length;t0&&r.push(new G(i[n-1].curve.slice(6))),this.setSegments(r)},simplify:function(t){var e=new _e(this).fit(t||2.5);return e&&this.setSegments(e),!!e},smooth:function(t){var e=this,i=t||{},n=i.type||"asymmetric",r=this._segments,s=r.length,h=this._closed;function a(U,rt){var Y=U&&U.index;if(Y!=null){var tt=U.path;if(tt&&tt!==e)throw new Error(U._class+" "+Y+" of "+tt+" is not part of "+e);rt&&U instanceof R&&Y++}else Y=typeof U=="number"?U:rt;return Math.min(Y<0&&h?Y%s:Y<0?Y+s:Y,s-1)}var o=h&&i.from===D&&i.to===D,u=a(i.from,0),_=a(i.to,s-1);if(u>_)if(h)u-=s;else{var d=u;u=_,_=d}if(/^(?:asymmetric|continuous)$/.test(n)){var c=n==="asymmetric",l=Math.min,p=_-u+1,y=p-1,C=o?l(p,4):1,v=C,m=C,f=[];if(h||(v=l(1,u),m=l(1,s-_-1)),y+=v+m,y<=1)return;for(var g=0,w=u-v;g<=y;g++,w++)f[g]=r[(w<0?w+s:w)%s]._point;for(var S=f[0]._x+2*f[1]._x,x=f[0]._y+2*f[1]._y,b=2,P=y-1,I=[S],O=[x],A=[b],z=[],M=[],g=1;g=0;g--)z[g]=(I[g]-z[g+1])/A[g],M[g]=(O[g]-M[g+1])/A[g];z[y]=(3*f[y]._x-z[P])/2,M[y]=(3*f[y]._y-M[P])/2;for(var g=v,W=y-m,w=u;g<=W;g++,w++){var H=r[w<0?w+s:w],J=H._point,q=z[g]-J._x,$=M[g]-J._y;(o||gv)&&H.setHandleIn(-q,-$)}}else for(var g=u;g<=_;g++)r[g<0?g+s:g].smooth(i,!o&&g===u,!o&&g===_)},toShape:function(t){if(!this._closed)return null;var e=this._segments,i,n,r,s;function h(c,l){var p=e[c],y=p.getNext(),C=e[l],v=C.getNext();return p._handleOut.isZero()&&y._handleIn.isZero()&&C._handleOut.isZero()&&v._handleIn.isZero()&&y._point.subtract(p._point).isCollinear(v._point.subtract(C._point))}function a(c){var l=e[c],p=l.getPrevious(),y=l.getNext();return p._handleOut.isZero()&&l._handleIn.isZero()&&l._handleOut.isZero()&&y._handleIn.isZero()&&l._point.subtract(p._point).isOrthogonal(y._point.subtract(l._point))}function o(c){var l=e[c],p=l.getNext(),y=l._handleOut,C=p._handleIn,v=.5522847498307936;if(y.isOrthogonal(C)){var m=l._point,f=p._point,g=new pt(m,y,!0).intersect(new pt(f,C,!0),!0);return g&&et.isZero(y.getLength()/g.subtract(m).getLength()-v)&&et.isZero(C.getLength()/g.subtract(f).getLength()-v)}return!1}function u(c,l){return e[c]._point.getDistance(e[l]._point)}if(!this.hasHandles()&&e.length===4&&h(0,2)&&h(1,3)&&a(1)?(i=xt.Rectangle,n=new Z(u(0,3),u(0,1)),s=e[1]._point.add(e[2]._point).divide(2)):e.length===8&&o(0)&&o(2)&&o(4)&&o(6)&&h(1,5)&&h(3,7)?(i=xt.Rectangle,n=new Z(u(1,6),u(0,3)),r=n.subtract(new Z(u(0,7),u(1,2))).divide(2),s=e[3]._point.add(e[4]._point).divide(2)):e.length===4&&o(0)&&o(1)&&o(2)&&o(3)&&(et.isZero(u(0,2)-u(1,3))?(i=xt.Circle,r=u(0,2)/2):(i=xt.Ellipse,r=new Z(u(2,0)/2,u(3,1)/2)),s=e[1]._point),i){var _=this.getPosition(!0),d=new i({center:_,size:n,radius:r,insert:!1});return d.copyAttributes(this,!0),d._matrix.prepend(this._matrix),d.rotate(s.subtract(_).getAngle()+90),(t===D||t)&&d.insertAbove(this),d}return null},toPath:"#clone",compare:function t(e){if(!e||e instanceof Mt)return t.base.call(this,e);var i=this.getCurves(),n=e.getCurves(),r=i.length,s=n.length;if(!r||!s)return r==s;for(var h=i[0].getValues(),a=[],o=0,u,_=0,d,c=0;c0?s-1:c,d=l[0][1];break}}for(var p=Math.abs,y=1e-8,C=a[u],v;h&&C;){var l=R.getOverlaps(h,C);if(l){var m=l[0][0];if(p(m-_)=s&&(u=0),C=a[u]||n[u].getValues(),d=0),!h)return v[0]===u&&v[1]===d;continue}}}break}return!1},_hitTestSelf:function(t,e,i,n){var r=this,s=this.getStyle(),h=this._segments,a=h.length,o=this._closed,u=e._tolerancePadding,_=u,d,c,l,p,y,C,v=e.stroke&&s.hasStroke(),m=e.fill&&s.hasFill(),f=e.curves,g=v?s.getStrokeWidth()/2:m&&e.tolerance>0||f?0:null;g!==null&&(g>0?(d=s.getStrokeJoin(),c=s.getStrokeCap(),l=s.getMiterLimit(),_=_.add(nt._getStrokePadding(g,n))):d=c="round");function w(z,M){return t.subtract(z).divide(M).length<=1}function S(z,M,k){if(!e.selected||M.isSelected()){var E=z._point;if(M!==E&&(M=M.add(E)),w(M,_))return new Lt(k,r,{segment:z,point:M})}}function x(z,M){return(M||e.segments)&&S(z,z._point,"segment")||!M&&e.handles&&(S(z,z._handleIn,"handle-in")||S(z,z._handleOut,"handle-out"))}function b(z){p.add(z)}function P(z){var M=o||z._index>0&&z._index1?P(y.getSegment())||(y=null):w(y.getPoint(),_)||(y=null)}if(!y&&d==="miter"&&a>1)for(var I=0;It)return h.getLocationAt(t-s)}if(e.length>0&&t<=this.getLength())return new Tt(e[e.length-1],1)}else if(t&&t.getPath&&t.getPath()===this)return t;return null},getOffsetsWithTangent:function(){var t=L.read(arguments);if(t.isZero())return[];for(var e=[],i=0,n=this.getCurves(),r=0,s=n.length;r0&&!(C&1)){var v=i.fillStyle;i.fillStyle="#ffffff",i.fillRect(_-o,d-o,a,a),i.fillStyle=v}}}function e(i,n,r){var s=n._segments,h=s.length,a=new Array(6),o=!0,u,_,d,c,l,p,y,C;function v(f){if(r)f._transformCoordinates(r,a),u=a[0],_=a[1];else{var g=f._point;u=g._x,_=g._y}if(o)i.moveTo(u,_),o=!1;else{if(r)l=a[2],p=a[3];else{var w=f._handleIn;l=u+w._x,p=_+w._y}l===u&&p===_&&y===d&&C===c?i.lineTo(u,_):i.bezierCurveTo(y,C,l,p,u,_)}if(d=u,c=_,r)y=a[4],C=a[5];else{var w=f._handleOut;y=d+w._x,C=c+w._y}}for(var m=0;m0&&v(s[0])}return{_draw:function(i,n,r,s){var h=n.dontStart,a=n.dontFinish||n.clip,o=this.getStyle(),u=o.hasFill(),_=o.hasStroke(),d=o.getDashArray(),c=!Q.support.nativeDash&&_&&d&&d.length;h||i.beginPath(),(u||_&&!c||a)&&(e(i,this,s),this._closed&&i.closePath());function l(f){return d[(f%c+c)%c]}if(!a&&(u||_)&&(this._setStyles(i,n,r),u&&(i.fill(o.getFillRule()),i.shadowColor="rgba(0,0,0,0)"),_)){if(c){h||i.beginPath();for(var p=new ue(this,.25,32,!1,s),y=p.length,C=-o.getDashOffset(),v,m=0;C>0;)C-=l(m--)+l(m--);for(;C0||v>0)&&p.drawPart(i,Math.max(C,0),Math.max(v,0)),C=v+l(m++)}i.stroke()}},_drawSelected:function(i,n){i.beginPath(),e(i,this,n),i.stroke(),t(i,this._segments,n,Q.settings.handleSize)}}},new function(){function t(e){var i=e._segments;if(!i.length)throw new Error("Use a moveTo() command first");return i[i.length-1]}return{moveTo:function(){var e=this._segments;e.length===1&&this.removeSegment(0),e.length||this._add([new G(L.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new G(L.read(arguments))])},cubicCurveTo:function(){var e=arguments,i=L.read(e),n=L.read(e),r=L.read(e),s=t(this);s.setHandleOut(i.subtract(s._point)),this._add([new G(r,n.subtract(r))])},quadraticCurveTo:function(){var e=arguments,i=L.read(e),n=L.read(e),r=t(this)._point;this.cubicCurveTo(i.add(r.subtract(i).multiply(1/3)),i.add(n.subtract(i).multiply(1/3)),n)},curveTo:function(){var e=arguments,i=L.read(e),n=L.read(e),r=T.pick(T.read(e),.5),s=1-r,h=t(this)._point,a=i.subtract(h.multiply(s*s)).subtract(n.multiply(r*r)).divide(2*r*s);if(a.isNaN())throw new Error("Cannot put a curve through points with parameter = "+r);this.quadraticCurveTo(a,n)},arcTo:function(){var e=arguments,i=Math.abs,n=Math.sqrt,r=t(this),s=r._point,h=L.read(e),a,o=T.peek(e),u=T.pick(o,!0),_,d,c,l;if(typeof u=="boolean")var p=s.add(h).divide(2),a=p.add(p.subtract(s).rotate(u?-90:90));else if(T.remain(e)<=2)a=h,h=L.read(e);else if(!s.equals(h)){var y=Z.read(e),C=et.isZero;if(C(y.width)||C(y.height))return this.lineTo(h);var v=T.read(e),u=!!T.read(e),m=!!T.read(e),p=s.add(h).divide(2),f=s.subtract(p).rotate(-v),g=f.x,w=f.y,S=i(y.width),x=i(y.height),b=S*S,P=x*x,I=g*g,O=w*w,A=n(I/b+O/P);if(A>1&&(S*=A,x*=A,b=S*S,P=x*x),A=(b*P-b*O-P*I)/(b*O+P*I),i(A)<1e-12&&(A=0),A<0)throw new Error("Cannot create an arc with the given arguments");_=new L(S*w/x,-x*g/S).multiply((m===u?-1:1)*n(A)).rotate(v).add(p),l=new st().translate(_).rotate(v).scale(S,x),c=l._inverseTransform(s),d=c.getDirectedAngle(l._inverseTransform(h)),!u&&d>0?d-=360:u&&d<0&&(d+=360)}if(a){var z=new pt(s.add(a).divide(2),a.subtract(s).rotate(90),!0),M=new pt(a.add(h).divide(2),h.subtract(a).rotate(90),!0),k=new pt(s,h),E=k.getSide(a);if(_=z.intersect(M,!0),!_){if(!E)return this.lineTo(h);throw new Error("Cannot create an arc with the given arguments")}c=s.subtract(_),d=c.getDirectedAngle(h.subtract(_));var N=k.getSide(_,!0);N===0?d=E*i(d):E===N&&(d+=d<0?360:-360)}if(d){for(var B=1e-5,F=i(d),V=F>=360?4:Math.ceil((F-B)/90),W=d/V,H=W*Math.PI/360,J=4/3*Math.sin(H)/(1+Math.cos(H)),q=[],$=0;$<=V;$++){var f=h,U=null;if($0){for(var w=1;w=180)&&(d=d.negate(),c=c.negate()),a&&h(_),h(_.add(d)),e==="miter"){var p=new pt(_.add(d),new L(-d.y,d.x),!0).intersect(new pt(_.add(c),new L(-c.y,c.x),!0),!0);p&&_.getDistance(p)<=n*i&&h(p)}h(_.add(c))},_addSquareCap:function(t,e,i,n,r,s,h){var a=t._point.transform(n),o=t.getLocation(),u=o.getNormal().multiply(o.getTime()===0?i:-i).transform(r);e==="square"&&(h&&(s(a.subtract(u)),s(a.add(u))),a=a.add(u.rotate(-90))),s(a.add(u)),s(a.subtract(u))},getHandleBounds:function(t,e,i,n,r){var s=i.getStyle(),h=r.stroke&&s.hasStroke(),a,o;if(h){var u=i._getStrokeMatrix(n,r),_=s.getStrokeWidth()/2,d=_;s.getStrokeJoin()==="miter"&&(d=_*s.getMiterLimit()),s.getStrokeCap()==="square"&&(d=Math.max(d,_*Math.SQRT2)),a=nt._getStrokePadding(_,u),o=nt._getStrokePadding(d,u)}for(var c=new Array(6),l=1/0,p=-l,y=l,C=p,v=0,m=t.length;vp&&(p=O),AC&&(C=z)}}return new K(l,y,p-l,C-y)}}});nt.inject({statics:new function(){var t=.5522847498307936,e=[new G([-1,0],[0,t],[0,-t]),new G([0,-1],[-t,0],[t,0]),new G([1,0],[0,-t],[0,t]),new G([0,1],[t,0],[-t,0])];function i(r,s,h){var a=T.getNamed(h),o=new nt(a&&(a.insert==!0?X.INSERT:a.insert==!1?X.NO_INSERT:null));return o._add(r),o._closed=s,o.set(a,X.INSERT)}function n(r,s,h){for(var a=new Array(4),o=0;o<4;o++){var u=e[o];a[o]=new G(u._point.multiply(s).add(r),u._handleIn.multiply(s),u._handleOut.multiply(s))}return i(a,!0,h)}return{Line:function(){var r=arguments;return i([new G(L.readNamed(r,"from")),new G(L.readNamed(r,"to"))],!1,r)},Circle:function(){var r=arguments,s=L.readNamed(r,"center"),h=T.readNamed(r,"radius");return n(s,new Z(h),r)},Rectangle:function(){var r=arguments,s=K.readNamed(r,"rectangle"),h=Z.readNamed(r,"radius",0,{readNull:!0}),a=s.getBottomLeft(!0),o=s.getTopLeft(!0),u=s.getTopRight(!0),_=s.getBottomRight(!0),d;if(!h||h.isZero())d=[new G(a),new G(o),new G(u),new G(_)];else{h=Z.min(h,s.getSize(!0).divide(2));var c=h.width,l=h.height,p=c*t,y=l*t;d=[new G(a.add(c,0),null,[-p,0]),new G(a.subtract(0,l),[0,y]),new G(o.add(0,l),null,[0,-y]),new G(o.add(c,0),[-p,0],null),new G(u.subtract(c,0),null,[p,0]),new G(u.add(0,l),[0,-y],null),new G(_.subtract(0,l),null,[0,y]),new G(_.subtract(c,0),[p,0])]}return i(d,!0,r)},RoundRectangle:"#Rectangle",Ellipse:function(){var r=arguments,s=xt._readEllipse(r);return n(s.center,s.radius,r)},Oval:"#Ellipse",Arc:function(){var r=arguments,s=L.readNamed(r,"from"),h=L.readNamed(r,"through"),a=L.readNamed(r,"to"),o=T.getNamed(r),u=new nt(o&&o.insert==!1&&X.NO_INSERT);return u.moveTo(s),u.arcTo(h,a),u.set(o)},RegularPolygon:function(){for(var r=arguments,s=L.readNamed(r,"center"),h=T.readNamed(r,"sides"),a=T.readNamed(r,"radius"),o=360/h,u=h%3===0,_=new L(0,u?-a:a),d=u?-1:.5,c=new Array(h),l=0;l=0;s--){var h=n[s];n===i&&!(h instanceof nt)&&(n=T.slice(n)),Array.isArray(h)?n[s]=new nt({segments:h,insert:!1}):h instanceof Mt&&(n.splice.apply(n,[s,1].concat(h.removeChildren())),h.remove())}return t.base.call(this,e,n)},reduce:function t(e){for(var i=this._children,n=i.length-1;n>=0;n--){var r=i[n].reduce(e);r.isEmpty()&&r.remove()}if(!i.length){var r=new nt(X.NO_INSERT);return r.copyAttributes(this),r.insertAbove(this),this.remove(),r}return t.base.call(this)},isClosed:function(){for(var t=this._children,e=0,i=t.length;e=0;A--){var z=S[A].split();z&&(O(z)&&z.getFirstSegment().setHandleIn(0,0),g.getLastSegment().setHandleOut(0,0))}return O(g),h(I,!1,v,m)}function _(v,m){for(var f=v;f;){if(f===m)return;f=f._previous}for(;v._next&&v._next!==m;)v=v._next;if(!v._next){for(;m._previous;)m=m._previous;v._next=m,m._previous=v}}function d(v){for(var m=v.length-1;m>=0;m--)v[m].clearHandles()}function c(v,m,f){var g=v&&v.length;if(g){var w=T.each(v,function(F,V){this[F._id]={container:null,winding:F.isClockwise()?1:-1,index:V}},{}),S=v.slice().sort(function(F,V){return i(V.getArea())-i(F.getArea())}),x=S[0],b=Yt.findItemBoundsCollisions(S,null,et.GEOMETRIC_EPSILON);f==null&&(f=x.isClockwise());for(var P=0;P=0;k--)if(z[k]=0;M--){var k=f[M];k._path&&(P[z(k)]=!0)}for(var M=v.length-1;M>=0;M--){var E=v[M],N=E._time,B=N,F=m&&!m(E),k=E._curve,V;if(k&&(k!==O?(x=!k.hasHandles()||P&&P[z(k)],I=[],A=null,O=k):A>=w&&(N/=A)),F){I&&I.push(E);continue}else m&&g.unshift(E);if(A=B,NS)V=k._segment2;else{var W=k.divideAtTime(N,!0);x&&b.push(k,W),V=W._segment1;for(var H=I.length-1;H>=0;H--){var J=I[H];J._time=(J._time-N)/(1-N)}}E._setSegment(V);var q=V._intersection,$=E._intersection;if(q){_(q,$);for(var U=q;U;)_(U._intersection,q),U=U._next}else V._intersection=$}return f||d(b),g||v}function p(v,m,f,g,w){var S=Array.isArray(m)?m:m[f?"hor":"ver"],x=f?1:0,b=x^1,P=[v.x,v.y],I=P[x],O=P[b],A=1e-9,z=1e-6,M=I-A,k=I+A,E=0,N=0,B=0,F=0,V=!1,W=!1,H=1,J=[],q,$;function U(at){var gt=at[b+0],Pt=at[b+6];if(!(Oe(gt,Pt))){var yt=at[x+0],Ft=at[x+2],Jt=at[x+4],Dt=at[x+6];if(gt===Pt){(ytM||DtM)&&(V=!0);return}var Vt=O===gt?0:O===Pt||M>e(yt,Ft,Jt,Dt)||k0?J[0]:1,It=Vt===0?yt:Vt===1?Dt:R.getPoint(at,Vt)[f?"y":"x"],Ot=gt>Pt?1:-1,ne=q[b]>q[b+6]?1:-1,qt=q[x+6];return O!==gt?(Itk?F+=Ot:V=!0,It>I-z&&Itk&&(F+=Ot):yt!=qt&&(qtk?(F+=Ot,V=!0):qt>M&&ItM&&It=t(gt,Pt,yt,Ft)){for(var Jt=at[x+0],Dt=at[x+2],Vt=at[x+4],It=at[x+6],Ot=M>e(Jt,Dt,Vt,It)||kA.quality&&(A=U);break}I-=F}for(var E=S.length-1;E>=0;E--)S[E].segment._winding=A}function C(v,m){var f=[],g;function w(tt){var it;return!!(tt&&!tt._visited&&(!m||m[(it=tt._winding||{}).winding]&&!(m.unite&&it.winding===2&&it.windingL&&it.windingR)))}function S(tt){if(tt){for(var it=0,j=g.length;it=0;P--){var I=b[P],O=I._path,A=I._segment,z=A.getPrevious(),M=A.getNext();f(z,O)&&f(M,O)&&(A.remove(),z._handleOut._set(0,0),M._handleIn._set(0,0),z!==A&&!z.getCurve().hasLength()&&(M._handleIn.set(z._handleIn),z.remove()))}w&&(l(S,g&&function(N){var B=N.getCurve(),F=N.getSegment(),V=N._intersection,W=V._curve,H=V._segment;if(B&&W&&B._path&&W._path)return!0;F&&(F._intersection=null),H&&(H._intersection=null)},x),x&&d(x),m=C(T.each(m,function(N){T.push(this,N._segments)},[])));var k=m.length,E;return k>1&&v?(m!==v&&this.setChildren(m),E=this):k===1&&!v&&(m[0]!==this&&this.setSegments(m[0].removeSegments()),E=this),E||(E=new Mt(X.NO_INSERT),E.addChildren(m),E=E.reduce(),E.copyAttributes(this),this.replaceWith(E)),E},reorient:function(v,m){var f=this._children;return f&&f.length?this.setChildren(c(this.removeChildren(),function(g){return!!(v?g:g&1)},m)):m!==D&&this.setClockwise(m),this},getInteriorPoint:function(){var v=this.getBounds(),m=v.getCenter(!0);if(!this.contains(m)){for(var f=this.getCurves(),g=m.y,w=[],S=[],x=0,b=f.length;x=t(I,O,A,z)&&g<=e(I,O,A,z))for(var M=R.getMonoCurves(P),k=0,E=M.length;k=B&&g<=F||g>=F&&g<=B)){var V=g===B?N[0]:g===F?N[6]:R.solveCubic(N,1,g,S,0,1)===1?R.getPoint(N,S[0]).x:(N[0]+N[6])/2;w.push(V)}}}w.length>1&&(w.sort(function(W,H){return W-H}),m.x=(w[0]+w[1])/2)}return m}}});var ue=T.extend({_class:"PathFlattener",initialize:function(t,e,i,n,r){var s=[],h=[],a=0,o=1/(i||32),u=t._segments,_=u[0],d;function c(C,v){var m=R.getValues(C,v,r);s.push(m),l(m,C._index,0,1)}function l(C,v,m,f){if(f-m>o&&!(n&&R.isStraight(C))&&!R.isFlatEnough(C,e||.25)){var g=R.subdivide(C,.5),w=(m+f)/2;l(g[0],v,m,w),l(g[1],v,w,f)}else{var S=C[6]-C[0],x=C[7]-C[1],b=Math.sqrt(S*S+x*x);b>0&&(a+=b,h.push({offset:a,curve:C,index:v,time:f}))}}for(var p=1,y=u.length;p=t){this.index=r;var a=e[r-1],o=a&&a.index===h.index?a.time:0,u=a?a.offset:0;return{index:h.index,time:o+(h.time-o)*(t-u)/(h.offset-u)}}}return{index:e[i-1].index,time:1}},drawPart:function(t,e,i){for(var n=this._get(e),r=this._get(i),s=n.index,h=r.index;s<=h;s++){var a=R.getPart(this.curves[s],s===n.index?n.time:0,s===r.index?r.time:1);s===n.index&&t.moveTo(a[0],a[1]),t.bezierCurveTo.apply(t,a.slice(2))}}},T.each(R._evaluateMethods,function(t){this[t+"At"]=function(e){var i=this._get(e);return R[t](this.curves[i.index],i.time)}},{})),_e=T.extend({initialize:function(t){for(var e=this.points=[],i=t._segments,n=t._closed,r=0,s,h=i.length;r0&&(n=[new G(e[0])],i>1&&(this.fitCubic(n,t,0,i-1,e[1].subtract(e[0]),e[i-2].subtract(e[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(t,e,i,n,r,s){var h=this.points;if(n-i===1){var a=h[i],o=h[n],u=a.getDistance(o)/3;this.addCurve(t,[a,a.add(r.normalize(u)),o.add(s.normalize(u)),o]);return}for(var _=this.chordLengthParameterize(i,n),d=Math.max(e,e*e),c,l=!0,p=0;p<=4;p++){var y=this.generateBezier(i,n,_,r,s),C=this.findMaxError(i,n,y,_);if(C.error=d)break;l=this.reparameterize(i,n,_,y),d=C.error}var v=h[c-1].subtract(h[c+1]);this.fitCubic(t,e,i,c,r,v),this.fitCubic(t,e,c,n,v.negate(),s)},addCurve:function(t,e){var i=t[t.length-1];i.setHandleOut(e[1].subtract(e[0])),t.push(new G(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,i,n,r){for(var s=1e-12,h=Math.abs,a=this.points,o=a[t],u=a[e],_=[[0,0],[0,0]],d=[0,0],c=0,l=e-t+1;cs){var O=_[0][0]*d[1]-_[1][0]*d[0],A=d[0]*_[1][1]-d[1]*_[0][1];P=A/b,I=O/b}else{var z=_[0][0]+_[0][1],M=_[1][0]+_[1][1];P=I=h(z)>s?d[0]/z:h(M)>s?d[1]/M:0}var k=u.getDistance(o),E=s*k,N,B;if(Pk*k&&(P=I=k/3,N=B=null)}return[o,o.add(N||n.normalize(P)),u.add(B||r.normalize(I)),u]},reparameterize:function(t,e,i,n){for(var r=t;r<=e;r++)i[r-t]=this.findRoot(n,this.points[r],i[r-t]);for(var r=1,s=i.length;r=s&&(s=u,r=h)}return{error:s,index:r}}}),te=X.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(e){this._content="",this._lines=[];var i=e&&T.isPlainObject(e)&&e.x===D&&e.y===D;this._initialize(i&&e,!i&&L.read(arguments))},_equals:function(t){return this._content===t._content},copyContent:function(t){this.setContent(t._content)},getContent:function(){return this._content},setContent:function(t){this._content=""+t,this._lines=this._content.split(/\r\n|\n|\r/mg),this._changed(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),de=te.extend({_class:"PointText",initialize:function(){te.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new Nt(t.x,t.y,this,"setPoint")},setPoint:function(){var t=L.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=this._lines,r=this._style,s=r.hasFill(),h=r.hasStroke(),a=r.getLeading(),o=t.shadowColor;t.font=r.getFontStyle(),t.textAlign=r.getJustification();for(var u=0,_=n.length;u<_;u++){t.shadowColor=o;var d=n[u];s&&(t.fillText(d,0,0),t.shadowColor="rgba(0,0,0,0)"),h&&t.strokeText(d,0,0),t.translate(0,a)}}},_getBounds:function(t,e){var i=this._style,n=this._lines,r=n.length,s=i.getJustification(),h=i.getLeading(),a=this.getView().getTextWidth(i.getFontStyle(),n),o=0;s!=="left"&&(o-=a/(s==="center"?2:1));var u=new K(o,r?-.75*h:0,a,r*h);return t?t._transformBounds(u,u):u}}),ct=T.extend(new function(){var t={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},e={},i={transparent:[0,0,0,0]},n;function r(a){var o=a.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i)||a.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),u="rgb",_;if(o){var d=o[4]?4:3;_=new Array(d);for(var c=0;c1&&(y-=1),l[p]=6*y<1?c+(d-c)*6*y:2*y<1?d:3*y<2?c+(d-c)*(2/3-y)*6:c}return l},"rgb-gray":function(a,o,u){return[a*.2989+o*.587+u*.114]},"gray-rgb":function(a){return[a,a,a]},"gray-hsb":function(a){return[0,0,a]},"gray-hsl":function(a){return[0,0,a]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return T.each(t,function(a,o){e[o]=[],T.each(a,function(u,_){var d=T.capitalize(u),c=/^(hue|saturation)$/.test(u),l=e[o][_]=o==="gradient"?u==="gradient"?function(p){var y=this._components[0];return p=ee.read(Array.isArray(p)?p:arguments,0,{readNull:!0}),y!==p&&(y&&y._removeOwner(this),p&&p._addOwner(this)),p}:function(){return L.read(arguments,0,{readNull:u==="highlight",clone:!0})}:function(p){return p==null||isNaN(p)?0:+p};this["get"+d]=function(){return this._type===o||c&&/^hs[bl]$/.test(this._type)?this._components[_]:this._convert(o)[_]},this["set"+d]=function(p){this._type!==o&&!(c&&/^hs[bl]$/.test(this._type))&&(this._components=this._convert(o),this._properties=t[o],this._type=o),this._components[_]=l.call(this,p),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function a(o){var u=arguments,_=this.__read,d=0,c,l,p,y;Array.isArray(o)&&(u=o,o=u[0]);var C=o!=null&&typeof o;if(C==="string"&&o in t&&(c=o,o=u[1],Array.isArray(o)?(l=o,p=u[2]):(_&&(d=1),u=T.slice(u,1),C=typeof o)),!l){if(y=C==="number"?u:C==="object"&&o.length!=null?o:null,y){c||(c=y.length>=3?"rgb":"gray");var v=t[c].length;p=y[v],_&&(d+=y===arguments?v+(p!=null?1:0):1),y.length>v&&(y=T.slice(y,0,v))}else if(C==="string"){var m=r(o);c=m[0],l=m[1],l.length===4&&(p=l[3],l.length--)}else if(C==="object")if(o.constructor===a){if(c=o._type,l=o._components.slice(),p=o._alpha,c==="gradient")for(var f=1,g=l.length;f1?1:d)*255)}return o=[_(o[0]),_(o[1]),_(o[2])],u<1&&o.push(u<0?0:u),a?"#"+((1<<24)+(o[0]<<16)+(o[1]<<8)+o[2]).toString(16).slice(1):(o.length==4?"rgba(":"rgb(")+o.join(",")+")"},toCanvasStyle:function(a,o){if(this._canvasStyle)return this._canvasStyle;if(this._type!=="gradient")return this._canvasStyle=this.toCSS();var u=this._components,_=u[0],d=_._stops,c=u[1],l=u[2],p=u[3],y=o&&o.inverted(),C;if(y&&(c=y._transformPoint(c),l=y._transformPoint(l),p&&(p=y._transformPoint(p))),_._radial){var v=l.getDistance(c);if(p){var m=p.subtract(c);m.getLength()>v&&(p=c.add(m.normalize(v-.1)))}var f=p||c;C=a.createRadialGradient(f.x,f.y,0,c.x,c.y,v)}else C=a.createLinearGradient(c.x,c.y,l.x,l.y);for(var g=0,w=d.length;g0&&!(y instanceof Mt);if(v)for(var m=0,f=C.length;m0&&!(y instanceof Mt),m;if(v&&!p)for(var f=0,g=C.length;f0},hasStroke:function(){var t=this.getStrokeColor();return!!t&&t.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var t=this.getShadowColor();return!!t&&t.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var t=this.getFontSize();return this.getFontWeight()+" "+t+(/[a-z]/i.test(t+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function t(){var e=t.base.call(this),i=this.getFontSize();return/pt|em|%|px/.test(i)&&(i=this.getView().getPixelSize(i)),e!=null?e:i*1.2}}),ht=new function(){function t(e,i,n,r){for(var s=["","webkit","moz","Moz","ms","o"],h=i[0].toUpperCase()+i.substring(1),a=0;a<6;a++){var o=s[a],u=o?o+h:i;if(u in e){if(n)e[u]=r;else return e[u];break}}}return{getStyles:function(e){var i=e&&e.nodeType!==9?e.ownerDocument:e,n=i&&i.defaultView;return n&&n.getComputedStyle(e,"")},getBounds:function(e,i){var n=e.ownerDocument,r=n.body,s=n.documentElement,h;try{h=e.getBoundingClientRect()}catch(_){h={left:0,top:0,width:0,height:0}}var a=h.left-(s.clientLeft||r.clientLeft||0),o=h.top-(s.clientTop||r.clientTop||0);if(!i){var u=n.defaultView;a+=u.pageXOffset||s.scrollLeft||r.scrollLeft,o+=u.pageYOffset||s.scrollTop||r.scrollTop}return new K(a,o,h.width,h.height)},getViewportBounds:function(e){var i=e.ownerDocument,n=i.defaultView,r=i.documentElement;return new K(0,0,n.innerWidth||r.clientWidth,n.innerHeight||r.clientHeight)},getOffset:function(e,i){return ht.getBounds(e,i).getPoint()},getSize:function(e){return ht.getBounds(e,!0).getSize()},isInvisible:function(e){return ht.getSize(e).equals(new Z(0,0))},isInView:function(e){return!ht.isInvisible(e)&&ht.getViewportBounds(e).intersects(ht.getBounds(e,!0))},isInserted:function(e){return vt.body.contains(e)},getPrefixed:function(e,i){return e&&t(e,i)},setPrefixed:function(e,i,n){if(typeof i=="object")for(var r in i)t(e,r,!0,i[r]);else t(e,i,!0,n)}}},_t={add:function(t,e){if(t)for(var i in e)for(var n=e[i],r=i.split(/[\s,]+/g),s=0,h=r.length;s1?T.hyphenate(_):_.toLowerCase())}function o(u,_,d,c){var l=u?"keydown":"keyup",p=ot._focused,y;if(i[_]=u,u?n[_]=d:delete n[_],_.length>1&&(y=T.camelize(_))in h){h[y]=u;var C=Q&&Q.agent;if(y==="meta"&&C&&C.mac)if(u)r={};else{for(var v in r)v in n&&o(!1,v,r[v],c);r=null}}else u&&r&&(r[_]=d);p&&p._handleKeyEvent(u?"keydown":"keyup",c,_,d)}return _t.add(vt,{keydown:function(u){var _=a(u),d=Q&&Q.agent;_.length>1||d&&d.chrome&&(u.altKey||d.mac&&u.metaKey||!d.mac&&u.ctrlKey)?o(!0,_,e[_]||(_.length>1?"":_),u):s=_},keypress:function(u){if(s){var _=a(u),d=u.charCode,c=d>=32?String.fromCharCode(d):_.length>1?"":_;_!==s&&(_=c.toLowerCase()),o(!0,_,c,u),s=null}},keyup:function(u){var _=a(u);_ in n&&o(!1,_,n[_],u)}}),_t.add(lt,{blur:function(u){for(var _ in n)o(!1,_,n[_],u)}}),{modifiers:h,isDown:function(u){return!!i[u]}}},pe=ie.extend({_class:"MouseEvent",initialize:function(e,i,n,r,s){this.type=e,this.event=i,this.point=n,this.target=r,this.delta=s},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),me=ie.extend({_class:"ToolEvent",_item:null,initialize:function(e,i,n){this.tool=e,this.type=i,this.event=n},_choosePoint:function(t,e){return t||(e?e.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(t){this._point=t},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(t){this._lastPoint=t},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(t){this._downPoint=t},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(t){this._middlePoint=t},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(t){this._delta=t},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(t){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=t},getItem:function(){if(!this._item){var t=this.tool._scope.project.hitTest(this.getPoint());if(t){for(var e=t.item,i=e._parent;/^(Group|CompoundPath)$/.test(i._class);)e=i,i=i._parent;this._item=e}}return this._item},setItem:function(t){this._item=t},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),xe=$t.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(e){$t.call(this),this._moveCount=-1,this._downCount=-1,this.set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(t){this._minDistance=t,t!=null&&this._maxDistance!=null&&t>this._maxDistance&&(this._maxDistance=t)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(t){this._maxDistance=t,this._minDistance!=null&&t!=null&&t=0&&c.equals(l))return!1;if(l&&(_!=null||d!=null)){var p=c.subtract(l),y=p.getLength();if(y<(_||0))return!1;d&&(c=l.add(p.normalize(Math.min(y,d))))}a._moveCount++}return a._point=c,a._lastPoint=l||c,n.down&&(a._moveCount=-1,a._downPoint=c,a._downCount++),!0}function u(){s&&(h=a.emit(t,new me(a,t,e))||h)}if(n.down)o(),u();else if(n.up)o(null,this._maxDistance),u();else if(s)for(;o(this._minDistance,this._maxDistance);)u();return h}}),we=T.extend(Xt,{_class:"Tween",statics:{easings:new T({linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:-1+2*(2-t)*t},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}})},initialize:function t(e,i,n,r,s,h){this.object=e;var a=typeof s,o=a==="function";this.type=o?a:a==="string"?s:"linear",this.easing=o?s:t.easings[this.type],this.duration=r,this.running=!1,this._then=null,this._startTime=null;var u=i||n;this._keys=u?Object.keys(u):[],this._parsedKeys=this._parseKeys(this._keys),this._from=u&&this._getState(i),this._to=u&&this._getState(n),h!==!1&&this.start()},then:function(t){return this._then=t,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(t){if(this.running){t>=1&&(t=1,this.running=!1);for(var e=this.easing(t),i=this._keys,n=function(_){return typeof _=="function"?_(e,t):_},r=0,s=i&&i.length;r255){var M=255-I,k=A-I;d=I+(d-I)*M/k,c=I+(c-I)*M/k,l=I+(l-I)*M/k}}function C(w,S,x){return e(w,S,x)-t(w,S,x)}function v(w,S,x,b){var P=[w,S,x],I=e(w,S,x),O=t(w,S,x),A;O=O===w?0:O===S?1:2,I=I===w?0:I===S?1:2,A=t(O,I)===0?e(O,I)===1?2:1:0,P[I]>P[O]?(P[A]=(P[A]-P[O])*b/(P[I]-P[O]),P[I]=b):P[A]=P[I]=0,P[O]=0,d=P[0],c=P[1],l=P[2]}var m={multiply:function(){d=a*n/255,c=o*r/255,l=u*s/255},screen:function(){d=a+n-a*n/255,c=o+r-o*r/255,l=u+s-u*s/255},overlay:function(){d=a<128?2*a*n/255:255-2*(255-a)*(255-n)/255,c=o<128?2*o*r/255:255-2*(255-o)*(255-r)/255,l=u<128?2*u*s/255:255-2*(255-u)*(255-s)/255},"soft-light":function(){var w=n*a/255;d=w+a*(255-(255-a)*(255-n)/255-w)/255,w=r*o/255,c=w+o*(255-(255-o)*(255-r)/255-w)/255,w=s*u/255,l=w+u*(255-(255-u)*(255-s)/255-w)/255},"hard-light":function(){d=n<128?2*n*a/255:255-2*(255-n)*(255-a)/255,c=r<128?2*r*o/255:255-2*(255-r)*(255-o)/255,l=s<128?2*s*u/255:255-2*(255-s)*(255-u)/255},"color-dodge":function(){d=a===0?0:n===255?255:t(255,255*a/(255-n)),c=o===0?0:r===255?255:t(255,255*o/(255-r)),l=u===0?0:s===255?255:t(255,255*u/(255-s))},"color-burn":function(){d=a===255?255:n===0?0:e(0,255-(255-a)*255/n),c=o===255?255:r===0?0:e(0,255-(255-o)*255/r),l=u===255?255:s===0?0:e(0,255-(255-u)*255/s)},darken:function(){d=an?a:n,c=o>r?o:r,l=u>s?u:s},difference:function(){d=a-n,d<0&&(d=-d),c=o-r,c<0&&(c=-c),l=u-s,l<0&&(l=-l)},exclusion:function(){d=a+n*(255-a-a)/255,c=o+r*(255-o-o)/255,l=u+s*(255-u-u)/255},hue:function(){v(n,r,s,C(a,o,u)),y(d,c,l,p(a,o,u))},saturation:function(){v(a,o,u,C(n,r,s)),y(d,c,l,p(a,o,u))},luminosity:function(){y(a,o,u,p(n,r,s))},color:function(){y(n,r,s,p(a,o,u))},add:function(){d=t(a+n,255),c=t(o+r,255),l=t(u+s,255)},subtract:function(){d=e(a-n,0),c=e(o-r,0),l=e(u-s,0)},average:function(){d=(a+n)/2,c=(o+r)/2,l=(u+s)/2},negation:function(){d=255-i(255-n-a),c=255-i(255-r-o),l=255-i(255-s-u)}},f=this.nativeModes=T.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(w){this[w]=!0},{}),g=ft.getContext(1,1,{willReadFrequently:!0});g&&(T.each(m,function(w,S){var x=S==="darken",b=!1;g.save();try{g.fillStyle=x?"#300":"#a00",g.fillRect(0,0,1,1),g.globalCompositeOperation=S,g.globalCompositeOperation===S&&(g.fillStyle=x?"#a00":"#300",g.fillRect(0,0,1,1),b=g.getImageData(0,0,1,1).data[0]!==x?170:51)}catch(P){}g.restore(),f[S]=b}),ft.release(g)),this.process=function(w,S,x,b,P){var I=S.canvas,O=w==="normal";if(O||f[w])x.save(),x.setTransform(1,0,0,1,0,0),x.globalAlpha=b,O||(x.globalCompositeOperation=w),x.drawImage(I,P.x,P.y),x.restore();else{var A=m[w];if(!A)return;for(var z=x.getImageData(P.x,P.y,I.width,I.height),M=z.data,k=S.getImageData(0,0,I.width,I.height).data,E=0,N=M.length;E=2&&!m.hasHandles())if(x>2){b=m._closed?"polygon":"polyline";for(var I=[],O=0;O{},2965:()=>{}}]); //# sourceMappingURL=lazy-lib-paper-652e1d1aaf5a025c5f3d.js.map