diff --git a/.eslintrc.json b/.eslintrc.json index 530cfa5e8..abf005bd3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,5 +43,6 @@ "arrowParens": "always" } ] - } + }, + "ignorePatterns": ["src/gui.js"] } diff --git a/src/components/Editor/Project/Project.jsx b/src/components/Editor/Project/Project.jsx index 4fa543b97..d197242b8 100644 --- a/src/components/Editor/Project/Project.jsx +++ b/src/components/Editor/Project/Project.jsx @@ -25,6 +25,7 @@ const Project = (props) => { } = props; const saving = useSelector((state) => state.editor.saving); const autosave = useSelector((state) => state.editor.lastSaveAutosave); + const project = useSelector((state) => state.editor.project); useEffect(() => { if (saving === "success" && autosave === false) { @@ -52,6 +53,9 @@ const Project = (props) => { setLoading(false); }, []); + const publicUrl = process.env.PUBLIC_URL; + const iframeSrc = `${publicUrl}/scratch-component.html`; + return (
{ {withProjectbar && } {!loading && (
- - - - + {project.project_type === "scratch" ? ( + + ) : ( + <> + + + + + + )}
)}
diff --git a/src/gui.js b/src/gui.js new file mode 100644 index 000000000..df01fad6b --- /dev/null +++ b/src/gui.js @@ -0,0 +1,3 @@ +/*! For license information please see gui.js.LICENSE.txt */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GUI=t():e.GUI=t()}(self,(()=>(()=>{var __webpack_modules__={48311:function(e,t,o){var i,n,a;(function(A,r){var s=(A=A||o(32012)).window?A.window:A,l=A.document,u=new function(){var e=/^(statics|enumerable|beans|preserve)$/,t=[],o=t.slice,i=Object.create,n=Object.getOwnPropertyDescriptor,a=Object.defineProperty,A=t.forEach||function(e,t){for(var o=0,i=this.length;o0||s+i0?[["dictionary",i.definitions],n]:n},deserialize:function(e,t,o,i,n){var a=e,A=!o,r=A&&e&&e.length&&"dictionary"===e[0][0];if(o=o||{},Array.isArray(e)){var s=e[0],l="dictionary"===s;if(1==e.length&&/^#/.test(s))return o.dictionary[s];a=[];for(var g=(s=u.exports[s])?1:0,c=e.length;ge.length&&(o=e.length);for(var A=0;A0){var a=t[n],A=a&&a[i];A&&A.call(this,n)}},statics:{inject:function e(t){var o=t._events;if(o){var i={};u.each(o,(function(e,o){var n="string"==typeof e,a=n?e:o,A=u.capitalize(a),r=a.substring(2).toLowerCase();i[r]=n?{}:e,a="_"+a,t["get"+A]=function(){return this[a]},t["set"+A]=function(e){var t=this[a];t&&this.off(r,t),e&&this.on(r,e),this[a]=e}})),t._eventTypes=i}return e.base.apply(this,arguments)}}},c=u.extend({_class:"PaperScope",initialize:function e(){ce=this,this.settings=new u({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this._id=e._id++,e._scopes[this._id]=this;var t=e.prototype;if(!this.support){var o=se.getContext(1,1)||{};t.support={nativeDash:"setLineDash"in o||"mozDash"in o,nativeBlendModes:le.nativeModes},se.release(o)}if(!this.agent){var i=A.navigator.userAgent.toLowerCase(),n=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(i)||[])[0],a="darwin"===n?"mac":n,r=t.agent=t.browser={platform:a};a&&(r[a]=!0),i.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node|jsdom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,(function(e,t,o,i,n){if(!r.chrome){var a="opera"===t?i:/^(node|trident)$/.test(t)?n:o;r.version=a,r.versionNumber=parseFloat(a),t={trident:"msie",jsdom:"node"}[t]||t,r.name=t,r[t]=!0}})),r.chrome&&delete r.webkit,r.atom&&delete r.chrome}},version:"0.12.7",getView:function(){var e=this.project;return e&&e._view},getPaper:function(){return this},execute:function(e,t){var o=ce.PaperScript.execute(e,this,t);return q.updateFocus(),o},install:function(e){var t=this;for(var o in u.each(["project","view","tool"],(function(o){u.define(e,o,{configurable:!0,get:function(){return t[o]}})})),this)!/^_/.test(o)&&this[o]&&(e[o]=this[o])},setup:function(e){return ce=this,this.project=new w(e),this},createCanvas:function(e,t){return se.getCanvas(e,t)},activate:function(){ce=this},clear:function(){for(var e=this.projects,t=this.tools,o=e.length-1;o>=0;o--)e[o].remove();for(o=t.length-1;o>=0;o--)t[o].remove()},remove:function(){this.clear(),delete c._scopes[this._id]},statics:new function(){function e(e){return e+="Attribute",function(t,o){return t[e](o)||t[e]("data-paper-"+o)}}return{_scopes:{},_id:0,get:function(e){return this._scopes[e]||null},getAttribute:e("get"),hasAttribute:e("has")}}}),d=u.extend(g,{initialize:function(e){this._scope=ce,this._index=this._scope[this._list].push(this)-1,!e&&this._scope[this._reference]||this.activate()},activate:function(){if(!this._scope)return!1;var e=this._scope[this._reference];return e&&e!==this&&e.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",e),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(u.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()}}),E={findItemBoundsCollisions:function(e,t,o){function i(e){for(var t=new Array(e.length),o=0;o>>1;A[e[a]][t]=r;(n||(B&&k||S&&b)&&w>=D[c]-o&&y<=D[d]+o)&&(B&&k&&O.push(a?f:f-r),S&&b&&m[f].push(I))}}}if(B&&(e===t&&O.push(T),m[T]=O),p.length){var R=l(p,g,C[g]);p.splice(R+1,0,T)}else p.push(T)}for(h=0;ho?o:e}function l(e,t,i){function n(e){var t=134217729*e,o=e-t+t;return[o,e-o]}var a=t*t-e*i,A=t*t+e*i;if(3*o(a)1e8)?n(2,-Math.round(a(e))):0}return{EPSILON:A,MACHINE_EPSILON:r,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,KAPPA:4*(i(2)-1)/3,isZero:function(e){return e>=-1e-12&&e<=A},isMachineZero:function(e){return e>=-112e-18&&e<=r},clamp:s,integrate:function(o,i,n,a){for(var A=e[a-2],r=t[a-2],s=.5*(n-i),l=s+i,u=0,g=a+1>>1,c=1&a?r[u++]*o(l):0;u0?(a=i,i=c<=n?.5*(n+a):c):(n=i,i=c>=a?.5*(n+a):c)}return s(i,n,a)},solveQuadratic:function(e,t,n,a,g,c){var d,E=1/0;if(o(e)=-112e-18){var m=h<0?0:i(h),T=t+(t<0?-m:m);0===T?E=-(d=n/e):(d=T/e,E=n/T)}}var C=0,I=null==g,B=g-A,S=c+A;return isFinite(d)&&(I||d>B&&dB&&E0?1.324717957244746*Math.max(O,i(M)):O,y=E-N*w;if(y!==E){do{B(y),y=0===T?E:E-C/T/(1+r)}while(N*y>N*E);o(e)*E*E>o(l/E)&&(h=((m=-l/E)-a)/E)}}var f=p.solveQuadratic(e,h,m,g,c,d),D=null==c;return isFinite(E)&&(0===f||f>0&&E!==g[0]&&E!==g[1])&&(D||E>c-A&&E1?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),n=0)}return i&&(this.__read=n),this},set:"#initialize",_set:function(e,t){return this.x=e,this.y=t,this},equals:function(e){return this===e||e&&(this.x===e.x&&this.y===e.y||Array.isArray(e)&&this.x===e[0]&&this.y===e[1])||!1},clone:function(){return new T(this.x,this.y)},toString:function(){var e=h.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(e){if(this.isZero()){var t=this._angle||0;this._set(Math.cos(t)*e,Math.sin(t)*e)}else{var o=e/this.getLength();p.isZero(o)&&this.getAngle(),this._set(this.x*o,this.y*o)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(e){this.setAngleInRadians.call(this,e*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var e=T.read(arguments),t=this.getLength()*e.getLength();if(p.isZero(t))return NaN;var o=this.dot(e)/t;return Math.acos(o<-1?-1:o>1?1:o)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(e){if(this._angle=e,!this.isZero()){var t=this.getLength();this._set(Math.cos(e)*t,Math.sin(e)*t)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var e=T.read(arguments);return 180*Math.atan2(this.cross(e),this.dot(e))/Math.PI},getDistance:function(){var e=arguments,t=T.read(e),o=t.x-this.x,i=t.y-this.y,n=o*o+i*i;return u.read(e)?n:Math.sqrt(n)},normalize:function(e){e===r&&(e=1);var t=this.getLength(),o=0!==t?e/t:0,i=new T(this.x*o,this.y*o);return o>=0&&(i._angle=this._angle),i},rotate:function(e,t){if(0===e)return this.clone();e=e*Math.PI/180;var o=t?this.subtract(t):this,i=Math.sin(e),n=Math.cos(e);return o=new T(o.x*n-o.y*i,o.x*i+o.y*n),t?o.add(t):o},transform:function(e){return e?e._transformPoint(this):this},add:function(){var e=T.read(arguments);return new T(this.x+e.x,this.y+e.y)},subtract:function(){var e=T.read(arguments);return new T(this.x-e.x,this.y-e.y)},multiply:function(){var e=T.read(arguments);return new T(this.x*e.x,this.y*e.y)},divide:function(){var e=T.read(arguments);return new T(this.x/e.x,this.y/e.y)},modulo:function(){var e=T.read(arguments);return new T(this.x%e.x,this.y%e.y)},negate:function(){return new T(-this.x,-this.y)},isInside:function(){return S.read(arguments).contains(this)},isClose:function(){var e=arguments,t=T.read(e),o=u.read(e);return this.getDistance(t)<=o},isCollinear:function(){var e=T.read(arguments);return T.isCollinear(this.x,this.y,e.x,e.y)},isColinear:"#isCollinear",isOrthogonal:function(){var e=T.read(arguments);return T.isOrthogonal(this.x,this.y,e.x,e.y)},isZero:function(){var e=p.isZero;return e(this.x)&&e(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},isInQuadrant:function(e){return this.x*(e>1&&e<4?-1:1)>=0&&this.y*(e>2?-1:1)>=0},dot:function(){var e=T.read(arguments);return this.x*e.x+this.y*e.y},cross:function(){var e=T.read(arguments);return this.x*e.y-this.y*e.x},project:function(){var e=T.read(arguments),t=e.isZero()?0:this.dot(e)/e.dot(e);return new T(e.x*t,e.y*t)},statics:{min:function(){var e=arguments,t=T.read(e),o=T.read(e);return new T(Math.min(t.x,o.x),Math.min(t.y,o.y))},max:function(){var e=arguments,t=T.read(e),o=T.read(e);return new T(Math.max(t.x,o.x),Math.max(t.y,o.y))},random:function(){return new T(Math.random(),Math.random())},isCollinear:function(e,t,o,i){return Math.abs(e*i-t*o)<=1e-8*Math.sqrt((e*e+t*t)*(o*o+i*i))},isOrthogonal:function(e,t,o,i){return Math.abs(e*o+t*i)<=1e-8*Math.sqrt((e*e+t*t)*(o*o+i*i))}}},u.each(["round","ceil","floor","abs"],(function(e){var t=Math[e];this[e]=function(){return new T(t(this.x),t(this.y))}}),{})),C=T.extend({initialize:function(e,t,o,i){this._x=e,this._y=t,this._owner=o,this._setter=i},_set:function(e,t,o){return this._x=e,this._y=t,o||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner[this._setter](this)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){return"setPosition"===this._setter?4:0}}),I=u.extend({_class:"Size",_readIndex:!0,initialize:function(e,t){var o=typeof e,i=this.__read,n=0;if("number"===o){var a="number"==typeof t;this._set(e,a?t:e),i&&(n=a?2:1)}else if("undefined"===o||null===e)this._set(0,0),i&&(n=null===e?1:0);else{var A="string"===o?e.split(/[\s,]+/)||[]:e;n=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),n=0)}return i&&(this.__read=n),this},set:"#initialize",_set:function(e,t){return this.width=e,this.height=t,this},equals:function(e){return e===this||e&&(this.width===e.width&&this.height===e.height||Array.isArray(e)&&this.width===e[0]&&this.height===e[1])||!1},clone:function(){return new I(this.width,this.height)},toString:function(){var e=h.instance;return"{ width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.width),t.number(this.height)]},add:function(){var e=I.read(arguments);return new I(this.width+e.width,this.height+e.height)},subtract:function(){var e=I.read(arguments);return new I(this.width-e.width,this.height-e.height)},multiply:function(){var e=I.read(arguments);return new I(this.width*e.width,this.height*e.height)},divide:function(){var e=I.read(arguments);return new I(this.width/e.width,this.height/e.height)},modulo:function(){var e=I.read(arguments);return new I(this.width%e.width,this.height%e.height)},negate:function(){return new I(-this.width,-this.height)},isZero:function(){var e=p.isZero;return e(this.width)&&e(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(e,t){return new I(Math.min(e.width,t.width),Math.min(e.height,t.height))},max:function(e,t){return new I(Math.max(e.width,t.width),Math.max(e.height,t.height))},random:function(){return new I(Math.random(),Math.random())}}},u.each(["round","ceil","floor","abs"],(function(e){var t=Math[e];this[e]=function(){return new I(t(this.width),t(this.height))}}),{})),B=I.extend({initialize:function(e,t,o,i){this._width=e,this._height=t,this._owner=o,this._setter=i},_set:function(e,t,o){return this._width=e,this._height=t,o||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(e){this._width=e,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(e){this._height=e,this._owner[this._setter](this)}}),S=u.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(e,t,o,i){var n,a=arguments,A=typeof e;if("number"===A?(this._set(e,t,o,i),n=4):"undefined"===A||null===e?(this._set(0,0,0,0),n=null===e?1:0):1===a.length&&(Array.isArray(e)?(this._set.apply(this,e),n=1):e.x!==r||e.width!==r?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),n=1):e.from===r&&e.to===r&&(this._set(0,0,0,0),u.readSupported(a,this)&&(n=1))),n===r){var s,l,g=T.readNamed(a,"from"),c=u.peek(a),d=g.x,E=g.y;if(c&&c.x!==r||u.hasNamed(a,"to")){var h=T.readNamed(a,"to");s=h.x-d,l=h.y-E,s<0&&(d=h.x,s=-s),l<0&&(E=h.y,l=-l)}else{var p=I.read(a);s=p.width,l=p.height}this._set(d,E,s,l),n=a.__index}var m=a.__filtered;return m&&(this.__filtered=m),this.__read&&(this.__read=n),this},set:"#initialize",_set:function(e,t,o,i){return this.x=e,this.y=t,this.width=o,this.height=i,this},clone:function(){return new S(this.x,this.y,this.width,this.height)},equals:function(e){var t=u.isPlainValue(e)?S.read(arguments):e;return t===this||t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height||!1},toString:function(){var e=h.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+", width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y),t.number(this.width),t.number(this.height)]},getPoint:function(e){return new(e?T:C)(this.x,this.y,this,"setPoint")},setPoint:function(){var e=T.read(arguments);this.x=e.x,this.y=e.y},getSize:function(e){return new(e?I:B)(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var e=I.read(arguments),t=this._sx,o=this._sy,i=e.width,n=e.height;t&&(this.x+=(this.width-i)*t),o&&(this.y+=(this.height-n)*o),this.width=i,this.height=n,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(e){if(!this._fw){var t=e-this.x;this.width-=.5===this._sx?2*t:t}this.x=e,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(e){if(!this._fh){var t=e-this.y;this.height-=.5===this._sy?2*t:t}this.y=e,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(e){if(!this._fw){var t=e-this.x;this.width=.5===this._sx?2*t:t}this.x=e-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(e){if(!this._fh){var t=e-this.y;this.height=.5===this._sy?2*t:t}this.y=e-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(e){this._fw||.5===this._sx?this.x=e-this.width/2:(this._sx&&(this.x+=2*(e-this.x)*this._sx),this.width=2*(e-this.x)),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(e){this._fh||.5===this._sy?this.y=e-this.height/2:(this._sy&&(this.y+=2*(e-this.y)*this._sy),this.height=2*(e-this.y)),this._sy=.5,this._fh=0},getCenter:function(e){return new(e?T:C)(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var e=T.read(arguments);return this.setCenterX(e.x),this.setCenterY(e.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(e){return e&&e.width!==r||4===(Array.isArray(e)?e:arguments).length?this._containsRectangle(S.read(arguments)):this._containsPoint(T.read(arguments))},_containsPoint:function(e){var t=e.x,o=e.y;return t>=this.x&&o>=this.y&&t<=this.x+this.width&&o<=this.y+this.height},_containsRectangle:function(e){var t=e.x,o=e.y;return t>=this.x&&o>=this.y&&t+e.width<=this.x+this.width&&o+e.height<=this.y+this.height},intersects:function(){var e=S.read(arguments),t=u.read(arguments)||0;return e.x+e.width>this.x-t&&e.y+e.height>this.y-t&&e.x=4&&(e[1]+=i?"Y":"X");var n=e[i?0:1],a=e[i?1:0],A="get"+n,r="get"+a,s="set"+n,l="set"+a,u="set"+o;this["get"+o]=function(e){return new(e?T:C)(this[A](),this[r](),this,u)},this[u]=function(){var e=T.read(arguments);this[s](e.x),this[l](e.y)}}),{beans:!0})),O=S.extend({initialize:function(e,t,o,i,n,a){this._set(e,t,o,i,!0),this._owner=n,this._setter=a},_set:function(e,t,o,i,n){return this._x=e,this._y=t,this._width=o,this._height=i,n||this._owner[this._setter](this),this}},new function(){var e=S.prototype;return u.each(["x","y","width","height"],(function(e){var t=u.capitalize(e),o="_"+e;this["get"+t]=function(){return this[o]},this["set"+t]=function(e){this[o]=e,this._dontNotify||this._owner[this._setter](this)}}),u.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],(function(t){var o="set"+t;this[o]=function(){this._dontNotify=!0,e[o].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}}),{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(e){var t=this._owner;t._changeSelection&&t._changeSelection(2,e)}}))}),N=u.extend({_class:"Matrix",initialize:function e(t,o){var i=arguments,n=i.length,a=!0;if(n>=6?this._set.apply(this,i):1===n||2===n?t instanceof e?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,o):Array.isArray(t)?this._set.apply(this,o?t.concat([o]):t):a=!1:n?a=!1:this.reset(),!a)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(e,t,o,i,n,a,A){return this._a=e,this._b=t,this._c=o,this._d=i,this._tx=n,this._ty=a,A||this._changed(),this},_serialize:function(e,t){return u.serialize(this.getValues(),e,!0,t)},_changed:function(){var e=this._owner;e&&(e._applyMatrix?e.transform(null,!0):e._changed(25))},clone:function(){return new N(this._a,this._b,this._c,this._d,this._tx,this._ty)},equals:function(e){return e===this||e&&this._a===e._a&&this._b===e._b&&this._c===e._c&&this._d===e._d&&this._tx===e._tx&&this._ty===e._ty},toString:function(){var e=h.instance;return"[["+[e.number(this._a),e.number(this._c),e.number(this._tx)].join(", ")+"], ["+[e.number(this._b),e.number(this._d),e.number(this._ty)].join(", ")+"]]"},reset:function(e){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,e||this._changed(),this},apply:function(e,t){var o=this._owner;return!!o&&(o.transform(null,u.pick(e,!0),t),this.isIdentity())},translate:function(){var e=T.read(arguments),t=e.x,o=e.y;return this._tx+=t*this._a+o*this._c,this._ty+=t*this._b+o*this._d,this._changed(),this},scale:function(){var e=arguments,t=T.read(e),o=T.read(e,0,{readNull:!0});return o&&this.translate(o),this._a*=t.x,this._b*=t.x,this._c*=t.y,this._d*=t.y,o&&this.translate(o.negate()),this._changed(),this},rotate:function(e){e*=Math.PI/180;var t=T.read(arguments,1),o=t.x,i=t.y,n=Math.cos(e),a=Math.sin(e),A=o-o*n+i*a,r=i-o*a-i*n,s=this._a,l=this._b,u=this._c,g=this._d;return this._a=n*s+a*u,this._b=n*l+a*g,this._c=-a*s+n*u,this._d=-a*l+n*g,this._tx+=A*s+r*u,this._ty+=A*l+r*g,this._changed(),this},shear:function(){var e=arguments,t=T.read(e),o=T.read(e,0,{readNull:!0});o&&this.translate(o);var i=this._a,n=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*i,this._d+=t.x*n,o&&this.translate(o.negate()),this._changed(),this},skew:function(){var e=arguments,t=T.read(e),o=T.read(e,0,{readNull:!0}),i=Math.PI/180,n=new T(Math.tan(t.x*i),Math.tan(t.y*i));return this.shear(n,o)},append:function(e,t){if(e){var o=this._a,i=this._b,n=this._c,a=this._d,A=e._a,r=e._c,s=e._b,l=e._d,u=e._tx,g=e._ty;this._a=A*o+s*n,this._c=r*o+l*n,this._b=A*i+s*a,this._d=r*i+l*a,this._tx+=u*o+g*n,this._ty+=u*i+g*a,t||this._changed()}return this},prepend:function(e,t){if(e){var o=this._a,i=this._b,n=this._c,a=this._d,A=this._tx,r=this._ty,s=e._a,l=e._c,u=e._b,g=e._d,c=e._tx,d=e._ty;this._a=s*o+l*i,this._c=s*n+l*a,this._b=u*o+g*i,this._d=u*n+g*a,this._tx=s*A+l*r+c,this._ty=u*A+g*r+d,t||this._changed()}return this},appended:function(e){return this.clone().append(e)},prepended:function(e){return this.clone().prepend(e)},invert:function(){var e=this._a,t=this._b,o=this._c,i=this._d,n=this._tx,a=this._ty,A=e*i-t*o,r=null;return A&&!isNaN(A)&&isFinite(n)&&isFinite(a)&&(this._a=i/A,this._b=-t/A,this._c=-o/A,this._d=e/A,this._tx=(o*a-i*n)/A,this._ty=(t*n-e*a)/A,r=this),r},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new N(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var e=this._a*this._d-this._c*this._b;return e&&!isNaN(e)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(e,t,o){return arguments.length<3?this._transformPoint(T.read(arguments)):this._transformCoordinates(e,t,o)},_transformPoint:function(e,t,o){var i=e.x,n=e.y;return t||(t=new T),t._set(i*this._a+n*this._c+this._tx,i*this._b+n*this._d+this._ty,o)},_transformCoordinates:function(e,t,o){for(var i=0,n=2*o;ia[s]&&(a[s]=r)}return t||(t=new S),t._set(n[0],n[1],a[0]-n[0],a[1]-n[1],o)},inverseTransform:function(){return this._inverseTransform(T.read(arguments))},_inverseTransform:function(e,t,o){var i=this._a,n=this._b,a=this._c,A=this._d,r=this._tx,s=this._ty,l=i*A-n*a,u=null;if(l&&!isNaN(l)&&isFinite(r)&&isFinite(s)){var g=e.x-this._tx,c=e.y-this._ty;t||(t=new T),u=t._set((g*A-c*a)/l,(c*i-g*n)/l,o)}return u},decompose:function(){var e,t,o,i=this._a,n=this._b,a=this._c,A=this._d,r=i*A-n*a,s=Math.sqrt,l=Math.atan2,u=180/Math.PI;if(0!==i||0!==n){var g=s(i*i+n*n);e=Math.acos(i/g)*(n>0?1:-1),t=[g,r/g],o=[l(i*a+n*A,g*g),0]}else if(0!==a||0!==A){var c=s(a*a+A*A);e=Math.asin(a/c)*(A>0?1:-1),t=[r/c,c],o=[0,l(i*a+n*A,c*c)]}else e=0,o=t=[0,0];return{translation:this.getTranslation(),rotation:e*u,scaling:new T(t),skewing:new T(o[0]*u,o[1]*u)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new T(this._tx,this._ty)},getScaling:function(){return this.decompose().scaling},getRotation:function(){return this.decompose().rotation},applyToContext:function(e){this.isIdentity()||e.transform(this._a,this._b,this._c,this._d,this._tx,this._ty)}},u.each(["a","b","c","d","tx","ty"],(function(e){var t=u.capitalize(e),o="_"+e;this["get"+t]=function(){return this[o]},this["set"+t]=function(e){this[o]=e,this._changed()}}),{})),M=u.extend({_class:"Line",initialize:function(e,t,o,i,n){var a=!1;arguments.length>=4?(this._px=e,this._py=t,this._vx=o,this._vy=i,a=n):(this._px=e.x,this._py=e.y,this._vx=t.x,this._vy=t.y,a=o),a||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new T(this._px,this._py)},getVector:function(){return new T(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(e,t){return M.intersect(this._px,this._py,this._vx,this._vy,e._px,e._py,e._vx,e._vy,!0,t)},getSide:function(e,t){return M.getSide(this._px,this._py,this._vx,this._vy,e.x,e.y,!0,t)},getDistance:function(e){return Math.abs(this.getSignedDistance(e))},getSignedDistance:function(e){return M.getSignedDistance(this._px,this._py,this._vx,this._vy,e.x,e.y,!0)},isCollinear:function(e){return T.isCollinear(this._vx,this._vy,e._vx,e._vy)},isOrthogonal:function(e){return T.isOrthogonal(this._vx,this._vy,e._vx,e._vy)},statics:{intersect:function(e,t,o,i,n,a,A,r,s,l){s||(o-=e,i-=t,A-=n,r-=a);var u=o*r-i*A;if(!p.isMachineZero(u)){var g=e-n,c=t-a,d=(A*c-r*g)/u,E=(o*c-i*g)/u,h=-1e-12,m=1+1e-12;if(l||h=1?1:d),new T(e+d*o,t+d*i)}},getSide:function(e,t,o,i,n,a,A,r){A||(o-=e,i-=t);var s=n-e,l=s*i-(a-t)*o;return!r&&p.isMachineZero(l)&&(l=(s*o+s*o)/(o*o+i*i))>=0&&l<=1&&(l=0),l<0?-1:l>0?1:0},getSignedDistance:function(e,t,o,i,n,a,A){return A||(o-=e,i-=t),0===o?i>0?n-e:e-n:0===i?o<0?a-t:t-a:((n-e)*i-(a-t)*o)/(i>o?i*Math.sqrt(1+o*o/(i*i)):o*Math.sqrt(1+i*i/(o*o)))},getDistance:function(e,t,o,i,n,a,A){return Math.abs(M.getSignedDistance(e,t,o,i,n,a,A))}}}),w=d.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(e){d.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new J(null,null,this),this._view=q.create(this,e||se.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(e,t){return u.serialize(this._children,e,!0,t)},_changed:function(e,t){if(1&e){var o=this._view;o&&(o._needsUpdate=!0,!o._requested&&o._autoUpdate&&o.requestUpdate())}var i=this._changes;if(i&&t){var n=this._changesById,a=t._id,A=n[a];A?A.flags|=e:i.push(n[a]={item:t,flags:e})}},clear:function(){for(var e=this._children,t=e.length-1;t>=0;t--)e[t].remove()},isEmpty:function(){return!this._children.length},remove:function e(){return!!e.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(e){this._currentStyle.set(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getLayers:function(){return this._children},getActiveLayer:function(){return this._activeLayer||new D({project:this,insert:!0})},getSymbolDefinitions:function(){var e=[],t={};return this.getItems({class:R,match:function(o){var i=o._definition,n=i._id;return t[n]||(t[n]=!0,e.push(i)),!1}}),e},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var e=this._selectionItems,t=[];for(var o in e){var i=e[o],n=i._selection;1&n&&i.isInserted()?t.push(i):n||this._updateSelection(i)}return t},_updateSelection:function(e){var t=e._id,o=this._selectionItems;e._selection?o[t]!==e&&(this._selectionCount++,o[t]=e):o[t]===e&&(this._selectionCount--,delete o[t])},selectAll:function(){for(var e=this._children,t=0,o=e.length;t0){e.save(),e.strokeWidth=1;var r=this._selectionItems,s=this._scope.settings.handleSize,l=this._updateVersion;for(var g in r)r[g]._drawSelection(e,t,s,r,l);e.restore()}}}),y=u.extend(g,{statics:{extend:function e(t){return t._serializeFields&&(t._serializeFields=u.set({},this.prototype._serializeFields,t._serializeFields)),e.base.apply(this,arguments)},NO_INSERT:{insert:!1}},_class:"Item",_name:null,_applyMatrix:!0,_canApplyMatrix:!0,_canScaleStroke:!1,_pivot:null,_visible:!0,_blendMode:"normal",_opacity:1,_locked:!1,_guide:!1,_clipMask:!1,_selection:0,_selectBounds:!0,_selectChildren:!1,_serializeFields:{name:null,applyMatrix:null,matrix:new N,pivot:null,visible:!0,blendMode:"normal",opacity:1,locked:!1,guide:!1,clipMask:!1,selected:!1,data:{}},_prioritize:["applyMatrix"]},new function(){var e=["onMouseDown","onMouseUp","onMouseDrag","onClick","onDoubleClick","onMouseMove","onMouseEnter","onMouseLeave"];return u.each(e,(function(e){this._events[e]={install:function(e){this.getView()._countItemEvent(e,1)},uninstall:function(e){this.getView()._countItemEvent(e,-1)}}}),{_events:{onFrame:{install:function(){this.getView()._animateItem(this,!0)},uninstall:function(){this.getView()._animateItem(this,!1)}},onLoad:{},onError:{}},statics:{_itemHandlers:e}})},{initialize:function(){},_initialize:function(e,t){var o=e&&u.isPlainObject(e),i=o&&!0===e.internal,n=this._matrix=new N,a=o&&e.project||ce.project,A=ce.settings;return this._id=i?null:m.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&A.applyMatrix,t&&n.translate(t),n._owner=this,this._style=new J(a._currentStyle,this,a),i||o&&0==e.insert||!A.insertItems&&(!o||!0!==e.insert)?this._setProject(a):(o&&e.parent||a)._insertItem(r,this,!0),o&&e!==y.NO_INSERT&&this.set(e,{internal:!0,insert:!0,project:!0,parent:!0}),o},_serialize:function(e,t){var o={},i=this;function n(n){for(var a in n){var A=i[a];u.equals(A,"leading"===a?1.2*n.fontSize:n[a])||(o[a]=u.serialize(A,e,"data"!==a,t))}}return n(this._serializeFields),this instanceof f||n(this._style._defaults),[this._class,o]},_changed:function(e){var t=this._symbol,o=this._parent||t,i=this._project;8&e&&(this._bounds=this._position=this._decomposed=r),16&e&&(this._globalMatrix=r),o&&72&e&&y._clearBoundsCache(o),2&e&&y._clearBoundsCache(this),i&&i._changed(e,this),t&&t._changed(e)},getId:function(){return this._id},getName:function(){return this._name},setName:function(e){if(this._name&&this._removeNamed(),e===+e+"")throw new Error("Names consisting only of numbers are not supported.");var t=this._getOwner();if(e&&t){var o=t._children,i=t._namedChildren;(i[e]=i[e]||[]).push(this),e in o||(o[e]=this)}this._name=e||r,this._changed(256)},getStyle:function(){return this._style},setStyle:function(e){this.getStyle().set(e)}},u.each(["locked","visible","blendMode","opacity","guide"],(function(e){var t=u.capitalize(e),o="_"+e,i={locked:256,visible:265};this["get"+t]=function(){return this[o]},this["set"+t]=function(t){t!=this[o]&&(this[o]=t,this._changed(i[e]||257))}}),{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(e){if(e!==this._selection){this._selection=e;var t=this._project;t&&(t._updateSelection(this),this._changed(257))}},_changeSelection:function(e,t){var o=this._selection;this.setSelection(t?o|e:o&~e)},isSelected:function(){if(this._selectChildren)for(var e=this._children,t=0,o=e.length;t=0;o--)if(t[o].contains(e))return!0;return!1}return e.isInside(this.getInternalBounds())},isInside:function(){return S.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new U.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(e,t){return e instanceof y&&this._asPathItem().getIntersections(e._asPathItem(),null,t,!0).length>0}},new function(){function e(){var e=arguments;return this._hitTest(T.read(e),L.getOptions(e))}function t(){var e=arguments,t=T.read(e),o=L.getOptions(e),i=[];return this._hitTest(t,new u({all:i},o)),i}function o(e,t,o,i){var n=this._children;if(n)for(var a=n.length-1;a>=0;a--){var A=n[a],r=A!==i&&A._hitTest(e,t,o);if(r&&!t.all)return r}return null}return w.inject({hitTest:e,hitTestAll:t,_hitTest:o}),{hitTest:e,hitTestAll:t,_hitTestChildren:o}},{_hitTest:function(e,t,o){if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var i=this._matrix,n=o?o.appended(i):this.getGlobalMatrix().prepend(this.getView()._matrix),a=Math.max(t.tolerance,1e-12),A=t._tolerancePadding=new I(U._getStrokePadding(a,i._shiftless().invert()));if(!(e=i._inverseTransform(e))||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(A.multiply(2))._containsPoint(e))return null;var r,s,l=!(t.guides&&!this._guide||t.selected&&!this.isSelected()||t.type&&t.type!==u.hyphenate(this._class)||t.class&&!(this instanceof t.class)),g=t.match,c=this;function d(e){return e&&g&&!g(e)&&(e=null),e&&t.all&&t.all.push(e),e}function E(t,o){var i=o?r["get"+o]():c.getPosition();if(e.subtract(i).divide(A).length<=1)return new L(t,c,{name:o?u.hyphenate(o):t,point:i})}var h=t.position,p=t.center,m=t.bounds;if(l&&this._parent&&(h||p||m)){if((p||m)&&(r=this.getInternalBounds()),!(s=h&&E("position")||p&&E("center","Center"))&&m)for(var T=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],C=0;C<8&&!s;C++)s=E("bounds",T[C]);s=d(s)}return s||(s=this._hitTestChildren(e,t,n)||l&&d(this._hitTestSelf(e,t,n,this.getStrokeScaling()?null:n._shiftless().invert()))||null),s&&s.point&&(s.point=i.transform(s.point)),s},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new L("fill",this)},matches:function(e,t){var o=typeof e;if("object"===o){for(var i in e)if(e.hasOwnProperty(i)&&!this.matches(i,e[i]))return!1;return!0}if("function"===o)return e(this);if("match"===e)return t(this);var n=/^(empty|editable)$/.test(e)?this["is"+u.capitalize(e)]():"type"===e?u.hyphenate(this._class):this[e];if("class"===e){if("function"==typeof t)return this instanceof t;n=this._class}if("function"==typeof t)return!!t(n);if(t){if(t.test)return t.test(n);if(u.isPlainObject(t))return function e(t,o){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i],a=o[i];if(u.isPlainObject(n)&&u.isPlainObject(a)){if(!e(n,a))return!1}else if(!u.equals(n,a))return!1}return!0}(t,n)}return u.equals(n,t)},getItems:function(e){return y._getItems(this,e,this._matrix)},getItem:function(e){return y._getItems(this,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,o,i,n,a){if(!n){var A="object"==typeof o&&o,r=A&&A.overlapping,s=A&&A.inside,l=(T=r||s)&&S.read([T]);n={items:[],recursive:A&&!1!==A.recursive,inside:!!s,overlapping:!!r,rect:l,path:r&&new U.Rectangle({rectangle:l,insert:!1})},A&&(o=u.filter({},o,{recursive:!0,inside:!0,overlapping:!0}))}var g=t._children,c=n.items;i=(l=n.rect)&&(i||new N);for(var d=0,E=g&&g.length;d0)break}return c}}},{importJSON:function(e){var t=u.importJSON(e,this);return t!==this?this.addChild(t):t},addChild:function(e){return this.insertChild(r,e)},insertChild:function(e,t){var o=t?this.insertChildren(e,[t]):null;return o&&o[0]},addChildren:function(e){return this.insertChildren(this._children.length,e)},insertChildren:function(e,t){var o=this._children;if(o&&t&&t.length>0){for(var i={},n=(t=u.slice(t)).length-1;n>=0;n--){var a=(l=t[n])&&l._id;!l||i[a]?t.splice(n,1):(l._remove(!1,!0),i[a]=!0)}u.splice(o,t,e,0);for(var A=this._project,r=A._changes,s=(n=0,t.length);n=0;i--)o[i]._remove(!0,!1);return o.length>0&&this._changed(11),o},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var e=0,t=this._children.length;e0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(e){return-1===this._getOrder(e)},isBelow:function(e){return 1===this._getOrder(e)},isParent:function(e){return this._parent===e},isChild:function(e){return e&&e._parent===this},isDescendant:function(e){for(var t=this;t=t._parent;)if(t===e)return!0;return!1},isAncestor:function(e){return!!e&&e.isDescendant(this)},isSibling:function(e){return this._parent===e._parent},isGroupedWith:function(e){for(var t=this._parent;t;){if(t._parent&&/^(Group|Layer|CompoundPath)$/.test(t._class)&&e.isDescendant(t))return!0;t=t._parent}return!1}},u.each(["rotate","scale","shear","skew"],(function(e){var t="rotate"===e;this[e]=function(){var o=arguments,i=(t?u:T).read(o),n=T.read(o,0,{readNull:!0});return this.transform((new N)[e](i,n||this.getPosition(!0)))}}),{translate:function(){var e=new N;return this.transform(e.translate.apply(e,arguments))},transform:function(e,t,o){var i=this._matrix,n=e&&!e.isIdentity(),a=o&&this._canApplyMatrix||this._applyMatrix&&(n||!i.isIdentity()||t&&this._children);if(!n&&!a)return this;if(n){!e.isInvertible()&&i.isInvertible()&&(i._backup=i.getValues()),i.prepend(e,!0);var A=this._style,r=A.getFillColor(!0),s=A.getStrokeColor(!0);r&&r.transform(e),s&&s.transform(e)}if(a&&(a=this._transformContent(i,t,o))){var l=this._pivot;l&&i._transformPoint(l,l,!0),i.reset(!0),o&&this._canApplyMatrix&&(this._applyMatrix=!0)}var u=this._bounds,g=this._position;(n||a)&&this._changed(25);var c=n&&u&&e.decompose();if(c&&c.skewing.isZero()&&c.rotation%90==0){for(var d in u){var E=u[d];if(E.nonscaling)delete u[d];else if(a||!E.internal){var h=E.rect;e._transformBounds(h,h)}}this._bounds=u;var p=u[this._getBoundsCacheKey(this._boundsOptions||{})];p&&(this._position=this._getPositionFromBounds(p.rect))}else n&&g&&this._pivot&&(this._position=e._transformPoint(g,g));return this},_transformContent:function(e,t,o){var i=this._children;if(i){for(var n=0,a=i.length;nn:i1&&a<4?-1:1,a>2?-1:1),r=A.multiply(n),s=r.subtract(A.multiply(i));if(new S(o?r.add(A.multiply(o)):r,s).contains(t))return{point:s,quadrant:a}}}function t(e,t,o,i){var n=e.divide(t);return(!i||n.isInQuadrant(i))&&n.subtract(n.normalize()).multiply(t).divide(o).length<=1}return{_contains:function t(o){if("rectangle"===this._type){var i=e(this,o);return i?o.subtract(i.point).divide(this._radius).getLength()<=1:t.base.call(this,o)}return o.divide(this.size).getLength()<=.5},_hitTestSelf:function o(i,n,a,A){var r=!1,s=this._style,l=n.stroke&&s.hasStroke(),u=n.fill&&s.hasFill();if(l||u){var g=this._type,c=this._radius,d=l?s.getStrokeWidth()/2:0,E=n._tolerancePadding.add(U._getStrokePadding(d,!s.getStrokeScaling()&&A));if("rectangle"===g){var h=E.multiply(2),p=e(this,i,h);if(p)r=t(i.subtract(p.point),c,E,p.quadrant);else{var m=new S(this._size).setCenter(0,0),T=m.expand(h),C=m.expand(h.negate());r=T._containsPoint(i)&&!C._containsPoint(i)}}else r=t(i,c,E)}return r?new L(l?"stroke":"fill",this):o.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,o,i,n){var a=u.create(b.prototype);return a._type=e,a._size=o,a._radius=i,a._initialize(u.getNamed(n),t),a}return{Circle:function(){var t=arguments,o=T.readNamed(t,"center"),i=u.readNamed(t,"radius");return e("circle",o,new I(2*i),i,t)},Rectangle:function(){var t=arguments,o=S.readNamed(t,"rectangle"),i=I.min(I.readNamed(t,"radius"),o.getSize(!0).divide(2));return e("rectangle",o.getCenter(!0),o.getSize(!0),i,t)},Ellipse:function(){var t=arguments,o=b._readEllipse(t),i=o.radius;return e("ellipse",o.center,i.multiply(2),i,t)},_readEllipse:function(e){var t,o;if(u.hasNamed(e,"radius"))t=T.readNamed(e,"center"),o=I.readNamed(e,"radius");else{var i=S.readNamed(e,"rectangle");t=i.getCenter(!0),o=i.getSize(!0).divide(2)}return{center:t,radius:o}}}}}),k=y.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:!1,beans:!0,initialize:function(e,t){if(!this._initialize(e,t!==r&&T.read(arguments))){var o,i=typeof e,n="string"===i?l.getElementById(e):"object"===i?e:null;if(n&&n!==y.NO_INSERT)if(n.getContext||null!=n.naturalHeight)o=n;else if(n){var a=I.read(arguments);a.isZero()||(o=se.getCanvas(a))}o?this.setImage(o):this.setSource(e)}this._size||(this._size=new I,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},copyContent:function(e){var t=e._image,o=e._canvas;if(t)this._setImage(t);else if(o){var i=se.getCanvas(e._size);i.getContext("2d").drawImage(o,0,0),this._setImage(i)}this._crossOrigin=e._crossOrigin},getSize:function(){var e=this._size;return new B(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(){var e=I.read(arguments);if(!e.equals(this._size))if(e.width>0&&e.height>0){var t=this.getElement();this._setImage(se.getCanvas(e)),t&&this.getContext(!0).drawImage(t,0,0,e.width,e.height)}else this._canvas&&se.release(this._canvas),this._size=e.clone()},getWidth:function(){return this._size?this._size.width:0},setWidth:function(e){this.setSize(e,this.getHeight())},getHeight:function(){return this._size?this._size.height:0},setHeight:function(e){this.setSize(this.getWidth(),e)},getLoaded:function(){return this._loaded},isEmpty:function(){var e=this._size;return!e||0===e.width&&0===e.height},getResolution:function(){var e=this._matrix,t=new T(0,0).transform(e),o=new T(1,0).transform(e).subtract(t),i=new T(0,1).transform(e).subtract(t);return new I(72/o.getLength(),72/i.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(e){var t=this;function o(e){var o=t.getView(),i=e&&e.type||"load";o&&t.responds(i)&&(ce=o._scope,t.emit(i,new ee(e)))}this._setImage(e),this._loaded?setTimeout(o,0):e&&X.add(e,{load:function(i){t._setImage(e),o(i)},error:o})},_setImage:function(e){this._canvas&&se.release(this._canvas),e&&e.getContext?(this._image=null,this._canvas=e,this._loaded=!0):(this._image=e,this._canvas=null,this._loaded=!!(e&&e.src&&e.complete)),this._size=new I(e?e.naturalWidth||e.width:0,e?e.naturalHeight||e.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var e=se.getContext(this._size);try{this._image&&e.drawImage(this._image,0,0),this._canvas=e.canvas}catch(t){se.release(e)}}return this._canvas},setCanvas:"#setImage",getContext:function(e){return this._context||(this._context=this.getCanvas().getContext("2d")),e&&(this._image=null,this._changed(1025)),this._context},setContext:function(e){this._context=e},getSource:function(){var e=this._image;return e&&e.src||this.toDataURL()},setSource:function(e){var t=new A.Image,o=this._crossOrigin;o&&(t.crossOrigin=o),e&&(t.src=e),this.setImage(t)},getCrossOrigin:function(){var e=this._image;return e&&e.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(e){this._crossOrigin=e;var t=this._image;t&&(t.crossOrigin=e)},getSmoothing:function(){return this._smoothing},setSmoothing:function(e){this._smoothing=e,this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var e=S.read(arguments),t=se.getContext(e.getSize()),o=Math.max(0,e.x),i=Math.max(0,e.y),n=Math.min(this.getCanvas().width,e.x+e.width),a=Math.min(this.getCanvas().height,e.y+e.height);return t.drawImage(this.getCanvas(),o,i,n-o,a-i,o-e.x,i-e.y,n-o,a-i),t.canvas},getSubRaster:function(){var e=S.read(arguments),t=new k(y.NO_INSERT);return t._setImage(this.getSubCanvas(e)),t.translate(e.getCenter().subtract(this.getSize().divide(2))),t._matrix.prepend(this._matrix),t.insertAbove(this),t},toDataURL:function(){var e=this._image,t=e&&e.src;if(/^data:/.test(t))return t;var o=this.getCanvas();return o?o.toDataURL.apply(o,arguments):null},drawImage:function(e){var t=T.read(arguments,1);this.getContext(!0).drawImage(e,t.x,t.y)},getAverageColor:function(e){var t,o;if(e?e instanceof x?(o=e,t=e.getBounds()):"object"==typeof e&&("width"in e?t=new S(e):"x"in e&&(t=new S(e.x-.5,e.y-.5,1,1))):t=this.getBounds(),!t)return null;var i=Math.min(t.width,32),n=Math.min(t.height,32),a=k._sampleContext;a?a.clearRect(0,0,33,33):a=k._sampleContext=se.getContext(new I(32)),a.save();var A=(new N).scale(i/t.width,n/t.height).translate(-t.x,-t.y);A.applyToContext(a),o&&o.draw(a,new u({clip:!0,matrices:[A]})),this._matrix.applyToContext(a);var r=this.getElement(),s=this._size;r&&a.drawImage(r,-s.width/2,-s.height/2),a.restore();for(var l=a.getImageData(.5,.5,Math.ceil(i),Math.ceil(n)).data,g=[0,0,0],c=0,d=0,E=l.length;d0&&i.height>0&&(e.globalAlpha=p.clamp(this._opacity,0,1),this._setStyles(e,t,o),Z.setPrefixed(e,"imageSmoothingEnabled",this._smoothing),e.drawImage(i,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),R=y.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(e,t){this._initialize(e,t!==r&&T.read(arguments,1))||this.setDefinition(e instanceof _?e:new _(e))},_equals:function(e){return this._definition===e._definition},copyContent:function(e){this.setDefinition(e._definition)},getDefinition:function(){return this._definition},setDefinition:function(e){this._definition=e,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(e,t){var o=this._definition._item;return o._getCachedBounds(o._matrix.prepended(e),t)},_hitTestSelf:function(e,t,o){var i=t.extend({all:!1}),n=this._definition._item._hitTest(e,i,o);return n&&(n.item=this),n},_draw:function(e,t){this._definition._item.draw(e,t)}}),_=u.extend({_class:"SymbolDefinition",initialize:function(e,t){this._id=m.get(),this.project=ce.project,e&&this.setItem(e,t)},_serialize:function(e,t){return t.add(this,(function(){return u.serialize([this._class,this._item],e,!1,t)}))},_changed:function(e){8&e&&y._clearBoundsCache(this),1&e&&this.project._changed(e)},getItem:function(){return this._item},setItem:function(e,t){e._symbol&&(e=e.clone()),this._item&&(this._item._symbol=null),this._item=e,e.remove(),e.setSelected(!1),t||e.setPosition(new T),e._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(e){return new R(this,e)},clone:function(){return new _(this._item.clone(!1))},equals:function(e){return e===this||e&&this._item.equals(e._item)||!1}}),L=u.extend({_class:"HitResult",initialize:function(e,t,o){this.type=e,this.item=t,o&&this.inject(o)},statics:{getOptions:function(e){var t=e&&u.read(e);return new u({type:null,tolerance:ce.settings.hitTolerance,fill:!t,stroke:!t,segments:!t,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},t)}}}),v=u.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(e,t,o,i,n,a){var A,s,l,u,g=arguments.length;g>0&&(null==e||"object"==typeof e?1===g&&e&&"point"in e?(A=e.point,s=e.handleIn,l=e.handleOut,u=e.selection):(A=e,s=t,l=o,u=i):(A=[e,t],s=o!==r?[o,i]:null,l=n!==r?[n,a]:null)),new Q(A,this,"_point"),new Q(s,this,"_handleIn"),new Q(l,this,"_handleOut"),u&&this.setSelection(u)},_serialize:function(e,t){var o=this._point,i=this._selection,n=i||this.hasHandles()?[o,this._handleIn,this._handleOut]:o;return i&&n.push(i),u.serialize(n,e,!0,t)},_changed:function(e){var t=this._path;if(t){var o,i=t._curves,n=this._index;i&&(e&&e!==this._point&&e!==this._handleIn||!(o=n>0?i[n-1]:t._closed?i[i.length-1]:null)||o._changed(),e&&e!==this._point&&e!==this._handleOut||!(o=i[n])||o._changed()),t._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(T.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(T.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(T.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var e=this._handleIn,t=this._handleOut;return!e.isZero()&&!t.isZero()&&e.isCollinear(t)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(e){var t=this._selection,o=this._path;this._selection=e=e||0,o&&e!==t&&(o._updateSelection(this,t,e),o._changed(257))},_changeSelection:function(e,t){var o=this._selection;this.setSelection(t?o|e:o&~e)},isSelected:function(){return!!(7&this._selection)},setSelected:function(e){this._changeSelection(7,e)},getIndex:function(){return this._index!==r?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var e=this._path,t=this._index;return e?(t>0&&!e._closed&&t===e._segments.length-1&&t--,e.getCurves()[t]||null):null},getLocation:function(){var e=this.getCurve();return e?new Y(e,this===e._segment1?0:1):null},getNext:function(){var e=this._path&&this._path._segments;return e&&(e[this._index+1]||this._path._closed&&e[0])||null},smooth:function(e,t,o){var i=e||{},n=i.type,a=i.factor,A=this.getPrevious(),s=this.getNext(),l=(A||this)._point,u=this._point,g=(s||this)._point,c=l.getDistance(u),d=u.getDistance(g);if(n&&"catmull-rom"!==n){if("geometric"!==n)throw new Error("Smoothing method '"+n+"' not supported.");if(A&&s){var E=l.subtract(g),h=a===r?.4:a,p=h*c/(c+d);t||this.setHandleIn(E.multiply(p)),o||this.setHandleOut(E.multiply(p-h))}}else{var m=a===r?.5:a,C=Math.pow(c,m),I=C*C,B=Math.pow(d,m),S=B*B;if(!t&&A){var O=2*S+3*B*C+I,N=3*B*(B+C);this.setHandleIn(0!==N?new T((S*l._x+O*u._x-I*g._x)/N-u._x,(S*l._y+O*u._y-I*g._y)/N-u._y):new T)}if(!o&&s){O=2*I+3*C*B+S,N=3*C*(C+B);this.setHandleOut(0!==N?new T((I*g._x+O*u._x-S*l._x)/N-u._x,(I*g._y+O*u._y-S*l._y)/N-u._y):new T)}}},getPrevious:function(){var e=this._path&&this._path._segments;return e&&(e[this._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._index},isLast:function(){var e=this._path;return e&&this._index===e._segments.length-1||!1},reverse:function(){var e=this._handleIn,t=this._handleOut,o=e.clone();e.set(t),t.set(o)},reversed:function(){return new v(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new v(this._point,this._handleIn,this._handleOut)},equals:function(e){return e===this||e&&this._class===e._class&&this._point.equals(e._point)&&this._handleIn.equals(e._handleIn)&&this._handleOut.equals(e._handleOut)||!1},toString:function(){var e=["point: "+this._point];return this._handleIn.isZero()||e.push("handleIn: "+this._handleIn),this._handleOut.isZero()||e.push("handleOut: "+this._handleOut),"{ "+e.join(", ")+" }"},transform:function(e){this._transformCoordinates(e,new Array(6),!0),this._changed()},interpolate:function(e,t,o){var i=1-o,n=o,a=e._point,A=t._point,r=e._handleIn,s=t._handleIn,l=t._handleOut,u=e._handleOut;this._point._set(i*a._x+n*A._x,i*a._y+n*A._y,!0),this._handleIn._set(i*r._x+n*s._x,i*r._y+n*s._y,!0),this._handleOut._set(i*u._x+n*l._x,i*u._y+n*l._y,!0),this._changed()},_transformCoordinates:function(e,t,o){var i=this._point,n=o&&this._handleIn.isZero()?null:this._handleIn,a=o&&this._handleOut.isZero()?null:this._handleOut,A=i._x,r=i._y,s=2;return t[0]=A,t[1]=r,n&&(t[s++]=n._x+A,t[s++]=n._y+r),a&&(t[s++]=a._x+A,t[s++]=a._y+r),e&&(e._transformCoordinates(t,t,s/2),A=t[0],r=t[1],o?(i._x=A,i._y=r,s=2,n&&(n._x=t[s++]-A,n._y=t[s++]-r),a&&(a._x=t[s++]-A,a._y=t[s++]-r)):(n||(t[s++]=A,t[s++]=r),a||(t[s++]=A,t[s++]=r))),t}}),Q=T.extend({initialize:function(e,t,o){var i,n,a;if(e)if((i=e[0])!==r)n=e[1];else{var A=e;(i=A.x)===r&&(i=(A=T.read(arguments)).x),n=A.y,a=A.selected}else i=n=0;this._x=i,this._y=n,this._owner=t,t[o]=this,a&&this.setSelected(!0)},_set:function(e,t){return this._x=e,this._y=t,this._owner._changed(this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner._changed(this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner._changed(this)},isZero:function(){var e=p.isZero;return e(this._x)&&e(this._y)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){var e=this._owner;return this===e._point?1:this===e._handleIn?2:this===e._handleOut?4:0}}),F=u.extend({_class:"Curve",beans:!0,initialize:function(e,t,o,i,n,a,A,r){var s,l,u,g,c,d,E=arguments.length;3===E?(this._path=e,s=t,l=o):E?1===E?"segment1"in e?(s=new v(e.segment1),l=new v(e.segment2)):"point1"in e?(u=e.point1,c=e.handle1,d=e.handle2,g=e.point2):Array.isArray(e)&&(u=[e[0],e[1]],g=[e[6],e[7]],c=[e[2]-e[0],e[3]-e[1]],d=[e[4]-e[6],e[5]-e[7]]):2===E?(s=new v(e),l=new v(t)):4===E?(u=e,c=t,d=o,g=i):8===E&&(u=[e,t],g=[A,r],c=[o-e,i-t],d=[n-A,a-r]):(s=new v,l=new v),this._segment1=s||new v(u,null,c),this._segment2=l||new v(g,d,null)},_serialize:function(e,t){return u.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],e,!0,t)},_changed:function(){this._length=this._bounds=r},clone:function(){return new F(this._segment1,this._segment2)},toString:function(){var e=["point1: "+this._segment1._point];return this._segment1._handleOut.isZero()||e.push("handle1: "+this._segment1._handleOut),this._segment2._handleIn.isZero()||e.push("handle2: "+this._segment2._handleIn),e.push("point2: "+this._segment2._point),"{ "+e.join(", ")+" }"},classify:function(){return F.classify(this.getValues())},remove:function(){var e=!1;if(this._path){var t=this._segment2,o=t._handleOut;(e=t.remove())&&this._segment1._handleOut.set(o)}return e},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(T.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(T.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(T.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(T.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 e=this._path&&this._path._curves;return e&&(e[this._segment1._index+1]||this._path._closed&&e[0])||null},getPrevious:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._segment1._index},isLast:function(){var e=this._path;return e&&this._segment1._index===e._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle1().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(e){this.getPoint1().setSelected(e),this.getHandle1().setSelected(e),this.getHandle2().setSelected(e),this.getPoint2().setSelected(e)},getValues:function(e){return F.getValues(this._segment1,this._segment2,e)},getPoints:function(){for(var e=this.getValues(),t=[],o=0;o<8;o+=2)t.push(new T(e[o],e[o+1]));return t}},{getLength:function(){return null==this._length&&(this._length=F.getLength(this.getValues(),0,1)),this._length},getArea:function(){return F.getArea(this.getValues())},getLine:function(){return new M(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new F(F.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return F.getLength(this.getValues(),e,t)},divideAt:function(e){return this.divideAtTime(e&&e.curve===this?e.time:this.getTimeAt(e))},divideAtTime:function(e,t){var o=null;if(e>=1e-8&&e<=.99999999){var i=F.subdivide(this.getValues(),e),n=i[0],a=i[1],A=t||this.hasHandles(),r=this._segment1,s=this._segment2,l=this._path;A&&(r._handleOut._set(n[2]-n[0],n[3]-n[1]),s._handleIn._set(a[4]-a[6],a[5]-a[7]));var u=n[6],g=n[7],c=new v(new T(u,g),A&&new T(n[4]-u,n[5]-g),A&&new T(a[2]-u,a[3]-g));l?(l.insert(r._index+1,c),o=this.getNext()):(this._segment2=c,this._changed(),o=new F(c,s))}return o},splitAt:function(e){var t=this._path;return t?t.splitAt(e):null},splitAtTime:function(e){return this.splitAt(this.getLocationAtTime(e))},divide:function(e,t){return this.divideAtTime(e===r?.5:t?e:this.getTimeAt(e))},split:function(e,t){return this.splitAtTime(e===r?.5:t?e:this.getTimeAt(e))},reversed:function(){return new F(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut._set(0,0),this._segment2._handleIn._set(0,0)},statics:{getValues:function(e,t,o,i){var n=e._point,a=e._handleOut,A=t._handleIn,r=t._point,s=n.x,l=n.y,u=r.x,g=r.y,c=i?[s,l,s,l,u,g,u,g]:[s,l,s+a._x,l+a._y,u+A._x,g+A._y,u,g];return o&&o._transformCoordinates(c,c,4),c},subdivide:function(e,t){var o=e[0],i=e[1],n=e[2],a=e[3],A=e[4],s=e[5],l=e[6],u=e[7];t===r&&(t=.5);var g=1-t,c=g*o+t*n,d=g*i+t*a,E=g*n+t*A,h=g*a+t*s,p=g*A+t*l,m=g*s+t*u,T=g*c+t*E,C=g*d+t*h,I=g*E+t*p,B=g*h+t*m,S=g*T+t*I,O=g*C+t*B;return[[o,i,c,d,T,C,S,O],[S,O,I,B,p,m,l,u]]},getMonoCurves:function(e,t){var o=[],i=t?0:1,n=e[i+0],a=e[i+2],A=e[i+4],r=e[i+6];if(n>=a==a>=A&&a>=A==A>=r||F.isStraight(e))o.push(e);else{var s=3*(a-A)-n+r,l=2*(n+A)-4*a,u=a-n,g=[],c=p.solveQuadratic(s,l,u,g,1e-8,.99999999);if(c){g.sort();var d=g[0],E=F.subdivide(e,d);o.push(E[0]),c>1&&(d=(g[1]-d)/(1-d),E=F.subdivide(E[1],d),o.push(E[0])),o.push(E[1])}else o.push(e)}return o},solveCubic:function(e,t,o,i,n,a){var A=e[t],r=e[t+2],s=e[t+4],l=e[t+6],u=0;if(!(Ao&&l>o&&r>o&&s>o)){var g=3*(r-A),c=3*(s-r)-g,d=l-A-g-c;u=p.solveCubic(d,c,g,A-o,i,n,a)}return u},getTimeOf:function(e,t){var o=new T(e[0],e[1]),i=new T(e[6],e[7]),n=1e-7;if(null===(t.isClose(o,1e-12)?0:t.isClose(i,1e-12)?1:null))for(var a=[t.x,t.y],A=[],r=0;r<2;r++)for(var s=F.solveCubic(e,r,a[r],A,0,1),l=0;l.999999999999?1:F.getTimeOf(e,new T(o+r*n,i+r*a))}var s=1/0,l=0;function u(o){if(o>=0&&o<=1){var i=t.getDistance(F.getPoint(e,o),!0);if(i1e-8;)u(l-c)||u(l+c)||(c/=2);return l},getPart:function(e,t,o){var i=t>o;if(i){var n=t;t=o,o=n}return t>0&&(e=F.subdivide(e,t)[1]),o<1&&(e=F.subdivide(e,(o-t)/(1-t))[0]),i?[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]]:e},isFlatEnough:function(e,t){var o=e[0],i=e[1],n=e[2],a=e[3],A=e[4],r=e[5],s=e[6],l=e[7],u=3*n-2*o-s,g=3*a-2*i-l,c=3*A-2*s-o,d=3*r-2*l-i;return Math.max(u*u,c*c)+Math.max(g*g,d*d)<=16*t*t},getArea:function(e){var t=e[0],o=e[1],i=e[2],n=e[3],a=e[4],A=e[5],r=e[6],s=e[7];return 3*((s-o)*(i+a)-(r-t)*(n+A)+n*(t-a)-i*(o-A)+s*(a+t/3)-r*(A+o/3))/20},getBounds:function(e){for(var t=e.slice(0,2),o=t.slice(),i=[0,0],n=0;n<2;n++)F._addBounds(e[n],e[n+2],e[n+4],e[n+6],n,0,t,o,i);return new S(t[0],t[1],o[0]-t[0],o[1]-t[1])},_addBounds:function(e,t,o,i,n,a,A,r,s){function l(e,t){var o=e-t,i=e+t;or[n]&&(r[n]=i)}a/=2;var u=A[n]-a,g=r[n]+a;if(eg||t>g||o>g||i>g)if(t=0&&r<=1&&s<=0&&s>=-1}}return!1},isLinear:function(e,t,o,i){var n=i.subtract(e).divide(3);return t.equals(n)&&o.negate().equals(n)}},(function(e,t){this[t]=function(t){var o=this._segment1,i=this._segment2;return e(o._point,o._handleOut,i._handleIn,i._point,t)},this.statics[t]=function(t,o){var i=t[0],n=t[1],a=t[6],A=t[7];return e(new T(i,n),new T(t[2]-i,t[3]-n),new T(t[4]-a,t[5]-A),new T(a,A),o)}}),{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(e){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(e||0)},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.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(e,t){return this.getLocationAtTime(t?e:this.getTimeAt(e))},getLocationAtTime:function(e){return null!=e&&e>=0&&e<=1?new Y(this,e):null},getTimeAt:function(e,t){return F.getTimeAt(this.getValues(),e,t)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var e=T.read(arguments);return e.isZero()?[]:F.getTimesWithTangent(this.getValues(),e)},getOffsetAtTime:function(e){return this.getPartLength(0,e)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(T.read(arguments)))},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getTimeOf:function(){return F.getTimeOf(this.getValues(),T.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var e=T.read(arguments),t=this.getValues(),o=F.getNearestTime(t,e),i=F.getPoint(t,o);return new Y(this,o,i,null,e.getDistance(i))},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e?e.getPoint():e}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return u.each(e,(function(e){this[e+"At"]=function(t,o){var i=this.getValues();return F[e](i,o?t:F.getTimeAt(i,t))},this[e+"AtTime"]=function(t){return F[e](this.getValues(),t)}}),{statics:{_evaluateMethods:e}})},new function(){function e(e){var t=e[0],o=e[1],i=e[2],n=e[3],a=e[4],A=e[5],r=e[6],s=e[7],l=9*(i-a)+3*(r-t),u=6*(t+a)-12*i,g=3*(i-t),c=9*(n-A)+3*(s-o),d=6*(o+A)-12*n,E=3*(n-o);return function(e){var t=(l*e+u)*e+g,o=(c*e+d)*e+E;return Math.sqrt(t*t+o*o)}}function t(e,t){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(t-e))))}function o(e,t,o,i){if(null==t||t<0||t>1)return null;var n=e[0],a=e[1],A=e[2],r=e[3],s=e[4],l=e[5],u=e[6],g=e[7],c=p.isZero;c(A-n)&&c(r-a)&&(A=n,r=a),c(s-u)&&c(l-g)&&(s=u,l=g);var d,E,h=3*(A-n),m=3*(s-A)-h,C=u-n-h-m,I=3*(r-a),B=3*(l-r)-I,S=g-a-I-B;if(0===o)d=0===t?n:1===t?u:((C*t+m)*t+h)*t+n,E=0===t?a:1===t?g:((S*t+B)*t+I)*t+a;else{var O=1e-8,N=1-O;if(tN?(d=3*(u-s),E=3*(g-l)):(d=(3*C*t+2*m)*t+h,E=(3*S*t+2*B)*t+I),i){0===d&&0===E&&(tN)&&(d=s-A,E=l-r);var M=Math.sqrt(d*d+E*E);M&&(d/=M,E/=M)}if(3===o){s=6*C*t+2*m,l=6*S*t+2*B;var w=Math.pow(d*d+E*E,1.5);d=0!==w?(d*l-E*s)/w:0,E=0}}return 2===o?new T(E,-d):new T(d,E)}return{statics:{classify:function(e){var t=e[0],o=e[1],i=e[2],n=e[3],a=e[4],A=e[5],s=e[6],l=e[7],u=i*(o-l)+n*(s-t)+t*l-o*s,g=3*(a*(n-o)+A*(t-i)+i*o-n*t),c=g-u,d=c-u+(t*(l-A)+o*(a-s)+s*A-l*a),E=Math.sqrt(d*d+c*c+g*g),h=0!==E?1/E:0,m=p.isZero,T="serpentine";function C(e,t,o){var i=t!==r,n=i&&t>0&&t<1,a=i&&o>0&&o<1;return!i||(n||a)&&("loop"!==e||n&&a)||(e="arch",n=a=!1),{type:e,roots:n||a?n&&a?t0?Math.sqrt(I/3):Math.sqrt(-I),S=2*d;return C(I>0?T:"loop",(c+B)/S,(c-B)/S)},getLength:function(o,i,n,a){if(i===r&&(i=0),n===r&&(n=1),F.isStraight(o)){var A=o;n<1&&(A=F.subdivide(A,n)[0],i/=n),i>0&&(A=F.subdivide(A,i)[1]);var s=A[6]-A[0],l=A[7]-A[1];return Math.sqrt(s*s+l*l)}return p.integrate(a||e(o),i,n,t(i,n))},getTimeAt:function(o,i,n){if(n===r&&(n=i<0?1:0),0===i)return n;var a=Math.abs,A=i>0,s=A?n:0,l=A?1:n,u=e(o),g=F.getLength(o,s,l,u),c=a(i)-g;if(a(c)<1e-12)return A?l:s;if(c>1e-12)return null;var d=i/g,E=0;return p.findRoot((function(e){return E+=p.integrate(u,n,e,t(n,e)),n=e,E-i}),u,n+d,s,l,32,1e-12)},getPoint:function(e,t){return o(e,t,0,!1)},getTangent:function(e,t){return o(e,t,1,!0)},getWeightedTangent:function(e,t){return o(e,t,1,!1)},getNormal:function(e,t){return o(e,t,2,!0)},getWeightedNormal:function(e,t){return o(e,t,2,!1)},getCurvature:function(e,t){return o(e,t,3,!1).x},getPeaks:function(e){var t=e[0],o=e[1],i=e[2],n=e[3],a=e[4],A=e[5],r=3*i-t-3*a+e[6],s=3*t-6*i+3*a,l=-3*t+3*i,u=3*n-o-3*A+e[7],g=3*o-6*n+3*A,c=-3*o+3*n,d=[];return p.solveCubic(9*(r*r+u*u),9*(r*s+g*u),2*(s*s+g*g)+3*(l*r+c*u),l*s+g*c,d,1e-8,.99999999),d.sort()}}}},new function(){function e(e,t,o,i,n,a,A){var r=!A&&o.getPrevious()===n,s=!A&&o!==n&&o.getNext()===n,l=1e-8,u=1-l;if(null!==i&&i>=(r?l:0)&&i<=(s?u:1)&&null!==a&&a>=(s?l:0)&&a<=(r?u:1)){var g=new Y(o,i,null,A),c=new Y(n,a,null,A);g._intersection=c,c._intersection=g,t&&!t(g)||Y.insert(e,g,!0)}}function t(i,n,a,A,r,s,l,u,g,c,d,E,h){if(++g>=4096||++u>=40)return g;var p,m,T=n[0],C=n[1],I=n[6],B=n[7],S=M.getSignedDistance,O=S(T,C,I,B,n[2],n[3]),N=S(T,C,I,B,n[4],n[5]),w=O*N>0?3/4:4/9,y=w*Math.min(0,O,N),f=w*Math.max(0,O,N),D=S(T,C,I,B,i[0],i[1]),b=S(T,C,I,B,i[2],i[3]),k=S(T,C,I,B,i[4],i[5]),R=S(T,C,I,B,i[6],i[7]),_=function(e,t,o,i){var n,a=[0,e],A=[1/3,t],r=[2/3,o],s=[1,i],l=t-(2*e+i)/3,u=o-(e+2*i)/3;if(l*u<0)n=[[a,A,s],[a,r,s]];else{var g=l/u;n=[g>=2?[a,A,s]:g<=.5?[a,r,s]:[a,A,r,s],[a,s]]}return(l||u)<0?n.reverse():n}(D,b,k,R),L=_[0],v=_[1];if(0===O&&0===N&&0===D&&0===b&&0===k&&0===R||null==(p=o(L,v,y,f))||null==(m=o(L.reverse(),v.reverse(),y,f)))return g;var Q=c+(d-c)*p,Y=c+(d-c)*m;if(Math.max(h-E,Y-Q)<1e-9){var x=(Q+Y)/2,U=(E+h)/2;e(r,s,l?A:a,l?U:x,l?a:A,l?x:U)}else{i=F.getPart(i,p,m);var G=h-E;if(m-p>.8)if(Y-Q>G){x=(Q+Y)/2;g=t(n,(P=F.subdivide(i,.5))[0],A,a,r,s,!l,u,g,E,h,Q,x),g=t(n,P[1],A,a,r,s,!l,u,g,E,h,x,Y)}else{var P;U=(E+h)/2;g=t((P=F.subdivide(n,.5))[0],i,A,a,r,s,!l,u,g,E,U,Q,Y),g=t(P[1],i,A,a,r,s,!l,u,g,U,h,Q,Y)}else g=0===G||G>=1e-9?t(n,i,A,a,r,s,!l,u,g,E,h,Q,Y):t(i,n,a,A,r,s,l,u,g,Q,Y,E,h)}return g}function o(e,t,o,n){return e[0][1]n?i(t,!1,n):e[0][0]}function i(e,t,o){for(var i=e[0][0],n=e[0][1],a=1,A=e.length;a=o:s<=o)return s===o?r:i+(o-n)*(r-i)/(s-n);i=r,n=s}return null}function n(e,t,o,i,n){var a=p.isZero;if(a(i)&&a(n)){var A=F.getTimeOf(e,new T(t,o));return null===A?[]:[A]}for(var r=Math.atan2(-n,i),s=Math.sin(r),l=Math.cos(r),u=[],g=[],c=0;c<8;c+=2){var d=e[c]-t,E=e[c+1]-o;u.push(d*l-E*s,d*s+E*l)}return F.solveCubic(u,1,0,g,0,1),g}function a(t,o,i,a,A,r,s){for(var l=o[0],u=o[1],g=n(t,l,u,o[6]-l,o[7]-u),c=0,d=g.length;cc(i[0],i[2],i[4],i[6])&&c(o[0],o[2],o[4],o[6])-gc(i[1],i[3],i[5],i[7])&&c(o[1],o[3],o[5],o[7])-g>1,N=1&h,M=6*O,w=6*N,y=new T(o[M],o[M+1]),f=new T(i[w],i[w+1]);y.isClose(f,g)&&e(s,u,n,O,r,N)}}}return s}function s(t,o,i,n){var a=F.classify(t);if("loop"===a.type){var A=a.roots;e(i,n,o,A[0],o,A[1])}return i}function l(e,t){function o(e){var t=e[6]-e[0],o=e[7]-e[1];return t*t+o*o}var i=Math.abs,n=M.getDistance,a=1e-7,A=F.isStraight(e),r=F.isStraight(t),s=A&&r,l=o(e)>1,O=F.getTimeOf(p[I],new T(p[B][S?6:0],p[B][S?7:1]));if(null!=O){var N=I?[S,O]:[O,S];(!m.length||i(N[0]-m[0][0])>1e-8&&i(N[1]-m[0][1])>1e-8)&&m.push(N)}if(C>2&&!m.length)break}if(2!==m.length)m=null;else if(!s){var w=F.getPart(e,m[0][0],m[1][0]),y=F.getPart(t,m[0][1],m[1][1]);(i(y[2]-w[2])>a||i(y[3]-w[3])>a||i(y[4]-w[4])>a||i(y[5]-w[5])>a)&&(m=null)}return m}return{getIntersections:function(e){var t=this.getValues(),o=e&&e!==this&&e.getValues();return o?r(t,o,this,e,[]):s(t,this,[])},statics:{getOverlaps:l,getIntersections:function(e,t,o,i,n,a){var A=!t;A&&(t=e);for(var l=e.length,u=t.length,g=new Array(l),c=A?g:new Array(u),d=[],h=0;hm){var O=t[S];r(C,c[S],T,O,d,o)}}}return d},getCurveLineIntersections:n,getTimesWithTangent:function(e,t){var o=e[0],i=e[1],n=e[2],a=e[3],A=e[4],r=e[5],s=e[6],l=e[7],u=t.normalize(),g=u.x,c=u.y,d=3*s-9*A+9*n-3*o,E=3*l-9*r+9*a-3*i,h=6*A-12*n+6*o,m=6*r-12*a+6*i,T=3*n-3*o,C=3*a-3*i,I=2*d*c-2*E*g,B=[];if(Math.abs(I)=0&&S<=1&&B.push(S)}}else{var O=(h*h-4*d*T)*c*c+(-2*h*m+4*E*T+4*d*C)*g*c+(m*m-4*E*C)*g*g,N=h*c-m*g;if(O>=0&&0!=I){var M=Math.sqrt(O),w=-(N+M)/I,y=(-N+M)/I;w>=0&&w<=1&&B.push(w),y>=0&&y<=1&&B.push(y)}}return B}}}}),Y=u.extend({_class:"CurveLocation",initialize:function(e,t,o,i,n){if(t>=.99999999){var a=e.getNext();a&&(t=0,e=a)}this._setCurve(e),this._time=t,this._point=o||e.getPointAtTime(t),this._overlap=i,this._distance=n,this._intersection=this._next=this._previous=null},_setPath:function(e){this._path=e,this._version=e?e._version:0},_setCurve:function(e){this._setPath(e._path),this._curve=e,this._segment=null,this._segment1=e._segment1,this._segment2=e._segment2},_setSegment:function(e){var t=e.getCurve();t?this._setCurve(t):(this._setPath(e._path),this._segment1=e,this._segment2=null),this._segment=e,this._time=e===this._segment1?0:1,this._point=e._point.clone()},getSegment:function(){var e=this._segment;if(!e){var t=this.getCurve(),o=this.getTime();0===o?e=t._segment1:1===o?e=t._segment2:null!=o&&(e=t.getPartLength(0,o)=i&&t<=n,A=o>=i&&o<=n;if(a&&A)return!this.isTouching();var r=this.getCurve(),s=r&&tn&&(r=r.getNext()),o>n&&(l=l.getNext()),!(s&&r&&u&&l))return!1;var g=[];function c(e,t){var o=e.getValues(),i=F.classify(o).roots||F.getPeaks(o),n=i.length,a=F.getLength(o,t&&n?i[n-1]:0,!t&&n?i[0]:1);g.push(n?a:a/32)}function d(e,t,o){return tt&&et||e=-1&&a<=i;a+=n){var A=e[(a%i+i)%i];if(!t.getPoint().isClose(A.getPoint(),1e-7))break;if(t.equals(A))return A}return null}for(;n<=a;){var r,s=n+a>>>1,l=e[s];if(o&&(r=t.equals(l)?l:A(s,-1)||A(s,1)))return t._overlap&&(r._overlap=r._intersection._overlap=!0),r;var u=t.getPath(),g=l.getPath();(u!==g?u._id-g._id:t.getIndex()+t.getTime()-(l.getIndex()+l.getTime()))<0?a=s-1:n=s+1}return e.splice(n,0,t),t}return{statics:{insert:e,expand:function(t){for(var o=t.slice(),i=t.length-1;i>=0;i--)e(o,t[i]._intersection,!1);return o}}}}),x=y.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(e){var t,o,i;if(u.isPlainObject(e)?(o=e.segments,t=e.pathData):Array.isArray(e)?o=e:"string"==typeof e&&(t=e),o){var n=o[0];i=n&&Array.isArray(n[0])}else t&&(i=(t.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(t));return new(i?G:U)(e)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(e){this.isClockwise()!=(e=!!e)&&this.reverse()},setPathData:function(e){var t,o,i,n=e&&e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),a=!1,A=new T,r=new T;function s(e,o){var i=+t[e];return a&&(i+=A[o]),i}function l(e){return new T(s(e,"x"),s(e+1,"y"))}this.clear();for(var u=0,g=n&&n.length;ul&&this[i?"removeSegments":"removeChildren"](l,s);for(g=0;g=0&&t;l--){var u=o[l];t=!1;var g=s[l];if(g)for(var c=g.length-1;c>=0&&!t;c--)u.compare(i[g[c]])&&(A[g[c]]||(A[g[c]]=!0,r++),t=!0)}t=t&&r===a}return t}}),U=x.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(e){this._closed=!1,this._segments=[],this._version=0;var t=arguments,o=Array.isArray(e)?"object"==typeof e[0]?e:t:!e||e.size!==r||e.x===r&&e.point===r?null:t;o&&o.length>0?this.setSegments(o):(this._curves=r,this._segmentSelection=0,o||"string"!=typeof e||(this.setPathData(e),e=null)),this._initialize(!o&&e)},_equals:function(e){return this._closed===e._closed&&u.equals(this._segments,e._segments)},copyContent:function(e){this.setSegments(e._segments),this._closed=e._closed},_changed:function e(t){if(e.base.call(this,t),8&t){if(this._length=this._area=r,32&t)this._version++;else if(this._curves)for(var o=0,i=this._curves.length;o0&&(m(u[0],!0),p.push("z")),p.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(e){for(var t=this._segments,o=new Array(6),i=0,n=t.length;i0&&t+n-1===l?t-1:t,c=g,d=Math.min(g+n,l);e._curves&&(i.splice.apply(i,[g,0].concat(e._curves)),c+=e._curves.length);for(A=c;A0?e-1:e},add:function(e){var t=arguments;return t.length>1&&"number"!=typeof e?this._add(v.readList(t)):this._add([v.read(t)])[0]},insert:function(e,t){var o=arguments;return o.length>2&&"number"!=typeof t?this._add(v.readList(o,1),e):this._add([v.read(o,1)],e)[0]},addSegment:function(){return this._add([v.read(arguments)])[0]},insertSegment:function(e){return this._add([v.read(arguments,1)],e)[0]},addSegments:function(e){return this._add(v.readList(e))},insertSegments:function(e,t){return this._add(v.readList(t),e)},removeSegment:function(e){return this.removeSegments(e,e+1)[0]||null},removeSegments:function(e,t,o){e=e||0,t=u.pick(t,this._segments.length);var i=this._segments,n=this._curves,a=i.length,A=i.splice(e,t-e),r=A.length;if(!r)return A;for(var s=0;s0&&t===a+(this._closed?1:0)?e-1:e;for(s=(n=n.splice(c,r)).length-1;s>=0;s--)n[s]._path=null;o&&(A._curves=n.slice(1)),this._adjustCurves(c,c)}return this._changed(41),A},clear:"#removeSegments",hasHandles:function(){for(var e=this._segments,t=0,o=e.length;t0&&this._segmentSelection===7*e},setFullySelected:function(e){e&&this._selectSegments(!0),this.setSelected(e)},setSelection:function e(t){1&t||this._selectSegments(!1),e.base.call(this,t)},_selectSegments:function(e){var t=this._segments,o=t.length,i=e?7:0;this._segmentSelection=i*o;for(var n=0;n0&&this.setSelected(!0)},divideAt:function(e){var t,o=this.getLocationAt(e);return o&&(t=o.getCurve().divideAt(o.getCurveOffset()))?t._segment1:null},splitAt:function(e){var t=this.getLocationAt(e),o=t&&t.index,i=t&&t.time;i>.99999999&&(o++,i=0);var n=this.getCurves();if(o>=0&&o=1e-8&&n[o++].divideAtTime(i);var a,A=this.removeSegments(o,this._segments.length,!0);return this._closed?(this.setClosed(!1),a=this):((a=new U(y.NO_INSERT)).insertAbove(this),a.copyAttributes(this)),a._add(A,0),this.addSegment(A[0]),a}return null},split:function(e,t){var o,i=t===r?e:(o=this.getCurves()[e])&&o.getLocationAtTime(t);return null!=i?this.splitAt(i):null},join:function(e,t){var o=t||0;if(e&&e!==this){var i=e._segments,n=this.getLastSegment(),a=e.getLastSegment();if(!a)return this;n&&n._point.isClose(a._point,o)&&e.reverse();var A=e.getFirstSegment();if(n&&n._point.isClose(A._point,o))n.setHandleOut(A._handleOut),this._add(i.slice(1));else{var r=this.getFirstSegment();r&&r._point.isClose(A._point,o)&&e.reverse(),a=e.getLastSegment(),r&&r._point.isClose(a._point,o)?(r.setHandleIn(a._handleIn),this._add(i.slice(0,i.length-1),0)):this._add(i.slice())}e._closed&&this._add([i[0]]),e.remove()}var s=this.getFirstSegment(),l=this.getLastSegment();return s!==l&&s._point.isClose(l._point,o)&&(s.setHandleIn(l._handleIn),l.remove(),this.setClosed(!0)),this},reduce:function(e){for(var t=this.getCurves(),o=e&&e.simplify,i=o?1e-7:0,n=t.length-1;n>=0;n--){var a=t[n];!a.hasHandles()&&(!a.hasLength(i)||o&&a.isCollinear(a.getNext()))&&a.remove()}return this},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;e0&&i.push(new v(t[o-1].curve.slice(6))),this.setSegments(i)},simplify:function(e){var t=new j(this).fit(e||2.5);return t&&this.setSegments(t),!!t},smooth:function(e){var t=this,o=e||{},i=o.type||"asymmetric",n=this._segments,a=n.length,A=this._closed;function s(e,o){var i=e&&e.index;if(null!=i){var n=e.path;if(n&&n!==t)throw new Error(e._class+" "+i+" of "+n+" is not part of "+t);o&&e instanceof F&&i++}else i="number"==typeof e?e:o;return Math.min(i<0&&A?i%a:i<0?i+a:i,a-1)}var l=A&&o.from===r&&o.to===r,u=s(o.from,0),g=s(o.to,a-1);if(u>g)if(A)u-=a;else{var c=u;u=g,g=c}if(/^(?:asymmetric|continuous)$/.test(i)){var d="asymmetric"===i,E=Math.min,h=g-u+1,p=h-1,m=l?E(h,4):1,T=m,C=m,I=[];if(A||(T=E(1,u),C=E(1,a-g-1)),(p+=T+C)<=1)return;for(var B=0,S=u-T;B<=p;B++,S++)I[B]=n[(S<0?S+a:S)%a]._point;var O=I[0]._x+2*I[1]._x,N=I[0]._y+2*I[1]._y,M=2,w=p-1,y=[O],f=[N],D=[M],b=[],k=[];for(B=1;B=0;B--)b[B]=(y[B]-b[B+1])/D[B],k[B]=(f[B]-k[B+1])/D[B];b[p]=(3*I[p]._x-b[w])/2,k[p]=(3*I[p]._y-k[w])/2;B=T;var Y=p-C;for(S=u;B<=Y;B++,S++){var x=n[S<0?S+a:S],U=x._point,G=b[B]-U._x,P=k[B]-U._y;(l||BT)&&x.setHandleIn(-G,-P)}}else for(B=u;B<=g;B++)n[B<0?B+a:B].smooth(o,!l&&B===u,!l&&B===g)},toShape:function(e){if(!this._closed)return null;var t,o,i,n,a,A,s,l=this._segments;function u(e,t){var o=l[e],i=o.getNext(),n=l[t],a=n.getNext();return o._handleOut.isZero()&&i._handleIn.isZero()&&n._handleOut.isZero()&&a._handleIn.isZero()&&i._point.subtract(o._point).isCollinear(a._point.subtract(n._point))}function g(e){var t=l[e],o=t.getNext(),i=t._handleOut,n=o._handleIn,a=.5522847498307936;if(i.isOrthogonal(n)){var A=t._point,r=o._point,s=new M(A,i,!0).intersect(new M(r,n,!0),!0);return s&&p.isZero(i.getLength()/s.subtract(A).getLength()-a)&&p.isZero(n.getLength()/s.subtract(r).getLength()-a)}return!1}function c(e,t){return l[e]._point.getDistance(l[t]._point)}if(!this.hasHandles()&&4===l.length&&u(0,2)&&u(1,3)&&(a=l[1],A=a.getPrevious(),s=a.getNext(),A._handleOut.isZero()&&a._handleIn.isZero()&&a._handleOut.isZero()&&s._handleIn.isZero()&&a._point.subtract(A._point).isOrthogonal(s._point.subtract(a._point)))?(t=b.Rectangle,o=new I(c(0,3),c(0,1)),n=l[1]._point.add(l[2]._point).divide(2)):8===l.length&&g(0)&&g(2)&&g(4)&&g(6)&&u(1,5)&&u(3,7)?(t=b.Rectangle,i=(o=new I(c(1,6),c(0,3))).subtract(new I(c(0,7),c(1,2))).divide(2),n=l[3]._point.add(l[4]._point).divide(2)):4===l.length&&g(0)&&g(1)&&g(2)&&g(3)&&(p.isZero(c(0,2)-c(1,3))?(t=b.Circle,i=c(0,2)/2):(t=b.Ellipse,i=new I(c(2,0)/2,c(3,1)/2)),n=l[1]._point),t){var d=this.getPosition(!0),E=new t({center:d,size:o,radius:i,insert:!1});return E.copyAttributes(this,!0),E._matrix.prepend(this._matrix),E.rotate(n.subtract(d).getAngle()+90),(e===r||e)&&E.insertAbove(this),E}return null},toPath:"#clone",compare:function e(t){if(!t||t instanceof G)return e.base.call(this,t);var o=this.getCurves(),i=t.getCurves(),n=o.length,a=i.length;if(!n||!a)return n==a;for(var A,r,s=o[0].getValues(),l=[],u=0,g=0,c=0;c0?a-1:c,r=p[0][1];break}}var E,h=Math.abs;for(d=l[A];s&&d;){var p;if(p=F.getOverlaps(s,d))if(h(p[0][0]-g)<1e-8){1===(g=p[1][0])&&(s=++u=a&&(A=0),d=l[A]||i[A].getValues(),r=0),!s)return E[0]===A&&E[1]===r;continue}}break}return!1},_hitTestSelf:function(e,t,o,i){var n,a,A,r,s,l,u=this,g=this.getStyle(),c=this._segments,d=c.length,E=this._closed,h=t._tolerancePadding,p=h,m=t.stroke&&(g.hasStroke()||t.hitUnstrokedPaths),T=t.fill&&(g.hasFill()||t.hitUnfilledPaths),C=t.curves,I=m?g.getStrokeWidth()/2:T&&t.tolerance>0||C?0:null;function B(t,o){return e.subtract(t).divide(o).length<=1}function S(e,o,i){if(!t.selected||o.isSelected()){var n=e._point;if(o!==n&&(o=o.add(n)),B(o,p))return new L(i,u,{segment:e,point:o})}}function O(e,o){return(o||t.segments)&&S(e,e._point,"segment")||!o&&t.handles&&(S(e,e._handleIn,"handle-in")||S(e,e._handleOut,"handle-out"))}function N(e){r.add(e)}function M(t){var o,s=E||t._index>0&&t._index0?(n=g.getStrokeJoin(),a=g.getStrokeCap(),A=g.getMiterLimit(),p=p.add(U._getStrokePadding(I,i))):n=a="round"),!t.ends||t.segments||E){if(t.segments||t.handles)for(var w=0;w1?M(s.getSegment())||(s=null):B(s.getPoint(),p)||(s=null)}if(!s&&"miter"===n&&d>1)for(w=0;we)return A.getLocationAt(e-a)}if(t.length>0&&e<=this.getLength())return new Y(t[t.length-1],1)}else if(e&&e.getPath&&e.getPath()===this)return e;return null},getOffsetsWithTangent:function(){var e=T.read(arguments);if(e.isZero())return[];for(var t=[],o=0,i=this.getCurves(),n=0,a=i.length;n0&&h(g[0])}return{_draw:function(t,o,i,n){var a=o.dontStart,A=o.dontFinish||o.clip,r=this.getStyle(),s=r.hasFill(),l=r.hasStroke(),u=r.getDashArray(),g=!ce.support.nativeDash&&l&&u&&u.length;function c(e){return u[(e%g+g)%g]}if(a||t.beginPath(),(s||l&&!g||A)&&(e(t,this,n),this._closed&&t.closePath()),!A&&(s||l)&&(this._setStyles(t,o,i,n),s&&(t.fill(r.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(g){a||t.beginPath();var d,E=new P(this,.25,32,!1,n),h=E.length,p=-r.getDashOffset(),m=0;for(p%=h;p>0;)p-=c(m--)+c(m--);for(;p0||d>0)&&E.drawPart(t,Math.max(p,0),Math.max(d,0)),p=d+c(m++)}t.stroke()}},_drawSelected:function(t,o){t.beginPath(),e(t,this,o),t.stroke(),function(e,t,o,i,n){if(!(i<=0))for(var a,A,r=i/2,s=new Array(6),l=0,u=t.length;l1&&(D=(y*=_)*y,b=(f*=_)*f),A(_=(D*b-D*R-b*k)/(D*R+b*k))<1e-12&&(_=0),_<0)throw new Error("Cannot create an arc with the given arguments");t=new T(y*w/f,-f*O/y).multiply((B===C?-1:1)*r(_)).rotate(m).add(S),o=(i=(n=(new N).translate(t).rotate(m).scale(y,f))._inverseTransform(l)).getDirectedAngle(n._inverseTransform(g)),!C&&o>0?o-=360:C&&o<0&&(o+=360)}if(d){var L=new M(l.add(d).divide(2),d.subtract(l).rotate(90),!0),Q=new M(d.add(g).divide(2),g.subtract(d).rotate(90),!0),F=new M(l,g),Y=F.getSide(d);if(!(t=L.intersect(Q,!0))){if(!Y)return this.lineTo(g);throw new Error("Cannot create an arc with the given arguments")}o=(i=l.subtract(t)).getDirectedAngle(g.subtract(t));var x=F.getSide(t,!0);0===x?o=Y*A(o):Y===x&&(o+=o<0?360:-360)}if(o){for(var U=A(o),G=U>=360?4:Math.ceil((U-1e-7)/90),P=o/G,j=P*Math.PI/360,z=4/3*Math.sin(j)/(1+Math.cos(j)),H=[],W=0;W<=G;W++){var K=g,V=null;if(W0){for(var O=1;O=180)&&(g=g.negate(),c=c.negate()),r&&A(u),A(u.add(g)),"miter"===t){var E=new M(u.add(g),new T(-g.y,g.x),!0).intersect(new M(u.add(c),new T(-c.y,c.x),!0),!0);E&&u.getDistance(E)<=i*o&&A(E)}A(u.add(c))},_addSquareCap:function(e,t,o,i,n,a,A){var r=e._point.transform(i),s=e.getLocation(),l=s.getNormal().multiply(0===s.getTime()?o:-o).transform(n);"square"===t&&(A&&(a(r.subtract(l)),a(r.add(l))),r=r.add(l.rotate(-90))),a(r.add(l)),a(r.subtract(l))},getHandleBounds:function(e,t,o,i,n){var a,A,r=o.getStyle();if(n.stroke&&r.hasStroke()){var s=o._getStrokeMatrix(i,n),l=r.getStrokeWidth()/2,u=l;"miter"===r.getStrokeJoin()&&(u=l*r.getMiterLimit()),"square"===r.getStrokeCap()&&(u=Math.max(u,l*Math.SQRT2)),a=U._getStrokePadding(l,s),A=U._getStrokePadding(u,s)}for(var g=new Array(6),c=1/0,d=-c,E=c,h=d,p=0,m=e.length;pd&&(d=w),yh&&(h=f)}}return new S(c,E,d-c,h-E)}}});U.inject({statics:new function(){var e=.5522847498307936,t=[new v([-1,0],[0,e],[0,-e]),new v([0,-1],[-e,0],[e,0]),new v([1,0],[0,-e],[0,e]),new v([0,1],[e,0],[-e,0])];function o(e,t,o){var i=u.getNamed(o),n=new U(i&&0==i.insert&&y.NO_INSERT);return n._add(e),n._closed=t,n.set(i,{insert:!0})}function i(e,i,n){for(var a=new Array(4),A=0;A<4;A++){var r=t[A];a[A]=new v(r._point.multiply(i).add(e),r._handleIn.multiply(i),r._handleOut.multiply(i))}return o(a,!0,n)}return{Line:function(){var e=arguments;return o([new v(T.readNamed(e,"from")),new v(T.readNamed(e,"to"))],!1,e)},Circle:function(){var e=arguments,t=T.readNamed(e,"center"),o=u.readNamed(e,"radius");return i(t,new I(o),e)},Rectangle:function(){var t,i=arguments,n=S.readNamed(i,"rectangle"),a=I.readNamed(i,"radius",0,{readNull:!0}),A=n.getBottomLeft(!0),r=n.getTopLeft(!0),s=n.getTopRight(!0),l=n.getBottomRight(!0);if(!a||a.isZero())t=[new v(A),new v(r),new v(s),new v(l)];else{var u=(a=I.min(a,n.getSize(!0).divide(2))).width,g=a.height,c=u*e,d=g*e;t=[new v(A.add(u,0),null,[-c,0]),new v(A.subtract(0,g),[0,d]),new v(r.add(0,g),null,[0,-d]),new v(r.add(u,0),[-c,0],null),new v(s.subtract(u,0),null,[c,0]),new v(s.add(0,g),[0,-d],null),new v(l.subtract(0,g),null,[0,d]),new v(l.subtract(u,0),[c,0])]}return o(t,!0,i)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=arguments,t=b._readEllipse(e);return i(t.center,t.radius,e)},Oval:"#Ellipse",Arc:function(){var e=arguments,t=T.readNamed(e,"from"),o=T.readNamed(e,"through"),i=T.readNamed(e,"to"),n=u.getNamed(e),a=new U(n&&0==n.insert&&y.NO_INSERT);return a.moveTo(t),a.arcTo(o,i),a.set(n)},RegularPolygon:function(){for(var e=arguments,t=T.readNamed(e,"center"),i=u.readNamed(e,"sides"),n=u.readNamed(e,"radius"),a=360/i,A=i%3==0,r=new T(0,A?-n:n),s=A?-1:.5,l=new Array(i),g=0;g=0;a--){var A=i[a];i!==o||A instanceof U||(i=u.slice(i)),Array.isArray(A)?i[a]=new U({segments:A,insert:!1}):A instanceof G&&(i.splice.apply(i,[a,1].concat(A.removeChildren())),A.remove())}return e.base.call(this,t,i)},reduce:function e(t){for(var o=this._children,i=o.length-1;i>=0;i--){var n;(n=o[i].reduce(t)).isEmpty()&&n.remove()}return o.length?e.base.call(this):((n=new U(y.NO_INSERT)).copyAttributes(this),n.insertAbove(this),this.remove(),n)},isClosed:function(){for(var e=this._children,t=0,o=e.length;t=0;E--){var h=r[E].split();h&&(d(h)&&h.getFirstSegment().setHandleIn(0,0),i.getLastSegment().setHandleOut(0,0))}return d(i),A(c,!1,e,t)}function c(e,t){for(var o=e;o;){if(o===t)return;o=o._previous}for(;e._next&&e._next!==t;)e=e._next;if(!e._next){for(;t._previous;)t=t._previous;e._next=t,t._previous=e}}function d(e){for(var t=e.length-1;t>=0;t--)e[t].clearHandles()}function h(e,t,i){var n=e&&e.length;if(n){var a=u.each(e,(function(e,t){this[e._id]={container:null,winding:e.isClockwise()?1:-1,index:t}}),{}),A=e.slice().sort((function(e,t){return o(t.getArea())-o(e.getArea())})),r=A[0],s=E.findItemBoundsCollisions(A,null,p.GEOMETRIC_EPSILON);null==i&&(i=r.isClockwise());for(var l=0;l=0;T--)if(h[T]=0;h--){(p=o[h])._path&&(g[E(p)]=!0)}for(h=e.length-1;h>=0;h--){var p,m,T=e[h],C=T._time,I=C,B=t&&!t(T);if((p=T._curve)&&(p!==n?(l=!p.hasHandles()||g&&g[E(p)],i=[],a=null,n=p):a>=r&&(C/=a)),B)i&&i.push(T);else{if(t&&A.unshift(T),a=I,Cs)m=p._segment2;else{var S=p.divideAtTime(C,!0);l&&u.push(p,S),m=S._segment1;for(var O=i.length-1;O>=0;O--){var N=i[O];N._time=(N._time-C)/(1-C)}}T._setSegment(m);var M=m._intersection,w=T._intersection;if(M){c(M,w);for(var y=M;y;)c(y._intersection,M),y=y._next}else m._intersection=w}}return o||d(u),A||e}function T(i,n,a,A,r){var s,l,u=Array.isArray(n)?n:n[a?"hor":"ver"],g=a?1:0,c=1^g,d=[i.x,i.y],E=d[g],h=d[c],p=1e-6,m=E-1e-9,C=E+1e-9,I=0,B=0,S=0,O=0,N=!1,M=!1,w=1,y=[];function f(o){var l=o[c+0],u=o[c+6];if(!(ht(l,u))){var d=o[g+0],I=o[g+2],B=o[g+4],M=o[g+6];if(l!==u){var f=h===l?0:h===u||m>t(d,I,B,M)||C0?y[0]:1,D=0===f?d:1===f?M:F.getPoint(o,f)[a?"y":"x"],b=l>u?1:-1,k=s[c]>s[c+6]?1:-1,R=s[g+6];return h!==l?(DC?O+=b:N=!0,D>E-p&&DC&&(O+=b):d!=R&&(RC?(O+=b,N=!0):R>m&&Dm&&Dm||Mm)&&(N=!0)}}function D(o){var i=o[c+0],n=o[c+2],A=o[c+4],r=o[c+6];if(h<=t(i,n,A,r)&&h>=e(i,n,A,r))for(var s,l=o[g+0],u=o[g+2],d=o[g+4],E=o[g+6],p=m>t(l,u,d,E)||Cg.quality&&(g=w);break}l-=m}}for(d=A.length-1;d>=0;d--)A[d].segment._winding=g}function I(e,t){var o,i=[];function n(e){var o;return!(!e||e._visited||t&&(!t[(o=e._winding||{}).winding]||t.unite&&2===o.winding&&o.windingL&&o.windingR))}function a(e){if(e)for(var t=0,i=o.length;t=0;s--){var l=r[s],g=l._path,c=l._segment,E=c.getPrevious(),h=c.getNext();o(E,g)&&o(h,g)&&(c.remove(),E._handleOut._set(0,0),h._handleIn._set(0,0),E===c||E.getCurve().hasLength()||(h._handleIn.set(E._handleIn),E.remove()))}n&&(m(a,i&&function(e){var t=e.getCurve(),o=e.getSegment(),i=e._intersection,n=i._curve,a=i._segment;if(t&&n&&t._path&&n._path)return!0;o&&(o._intersection=null),a&&(a._intersection=null)},A),A&&d(A),t=I(u.each(t,(function(e){u.push(this,e._segments)}),[])));var p,T=t.length;return T>1&&e?(t!==e&&this.setChildren(t),p=this):1!==T||e||(t[0]!==this&&this.setSegments(t[0].removeSegments()),p=this),p||((p=new G(y.NO_INSERT)).addChildren(t),(p=p.reduce()).copyAttributes(this),this.replaceWith(p)),p},reorient:function(e,t){var o=this._children;return o&&o.length?this.setChildren(h(this.removeChildren(),(function(t){return!!(e?t:1&t)}),t)):t!==r&&this.setClockwise(t),this},getInteriorPoint:function(){var o=this.getBounds().getCenter(!0);if(!this.contains(o)){for(var i=this.getCurves(),n=o.y,a=[],A=[],r=0,s=i.length;r=e(u,g,c,d)&&n<=t(u,g,c,d))for(var E=F.getMonoCurves(l),h=0,p=E.length;h=T&&n<=C||n>=C&&n<=T)){var I=n===T?m[0]:n===C?m[6]:1===F.solveCubic(m,1,n,A,0,1)?F.getPoint(m,A[0]).x:(m[0]+m[6])/2;a.push(I)}}}a.length>1&&(a.sort((function(e,t){return e-t})),o.x=(a[0]+a[1])/2)}return o}}});var P=u.extend({_class:"PathFlattener",initialize:function(e,t,o,i,n){var a,A=[],r=[],s=0,l=1/(o||32),u=e._segments,g=u[0];function c(e,t){var o=F.getValues(e,t,n);A.push(o),d(o,e._index,0,1)}function d(e,o,n,a){if(!(a-n>l)||i&&F.isStraight(e)||F.isFlatEnough(e,t||.25)){var A=e[6]-e[0],u=e[7]-e[1],g=Math.sqrt(A*A+u*u);g>0&&(s+=g,r.push({offset:s,curve:e,index:o,time:a}))}else{var c=F.subdivide(e,.5),E=(n+a)/2;d(c[0],o,n,E),d(c[1],o,E,a)}}for(var E=1,h=u.length;E=e){this.index=t;var A=o[t-1],r=A&&A.index===a.index?A.time:0,s=A?A.offset:0;return{index:a.index,time:r+(a.time-r)*(e-s)/(a.offset-s)}}}return{index:o[i-1].index,time:1}},drawPart:function(e,t,o){for(var i=this._get(t),n=this._get(o),a=i.index,A=n.index;a<=A;a++){var r=F.getPart(this.curves[a],a===i.index?i.time:0,a===n.index?n.time:1);a===i.index&&e.moveTo(r[0],r[1]),e.bezierCurveTo.apply(e,r.slice(2))}}},u.each(F._evaluateMethods,(function(e){this[e+"At"]=function(t){var o=this._get(t);return F[e](this.curves[o.index],o.time)}}),{})),j=u.extend({initialize:function(e){for(var t,o=this.points=[],i=e._segments,n=e._closed,a=0,A=i.length;a0&&(i=[new v(t[0])],o>1&&(this.fitCubic(i,e,0,o-1,t[1].subtract(t[0]),t[o-2].subtract(t[o-1])),this.closed&&(i.shift(),i.pop()))),i},fitCubic:function(e,t,o,i,n,a){var A=this.points;if(i-o!=1){for(var r,s=this.chordLengthParameterize(o,i),l=Math.max(t,t*t),u=!0,g=0;g<=4;g++){var c=this.generateBezier(o,i,s,n,a),d=this.findMaxError(o,i,c,s);if(d.error=l)break;u=this.reparameterize(o,i,s,c),l=d.error}var E=A[r-1].subtract(A[r+1]);this.fitCubic(e,t,o,r,n,E),this.fitCubic(e,t,r,i,E.negate(),a)}else{var h=A[o],p=A[i],m=h.getDistance(p)/3;this.addCurve(e,[h,h.add(n.normalize(m)),p.add(a.normalize(m)),p])}},addCurve:function(e,t){e[e.length-1].setHandleOut(t[1].subtract(t[0])),e.push(new v(t[3],t[2].subtract(t[3])))},generateBezier:function(e,t,o,i,n){for(var a=1e-12,A=Math.abs,r=this.points,s=r[e],l=r[t],u=[[0,0],[0,0]],g=[0,0],c=0,d=t-e+1;ca){var y=u[0][0]*g[1]-u[1][0]*g[0];N=(g[0]*u[1][1]-g[1]*u[0][1])/w,M=y/w}else{var f=u[0][0]+u[0][1],D=u[1][0]+u[1][1];N=M=A(f)>a?g[0]/f:A(D)>a?g[1]/D:0}var b,k,R=l.getDistance(s),_=a*R;if(N<_||M<_)N=M=R/3;else{var L=l.subtract(s);b=i.normalize(N),k=n.normalize(M),b.dot(L)-k.dot(L)>R*R&&(N=M=R/3,b=k=null)}return[s,s.add(b||i.normalize(N)),l.add(k||n.normalize(M)),l]},reparameterize:function(e,t,o,i){for(var n=e;n<=t;n++)o[n-e]=this.findRoot(i,this.points[n],o[n-e]);n=1;for(var a=o.length;n=a&&(a=s,n=A)}return{error:a,index:n}}}),z=y.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(e){this._content="",this._lines=[];var t=e&&u.isPlainObject(e)&&e.x===r&&e.y===r;this._initialize(t&&e,!t&&T.read(arguments))},_equals:function(e){return this._content===e._content},copyContent:function(e){this.setContent(e._content)},getContent:function(){return this._content},setContent:function(e){this._content=""+e,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),H=z.extend({_class:"PointText",initialize:function(){z.apply(this,arguments)},getPoint:function(){var e=this._matrix.getTranslation();return new C(e.x,e.y,this,"setPoint")},setPoint:function(){var e=T.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e,t,o){if(this._content){this._setStyles(e,t,o);var i=this._lines,n=this._style,a=n.hasFill(),A=n.hasStroke(),r=n.getLeading(),s=e.shadowColor;e.font=n.getFontStyle(),e.textAlign=n.getJustification();for(var l=0,u=i.length;l1&&(s-=1),A[r]=6*s<1?a+6*(n-a)*s:2*s<1?n:3*s<2?a+(n-a)*(2/3-s)*6:a}return A},"rgb-gray":function(e,t,o){return[.2989*e+.587*t+.114*o]},"gray-rgb":function(e){return[e,e,e]},"gray-hsb":function(e){return[0,0,e]},"gray-hsl":function(e){return[0,0,e]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return u.each(t,(function(e,i){o[i]=[],u.each(e,(function(e,n){var a=u.capitalize(e),A=/^(hue|saturation)$/.test(e),r=o[i][n]="gradient"===i?"gradient"===e?function(e){var t=this._components[0];return t!==(e=K.read(Array.isArray(e)?e:arguments,0,{readNull:!0}))&&(t&&t._removeOwner(this),e&&e._addOwner(this)),e}:function(){return T.read(arguments,0,{readNull:"highlight"===e,clone:!0})}:function(e){return null==e||isNaN(e)?0:+e};this["get"+a]=function(){return this._type===i||A&&/^hs[bl]$/.test(this._type)?this._components[n]:this._convert(i)[n]},this["set"+a]=function(e){this._type===i||A&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(i),this._properties=t[i],this._type=i),this._components[n]=r.call(this,e),this._changed()}}),this)}),{_class:"Color",_readIndex:!0,initialize:function n(a){var A,r,l,g,c=arguments,d=this.__read,E=0;Array.isArray(a)&&(a=(c=a)[0]);var h=null!=a&&typeof a;if("string"===h&&a in t&&(A=a,a=c[1],Array.isArray(a)?(r=a,l=c[2]):(d&&(E=1),c=u.slice(c,1),h=typeof a)),!r){if(g="number"===h?c:"object"===h&&null!=a.length?a:null){A||(A=g.length>=3?"rgb":"gray");var p=t[A].length;l=g[p],d&&(E+=g===arguments?p+(null!=l?1:0):1),g.length>p&&(g=u.slice(g,0,p))}else if("string"===h){var m=function(t){var o,n=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i)||t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),a="rgb";if(n){var A=n[4]?4:3;o=new Array(A);for(var r=0;r1?1:e))}return t=[i(t[0]),i(t[1]),i(t[2])],o<1&&t.push(o<0?0:o),e?"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1):(4==t.length?"rgba(":"rgb(")+t.join(",")+")"},toCanvasStyle:function(e,t,o){var i="gradient"===this._type&&o;if(this._canvasStyle&&!i)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var n,a=this._components,A=a[0],r=A._stops,s=a[1],l=a[2],u=a[3],g=t&&t.inverted();if(g&&(s=g._transformPoint(s),l=g._transformPoint(l),u&&(u=g._transformPoint(u))),o&&(s=o._transformPoint(s),l=o._transformPoint(l),u&&(u=o._transformPoint(u))),A._radial){var c=l.getDistance(s);if(u){var d=u.subtract(s);d.getLength()>c&&(u=s.add(d.normalize(c-.1)))}var E=u||s;n=e.createRadialGradient(E.x,E.y,0,s.x,s.y,c)}else n=e.createLinearGradient(s.x,s.y,l.x,l.y);for(var h=0,p=r.length;h0&&!(i instanceof G);if(a)for(var A=0,r=n.length;A0&&!(i instanceof G);if(a&&!e)for(var s=0,l=n.length;s0},hasStroke:function(){var e=this.getStrokeColor();return!!e&&e.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var e=this.getShadowColor();return!!e&&e.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var e=this.getFontSize();return this.getFontWeight()+" "+e+(/[a-z]/i.test(e+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function e(){var t=e.base.call(this),o=this.getFontSize();return/pt|em|%|px/.test(o)&&(o=this.getView().getPixelSize(o)),null!=t?t:1.2*o}}),Z=new function(){function e(e,t,o,i){for(var n=["","webkit","moz","Moz","ms","o"],a=t[0].toUpperCase()+t.substring(1),A=0;A<6;A++){var r=n[A],s=r?r+a:t;if(s in e){if(!o)return e[s];e[s]=i;break}}}return{getStyles:function(e){var t=e&&9!==e.nodeType?e.ownerDocument:e,o=t&&t.defaultView;return o&&o.getComputedStyle(e,"")},getBounds:function(e,t){var o,i=e.ownerDocument,n=i.body,a=i.documentElement;try{o=e.getBoundingClientRect()}catch(e){o={left:0,top:0,width:0,height:0}}var A=o.left-(a.clientLeft||n.clientLeft||0),r=o.top-(a.clientTop||n.clientTop||0);if(!t){var s=i.defaultView;A+=s.pageXOffset||a.scrollLeft||n.scrollLeft,r+=s.pageYOffset||a.scrollTop||n.scrollTop}return new S(A,r,o.width,o.height)},getViewportBounds:function(e){var t=e.ownerDocument,o=t.defaultView,i=t.documentElement;return new S(0,0,o.innerWidth||i.clientWidth,o.innerHeight||i.clientHeight)},getOffset:function(e,t){return Z.getBounds(e,t).getPoint()},getSize:function(e){return Z.getBounds(e,!0).getSize()},isInvisible:function(e){return Z.getSize(e).equals(new I(0,0))},isInView:function(e){return!Z.isInvisible(e)&&Z.getViewportBounds(e).intersects(Z.getBounds(e,!0))},isInserted:function(e){return l.body.contains(e)},getPrefixed:function(t,o){return t&&e(t,o)},setPrefixed:function(t,o,i){if("object"==typeof o)for(var n in o)e(t,n,!0,o[n]);else e(t,o,!0,i)}}},X={add:function(e,t){if(e)for(var o in t)for(var i=t[o],n=o.split(/[\s,]+/g),a=0,A=n.length;a1?u.hyphenate(t):t.toLowerCase())}function c(t,o,i,r){var s,l=q._focused;if(n[o]=t,t?a[o]=i:delete a[o],o.length>1&&(s=u.camelize(o))in A){A[s]=t;var g=ce&&ce.agent;if("meta"===s&&g&&g.mac)if(t)e={};else{for(var d in e)d in a&&c(!1,d,e[d],r);e=null}}else t&&e&&(e[o]=i);l&&l._handleKeyEvent(t?"keydown":"keyup",r,o,i)}return X.add(l,{keydown:function(e){var o=g(e),n=ce&&ce.agent;o.length>1||n&&n.chrome&&(e.altKey||n.mac&&e.metaKey||!n.mac&&e.ctrlKey)?c(!0,o,i[o]||(o.length>1?"":o),e):t=o},keypress:function(e){if(t){var o=g(e),i=e.charCode,n=i>=32?String.fromCharCode(i):o.length>1?"":o;o!==t&&(o=n.toLowerCase()),c(!0,o,n,e),t=null}},keyup:function(e){var t=g(e);t in a&&c(!1,t,a[t],e)}}),X.add(s,{blur:function(e){for(var t in a)c(!1,t,a[t],e)}}),{modifiers:A,isDown:function(e){return!!n[e]}}},ie=ee.extend({_class:"MouseEvent",initialize:function(e,t,o,i,n){this.type=e,this.event=t,this.point=o,this.target=i,this.delta=n},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),ne=ee.extend({_class:"ToolEvent",_item:null,initialize:function(e,t,o){this.tool=e,this.type=t,this.event=o},_choosePoint:function(e,t){return e||(t?t.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(e){this._point=e},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(e){this._lastPoint=e},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(e){this._downPoint=e},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(e){this._middlePoint=e},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(e){this._delta=e},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(e){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=e},getItem:function(){if(!this._item){var e=this.tool._scope.project.hitTest(this.getPoint());if(e){for(var t=e.item,o=t._parent;/^(Group|CompoundPath)$/.test(o._class);)t=o,o=o._parent;this._item=t}}return this._item},setItem:function(e){this._item=e},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),ae=d.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(e){d.call(this),this._moveCount=-1,this._downCount=-1,this.set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(e){this._minDistance=e,null!=e&&null!=this._maxDistance&&e>this._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&e=0&&a.equals(A))return!1;if(A&&(null!=e||null!=t)){var r=a.subtract(A),s=r.getLength();if(s<(e||0))return!1;t&&(a=A.add(r.normalize(Math.min(s,t))))}l._moveCount++}return l._point=a,l._lastPoint=A||a,i.down&&(l._moveCount=-1,l._downPoint=a,l._downCount++),!0}function g(){a&&(s=l.emit(e,new ne(l,e,t))||s)}if(i.down)u(),g();else if(i.up)u(null,r),g();else if(a)for(;u(A,r);)g();return s}}),Ae=u.extend(g,{_class:"Tween",statics:{easings:{linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return e<.5?2*e*e:2*(2-e)*e-1},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}}},initialize:function e(t,o,i,n,a,A){this.object=t;var r=typeof a,s="function"===r;this.type=s?r:"string"===r?a:"linear",this.easing=s?a:e.easings[this.type],this.duration=n,this.running=!1,this._then=null,this._startTime=null;var l=o||i;this._keys=l?Object.keys(l):[],this._parsedKeys=this._parseKeys(this._keys),this._from=l&&this._getState(o),this._to=l&&this._getState(i),!1!==A&&this.start()},then:function(e){return this._then=e,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(e){if(this.running){e>1&&(e=1,this.running=!1);for(var t=this.easing(e),o=this._keys,i=function(o){return"function"==typeof o?o(t,e):o},n=0,a=o&&o.length;n255){var u=255-i,E=A-i;s=i+(s-i)*u/E,l=i+(l-i)*u/E,g=i+(g-i)*u/E}}function m(e,t,o){return d(e,t,o)-c(e,t,o)}function T(e,t,o,i){var n,a=[e,t,o],A=d(e,t,o),r=c(e,t,o);n=0===c(r=r===e?0:r===t?1:2,A=A===e?0:A===t?1:2)?1===d(r,A)?2:1:0,a[A]>a[r]?(a[n]=(a[n]-a[r])*i/(a[A]-a[r]),a[A]=i):a[n]=a[A]=0,a[r]=0,s=a[0],l=a[1],g=a[2]}var C={multiply:function(){s=n*e/255,l=a*t/255,g=A*o/255},screen:function(){s=n+e-n*e/255,l=a+t-a*t/255,g=A+o-A*o/255},overlay:function(){s=n<128?2*n*e/255:255-2*(255-n)*(255-e)/255,l=a<128?2*a*t/255:255-2*(255-a)*(255-t)/255,g=A<128?2*A*o/255:255-2*(255-A)*(255-o)/255},"soft-light":function(){var i=e*n/255;s=i+n*(255-(255-n)*(255-e)/255-i)/255,l=(i=t*a/255)+a*(255-(255-a)*(255-t)/255-i)/255,g=(i=o*A/255)+A*(255-(255-A)*(255-o)/255-i)/255},"hard-light":function(){s=e<128?2*e*n/255:255-2*(255-e)*(255-n)/255,l=t<128?2*t*a/255:255-2*(255-t)*(255-a)/255,g=o<128?2*o*A/255:255-2*(255-o)*(255-A)/255},"color-dodge":function(){s=0===n?0:255===e?255:c(255,255*n/(255-e)),l=0===a?0:255===t?255:c(255,255*a/(255-t)),g=0===A?0:255===o?255:c(255,255*A/(255-o))},"color-burn":function(){s=255===n?255:0===e?0:d(0,255-255*(255-n)/e),l=255===a?255:0===t?0:d(0,255-255*(255-a)/t),g=255===A?255:0===o?0:d(0,255-255*(255-A)/o)},darken:function(){s=ne?n:e,l=a>t?a:t,g=A>o?A:o},difference:function(){(s=n-e)<0&&(s=-s),(l=a-t)<0&&(l=-l),(g=A-o)<0&&(g=-g)},exclusion:function(){s=n+e*(255-n-n)/255,l=a+t*(255-a-a)/255,g=A+o*(255-A-A)/255},hue:function(){T(e,t,o,m(n,a,A)),p(s,l,g,h(n,a,A))},saturation:function(){T(n,a,A,m(e,t,o)),p(s,l,g,h(n,a,A))},luminosity:function(){p(n,a,A,h(e,t,o))},color:function(){p(e,t,o,h(n,a,A))},add:function(){s=c(n+e,255),l=c(a+t,255),g=c(A+o,255)},subtract:function(){s=d(n-e,0),l=d(a-t,0),g=d(A-o,0)},average:function(){s=(n+e)/2,l=(a+t)/2,g=(A+o)/2},negation:function(){s=255-E(255-e-n),l=255-E(255-t-a),g=255-E(255-o-A)}},I=this.nativeModes=u.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],(function(e){this[e]=!0}),{}),B=se.getContext(1,1);B&&(u.each(C,(function(e,t){var o="darken"===t,i=!1;B.save();try{B.fillStyle=o?"#300":"#a00",B.fillRect(0,0,1,1),B.globalCompositeOperation=t,B.globalCompositeOperation===t&&(B.fillStyle=o?"#a00":"#300",B.fillRect(0,0,1,1),i=B.getImageData(0,0,1,1).data[0]!==o?170:51)}catch(e){}B.restore(),I[t]=i})),se.release(B)),this.process=function(u,c,d,E,h){var p=c.canvas,m="normal"===u;if(m||I[u])d.save(),d.setTransform(1,0,0,1,0,0),d.globalAlpha=E,m||(d.globalCompositeOperation=u),d.drawImage(p,h.x,h.y),d.restore();else{var T=C[u];if(!T)return;for(var B=d.getImageData(h.x,h.y,p.width,p.height),S=B.data,O=c.getImageData(0,0,p.width,p.height).data,N=0,M=S.length;N=2&&!o.hasHandles())if(l>2){r=o._closed?"polygon":"polyline";for(var g=[],c=0;c3){for(o.sort((function(e,t){return t.length-e.length})),t+="switch(str.length){",i=0;i=170&&xe.test(String.fromCharCode(e)))},ze=e.isIdentifierChar=function(e){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||e>=170&&Ue.test(String.fromCharCode(e))))};function He(){this.line=h,this.column=r-p}function We(){h=1,r=p=0,E=!0,Ze()}function Ke(e,o){l=r,t.locations&&(g=new He),c=e,Ze(),d=o,E=e.beforeExpr}function Ve(){var e,i=t.onComment&&t.locations&&new He,n=r,a=o.indexOf("*/",r+=2);if(-1===a&&N(r-2,"Unterminated comment"),r=a+2,t.locations)for(Pe.lastIndex=n;(e=Pe.exec(o))&&e.index8&&e<14)++r;else if(47===e){var n;if(42===(n=o.charCodeAt(r+1)))Ve();else{if(47!==n)break;Je()}}else if(160===e)++r;else{if(!(e>=5760&&Fe.test(String.fromCharCode(e))))break;++r}}}function Xe(e){switch(e){case 46:return function(){var e=o.charCodeAt(r+1);return e>=48&&e<=57?ot(!0):(++r,Ke(ce))}();case 40:return++r,Ke(re);case 41:return++r,Ke(se);case 59:return++r,Ke(ue);case 44:return++r,Ke(le);case 91:return++r,Ke(ie);case 93:return++r,Ke(ne);case 123:return++r,Ke(ae);case 125:return++r,Ke(Ae);case 58:return++r,Ke(ge);case 63:return++r,Ke(de);case 48:var n=o.charCodeAt(r+1);if(120===n||88===n)return function(){r+=2;var e=tt(16);return null==e&&N(s+2,"Expected hexadecimal number"),je(o.charCodeAt(r))&&N(r,"Identifier directly after number"),Ke(w,e)}();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return ot(!1);case 34:case 39:return function(e){r++;for(var n="";;){r>=i&&N(s,"Unterminated string constant");var a=o.charCodeAt(r);if(a===e)return++r,Ke(f,n);if(92===a){a=o.charCodeAt(++r);var A=/^[0-7]+/.exec(o.slice(r,r+3));for(A&&(A=A[0]);A&&parseInt(A,8)>255;)A=A.slice(0,-1);if("0"===A&&(A=null),++r,A)S&&N(r-2,"Octal literal in strict mode"),n+=String.fromCharCode(parseInt(A,8)),r+=A.length-1;else switch(a){case 110:n+="\n";break;case 114:n+="\r";break;case 120:n+=String.fromCharCode(it(2));break;case 117:n+=String.fromCharCode(it(4));break;case 85:n+=String.fromCharCode(it(8));break;case 116:n+="\t";break;case 98:n+="\b";break;case 118:n+="\v";break;case 102:n+="\f";break;case 48:n+="\0";break;case 13:10===o.charCodeAt(r)&&++r;case 10:t.locations&&(p=r,++h);break;default:n+=String.fromCharCode(a)}}else 13!==a&&10!==a&&8232!==a&&8233!==a||N(s,"Unterminated string constant"),n+=String.fromCharCode(a),++r}}(e);case 47:return function(){var e=o.charCodeAt(r+1);return E?(++r,et()):61===e?$e(pe,2):$e(Ee,1)}();case 37:case 42:return 61===o.charCodeAt(r+1)?$e(pe,2):$e(fe,1);case 124:case 38:return function(e){var t=o.charCodeAt(r+1);return t===e?$e(124===e?Ce:Ie,2):61===t?$e(pe,2):$e(124===e?Be:Oe,1)}(e);case 94:return 61===o.charCodeAt(r+1)?$e(pe,2):$e(Se,1);case 43:case 45:return function(e){var t=o.charCodeAt(r+1);return t===e?45==t&&62==o.charCodeAt(r+2)&&Ge.test(o.slice(T,r))?(r+=3,Je(),Ze(),qe()):$e(me,2):61===t?$e(pe,2):$e(ye,1)}(e);case 60:case 62:return function(e){var t=o.charCodeAt(r+1),i=1;return t===e?(i=62===e&&62===o.charCodeAt(r+2)?3:2,61===o.charCodeAt(r+i)?$e(pe,i+1):$e(we,i)):33==t&&60==e&&45==o.charCodeAt(r+2)&&45==o.charCodeAt(r+3)?(r+=4,Je(),Ze(),qe()):(61===t&&(i=61===o.charCodeAt(r+2)?3:2),$e(Me,i))}(e);case 61:case 33:return function(e){return 61===o.charCodeAt(r+1)?$e(Ne,61===o.charCodeAt(r+2)?3:2):$e(61===e?he:Te,1)}(e);case 126:return $e(Te,1)}return!1}function qe(e){if(e?r=s+1:s=r,t.locations&&(u=new He),e)return et();if(r>=i)return Ke(b);var n=o.charCodeAt(r);if(je(n)||92===n)return at();var a=Xe(n);if(!1===a){var A=String.fromCharCode(n);if("\\"===A||xe.test(A))return at();N(r,"Unexpected character '"+A+"'")}return a}function $e(e,t){var i=o.slice(r,r+t);r+=t,Ke(e,i)}function et(){for(var e,t,n=r;;){r>=i&&N(n,"Unterminated regular expression");var a=o.charAt(r);if(Ge.test(a)&&N(n,"Unterminated regular expression"),e)e=!1;else{if("["===a)t=!0;else if("]"===a&&t)t=!1;else if("/"===a&&!t)break;e="\\"===a}++r}var A=o.slice(n,r);++r;var s=nt();s&&!/^[gmsiy]*$/.test(s)&&N(n,"Invalid regexp flag");try{var l=new RegExp(A,s)}catch(e){e instanceof SyntaxError&&N(n,e.message),N(e)}return Ke(y,l)}function tt(e,t){for(var i=r,n=0,a=0,A=null==t?1/0:t;a=97?l-97+10:l>=65?l-65+10:l>=48&&l<=57?l-48:1/0)>=e)break;++r,n=n*e+s}return r===i||null!=t&&r-i!==t?null:n}function ot(e){var t=r,i=!1,n=48===o.charCodeAt(r);e||null!==tt(10)||N(t,"Invalid number"),46===o.charCodeAt(r)&&(++r,tt(10),i=!0);var a=o.charCodeAt(r);69!==a&&101!==a||(43!==(a=o.charCodeAt(++r))&&45!==a||++r,null===tt(10)&&N(t,"Invalid number"),i=!0),je(o.charCodeAt(r))&&N(r,"Identifier directly after number");var A,s=o.slice(t,r);return i?A=parseFloat(s):n&&1!==s.length?/[89]/.test(s)||S?N(t,"Invalid number"):A=parseInt(s,8):A=parseInt(s,10),Ke(w,A)}function it(e){var t=tt(16,e);return null===t&&N(s,"Bad character escape sequence"),t}function nt(){ke=!1;for(var e,t=!0,i=r;;){var n=o.charCodeAt(r);if(ze(n))ke&&(e+=o.charAt(r)),++r;else{if(92!==n)break;ke||(e=o.slice(i,r)),ke=!0,117!=o.charCodeAt(++r)&&N(r,"Expecting Unicode escape sequence \\uXXXX"),++r;var a=it(4),A=String.fromCharCode(a);A||N(r-1,"Invalid Unicode escape"),(t?je(a):ze(a))||N(r-4,"Invalid Unicode escape"),e+=A}t=!1}return ke?e:o.slice(i,r)}function at(){var e=nt(),t=D;return!ke&&Qe(e)&&(t=oe[e]),Ke(t,e)}function At(){m=s,T=l,C=g,qe()}function rt(e){if(S=e,r=s,t.locations)for(;r=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}function Et(e){if(c===e)return At(),!0}function ht(){return!t.strictSemicolons&&(c===b||c===Ae||Ge.test(o.slice(T,s)))}function pt(){Et(ue)||ht()||Tt()}function mt(e){c===e?At():Tt()}function Tt(){N(s,"Unexpected token")}function Ct(e){"Identifier"!==e.type&&"MemberExpression"!==e.type&&N(e.start,"Assigning to rvalue"),S&&"Identifier"===e.type&&ve(e.name)&&N(e.start,"Assigning to "+e.name+" in strict mode")}var It={kind:"loop"},Bt={kind:"switch"};function St(){(c===Ee||c===pe&&"/="==d)&&qe(!0);var e=c,i=ut();switch(e){case k:case L:At();var n=e===k;Et(ue)||ht()?i.label=null:c!==D?Tt():(i.label=Ft(),pt());for(var a=0;at){var n=gt(e);n.left=e,n.operator=d;var a=c;return At(),n.right=bt(kt(),i,o),bt(ct(n,a===Ce||a===Ie?"LogicalExpression":"BinaryExpression"),t,o)}return e}function kt(){if(c.prefix){var e=ut(),t=c.isUpdate;return e.operator=d,e.prefix=!0,E=!0,At(),e.argument=kt(),t?Ct(e.argument):S&&"delete"===e.operator&&"Identifier"===e.argument.type&&N(e.start,"Deleting local variable in strict mode"),ct(e,t?"UpdateExpression":"UnaryExpression")}for(var o=Rt(_t());c.postfix&&!ht();)(e=gt(o)).operator=d,e.prefix=!1,e.argument=o,Ct(o),At(),o=ct(e,"UpdateExpression");return o}function Rt(e,t){var o;return Et(ce)?((o=gt(e)).object=e,o.property=Ft(!0),o.computed=!1,Rt(ct(o,"MemberExpression"),t)):Et(ie)?((o=gt(e)).object=e,o.property=ft(),o.computed=!0,mt(ne),Rt(ct(o,"MemberExpression"),t)):!t&&Et(re)?((o=gt(e)).callee=e,o.arguments=Qt(se,!1),Rt(ct(o,"CallExpression"),t)):e}function _t(){switch(c){case X:var e=ut();return At(),ct(e,"ThisExpression");case D:return Ft();case w:case f:case y:return(e=ut()).value=d,e.raw=o.slice(s,l),At(),ct(e,"Literal");case q:case $:case ee:return(e=ut()).value=c.atomValue,e.raw=c.keyword,At(),ct(e,"Literal");case re:var i=u,n=s;At();var a=ft();return a.start=n,a.end=l,t.locations&&(a.loc.start=i,a.loc.end=g),t.ranges&&(a.range=[n,l]),mt(se),a;case ie:return e=ut(),At(),e.elements=Qt(ne,!0,!0),ct(e,"ArrayExpression");case ae:return function(){var e=ut(),o=!0,i=!1;for(e.properties=[],At();!Et(Ae);){if(o)o=!1;else if(mt(le),t.allowTrailingCommas&&Et(Ae))break;var n,a={key:Lt()},A=!1;if(Et(ge)?(a.value=ft(!0),n=a.kind="init"):t.ecmaVersion>=5&&"Identifier"===a.key.type&&("get"===a.key.name||"set"===a.key.name)?(A=i=!0,n=a.kind=a.key.name,a.key=Lt(),c!==re&&Tt(),a.value=vt(ut(),!1)):Tt(),"Identifier"===a.key.type&&(S||i))for(var r=0;r=0)for(var r=0;r=e)break;e+=n[1]}return e}function n(t){return e.substring(i(t.range[0]),i(t.range[1]))}function a(t,n){for(var a=i(t.range[0]),A=i(t.range[1]),r=0,s=o.length-1;s>=0;s--)if(a>o[s][0]){r=s+1;break}o.splice(r,0,[a,n.length-A+a]),e=e.substring(0,a)+n+e.substring(A)}function r(t,o){switch(t.type){case"UnaryExpression":if(t.operator in m&&"Literal"!==t.argument.type){var A=n(t.argument);a(t,'$__("'+t.operator+'", '+A+")")}break;case"BinaryExpression":if(t.operator in p&&"Literal"!==t.left.type){var r=n(t.left),s=n(t.right),l=function(t,o){return e.substring(i(t.range[1]),i(o.range[0]))}(t.left,t.right),u=t.operator;a(t,"__$__("+r+","+l.replace(new RegExp("\\"+u),'"'+u+'"')+", "+s+")")}break;case"UpdateExpression":case"AssignmentExpression":var g=o&&o.type;if(!("ForStatement"===g||"BinaryExpression"===g&&/^[=!<>]/.test(o.operator)||"MemberExpression"===g&&o.computed))if("UpdateExpression"===t.type){var c=(A=n(t.argument))+" = "+(d="__$__("+A+', "'+t.operator[0]+'", 1)');t.prefix?c="("+c+")":"AssignmentExpression"!==g&&"VariableDeclarator"!==g&&"BinaryExpression"!==g||(n(o.left||o.id)===A&&(c=d),c=A+"; "+c),a(t,c)}else if(/^.=$/.test(t.operator)&&"Literal"!==t.left.type){r=n(t.left),s=n(t.right);var d=r+" = __$__("+r+', "'+t.operator[0]+'", '+s+")";a(t,/^\(.*\)$/.test(n(t))?"("+d+")":d)}}}var u,g=(t=t||{}).url||"",c=t.sourceMaps,d=t.paperFeatures||{},E=t.source||e,T=t.offset||0,C=ce.agent,I=C.versionNumber,B=!1,S=/\r\n|\n|\r/gm;if(c&&(C.chrome&&I>=30||C.webkit&&I>=537.76||C.firefox&&I>=23||C.node)){if(C.node)T-=2;else if(s&&g&&!s.location.href.indexOf(g)){var O=l.getElementsByTagName("html")[0].innerHTML;T=O.substr(0,O.indexOf(e)+1).match(S).length+1}var N=["AA"+function(e){var t="";for(e=(Math.abs(e)<<1)+(e<0?1:0);e||!t;){var o=31&e;(e>>=5)&&(o|=32),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[o]}return t}((B=T>0&&!(C.chrome&&I>=36||C.safari&&I>=600||C.firefox&&I>=40||C.node))?0:T)+"A"];N.length=(e.match(S)||[]).length+1+(B?T:0),u={version:3,file:g,names:[],mappings:N.join(";AACA"),sourceRoot:"",sources:[g],sourcesContent:[E]}}return!1===d.operatorOverloading&&!1===d.moduleExports||function e(t,o,i){if(t){for(var A in t)if("range"!==A&&"loc"!==A){var s=t[A];if(Array.isArray(s))for(var l=0,u=s.length;l{"use strict";function i(e,t,o,i,n,a,A){try{var r=e[a](A),s=r.value}catch(e){return void o(e)}r.done?t(s):Promise.resolve(s).then(i,n)}function n(e){return function(){var t=this,o=arguments;return new Promise((function(n,a){var A=e.apply(t,o);function r(e){i(A,n,a,r,s,"next",e)}function s(e){i(A,n,a,r,s,"throw",e)}r(void 0)}))}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A(e,t){for(var o=0;oe.length)&&(t=e.length);for(var o=0,i=new Array(t);o0&&G[0]<4?1:+(G[0]+G[1])),!P&&pe&&(!(G=pe.match(/Edge\/(\d+)/))||G[1]>=74)&&(G=pe.match(/Chrome\/(\d+)/))&&(P=+G[1]);var Be=P,Se=Be,Oe=T,Ne=!!Object.getOwnPropertySymbols&&!Oe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Se&&Se<41})),Me=Ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,we=ce,ye=k,fe=de,De=Me,be=m.Object,ke=De?function(e){return"symbol"==typeof e}:function(e){var t=we("Symbol");return ye(t)&&fe(t.prototype,be(e))},Re=m.String,_e=function(e){try{return Re(e)}catch(e){return"Object"}},Le=k,ve=_e,Qe=m.TypeError,Fe=function(e){if(Le(e))return e;throw Qe(ve(e)+" is not a function")},Ye=Fe,xe=function(e,t){var o=e[t];return null==o?void 0:Ye(o)},Ue=Q,Ge=k,Pe=Ae,je=m.TypeError,ze={exports:{}},He=m,We=Object.defineProperty,Ke=m["__core-js_shared__"]||function(e,t){try{We(He,e,{value:t,configurable:!0,writable:!0})}catch(o){He[e]=t}return t}("__core-js_shared__",{}),Ve=Ke;(ze.exports=function(e,t){return Ve[e]||(Ve[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.21.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.21.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Je=te,Ze=m.Object,Xe=function(e){return Ze(Je(e))},qe=Xe,$e=b({}.hasOwnProperty),et=Object.hasOwn||function(e,t){return $e(qe(e),t)},tt=b,ot=0,it=Math.random(),nt=tt(1..toString),at=function(e){return"Symbol("+(void 0===e?"":e)+")_"+nt(++ot+it,36)},At=m,rt=ze.exports,st=et,lt=at,ut=Ne,gt=Me,ct=rt("wks"),dt=At.Symbol,Et=dt&&dt.for,ht=gt?dt:dt&&dt.withoutSetter||lt,pt=function(e){if(!st(ct,e)||!ut&&"string"!=typeof ct[e]){var t="Symbol."+e;ut&&st(dt,e)?ct[e]=dt[e]:ct[e]=gt&&Et?Et(t):ht(t)}return ct[e]},mt=Q,Tt=Ae,Ct=ke,It=xe,Bt=pt,St=m.TypeError,Ot=Bt("toPrimitive"),Nt=function(e,t){if(!Tt(e)||Ct(e))return e;var o,i=It(e,Ot);if(i){if(void 0===t&&(t="default"),o=mt(i,e,t),!Tt(o)||Ct(o))return o;throw St("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var o,i;if("string"===t&&Ge(o=e.toString)&&!Pe(i=Ue(o,e)))return i;if(Ge(o=e.valueOf)&&!Pe(i=Ue(o,e)))return i;if("string"!==t&&Ge(o=e.toString)&&!Pe(i=Ue(o,e)))return i;throw je("Can't convert object to primitive value")}(e,t)},Mt=ke,wt=function(e){var t=Nt(e,"string");return Mt(t)?t:t+""},yt=Ae,ft=m.document,Dt=yt(ft)&&yt(ft.createElement),bt=function(e){return Dt?ft.createElement(e):{}},kt=bt,Rt=!_&&!T((function(){return 7!=Object.defineProperty(kt("div"),"a",{get:function(){return 7}}).a})),_t=_,Lt=Q,vt=F,Qt=j,Ft=ne,Yt=wt,xt=et,Ut=Rt,Gt=Object.getOwnPropertyDescriptor;R.f=_t?Gt:function(e,t){if(e=Ft(e),t=Yt(t),Ut)try{return Gt(e,t)}catch(e){}if(xt(e,t))return Qt(!Lt(vt.f,e,t),e[t])};var Pt=T,jt=k,zt=/#|\.prototype\./,Ht=function(e,t){var o=Kt[Wt(e)];return o==Jt||o!=Vt&&(jt(t)?Pt(t):!!t)},Wt=Ht.normalize=function(e){return String(e).replace(zt,".").toLowerCase()},Kt=Ht.data={},Vt=Ht.NATIVE="N",Jt=Ht.POLYFILL="P",Zt=Ht,Xt=Fe,qt=C,$t=b(b.bind),eo=function(e,t){return Xt(e),void 0===t?e:qt?$t(e,t):function(){return e.apply(t,arguments)}},to={},oo=_&&T((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),io=m,no=Ae,ao=io.String,Ao=io.TypeError,ro=function(e){if(no(e))return e;throw Ao(ao(e)+" is not an object")},so=_,lo=Rt,uo=oo,go=ro,co=wt,Eo=m.TypeError,ho=Object.defineProperty,po=Object.getOwnPropertyDescriptor;to.f=so?uo?function(e,t,o){if(go(e),t=co(t),go(o),"function"==typeof e&&"prototype"===t&&"value"in o&&"writable"in o&&!o.writable){var i=po(e,t);i&&i.writable&&(e[t]=o.value,o={configurable:"configurable"in o?o.configurable:i.configurable,enumerable:"enumerable"in o?o.enumerable:i.enumerable,writable:!1})}return ho(e,t,o)}:ho:function(e,t,o){if(go(e),t=co(t),go(o),lo)try{return ho(e,t,o)}catch(e){}if("get"in o||"set"in o)throw Eo("Accessors not supported");return"value"in o&&(e[t]=o.value),e};var mo=to,To=j,Co=_?function(e,t,o){return mo.f(e,t,To(1,o))}:function(e,t,o){return e[t]=o,e},Io=m,Bo=N,So=b,Oo=k,No=R.f,Mo=Zt,wo=re,yo=eo,fo=Co,Do=et,bo=function(e){var t=function(o,i,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(o);case 2:return new e(o,i)}return new e(o,i,n)}return Bo(e,this,arguments)};return t.prototype=e.prototype,t},ko=function(e,t){var o,i,n,a,A,r,s,l,u=e.target,g=e.global,c=e.stat,d=e.proto,E=g?Io:c?Io[u]:(Io[u]||{}).prototype,h=g?wo:wo[u]||fo(wo,u,{})[u],p=h.prototype;for(n in t)o=!Mo(g?n:u+(c?".":"#")+n,e.forced)&&E&&Do(E,n),A=h[n],o&&(r=e.noTargetGet?(l=No(E,n))&&l.value:E[n]),a=o&&r?r:t[n],o&&typeof A==typeof a||(s=e.bind&&o?yo(a,Io):e.wrap&&o?bo(a):d&&Oo(a)?So(a):a,(e.sham||a&&a.sham||A&&A.sham)&&fo(s,"sham",!0),fo(h,n,s),d&&(Do(wo,i=u+"Prototype")||fo(wo,i,{}),fo(wo[i],n,a),e.real&&p&&!p[n]&&fo(p,n,a)))},Ro=ze.exports,_o=at,Lo=Ro("keys"),vo=function(e){return Lo[e]||(Lo[e]=_o(e))},Qo=!T((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Fo=m,Yo=et,xo=k,Uo=Xe,Go=Qo,Po=vo("IE_PROTO"),jo=Fo.Object,zo=jo.prototype,Ho=Go?jo.getPrototypeOf:function(e){var t=Uo(e);if(Yo(t,Po))return t[Po];var o=t.constructor;return xo(o)&&t instanceof o?o.prototype:t instanceof jo?zo:null},Wo=m,Ko=k,Vo=Wo.String,Jo=Wo.TypeError,Zo=b,Xo=ro,qo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,o={};try{(e=Zo(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(o,[]),t=o instanceof Array}catch(e){}return function(o,i){return Xo(o),function(e){if("object"==typeof e||Ko(e))return e;throw Jo("Can't set "+Vo(e)+" as a prototype")}(i),t?e(o,i):o.__proto__=i,o}}():void 0),$o={},ei=Math.ceil,ti=Math.floor,oi=function(e){var t=+e;return t!=t||0===t?0:(t>0?ti:ei)(t)},ii=oi,ni=Math.max,ai=Math.min,Ai=function(e,t){var o=ii(e);return o<0?ni(o+t,0):ai(o,t)},ri=oi,si=Math.min,li=function(e){return e>0?si(ri(e),9007199254740991):0},ui=li,gi=function(e){return ui(e.length)},ci=ne,di=Ai,Ei=gi,hi=function(e){return function(t,o,i){var n,a=ci(t),A=Ei(a),r=di(i,A);if(e&&o!=o){for(;A>r;)if((n=a[r++])!=n)return!0}else for(;A>r;r++)if((e||r in a)&&a[r]===o)return e||r||0;return!e&&-1}},pi={includes:hi(!0),indexOf:hi(!1)},mi={},Ti=et,Ci=ne,Ii=pi.indexOf,Bi=mi,Si=b([].push),Oi=function(e,t){var o,i=Ci(e),n=0,a=[];for(o in i)!Ti(Bi,o)&&Ti(i,o)&&Si(a,o);for(;t.length>n;)Ti(i,o=t[n++])&&(~Ii(a,o)||Si(a,o));return a},Ni=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Mi=Oi,wi=Ni.concat("length","prototype");$o.f=Object.getOwnPropertyNames||function(e){return Mi(e,wi)};var yi={};yi.f=Object.getOwnPropertySymbols;var fi=ce,Di=$o,bi=yi,ki=ro,Ri=b([].concat),_i=fi("Reflect","ownKeys")||function(e){var t=Di.f(ki(e)),o=bi.f;return o?Ri(t,o(e)):t},Li=et,vi=_i,Qi=R,Fi=to,Yi={},xi=Oi,Ui=Ni,Gi=Object.keys||function(e){return xi(e,Ui)},Pi=_,ji=oo,zi=to,Hi=ro,Wi=ne,Ki=Gi;Yi.f=Pi&&!ji?Object.defineProperties:function(e,t){Hi(e);for(var o,i=Wi(t),n=Ki(t),a=n.length,A=0;a>A;)zi.f(e,o=n[A++],i[o]);return e};var Vi,Ji=ce("document","documentElement"),Zi=ro,Xi=Yi,qi=Ni,$i=mi,en=Ji,tn=bt,on=vo("IE_PROTO"),nn=function(){},an=function(e){return" + + + + diff --git a/src/utils/defaultProjects.js b/src/utils/defaultProjects.js index abacf349f..bb1c6f32b 100644 --- a/src/utils/defaultProjects.js +++ b/src/utils/defaultProjects.js @@ -21,7 +21,14 @@ export const defaultHtmlProject = { ], }; +export const defaultScratchProject = { + project_type: "scratch", + name: i18n.t("project.untitled"), + components: [{ extension: "sb3", name: "main", content: "" }], +}; + export const DEFAULT_PROJECTS = { python: defaultPythonProject, html: defaultHtmlProject, + scratch: defaultScratchProject, }; diff --git a/webpack.config.js b/webpack.config.js index 0666b78f8..d51f5ca69 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -107,6 +107,7 @@ module.exports = { // Pyodide - required for input and code interruption - needed on the host app "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp", + "Cross-Origin-Resource-Policy": "cross-origin", }, setupMiddlewares: (middlewares, devServer) => { devServer.app.use((req, res, next) => { @@ -136,8 +137,13 @@ module.exports = { template: "src/web-component.html", filename: "web-component.html", }), + new HtmlWebpackPlugin({ + inject: "body", + template: "src/scratch-component.html", + filename: "scratch-component.html", + }), new CopyWebpackPlugin({ - patterns: [{ from: "public", to: "" }], + patterns: [{ from: "public", to: "" }, { from: "src/gui.js", to: "" }], }), ], stats: "minimal",