scratch-gui
Version:
Graphical User Interface for creating and running Scratch 3.0 projects
2 lines • 18.2 MB
JavaScript
/*! For license information please see scratch-gui.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.GUI=t(require("react"),require("react-dom")):e.GUI=t(e.react,e["react-dom"])}(self,(__WEBPACK_EXTERNAL_MODULE__80629__,__WEBPACK_EXTERNAL_MODULE__80400__)=>(()=>{var __webpack_modules__={48311(e,t,o){var i,n,a;(function(r,A){var s=(r=r||o(32012)).window?r.window:r,l=r.document,u=new function(){var e=/^(statics|enumerable|beans|preserve)$/,t=[],o=t.slice,i=Object.create,n=Object.getOwnPropertyDescriptor,a=Object.defineProperty,r=t.forEach||function(e,t){for(var o=0,i=this.length;o<i;o++)e.call(t,this[o],o,this)},s=function(e,t){for(var o in this)this.hasOwnProperty(o)&&e.call(t,this[o],o,this)},l=Object.assign||function(e){for(var t=1,o=arguments.length;t<o;t++){var i=arguments[t];for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}return e},u=function(e,t,o){if(e){var i=n(e,"length");(i&&"number"==typeof i.value?r:s).call(e,t,o=o||e)}return o};function g(t,o,i,r,A){var s={};function l(e,l){"string"==typeof(l=l||(l=n(o,e))&&(l.get?l:l.value))&&"#"===l[0]&&(l=t[l.substring(1)]||l);var u,g="function"==typeof l,d=l,h=A||g&&!l.base?l&&l.get?e in t:t[e]:null;A&&h||(g&&h&&(l.base=h),g&&!1!==r&&(u=e.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(s[u[3].toLowerCase()+u[4]]=u[2]),d&&!g&&d.get&&"function"==typeof d.get&&c.isPlainObject(d)||(d={value:d,writable:!0}),(n(t,e)||{configurable:!0}).configurable&&(d.configurable=!0,d.enumerable=null!=i?i:!u),a(t,e,d))}if(o){for(var u in o)o.hasOwnProperty(u)&&!e.test(u)&&l(u);for(var u in s){var g=s[u],d=t["set"+g],h=t["get"+g]||d&&t["is"+g];!h||!0!==r&&0!==h.length||l(u,{get:h,set:d})}}return t}function c(){for(var e=0,t=arguments.length;e<t;e++){var o=arguments[e];o&&l(this,o)}return this}return g(c,{inject:function(e){if(e){var t=!0===e.statics?e:e.statics,o=e.beans,i=e.preserve;t!==e&&g(this.prototype,e,e.enumerable,o,i),g(this,t,null,o,i)}for(var n=1,a=arguments.length;n<a;n++)this.inject(arguments[n]);return this},extend:function(){for(var e,t,o,n=this,r=0,A=arguments.length;r<A&&(!e||!t);r++)o=arguments[r],e=e||o.initialize,t=t||o.prototype;return e=e||function(){n.apply(this,arguments)},t=e.prototype=t||i(this.prototype),a(t,"constructor",{value:e,writable:!0,configurable:!0}),g(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=n,e}}).inject({enumerable:!1,initialize:c,set:c,inject:function(){for(var e=0,t=arguments.length;e<t;e++){var o=arguments[e];o&&g(this,o,o.enumerable,o.beans,o.preserve)}return this},extend:function(){var e=i(this);return e.inject.apply(e,arguments)},each:function(e,t){return u(this,e,t)},clone:function(){return new this.constructor(this)},statics:{set:l,each:u,create:i,define:a,describe:n,clone:function(e){return l(new e.constructor,e)},isPlainObject:function(e){var t=null!=e&&e.constructor;return t&&(t===Object||t===c||"Object"===t.name)},pick:function(e,t){return e!==A?e:t},slice:function(e,t,i){return o.call(e,t,i)}}})};e.exports=u,u.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+u.each(this,function(e,t){if(!/^_/.test(t)){var o=typeof e;this.push(t+": "+("number"===o?p.instance.number(e):"string"===o?"'"+e+"'":e))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(e){return u.importJSON(e,this)},exportJSON:function(e){return u.exportJSON(this,e)},toJSON:function(){return u.serialize(this)},set:function(e,t){return e&&u.filter(this,e,t,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function e(){var t=e.base.apply(this,arguments),o=t.prototype._class;return o&&!u.exports[o]&&(u.exports[o]=t),t},equals:function(e,t){if(e===t)return!0;if(e&&e.equals)return e.equals(t);if(t&&t.equals)return t.equals(e);if(e&&t&&"object"==typeof e&&"object"==typeof t){if(Array.isArray(e)&&Array.isArray(t)){if((o=e.length)!==t.length)return!1;for(;o--;)if(!u.equals(e[o],t[o]))return!1}else{var o,i=Object.keys(e);if((o=i.length)!==Object.keys(t).length)return!1;for(;o--;){var n=i[o];if(!t.hasOwnProperty(n)||!u.equals(e[n],t[n]))return!1}}return!0}return!1},read:function(e,t,o,i){if(this===u){var n=this.peek(e,t);return e.__index++,n}var a=this.prototype,r=a._readIndex,s=t||r&&e.__index||0,l=e.length,g=e[s];if(i=i||l-s,g instanceof this||o&&o.readNull&&null==g&&i<=1)return r&&(e.__index=s+1),g&&o&&o.clone?g.clone():g;if(g=u.create(a),r&&(g.__read=!0),g=g.initialize.apply(g,s>0||s+i<l?u.slice(e,s,s+i):e)||g,r){e.__index=s+g.__read;var c=g.__filtered;c&&(e.__filtered=c,g.__filtered=A),g.__read=A}return g},peek:function(e,t){return e[e.__index=t||e.__index||0]},remain:function(e){return e.length-(e.__index||0)},readList:function(e,t,o,i){for(var n,a=[],r=t||0,A=i?r+i:e.length,s=r;s<A;s++)a.push(Array.isArray(n=e[s])?this.read(n,0,o):this.read(e,s,o,1));return a},readNamed:function(e,t,o,i,n){var a=this.getNamed(e,t),r=a!==A;if(r){var s=e.__filtered;if(!s){var l=this.getSource(e);(s=e.__filtered=u.create(l)).__unfiltered=l}s[t]=A}return this.read(r?[a]:e,o,i,n)},readSupported:function(e,t){var o=this.getSource(e),i=this,n=!1;return o&&Object.keys(o).forEach(function(o){if(o in t){var a=i.readNamed(e,o);a!==A&&(t[o]=a),n=!0}}),n},getSource:function(e){var t=e.__source;if(t===A){var o=1===e.length&&e[0];t=e.__source=o&&u.isPlainObject(o)?o:null}return t},getNamed:function(e,t){var o=this.getSource(e);if(o)return t?o[t]:e.__filtered||o},hasNamed:function(e,t){return!!this.getNamed(e,t)},filter:function(e,t,o,i){var n;function a(i){if(!(o&&i in o||n&&i in n)){var a=t[i];a!==A&&(e[i]=a)}}if(i){for(var r,s={},l=0,u=i.length;l<u;l++)(r=i[l])in t&&(a(r),s[r]=!0);n=s}return Object.keys(t.__unfiltered||t).forEach(a),e},isPlainValue:function(e,t){return u.isPlainObject(e)||Array.isArray(e)||t&&"string"==typeof e},serialize:function(e,t,o,i){t=t||{};var n,a=!i;if(a&&(t.formatter=new p(t.precision),i={length:0,definitions:{},references:{},add:function(e,t){var o="#"+e._id,i=this.references[o];if(!i){this.length++;var n=t.call(e),a=e._class;a&&n[0]!==a&&n.unshift(a),this.definitions[o]=n,i=this.references[o]=[o]}return i}}),e&&e._serialize){n=e._serialize(t,i);var r=e._class;!r||e._compactSerialize||!a&&o||n[0]===r||n.unshift(r)}else if(Array.isArray(e)){n=[];for(var A=0,s=e.length;A<s;A++)n[A]=u.serialize(e[A],t,o,i)}else if(u.isPlainObject(e)){n={};var l=Object.keys(e);for(A=0,s=l.length;A<s;A++){var g=l[A];n[g]=u.serialize(e[g],t,o,i)}}else n="number"==typeof e?t.formatter.number(e,t.precision):e;return a&&i.length>0?[["dictionary",i.definitions],n]:n},deserialize:function(e,t,o,i,n){var a=e,r=!o,A=r&&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;g<c;g++)a.push(u.deserialize(e[g],t,o,l,A));if(s){var d=a;a=t?t(s,d,r||n):new s(d)}}else if(u.isPlainObject(e))for(var h in a={},i&&(o.dictionary=a),e)a[h]=u.deserialize(e[h],t,o);return A?a[1]:a},exportJSON:function(e,t){var o=u.serialize(e,t);return t&&0==t.asString?o:JSON.stringify(o)},importJSON:function(e,t){return u.deserialize("string"==typeof e?JSON.parse(e):e,function(e,o,i){var n=i&&t&&t.constructor===e,a=n?t:u.create(e.prototype);if(1===o.length&&a instanceof w&&(n||!(a instanceof f))){var r=o[0];u.isPlainObject(r)&&(r.insert=!1,n&&(o=o.concat([{insert:!0}])))}return(n?a.set:e).apply(a,o),n&&(t=null),a})},push:function(e,t){var o=t.length;if(o<4096)e.push.apply(e,t);else{var i=e.length;e.length+=o;for(var n=0;n<o;n++)e[i+n]=t[n]}return e},splice:function(e,t,o,i){var n=t&&t.length,a=o===A;(o=a?e.length:o)>e.length&&(o=e.length);for(var r=0;r<n;r++)t[r]._index=o+r;if(a)return u.push(e,t),[];var s=[o,i];t&&u.push(s,t);for(var l=e.splice.apply(e,s),g=(r=0,l.length);r<g;r++)l[r]._index=A;for(r=o+n,g=e.length;r<g;r++)e[r]._index=r;return l},capitalize:function(e){return e.replace(/\b[a-z]/g,function(e){return e.toUpperCase()})},camelize:function(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})},hyphenate:function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}});var g={on:function(e,t){if("string"!=typeof e)u.each(e,function(e,t){this.on(t,e)},this);else{var o=this._eventTypes,i=o&&o[e],n=this._callbacks=this._callbacks||{};-1===(n=n[e]=n[e]||[]).indexOf(t)&&(n.push(t),i&&i.install&&1===n.length&&i.install.call(this,e))}return this},off:function(e,t){if("string"==typeof e){var o,i=this._eventTypes,n=i&&i[e],a=this._callbacks&&this._callbacks[e];return a&&(!t||-1!==(o=a.indexOf(t))&&1===a.length?(n&&n.uninstall&&n.uninstall.call(this,e),delete this._callbacks[e]):-1!==o&&a.splice(o,1)),this}u.each(e,function(e,t){this.off(t,e)},this)},once:function(e,t){return this.on(e,function o(){t.apply(this,arguments),this.off(e,o)})},emit:function(e,t){var o=this._callbacks&&this._callbacks[e];if(!o)return!1;var i=u.slice(arguments,1),n=t&&t.target&&!t.currentTarget;o=o.slice(),n&&(t.currentTarget=this);for(var a=0,r=o.length;a<r;a++)if(0==o[a].apply(this,i)){t&&t.stop&&t.stop();break}return n&&delete t.currentTarget,!0},responds:function(e){return!(!this._callbacks||!this._callbacks[e])},attach:"#on",detach:"#off",fire:"#emit",_installEvents:function(e){var t=this._eventTypes,o=this._callbacks,i=e?"install":"uninstall";if(t)for(var n in o)if(o[n].length>0){var a=t[n],r=a&&a[i];r&&r.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,r=u.capitalize(a),A=a.substring(2).toLowerCase();i[A]=n?{}:e,a="_"+a,t["get"+r]=function(){return this[a]},t["set"+r]=function(e){var t=this[a];t&&this.off(A,t),e&&this.on(A,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=r.navigator.userAgent.toLowerCase(),n=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(i)||[])[0],a="darwin"===n?"mac":n,A=t.agent=t.browser={platform:a};a&&(A[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(!A.chrome){var a="opera"===t?i:/^(node|trident)$/.test(t)?n:o;A.version=a,A.versionNumber=parseFloat(a),t={trident:"msie",jsdom:"node"}[t]||t,A.name=t,A[t]=!0}}),A.chrome&&delete A.webkit,A.atom&&delete A.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 X.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 y(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()}}),h={findItemBoundsCollisions:function(e,t,o){function i(e){for(var t=new Array(e.length),o=0;o<e.length;o++){var i=e[o].getBounds();t[o]=[i.left,i.top,i.right,i.bottom]}return t}var n=i(e),a=t&&t!==e?i(t):n;return this.findBoundsCollisions(n,a,o||0)},findCurveBoundsCollisions:function(e,t,o,i){function n(e){for(var t=Math.min,o=Math.max,i=new Array(e.length),n=0;n<e.length;n++){var a=e[n];i[n]=[t(a[0],a[2],a[4],a[6]),t(a[1],a[3],a[5],a[7]),o(a[0],a[2],a[4],a[6]),o(a[1],a[3],a[5],a[7])]}return i}var a=n(e),r=t&&t!==e?n(t):a;if(i){for(var A=this.findBoundsCollisions(a,r,o||0,!1,!0),s=this.findBoundsCollisions(a,r,o||0,!0,!0),l=[],u=0,g=A.length;u<g;u++)l[u]={hor:A[u],ver:s[u]};return l}return this.findBoundsCollisions(a,r,o||0)},findBoundsCollisions:function(e,t,o,i,n){var a=!t||e===t,r=a?e:e.concat(t),A=e.length,s=r.length;function l(e,t,o){for(var i=0,n=e.length;i<n;){var a=n+i>>>1;r[e[a]][t]<o?i=a+1:n=a}return i-1}for(var u=i?1:0,g=u+2,c=i?0:1,d=c+2,h=new Array(s),p=0;p<s;p++)h[p]=p;h.sort(function(e,t){return r[e][u]-r[t][u]});var E=[],m=new Array(A);for(p=0;p<s;p++){var T=h[p],C=r[T],I=a?T:T-A,B=T<A,S=a||!B,O=B?[]:null;if(E.length){var M=l(E,g,C[u]-o)+1;if(E.splice(0,M),a&&n){O=O.concat(E);for(var N=0;N<E.length;N++){m[b=E[N]].push(I)}}else{var y=C[d],w=C[c];for(N=0;N<E.length;N++){var b=E[N],f=r[b],k=b<A,D=a||b>=A;(n||(B&&D||S&&k)&&y>=f[c]-o&&w<=f[d]+o)&&(B&&D&&O.push(a?b:b-A),S&&k&&m[b].push(I))}}}if(B&&(e===t&&O.push(T),m[T]=O),E.length){var R=l(E,g,C[g]);E.splice(R+1,0,T)}else E.push(T)}for(p=0;p<m.length;p++){var _=m[p];_&&_.sort(function(e,t){return e-t})}return m}},p=u.extend({initialize:function(e){this.precision=u.pick(e,5),this.multiplier=Math.pow(10,this.precision)},number:function(e){return this.precision<16?Math.round(e*this.multiplier)/this.multiplier:e},pair:function(e,t,o){return this.number(e)+(o||",")+this.number(t)},point:function(e,t){return this.number(e.x)+(t||",")+this.number(e.y)},size:function(e,t){return this.number(e.width)+(t||",")+this.number(e.height)},rectangle:function(e,t){return this.point(e,t)+(t||",")+this.size(e,t)}});p.instance=new p;var E=new function(){var e=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],t=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],o=Math.abs,i=Math.sqrt,n=Math.pow,a=Math.log2||function(e){return Math.log(e)*Math.LOG2E},r=1e-12,A=112e-18;function s(e,t,o){return e<t?t:e>o?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,r=t*t+e*i;if(3*o(a)<r){var A=n(e),s=n(t),l=n(i),u=t*t,g=e*i;a=u-g+(s[0]*s[0]-u+2*s[0]*s[1]+s[1]*s[1]-(A[0]*l[0]-g+A[0]*l[1]+A[1]*l[0]+A[1]*l[1]))}return a}function u(){var e=Math.max.apply(Math,arguments);return e&&(e<1e-8||e>1e8)?n(2,-Math.round(a(e))):0}return{EPSILON:r,MACHINE_EPSILON:A,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<=r},isMachineZero:function(e){return e>=-112e-18&&e<=A},clamp:s,integrate:function(o,i,n,a){for(var r=e[a-2],A=t[a-2],s=.5*(n-i),l=s+i,u=0,g=a+1>>1,c=1&a?A[u++]*o(l):0;u<g;){var d=s*r[u];c+=A[u++]*(o(l+d)+o(l-d))}return s*c},findRoot:function(e,t,i,n,a,r,A){for(var l=0;l<r;l++){var u=e(i),g=u/t(i),c=i-g;if(o(g)<A){i=c;break}u>0?(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,h=1/0;if(o(e)<r){if(o(t)<r)return o(n)<r?-1:0;d=-n/t}else{var p=l(e,t*=-.5,n);if(p&&o(p)<A){var E=u(o(e),o(t),o(n));E&&(p=l(e*=E,t*=E,n*=E))}if(p>=-112e-18){var m=p<0?0:i(p),T=t+(t<0?-m:m);0===T?h=-(d=n/e):(d=T/e,h=n/T)}}var C=0,I=null==g,B=g-r,S=c+r;return isFinite(d)&&(I||d>B&&d<S)&&(a[C++]=I?d:s(d,g,c)),h!==d&&isFinite(h)&&(I||h>B&&h<S)&&(a[C++]=I?h:s(h,g,c)),C},solveCubic:function(e,t,a,l,g,c,d){var h,p,m,T,C,I=u(o(e),o(t),o(a),o(l));function B(o){var i=e*(h=o);T=(i+(p=i+t))*h+(m=p*h+a),C=m*h+l}if(I&&(e*=I,t*=I,a*=I,l*=I),o(e)<r)e=t,p=a,m=l,h=1/0;else if(o(l)<r)p=t,m=a,h=0;else{B(-t/e/3);var S=C/e,O=n(o(S),1/3),M=S<0?-1:1,N=-T/e,y=N>0?1.324717957244746*Math.max(O,i(N)):O,w=h-M*y;if(w!==h){do{B(w),w=0===T?h:h-C/T/(1+A)}while(M*w>M*h);o(e)*h*h>o(l/h)&&(p=((m=-l/h)-a)/h)}}var b=E.solveQuadratic(e,p,m,g,c,d),f=null==c;return isFinite(h)&&(0===b||b>0&&h!==g[0]&&h!==g[1])&&(f||h>c-r&&h<d+r)&&(g[b++]=f?h:s(h,c,d)),b}}},m={_id:1,_pools:{},get:function(e){if(e){var t=this._pools[e];return t||(t=this._pools[e]={_id:1}),t._id++}return this._id++}},T=u.extend({_class:"Point",_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 r="string"===o?e.split(/[\s,]+/)||[]:e;n=1,Array.isArray(r)?this._set(+r[0],+(r.length>1?r[1]:r[0])):"x"in r?this._set(r.x||0,r.y||0):"width"in r?this._set(r.width||0,r.height||0):"angle"in r?(this._set(r.length||0,0),this.setAngle(r.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=p.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();E.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(E.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===A&&(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=E.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 r="string"===o?e.split(/[\s,]+/)||[]:e;n=1,Array.isArray(r)?this._set(+r[0],+(r.length>1?r[1]:r[0])):"width"in r?this._set(r.width||0,r.height||0):"x"in r?this._set(r.x||0,r.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=p.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=E.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,r=typeof e;if("number"===r?(this._set(e,t,o,i),n=4):"undefined"===r||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!==A||e.width!==A?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),n=1):e.from===A&&e.to===A&&(this._set(0,0,0,0),u.readSupported(a,this)&&(n=1))),n===A){var s,l,g=T.readNamed(a,"from"),c=u.peek(a),d=g.x,h=g.y;if(c&&c.x!==A||u.hasNamed(a,"to")){var p=T.readNamed(a,"to");s=p.x-d,l=p.y-h,s<0&&(d=p.x,s=-s),l<0&&(h=p.y,l=-l)}else{var E=I.read(a);s=E.width,l=E.height}this._set(d,h,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=p.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!==A||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<this.x+this.width+t&&e.y<this.y+this.height+t},intersect:function(){var e=S.read(arguments),t=Math.max(this.x,e.x),o=Math.max(this.y,e.y),i=Math.min(this.x+this.width,e.x+e.width),n=Math.min(this.y+this.height,e.y+e.height);return new S(t,o,i-t,n-o)},unite:function(){var e=S.read(arguments),t=Math.min(this.x,e.x),o=Math.min(this.y,e.y),i=Math.max(this.x+this.width,e.x+e.width),n=Math.max(this.y+this.height,e.y+e.height);return new S(t,o,i-t,n-o)},include:function(){var e=T.read(arguments),t=Math.min(this.x,e.x),o=Math.min(this.y,e.y),i=Math.max(this.x+this.width,e.x),n=Math.max(this.y+this.height,e.y);return new S(t,o,i-t,n-o)},expand:function(){var e=I.read(arguments),t=e.width,o=e.height;return new S(this.x-t/2,this.y-o/2,this.width+t,this.height+o)},scale:function(e,t){return this.expand(this.width*e-this.width,this.height*(t===A?e:t)-this.height)}},u.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(e,t){var o=e.join(""),i=/^[RL]/.test(o);t>=4&&(e[1]+=i?"Y":"X");var n=e[i?0:1],a=e[i?1:0],r="get"+n,A="get"+a,s="set"+n,l="set"+a,u="set"+o;this["get"+o]=function(e){return new(e?T:C)(this[r](),this[A](),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)}}))}),M=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,r){return this._a=e,this._b=t,this._c=o,this._d=i,this._tx=n,this._ty=a,r||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 M(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=p.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),r=o-o*n+i*a,A=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+=r*s+A*u,this._ty+=r*l+A*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,r=e._a,A=e._c,s=e._b,l=e._d,u=e._tx,g=e._ty;this._a=r*o+s*n,this._c=A*o+l*n,this._b=r*i+s*a,this._d=A*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,r=this._tx,A=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*r+l*A+c,this._ty=u*r+g*A+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,r=e*i-t*o,A=null;return r&&!isNaN(r)&&isFinite(n)&&isFinite(a)&&(this._a=i/r,this._b=-t/r,this._c=-o/r,this._d=e/r,this._tx=(o*a-i*n)/r,this._ty=(t*n-e*a)/r,A=this),A},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new M(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var 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;i<n;i+=2){var a=e[i],r=e[i+1];t[i]=a*this._a+r*this._c+this._tx,t[i+1]=a*this._b+r*this._d+this._ty}return t},_transformCorners:function(e){var t=e.x,o=e.y,i=t+e.width,n=o+e.height,a=[t,o,i,o,i,n,t,n];return this._transformCoordinates(a,a,4)},_transformBounds:function(e,t,o){for(var i=this._transformCorners(e),n=i.slice(0,2),a=n.slice(),r=2;r<8;r++){var A=i[r],s=1&r;A<n[s]?n[s]=A:A>a[s]&&(a[s]=A)}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,r=this._d,A=this._tx,s=this._ty,l=i*r-n*a,u=null;if(l&&!isNaN(l)&&isFinite(A)&&isFinite(s)){var g=e.x-this._tx,c=e.y-this._ty;t||(t=new T),u=t._set((g*r-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,r=this._d,A=i*r-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,A/g],o=[l(i*a+n*r,g*g),0]}else if(0!==a||0!==r){var c=s(a*a+r*r);e=Math.asin(a/c)*(r>0?1:-1),t=[A/c,c],o=[0,l(i*a+n*r,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()}},{})),N=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 N.intersect(this._px,this._py,this._vx,this._vy,e._px,e._py,e._vx,e._vy,!0,t)},getSide:function(e,t){return N.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 N.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,r,A,s,l){s||(o-=e,i-=t,r-=n,A-=a);var u=o*A-i*r;if(!E.isMachineZero(u)){var g=e-n,c=t-a,d=(r*c-A*g)/u,h=(o*c-i*g)/u,p=-1e-12,m=1+1e-12;if(l||p<d&&d<m&&p<h&&h<m)return l||(d=d<=0?0:d>=1?1:d),new T(e+d*o,t+d*i)}},getSide:function(e,t,o,i,n,a,r,A){r||(o-=e,i-=t);var s=n-e,l=s*i-(a-t)*o;return!A&&E.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,r){return r||(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,r){return Math.abs(N.getSignedDistance(e,t,o,i,n,a,r))}}}),y=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=X.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,r=n[a];r?r.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 f({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;t<o;t++)e[t].setFullySelected(!0)},deselectAll:function(){var e=this._selectionItems;for(var t in e)e[t].setFullySelected(!1)},addLayer:function(e){return this.insertLayer(A,e)},insertLayer:function(e,t){if(t instanceof f){t._remove(!1,!0),u.splice(this._children,[t],e,0),t._setProject(this,!0);var o=t._name;o&&t.setName(o),this._changes&&t._changed(5),this._activeLayer||(this._activeLayer=t)}else t=null;return t},_insertItem:function(e,t,o){return t=this.insertLayer(e,t)||(this._activeLayer||this._insertItem(A,new f(w.NO_INSERT),!0)).insertChild(e,t),o&&t.activate&&t.activate(),t},getItems:function(e){return w._getItems(this,e)},getItem:function(e){return w._getItems(this,e,null,null,!0)[0]||null},importJSON:function(e){this.activate();var t=this._activeLayer;return u.importJSON(e,t&&t.isEmpty()&&t)},removeOn:function(e){var t=this._removeSets;if(t){"mouseup"===e&&(t.mousedrag=null);var o=t[e];if(o){for(var i in o){var n=o[i];for(var a in t){var r=t[a];r&&r!=o&&delete r[n._id]}n.remove()}t[e]=null}}},draw:function(e,t,o){this._updateVersion++,e.save(),t.applyToContext(e);for(var i=this._children,n=new u({offset:new T(0,0),pixelRatio:o,viewMatrix:t.isIdentity()?null:t,matrices:[new M],updateMatrix:!0}),a=0,r=i.length;a<r;a++)i[a].draw(e,n);if(e.restore(),this._selectionCount>0){e.save(),e.strokeWidth=1;var A=this._selectionItems,s=this._scope.settings.handleSize,l=this._updateVersion;for(var g in A)A[g]._drawSelection(e,t,s,A,l);e.restore()}}}),w=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 M,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 M,a=o&&e.project||ce.project,r=ce.settings;return this._id=i?null:m.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&r.applyMatrix,t&&n.translate(t),n._owner=this,this._style=new J(a._currentStyle,this,a),i||o&&0==e.insert||!r.insertItems&&(!o||!0!==e.insert)?this._setProject(a):(o&&e.parent||a)._insertItem(A,this,!0),o&&e!==w.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 r=i[a];u.equals(r,"leading"===a?1.2*n.fontSize:n[a])||(o[a]=u.serialize(r,e,"data"!==a,t))}}return n(this._serializeFields),this instanceof b||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=A),16&e&&(this._globalMatrix=A),o&&72&e&&w._clearBoundsCache(o),2&e&&w._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||A,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<o;t++)if(e[t].isSelected())return!0;return!!(1&this._selection)},setSelected:function(e){if(this._selectChildren)for(var t=this._children,o=0,i=t.length;o<i;o++)t[o].setSelected(e);this._changeSelection(1,e)},isFullySelected:function(){var e=this._children,t=!!(1&this._selection);if(e&&t){for(var o=0,i=e.length;o<i;o++)if(!e[o].isFullySelected())return!1;return!0}return t},setFullySelected:function(e){var t=this._children;if(t)for(var o=0,i=t.length;o<i;o++)t[o].setFullySelected(e);this._changeSelection(1,e)},isClipMask:function(){return this._clipMask},setClipMask:function(e){this._clipMask!=(e=!!e)&&(this._clipMask=e,e&&(this.setFillColor(null),this.setStrokeColor(null)),this._changed(257),this._parent&&this._parent._changed(2048))},getData:function(){return this._data||(this._data={}),this._data},setData:function(e){this._data=e},getPosition:function(e){var t=e?T:C,o=this._position||(this._position=this._getPositionFromBounds());return new t(o.x,o.y,this,"setPosition")},setPosition:function(){this.translate(T.read(arguments).subtract(this.getPosition(!0)))},_getPositionFromBounds:function(e){return this._pivot?this._matrix._transformPoint(this._pivot):(e||this.getBounds()).getCenter(!0)},getPivot:function(){var e=this._pivot;return e?new C(e.x,e.y,this,"setPivot"):null},setPivot:function(){this._pivot=T.read(arguments,0,{clone:!0,readNull:!0}),this._position=A}},u.each({getStrokeBounds:{stroke:!0},getHandleBounds:{handle:!0},getInternalBounds:{internal:!0},getDrawnBounds:{stroke:!0,drawnTextBounds:!0}},function(e,t){this[t]=function(t){return this.getBounds(t,e)}},{beans:!0,getBounds:function(e,t){var o=t||e instanceof M,i=u.set({},o?t:e,this._boundsOptions);i.stroke&&!this.getStrokeScaling()||(i.cacheItem=this);var n=this._getCachedBounds(o&&e,i).rect;return arguments.length?n:new O(n.x,n.y,n.width,n.height,this,"setBounds")},setBounds:function(){var e=S.read(arguments),t=this.getBounds(),o=this._matrix,i=new M,n=e.getCenter();i.translate(n),e.width==t.width&&e.height==t.height||(o.isInvertible()||(o.set(o._backup||(new M).translate(o.getTranslation())),t=this.getBounds()),i.scale(0!==t.width?e.width/t.width:0,0!==t.height?e.height/t.height:0)),n=t.getCenter(),i.translate(-n.x,-n.y),this.transform(i)},_getBounds:function(e,t){var o=this._children;return o&&o.length?(w._updateBoundsCache(this,t.cacheItem),w._getBounds(o,e,t)):new S},_getBoundsCacheKey:function(e,t){return[e.stroke?1:0,e.handle?1:0,e.drawnTextBounds?1:0,t?1:0].join("")},_getCachedBounds:function(e,t,o){e=e&&e._orNullIfIdentity();var i=t.internal&&!o,n=t.cacheItem,a=i?null:this._matrix._orNullIfIdentity(),r=n&&(!e||e.equals(a))&&this._getBoundsCacheKey(t,i),A=this._bounds;if(w._updateBoundsCache(this._parent||this._symbol,n),r&&A&&r in A)return{rect:(c=A[r]).rect.clone(),nonscaling:c.nonscaling};var s=this._getBounds(e||a,t),l=s.rect||s,u=this._style,g=s.nonscaling||u.hasStroke()&&!u.getStrokeScaling();if(r){A||(this._bounds=A={});var c=A[r]={rect:l.clone(),nonscaling:g,internal:i}}return{rect:l,nonscaling:g}},_getStrokeMatrix:function(e,t){var o=this.getStrokeScaling()?null:t&&t.internal?this:this._parent||this._symbol&&this._symbol._item,i=o?o.getViewMatrix().invert():e;return i&&i._shiftless()},statics:{_updateBoundsCache:function(e,t){if(e&&t){var o=t._id,i=e._boundsCache=e._boundsCache||{ids:{},list:[]};i.ids[o]||(i.list.push(t),i