@wise-community/drawing-tool
Version:
HTML5 Drawing Tool
3 lines • 447 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?exports.DrawingTool=e(require("jquery")):t.DrawingTool=e(t.jQuery)}(window,(function(t){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},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 n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},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=13)}([function(t,e){t.exports=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.super=e.prototype}},function(e,i){e.exports=t},function(t,e,i){(function(t){
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
var n,r,s,o,a,h,c,l,u,g,f,d,p,C,A,v,m,I,w,y,M,b=b||{version:"3.6.3"};if(e.fabric=b,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?b.document=document:b.document=document.implementation.createHTMLDocument(""),b.window=window;else{var x=new(i(20).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;b.document=x.document,b.jsdomImplForWrapper=i(21).implForWrapper,b.nodeCanvas=i(22).Canvas,b.window=x,DOMParser=b.window.DOMParser}function D(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function _(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,o);var h=new ImageData(a,n,r);i.putImageData(h,0,0)}b.isTouchSupported="ontouchstart"in b.window||"ontouchstart"in b.document||b.window&&b.window.navigator&&b.window.navigator.maxTouchPoints>0,b.isLikelyNode=void 0!==t&&"undefined"==typeof window,b.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"],b.DPI=96,b.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",b.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,b.reNonWord=/[ \n\.,;!\?\-]/,b.fontPaths={},b.iMatrix=[1,0,0,1,0,0],b.svgNS="http://www.w3.org/2000/svg",b.perfLimitSizeTotal=2097152,b.maxCacheSideLimit=4096,b.minCacheSideLimit=256,b.charWidthsCache={},b.textureSize=2048,b.disableStyleCopyPaste=!1,b.enableGLFiltering=!0,b.devicePixelRatio=b.window.devicePixelRatio||b.window.webkitDevicePixelRatio||b.window.mozDevicePixelRatio||1,b.browserShadowBlurConstant=1,b.arcToSegmentsCache={},b.boundsOfCurveCache={},b.cachesBoundsOfCurve=!0,b.forceGLPutImageData=!1,b.initFilterBackend=function(){return b.enableGLFiltering&&b.isWebglSupported&&b.isWebglSupported(b.textureSize)?(console.log("max texture size: "+b.maxTextureSize),new b.WebglFilterBackend({tileSize:b.textureSize})):b.Canvas2dFilterBackend?new b.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=b),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:b.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)return this;if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var n in e)t.call(this,n,e[n]);else t.call(this,e,i);return this}function n(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n<r;n++)i[n]&&i[n].call(this,e||{});return this.__eventListeners[t]=i.filter((function(t){return!1!==t})),this}b.Observable={observe:e,stopObserving:i,fire:n,on:e,off:i,trigger:n}}(),b.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 n=this._objects;return i?n[e]=t:n.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,n=0,r=arguments.length;n<r;n++)-1!==(t=e.indexOf(arguments[n]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[n]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),n=0,r=i.length;n<r;n++)t.call(e,i[n],n,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 this._objects.indexOf(t)>-1},complexity:function(){return this._objects.reduce((function(t,e){return t+=e.complexity?e.complexity():0}),0)}},b.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof b.Gradient||this.set(e,new b.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof b.Pattern?i&&i():this.set(e,new b.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=b.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]}},n=e,r=Math.sqrt,s=Math.atan2,o=Math.pow,a=Math.PI/180,h=Math.PI/2,b.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/h){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/h){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*a},radiansToDegrees:function(t){return t/a},rotatePoint:function(t,e,i){t.subtractEquals(e);var n=b.util.rotateVector(t,i);return new b.Point(n.x,n.y).addEquals(e)},rotateVector:function(t,e){var i=b.util.sin(e),n=b.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},transformPoint:function(t,e,i){return i?new b.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new b.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]=b.util.transformPoint(t[i],e);var n=[t[0].x,t[1].x,t[2].x,t[3].x],r=b.util.array.min(n),s=b.util.array.max(n)-r,o=[t[0].y,t[1].y,t[2].y,t[3].y],a=b.util.array.min(o);return{left:r,top:a,width:s,height:b.util.array.max(o)-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]],n=b.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-n.x,i[5]=-n.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),n=parseFloat(t);switch(e||(e=b.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return n*b.DPI/25.4;case"cm":return n*b.DPI/2.54;case"in":return n*b.DPI;case"pt":return n*b.DPI/72;case"pc":return n*b.DPI/72*12;case"em":return n*e;default:return n}},falseFunction:function(){return!1},getKlass:function(t,e){return t=b.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),b.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 b;var e,i=t.split("."),r=i.length,s=n||b.window;for(e=0;e<r;++e)s=s[i[e]];return s},loadImage:function(t,e,i,n){if(t){var r=b.util.createImage(),s=function(){e&&e.call(i,r),r=r.onload=r.onerror=null};r.onload=s,r.onerror=function(){b.log("Error loading "+r.src),e&&e.call(i,null,!0),r=r.onload=r.onerror=null},0!==t.indexOf("data")&&n&&(r.crossOrigin=n),"data:image/svg"===t.substring(0,14)&&(r.onload=null,b.util.loadImageInDom(r,s)),r.src=t}else e&&e.call(i,t)},loadImageInDom:function(t,e){var i=b.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),b.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,n){var r=[],s=0,o=(t=t||[]).length;function a(){++s===o&&e&&e(r.filter((function(t){return t})))}o?t.forEach((function(t,e){t&&t.type?b.util.getKlass(t.type,i).fromObject(t,(function(i,s){s||(r[e]=i),n&&n(t,i,s),a()})):a()})):e&&e(r)},enlivenPatterns:function(t,e){function i(){++r===s&&e&&e(n)}var n=[],r=0,s=(t=t||[]).length;s?t.forEach((function(t,e){t&&t.source?new b.Pattern(t,(function(t){n[e]=t,i()})):(n[e]=t,i())})):e&&e(n)},groupSVGElements:function(t,e,i){var n;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)),n=new b.Group(t,e),void 0!==i&&(n.sourcePath=i),n)},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var n=0,r=i.length;n<r;n++)i[n]in t&&(e[i[n]]=t[i[n]])},drawDashedLine:function(t,e,i,n,o,a){var h=n-e,c=o-i,l=r(h*h+c*c),u=s(c,h),g=a.length,f=0,d=!0;for(t.save(),t.translate(e,i),t.moveTo(0,0),t.rotate(u),e=0;l>e;)(e+=a[f++%g])>l&&(e=l),t[d?"lineTo":"moveTo"](e,0),d=!d;t.restore()},createCanvasElement:function(){return b.document.createElement("canvas")},copyCanvasElement:function(t){var e=b.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 b.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=o(t[0],2)+o(t[1],2),n=r(i),h=(t[0]*t[3]-t[2]*t[1])/n,c=s(t[0]*t[2]+t[1]*t[3],i);return{angle:e/a,scaleX:n,scaleY:h,skewX:c/a,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return b.iMatrix.concat();var e=b.util.degreesToRadians(t.angle),i=b.util.cos(e),n=b.util.sin(e);return[i,n,-n,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,n=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],r=b.util.multiplyTransformMatrices,s=b.util.degreesToRadians;return t.skewX&&(n=r(n,[1,0,Math.tan(s(t.skewX)),1],!0)),t.skewY&&(n=r(n,[1,Math.tan(s(t.skewY)),0,1],!0)),n},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=b.util.multiplyTransformMatrices;return t.angle&&(e=i(e,b.util.calcRotateMatrix(t))),(t.scaleX||t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,b.util.calcDimensionsMatrix(t))),e},customTransformMatrix:function(t,e,i){return b.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,n){n>0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,o=t.getImageData(e,i,2*n||1,2*n||1),a=o.data.length;for(r=3;r<a&&!1!=(s=o.data[r]<=0);r+=4);return o=null,s},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",n=t.split(" ");return n&&n.length&&("meet"!==(i=n.pop())&&"slice"!==i?(e=i,i="meet"):n.length&&(e=n.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())?b.charWidthsCache[t]&&delete b.charWidthsCache[t]:b.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),n=Math.floor(e/i);return{x:Math.floor(i),y:n}},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 b.util.toFixed(t,b.Object.NUM_FRACTION_DIGITS)})).join(" ")+")"}},function(){var t=Array.prototype.join;function e(e,r,s,o,a,h,c){var l=t.call(arguments);if(b.arcToSegmentsCache[l])return b.arcToSegmentsCache[l];var u=Math.PI,g=c*u/180,f=b.util.sin(g),d=b.util.cos(g),p=0,C=0,A=-d*e*.5-f*r*.5,v=-d*r*.5+f*e*.5,m=(s=Math.abs(s))*s,I=(o=Math.abs(o))*o,w=v*v,y=A*A,M=m*I-m*w-I*y,x=0;if(M<0){var D=Math.sqrt(1-M/(m*I));s*=D,o*=D}else x=(a===h?-1:1)*Math.sqrt(M/(m*w+I*y));var _=x*s*v/o,T=-x*o*A/s,S=d*_-f*T+.5*e,O=f*_+d*T+.5*r,j=n(1,0,(A-_)/s,(v-T)/o),P=n((A-_)/s,(v-T)/o,(-A-_)/s,(-v-T)/o);0===h&&P>0?P-=2*u:1===h&&P<0&&(P+=2*u);for(var L=Math.ceil(Math.abs(P/u*2)),k=[],N=P/L,E=8/3*Math.sin(N/4)*Math.sin(N/4)/Math.sin(N/2),z=j+N,R=0;R<L;R++)k[R]=i(j,z,d,f,s,o,S,O,E,p,C),p=k[R][4],C=k[R][5],j=z,z+=N;return b.arcToSegmentsCache[l]=k,k}function i(t,e,i,n,r,s,o,a,h,c,l){var u=b.util.cos(t),g=b.util.sin(t),f=b.util.cos(e),d=b.util.sin(e),p=i*r*f-n*s*d+o,C=n*r*f+i*s*d+a;return[c+h*(-i*r*g-n*s*u),l+h*(-n*r*g+i*s*u),p+h*(i*r*d+n*s*f),C+h*(n*r*d-i*s*f),p,C]}function n(t,e,i,n){var r=Math.atan2(e,t),s=Math.atan2(n,i);return s>=r?s-r:2*Math.PI-(r-s)}function r(e,i,n,r,s,o,a,h){var c;if(b.cachesBoundsOfCurve&&(c=t.call(arguments),b.boundsOfCurveCache[c]))return b.boundsOfCurveCache[c];var l,u,g,f,d,p,C,A,v=Math.sqrt,m=Math.min,I=Math.max,w=Math.abs,y=[],M=[[],[]];u=6*e-12*n+6*s,l=-3*e+9*n-9*s+3*a,g=3*n-3*e;for(var x=0;x<2;++x)if(x>0&&(u=6*i-12*r+6*o,l=-3*i+9*r-9*o+3*h,g=3*r-3*i),w(l)<1e-12){if(w(u)<1e-12)continue;0<(f=-g/u)&&f<1&&y.push(f)}else(C=u*u-4*g*l)<0||(0<(d=(-u+(A=v(C)))/(2*l))&&d<1&&y.push(d),0<(p=(-u-A)/(2*l))&&p<1&&y.push(p));for(var D,_,T,S=y.length,O=S;S--;)D=(T=1-(f=y[S]))*T*T*e+3*T*T*f*n+3*T*f*f*s+f*f*f*a,M[0][S]=D,_=T*T*T*i+3*T*T*f*r+3*T*f*f*o+f*f*f*h,M[1][S]=_;M[0][O]=e,M[1][O]=i,M[0][O+1]=a,M[1][O+1]=h;var j=[{x:m.apply(null,M[0]),y:m.apply(null,M[1])},{x:I.apply(null,M[0]),y:I.apply(null,M[1])}];return b.cachesBoundsOfCurve&&(b.boundsOfCurveCache[c]=j),j}b.util.drawArc=function(t,i,n,r){for(var s=r[0],o=r[1],a=r[2],h=r[3],c=r[4],l=[[],[],[],[]],u=e(r[5]-i,r[6]-n,s,o,h,c,a),g=0,f=u.length;g<f;g++)l[g][0]=u[g][0]+i,l[g][1]=u[g][1]+n,l[g][2]=u[g][2]+i,l[g][3]=u[g][3]+n,l[g][4]=u[g][4]+i,l[g][5]=u[g][5]+n,t.bezierCurveTo.apply(t,l[g])},b.util.getBoundsOfArc=function(t,i,n,s,o,a,h,c,l){for(var u,g=0,f=0,d=[],p=e(c-t,l-i,n,s,a,h,o),C=0,A=p.length;C<A;C++)u=r(g,f,p[C][0],p[C][1],p[C][2],p[C][3],p[C][4],p[C][5]),d.push({x:u[0].x+t,y:u[0].y+i}),d.push({x:u[1].x+t,y:u[1].y+i}),g=p[C][4],f=p[C][5];return d},b.util.getBoundsOfCurve=r}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var n=t.length-1,r=e?t[n][e]:t[n];if(e)for(;n--;)i(t[n][e],r)&&(r=t[n][e]);else for(;n--;)i(t[n],r)&&(r=t[n]);return r}}b.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var n=t.call(arguments,2),r=[],s=0,o=e.length;s<o;s++)r[s]=n.length?e[s][i].apply(e[s],n):e[s][i].call(e[s]);return r},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 t>=e}))}}}(),function(){function t(e,i,n){if(n)if(!b.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,s=i.length;r<s;r++)e[r]=t({},i[r],n)}else if(i&&"object"==typeof i)for(var o in i)"canvas"===o?e[o]=t({},i[o]):i.hasOwnProperty(o)&&(e[o]=t({},i[o],n));else e=i;else for(var o in i)e[o]=i[o];return e}b.util.object={extend:t,clone:function(e,i){return t({},e,i)}},b.util.object.extend(b.util,b.Observable)}(),function(){function t(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)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 r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}b.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,n=0,r=[];for(n=0;n<e.length;n++)!1!==(i=t(e,n))&&r.push(i);return r}}}(),function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),n=function(t,e,n){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}b.util.createClass=function(){var i=null,o=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof o[0]&&(i=o.shift()),a.superclass=i,a.subclasses=[],i&&(r.prototype=i.prototype,a.prototype=new r,i.subclasses.push(a));for(var h=0,c=o.length;h<c;h++)n(a,o[h],i);return a.prototype.initialize||(a.prototype.initialize=e),a.prototype.constructor=a,a.prototype.callSuper=s,a}}(),c=!!b.document.createElement("div").attachEvent,b.util.addListener=function(t,e,i,n){t&&t.addEventListener(e,i,!c&&n)},b.util.removeListener=function(t,e,i,n){t&&t.removeEventListener(e,i,!c&&n)},b.util.getPointer=function(t){var e=t.target,i=b.util.getScrollLeftTop(e),n=function(t){var e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return{x:n.clientX+i.left,y:n.clientY+i.top}},l=b.document.createElement("div"),u="string"==typeof l.style.opacity,g="string"==typeof l.style.filter,f=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,d=function(t){return t},u?d=function(t,e){return t.style.opacity=e,t}:g&&(d=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),f.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(f,e)):i.filter+=" alpha(opacity="+100*e+")",t}),b.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?d(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?d(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t=Array.prototype.slice;var e,i,n,r,s=function(e){return t.call(e,0)};try{e=s(b.document.childNodes)instanceof Array}catch(t){}function o(t,e){var i=b.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function a(t){for(var e=0,i=0,n=b.document.documentElement,r=b.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===b.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}e||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),i=b.document.defaultView&&b.document.defaultView.getComputedStyle?function(t,e){var i=b.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},n=b.document.documentElement.style,r="userSelect"in n?"userSelect":"MozUserSelect"in n?"MozUserSelect":"WebkitUserSelect"in n?"WebkitUserSelect":"KhtmlUserSelect"in n?"KhtmlUserSelect":"",b.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=b.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},b.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},b.util.getScript=function(t,e){var i=b.document.getElementsByTagName("head")[0],n=b.document.createElement("script"),r=!0;n.onload=n.onreadystatechange=function(t){if(r){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;r=!1,e(t||b.window.event),n=n.onload=n.onreadystatechange=null}},n.src=t,i.appendChild(n)},b.util.getById=function(t){return"string"==typeof t?b.document.getElementById(t):t},b.util.toArray=s,b.util.makeElement=o,b.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},b.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=o(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},b.util.getScrollLeftTop=a,b.util.getElementOffset=function(t){var e,n,r=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return o;for(var c in h)o[h[c]]+=parseInt(i(t,c),10)||0;return e=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=a(t),{left:s.left+n.left-(e.clientLeft||0)+o.left,top:s.top+n.top-(e.clientTop||0)+o.top}},b.util.getElementStyle=i,b.util.getNodeCanvas=function(t){var e=b.jsdomImplForWrapper(t);return e._canvas||e._image},b.util.cleanUpJsdomNode=function(t){if(b.isLikelyNode){var e=b.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}b.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},s=new b.window.XMLHttpRequest,o=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(r(s),s.onreadystatechange=t)},"GET"===n&&(o=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(n,e,!0),"POST"!==n&&"PUT"!==n||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s}}(),b.log=console.log,b.warn=console.warn,function(){function t(){return!1}function e(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}var i=b.window.requestAnimationFrame||b.window.webkitRequestAnimationFrame||b.window.mozRequestAnimationFrame||b.window.oRequestAnimationFrame||b.window.msRequestAnimationFrame||function(t){return b.window.setTimeout(t,1e3/60)},n=b.window.cancelAnimationFrame||b.window.clearTimeout;function r(){return i.apply(b.window,arguments)}b.util.animate=function(i){r((function(n){i||(i={});var s,o=n||+new Date,a=i.duration||500,h=o+a,c=i.onChange||t,l=i.abort||t,u=i.onComplete||t,g=i.easing||e,f="startValue"in i?i.startValue:0,d="endValue"in i?i.endValue:100,p=i.byValue||d-f;i.onStart&&i.onStart(),function t(e){var i=(s=e||+new Date)>h?a:s-o,n=i/a,C=g(i,f,p,a),A=Math.abs((C-f)/p);if(!l())return s>h?(c(d,1,1),void u(d,1,1)):(c(C,A,n),void r(t));u(d,1,1)}(o)}))},b.util.requestAnimFrame=r,b.util.cancelAnimFrame=function(){return n.apply(b.window,arguments)}}(),b.util.animateColor=function(t,e,i,n){var r=new b.Color(t).getSource(),s=new b.Color(e).getSource();n=n||{},b.util.animate(b.util.object.extend(n,{duration:i||500,startValue:r,endValue:s,byValue:s,easing:function(t,e,i,r){var s,o,a,h,c=n.colorEasing?n.colorEasing(t,r):1-Math.cos(t/r*(Math.PI/2));return s=e,o=i,a=c,h="rgba("+parseInt(s[0]+a*(o[0]-s[0]),10)+","+parseInt(s[1]+a*(o[1]-s[1]),10)+","+parseInt(s[2]+a*(o[2]-s[2]),10),h+=","+(s&&o?parseFloat(s[3]+a*(o[3]-s[3])):1),h+=")"}}))},function(){function t(t,e,i,n){return t<Math.abs(e)?(t=e,n=i/4):n=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:n}}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,r){return i-n(r-t,0,i,r)+e}function n(t,e,i,n){return(t/=n)<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}b.util.ease={easeInQuad:function(t,e,i,n){return i*(t/=n)*t+e},easeOutQuad:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},easeInOutQuad:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,n){return i*(t/=n)*t*t+e},easeOutCubic:function(t,e,i,n){return i*((t=t/n-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,n){return i*(t/=n)*t*t*t+e},easeOutQuart:function(t,e,i,n){return-i*((t=t/n-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},easeOutQuint:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,n){return(t/=n/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,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,n){return i*Math.sin(t/n*(Math.PI/2))+e},easeInOutSine:function(t,e,i,n){return-i/2*(Math.cos(Math.PI*t/n)-1)+e},easeInExpo:function(t,e,i,n){return 0===t?e:i*Math.pow(2,10*(t/n-1))+e},easeOutExpo:function(t,e,i,n){return t===n?e+i:i*(1-Math.pow(2,-10*t/n))+e},easeInOutExpo:function(t,e,i,n){return 0===t?e:t===n?e+i:(t/=n/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,n){return-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOutCirc:function(t,e,i,n){return i*Math.sqrt(1-(t=t/n-1)*t)+e},easeInOutCirc:function(t,e,i,n){return(t/=n/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,n,r,s){var o=0;return 0===i?n:1===(i/=s)?n+r:(o||(o=.3*s),-e(t(r,r,o,1.70158),i,s)+n)},easeOutElastic:function(e,i,n,r){var s=0;if(0===e)return i;if(1===(e/=r))return i+n;s||(s=.3*r);var o=t(n,n,s,1.70158);return o.a*Math.pow(2,-10*e)*Math.sin((e*r-o.s)*(2*Math.PI)/o.p)+o.c+i},easeInOutElastic:function(i,n,r,s){var o=0;if(0===i)return n;if(2===(i/=s/2))return n+r;o||(o=s*(.3*1.5));var a=t(r,r,o,1.70158);return i<1?-.5*e(a,i,s)+n:a.a*Math.pow(2,-10*(i-=1))*Math.sin((i*s-a.s)*(2*Math.PI)/a.p)*.5+a.c+n},easeInBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*(t/=n)*t*((r+1)*t-r)+e},easeOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},easeInOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInBounce:i,easeOutBounce:n,easeInOutBounce:function(t,e,r,s){return t<s/2?.5*i(2*t,0,r,s)+e:.5*n(2*t-s,0,r,s)+.5*r+e}}}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.parseUnit,o=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-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"},h={stroke:"strokeOpacity",fill:"fillOpacity"};function c(t){return t in a?a[t]:t}function l(t,i,n,r){var a,h="[object Array]"===Object.prototype.toString.call(i);if("fill"!==t&&"stroke"!==t||"none"!==i)if("vector-effect"===t)i="non-scaling-stroke"===i;else if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)i=n&&n.transformMatrix?o(n.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,n&&!1===n.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),n&&void 0!==n.opacity&&(i*=n.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=s(i,r)/r*1e3;else if("paintFirst"===t){var c=i.indexOf("fill"),l=i.indexOf("stroke");i="fill";(c>-1&&l>-1&&l<c||-1===c&&l>-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t)return i;a=h?i.map(s):s(i,r)}else i="";return!h&&isNaN(a)?i:a}function u(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,n,r,s,o=[];for(r=0,s=e.length;r<s;r++)i=e[r],n=t.getElementsByTagName(i),o=o.concat(Array.prototype.slice.call(n));return o}function f(t,e){var i,n=!0;return(i=d(t,e.pop()))&&e.length&&(n=function(t,e){var i,n=!0;for(;t.parentNode&&1===t.parentNode.nodeType&&e.length;)n&&(i=e.pop()),t=t.parentNode,n=d(t,i);return 0===e.length}(t,e)),i&&n&&0===e.length}function d(t,e){var i,n,r=t.nodeName,s=t.getAttribute("class"),o=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),o&&e.length&&(i=new RegExp("#"+o+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),s&&e.length)for(n=(s=s.split(" ")).length;n--;)i=new RegExp("\\."+s[n]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function p(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var n,r,s,o=t.getElementsByTagName("*");for(r=0,s=o.length;r<s;r++)if(e===(n=o[r]).getAttribute("id"))return n}e.svgValidTagNamesRegEx=u(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=u(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=u(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=u(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,n){t[n]=Math.tan(e.util.degreesToRadians(i[0]))}var i=e.iMatrix,n=e.reNum,r="(?:\\s+,?\\s*|,\\s*)",s="(?:"+("(?:(matrix)\\s*\\(\\s*("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")\\s*\\))")+"|"+("(?:(translate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(scale)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(rotate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+")"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(skewX)\\s*\\(\\s*("+n+")\\s*\\))")+"|"+("(?:(skewY)\\s*\\(\\s*("+n+")\\s*\\))")+")",o=new RegExp("^\\s*(?:"+("(?:"+s+"(?:"+r+"*"+s+")*)")+"?)\\s*$"),a=new RegExp(s,"g");return function(n){var r=i.concat(),h=[];if(!n||n&&!o.test(n))return r;n.replace(a,(function(n){var o=new RegExp(s).exec(n).filter((function(t){return!!t})),a=o[1],c=o.slice(2).map(parseFloat);switch(a){case"translate":!function(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}(r,c);break;case"rotate":c[0]=e.util.degreesToRadians(c[0]),function(t,i){var n=e.util.cos(i[0]),r=e.util.sin(i[0]),s=0,o=0;3===i.length&&(s=i[1],o=i[2]),t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=s-(n*s-r*o),t[5]=o-(r*s+n*o)}(r,c);break;case"scale":!function(t,e){var i=e[0],n=2===e.length?e[1]:e[0];t[0]=i,t[3]=n}(r,c);break;case"skewX":t(r,c,2);break;case"skewY":t(r,c,1);break;case"matrix":r=c}h.push(r.concat()),r=i.concat()}));for(var c=h[0];h.length>1;)h.shift(),c=e.util.multiplyTransformMatrices(c,h[0]);return c}}();var C=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function A(t){var i,n,r,o,a,h,c=t.getAttribute("viewBox"),l=1,u=1,g=t.getAttribute("width"),f=t.getAttribute("height"),d=t.getAttribute("x")||0,p=t.getAttribute("y")||0,A=t.getAttribute("preserveAspectRatio")||"",v=!c||!e.svgViewBoxElementsRegEx.test(t.nodeName)||!(c=c.match(C)),m=!g||!f||"100%"===g||"100%"===f,I=v&&m,w={},y="",M=0,b=0;if(w.width=0,w.height=0,w.toBeParsed=I,I)return w;if(v)return w.width=s(g),w.height=s(f),w;if(i=-parseFloat(c[1]),n=-parseFloat(c[2]),r=parseFloat(c[3]),o=parseFloat(c[4]),w.minX=i,w.minY=n,w.viewBoxWidth=r,w.viewBoxHeight=o,m?(w.width=r,w.height=o):(w.width=s(g),w.height=s(f),l=w.width/r,u=w.height/o),"none"!==(A=e.util.parsePreserveAspectRatioAttribute(A)).alignX&&("meet"===A.meetOrSlice&&(u=l=l>u?u:l),"slice"===A.meetOrSlice&&(u=l=l>u?l:u),M=w.width-r*l,b=w.height-o*l,"Mid"===A.alignX&&(M/=2),"Mid"===A.alignY&&(b/=2),"Min"===A.alignX&&(M=0),"Min"===A.alignY&&(b=0)),1===l&&1===u&&0===i&&0===n&&0===d&&0===p)return w;if((d||p)&&(y=" translate("+s(d)+" "+s(p)+") "),a=y+" matrix("+l+" 0 0 "+u+" "+(i*l+M)+" "+(n*u+b)+") ",w.viewboxTransform=e.parseTransformAttribute(a),"svg"===t.nodeName){for(h=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else a=(h=t).getAttribute("transform")+a;return h.setAttribute("transform",a),w}function v(t,e){var i=p(t,e.getAttribute("xlink:href").substr(1));if(i&&i.getAttribute("xlink:href")&&v(t,i),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){i&&!e.hasAttribute(t)&&i.hasAttribute(t)&&e.setAttribute(t,i.getAttribute(t))})),!e.children.length)for(var n=i.cloneNode(!0);n.firstChild;)e.appendChild(n.firstChild);e.removeAttribute("xlink:href")}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),n=0;i.length&&n<i.length;){var r,s,o,a,h=i[n],c=(h.getAttribute("xlink:href")||h.getAttribute("href")).substr(1),l=h.getAttribute("x")||0,u=h.getAttribute("y")||0,f=p(t,c).cloneNode(!0),d=(f.getAttribute("transform")||"")+" translate("+l+", "+u+")",C=i.length,v=e.svgNS;if(A(f),/^svg$/i.test(f.nodeName)){var m=f.ownerDocument.createElementNS(v,"g");for(s=0,a=(o=f.attributes).length;s<a;s++)r=o.item(s),m.setAttributeNS(v,r.nodeName,r.nodeValue);for(;f.firstChild;)m.appendChild(f.firstChild);f=m}for(s=0,a=(o=h.attributes).length;s<a;s++)"x"!==(r=o.item(s)).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"),h.parentNode.replaceChild(f,h),i.length===C&&n++}}(t);var o,a,h=e.Object.__uid++,c=A(t),l=e.util.toArray(t.getElementsByTagName("*"));if(c.crossOrigin=s&&s.crossOrigin,c.svgUid=h,0===l.length&&e.isLikelyNode){var u=[];for(o=0,a=(l=t.selectNodes('//*[name(.)!="svg"]')).length;o<a;o++)u[o]=l[o];l=u}var f=l.filter((function(t){return A(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(!f||f&&!f.length)i&&i([],{});else{var d={};l.filter((function(t){return"clipPath"===t.nodeName.replace("svg:","")})).forEach((function(t){var i=t.getAttribute("id");d[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]=d,e.parseElements(f,(function(t,n){i&&(i(t,c,n,l),delete e.gradientDefs[h],delete e.cssRules[h],delete e.clipPaths[h])}),n(c),r,s)}}};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 n=i[1],r=i[3],o=i[4],a=i[5],h=i[6];n&&(e.fontStyle=n),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),o&&(e.fontSize=s(o)),h&&(e.fontFamily=h),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i=g(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),n=0,r={};for(n=i.length;n--;)(e=i[n]).getAttribute("xlink:href")&&v(t,e),r[e.getAttribute("id")]=e;return r},parseAttributes:function(t,n,o){if(t){var a,u,g,d={};void 0===o&&(o=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(d=e.parseAttributes(t.parentNode,n,o));var p=n.reduce((function(e,i){return(a=t.getAttribute(i))&&(e[i]=a),e}),{}),C=i(function(t,i){var n={};for(var r in e.cssRules[i])if(f(t,r.split(" ")))for(var s in e.cssRules[i][r])n[s]=e.cssRules[i][r][s];return n}(t,o),e.parseStyleAttribute(t));p=i(p,C),C["clip-path"]&&t.setAttribute("clip-path",C["clip-path"]),u=g=d.fontSize||e.Text.DEFAULT_SVG_FONT_SIZE,p["font-size"]&&(p["font-size"]=u=s(p["font-size"],g));var A,v,m={};for(var I in p)v=l(A=c(I),p[I],d,u),m[A]=v;m&&m.font&&e.parseFontDeclaration(m.font,m);var w=i(d,m);return e.svgValidParentsRegEx.test(t.nodeName)?w: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 n=new e.Color(t[i]);t[i]=n.setAlpha(r(n.getAlpha()*t[h[i]],2)).toRgba()}}return t}(w)}},parseElements:function(t,i,n,r,s){new e.ElementsParser(t,i,n,r,s).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){var i,n;t.replace(/;\s*$/,"").split(";").forEach((function(t){var r=t.split(":");i=r[0].trim().toLowerCase(),n=r[1].trim(),e[i]=n}))}(i,e):function(t,e){var i,n;for(var r in t)void 0!==t[r]&&(i=r.toLowerCase(),n=t[r],e[i]=n)}(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;var e,i,n=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n},getCSSRules:function(t){var i,n,r=t.getElementsByTagName("style"),s={};for(i=0,n=r.length;i<n;i++){var o=r[i].textContent||"";""!==(o=o.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&o.match(/[^{]*\{[\s\S]*?\}/g).map((function(t){return t.trim()})).forEach((function(t){var r=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),o={},a=r[2].trim().replace(/;$/,"").split(/\s*;\s*/);for(i=0,n=a.length;i<n;i++){var h=a[i].split(/\s*:\s*/),c=h[0],l=h[1];o[c]=l}(t=r[1]).split(",").forEach((function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(s[t]?e.util.object.extend(s[t],o):s[t]=e.util.object.clone(o))}))}))}return s},loadSVGFromURL:function(t,i,n,r){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var s=t.responseXML;s&&!s.documentElement&&e.window.ActiveXObject&&t.responseText&&((s=new ActiveXObject("Microsoft.XMLDOM")).async="false",s.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));if(!s||!s.documentElement)return i&&i(null),!1;e.parseSVGDocument(s.documentElement,(function(t,e,n,r){i&&i(t,e,n,r)}),n,r)}})},loadSVGFromString:function(t,i,n,r){var s;if(t=t.trim(),void 0!==e.window.DOMParser){var o=new e.window.DOMParser;o&&o.parseFromString&&(s=o.parseFromString(t,"text/xml"))}else e.window.ActiveXObject&&((s=new ActiveXObject("Microsoft.XMLDOM")).async="false",s.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));e.parseSVGDocument(s.documentElement,(function(t,e,n,r){i(t,e,n,r)}),n,r)}})}(e),b.ElementsParser=function(t,e,i,n,r,s){this.elements=t,this.callback=e,this.options=i,this.reviver=n,this.svgUid=i&&i.svgUid||0,this.parsingOptions=r,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=s},(p=b.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 b[b.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){b.log(t)}else this.checkIfDone()},p.createCallback=function(t,e){var i=this;return function(n){var r;i.resolveGradient(n,e,"fill"),i.resolveGradient(n,e,"stroke"),n instanceof b.Image&&n._originalElement&&(r=n.parsePreserveAspectRatioAttribute(e)),n._removeTransformMatrix(r),i.resolveClipPath(n,e),i.reviver&&i.reviver(e,n),i.instances[t]=n,i.checkIfDone()}},p.extractPropertyDefinition=function(t,e,i){var n=t[e],r=this.regexUrl;if(r.test(n)){r.lastIndex=0;var s=r.exec(n)[1];return r.lastIndex=0,b[i][this.svgUid][s]}},p.resolveGradient=function(t,e,i){var n=this.extractPropertyDefinition(t,i,"gradientDefs");if(n){var r=e.getAttribute(i+"-opacity"),s=b.Gradient.fromElement(n,t,r,this.options);t.set(i,s)}},p.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},p.resolveClipPath=function(t,e){var i,n,r,s,o=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(o){r=[],n=b.util.invertTransform(t.calcTransformMatrix());for(var a=o[0].parentNode,h=e;h.parentNode&&h.getAttribute("clip-path")!==t.clipPath;)h=h.parentNode;h.parentNode.appendChild(a);for(var c=0;c<o.length;c++)i=o[c],this.findTag(i).fromElement(i,this.createClipPathCallback(t,r),this.options);o=1===r.length?r[0]:new b.Group(r),s=b.util.multiplyTransformMatrices(n,o.calcTransformMatrix()),o.clipPath&&this.resolveClipPath(o,h);var l=b.util.qrDecompose(s);o.flipX=!1,o.flipY=!1,o.set("scaleX",l.scaleX),o.set("scaleY",l.scaleY),o.angle=l.angle,o.skewX=l.skewX,o.skewY=0,o.setPositionByOrigin({x:l.translateX,y:l.translateY},"center","center"),t.clipPath=o}else delete t.clipPath},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,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,n,r,s){var o,a=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),h=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),c=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(o=new i("Intersection")).appendPoint(new e.Point(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):o=new i}else o=new i(0===a||0===h?"Coincident":"Parallel");return o},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,o,a,h=new i,c=n.length;for(a=0;a<c;a++)r=n[a],s=n[(a+1)%c],o=i.intersectLineLine(t,e,r,s),h.appendPoints(o.points);return h.points.length>0&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n<s;n++){var o=t[n],a=t[(n+1)%s],h=i.intersectLinePolygon(o,a,e);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),o=n.max(r),a=new e.Point(o.x,s.y),h=new e.Point(s.x,o.y),c=i.intersectLinePolygon(s,a,t),l=i.intersectLinePolygon(a,o,t),u=i.intersectLinePolygon(o,h,t),g=i.intersectLinePolygon(h,s,t),f=new i;return f.appendPoints(c.points),f.appendPoints(l.points),f.appendPoints(u.points),f.appendPoints(g.points),f.points.length>0&&(f.status="Intersection"),f})}(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 n(t,e,i){return i<0&&(i+=1),i>1&&(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,n){t/=255,i/=255,n/=255;var r,s,o,a=e.util.array.max([t,i,n]),h=e.util.array.min([t,i,n]);if(o=(a+h)/2,a===h)r=s=0;else{var c=a-h;switch(s=o>.5?c/(2-a-h):c/(a+h),a){case t:r=(i-n)/c+(i<n?6:0);break;case i:r=(n-t)/c+2;break;case n:r=(t-i)/c+4}r/=6}return[Math.round(360*r),Math.round(100*s),Math.round(100*o)]},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,n=this.getSource();return t=1===(t=n[0].toString(16)).length?"0"+t:t,e=1===(e=n[1].toString(16)).length?"0"+e:e,i=1===(i=n[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),n=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,n]),this},overlayWith:function(t){t instanceof i||(t=new i(t));var e,n=[],r=this.getAlpha(),s=this.getSource(),o=t.getSource();for(e=0;e<3;e++)n.push(Math.round(.5*s[e]+.5*o[e]));return n[3]=r,this.setSource(n),this}},e.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?: