react-sketch2
Version:
Sketch Element for React based applications, backed-up by fabricjs as its core
3 lines • 355 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var r in i)("object"==typeof exports?exports:t)[r]=i[r]}}(window,(function(){return i={},t.m=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){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);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){var r=i(13),n=i(14);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?n(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,k,P,E,j,D,A,M,R,F,L,I,B,Y,X,U,W,z=z||{version:"3.6.3"};function N(t,e){var i;this.__eventListeners[t]&&(i=this.__eventListeners[t],e?i[i.indexOf(e)]=!1:z.util.array.fill(i,!1))}function G(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 V(t,e){if(!this.__eventListeners)return this;if(0===arguments.length)for(t in this.__eventListeners)N.call(this,t);else if(1===arguments.length&&"object"==typeof t)for(var i in t)N.call(this,i,t[i]);else N.call(this,t,e);return this}function H(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;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}function q(t,e,i,r,n,o,s){var a=l.call(arguments);if(z.arcToSegmentsCache[a])return z.arcToSegmentsCache[a];var h,c=Math.PI,u=s*c/180,f=z.util.sin(u),d=z.util.cos(u),g=0,p=0,v=-d*t*.5-f*e*.5,m=-d*e*.5+f*t*.5,y=(i=Math.abs(i))*i,_=(r=Math.abs(r))*r,b=m*m,x=v*v,C=y*_-y*b-_*x,S=0;C<0?(i*=h=Math.sqrt(1-C/(y*_)),r*=h):S=(n===o?-1:1)*Math.sqrt(C/(y*b+_*x));var w=S*i*m/r,T=-S*r*v/i,O=d*w-f*T+.5*t,k=f*w+d*T+.5*e,P=K(1,0,(v-w)/i,(m-T)/r),E=K((v-w)/i,(m-T)/r,(-v-w)/i,(-m-T)/r);0===o&&0<E?E-=2*c:1===o&&E<0&&(E+=2*c);for(var j,D,A,M,R,F,L,I,B,Y,X,U,W,N,G,V,H,q=Math.ceil(Math.abs(E/c*2)),J=[],$=E/q,Z=8/3*Math.sin($/4)*Math.sin($/4)/Math.sin($/2),Q=P+$,tt=0;tt<q;tt++)J[tt]=(j=P,D=Q,A=d,M=f,R=i,F=r,L=O,I=k,B=Z,Y=g,X=p,U=z.util.cos(j),[Y+B*(-A*R*(W=z.util.sin(j))-M*F*U),X+B*(-M*R*W+A*F*U),(V=A*R*(N=z.util.cos(D))-M*F*(G=z.util.sin(D))+L)+B*(A*R*G+M*F*N),(H=M*R*N+A*F*G+I)+B*(M*R*G-A*F*N),V,H]),g=J[tt][4],p=J[tt][5],P=Q,Q+=$;return z.arcToSegmentsCache[a]=J}function K(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 J(t,e,i,r,n,o,s,a){var h;if(z.cachesBoundsOfCurve&&(h=l.call(arguments),z.boundsOfCurveCache[h]))return z.boundsOfCurveCache[h];for(var c,u,f,d,g,p=Math.sqrt,v=Math.min,m=Math.max,y=Math.abs,_=[],b=[[],[]],x=6*t-12*i+6*n,C=-3*t+9*i-9*n+3*s,S=3*i-3*t,w=0;w<2;++w)if(0<w&&(x=6*e-12*r+6*o,C=-3*e+9*r-9*o+3*a,S=3*r-3*e),y(C)<1e-12){if(y(x)<1e-12)continue;0<(c=-S/x)&&c<1&&_.push(c)}else(d=x*x-4*S*C)<0||(0<(u=(-x+(g=p(d)))/(2*C))&&u<1&&_.push(u),0<(f=(-x-g)/(2*C))&&f<1&&_.push(f));for(var T,O,k,P=_.length,E=P;P--;)T=(k=1-(c=_[P]))*k*k*t+3*k*k*c*i+3*k*c*c*n+c*c*c*s,b[0][P]=T,O=k*k*k*e+3*k*k*c*r+3*k*c*c*o+c*c*c*a,b[1][P]=O;b[0][E]=t,b[1][E]=e,b[0][E+1]=s,b[1][E+1]=a;var j=[{x:v.apply(null,b[0]),y:v.apply(null,b[1])},{x:m.apply(null,b[0]),y:m.apply(null,b[1])}];return z.cachesBoundsOfCurve&&(z.boundsOfCurveCache[h]=j),j}function $(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}}function Z(t,e,i){if(i)if(!z.isLikelyNode&&e instanceof Element)t=e;else if(e instanceof Array){t=[];for(var r=0,n=e.length;r<n;r++)t[r]=Z({},e[r],i)}else if(e&&"object"==typeof e)for(var o in e)"canvas"===o?t[o]=Z({},e[o]):e.hasOwnProperty(o)&&(t[o]=Z({},e[o],i));else t=e;else for(var o in e)t[o]=e[o];return t}function Q(){}function tt(){}function et(t){for(var e=null,i=this;i.constructor.superclass;){var r=i.constructor.superclass.prototype[t];if(i[t]!==r){e=r;break}i=i.constructor.superclass.prototype}return e?1<arguments.length?e.apply(this,f.call(arguments,1)):e.call(this):console.log("tried to callSuper "+t+", method not found in prototype chain",this)}function it(){}function rt(){return!1}function nt(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}function ot(){return b.apply(z.window,arguments)}function st(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 at(t,e,i){return t.a*Math.pow(2,10*--e)*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function ht(t,e,i,r){return i-ct(r-t,0,i,r)+e}function ct(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}function lt(t,e,i,r){var n,o;Object.keys(e).forEach((function(t){"Infinity"===(n=e[t])?o=1:"-Infinity"===n?o=0:(o=parseFloat(e[t],10),"string"==typeof n&&/^(\d+\.\d+)%|(\d+)%$/.test(n)&&(o*=.01,"pixels"===r&&("x1"!==t&&"x2"!==t&&"r2"!==t||(o*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(o*=i.viewBoxHeight||i.height)))),e[t]=o}))}function ut(t,e){return t.button&&t.button===e-1}function ft(t,e){if(e){if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new z.Color(e),r=t+": "+i.toRgb()+"; ",n=i.getAlpha();return 1!==n&&(r+=t+"-opacity: "+n.toString()+"; "),r}return t+": none; "}function dt(t,e,i){var r={};i.forEach((function(e){r[e]=t[e]})),I(t[e],r,!0)}function gt(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 pt(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)}function vt(t){t.textDecoration&&(-1<t.textDecoration.indexOf("underline")&&(t.underline=!0),-1<t.textDecoration.indexOf("line-through")&&(t.linethrough=!0),-1<t.textDecoration.indexOf("overline")&&(t.overline=!0),delete t.textDecoration)}e.fabric=z,"undefined"!=typeof document&&"undefined"!=typeof window?(document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?z.document=document:z.document=document.implementation.createHTMLDocument(""),z.window=window):(r=new(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"]},resources:"usable"}).window,z.document=r.document,z.jsdomImplForWrapper=i(25).implForWrapper,z.nodeCanvas=i(26).Canvas,z.window=r,DOMParser=z.window.DOMParser),z.isTouchSupported="ontouchstart"in z.window||"ontouchstart"in z.document||z.window&&z.window.navigator&&0<z.window.navigator.maxTouchPoints,z.isLikelyNode=void 0!==t&&"undefined"==typeof window,z.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],z.DPI=96,z.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",z.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,z.reNonWord=/[ \n\.,;!\?\-]/,z.fontPaths={},z.iMatrix=[1,0,0,1,0,0],z.svgNS="http://www.w3.org/2000/svg",z.perfLimitSizeTotal=2097152,z.maxCacheSideLimit=4096,z.minCacheSideLimit=256,z.charWidthsCache={},z.textureSize=2048,z.disableStyleCopyPaste=!1,z.enableGLFiltering=!0,z.devicePixelRatio=z.window.devicePixelRatio||z.window.webkitDevicePixelRatio||z.window.mozDevicePixelRatio||1,z.browserShadowBlurConstant=1,z.arcToSegmentsCache={},z.boundsOfCurveCache={},z.cachesBoundsOfCurve=!0,z.forceGLPutImageData=!1,z.initFilterBackend=function(){return z.enableGLFiltering&&z.isWebglSupported&&z.isWebglSupported(z.textureSize)?(console.log("max texture size: "+z.maxTextureSize),new z.WebglFilterBackend({tileSize:z.textureSize})):z.Canvas2dFilterBackend?new z.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=z),z.Observable={observe:G,stopObserving:V,fire:H,on:G,off:V,trigger:H},z.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)}},z.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof z.Gradient||this.set(e,new z.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof z.Pattern?i&&i():this.set(e,new z.Pattern(t,i))},_initClipping:function(t){var e;!t.clipTo||"string"!=typeof t.clipTo||void 0!==(e=z.util.getFunctionBody(t.clipTo))&&(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]}},n=e,o=Math.sqrt,s=Math.atan2,a=Math.pow,h=Math.PI/180,c=Math.PI/2,z.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=t<0?-1:1;switch(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=z.util.rotateVector(t,i);return new z.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=z.util.sin(e),r=z.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 z.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new z.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i<t.length;i++)t[i]=z.util.transformPoint(t[i],e);var r=[t[0].x,t[1].x,t[2].x,t[3].x],n=z.util.array.min(r),o=z.util.array.max(r)-n,s=[t[0].y,t[1].y,t[2].y,t[3].y],a=z.util.array.min(s);return{left:n,top:a,width:o,height:z.util.array.max(s)-a}},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=z.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||z.Text.DEFAULT_SVG_FONT_SIZE,i[0]){case"mm":return r*z.DPI/25.4;case"cm":return r*z.DPI/2.54;case"in":return r*z.DPI;case"pt":return r*z.DPI/72;case"pc":return r*z.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=z.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),z.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 z;for(var e=t.split("."),i=e.length,r=n||z.window,o=0;o<i;++o)r=r[e[o]];return r},loadImage:function(t,e,i,r){var n,o;t?(o=function(){e&&e.call(i,n),n=n.onload=n.onerror=null},(n=z.util.createImage()).onload=o,n.onerror=function(){z.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,z.util.loadImageInDom(n,o)),n.src=t):e&&e.call(i,t)},loadImageInDom:function(t,e){var i=z.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),z.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,r){var n=[],o=0,s=(t=t||[]).length;function a(){++o===s&&e&&e(n.filter((function(t){return t})))}s?t.forEach((function(t,e){t&&t.type?z.util.getKlass(t.type,i).fromObject(t,(function(i,o){o||(n[e]=i),r&&r(t,i,o),a()})):a()})):e&&e(n)},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 z.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 z.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,n,a){var h=r-e,c=n-i,l=o(h*h+c*c),u=s(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 z.document.createElement("canvas")},copyCanvasElement:function(t){var e=z.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return z.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=s(t[1],t[0]),i=a(t[0],2)+a(t[1],2),r=o(i),n=(t[0]*t[3]-t[2]*t[1])/r,c=s(t[0]*t[2]+t[1]*t[3],i);return{angle:e/h,scaleX:r,scaleY:n,skewX:c/h,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return z.iMatrix.concat();var e=z.util.degreesToRadians(t.angle),i=z.util.cos(e),r=z.util.sin(e);return[i,r,-r,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,r=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],n=z.util.multiplyTransformMatrices,o=z.util.degreesToRadians;return t.skewX&&(r=n(r,[1,0,Math.tan(o(t.skewX)),1],!0)),t.skewY&&(r=n(r,[1,Math.tan(o(t.skewY)),0,1],!0)),r},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=z.util.multiplyTransformMatrices;return t.angle&&(e=i(e,z.util.calcRotateMatrix(t))),(t.scaleX||t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,z.util.calcDimensionsMatrix(t))),e},customTransformMatrix:function(t,e,i){return z.util.composeMatrix({scaleX:t,scaleY:e,skewX:i})},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);for(var n=!0,o=t.getImageData(e,i,2*r||1,2*r||1),s=o.data.length,a=3;a<s&&!1!=(n=o.data[a]<=0);a+=4);return o=null,n},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())?z.charWidthsCache[t]&&delete z.charWidthsCache[t]:z.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)},matrixToSVG:function(t){return"matrix("+t.map((function(t){return z.util.toFixed(t,z.Object.NUM_FRACTION_DIGITS)})).join(" ")+")"}},l=Array.prototype.join,z.util.drawArc=function(t,e,i,r){for(var n=r[0],o=r[1],s=r[2],a=r[3],h=r[4],c=[[],[],[],[]],l=q(r[5]-e,r[6]-i,n,o,a,h,s),u=0,f=l.length;u<f;u++)c[u][0]=l[u][0]+e,c[u][1]=l[u][1]+i,c[u][2]=l[u][2]+e,c[u][3]=l[u][3]+i,c[u][4]=l[u][4]+e,c[u][5]=l[u][5]+i,t.bezierCurveTo.apply(t,c[u])},z.util.getBoundsOfArc=function(t,e,i,r,n,o,s,a,h){for(var c,l=0,u=0,f=[],d=q(a-t,h-e,i,r,o,s,n),g=0,p=d.length;g<p;g++)c=J(l,u,d[g][0],d[g][1],d[g][2],d[g][3],d[g][4],d[g][5]),f.push({x:c[0].x+t,y:c[0].y+e}),f.push({x:c[1].x+t,y:c[1].y+e}),l=d[g][4],u=d[g][5];return f},z.util.getBoundsOfCurve=J,u=Array.prototype.slice,z.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(t,e){for(var i=u.call(arguments,2),r=[],n=0,o=t.length;n<o;n++)r[n]=i.length?t[n][e].apply(t[n],i):t[n][e].call(t[n]);return r},min:function(t,e){return $(t,e,(function(t,e){return t<e}))},max:function(t,e){return $(t,e,(function(t,e){return e<=t}))}},z.util.object={extend:Z,clone:function(t,e){return Z({},t,e)}},z.util.object.extend(z.util,z.Observable),z.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(t){var e,i=0,r=[];for(i=0;i<t.length;i++)!1!==(e=function(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}(t,i))&&r.push(e);return r}},f=Array.prototype.slice,d=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),z.util.createClass=function(){var t=null,e=f.call(arguments,0);function i(){this.initialize.apply(this,arguments)}"function"==typeof e[0]&&(t=e.shift()),i.superclass=t,i.subclasses=[],t&&(tt.prototype=t.prototype,i.prototype=new tt,t.subclasses.push(i));for(var r=0,n=e.length;r<n;r++)!function(t,e,i){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&-1<(e[r]+"").indexOf("callSuper")?t.prototype[r]=function(t){return function(){var r=this.constructor.superclass;this.constructor.superclass=i;var n=e[t].apply(this,arguments);if(this.constructor.superclass=r,"initialize"!==t)return n}}(r):t.prototype[r]=e[r],d&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))}(i,e[r],t);return i.prototype.initialize||(i.prototype.initialize=Q),(i.prototype.constructor=i).prototype.callSuper=et,i},g=!!z.document.createElement("div").attachEvent,z.util.addListener=function(t,e,i,r){t&&t.addEventListener(e,i,!g&&r)},z.util.removeListener=function(t,e,i,r){t&&t.removeEventListener(e,i,!g&&r)},z.util.getPointer=function(t){var e,i,r=t.target,n=z.util.getScrollLeftTop(r),o=(i=(e=t).changedTouches)&&i[0]?i[0]:e;return{x:o.clientX+n.left,y:o.clientY+n.top}},v="string"==typeof(p=z.document.createElement("div")).style.opacity,m="string"==typeof p.style.filter,y=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,_=function(t){return t},v?_=function(t,e){return t.style.opacity=e,t}:m&&(_=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),y.test(i.filter)?(e=.9999<=e?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(y,e)):i.filter+=" alpha(opacity="+100*e+")",t}),z.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")?_(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var r in e)"opacity"===r?_(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(z.document.childNodes)instanceof Array}catch(t){}function s(t,e){var i=z.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=z.document.documentElement,n=z.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===z.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=z.document.defaultView&&z.document.defaultView.getComputedStyle?function(t,e){var i=z.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=z.document.documentElement.style,r="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",z.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=z.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},z.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},z.util.getScript=function(t,e){var i=z.document.getElementsByTagName("head")[0],r=z.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||z.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)},z.util.getById=function(t){return"string"==typeof t?z.document.getElementById(t):t},z.util.toArray=o,z.util.makeElement=s,z.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},z.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},z.util.getScrollLeftTop=a,z.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}},z.util.getElementStyle=e,z.util.getNodeCanvas=function(t){var e=z.jsdomImplForWrapper(t);return e._canvas||e._image},z.util.cleanUpJsdomNode=function(t){var e;!z.isLikelyNode||(e=z.jsdomImplForWrapper(t))&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}(),z.util.request=function(t,e){var i,r,n=(e=e||{}).method?e.method.toUpperCase():"GET",o=e.onComplete||function(){},s=new z.window.XMLHttpRequest,a=e.body||e.parameters;return s.onreadystatechange=function(){4===s.readyState&&(o(s),s.onreadystatechange=it)},"GET"===n&&(a=null,"string"==typeof e.parameters&&(i=t,r=e.parameters,t=i+(/\?/.test(i)?"&":"?")+r)),s.open(n,t,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s},z.log=console.log,z.warn=console.warn,b=z.window.requestAnimationFrame||z.window.webkitRequestAnimationFrame||z.window.mozRequestAnimationFrame||z.window.oRequestAnimationFrame||z.window.msRequestAnimationFrame||function(t){return z.window.setTimeout(t,1e3/60)},x=z.window.cancelAnimationFrame||z.window.clearTimeout,z.util.animate=function(t){ot((function(e){t=t||{};var i,r=e||+new Date,n=t.duration||500,o=r+n,s=t.onChange||rt,a=t.abort||rt,h=t.onComplete||rt,c=t.easing||nt,l="startValue"in t?t.startValue:0,u="endValue"in t?t.endValue:100,f=t.byValue||u-l;t.onStart&&t.onStart(),function t(e){i=e||+new Date;var d=o<i?n:i-r,g=d/n,p=c(d,l,f,n),v=Math.abs((p-l)/f);if(!a())return o<i?(s(u,1,1),void h(u,1,1)):(s(p,v,g),void ot(t));h(u,1,1)}(r)}))},z.util.requestAnimFrame=ot,z.util.cancelAnimFrame=function(){return x.apply(z.window,arguments)},z.util.animateColor=function(t,e,i,r){var n=new z.Color(t).getSource(),o=new z.Color(e).getSource();r=r||{},z.util.animate(z.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))+")"}}))},z.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(t,e,i,r){var n=0;return 0===t?e:1==(t/=r)?e+i:-at(st(i,i,n=n||.3*r,1.70158),t,r)+e},easeOutElastic:function(t,e,i,r){var n=0;if(0===t)return e;if(1==(t/=r))return e+i;var o=st(i,i,n=n||.3*r,1.70158);return o.a*Math.pow(2,-10*t)*Math.sin((t*r-o.s)*(2*Math.PI)/o.p)+o.c+e},easeInOutElastic:function(t,e,i,r){var n=0;if(0===t)return e;if(2==(t/=r/2))return e+i;var o=st(i,i,n=n||r*(.3*1.5),1.70158);return t<1?-.5*at(o,t,r)+e:o.a*Math.pow(2,-10*--t)*Math.sin((t*r-o.s)*(2*Math.PI)/o.p)*.5+o.c+e},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:ht,easeOutBounce:ct,easeInOutBounce:function(t,e,i,r){return t<r/2?.5*ht(2*t,0,i,r)+e:.5*ct(2*t-r,0,i,r)+.5*i+e}},function(t){"use strict";var e,i,r,n,o,s,a=t.fabric||(t.fabric={}),h=a.util.object.extend,c=a.util.object.clone,l=a.util.toFixed,u=a.util.parseUnit,f=a.util.multiplyTransformMatrices,d={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-dashoffset":"strokeDashOffset","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","vector-effect":"strokeUniform"},g={stroke:"strokeOpacity",fill:"fillOpacity"},p="font-size",v="clip-path";function m(t){return new RegExp("^("+t.join("|")+")\\b","i")}function y(t,e){for(var i,r,n=[],o=0,s=e.length;o<s;o++)i=e[o],r=t.getElementsByTagName(i),n=n.concat(Array.prototype.slice.call(r));return n}function _(t,e,i){t[i]=Math.tan(a.util.degreesToRadians(e[0]))}function b(t,e){var i={};for(var r in a.cssRules[e])if(function(t,e){var i,r=!0;return(i=x(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=x(t=t.parentNode,i);return 0===e.length}(t,e)),i&&r&&0===e.length}(t,r.split(" ")))for(var n in a.cssRules[e][r])i[n]=a.cssRules[e][r][n];return i}function x(t,e){var i,r=t.nodeName,n=t.getAttribute("class"),o=t.getAttribute("id"),s=new RegExp("^"+r,"i");if(e=e.replace(s,""),o&&e.length&&(s=new RegExp("#"+o+"(?![a-zA-Z\\-]+)","i"),e=e.replace(s,"")),n&&e.length)for(i=(n=n.split(" ")).length;i--;)s=new RegExp("\\."+n[i]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(s,"");return 0===e.length}function C(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;for(var r,n=t.getElementsByTagName("*"),o=0,s=n.length;o<s;o++)if(e===(r=n[o]).getAttribute("id"))return r}a.svgValidTagNamesRegEx=m(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),a.svgViewBoxElementsRegEx=m(["symbol","image","marker","pattern","view","svg"]),a.svgInvalidAncestorsRegEx=m(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),a.svgValidParentsRegEx=m(["symbol","g","a","svg","clipPath","defs"]),a.cssRules={},a.gradientDefs={},a.clipPaths={},a.parseTransformAttribute=(e=a.iMatrix,i=a.reNum,n="(?:(?:(matrix)\\s*\\(\\s*("+i+")"+(r="(?:\\s+,?\\s*|,\\s*)")+"("+i+")"+r+"("+i+")"+r+"("+i+")"+r+"("+i+")"+r+"("+i+")\\s*\\))|(?:(translate)\\s*\\(\\s*("+i+")(?:"+r+"("+i+"))?\\s*\\))|(?:(scale)\\s*\\(\\s*("+i+")(?:"+r+"("+i+"))?\\s*\\))|(?:(rotate)\\s*\\(\\s*("+i+")(?:"+r+"("+i+")"+r+"("+i+"))?\\s*\\))|(?:(skewX)\\s*\\(\\s*("+i+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+i+")\\s*\\)))",o=new RegExp("^\\s*(?:(?:"+n+"(?:"+r+"*"+n+")*)?)\\s*$"),s=new RegExp(n,"g"),function(t){var i=e.concat(),r=[];if(!t||t&&!o.test(t))return i;t.replace(s,(function(t){var o,s,h,c,l,u,f,d,g,p,v,m,y=new RegExp(n).exec(t).filter((function(t){return!!t})),b=y[1],x=y.slice(2).map(parseFloat);switch(b){case"translate":m=x,(v=i)[4]=m[0],2===m.length&&(v[5]=m[1]);break;case"rotate":x[0]=a.util.degreesToRadians(x[0]),l=i,u=x,f=a.util.cos(u[0]),d=a.util.sin(u[0]),p=g=0,3===u.length&&(g=u[1],p=u[2]),l[0]=f,l[1]=d,l[2]=-d,l[3]=f,l[4]=g-(f*g-d*p),l[5]=p-(d*g+f*p);break;case"scale":o=i,h=(s=x)[0],c=2===s.length?s[1]:s[0],o[0]=h,o[3]=c;break;case"skewX":_(i,x,2);break;case"skewY":_(i,x,1);break;case"matrix":i=x}r.push(i.concat()),i=e.concat()}));for(var h=r[0];1<r.length;)r.shift(),h=a.util.multiplyTransformMatrices(h,r[0]);return h});var S=new RegExp("^\\s*("+a.reNum+"+)\\s*,?\\s*("+a.reNum+"+)\\s*,?\\s*("+a.reNum+"+)\\s*,?\\s*("+a.reNum+"+)\\s*$");function w(t){var e,i,r,n,o,s,h=t.getAttribute("viewBox"),c=1,l=1,f=t.getAttribute("width"),d=t.getAttribute("height"),g=t.getAttribute("x")||0,p=t.getAttribute("y")||0,v=t.getAttribute("preserveAspectRatio")||"",m=!h||!a.svgViewBoxElementsRegEx.test(t.nodeName)||!(h=h.match(S)),y=!f||!d||"100%"===f||"100%"===d,_=m&&y,b={},x="",C=0,w=0;if(b.width=0,b.height=0,b.toBeParsed=_)return b;if(m)return b.width=u(f),b.height=u(d),b;if(e=-parseFloat(h[1]),i=-parseFloat(h[2]),r=parseFloat(h[3]),n=parseFloat(h[4]),b.minX=e,b.minY=i,b.viewBoxWidth=r,b.viewBoxHeight=n,y?(b.width=r,b.height=n):(b.width=u(f),b.height=u(d),c=b.width/r,l=b.height/n),"none"!==(v=a.util.parsePreserveAspectRatioAttribute(v)).alignX&&("meet"===v.meetOrSlice&&(l=c=l<c?l:c),"slice"===v.meetOrSlice&&(l=c=l<c?c:l),C=b.width-r*c,w=b.height-n*c,"Mid"===v.alignX&&(C/=2),"Mid"===v.alignY&&(w/=2),"Min"===v.alignX&&(C=0),"Min"===v.alignY&&(w=0)),1===c&&1===l&&0==e&&0==i&&0===g&&0===p)return b;if((g||p)&&(x=" translate("+u(g)+" "+u(p)+") "),o=x+" matrix("+c+" 0 0 "+l+" "+(e*c+C)+" "+(i*l+w)+") ",b.viewboxTransform=a.parseTransformAttribute(o),"svg"===t.nodeName){for(s=t.ownerDocument.createElementNS(a.svgNS,"g");t.firstChild;)s.appendChild(t.firstChild);t.appendChild(s)}else o=(s=t).getAttribute("transform")+o;return s.setAttribute("transform",o),b}a.parseSVGDocument=function(t,e,i,r){if(t){!function(t){for(var e=y(t,["use","svg:use"]),i=0;e.length&&i<e.length;){var r,n=e[i],o=(n.getAttribute("xlink:href")||n.getAttribute("href")).substr(1),s=n.getAttribute("x")||0,h=n.getAttribute("y")||0,c=C(t,o).cloneNode(!0),l=(c.getAttribute("transform")||"")+" translate("+s+", "+h+")",u=e.length,f=a.svgNS;if(w(c),/^svg$/i.test(c.nodeName)){for(var d,g=c.ownerDocument.createElementNS(f,"g"),p=0,v=(d=c.attributes).length;p<v;p++)r=d.item(p),g.setAttributeNS(f,r.nodeName,r.nodeValue);for(;c.firstChild;)g.appendChild(c.firstChild);c=g}for(p=0,v=(d=n.attributes).length;p<v;p++)"x"!==(r=d.item(p)).nodeName&&"y"!==r.nodeName&&"xlink:href"!==r.nodeName&&"href"!==r.nodeName&&("transform"===r.nodeName?l=r.nodeValue+" "+l:c.setAttribute(r.nodeName,r.nodeValue));c.setAttribute("transform",l),c.setAttribute("instantiated_by_use","1"),c.removeAttribute("id"),n.parentNode.replaceChild(c,n),e.length===u&&i++}}(t);var n=a.Object.__uid++,o=w(t),s=a.util.toArray(t.getElementsByTagName("*"));if(o.crossOrigin=r&&r.crossOrigin,o.svgUid=n,0===s.length&&a.isLikelyNode){for(var h=[],l=0,u=(s=t.selectNodes('//*[name(.)!="svg"]')).length;l<u;l++)h[l]=s[l];s=h}var f,d=s.filter((function(t){return w(t),a.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 1}(t,a.svgInvalidAncestorsRegEx)}));!d||d&&!d.length?e&&e([],{}):(f={},s.filter((function(t){return"clipPath"===t.nodeName.replace("svg:","")})).forEach((function(t){var e=t.getAttribute("id");f[e]=a.util.toArray(t.getElementsByTagName("*")).filter((function(t){return a.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))}))})),a.gradientDefs[n]=a.getGradientDefs(t),a.cssRules[n]=a.getCSSRules(t),a.clipPaths[n]=f,a.parseElements(d,(function(t,i){e&&(e(t,o,i,s),delete a.gradientDefs[n],delete a.cssRules[n],delete a.clipPaths[n])}),c(o),i,r))}};var T=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+a.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+a.reNum+"))?\\s+(.*)");h(a,{parseFontDeclaration:function(t,e){var i,r,n,o,s,a=t.match(T);a&&(i=a[1],r=a[3],n=a[4],o=a[5],s=a[6],i&&(e.fontStyle=i),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),n&&(e.fontSize=u(n)),s&&(e.fontFamily=s),o&&(e.lineHeight="normal"===o?1:o))},getGradientDefs:function(t){var e,i=y(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),r=0,n={};for(r=i.length;r--;)(e=i[r]).getAttribute("xlink:href")&&function t(e,i){var r="xlink:href",n=C(e,i.getAttribute(r).substr(1));if(n&&n.getAttribute(r)&&t(e,n),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){n&&!i.hasAttribute(t)&&n.hasAttribute(t)&&i.setAttribute(t,n.getAttribute(t))})),!i.children.length)for(var o=n.cloneNode(!0);o.firstChild;)i.appendChild(o.firstChild);i.removeAttribute(r)}(t,e),n[e.getAttribute("id")]=e;return n},parseAttributes:function(t,e,i){if(t){var r,n,o,s={};void 0===i&&(i=t.getAttribute("svgUid")),t.parentNode&&a.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(s=a.parseAttributes(t.parentNode,e,i));var c=e.reduce((function(e,i){return(r=t.getAttribute(i))&&(e[i]=r),e}),{}),m=h(b(t,i),a.parseStyleAttribute(t));c=h(c,m);m[v]&&t.setAttribute(v,m[v]),n=o=s.fontSize||a.Text.DEFAULT_SVG_FONT_SIZE,c[p]&&(c[p]=n=u(c[p],o));var y,_,x,C={};for(var S in c)_=function(t,e,i,r){var n,o="[object Array]"===Object.prototype.toString.call(e);if("fill"!==t&&"stroke"!==t||"none"!==e)if("vector-effect"===t)e="non-scaling-stroke"===e;else if("strokeDashArray"===t)e="none"===e?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)e=i&&i.transformMatrix?f(i.transformMatrix,a.parseTransformAttribute(e)):a.parseTransformAttribute(e);else if("visible"===t)e="none"!==e&&"hidden"!==e,i&&!1===i.visible&&(e=!1);else if("opacity"===t)e=parseFloat(e),i&&void 0!==i.opacity&&(e*=i.opacity);else if("textAnchor"===t)e="start"===e?"left":"end"===e?"right":"center";else if("charSpacing"===t)n=u(e,r)/r*1e3;else if("paintFirst"===t){var s=e.indexOf("fill"),h=e.indexOf("stroke");e="fill";(-1<s&&-1<h&&h<s||-1===s&&-1<h)&&(e="stroke")}else{if("href"===t||"xlink:href"===t)return e;n=o?e.map(u):u(e,r)}else e="";return!o&&isNaN(n)?e:n}(y=(x=S)in d?d[x]:x,c[S],s,n),C[y]=_;C&&C.font&&a.parseFontDeclaration(C.font,C);var w=h(s,C);return a.svgValidParentsRegEx.test(t.nodeName)?w:function(t){for(var e in g)if(void 0!==t[g[e]]&&""!==t[e]){if(void 0===t[e]){if(!a.Object.prototype[e])continue;t[e]=a.Object.prototype[e]}var i;0!==t[e].indexOf("url(")&&(i=new a.Color(t[e]),t[e]=i.setAlpha(l(i.getAlpha()*t[g[e]],2)).toRgba())}return t}(w)}},parseElements:function(t,e,i,r,n){new a.ElementsParser(t,e,i,r,n).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;for(var e=[],i=0,r=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;i<r;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e},getCSSRules:function(t){for(var e=t.getElementsByTagName("style"),i={},r=0,n=e.length;r<n;r++){var o=e[r].textContent||"";""!==(o=o.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&o.match(/[^{]*\{[\s\S]*?\}/g).map((function(t){return t.trim()})).forEach((function(t){var e=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),o={},s=e[2].trim().replace(/;$/,"").split(/\s*;\s*/);for(r=0,n=s.length;r<n;r++){var h=s[r].split(/\s*:\s*/),c=h[0],l=h[1];o[c]=l}(t=e[1]).split(",").forEach((function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(i[t]?a.util.object.extend(i[t],o):i[t]=a.util.object.clone(o))}))}))}return i},loadSVGFromURL:function(t,e,i,r){t=t.replace(/^\n\s*/,"").trim(),new a.util.request(t,{method:"get",onComplete:function(t){var n=t.responseXML;if(n&&!n.documentElement&&a.window.ActiveXObject&&t.responseText&&((n=new ActiveXObject("Microsoft.XMLDOM")).async="false",n.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),!n||!n.documentElement)return e&&e(null),!1;a.parseSVGDocument(n.documentElement,(function(t,i,r,n){e&&e(t,i,r,n)}),i,r)}})},loadSVGFromString:function(t,e,i,r){var n,o;t=t.trim(),void 0!==a.window.DOMParser?(o=new a.window.DOMParser)&&o.parseFromString&&(n=o.parseFromString(t,"text/xml")):a.window.ActiveXObject&&((n=new ActiveXObject("Microsoft.XMLDOM")).async="false",n.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),a.parseSVGDocument(n.documentElement,(function(t,i,r,n){e(t,i,r,n)}),i,r)}})}(e),z.ElementsParser=function(t,e,i,r,n,o){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,this.doc=o},(C=z.ElementsParser.prototype).parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},C.createObjects=function(){var t=this;this.elements.forEach((function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)}))},C.findTag=function(t){return z[z.util.string.capitalize(t.tagName.replace("svg:",""))]},C.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){z.log(t)}else this.checkIfDone()},C.createCallback=function(t,e){var i=this;return function(r){var n;i.resolveGradient(r,e,"fill"),i.resolveGradient(r,e,"stroke"),r instanceof z.Image&&r._originalElement&&(n=r.parsePreserveAspectRatioAttribute(e)),r._removeTransformMatrix(n),i.resolveClipPath(r,e),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},C.extractPropertyDefinition=function(t,e,i){var r=t[e],n=this.regexUrl;if(n.test(r)){n.lastIndex=0;var o=n.exec(r)[1];return n.lastIndex=0,z[i][this.svgUid][o]}},C.resolveGradient=function(t,e,i){var r,n,o=this.extractPropertyDefinition(t,i,"gradientDefs");o&&(r=e.getAttribute(i+"-opacity"),n=z.Gradient.fromElement(o,t,r,this.options),t.set(i,n))},C.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},C.resolveClipPath=function(t,e){var i,r,n,o,s=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(s){n=[],r=z.util.invertTransform(t.calcTransformMatrix());for(var a=s[0].parentNode,h=e;h.parentNode&&h.getAttribute("clip-path")!==t.clipPath;)h=h.parentNode;h.parentNode.appendChild(a);for(var c=0;c<s.length;c++)i=s[c],this.findTag(i).fromElement(i,this.createClipPathCallback(t,n),this.options);s=1===n.length?n[0]:new z.Group(n),o=z.util.multiplyTransformMatrices(r,s.calcTransformMatrix()),s.clipPath&&this.resolveClipPath(s,h);var l=z.util.qrDecompose(o);s.flipX=!1,s.flipY=!1,s.set("scaleX",l.scaleX),s.set("scaleY",l.scaleY),s.angle=l.angle,s.skewX=l.skewX,s.skewY=0,s.setPositionByOrigin({x:l.translateX,y:l.translateY},"center","center"),t.clipPath=s}else delete t.clipPath},C.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,h,c=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),l=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),u=(o.y-n.y)*(r.x-t.x)-(o.x-n.x)*(r.y-t.y);return 0!=u?(h=l/u,0<=(a=c/u)&&a<=1&&0<=h&&h<=1?(s=new i("Intersection")).appendPoint(new e.Point(t.x+a*(r.x-t.x),t.y+a*(r.y-t.y))):s=new i):s=new i(0==c||0==l?"Coincident":"Parallel"),s},e.Intersection.intersectLinePolygon=function(t,e,r){for(var n,o,s,a=new i,h=r.length,c=0;c<h;c++)n=r[c],o=r[(c+1)%h],s=i.intersectLineLine(t,e,n,o),a.appendPoints(s.points);return 0<a.points.length&&(a.status="Intersection"),a},e.Intersection.intersectPolygonPolygon=function(t,e){for(var r=new i,n=t.length,o=0;o<n;o++){var s=t[o],a=t[(o+1)%n],h=i.intersectLinePolygon(s,a,e);r.appendPoints(h.points)}return 0<r.points.length&&(r.status="Intersection"),r},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,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=(e=(e=e||i.sourceFromHex(t))||i.sourceFromRgb(t))||i.sourceFromHsl(t))||[0,0,0,1])&&this.setSource(e)},_rgbToHsl:function(t,i,r){t/=255,i/=255,r/=255;var n,o=e.util.array.max([t,i,r]),s=e.util.array.min([t,i,r]),a=(o+s)/2;if(o===s)n=c=0;else{var h=o-s,c=.5<a?h/(2-o-s):h/(o+s);switch(o){case t:n=(i-r)/h+(i<r?6:0);break;case i:n=(r-t)/h+2;break;case r:n=(t-i)/h+4}n/=6}return[Math.round(360*n),Math.round(100*c),Math.round(100*a)]},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=this.getSource(),r=i[0].toString(16);return r=1===r.length?"0"+r:r,t=1===(t=i[1].toString(16)).length?"0"+t:t,e=1===(e=i[2].toString(16)).length?"0"+e:e,r.toUpperCase()+t.toUpperCase()+e.toUpperCase()},toHexa:function(){var t=this.getSource(),e=Math.round(255*t[3]);return e=1===(e=e.toString(16)).length?"0"+e:e,this.toHex()+e.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:fu