react-sketch
Version:
Sketch Element for React based applications, backed-up by fabricjs as its core
3 lines • 339 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("jsdom"));else if("function"==typeof define&&define.amd)define(["jsdom"],e);else{var i="object"==typeof exports?e(require("jsdom")):e(t.jsdom);for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}(window,function(f){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=28)}([function(t,e,i){t.exports=i(17)()},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function i(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t}},function(t,e,i){var r=i(12),n=i(13);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?n(t):e}},function(t,e){function i(e){return t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},i(e)}t.exports=i},function(t,e,i){var r=i(14);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,i){(function(t){
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
var r,n,o,s,a,h,c,l,u,f,d,g,p,v,m,y,_,b,x,C,S,w,T,O,E,k,P,A=A||{version:"2.4.3"};function D(t,e){var i=t.canvas,r=e.targetCanvas,n=r.getContext("2d");n.translate(0,r.height),n.scale(1,-1);var o=i.height-r.height;n.drawImage(i,0,o,r.width,r.height,0,0,r.width,r.height)}function j(t,e){var i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,n=e.destinationHeight,o=r*n*4,s=new Uint8Array(this.imageBuffer,0,o),a=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,r,n,t.RGBA,t.UNSIGNED_BYTE,s);var h=new ImageData(a,r,n);i.putImageData(h,0,0)}e.fabric=A,"undefined"!=typeof document&&"undefined"!=typeof window?(A.document=document,A.window=window):(A.document=i(24).jsdom(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]}}),A.jsdomImplForWrapper=i(25).implForWrapper,A.nodeCanvas=i(26).Canvas,A.window=A.document.defaultView,DOMParser=i(27).DOMParser),A.isTouchSupported="ontouchstart"in A.window,A.isLikelyNode=void 0!==t&&"undefined"==typeof window,A.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","instantiated_by_use","clip-path"],A.DPI=96,A.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",A.fontPaths={},A.iMatrix=[1,0,0,1,0,0],A.canvasModule="canvas",A.perfLimitSizeTotal=2097152,A.maxCacheSideLimit=4096,A.minCacheSideLimit=256,A.charWidthsCache={},A.textureSize=2048,A.enableGLFiltering=!0,A.devicePixelRatio=A.window.devicePixelRatio||A.window.webkitDevicePixelRatio||A.window.mozDevicePixelRatio||1,A.browserShadowBlurConstant=1,A.arcToSegmentsCache={},A.boundsOfCurveCache={},A.cachesBoundsOfCurve=!0,A.initFilterBackend=function(){return A.enableGLFiltering&&A.isWebglSupported&&A.isWebglSupported(A.textureSize)?(console.log("max texture size: "+A.maxTextureSize),new A.WebglFilterBackend({tileSize:A.textureSize})):A.Canvas2dFilterBackend?new A.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=A),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:A.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(this.__eventListeners){if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof e)for(var r in e)t.call(this,r,e[r]);else t.call(this,e,i);return this}}function r(t,e){if(this.__eventListeners){var i=this.__eventListeners[t];if(i){for(var r=0,n=i.length;r<n;r++)i[r]&&i[r].call(this,e||{});return this.__eventListeners[t]=i.filter(function(t){return!1!==t}),this}}}A.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}}(),A.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(t,e,i){var r=this._objects;return i?r[e]=t:r.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,r=0,n=arguments.length;r<n;r++)-1!==(t=e.indexOf(arguments[r]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[r]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),r=0,n=i.length;r<n;r++)t.call(e,i[r],r,i);return this},getObjects:function(t){return void 0===t?this._objects.concat():this._objects.filter(function(e){return e.type===t})},item:function(t){return this._objects[t]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(t){return-1<this._objects.indexOf(t)},complexity:function(){return this._objects.reduce(function(t,e){return t+(e.complexity?e.complexity():0)},0)}},A.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof A.Gradient||this.set(e,new A.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof A.Pattern?i&&i():this.set(e,new A.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=A.util.getFunctionBody(t.clipTo);void 0!==e&&(this.clipTo=new Function("ctx",e))}},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},r=e,n=Math.sqrt,o=Math.atan2,s=Math.pow,a=Math.abs,h=Math.PI/180,c=Math.PI/2,A.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/c){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/c){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*h},radiansToDegrees:function(t){return t/h},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=A.util.rotateVector(t,i);return new A.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=A.util.sin(e),r=A.util.cos(e);return{x:t.x*r-t.y*i,y:t.x*i+t.y*r}},transformPoint:function(t,e,i){return i?new A.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new A.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t){var e=[t[0].x,t[1].x,t[2].x,t[3].x],i=A.util.array.min(e),r=A.util.array.max(e)-i,n=[t[0].y,t[1].y,t[2].y,t[3].y],o=A.util.array.min(n);return{left:i,top:o,width:r,height:A.util.array.max(n)-o}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=A.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-r.x,i[5]=-r.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);switch(e||(e=A.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*A.DPI/25.4;case"cm":return r*A.DPI/2.54;case"in":return r*A.DPI;case"pt":return r*A.DPI/72;case"pc":return r*A.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=A.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),A.util.resolveNamespace(e)[t]},getSvgAttributes:function(t){var e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":e=e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":e=e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":e=e.concat(["offset","stop-color","stop-opacity"])}return e},resolveNamespace:function(t){if(!t)return A;var e,i=t.split("."),n=i.length,o=r||A.window;for(e=0;e<n;++e)o=o[i[e]];return o},loadImage:function(t,e,i,r){if(t){var n=A.util.createImage(),o=function(){e&&e.call(i,n),n=n.onload=n.onerror=null};n.onload=o,n.onerror=function(){A.log("Error loading "+n.src),e&&e.call(i,null,!0),n=n.onload=n.onerror=null},0!==t.indexOf("data")&&r&&(n.crossOrigin=r),"data:image/svg"===t.substring(0,14)&&(n.onload=null,A.util.loadImageInDom(n,o)),n.src=t}else e&&e.call(i,t)},loadImageInDom:function(t,e){var i=A.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),A.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,r){function n(){++s===a&&e&&e(o)}var o=[],s=0,a=(t=t||[]).length;a?t.forEach(function(t,e){t&&t.type?A.util.getKlass(t.type,i).fromObject(t,function(i,s){s||(o[e]=i),r&&r(t,i,s),n()}):n()}):e&&e(o)},enlivenPatterns:function(t,e){function i(){++n===o&&e&&e(r)}var r=[],n=0,o=(t=t||[]).length;o?t.forEach(function(t,e){t&&t.source?new A.Pattern(t,function(t){r[e]=t,i()}):(r[e]=t,i())}):e&&e(r)},groupSVGElements:function(t,e,i){var r;return t&&1===t.length?t[0]:(e&&(e.width&&e.height?e.centerPoint={x:e.width/2,y:e.height/2}:(delete e.width,delete e.height)),r=new A.Group(t,e),void 0!==i&&(r.sourcePath=i),r)},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var r=0,n=i.length;r<n;r++)i[r]in t&&(e[i[r]]=t[i[r]])},drawDashedLine:function(t,e,i,r,s,a){var h=r-e,c=s-i,l=n(h*h+c*c),u=o(c,h),f=a.length,d=0,g=!0;for(t.save(),t.translate(e,i),t.moveTo(0,0),t.rotate(u),e=0;e<l;)l<(e+=a[d++%f])&&(e=l),t[g?"lineTo":"moveTo"](e,0),g=!g;t.restore()},createCanvasElement:function(){return A.document.createElement("canvas")},copyCanvasElement:function(t){var e=A.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},createImage:function(){return A.document.createElement("img")},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var e=o(t[1],t[0]),i=s(t[0],2)+s(t[1],2),r=n(i),a=(t[0]*t[3]-t[2]*t[1])/r,c=o(t[0]*t[2]+t[1]*t[3],i);return{angle:e/h,scaleX:r,scaleY:a,skewX:c/h,skewY:0,translateX:t[4],translateY:t[5]}},customTransformMatrix:function(t,e,i){var r=[1,0,a(Math.tan(i*h)),1],n=[a(t),0,0,a(e)];return A.util.multiplyTransformMatrices(n,r,!0)},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,r){0<r&&(r<e?e-=r:e=0,r<i?i-=r:i=0);var n,o=!0,s=t.getImageData(e,i,2*r||1,2*r||1),a=s.data.length;for(n=3;n<a&&0!=(o=s.data[n]<=0);n+=4);return s=null,o},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",r=t.split(" ");return r&&r.length&&("meet"!==(i=r.pop())&&"slice"!==i?(e=i,i="meet"):r.length&&(e=r.pop())),{meetOrSlice:i,alignX:"none"!==e?e.slice(1,4):"none",alignY:"none"!==e?e.slice(5,8):"none"}},clearFabricFontCache:function(t){(t=(t||"").toLowerCase())?A.charWidthsCache[t]&&delete A.charWidthsCache[t]:A.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),r=Math.floor(e/i);return{x:Math.floor(i),y:r}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))},findScaleToFit:function(t,e){return Math.min(e.width/t.width,e.height/t.height)},findScaleToCover:function(t,e){return Math.max(e.width/t.width,e.height/t.height)}},function(){var t=Array.prototype.join;function e(e,r,n,o,s,a,h){var c=t.call(arguments);if(A.arcToSegmentsCache[c])return A.arcToSegmentsCache[c];var l=Math.PI,u=h*l/180,f=A.util.sin(u),d=A.util.cos(u),g=0,p=0,v=-d*e*.5-f*r*.5,m=-d*r*.5+f*e*.5,y=(n=Math.abs(n))*n,_=(o=Math.abs(o))*o,b=m*m,x=v*v,C=y*_-y*b-_*x,S=0;if(C<0){var w=Math.sqrt(1-C/(y*_));n*=w,o*=w}else S=(s===a?-1:1)*Math.sqrt(C/(y*b+_*x));var T=S*n*m/o,O=-S*o*v/n,E=d*T-f*O+.5*e,k=f*T+d*O+.5*r,P=i(1,0,(v-T)/n,(m-O)/o),D=i((v-T)/n,(m-O)/o,(-v-T)/n,(-m-O)/o);0===a&&0<D?D-=2*l:1===a&&D<0&&(D+=2*l);for(var j,M,F,I,L,R,B,Y,X,U,W,N,z,V,G,H,q,K=Math.ceil(Math.abs(D/l*2)),J=[],$=D/K,Z=8/3*Math.sin($/4)*Math.sin($/4)/Math.sin($/2),Q=P+$,tt=0;tt<K;tt++)J[tt]=(j=P,M=Q,F=d,I=f,L=n,R=o,B=E,Y=k,X=Z,U=g,W=p,N=A.util.cos(j),[U+X*(-F*L*(z=A.util.sin(j))-I*R*N),W+X*(-I*L*z+F*R*N),(H=F*L*(V=A.util.cos(M))-I*R*(G=A.util.sin(M))+B)+X*(F*L*G+I*R*V),(q=I*L*V+F*R*G+Y)+X*(I*L*G-F*R*V),H,q]),g=J[tt][4],p=J[tt][5],P=Q,Q+=$;return A.arcToSegmentsCache[c]=J}function i(t,e,i,r){var n=Math.atan2(e,t),o=Math.atan2(r,i);return n<=o?o-n:2*Math.PI-(n-o)}function r(e,i,r,n,o,s,a,h){var c;if(A.cachesBoundsOfCurve&&(c=t.call(arguments),A.boundsOfCurveCache[c]))return A.boundsOfCurveCache[c];var l,u,f,d,g,p,v,m,y=Math.sqrt,_=Math.min,b=Math.max,x=Math.abs,C=[],S=[[],[]];u=6*e-12*r+6*o,l=-3*e+9*r-9*o+3*a,f=3*r-3*e;for(var w=0;w<2;++w)if(0<w&&(u=6*i-12*n+6*s,l=-3*i+9*n-9*s+3*h,f=3*n-3*i),x(l)<1e-12){if(x(u)<1e-12)continue;0<(d=-f/u)&&d<1&&C.push(d)}else(v=u*u-4*f*l)<0||(0<(g=(-u+(m=y(v)))/(2*l))&&g<1&&C.push(g),0<(p=(-u-m)/(2*l))&&p<1&&C.push(p));for(var T,O,E,k=C.length,P=k;k--;)T=(E=1-(d=C[k]))*E*E*e+3*E*E*d*r+3*E*d*d*o+d*d*d*a,S[0][k]=T,O=E*E*E*i+3*E*E*d*n+3*E*d*d*s+d*d*d*h,S[1][k]=O;S[0][P]=e,S[1][P]=i,S[0][P+1]=a,S[1][P+1]=h;var D=[{x:_.apply(null,S[0]),y:_.apply(null,S[1])},{x:b.apply(null,S[0]),y:b.apply(null,S[1])}];return A.cachesBoundsOfCurve&&(A.boundsOfCurveCache[c]=D),D}A.util.drawArc=function(t,i,r,n){for(var o=n[0],s=n[1],a=n[2],h=n[3],c=n[4],l=[[],[],[],[]],u=e(n[5]-i,n[6]-r,o,s,h,c,a),f=0,d=u.length;f<d;f++)l[f][0]=u[f][0]+i,l[f][1]=u[f][1]+r,l[f][2]=u[f][2]+i,l[f][3]=u[f][3]+r,l[f][4]=u[f][4]+i,l[f][5]=u[f][5]+r,t.bezierCurveTo.apply(t,l[f])},A.util.getBoundsOfArc=function(t,i,n,o,s,a,h,c,l){for(var u,f=0,d=0,g=[],p=e(c-t,l-i,n,o,a,h,s),v=0,m=p.length;v<m;v++)u=r(f,d,p[v][0],p[v][1],p[v][2],p[v][3],p[v][4],p[v][5]),g.push({x:u[0].x+t,y:u[0].y+i}),g.push({x:u[1].x+t,y:u[1].y+i}),f=p[v][4],d=p[v][5];return g},A.util.getBoundsOfCurve=r}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var r=t.length-1,n=e?t[r][e]:t[r];if(e)for(;r--;)i(t[r][e],n)&&(n=t[r][e]);else for(;r--;)i(t[r],n)&&(n=t[r]);return n}}A.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var r=t.call(arguments,2),n=[],o=0,s=e.length;o<s;o++)n[o]=r.length?e[o][i].apply(e[o],r):e[o][i].call(e[o]);return n},min:function(t,i){return e(t,i,function(t,e){return t<e})},max:function(t,i){return e(t,i,function(t,e){return e<=t})}}}(),function(){function t(e,i,r){if(r)if(!A.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var n=0,o=i.length;n<o;n++)e[n]=t({},i[n],r)}else if(i&&"object"==typeof i)for(var s in i)i.hasOwnProperty(s)&&(e[s]=t({},i[s],r));else e=i;else for(var s in i)e[s]=i[s];return e}A.util.object={extend:t,clone:function(e,i){return t({},e,i)}},A.util.object.extend(A.util,A.Observable)}(),function(){function t(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||57343<i)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var r=t.charCodeAt(e+1);if(r<56320||57343<r)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var n=t.charCodeAt(e-1);if(n<55296||56319<n)throw"Low surrogate without preceding high surrogate";return!1}A.util.string={camelize:function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")},graphemeSplit:function(e){var i,r=0,n=[];for(r=0;r<e.length;r++)!1!==(i=t(e,r))&&n.push(i);return n}}}(),function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),r=function(t,e,r){for(var n in e)n in t.prototype&&"function"==typeof t.prototype[n]&&-1<(e[n]+"").indexOf("callSuper")?t.prototype[n]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=r;var n=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return n}}(n):t.prototype[n]=e[n],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function n(){}function o(e){for(var i=null,r=this;r.constructor.superclass;){var n=r.constructor.superclass.prototype[e];if(r[e]!==n){i=n;break}r=r.constructor.superclass.prototype}return i?1<arguments.length?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}A.util.createClass=function(){var i=null,s=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof s[0]&&(i=s.shift()),a.superclass=i,a.subclasses=[],i&&(n.prototype=i.prototype,a.prototype=new n,i.subclasses.push(a));for(var h=0,c=s.length;h<c;h++)r(a,s[h],i);return a.prototype.initialize||(a.prototype.initialize=e),(a.prototype.constructor=a).prototype.callSuper=o,a}}(),function(){function t(t){var e,i,r=Array.prototype.slice.call(arguments,1),n=r.length;for(i=0;i<n;i++)if(e=typeof t[r[i]],!/^(?:function|object|unknown)$/.test(e))return!1;return!0}var e,i,r,n,o=(r=0,function(t){return t.__uniqueID||(t.__uniqueID="uniqueID__"+r++)});function s(t,i){return{handler:i,wrappedHandler:(r=t,n=i,function(t){n.call(e(r),t||A.window.event)})};var r,n}n={},e=function(t){return n[t]},i=function(t,e){n[t]=e};var a,h,c=t(A.document.documentElement,"addEventListener","removeEventListener")&&t(A.window,"addEventListener","removeEventListener"),l=t(A.document.documentElement,"attachEvent","detachEvent")&&t(A.window,"attachEvent","detachEvent"),u={},f={};h=c?(a=function(t,e,i,r){t&&t.addEventListener(e,i,!l&&r)},function(t,e,i,r){t&&t.removeEventListener(e,i,!l&&r)}):l?(a=function(t,e,r){if(t){var n=o(t);i(n,t),u[n]||(u[n]={}),u[n][e]||(u[n][e]=[]);var a=s(n,r);u[n][e].push(a),t.attachEvent("on"+e,a.wrappedHandler)}},function(t,e,i){if(t){var r,n=o(t);if(u[n]&&u[n][e])for(var s=0,a=u[n][e].length;s<a;s++)(r=u[n][e][s])&&r.handler===i&&(t.detachEvent("on"+e,r.wrappedHandler),u[n][e][s]=null)}}):(a=function(t,e,i){if(t){var r,n,s=o(t);if(f[s]||(f[s]={}),!f[s][e]){f[s][e]=[];var a=t["on"+e];a&&f[s][e].push(a),t["on"+e]=(r=s,n=e,function(t){if(f[r]&&f[r][n])for(var e=f[r][n],i=0,o=e.length;i<o;i++)e[i].call(this,t||A.window.event)})}f[s][e].push(i)}},function(t,e,i){if(t){var r=o(t);if(f[r]&&f[r][e])for(var n=f[r][e],s=0,a=n.length;s<a;s++)n[s]===i&&n.splice(s,1)}}),A.util.addListener=a,A.util.removeListener=h;var d=function(t){return t.clientX},g=function(t){return t.clientY};function p(t,e,i){var r,n=t["touchend"===t.type?"changedTouches":"touches"];return n&&n[0]&&(r=n[0][i]),void 0===r&&(r=t[i]),r}A.isTouchSupported&&(d=function(t){return p(t,0,"clientX")},g=function(t){return p(t,0,"clientY")}),A.util.getPointer=function(t){t||(t=A.window.event);var e=t.target||("unknown"!=typeof t.srcElement?t.srcElement:null),i=A.util.getScrollLeftTop(e);return{x:d(t)+i.left,y:g(t)+i.top}}}(),u="string"==typeof(l=A.document.createElement("div")).style.opacity,f="string"==typeof l.style.filter,d=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,g=function(t){return t},u?g=function(t,e){return t.style.opacity=e,t}:f&&(g=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),d.test(i.filter)?(e=.9999<=e?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(d,e)):i.filter+=" alpha(opacity="+100*e+")",t}),A.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,-1<e.indexOf("opacity")?g(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var r in e)"opacity"===r?g(t,e[r]):i["float"===r||"cssFloat"===r?void 0===i.styleFloat?"cssFloat":"styleFloat":r]=e[r];return t},function(){var t,e,i,r,n=Array.prototype.slice,o=function(t){return n.call(t,0)};try{t=o(A.document.childNodes)instanceof Array}catch(t){}function s(t,e){var i=A.document.createElement(t);for(var r in e)"class"===r?i.className=e[r]:"for"===r?i.htmlFor=e[r]:i.setAttribute(r,e[r]);return i}function a(t){for(var e=0,i=0,r=A.document.documentElement,n=A.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===A.document?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(o=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=A.document.defaultView&&A.document.defaultView.getComputedStyle?function(t,e){var i=A.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=A.document.documentElement.style,r="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",A.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=A.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},A.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},A.util.getScript=function(t,e){var i=A.document.getElementsByTagName("head")[0],r=A.document.createElement("script"),n=!0;r.onload=r.onreadystatechange=function(t){if(n){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;n=!1,e(t||A.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)},A.util.getById=function(t){return"string"==typeof t?A.document.getElementById(t):t},A.util.toArray=o,A.util.makeElement=s,A.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},A.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=s(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},A.util.getScrollLeftTop=a,A.util.getElementOffset=function(t){var i,r,n=t&&t.ownerDocument,o={left:0,top:0},s={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!n)return s;for(var c in h)s[h[c]]+=parseInt(e(t,c),10)||0;return i=n.documentElement,void 0!==t.getBoundingClientRect&&(o=t.getBoundingClientRect()),r=a(t),{left:o.left+r.left-(i.clientLeft||0)+s.left,top:o.top+r.top-(i.clientTop||0)+s.top}},A.util.getElementStyle=e,A.util.getNodeCanvas=function(t){var e=A.jsdomImplForWrapper(t);return e._canvas||e._image},A.util.cleanUpJsdomNode=function(t){if(A.isLikelyNode){var e=A.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}A.util.request=function(e,i){i||(i={});var r,n,o=i.method?i.method.toUpperCase():"GET",s=i.onComplete||function(){},a=new A.window.XMLHttpRequest,h=i.body||i.parameters;return a.onreadystatechange=function(){4===a.readyState&&(s(a),a.onreadystatechange=t)},"GET"===o&&(h=null,"string"==typeof i.parameters&&(r=e,n=i.parameters,e=r+(/\?/.test(r)?"&":"?")+n)),a.open(o,e,!0),"POST"!==o&&"PUT"!==o||a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.send(h),a}}(),A.log=function(){},A.warn=function(){},"undefined"!=typeof console&&["log","warn"].forEach(function(t){void 0!==console[t]&&"function"==typeof console[t].apply&&(A[t]=function(){return console[t].apply(console,arguments)})}),function(){function t(){return!1}var e=A.window.requestAnimationFrame||A.window.webkitRequestAnimationFrame||A.window.mozRequestAnimationFrame||A.window.oRequestAnimationFrame||A.window.msRequestAnimationFrame||function(t){return A.window.setTimeout(t,1e3/60)},i=A.window.cancelAnimationFrame||A.window.clearTimeout;function r(){return e.apply(A.window,arguments)}A.util.animate=function(e){r(function(i){e||(e={});var n,o=i||+new Date,s=e.duration||500,a=o+s,h=e.onChange||t,c=e.abort||t,l=e.onComplete||t,u=e.easing||function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},f="startValue"in e?e.startValue:0,d="endValue"in e?e.endValue:100,g=e.byValue||d-f;e.onStart&&e.onStart(),function t(i){if(c())l(d,1,1);else{n=i||+new Date;var p=a<n?s:n-o,v=p/s,m=u(p,f,g,s),y=Math.abs((m-f)/g);h(m,y,v),a<n?e.onComplete&&e.onComplete():r(t)}}(o)})},A.util.requestAnimFrame=r,A.util.cancelAnimFrame=function(){return i.apply(A.window,arguments)}}(),A.util.animateColor=function(t,e,i,r){var n=new A.Color(t).getSource(),o=new A.Color(e).getSource();r=r||{},A.util.animate(A.util.object.extend(r,{duration:i||500,startValue:n,endValue:o,byValue:o,easing:function(t,e,i,n){var o,s,a,h;return o=e,s=i,a=r.colorEasing?r.colorEasing(t,n):1-Math.cos(t/n*(Math.PI/2)),h="rgba("+parseInt(o[0]+a*(s[0]-o[0]),10)+","+parseInt(o[1]+a*(s[1]-o[1]),10)+","+parseInt(o[2]+a*(s[2]-o[2]),10),(h+=","+(o&&s?parseFloat(o[3]+a*(s[3]-o[3])):1))+")"}}))},function(){function t(t,e,i,r){return r=t<Math.abs(e)?(t=e,i/4):0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:r}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,n){return i-r(n-t,0,i,n)+e}function r(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}A.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return 0===t?e:t===r?e+i:(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,r,n,o){var s=0;return 0===i?r:1==(i/=o)?r+n:(s||(s=.3*o),-e(t(n,n,s,1.70158),i,o)+r)},easeOutElastic:function(e,i,r,n){var o=0;if(0===e)return i;if(1==(e/=n))return i+r;o||(o=.3*n);var s=t(r,r,o,1.70158);return s.a*Math.pow(2,-10*e)*Math.sin((e*n-s.s)*(2*Math.PI)/s.p)+s.c+i},easeInOutElastic:function(i,r,n,o){var s=0;if(0===i)return r;if(2==(i/=o/2))return r+n;s||(s=o*(.3*1.5));var a=t(n,n,s,1.70158);return i<1?-.5*e(a,i,o)+r:a.a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-a.s)*(2*Math.PI)/a.p)*.5+a.c+r},easeInBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*(t/=r)*t*((n+1)*t-n)+e},easeOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*((t=t/r-1)*t*((n+1)*t+n)+1)+e},easeInOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(n*=1.525))*t-n))+e:i/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},easeInBounce:i,easeOutBounce:r,easeInOutBounce:function(t,e,n,o){return t<o/2?.5*i(2*t,0,n,o)+e:.5*r(2*t-o,0,n,o)+.5*n+e}}}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n=e.util.toFixed,o=e.util.parseUnit,s=e.util.multiplyTransformMatrices,a={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule"},h={stroke:"strokeOpacity",fill:"fillOpacity"};function c(t,i,r,n){var a,h="[object Array]"===Object.prototype.toString.call(i);if("fill"!==t&&"stroke"!==t||"none"!==i)if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(function(t){return parseFloat(t)});else if("transformMatrix"===t)i=r&&r.transformMatrix?s(r.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,r&&!1===r.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),r&&void 0!==r.opacity&&(i*=r.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=o(i,n)/n*1e3;else if("paintFirst"===t){var c=i.indexOf("fill"),l=i.indexOf("stroke");i="fill",-1<c&&-1<l&&l<c?i="stroke":-1===c&&-1<l&&(i="stroke")}else a=h?i.map(o):o(i,n);else i="";return!h&&isNaN(a)?i:a}function l(t){return new RegExp("^("+t.join("|")+")\\b","i")}function u(t,e){var i,r,n,o,s=[];for(n=0,o=e.length;n<o;n++)i=e[n],r=t.getElementsByTagName(i),s=s.concat(Array.prototype.slice.call(r));return s}function f(t,e){var i,r=!0;return(i=d(t,e.pop()))&&e.length&&(r=function(t,e){for(var i,r=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)r&&(i=e.pop()),r=d(t=t.parentNode,i);return 0===e.length}(t,e)),i&&r&&0===e.length}function d(t,e){var i,r,n=t.nodeName,o=t.getAttribute("class"),s=t.getAttribute("id");if(i=new RegExp("^"+n,"i"),e=e.replace(i,""),s&&e.length&&(i=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),o&&e.length)for(r=(o=o.split(" ")).length;r--;)i=new RegExp("\\."+o[r]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function g(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var r,n,o,s=t.getElementsByTagName("*");for(n=0,o=s.length;n<o;n++)if(e===(r=s[n]).getAttribute("id"))return r}e.svgValidTagNamesRegEx=l(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=l(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=l(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=l(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,r){t[r]=Math.tan(e.util.degreesToRadians(i[0]))}var i=[1,0,0,1,0,0],r=e.reNum,n="(?:\\s+,?\\s*|,\\s*)",o="(?:(?:(matrix)\\s*\\(\\s*("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")\\s*\\))|(?:(translate)\\s*\\(\\s*("+r+")(?:"+n+"("+r+"))?\\s*\\))|(?:(scale)\\s*\\(\\s*("+r+")(?:"+n+"("+r+"))?\\s*\\))|(?:(rotate)\\s*\\(\\s*("+r+")(?:"+n+"("+r+")"+n+"("+r+"))?\\s*\\))|(?:(skewX)\\s*\\(\\s*("+r+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+r+")\\s*\\)))",s=new RegExp("^\\s*(?:(?:"+o+"(?:"+n+"*"+o+")*)?)\\s*$"),a=new RegExp(o,"g");return function(r){var n=i.concat(),h=[];if(!r||r&&!s.test(r))return n;r.replace(a,function(r){var s,a,c,l,u,f,d,g,p,v,m,y,_=new RegExp(o).exec(r).filter(function(t){return!!t}),b=_[1],x=_.slice(2).map(parseFloat);switch(b){case"translate":y=x,(m=n)[4]=y[0],2===y.length&&(m[5]=y[1]);break;case"rotate":x[0]=e.util.degreesToRadians(x[0]),u=n,f=x,d=e.util.cos(f[0]),g=e.util.sin(f[0]),v=p=0,3===f.length&&(p=f[1],v=f[2]),u[0]=d,u[1]=g,u[2]=-g,u[3]=d,u[4]=p-(d*p-g*v),u[5]=v-(g*p+d*v);break;case"scale":s=n,c=(a=x)[0],l=2===a.length?a[1]:a[0],s[0]=c,s[3]=l;break;case"skewX":t(n,x,2);break;case"skewY":t(n,x,1);break;case"matrix":n=x}h.push(n.concat()),n=i.concat()});for(var c=h[0];1<h.length;)h.shift(),c=e.util.multiplyTransformMatrices(c,h[0]);return c}}();var p=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function v(t){var i,r,n,s,a,h,c=t.getAttribute("viewBox"),l=1,u=1,f=t.getAttribute("width"),d=t.getAttribute("height"),g=t.getAttribute("x")||0,v=t.getAttribute("y")||0,m=t.getAttribute("preserveAspectRatio")||"",y=!c||!e.svgViewBoxElementsRegEx.test(t.nodeName)||!(c=c.match(p)),_=!f||!d||"100%"===f||"100%"===d,b=y&&_,x={},C="",S=0,w=0;if(x.width=0,x.height=0,x.toBeParsed=b)return x;if(y)return x.width=o(f),x.height=o(d),x;if(i=-parseFloat(c[1]),r=-parseFloat(c[2]),n=parseFloat(c[3]),s=parseFloat(c[4]),_?(x.width=n,x.height=s):(x.width=o(f),x.height=o(d),l=x.width/n,u=x.height/s),"none"!==(m=e.util.parsePreserveAspectRatioAttribute(m)).alignX&&("meet"===m.meetOrSlice&&(u=l=u<l?u:l),"slice"===m.meetOrSlice&&(u=l=u<l?l:u),S=x.width-n*l,w=x.height-s*l,"Mid"===m.alignX&&(S/=2),"Mid"===m.alignY&&(w/=2),"Min"===m.alignX&&(S=0),"Min"===m.alignY&&(w=0)),1===l&&1===u&&0===i&&0===r&&0===g&&0===v)return x;if((g||v)&&(C=" translate("+o(g)+" "+o(v)+") "),a=C+" matrix("+l+" 0 0 "+u+" "+(i*l+S)+" "+(r*u+w)+") ",x.viewboxTransform=e.parseTransformAttribute(a),"svg"===t.nodeName){for(h=t.ownerDocument.createElement("g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else a=(h=t).getAttribute("transform")+a;return h.setAttribute("transform",a),x}e.parseSVGDocument=function(t,i,n,o){if(t){!function(t){for(var e=u(t,["use","svg:use"]),i=0;e.length&&i<e.length;){var r,n,o,s,a=e[i],h=(a.getAttribute("xlink:href")||a.getAttribute("href")).substr(1),c=a.getAttribute("x")||0,l=a.getAttribute("y")||0,f=g(t,h).cloneNode(!0),d=(f.getAttribute("transform")||"")+" translate("+c+", "+l+")",p=e.length;if(v(f),/^svg$/i.test(f.nodeName)){var m=f.ownerDocument.createElement("g");for(n=0,s=(o=f.attributes).length;n<s;n++)r=o.item(n),m.setAttribute(r.nodeName,r.nodeValue);for(;f.firstChild;)m.appendChild(f.firstChild);f=m}for(n=0,s=(o=a.attributes).length;n<s;n++)"x"!==(r=o.item(n)).nodeName&&"y"!==r.nodeName&&"xlink:href"!==r.nodeName&&"href"!==r.nodeName&&("transform"===r.nodeName?d=r.nodeValue+" "+d:f.setAttribute(r.nodeName,r.nodeValue));f.setAttribute("transform",d),f.setAttribute("instantiated_by_use","1"),f.removeAttribute("id"),a.parentNode.replaceChild(f,a),e.length===p&&i++}}(t);var s,a,h=e.Object.__uid++,c=v(t),l=e.util.toArray(t.getElementsByTagName("*"));if(c.crossOrigin=o&&o.crossOrigin,c.svgUid=h,0===l.length&&e.isLikelyNode){var f=[];for(s=0,a=(l=t.selectNodes('//*[name(.)!="svg"]')).length;s<a;s++)f[s]=l[s];l=f}var d=l.filter(function(t){return v(t),e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))&&!function(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}(t,e.svgInvalidAncestorsRegEx)});if(!d||d&&!d.length)i&&i([],{});else{var p={};l.filter(function(t){return"clipPath"===t.nodeName.replace("svg:","")}).forEach(function(t){var i=t.getAttribute("id");p[i]=e.util.toArray(t.getElementsByTagName("*")).filter(function(t){return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))})}),e.gradientDefs[h]=e.getGradientDefs(t),e.cssRules[h]=e.getCSSRules(t),e.clipPaths[h]=p,e.parseElements(d,function(t,r){i&&(i(t,c,r,l),delete e.gradientDefs[h],delete e.cssRules[h],delete e.clipPaths[h])},r(c),n,o)}}};var m=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(m);if(i){var r=i[1],n=i[3],s=i[4],a=i[5],h=i[6];r&&(e.fontStyle=r),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=o(s)),h&&(e.fontFamily=h),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i,r,n=u(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),o=0,s={},a={};for(o=n.length;o--;)r=(e=n[o]).getAttribute("xlink:href"),i=e.getAttribute("id"),r&&(a[i]=r.substr(1)),s[i]=e;for(i in a){var h=s[a[i]].cloneNode(!0);for(e=s[i];h.firstChild;)e.appendChild(h.firstChild)}return s},parseAttributes:function(t,r,o){if(t){var s,l,u={};void 0===o&&(o=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(u=e.parseAttributes(t.parentNode,r,o));var d=r.reduce(function(e,i){return(s=t.getAttribute(i))&&(e[i]=s),e},{});d=i(d,i(function(t,i){var r={};for(var n in e.cssRules[i])if(f(t,n.split(" ")))for(var o in e.cssRules[i][n])r[o]=e.cssRules[i][n][o];return r}(t,o),e.parseStyleAttribute(t))),l=u&&u.fontSize||d["font-size"]||e.Text.DEFAULT_SVG_FONT_SIZE;var g,p,v,m={};for(var y in d)p=c(g=(v=y)in a?a[v]:v,d[y],u,l),m[g]=p;m&&m.font&&e.parseFontDeclaration(m.font,m);var _=i(u,m);return e.svgValidParentsRegEx.test(t.nodeName)?_:function(t){for(var i in h)if(void 0!==t[h[i]]&&""!==t[i]){if(void 0===t[i]){if(!e.Object.prototype[i])continue;t[i]=e.Object.prototype[i]}if(0!==t[i].indexOf("url(")){var r=new e.Color(t[i]);t[i]=r.setAlpha(n(r.getAlpha()*t[h[i]],2)).toRgba()}}return t}(_)}},parseElements:function(t,i,r,n,o){new e.ElementsParser(t,i,r,n,o).parse()},parseStyleAttribute:function(t){var e,i,r,n={},o=t.getAttribute("style");return o&&("string"==typeof o?(e=n,o.replace(/;\s*$/,"").split(";").forEach(function(t){var n=t.split(":");i=n[0].trim().toLowerCase(),r=n[1].trim(),e[i]=r})):function(t,e){var i,r;for(var n in t)void 0!==t[n]&&(i=n.toLowerCase(),r=t[n],e[i]=r)}(o,n)),n},parsePointsAttribute:function(t){if(!t)return null;var e,i,r=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)r.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return r},getCSSRules:function(t){var i,r,n=t.getElementsByTagName("style"),o={};for(i=0,r=n.length;i<r;i++){var s=n[i].textContent||n[i].text;""!==(s=s.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&s.match(/[^{]*\{[\s\S]*?\}/g).map(function(t){return t.trim()}).forEach(function(t){var n=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),s={},a=n[2].trim().replace(/;$/,"").split(/\s*;\s*/);for(i=0,r=a.length;i<r;i++){var h=a[i].split(/\s*:\s*/),c=h[0],l=h[1];s[c]=l}(t=n[1]).split(",").forEach(function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(o[t]?e.util.object.extend(o[t],s):o[t]=e.util.object.clone(s))})})}return o},loadSVGFromURL:function(t,i,r,n){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var o=t.responseXML;if(o&&!o.documentElement&&e.window.ActiveXObject&&t.responseText&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),!o||!o.documentElement)return i&&i(null),!1;e.parseSVGDocument(o.documentElement,function(t,e,r,n){i&&i(t,e,r,n)},r,n)}})},loadSVGFromString:function(t,i,r,n){var o;if(t=t.trim(),"undefined"!=typeof DOMParser){var s=new DOMParser;s&&s.parseFromString&&(o=s.parseFromString(t,"text/xml"))}else e.window.ActiveXObject&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));e.parseSVGDocument(o.documentElement,function(t,e,r,n){i(t,e,r,n)},r,n)}})}(e),A.ElementsParser=function(t,e,i,r,n){this.elements=t,this.callback=e,this.options=i,this.reviver=r,this.svgUid=i&&i.svgUid||0,this.parsingOptions=n,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g},(p=A.ElementsParser.prototype).parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},p.createObjects=function(){var t=this;this.elements.forEach(function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)})},p.findTag=function(t){return A[A.util.string.capitalize(t.tagName.replace("svg:",""))]},p.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){A.log(t)}else this.checkIfDone()},p.createCallback=function(t,e){var i=this;return function(r){var n;i.resolveGradient(r,"fill"),i.resolveGradient(r,"stroke"),r instanceof A.Image&&(n=r.parsePreserveAspectRatioAttribute(e)),r._removeTransformMatrix(n),i.resolveClipPath(r),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},p.extractPropertyDefinition=function(t,e,i){var r=t[e];if(/^url\(/.test(r)){var n=this.regexUrl.exec(r)[1];return this.regexUrl.lastIndex=0,A[i][this.svgUid][n]}},p.resolveGradient=function(t,e){var i=this.extractPropertyDefinition(t,e,"gradientDefs");i&&t.set(e,A.Gradient.fromElement(i,t))},p.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},p.resolveClipPath=function(t){var e,i,r,n,o=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(o){r=[],i=A.util.invertTransform(t.calcTransformMatrix());for(var s=0;s<o.length;s++)e=o[s],this.findTag(e).fromElement(e,this.createClipPathCallback(t,r),this.options);o=1===r.length?r[0]:new A.Group(r),n=A.util.multiplyTransformMatrices(i,o.calcTransformMatrix());var a=A.util.qrDecompose(n);o.flipX=!1,o.flipY=!1,o.set("scaleX",a.scaleX),o.set("scaleY",a.scaleY),o.angle=a.angle,o.skewX=a.skewX,o.skewY=0,o.setPositionByOrigin({x:a.translateX,y:a.translateY},"center","center"),t.clipPath=o}},p.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances,this.elements))},function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t,e){this.x=t,this.y=e}e.Point?e.warn("fabric.Point is already defined"):(e.Point=i).prototype={type:"point",constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}}}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,r,n,o){var s,a=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),h=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),c=(o.y-n.y)*(r.x-t.x)-(o.x-n.x)*(r.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(s=new i("Intersection")).appendPoint(new e.Point(t.x+l*(r.x-t.x),t.y+l*(r.y-t.y))):s=new i}else s=new i(0===a||0===h?"Coincident":"Parallel");return s},e.Intersection.intersectLinePolygon=function(t,e,r){var n,o,s,a,h=new i,c=r.length;for(a=0;a<c;a++)n=r[a],o=r[(a+1)%c],s=i.intersectLineLine(t,e,n,o),h.appendPoints(s.points);return 0<h.points.length&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var r,n=new i,o=t.length;for(r=0;r<o;r++){var s=t[r],a=t[(r+1)%o],h=i.intersectLinePolygon(s,a,e);n.appendPoints(h.points)}return 0<n.points.length&&(n.status="Intersection"),n},e.Intersection.intersectPolygonRectangle=function(t,r,n){var o=r.min(n),s=r.max(n),a=new e.Point(s.x,o.y),h=new e.Point(o.x,s.y),c=i.intersectLinePolygon(o,a,t),l=i.intersectLinePolygon(a,s,t),u=i.intersectLinePolygon(s,h,t),f=i.intersectLinePolygon(h,o,t),d=new i;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),0<d.points.length&&(d.status="Intersection"),d})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function r(t,e,i){return i<0&&(i+=1),1<i&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,r){t/=255,i/=255,r/=255;var n,o,s,a=e.util.array.max([t,i,r]),h=e.util.array.min([t,i,r]);if(s=(a+h)/2,a===h)n=o=0;else{var c=a-h;switch(o=.5<s?c/(2-a-h):c/(a+h),a){case t:n=(i-r)/c+(i<r?6:0);break;case i:n=(r-t)/c+2;break;case r:n=(t-i)/c+4}n/=6}return[Math.round(360*n),Math.round(100*o),Math.round(100*s)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,r=this.getSource();return t=1===(t=r[0].toString(16)).length?"0"+t:t,e=1===(e=r[1].toString(16)).length?"0"+e:e,i=1===(i=r[2].toString(16)).length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t,e=this.getSource();return t=1===(t=(t=Math.round(255*e[3])).toString(16)).length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),r=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,r]),this},overlayWith:function(t){t instanceof i||(t=new i(t));var e,r=[],n=this.getAlpha(),o=this.getSource(),s=t.getSource();for(e=0;e<3;e++)r.push(Math.round(.5*o[e]+.5*s[e]));return r[3]=n,this.setSource(r),this}},e.Color.reRGBa=