PageSourceSearch

https://www.shirtsinbulk.com/cdn/shop/t/5/assets/fabric4.js?v=136006269476888978931689553324

js shirtsinbulk.com collected 2026-09-24 20:27:44 UTC 416,999 bytes, 2 lines download raw bytes

1/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"4.1.0"};if(typeof exports!="undefined"?exports.fabric=fabric:typeof define=="function"&&define.amd&&define([],function(){return fabric}),typeof document!="undefined"&&typeof window!="undefined")document instanceof(typeof HTMLDocument!="undefined"?HTMLDocument:Document)?fabric.document=document:fabric.document=document.implementation.createHTMLDocument(""),fabric.window=window;else{var jsdom=require("jsdom"),virtualWindow=new jsdom.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;fabric.document=virtualWindow.document,fabric.jsdomImplForWrapper=require("jsdom/lib/jsdom/living/generated/utils").implForWrapper,fabric.nodeCanvas=require("jsdom/lib/jsdom/utils").Canvas,fabric.window=virtualWindow,DOMParser=fabric.window.DOMParser}fabric.isTouchSupported="ontouchstart"in fabric.window||"ontouchstart"in fabric.document||fabric.window&&fabric.window.navigator&&fabric.window.navigator.maxTouchPoints>0,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined",fabric.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"],fabric.DPI=300,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",fabric.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig,fabric.reNonWord=/[ \n\.,;!\?\-]/,fabric.fontPaths={},fabric.iMatrix=[1,0,0,1,0,0],fabric.svgNS="http://www.w3.org/2000/svg",fabric.perfLimitSizeTotal=2097152,fabric.maxCacheSideLimit=4096,fabric.minCacheSideLimit=256,fabric.charWidthsCache={},fabric.textureSize=2048,fabric.disableStyleCopyPaste=!1,fabric.enableGLFiltering=!0,fabric.devicePixelRatio=fabric.window.devicePixelRatio||fabric.window.webkitDevicePixelRatio||fabric.window.mozDevicePixelRatio||1,fabric.browserShadowBlurConstant=1,fabric.arcToSegmentsCache={},fabric.boundsOfCurveCache={},fabric.cachesBoundsOfCurve=!0,fabric.forceGLPutImageData=!1,fabric.initFilterBackend=function(){if(fabric.enableGLFiltering&&fabric.isWebglSupported&&fabric.isWebglSupported(fabric.textureSize))return console.log("max texture size: "+fabric.maxTextureSize),new fabric.WebglFilterBackend({tileSize:fabric.textureSize});if(fabric.Canvas2dFilterBackend)return new fabric.Canvas2dFilterBackend},typeof document!="undefined"&&typeof window!="undefined"&&(window.fabric=fabric),(function(){function _removeEventListener(eventName,handler){if(this.__eventListeners[eventName]){var eventListener=this.__eventListeners[eventName];handler?eventListener[eventListener.indexOf(handler)]=!1:fabric.util.array.fill(eventListener,!1)}}function on(eventName,handler){if(this.__eventListeners||(this.__eventListeners={}),arguments.length===1)for(var prop in eventName)this.on(prop,eventName[prop]);else this.__eventListeners[eventName]||(this.__eventListeners[eventName]=[]),this.__eventListeners[eventName].push(handler);return this}function off(eventName,handler){if(!this.__eventListeners)return this;if(arguments.length===0)for(eventName in this.__eventListeners)_removeEventListener.call(this,eventName);else if(arguments.length===1&&typeof arguments[0]=="object")for(var prop in eventName)_removeEventListener.call(this,prop,eventName[prop]);else _removeEventListener.call(this,eventName,handler);return this}function fire(eventName,options){if(!this.__eventListeners)return this;var listenersForEvent=this.__eventListeners[eventName];if(!listenersForEvent)return this;for(var i=0,len=listenersForEvent.length;i<len;i++)listenersForEvent[i]&&listenersForEvent[i].call(this,options||{});return this.__eventListeners[eventName]=listenersForEvent.filter(function(value){return value!==!1}),this}fabric.Observable={fire:fire,on:on,off:off}})(),fabric.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var i=0,length=arguments.length;i<length;i++)this._onObjectAdded(arguments[i]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(object,index,nonSplicing){var objects=this._objects;return nonSplicing?objects[index]=object:objects.splice(index,0,object),this._onObjectAdded&&this._onObjectAdded(object),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var objects=this._objects,index,somethingRemoved=!1,i=0,length=arguments.length;i<length;i++)index=objects.indexOf(arguments[i]),index!==-1&&(somethingRemoved=!0,objects.splice(index,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[i]));return this.renderOnAddRemove&&somethingRemoved&&this.requestRenderAll(),this}
1,forEachObject:function(callback,context){for(var objects=this.getObjects(),i=0,len=objects.length;i<len;i++)callback.call(context,objects[i],i,objects);return this},getObjects:function(type){return typeof type=="undefined"?this._objects.concat():this._objects.filter(function(o){return o.type===type})},item:function(index){return this._objects[index]},isEmpty:function(){return this._objects.length===0},size:function(){return this._objects.length},contains:function(object){return this._objects.indexOf(object)>-1},complexity:function(){return this._objects.reduce(function(memo,current){return memo+=current.complexity?current.complexity():0,memo},0)}},fabric.CommonMethods={_setOptions:function(options){for(var prop in options)this.set(prop,options[prop])},_initGradient:function(filler,property){filler&&filler.colorStops&&!(filler instanceof fabric.Gradient)&&this.set(property,new fabric.Gradient(filler))},_initPattern:function(filler,property,callback){filler&&filler.source&&!(filler instanceof fabric.Pattern)?this.set(property,new fabric.Pattern(filler,callback)):callback&&callback()},_setObject:function(obj){for(var prop in obj)this._set(prop,obj[prop])},set:function(key,value){return typeof key=="object"?this._setObject(key):this._set(key,value),this},_set:function(key,value){this[key]=value},toggle:function(property){var value=this.get(property);return typeof value=="boolean"&&this.set(property,!value),this},get:function(property){return this[property]}},(function(global){var sqrt=Math.sqrt,atan2=Math.atan2,pow=Math.pow,PiBy180=Math.PI/180,PiBy2=Math.PI/2;fabric.util={cos:function(angle){if(angle===0)return 1;angle<0&&(angle=-angle);var angleSlice=angle/PiBy2;switch(angleSlice){case 1:case 3:return 0;case 2:return-1}return Math.cos(angle)},sin:function(angle){if(angle===0)return 0;var angleSlice=angle/PiBy2,sign=1;switch(angle<0&&(sign=-1),angleSlice){case 1:return sign;case 2:return 0;case 3:return-sign}return Math.sin(angle)},removeFromArray:function(array,value){var idx=array.indexOf(value);return idx!==-1&&array.splice(idx,1),array},getRandomInt:function(min,max){return Math.floor(Math.random()*(max-min+1))+min},degreesToRadians:function(degrees){return degrees*PiBy180},radiansToDegrees:function(radians){return radians/PiBy180},rotatePoint:function(point,origin,radians){point.subtractEquals(origin);var v=fabric.util.rotateVector(point,radians);return new fabric.Point(v.x,v.y).addEquals(origin)},rotateVector:function(vector,radians){var sin=fabric.util.sin(radians),cos=fabric.util.cos(radians),rx=vector.x*cos-vector.y*sin,ry=vector.x*sin+vector.y*cos;return{x:rx,y:ry}},transformPoint:function(p,t,ignoreOffset){return ignoreOffset?new fabric.Point(t[0]*p.x+t[2]*p.y,t[1]*p.x+t[3]*p.y):new fabric.Point(t[0]*p.x+t[2]*p.y+t[4],t[1]*p.x+t[3]*p.y+t[5])},makeBoundingBoxFromPoints:function(points,transform){if(transform)for(var i=0;i<points.length;i++)points[i]=fabric.util.transformPoint(points[i],transform);var xPoints=[points[0].x,points[1].x,points[2].x,points[3].x],minX=fabric.util.array.min(xPoints),maxX=fabric.util.array.max(xPoints),width=maxX-minX,yPoints=[points[0].y,points[1].y,points[2].y,points[3].y],minY=fabric.util.array.min(yPoints),maxY=fabric.util.array.max(yPoints),height=maxY-minY;return{left:minX,top:minY,width:width,height:height}},invertTransform:function(t){var a=1/(t[0]*t[3]-t[1]*t[2]),r=[a*t[3],-a*t[1],-a*t[2],a*t[0]],o=fabric.util.transformPoint({x:t[4],y:t[5]},r,!0);return r[4]=-o.x,r[5]=-o.y,r},toFixed:function(number,fractionDigits){return parseFloat(Number(number).toFixed(fractionDigits))},parseUnit:function(value,fontSize){var unit=/\D{0,2}$/.exec(value),number=parseFloat(value);switch(fontSize||(fontSize=fabric.Text.DEFAULT_SVG_FONT_SIZE),unit[0]){case"mm":return number*fabric.DPI/25.4;case"cm":return number*fabric.DPI/2.54;case"in":return number*fabric.DPI;case"pt":return number*fabric.DPI/72;case"pc":return number*fabric.DPI/72*12;case"em":return number*fontSize;default:return number}},falseFunction:function(){return!1},getKlass:function(type,namespace){return type=fabric.util.string.camelize(type.charAt(0).toUpperCase()+type.slice(1)),fabric.util.resolveNamespace(namespace)[type]},getSvgAttributes:function(type){var attributes=["instantiated_by_use","style","id","class"];switch(type){case"linearGradient":attributes=attributes.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":attributes=attributes.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":attributes=attributes.concat(["offset","stop-color","stop-opacity"]);break}return attributes},resolveNamespace:function(namespace){if(!namespace)return fabric;var parts=namespace.split("."),len=parts.length,i,obj=global||fabric.window;for(i=0;i<len;++i)obj=obj[parts[i]];return obj},loadImage:function(url,callback,context,crossOrigin){if(!url){callback&&callback.call(context,url);return}var img=fabric.util.createImage(),onLoadCallback=function(){callback&&callback.call(context,img,!1),img=img.onload=img.onerror=null};img.onload=onLoadCallback,img.onerror=function(){fabric.log("Error loading "+img.src),callback&&callback.call(context,null,!0),img=img.onload=img.onerror=null},url.indexOf("data")!==0&&crossOrigin!==void 0&&crossOrigin!==null&&(img.crossOrigin=crossOrigin),url.substring(0,14)==="data:image/svg"&&(img.onload=null,fabric.util.loadImageInDom(img,onLoadCallback)),img.src=url},loadImageInDom:function(img,onLoadCallback){var div=fabric.document.createElement("div");div.style.width=div.style.height="1px",div.style.left=div.style.top="-100%",div.style.position="absolute",div.appendChild(img),fabric.document.querySelector("body").appendChild(div),img.onload=function(){onLoadCallback(),div.parentNode.removeChild(div),div=null}}
1,enlivenObjects:function(objects,callback,namespace,reviver){objects=objects||[];var enlivenedObjects=[],numLoadedObjects=0,numTotalObjects=objects.length;function onLoaded(){++numLoadedObjects===numTotalObjects&&callback&&callback(enlivenedObjects.filter(function(obj){return obj}))}if(!numTotalObjects){callback&&callback(enlivenedObjects);return}objects.forEach(function(o,index){if(!o||!o.type){onLoaded();return}var klass=fabric.util.getKlass(o.type,namespace);klass.fromObject(o,function(obj,error){error||(enlivenedObjects[index]=obj),reviver&&reviver(o,obj,error),onLoaded()})})},enlivenPatterns:function(patterns,callback){patterns=patterns||[];function onLoaded(){++numLoadedPatterns===numPatterns&&callback&&callback(enlivenedPatterns)}var enlivenedPatterns=[],numLoadedPatterns=0,numPatterns=patterns.length;if(!numPatterns){callback&&callback(enlivenedPatterns);return}patterns.forEach(function(p,index){p&&p.source?new fabric.Pattern(p,function(pattern){enlivenedPatterns[index]=pattern,onLoaded()}):(enlivenedPatterns[index]=p,onLoaded())})},groupSVGElements:function(elements,options,path){var object;return elements&&elements.length===1?elements[0]:(options&&(options.width&&options.height?options.centerPoint={x:options.width/2,y:options.height/2}:(delete options.width,delete options.height)),object=new fabric.Group(elements,options),typeof path!="undefined"&&(object.sourcePath=path),object)},populateWithProperties:function(source,destination,properties){if(properties&&Object.prototype.toString.call(properties)==="[object Array]")for(var i=0,len=properties.length;i<len;i++)properties[i]in source&&(destination[properties[i]]=source[properties[i]])},drawDashedLine:function(ctx,x,y,x2,y2,da){var dx=x2-x,dy=y2-y,len=sqrt(dx*dx+dy*dy),rot=atan2(dy,dx),dc=da.length,di=0,draw=!0;for(ctx.save(),ctx.translate(x,y),ctx.moveTo(0,0),ctx.rotate(rot),x=0;len>x;)x+=da[di++%dc],x>len&&(x=len),ctx[draw?"lineTo":"moveTo"](x,0),draw=!draw;ctx.restore()},createCanvasElement:function(){return fabric.document.createElement("canvas")},copyCanvasElement:function(canvas){var newCanvas=fabric.util.createCanvasElement();return newCanvas.width=canvas.width,newCanvas.height=canvas.height,newCanvas.getContext("2d").drawImage(canvas,0,0),newCanvas},toDataURL:function(canvasEl,format,quality){return canvasEl.toDataURL("image/"+format,quality)},createImage:function(){return fabric.document.createElement("img")},multiplyTransformMatrices:function(a,b,is2x2){return[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1],a[0]*b[2]+a[2]*b[3],a[1]*b[2]+a[3]*b[3],is2x2?0:a[0]*b[4]+a[2]*b[5]+a[4],is2x2?0:a[1]*b[4]+a[3]*b[5]+a[5]]},qrDecompose:function(a){var angle=atan2(a[1],a[0]),denom=pow(a[0],2)+pow(a[1],2),scaleX=sqrt(denom),scaleY=(a[0]*a[3]-a[2]*a[1])/scaleX,skewX=atan2(a[0]*a[2]+a[1]*a[3],denom);return{angle:angle/PiBy180,scaleX:scaleX,scaleY:scaleY,skewX:skewX/PiBy180,skewY:0,translateX:a[4],translateY:a[5]}},calcRotateMatrix:function(options){if(!options.angle)return fabric.iMatrix.concat();var theta=fabric.util.degreesToRadians(options.angle),cos=fabric.util.cos(theta),sin=fabric.util.sin(theta);return[cos,sin,-sin,cos,0,0]},calcDimensionsMatrix:function(options){var scaleX=typeof options.scaleX=="undefined"?1:options.scaleX,scaleY=typeof options.scaleY=="undefined"?1:options.scaleY,scaleMatrix=[options.flipX?-scaleX:scaleX,0,0,options.flipY?-scaleY:scaleY,0,0],multiply=fabric.util.multiplyTransformMatrices,degreesToRadians=fabric.util.degreesToRadians;return options.skewX&&(scaleMatrix=multiply(scaleMatrix,[1,0,Math.tan(degreesToRadians(options.skewX)),1],!0)),options.skewY&&(scaleMatrix=multiply(scaleMatrix,[1,Math.tan(degreesToRadians(options.skewY)),0,1],!0)),scaleMatrix},composeMatrix:function(options){var matrix=[1,0,0,1,options.translateX||0,options.translateY||0],multiply=fabric.util.multiplyTransformMatrices;return options.angle&&(matrix=multiply(matrix,fabric.util.calcRotateMatrix(options))),(options.scaleX!==1||options.scaleY!==1||options.skewX||options.skewY||options.flipX||options.flipY)&&(matrix=multiply(matrix,fabric.util.calcDimensionsMatrix(options))),matrix},resetObjectTransform:function(target){target.scaleX=1,target.scaleY=1,target.skewX=0,target.skewY=0,target.flipX=!1,target.flipY=!1,target.rotate(0)},saveObjectTransform:function(target){return{scaleX:target.scaleX,scaleY:target.scaleY,skewX:target.skewX,skewY:target.skewY,angle:target.angle,left:target.left,flipX:target.flipX,flipY:target.flipY,top:target.top}},isTransparent:function(ctx,x,y,tolerance){tolerance>0&&(x>tolerance?x-=tolerance:x=0,y>tolerance?y-=tolerance:y=0);var _isTransparent=!0,i,temp,imageData=ctx.getImageData(x,y,tolerance*2||1,tolerance*2||1),l=imageData.data.length;for(i=3;i<l&&(temp=imageData.data[i],_isTransparent=temp<=0,_isTransparent!==!1);i+=4);return imageData=null,_isTransparent},parsePreserveAspectRatioAttribute:function(attribute){var meetOrSlice="meet",alignX="Mid",alignY="Mid",aspectRatioAttrs=attribute.split(" "),align;return aspectRatioAttrs&&aspectRatioAttrs.length&&(meetOrSlice=aspectRatioAttrs.pop(),meetOrSlice!=="meet"&&meetOrSlice!=="slice"?(align=meetOrSlice,meetOrSlice="meet"):aspectRatioAttrs.length&&(align=aspectRatioAttrs.pop())),alignX=align!=="none"?align.slice(1,4):"none",alignY=align!=="none"?align.slice(5,8):"none",{meetOrSlice:meetOrSlice,alignX:alignX,alignY:alignY}},clearFabricFontCache:function(fontFamily){fontFamily=(fontFamily||"").toLowerCase(),fontFamily?fabric.charWidthsCache[fontFamily]&&delete fabric.charWidthsCache[fontFamily]:fabric.charWidthsCache={}},limitDimsByArea:function(ar,maximumArea){var roughWidth=Math.sqrt(maximumArea*ar),perfLimitSizeY=Math.floor(maximumArea/roughWidth);return{x:Math.floor(roughWidth),y:perfLimitSizeY}},capValue:function(min,value,max){return Math.max(min,Math.min(value,max))},findScaleToFit:function(source,destination){return Math.min(destination.width/source.width,destination.height/source.height)},findScaleToCover:function(source,destination){return Math.max(destination.width/source.width,destination.height/source.height)},matrixToSVG:function(transform){return"matrix("+transform.map(function(value){return fabric.util.toFixed(value,fabric.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},sizeAfterTransform:function(width,height,options){var dimX=width/2,dimY=height/2,points=[{x:-dimX,y:-dimY},{x:dimX,y:-dimY},{x:-dimX,y:dimY},{x:dimX,y:dimY}],transformMatrix=fabric.util.calcDimensionsMatrix(options),bbox=fabric.util.makeBoundingBoxFromPoints(points,transformMatrix);return{x:bbox.width,y:bbox.height}}}})(typeof exports!="undefined"?exports:this),(function(){var _join=Array.prototype.join,commandLengths={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},repeatedCommands={m:"l",M:"L"};function segmentToBezier(th2,th3,cosTh,sinTh,rx,ry,cx1,cy1,mT,fromX,fromY){var costh2=fabric.util.cos(th2),sinth2=fabric.util.sin(th2),costh3=fabric.util.cos(th3),sinth3=fabric.util.sin(th3),toX=cosTh*rx*costh3-sinTh*ry*sinth3+cx1,toY=sinTh*rx*costh3+cosTh*ry*sinth3+cy1,cp1X=fromX+mT*(-cosTh*rx*sinth2-sinTh*ry*costh2),cp1Y=fromY+mT*(-sinTh*rx*sinth2+cosTh*ry*costh2),cp2X=toX+mT*(cosTh*rx*sinth3+sinTh*ry*costh3),cp2Y=toY+mT*(sinTh*rx*sinth3-cosTh*ry*costh3);
1return["C",cp1X,cp1Y,cp2X,cp2Y,toX,toY]}function arcToSegments(toX,toY,rx,ry,large,sweep,rotateX){var PI=Math.PI,th=rotateX*PI/180,sinTh=fabric.util.sin(th),cosTh=fabric.util.cos(th),fromX=0,fromY=0;rx=Math.abs(rx),ry=Math.abs(ry);var px=-cosTh*toX*.5-sinTh*toY*.5,py=-cosTh*toY*.5+sinTh*toX*.5,rx2=rx*rx,ry2=ry*ry,py2=py*py,px2=px*px,pl=rx2*ry2-rx2*py2-ry2*px2,root=0;if(pl<0){var s=Math.sqrt(1-pl/(rx2*ry2));rx*=s,ry*=s}else root=(large===sweep?-1:1)*Math.sqrt(pl/(rx2*py2+ry2*px2));var cx=root*rx*py/ry,cy=-root*ry*px/rx,cx1=cosTh*cx-sinTh*cy+toX*.5,cy1=sinTh*cx+cosTh*cy+toY*.5,mTheta=calcVectorAngle(1,0,(px-cx)/rx,(py-cy)/ry),dtheta=calcVectorAngle((px-cx)/rx,(py-cy)/ry,(-px-cx)/rx,(-py-cy)/ry);sweep===0&&dtheta>0?dtheta-=2*PI:sweep===1&&dtheta<0&&(dtheta+=2*PI);for(var segments=Math.ceil(Math.abs(dtheta/PI*2)),result=[],mDelta=dtheta/segments,mT=8/3*Math.sin(mDelta/4)*Math.sin(mDelta/4)/Math.sin(mDelta/2),th3=mTheta+mDelta,i=0;i<segments;i++)result[i]=segmentToBezier(mTheta,th3,cosTh,sinTh,rx,ry,cx1,cy1,mT,fromX,fromY),fromX=result[i][5],fromY=result[i][6],mTheta=th3,th3+=mDelta;return result}function calcVectorAngle(ux,uy,vx,vy){var ta=Math.atan2(uy,ux),tb=Math.atan2(vy,vx);return tb>=ta?tb-ta:2*Math.PI-(ta-tb)}function getBoundsOfCurve(x0,y0,x1,y1,x2,y2,x3,y3){var argsString;if(fabric.cachesBoundsOfCurve&&(argsString=_join.call(arguments),fabric.boundsOfCurveCache[argsString]))return fabric.boundsOfCurveCache[argsString];var sqrt=Math.sqrt,min=Math.min,max=Math.max,abs=Math.abs,tvalues=[],bounds=[[],[]],a,b,c,t,t1,t2,b2ac,sqrtb2ac;b=6*x0-12*x1+6*x2,a=-3*x0+9*x1-9*x2+3*x3,c=3*x1-3*x0;for(var i=0;i<2;++i){if(i>0&&(b=6*y0-12*y1+6*y2,a=-3*y0+9*y1-9*y2+3*y3,c=3*y1-3*y0),abs(a)<1e-12){if(abs(b)<1e-12)continue;t=-c/b,0<t&&t<1&&tvalues.push(t);continue}b2ac=b*b-4*c*a,!(b2ac<0)&&(sqrtb2ac=sqrt(b2ac),t1=(-b+sqrtb2ac)/(2*a),0<t1&&t1<1&&tvalues.push(t1),t2=(-b-sqrtb2ac)/(2*a),0<t2&&t2<1&&tvalues.push(t2))}for(var x,y,j=tvalues.length,jlen=j,mt;j--;)t=tvalues[j],mt=1-t,x=mt*mt*mt*x0+3*mt*mt*t*x1+3*mt*t*t*x2+t*t*t*x3,bounds[0][j]=x,y=mt*mt*mt*y0+3*mt*mt*t*y1+3*mt*t*t*y2+t*t*t*y3,bounds[1][j]=y;bounds[0][jlen]=x0,bounds[1][jlen]=y0,bounds[0][jlen+1]=x3,bounds[1][jlen+1]=y3;var result=[{x:min.apply(null,bounds[0]),y:min.apply(null,bounds[1])},{x:max.apply(null,bounds[0]),y:max.apply(null,bounds[1])}];return fabric.cachesBoundsOfCurve&&(fabric.boundsOfCurveCache[argsString]=result),result}function fromArcToBeizers(fx,fy,coords){for(var rx=coords[1],ry=coords[2],rot=coords[3],large=coords[4],sweep=coords[5],tx=coords[6],ty=coords[7],segsNorm=arcToSegments(tx-fx,ty-fy,rx,ry,large,sweep,rot),i=0,len=segsNorm.length;i<len;i++)segsNorm[i][1]+=fx,segsNorm[i][2]+=fy,segsNorm[i][3]+=fx,segsNorm[i][4]+=fy,segsNorm[i][5]+=fx,segsNorm[i][6]+=fy;return segsNorm}function makePathSimpler(path){var x=0,y=0,len=path.length,x1=0,y1=0,current,i,converted,destinationPath=[],previous,controlX,controlY;for(i=0;i<len;++i){switch(converted=!1,current=path[i].slice(0),current[0]){case"l":current[0]="L",current[1]+=x,current[2]+=y;case"L":x=current[1],y=current[2];break;case"h":current[1]+=x;case"H":current[0]="L",current[2]=y,x=current[1];break;case"v":current[1]+=y;case"V":current[0]="L",y=current[1],current[1]=x,current[2]=y;break;case"m":current[0]="M",current[1]+=x,current[2]+=y;case"M":x=current[1],y=current[2],x1=current[1],y1=current[2];break;case"c":current[0]="C",current[1]+=x,current[2]+=y,current[3]+=x,current[4]+=y,current[5]+=x,current[6]+=y;case"C":controlX=current[3],controlY=current[4],x=current[5],y=current[6];break;case"s":current[0]="S",current[1]+=x,current[2]+=y,current[3]+=x,current[4]+=y;case"S":previous==="C"?(controlX=2*x-controlX,controlY=2*y-controlY):(controlX=x,controlY=y),x=current[3],y=current[4],current[0]="C",current[5]=current[3],current[6]=current[4],current[3]=current[1],current[4]=current[2],current[1]=controlX,current[2]=controlY,controlX=current[3],controlY=current[4];break;case"q":current[0]="Q",current[1]+=x,current[2]+=y,current[3]+=x,current[4]+=y;case"Q":controlX=current[1],controlY=current[2],x=current[3],y=current[4];break;case"t":current[0]="T",current[1]+=x,current[2]+=y;case"T":previous==="Q"?(controlX=2*x-controlX,controlY=2*y-controlY):(controlX=x,controlY=y),current[0]="Q",x=current[1],y=current[2],current[1]=controlX,current[2]=controlY,current[3]=x,current[4]=y;break;case"a":current[0]="A",current[6]+=x,current[7]+=y;case"A":converted=!0,destinationPath=destinationPath.concat(fromArcToBeizers(x,y,current)),x=current[6],y=current[7];break;case"z":case"Z":x=x1,y=y1;break;default:}converted||destinationPath.push(current),previous=current[0]}return destinationPath}function calcLineLength(x1,y1,x2,y2){return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))}function CB1(t){return t*t*t}function CB2(t){return 3*t*t*(1-t)}function CB3(t){return 3*t*(1-t)*(1-t)}function CB4(t){return(1-t)*(1-t)*(1-t)}function getPointOnCubicBezierIterator(p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y){return function(pct){var c1=CB1(pct),c2=CB2(pct),c3=CB3(pct),c4=CB4(pct);return{x:p4x*c1+p3x*c2+p2x*c3+p1x*c4,y:p4y*c1+p3y*c2+p2y*c3+p1y*c4}}}function QB1(t){return t*t}function QB2(t){return 2*t*(1-t)}function QB3(t){return(1-t)*(1-t)}function getPointOnQuadraticBezierIterator(p1x,p1y,p2x,p2y,p3x,p3y){return function(pct){var c1=QB1(pct),c2=QB2(pct),c3=QB3(pct);return{x:p3x*c1+p2x*c2+p1x*c3,y:p3y*c1+p2y*c2+p1y*c3}}}function pathIterator(iterator,x1,y1){var tempP={x:x1,y:y1},p,tmpLen=0,perc;for(perc=.01;perc<=1;perc+=.01)p=iterator(perc),tmpLen+=calcLineLength(tempP.x,tempP.y,p.x,p.y),tempP=p;return tmpLen}function getPathSegmentsInfo(path){for(var totalLength=0,len=path.length,current,x1=0,y1=0,x2=0,y2=0,info=[],iterator,tempInfo,i=0;i<len;i++){switch(current=path[i],tempInfo={x:x1,y:y1,command:current[0]},current[0]){case"M":tempInfo.length=0,x2=x1=current[1],y2=y1=current[2];break;case"L":tempInfo.length=calcLineLength(x1,y1,current[1],current[2]),x1=current[1],y1=current[2];break;case"C":iterator=getPointOnCubicBezierIterator(x1,y1,current[1],current[2],current[3],current[4],current[5],current[6]),tempInfo.length=pathIterator(iterator,x1,y1),x1=current[5],y1=current[6];break;case"Q":iterator=getPointOnQuadraticBezierIterator(x1,y1,current[1],current[2],current[3],current[4]),tempInfo.length=pathIterator(iterator,x1,y1),x1=current[3],y1=current[4];break;case"Z":case"z":tempInfo.destX=x2,tempInfo.destY=y2,tempInfo.length=calcLineLength(x1,y1,x2,y2),x1=x2,y1=y2;break}totalLength+=tempInfo.length,info.push(tempInfo)}return info.push({length:totalLength,x:x1,y:y1}),info}function getPointOnPath(path,perc,infos){infos||(infos=getPathSegmentsInfo(path));for(var distance=infos[infos.length-1]*perc,i=0;distance-infos[i]>0&&i<infos.length;)distance-=infos[i],i++;var segInfo=infos[i],segPercent=distance/segInfo.length,command=segInfo.length,segment=path[i];switch(command){case"Z":case"z":return new fabric.Point(segInfo.x,segInfo.y).lerp(new fabric.Point(segInfo.destX,segInfo.destY),segPercent);case"L":return new fabric.Point(segInfo.x,segInfo.y).lerp(new fabric.Point(segment[1],segment[2]),segPercent);case"C":return getPointOnCubicBezierIterator(segInfo.x,segInfo.y,segment[1],segment[2],segment[3],segment[4],segment[5],segment[6])(segPercent);case"Q":return getPointOnQuadraticBezierIterator(segInfo.x,segInfo.y,segment[1],segment[2],segment[3],segment[4])(segPercent)}}function parsePath(pathString){var result=[],coords=[],currentPath,parsed,re=fabric.rePathCommand,match,coordsStr,path;if(!pathString||!pathString.match)return result;path=pathString.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);for(var i=0,coordsParsed,len=path.length;i<len;i++){for(currentPath=path[i],coordsStr=currentPath.slice(1).trim(),coords.length=0;match=re.exec(coordsStr);)coords.push(match[0]);coordsParsed=[currentPath.charAt(0)];for(var j=0,jlen=coords.length;j<jlen;j++)parsed=parseFloat(coords[j]),isNaN(parsed)||coordsParsed.push(parsed);var command=coordsParsed[0],commandLength=commandLengths[command.toLowerCase()],repeatedCommand=repeatedCommands[command]||command;if(coordsParsed.length-1>commandLength)for(var k=1,klen=coordsParsed.length;k<klen;k+=commandLength)result.push([command].concat(coordsParsed.slice(k,k+commandLength))),command=repeatedCommand;else result.push(coordsParsed)}return result}function getBoundsOfArc(fx,fy,rx,ry,rot,large,sweep,tx,ty){for(var fromX=0,fromY=0,bound,bounds=[],segs=arcToSegments(tx-fx,ty-fy,rx,ry,large,sweep,rot),i=0,len=segs.length;i<len;i++)bound=getBoundsOfCurve(fromX,fromY,segs[i][1],segs[i][2],segs[i][3],segs[i][4],segs[i][5],segs[i][6]),bounds.push({x:bound[0].x+fx,y:bound[0].y+fy}),bounds.push({x:bound[1].x+fx,y:bound[1].y+fy}),fromX=segs[i][5],fromY=segs[i][6];return bounds}function drawArc(ctx,fx,fy,coords){coords=coords.slice(0).unshift("X");var beizers=fromArcToBeizers(fx,fy,coords);
1beizers.forEach(function(beizer){ctx.bezierCurveTo.apply(ctx,beizer.slice(1))})}fabric.util.parsePath=parsePath,fabric.util.makePathSimpler=makePathSimpler,fabric.util.getPathSegmentsInfo=getPathSegmentsInfo,fabric.util.fromArcToBeizers=fromArcToBeizers,fabric.util.getBoundsOfCurve=getBoundsOfCurve,fabric.util.getPointOnPath=getPointOnPath,fabric.util.getBoundsOfArc=getBoundsOfArc,fabric.util.drawArc=drawArc})(),(function(){var slice=Array.prototype.slice;function invoke(array,method){for(var args=slice.call(arguments,2),result=[],i=0,len=array.length;i<len;i++)result[i]=args.length?array[i][method].apply(array[i],args):array[i][method].call(array[i]);return result}function max(array,byProperty){return find(array,byProperty,function(value1,value2){return value1>=value2})}function min(array,byProperty){return find(array,byProperty,function(value1,value2){return value1<value2})}function fill(array,value){for(var k=array.length;k--;)array[k]=value;return array}function find(array,byProperty,condition){if(!(!array||array.length===0)){var i=array.length-1,result=byProperty?array[i][byProperty]:array[i];if(byProperty)for(;i--;)condition(array[i][byProperty],result)&&(result=array[i][byProperty]);else for(;i--;)condition(array[i],result)&&(result=array[i]);return result}}fabric.util.array={fill:fill,invoke:invoke,min:min,max:max}})(),(function(){function extend(destination,source,deep){if(deep)if(!fabric.isLikelyNode&&source instanceof Element)destination=source;else if(source instanceof Array){destination=[];for(var i=0,len=source.length;i<len;i++)destination[i]=extend({},source[i],deep)}else if(source&&typeof source=="object")for(var property in source)property==="canvas"||property==="group"?destination[property]=null:source.hasOwnProperty(property)&&(destination[property]=extend({},source[property],deep));else destination=source;else for(var property in source)destination[property]=source[property];return destination}function clone(object,deep){return extend({},object,deep)}fabric.util.object={extend:extend,clone:clone},fabric.util.object.extend(fabric.util,fabric.Observable)})(),(function(){function camelize(string){return string.replace(/-+(.)?/g,function(match,character){return character?character.toUpperCase():""})}function capitalize(string,firstLetterOnly){return string.charAt(0).toUpperCase()+(firstLetterOnly?string.slice(1):string.slice(1).toLowerCase())}function escapeXml(string){return string.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function graphemeSplit(textstring){var i=0,chr,graphemes=[];for(i=0,chr;i<textstring.length;i++)(chr=getWholeChar(textstring,i))!==!1&&graphemes.push(chr);return graphemes}function getWholeChar(str,i){var code=str.charCodeAt(i);if(isNaN(code))return"";if(code<55296||code>57343)return str.charAt(i);if(55296<=code&&code<=56319){if(str.length<=i+1)throw"High surrogate without following low surrogate";var next=str.charCodeAt(i+1);if(56320>next||next>57343)throw"High surrogate without following low surrogate";return str.charAt(i)+str.charAt(i+1)}if(i===0)throw"Low surrogate without preceding high surrogate";var prev=str.charCodeAt(i-1);if(55296>prev||prev>56319)throw"Low surrogate without preceding high surrogate";return!1}fabric.util.string={camelize:camelize,capitalize:capitalize,escapeXml:escapeXml,graphemeSplit:graphemeSplit}})(),(function(){var slice=Array.prototype.slice,emptyFunction=function(){},IS_DONTENUM_BUGGY=(function(){for(var p in{toString:1})if(p==="toString")return!1;return!0})(),addMethods=function(klass,source,parent){for(var property in source)property in klass.prototype&&typeof klass.prototype[property]=="function"&&(source[property]+"").indexOf("callSuper")>-1?klass.prototype[property]=(function(property2){return function(){var superclass=this.constructor.superclass;this.constructor.superclass=parent;var returnValue=source[property2].apply(this,arguments);if(this.constructor.superclass=superclass,property2!=="initialize")return returnValue}})(property):klass.prototype[property]=source[property],IS_DONTENUM_BUGGY&&(source.toString!==Object.prototype.toString&&(klass.prototype.toString=source.toString),source.valueOf!==Object.prototype.valueOf&&(klass.prototype.valueOf=source.valueOf))};function Subclass(){}function callSuper(methodName){for(var parentMethod=null,_this=this;_this.constructor.superclass;){var superClassMethod=_this.constructor.superclass.prototype[methodName];if(_this[methodName]!==superClassMethod){parentMethod=superClassMethod;break}_this=_this.constructor.superclass.prototype}return parentMethod?arguments.length>
11?parentMethod.apply(this,slice.call(arguments,1)):parentMethod.call(this):console.log("tried to callSuper "+methodName+", method not found in prototype chain",this)}function createClass(){var parent=null,properties=slice.call(arguments,0);typeof properties[0]=="function"&&(parent=properties.shift());function klass(){this.initialize.apply(this,arguments)}klass.superclass=parent,klass.subclasses=[],parent&&(Subclass.prototype=parent.prototype,klass.prototype=new Subclass,parent.subclasses.push(klass));for(var i=0,length=properties.length;i<length;i++)addMethods(klass,properties[i],parent);return klass.prototype.initialize||(klass.prototype.initialize=emptyFunction),klass.prototype.constructor=klass,klass.prototype.callSuper=callSuper,klass}fabric.util.createClass=createClass})(),(function(){var couldUseAttachEvent=!!fabric.document.createElement("div").attachEvent,touchEvents=["touchstart","touchmove","touchend"];fabric.util.addListener=function(element,eventName,handler,options){element&&element.addEventListener(eventName,handler,couldUseAttachEvent?!1:options)},fabric.util.removeListener=function(element,eventName,handler,options){element&&element.removeEventListener(eventName,handler,couldUseAttachEvent?!1:options)};function getTouchInfo(event){var touchProp=event.changedTouches;return touchProp&&touchProp[0]?touchProp[0]:event}fabric.util.getPointer=function(event){var element=event.target,scroll=fabric.util.getScrollLeftTop(element),_evt=getTouchInfo(event);return{x:_evt.clientX+scroll.left,y:_evt.clientY+scroll.top}},fabric.util.isTouchEvent=function(event){return touchEvents.indexOf(event.type)>-1||event.pointerType==="touch"}})(),(function(){function setStyle(element,styles){var elementStyle=element.style;if(!elementStyle)return element;if(typeof styles=="string")return element.style.cssText+=";"+styles,styles.indexOf("opacity")>-1?setOpacity(element,styles.match(/opacity:\s*(\d?\.?\d*)/)[1]):element;for(var property in styles)if(property==="opacity")setOpacity(element,styles[property]);else{var normalizedProperty=property==="float"||property==="cssFloat"?typeof elementStyle.styleFloat=="undefined"?"cssFloat":"styleFloat":property;elementStyle[normalizedProperty]=styles[property]}return element}var parseEl=fabric.document.createElement("div"),supportsOpacity=typeof parseEl.style.opacity=="string",supportsFilters=typeof parseEl.style.filter=="string",reOpacity=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,setOpacity=function(element){return element};supportsOpacity?setOpacity=function(element,value){return element.style.opacity=value,element}:supportsFilters&&(setOpacity=function(element,value){var es=element.style;return element.currentStyle&&!element.currentStyle.hasLayout&&(es.zoom=1),reOpacity.test(es.filter)?(value=value>=.9999?"":"alpha(opacity="+value*100+")",es.filter=es.filter.replace(reOpacity,value)):es.filter+=" alpha(opacity="+value*100+")",element}),fabric.util.setStyle=setStyle})(),(function(){var _slice=Array.prototype.slice;function getById(id){return typeof id=="string"?fabric.document.getElementById(id):id}var sliceCanConvertNodelists,toArray=function(arrayLike){return _slice.call(arrayLike,0)};try{sliceCanConvertNodelists=toArray(fabric.document.childNodes)instanceof Array}catch(err){}sliceCanConvertNodelists||(toArray=function(arrayLike){for(var arr=new Array(arrayLike.length),i=arrayLike.length;i--;)arr[i]=arrayLike[i];return arr});function makeElement(tagName,attributes){var el=fabric.document.createElement(tagName);for(var prop in attributes)prop==="class"?el.className=attributes[prop]:prop==="for"?el.htmlFor=attributes[prop]:el.setAttribute(prop,attributes[prop]);return el}function addClass(element,className){element&&(" "+element.className+" ").indexOf(" "+className+" ")===-1&&(element.className+=(element.className?" ":"")+className)}function wrapElement(element,wrapper,attributes){return typeof wrapper=="string"&&(wrapper=makeElement(wrapper,attributes)),element.parentNode&&element.parentNode.replaceChild(wrapper,element),wrapper.appendChild(element),wrapper}function getScrollLeftTop(element){for(var left=0,top=0,docElement=fabric.document.documentElement,body=fabric.document.body||{scrollLeft:0,scrollTop:0};element&&(element.parentNode||element.host)&&(element=element.parentNode||element.host,element===fabric.document?(left=body.scrollLeft||docElement.scrollLeft||0,top=body.scrollTop||docElement.scrollTop||0):(left+=element.scrollLeft||0,top+=element.scrollTop||0),!(element.nodeType===1&&element.style.position==="fixed")););return{left:left,top:top}}function getElementOffset(element){var docElem,doc=element&&element.ownerDocument,box={left:0,top:0},offset={left:0,top:0},scrollLeftTop,offsetAttributes={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!doc)return offset;for(var attr in offsetAttributes)offset[offsetAttributes[attr]]+=parseInt(getElementStyle(element,attr),10)||0;return docElem=doc.documentElement,typeof element.getBoundingClientRect!="undefined"&&(box=element.getBoundingClientRect()),scrollLeftTop=getScrollLeftTop(element),{left:box.left+scrollLeftTop.left-(docElem.clientLeft||0)+offset.left,top:box.top+scrollLeftTop.top-(docElem.clientTop||0)+offset.top}}var getElementStyle;fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?getElementStyle=function(element,attr){var style=fabric.document.defaultView.getComputedStyle(element,null);return style?style[attr]:void 0}:getElementStyle=function(element,attr){var value=element.style[attr];return!value&&element.currentStyle&&(value=element.currentStyle[attr]),value},(function(){var style=fabric.document.documentElement.style,selectProp="userSelect"in style?"userSelect":"MozUserSelect"in style?"MozUserSelect":"WebkitUserSelect"in style?"WebkitUserSelect":"KhtmlUserSelect"in style?"KhtmlUserSelect":"";function makeElementUnselectable(element){return typeof element.onselectstart!="undefined"&&(element.onselectstart=fabric.util.falseFunction),selectProp?element.style[selectProp]="none":typeof element.unselectable=="string"&&(element.unselectable="on"),element}function makeElementSelectable(element){return typeof element.onselectstart!="undefined"&&(element.onselectstart=null),selectProp?element.style[selectProp]="":typeof element.unselectable=="string"&&(element.unselectable=""),element}fabric.util.makeElementUnselectable=makeElementUnselectable,fabric.util.makeElementSelectable=makeElementSelectable})();function getNodeCanvas(element){var impl=fabric.jsdomImplForWrapper(element);return impl._canvas||impl._image}function cleanUpJsdomNode(element){if(fabric.isLikelyNode){var impl=fabric.jsdomImplForWrapper(element);impl&&(impl._image=null,impl._canvas=null,impl._currentSrc=null,impl._attributes=null,impl._classList=null)}}function setImageSmoothing(ctx,value){ctx.imageSmoothingEnabled=ctx.imageSmoothingEnabled||ctx.webkitImageSmoothingEnabled||ctx.mozImageSmoothingEnabled||ctx.msImageSmoothingEnabled||ctx.oImageSmoothingEnabled,ctx.imageSmoothingEnabled=value}fabric.util.setImageSmoothing=setImageSmoothing,fabric.util.getById=getById,fabric.util.toArray=toArray,fabric.util.addClass=addClass,fabric.util.makeElement=makeElement,fabric.util.wrapElement=wrapElement,fabric.util.getScrollLeftTop=getScrollLeftTop,fabric.util.getElementOffset=getElementOffset,fabric.util.getNodeCanvas=getNodeCanvas,fabric.util.cleanUpJsdomNode=cleanUpJsdomNode})(),(function(){function addParamToUrl(url,param){return url+(/\?/.test(url)?"&":"?")+p
1aram}function emptyFn(){}function request(url,options){options||(options={});var method=options.method?options.method.toUpperCase():"GET",onComplete=options.onComplete||function(){},xhr=new fabric.window.XMLHttpRequest,body=options.body||options.parameters;return xhr.onreadystatechange=function(){xhr.readyState===4&&(onComplete(xhr),xhr.onreadystatechange=emptyFn)},method==="GET"&&(body=null,typeof options.parameters=="string"&&(url=addParamToUrl(url,options.parameters))),xhr.open(method,url,!0),(method==="POST"||method==="PUT")&&xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),xhr.send(body),xhr}fabric.util.request=request})(),fabric.log=console.log,fabric.warn=console.warn,(function(){function noop(){return!1}function defaultEasing(t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b}function animate(options){requestAnimFrame(function(timestamp){options||(options={});var start=timestamp||+new Date,duration=options.duration||500,finish=start+duration,time,onChange=options.onChange||noop,abort=options.abort||noop,onComplete=options.onComplete||noop,easing=options.easing||defaultEasing,startValue="startValue"in options?options.startValue:0,endValue="endValue"in options?options.endValue:100,byValue=options.byValue||endValue-startValue;options.onStart&&options.onStart(),(function tick(ticktime){time=ticktime||+new Date;var currentTime=time>finish?duration:time-start,timePerc=currentTime/duration,current=easing(currentTime,startValue,byValue,duration),valuePerc=Math.abs((current-startValue)/byValue);if(abort()){onComplete(endValue,1,1);return}if(time>finish){onChange(endValue,1,1),onComplete(endValue,1,1);return}else onChange(current,valuePerc,timePerc),requestAnimFrame(tick)})(start)})}var _requestAnimFrame=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(callback){return fabric.window.setTimeout(callback,1e3/60)},_cancelAnimFrame=fabric.window.cancelAnimationFrame||fabric.window.clearTimeout;function requestAnimFrame(){return _requestAnimFrame.apply(fabric.window,arguments)}function cancelAnimFrame(){return _cancelAnimFrame.apply(fabric.window,arguments)}fabric.util.animate=animate,fabric.util.requestAnimFrame=requestAnimFrame,fabric.util.cancelAnimFrame=cancelAnimFrame})(),(function(){function calculateColor(begin,end,pos){var color="rgba("+parseInt(begin[0]+pos*(end[0]-begin[0]),10)+","+parseInt(begin[1]+pos*(end[1]-begin[1]),10)+","+parseInt(begin[2]+pos*(end[2]-begin[2]),10);return color+=","+(begin&&end?parseFloat(begin[3]+pos*(end[3]-begin[3])):1),color+=")",color}function animateColor(fromColor,toColor,duration,options){var startColor=new fabric.Color(fromColor).getSource(),endColor=new fabric.Color(toColor).getSource(),originalOnComplete=options.onComplete,originalOnChange=options.onChange;options=options||{},fabric.util.animate(fabric.util.object.extend(options,{duration:duration||500,startValue:startColor,endValue:endColor,byValue:endColor,easing:function(currentTime,startValue,byValue,duration2){var posValue=options.colorEasing?options.colorEasing(currentTime,duration2):1-Math.cos(currentTime/duration2*(Math.PI/2));return calculateColor(startValue,byValue,posValue)},onComplete:function(current,valuePerc,timePerc){if(originalOnComplete)return originalOnComplete(calculateColor(endColor,endColor,0),valuePerc,timePerc)},onChange:function(current,valuePerc,timePerc){if(originalOnChange){if(Array.isArray(current))return originalOnChange(calculateColor(current,current,0),valuePerc,timePerc);originalOnChange(current,valuePerc,timePerc)}}}))}fabric.util.animateColor=animateColor})(),(function(){function normalize(a,c,p,s){return a<Math.abs(c)?(a=c,s=p/4):c===0&&a===0?s=p/(2*Math.PI)*Math.asin(1):s=p/(2*Math.PI)*Math.asin(c/a),{a:a,c:c,p:p,s:s}}function elastic(opts,t,d){return opts.a*Math.pow(2,10*(t-=1))*Math.sin((t*d-opts.s)*(2*Math.PI)/opts.p)}function easeOutCubic(t,b,c,d){return c*((t=t/d-1)*t*t+1)+b}function easeInOutCubic(t,b,c,d){return t/=d/2,t<1?c/2*t*t*t+b:c/2*((t-=2)*t*t+2)+b}function easeInQuart(t,b,c,d){return c*(t/=d)*t*t*t+b}function easeOutQuart(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b}function easeInOutQuart(t,b,c,d){return t/=d/2,t<1?c/2*t*t*t*t+b:-c/2*((t-=2)*t*t*t-2)+b}function easeInQuint(t,b,c,d){return c*(t/=d)*t*t*t*t+b}function easeOutQuint(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b}function easeInOutQuint(t,b,c,d){return t/=d/2,t<1?c/2*t*t*t*t*t+b:c/2*((t-=2)*t*t*t*t+2)+b}function easeInSine(t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b}function easeOutSine(t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b}function easeInOutSine(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b}function easeInExpo(t,b,c,d){return t===0?b:c*Math.pow(2,10*(t/d-1))+b}function easeOutExpo(t,b,c,d){return t===d?b+c:c*(-Math.pow(2,-10*t/d)+1)+b}function easeInOutExpo(t,b,c,d){return t===0?b:t===d?b+c:(t/=d/2,t<1?c/2*Math.pow(2,10*(t-1))+b:c/2*(-Math.pow(2,-10*--t)+2)+b)}function easeInCirc(t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b}function easeOutCirc(t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b}function easeInOutCirc(t,b,c,d){return t/=d/2,t<1?-c/2*(Math.sqrt(1-t*t)-1)+b:c/2*(Math.sqrt(1-(t-=2)*t)+1)+b}function easeInElastic(t,b,c,d){var s=1.70158,p=0,a=c;if(t===0)return b;if(t/=d,t===1)return b+c;p||(p=d*.3);var opts=normalize(a,c,p,s);return-elastic(opts,t,d)+b}function easeOutElastic(t,b,c,d){var s=1.70158,p=0,a=c;if(t===0)return b;if(t/=d,t===1)return b+c;p||(p=d*.3);var opts=normalize(a,c,p,s);return opts.a*Math.pow(2,-10*t)*Math.sin((t*d-opts.s)*(2*Math.PI)/opts.p)+opts.c+b}function easeInOutElastic(t,b,c,d){var s=1.70158,p=0,a=c;if(t===0)return b;if(t/=d/2,t===2)return b+c;p||(p=d*(.3*1.5));var opts=normalize(a,c,p,s);return t<1?-.5*elastic(opts,t,d)+b:opts.a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-opts.s)*(2*Math.PI)/opts.p)*.5+opts.c+b}function easeInBack(t,b,c,d,s){return s===void 0&&(s=1.70158),c*(t/=d)*t*((s+1)*t-s)+b}function easeOutBack(t,b,c,d,s){return s===void 0&&(s=1.70158),c*((t=t/d-1)*t*((s+1)*t+s)+1)+b}function easeInOutBack(t,b,c,d,s){return s===void 0&&(s=1.70158),t/=d/2,t<1?c/2*(t*t*(((s*=1.525)+1)*t-s))+b:c/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+b}function easeInBounce(t,b,c,d){return c-easeOutBounce(d-t,0,c,d)+b}function easeOutBounce(t,b,c,d){return(t/=d)<1/2.75?c*(7.5625*t*t)+b:t<2/2.75?c*(7.5625*(t-=1.5/2.75)*t+.75)+b:t<2.5/2.75?c*(7.5625*(t-=2.25/2.75)*t+.9375)+b:c*(7.5625*(t-=2.625/2.75)*t+.984375)+b}function easeInOutBounce(t,b,c,d){return t<d/2?easeInBounce(t*2,0,c,d)*.5+b:easeOutBounce(t*2-d,0,c,d)*.5+c*.5+b}fabric.util.ease={easeInQuad:function(t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(t,b,c,d){return t/=d/2,t<1?c/2*t*t+b:-c/2*(--t*(t-2)-1)+b},easeInCubic:function(t,b,c,d){return c*(t/=d)*t*t+b},easeOutCubic:easeOutCubic,easeInOutCubic:easeInOutCubic,easeInQuart:easeInQuart,easeOutQuart:easeOutQuart,easeInOutQuart:easeInOutQuart,easeInQuint:easeInQuint,easeOutQuint:easeOutQuint,easeInOutQuint:easeInOutQuint,easeInSine:easeInSine,easeOutSine:easeOutSine,easeInOutSine:easeInOutSine,easeInExpo:easeInExpo,easeOutExpo:easeOutExpo,easeInOutExpo:easeInOutExpo,easeInCirc:easeInCirc,easeOutCirc:easeOutCirc,easeInOutCirc:easeInOutCirc,easeInElastic:easeInElastic,easeOutElastic:easeOutElastic,easeInOutElastic:easeInOutElastic,easeInBack:easeInBack,easeOutBack:easeOutBack,easeInOutBack:easeInOutBack,easeInBounce:easeInBounce,easeOutBounce:easeOutBounce,easeInOutBounce:easeInOutBounce}})(),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,clone=fabric2.util.object.clone,toFixed=fabric2.util.toFixed,parseUnit=fabric2.util.parseUnit,multiplyTransformMatrices=fabric2.util.multiplyTransformMatrices,svgValidTagNames=["path","circle","polygon","polyline","ellipse","rect","line","image","text"],svgViewBoxElements=["symbol","image","marker","pattern","view","svg"],svgInvalidAncestors=["pattern","defs","symbol","metadata","clipPath","mask","desc"],svgValidParents=["symbol","g","a","svg","clipPath","defs"],attributesMap={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","image-rendering":"imageSmoothing"},colorAttributes={stroke:"strokeOpacity",fill:"fillOpacity"},fSize="font-size",cPath="clip-path";fabric2.svgValidTagNamesRegEx=getSvgRegex(svgValidTagNames),fabric2.svgViewBoxElementsRegEx=getSvgRegex(svgViewBoxElements),fabric2.svgInvalidAncestorsRegEx=getSvgRegex(svgInvalidAncestors),fabric2.svgValidParentsRegEx=getSvgRegex(svgValidParents),fabric2.cssRules={},fabric2.gradientDefs={},fabric2.clipPaths={};function normalizeAttr(attr){return attr in attributesMap?attributesMap[attr]:attr}function normalizeValue(attr,value,parentAttributes,fontSize){var isArray=Object.prototype.toString.call(value)==="[object Array]",parsed;if((attr==="fill"||attr==="stroke")&&value==="none")value="";else{if(attr==="strokeUniform")return value==="non-scaling-stroke";if(attr==="strokeDashArray")value==="none"?value=null:value=value.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(attr==="transformMatrix")parentAttributes&&parentAttributes.transformMatrix?value=multiplyTransformMatrices(parentAttributes.transformMatrix,fabric2.parseTransformAttribute(value)):value=fabric2.parseTransformAttribute(value);else if(attr==="visible")value=value!=="none"&&value!=="hidden",parentAttributes&&parentAttributes.visible===!1&&(value=!1);else if(attr==="opacity")value=parseFloat(value),parentAttributes&&typeof parentAttributes.opacity!="undefined"&&(value*=parentAttributes.opacity);
1else if(attr==="textAnchor")value=value==="start"?"left":value==="end"?"right":"center";else if(attr==="charSpacing")parsed=parseUnit(value,fontSize)/fontSize*1e3;else if(attr==="paintFirst"){var fillIndex=value.indexOf("fill"),strokeIndex=value.indexOf("stroke"),value="fill";(fillIndex>-1&&strokeIndex>-1&&strokeIndex<fillIndex||fillIndex===-1&&strokeIndex>-1)&&(value="stroke")}else{if(attr==="href"||attr==="xlink:href"||attr==="font")return value;if(attr==="imageSmoothing")return value==="optimizeQuality";parsed=isArray?value.map(parseUnit):parseUnit(value,fontSize)}}return!isArray&&isNaN(parsed)?value:parsed}function getSvgRegex(arr){return new RegExp("^("+arr.join("|")+")\\b","i")}function _setStrokeFillOpacity(attributes){for(var attr in colorAttributes)if(!(typeof attributes[colorAttributes[attr]]=="undefined"||attributes[attr]==="")){if(typeof attributes[attr]=="undefined"){if(!fabric2.Object.prototype[attr])continue;attributes[attr]=fabric2.Object.prototype[attr]}if(attributes[attr].indexOf("url(")!==0){var color=new fabric2.Color(attributes[attr]);attributes[attr]=color.setAlpha(toFixed(color.getAlpha()*attributes[colorAttributes[attr]],2)).toRgba()}}return attributes}function _getMultipleNodes(doc,nodeNames){var nodeName,nodeArray=[],nodeList,i,len;for(i=0,len=nodeNames.length;i<len;i++)nodeName=nodeNames[i],nodeList=doc.getElementsByTagName(nodeName),nodeArray=nodeArray.concat(Array.prototype.slice.call(nodeList));return nodeArray}fabric2.parseTransformAttribute=(function(){function rotateMatrix(matrix2,args){var cos=fabric2.util.cos(args[0]),sin=fabric2.util.sin(args[0]),x=0,y=0;args.length===3&&(x=args[1],y=args[2]),matrix2[0]=cos,matrix2[1]=sin,matrix2[2]=-sin,matrix2[3]=cos,matrix2[4]=x-(cos*x-sin*y),matrix2[5]=y-(sin*x+cos*y)}function scaleMatrix(matrix2,args){var multiplierX=args[0],multiplierY=args.length===2?args[1]:args[0];matrix2[0]=multiplierX,matrix2[3]=multiplierY}function skewMatrix(matrix2,args,pos){matrix2[pos]=Math.tan(fabric2.util.degreesToRadians(args[0]))}function translateMatrix(matrix2,args){matrix2[4]=args[0],args.length===2&&(matrix2[5]=args[1])}var iMatrix=fabric2.iMatrix,number=fabric2.reNum,commaWsp="(?:\\s+,?\\s*|,\\s*)",skewX="(?:(skewX)\\s*\\(\\s*("+number+")\\s*\\))",skewY="(?:(skewY)\\s*\\(\\s*("+number+")\\s*\\))",rotate="(?:(rotate)\\s*\\(\\s*("+number+")(?:"+commaWsp+"("+number+")"+commaWsp+"("+number+"))?\\s*\\))",scale="(?:(scale)\\s*\\(\\s*("+number+")(?:"+commaWsp+"("+number+"))?\\s*\\))",translate="(?:(translate)\\s*\\(\\s*("+number+")(?:"+commaWsp+"("+number+"))?\\s*\\))",matrix="(?:(matrix)\\s*\\(\\s*("+number+")"+commaWsp+"("+number+")"+commaWsp+"("+number+")"+commaWsp+"("+number+")"+commaWsp+"("+number+")"+commaWsp+"("+number+")\\s*\\))",transform="(?:"+matrix+"|"+translate+"|"+scale+"|"+rotate+"|"+skewX+"|"+skewY+")",transforms="(?:"+transform+"(?:"+commaWsp+"*"+transform+")*)",transformList="^\\s*(?:"+transforms+"?)\\s*$",reTransformList=new RegExp(transformList),reTransform=new RegExp(transform,"g");return function(attributeValue){var matrix2=iMatrix.concat(),matrices=[];if(!attributeValue||attributeValue&&!reTransformList.test(attributeValue))return matrix2;attributeValue.replace(reTransform,function(match){var m=new RegExp(transform).exec(match).filter(function(match2){return!!match2}),operation=m[1],args=m.slice(2).map(parseFloat);switch(operation){case"translate":translateMatrix(matrix2,args);break;case"rotate":args[0]=fabric2.util.degreesToRadians(args[0]),rotateMatrix(matrix2,args);break;case"scale":scaleMatrix(matrix2,args);break;case"skewX":skewMatrix(matrix2,args,2);break;case"skewY":skewMatrix(matrix2,args,1);break;case"matrix":matrix2=args;break}matrices.push(matrix2.concat()),matrix2=iMatrix.concat()});for(var combinedMatrix=matrices[0];matrices.length>1;)matrices.shift(),combinedMatrix=fabric2.util.multiplyTransformMatrices(combinedMatrix,matrices[0]);return combinedMatrix}})();function parseStyleString(style,oStyle){var attr,value;style.replace(/;\s*$/,"").split(";").forEach(function(chunk){var pair=chunk.split(":");attr=pair[0].trim().toLowerCase(),value=pair[1].trim(),oStyle[attr]=value})}function parseStyleObject(style,oStyle){var attr,value;for(var prop in style)typeof style[prop]!="undefined"&&(attr=prop.toLowerCase(),value=style[prop],oStyle[attr]=value)}function getGlobalStylesForElement(element,svgUid){var styles={};for(var rule in fabric2.cssRules[svgUid])if(elementMatchesRule(element,rule.split(" ")))for(var property in fabric2.cssRules[svgUid][rule])styles[property]=fabric2.cssRules[svgUid][rule][property];return styles}function elementMatchesRule(element,selectors){var firstMatching,parentMatching=!0;return firstMatching=selectorMatches(element,selectors.pop()),firstMatching&&selectors.length&&(parentMatching=doesSomeParentMatch(element,selectors)),firstMatching&&parentMatching&&selectors.length===0}function doesSomeParentMatch(element,selectors){for(var selector,parentMatching=!0;element.parentNode&&element.parentNode.nodeType===1&&selectors.length;)parentMatching&&(selector=selectors.pop()),element=element.parentNode,parentMatching=selectorMatches(element,selector);return selectors.length===0}function selectorMatches(element,selector){var nodeName=element.nodeName,classNames=element.getAttribute("class"),id=element.getAttribute("id"),matcher,i;if(matcher=new RegExp("^"+nodeName,"i"),selector=selector.replace(matcher,""),id&&selector.length&&(matcher=new RegExp("#"+id+"(?![a-zA-Z\\-]+)","i"),selector=selector.replace(matcher,"")),classNames&&selector.length)for(classNames=classNames.split(" "),i=classNames.length;i--;)matcher=new RegExp("\\."+classNames[i]+"(?![a-zA-Z\\-]+)","i"),selector=selector.replace(matcher,"");return selector.length===0}function elementById(doc,id){var el;if(doc.getElementById&&(el=doc.getElementById(id)),el)return el;var node,i,len,nodelist=doc.getElementsByTagName("*");for(i=0,len=nodelist.length;i<len;i++)if(node=nodelist[i],id===node.getAttribute("id"))return node}function parseUseDirectives(doc){for(var nodelist=_getMultipleNodes(doc,["use","svg:use"]),i=0;nodelist.length&&i<nodelist.length;){var el=nodelist[i],xlink=(el.getAttribute("xlink:href")||el.getAttribute("href")).substr(1),x=el.getAttribute("x")||0,y=el.getAttribute("y")||0,el2=elementById(doc,xlink).cloneNode(!0),currentTrans=(el2.getAttribute("transform")||"")+" translate("+x+", "+y+")",parentNode,oldLength=nodelist.length,attr,j,attrs,len,namespace=fabric2.svgNS;if(applyViewboxTransform(el2),/^svg$/i.test(el2.nodeName)){var el3=el2.ownerDocument.createElementNS(namespace,"g");for(j=0,attrs=el2.attributes,len=attrs.length;j<len;j++)attr=attrs.item(j),el3.setAttributeNS(namespace,attr.nodeName,attr.nodeValue);for(;el2.firstChild;)el3.appendChild(el2.firstChild);el2=el3}for(j=0,attrs=el.attributes,len=attrs.length;j<len;j++)attr=attrs.item(j),!(attr.nodeName==="x"||attr.nodeName==="y"||attr.nodeName==="xlink:href"||attr.nodeName==="href")&&(attr.nodeName==="transform"?currentTrans=attr.nodeValue+" "+currentTrans:el2.setAttribute(attr.nodeName,attr.nodeValue));el2.setAttribute("transform",currentTrans),el2.setAttribute("instantiated_by_use","1"),el2.removeAttribute("id"),parentNode=el.parentNode,parentNode.replaceChild(el2,el),nodelist.length===oldLength&&i++}}var reViewBoxAttrValue=new RegExp("^\\s*("+fabric2.reNum+"+)\\s*,?\\s*("+fabric2.reNum+"+)\\s*,?\\s*("+fabric2.reNum+"+)\\s*,?\\s*("+fabric2.reNum+"+)\\s*$");function applyViewboxTransform(element){if(fabric2.svgViewBoxElementsRegEx.test(element.nodeName)){var viewBoxAttr=element.getAttribute("viewBox"),scaleX=1,scaleY=1,minX=0,minY=0,viewBoxWidth,viewBoxHeight,matrix,el,widthAttr=element.getAttribute("width"),heightAttr=element.getAttribute("height"),x=element.getAttribute("x")||0,y=element.getAttribute("y")||0,preserveAspectRatio=element.getAttribute("preserveAspectRatio")||"",missingViewBox=!viewBoxAttr||!(viewBoxAttr=viewBoxAttr.match(reViewBoxAttrValue)),missingDimAttr=!widthAttr||!heightAttr||widthAttr==="100%"||heightAttr==="100%",toBeParsed=missingViewBox&&missingDimAttr,parsedDim={},translateMatrix="",widthDiff=0,heightDiff=0;if(parsedDim.width=0,parsedDim.height=0,parsedDim.toBeParsed=toBeParsed,missingViewBox&&(x||y)&&element.parentNode.nodeName!=="#document"&&(translateMatrix=" translate("+parseUnit(x)+" "+parseUnit(y)+") ",matrix=(element.getAttribute("transform")||"")+translateMatrix,element.setAttribute("transform",matrix),element.removeAttribute("x"),element.removeAttribute("y")),toBeParsed)return parsedDim;if(missingViewBox)return parsedDim.width=parseUnit(widthAttr),parsedDim.height=parseUnit(heightAttr),parsedDim;if(minX=-parseFloat(viewBoxAttr[1]),minY=-parseFloat(viewBoxAttr[2]),viewB
1oxWidth=parseFloat(viewBoxAttr[3]),viewBoxHeight=parseFloat(viewBoxAttr[4]),parsedDim.minX=minX,parsedDim.minY=minY,parsedDim.viewBoxWidth=viewBoxWidth,parsedDim.viewBoxHeight=viewBoxHeight,missingDimAttr?(parsedDim.width=viewBoxWidth,parsedDim.height=viewBoxHeight):(parsedDim.width=parseUnit(widthAttr),parsedDim.height=parseUnit(heightAttr),scaleX=parsedDim.width/viewBoxWidth,scaleY=parsedDim.height/viewBoxHeight),preserveAspectRatio=fabric2.util.parsePreserveAspectRatioAttribute(preserveAspectRatio),preserveAspectRatio.alignX!=="none"&&(preserveAspectRatio.meetOrSlice==="meet"&&(scaleY=scaleX=scaleX>scaleY?scaleY:scaleX),preserveAspectRatio.meetOrSlice==="slice"&&(scaleY=scaleX=scaleX>scaleY?scaleX:scaleY),widthDiff=parsedDim.width-viewBoxWidth*scaleX,heightDiff=parsedDim.height-viewBoxHeight*scaleX,preserveAspectRatio.alignX==="Mid"&&(widthDiff/=2),preserveAspectRatio.alignY==="Mid"&&(heightDiff/=2),preserveAspectRatio.alignX==="Min"&&(widthDiff=0),preserveAspectRatio.alignY==="Min"&&(heightDiff=0)),scaleX===1&&scaleY===1&&minX===0&&minY===0&&x===0&&y===0)return parsedDim;if((x||y)&&element.parentNode.nodeName!=="#document"&&(translateMatrix=" translate("+parseUnit(x)+" "+parseUnit(y)+") "),matrix=translateMatrix+" matrix("+scaleX+" 0 0 "+scaleY+" "+(minX*scaleX+widthDiff)+" "+(minY*scaleY+heightDiff)+") ",element.nodeName==="svg"){for(el=element.ownerDocument.createElementNS(fabric2.svgNS,"g");element.firstChild;)el.appendChild(element.firstChild);element.appendChild(el)}else el=element,el.removeAttribute("x"),el.removeAttribute("y"),matrix=el.getAttribute("transform")+matrix;return el.setAttribute("transform",matrix),parsedDim}}function hasAncestorWithNodeName(element,nodeName){for(;element&&(element=element.parentNode);)if(element.nodeName&&nodeName.test(element.nodeName.replace("svg:",""))&&!element.getAttribute("instantiated_by_use"))return!0;return!1}fabric2.parseSVGDocument=function(doc,callback,reviver,parsingOptions){if(doc){parseUseDirectives(doc);var svgUid=fabric2.Object.__uid++,i,len,options=applyViewboxTransform(doc),descendants=fabric2.util.toArray(doc.getElementsByTagName("*"));if(options.crossOrigin=parsingOptions&&parsingOptions.crossOrigin,options.svgUid=svgUid,descendants.length===0&&fabric2.isLikelyNode){descendants=doc.selectNodes('//*[name(.)!="svg"]');var arr=[];for(i=0,len=descendants.length;i<len;i++)arr[i]=descendants[i];descendants=arr}var elements=descendants.filter(function(el){return applyViewboxTransform(el),fabric2.svgValidTagNamesRegEx.test(el.nodeName.replace("svg:",""))&&!hasAncestorWithNodeName(el,fabric2.svgInvalidAncestorsRegEx)});if(!elements||elements&&!elements.length){callback&&callback([],{});return}var clipPaths={};descendants.filter(function(el){return el.nodeName.replace("svg:","")==="clipPath"}
1).forEach(function(el){var id=el.getAttribute("id");clipPaths[id]=fabric2.util.toArray(el.getElementsByTagName("*")).filter(function(el2){return fabric2.svgValidTagNamesRegEx.test(el2.nodeName.replace("svg:",""))})}),fabric2.gradientDefs[svgUid]=fabric2.getGradientDefs(doc),fabric2.cssRules[svgUid]=fabric2.getCSSRules(doc),fabric2.clipPaths[svgUid]=clipPaths,fabric2.parseElements(elements,function(instances,elements2){callback&&(callback(instances,options,elements2,descendants),delete fabric2.gradientDefs[svgUid],delete fabric2.cssRules[svgUid],delete fabric2.clipPaths[svgUid])},clone(options),reviver,parsingOptions)}};function recursivelyParseGradientsXlink(doc,gradient){var gradientsAttrs=["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"],xlinkAttr="xlink:href",xLink=gradient.getAttribute(xlinkAttr).substr(1),referencedGradient=elementById(doc,xLink);if(referencedGradient&&referencedGradient.getAttribute(xlinkAttr)&&recursivelyParseGradientsXlink(doc,referencedGradient),gradientsAttrs.forEach(function(attr){referencedGradient&&!gradient.hasAttribute(attr)&&referencedGradient.hasAttribute(attr)&&gradient.setAttribute(attr,referencedGradient.getAttribute(attr))}),!gradient.children.length)for(var referenceClone=referencedGradient.cloneNode(!0);referenceClone.firstChild;)gradient.appendChild(referenceClone.firstChild);gradient.removeAttribute(xlinkAttr)}var reFontDeclaration=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+fabric2.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+fabric2.reNum+"))?\\s+(.*)");extend(fabric2,{parseFontDeclaration:function(value,oStyle){var match=value.match(reFontDeclaration);if(match){var fontStyle=match[1],fontWeight=match[3],fontSize=match[4],lineHeight=match[5],fontFamily=match[6];fontStyle&&(oStyle.fontStyle=fontStyle),fontWeight&&(oStyle.fontWeight=isNaN(parseFloat(fontWeight))?fontWeight:parseFloat(fontWeight)),fontSize&&(oStyle.fontSize=parseUnit(fontSize)),fontFamily&&(oStyle.fontFamily=fontFamily),lineHeight&&(oStyle.lineHeight=lineHeight==="normal"?1:lineHeight)}},getGradientDefs:function(doc){var tagArray=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"],elList=_getMultipleNodes(doc,tagArray),el,j=0,gradientDefs={};for(j=elList.length;j--;)el=elList[j],el.getAttribute("xlink:href")&&recursivelyParseGradientsXlink(doc,el),gradientDefs[el.getAttribute("id")]=el;return gradientDefs},parseAttributes:function(element,attributes,svgUid){if(element){var value,parentAttributes={},fontSize,parentFontSize;typeof svgUid=="undefined"&&(svgUid=element.getAttribute("svgUid")),element.parentNode&&fabric2.svgValidParentsRegEx.test(element.parentNode.nodeName)&&(parentAttributes=fabric2.parseAttributes(element.parentNode,attributes,svgUid));var ownAttributes=attributes.reduce(function(memo,attr2){return value=element.getAttribute(attr2),value&&(memo[attr2]=value),memo},{}),cssAttrs=extend(getGlobalStylesForElement(element,svgUid),fabric2.parseStyleAttribute(element));ownAttributes=extend(ownAttributes,cssAttrs),cssAttrs[cPath]&&element.setAttribute(cPath,cssAttrs[cPath]),fontSize=parentFontSize=parentAttributes.fontSize||fabric2.Text.DEFAULT_SVG_FONT_SIZE,ownAttributes[fSize]&&(ownAttributes[fSize]=fontSize=parseUnit(ownAttributes[fSize],parentFontSize));var normalizedAttr,normalizedValue,normalizedStyle={};for(var attr in ownAttributes)normalizedAttr=normalizeAttr(attr),normalizedValue=normalizeValue(normalizedAttr,ownAttributes[attr],parentAttributes,fontSize),normalizedStyle[normalizedAttr]=normalizedValue;normalizedStyle&&normalizedStyle.font&&fabric2.parseFontDeclaration(normalizedStyle.font,normalizedStyle);var mergedAttrs=extend(parentAttributes,normalizedStyle);return fabric2.svgValidParentsRegEx.test(element.nodeName)?mergedAttrs:_setStrokeFillOpacity(mergedAttrs)}},parseElements:function(elements,callback,options,reviver,parsingOptions){new fabric2.ElementsParser(elements,callback,options,reviver,parsingOptions).parse()},parseStyleAttribute:function(element){var oStyle={},style=element.getAttribute("style");
1return style&&(typeof style=="string"?parseStyleString(style,oStyle):parseStyleObject(style,oStyle)),oStyle},parsePointsAttribute:function(points){if(!points)return null;points=points.replace(/,/g," ").trim(),points=points.split(/\s+/);var parsedPoints=[],i,len;for(i=0,len=points.length;i<len;i+=2)parsedPoints.push({x:parseFloat(points[i]),y:parseFloat(points[i+1])});return parsedPoints},getCSSRules:function(doc){var styles=doc.getElementsByTagName("style"),i,len,allRules={},rules;for(i=0,len=styles.length;i<len;i++){var styleContents=styles[i].textContent||"";styleContents=styleContents.replace(/\/\*[\s\S]*?\*\//g,""),styleContents.trim()!==""&&(rules=styleContents.match(/[^{]*\{[\s\S]*?\}/g),rules=rules.map(function(rule){return rule.trim()}),rules.forEach(function(rule){var match=rule.match(/([\s\S]*?)\s*\{([^}]*)\}/),ruleObj={},declaration=match[2].trim(),propertyValuePairs=declaration.replace(/;$/,"").split(/\s*;\s*/);for(i=0,len=propertyValuePairs.length;i<len;i++){var pair=propertyValuePairs[i].split(/\s*:\s*/),property=pair[0],value=pair[1];ruleObj[property]=value}rule=match[1],rule.split(",").forEach(function(_rule){_rule=_rule.replace(/^svg/i,"").trim(),_rule!==""&&(allRules[_rule]?fabric2.util.object.extend(allRules[_rule],ruleObj):allRules[_rule]=fabric2.util.object.clone(ruleObj))})}))}return allRules},loadSVGFromURL:function(url,callback,reviver,options){url=url.replace(/^\n\s*/,"").trim(),new fabric2.util.request(url,{method:"get",onComplete:onComplete});function onComplete(r){var xml=r.responseXML;if(!xml||!xml.documentElement)return callback&&callback(null),!1;fabric2.parseSVGDocument(xml.documentElement,function(results,_options,elements,allElements){callback&&callback(results,_options,elements,allElements)},reviver,options)}},loadSVGFromString:function(string,callback,reviver,options){var parser=new fabric2.window.DOMParser,doc=parser.parseFromString(string.trim(),"text/xml");fabric2.parseSVGDocument(doc.documentElement,function(results,_options,elements,allElements){callback(results,_options,elements,allElements)},reviver,options)}})})(typeof exports!="undefined"?exports:this),fabric.ElementsParser=function(elements,callback,options,reviver,parsingOptions,doc){this.elements=elements,this.callback=callback,this.options=options,this.reviver=reviver,this.svgUid=options&&options.svgUid||0,this.parsingOptions=parsingOptions,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=doc},(function(proto){proto.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},proto.createObjects=function(){var _this=this;this.elements.forEach(function(element,i){element.setAttribute("svgUid",_this.svgUid),_this.createObject(element,i)})},proto.findTag=function(el){return fabric[fabric.util.string.capitalize(el.tagName.replace("svg:",""))]},proto.createObject=function(el,index){var klass=this.findTag(el);if(klass&&klass.fromElement)try{klass.fromElement(el,this.createCallback(index,el),this.options)}catch(err){fabric.log(err)}else this.checkIfDone()},proto.createCallback=function(index,el){var _this=this;return function(obj){var _options;_this.resolveGradient(obj,el,"fill"),_this.resolveGradient(obj,el,"stroke"),obj instanceof fabric.Image&&obj._originalElement&&(_options=obj.parsePreserveAspectRatioAttribute(el)),obj._removeTransformMatrix(_options),_this.resolveClipPath(obj,el),_this.reviver&&_this.reviver(el,obj),_this.instances[index]=obj,_this.checkIfDone()}},proto.extractPropertyDefinition=function(obj,property,storage){var value=obj[property],regex=this.regexUrl;if(regex.test(value)){regex.lastIndex=0;var id=regex.exec(value)[1];return regex.lastIndex=0,fabric[storage][this.svgUid][id]}},proto.resolveGradient=function(obj,el,property){var gradientDef=this.extractPropertyDefinition(obj,property,"gradientDefs");if(gradientDef){var opacityAttr=el.getAttribute(property+"-opacity"),gradient=fabric.Gradient.fromElement(gradientDef,obj,opacityAttr,this.options);obj.set(property,gradient)}},proto.createClipPathCallback=function(obj,container){return function(_newObj){_newObj._removeTransformMatrix(),_newObj.fillRule=_newObj.clipRule,container.push(_newObj)}},proto.resolveClipPath=function(obj,usingElement){var clipPath=this.extractPropertyDefinition(obj,"clipPath","clipPaths"),element,klass,objTransformInv,container,gTransform,options;if(clipPath){container=[],objTransformInv=fabric.util.invertTransform(obj.calcTransformMatrix());for(var clipPathTag=clipPath[0].parentNode,clipPathOwner=usingElement;clipPathOwner.parentNode&&clipPathOwner.getAttribute("clip-path")!==obj.clipPath;)clipPathOwner=clipPathOwner.parentNode;clipPathOwner.parentNode.appendChild(clipPathTag);for(var i=0;i<clipPath.length;i++)element=clipPath[i],klass=this.findTag(element),klass.fromElement(element,this.createClipPathCallback(obj,container),this.options);container.length===1?clipPath=container[0]:clipPath=new fabric.Group(container),gTransform=fabric.util.multiplyTransformMatrices(objTransformInv,clipPath.calcTransformMatrix()),clipPath.clipPath&&this.resolveClipPath(clipPath,clipPathOwner);var options=fabric.util.qrDecompose(gTransform);clipPath.flipX=!1,clipPath.flipY=!1,clipPath.set("scaleX",options.scaleX),clipPath.set("scaleY",options.scaleY),clipPath.angle=options.angle,clipPath.skewX=options.skewX,clipPath.skewY=0,clipPath.setPositionByOrigin({x:options.translateX,y:options.translateY},"center","center"),obj.clipPath=clipPath}else delete obj.clipPath},proto.checkIfDone=function(){--this.numElements===0&&(this.instances=this.instances.filter(function(el){return el!=null}),this.callback(this.instances,this.elements))}})(fabric.ElementsParser.prototype),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});if(fabric2.Point){fabric2.warn("fabric.Point is already defined");return}fabric2.Point=Point;function Point(x,y){this.x=x,this.y=y}Point.prototype={type:"point",constructor:Point,add:function(that){return new Point(this.x+that.x,this.y+that.y)},addEquals:function(that){return this.x+=that.x,this.y+=that.y,this},scalarAdd:function(scalar){return new Point(this.x+scalar,this.y+scalar)},scalarAddEquals:function(scalar){return this.x+=scalar,this.y+=scalar,this},subtract:function(that){return new Point(this.x-that.x,this.y-that.y)},subtractEquals:function(that){return this.x-=that.x,this.y-=that.y,this},scalarSubtract:function(scalar){return new Point(this.x-scalar,this.y-scalar)},scalarSubtractEquals:function(scalar){return this.x-=scalar,this.y-=scalar,this},multiply:function(scalar){return new Point(this.x*scalar,this.y*scalar)},multiplyEquals:function(scalar){return this.x*=scalar,this.y*=scalar,this},divide:function(scalar){return new Point(this.x/scalar,this.y/scalar)},divideEquals:function(scalar){return this.x/=scalar,this.y/=scalar,this},eq:function(that){return this.x===that.x&&this.y===that.y},lt:function(that){return this.x<that.x&&this.y<that.y},lte:function(that){return this.x<=that.x&&this.y<=that.y},gt:function(that){return this.x>that.x&&this.y>that.y},gte:function(that){return this.x>=that.x&&this.y>=that.y},lerp:function(that,t){return typeof t=="undefined"&&(t=.5),t=Math.max(Math.min(1,t),0),new Point(this.x+(that.x-this.x)*t,this.y+(that.y-this.y)*t)},distanceFrom:function(that){var dx=this.x-that.x,dy=this.y-that.y;return Math.sqrt(dx*dx+dy*dy)},midPointFrom:function(that){return this.lerp(that)},min:function(that){return new Point(Math.min(this.x,that.x),Math.min(this.y,that.y))},max:function(that){return new Point(Math.max(this.x,that.x),Math.max(this.y,that.y))},toString:function(){return this.x+","+this.y},setXY:function(x,y){return this.x=x,this.y=y,this},setX:function(x){return this.x=x,this},setY:function(y){return this.y=y,this},setFromPoint:function(that){return this.x=that.x,this.y=that.y,this},swap:function(that){var x=this.x,y=this.y;this.x=that.x,this.y=that.y,that.x=x,that.y=y},clone:function(){return new Point(this.x,this.y)}}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});if(fabric2.Intersection){fabric2.warn("fabric.Intersection is already defined");return}function Intersection(status){this.status=status,this.points=[]}fabric2.Intersection=Intersection,fabric2.Intersection.prototype={constructor:Intersection,appendPoint:function(point){return this.points.push(point),this},appendPoints:function(points){return this.points=this.points.concat(points),this}},fabric2.Intersection.intersectLineLine=function(a1,a2,b1,b2){var result,uaT=(b2.x-b1.x)*(a1.y-b1.y)-(b2.y-b1.y)*(a1.x-b1.x),ubT=(a2.x-a1.x)*(a1.y-b1.y)-(a2.y-a1.y)*(a1.x-b1.x),uB=(b2.y-b1.y)*(a2.x-a1.x)-(b2.x-b1.x)*(a2.y-a1.y);if(uB!==0){var ua=uaT/uB,ub=ubT/uB;0<=ua&&ua<=1&&0<=ub&&ub<=1?(result=new Intersection("Intersection"),result.appendPoint(new fabric2.Point(a1.x+ua*(a2.x-a1.x),a1.y+ua*(a2.y-a1.y)))):result=new Intersection}else uaT===0||ubT===0?result=new Intersection("Coincident"):result=new Intersection("Parallel");return result},fabric2.Intersection.intersectLinePolygon=function(a1,a2,points){var result=new Intersection,length=points.length,b1,b2,inter,i;for(i=0;i<length;i++)b1=points[i],b2=points[(i+1)%length],inter=Intersection.intersectLineLine(a1,a2,b1,b2),result.appendPoints(inter.points);return result.points.length>0&&(result.status="Intersection"),result},fabric2.Intersection.intersectPolygonPolygon=function(points1,points2){var result=new Intersection,length=points1.length,i;for(i=0;i<length;i++){var a1=points1[i],a2=points1[(i+1)%length],inter=Intersection.intersectLinePolygon(a1,a2,points2);result.appendPoints(inter.points)}return result.points.length>0&&(result.status="Intersection"),result},fabric2.Intersection.intersectPolygonRectangle=function(points,r1,r2){var min=r1.min(r2),max=r1.max(r2),topRight=new fabric2.Point(max.x,min.y),bottomLeft=new fabric2.Point(min.x,max.y),inter1=Intersection.intersectLinePolygon(min,topRight,points),inter2=Intersection.intersectLinePolygon(topRight,max,points),inter3=Intersection.intersectLinePolygon(max,bottomLeft,points),inter4=Intersection.intersectLinePolygon(bottomLeft,min,points),result=new Intersection;return result.appendPoints(inter1.points),result.appendPoints(inter2.points),result.appendPoints(inter3.points),result.appendPoints(inter4.points),result.points.length>0&&(result.status="Intersection"),result}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});if(fabric2.Color){fabric2.warn("fabric.Color is already defined.");return}function Color(color){color?this._tryParsingColor(color):this.setSource([0,0,0,1])}fabric2.Color=Color,fabric2.Color.prototype={_tryParsingColor:function(color){var source;color in Color.colorNameMap&&(color=Color.colorNameMap[color]),color==="transparent"&&(source=[255,255,255,0]),source||(source=Color.sourceFromHex(color)),source||(source=Color.sourceFromRgb(color)),source||(source=Color.sourceFromHsl(color)),source||(source=[0,0,0,1]),source&&this.setSource(source)},_rgbToHsl:function(r,g,b){r/=255,g/=255,b/=255;var h,s,l,max=fabric2.util.array.max([r,g,b]),min=fabric2.util.array.min([r,g,b]);if(l=(max+min)/2,max===min)h=s=0;else{var d=max-min;switch(s=l>.5?d/(2-max-min):d/(max+min),max){case r:h=(g-b)/d+(g<b?6:0);break;case g:h=(b-r)/d+2;break;case b:h=(r-g)/d+4;break}h/=6}return[Math.round(h*360),Math.round(s*100),Math.round(l*100)]},getSource:function(){return this._source},setSource:function(source){this._source=source},toRgb:function(){var source=this.getSource();return"rgb("+source[0]+","+source[1]+","+source[2]+")"},toRgba:function(){var source=this.getSource();return"rgba("+source[0]+","+source[1]+","+source[2]+","+source[3]+")"},toHsl:function(){var source=this.getSource(),hsl=this._rgbToHsl(source[0],source[1],source[2]);return"hsl("+hsl[0]+","+hsl[1]+"%,"+hsl[2]+"%)"}
1,toHsla:function(){var source=this.getSource(),hsl=this._rgbToHsl(source[0],source[1],source[2]);return"hsla("+hsl[0]+","+hsl[1]+"%,"+hsl[2]+"%,"+source[3]+")"},toHex:function(){var source=this.getSource(),r,g,b;return r=source[0].toString(16),r=r.length===1?"0"+r:r,g=source[1].toString(16),g=g.length===1?"0"+g:g,b=source[2].toString(16),b=b.length===1?"0"+b:b,r.toUpperCase()+g.toUpperCase()+b.toUpperCase()},toHexa:function(){var source=this.getSource(),a;return a=Math.round(source[3]*255),a=a.toString(16),a=a.length===1?"0"+a:a,this.toHex()+a.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(alpha){var source=this.getSource();return source[3]=alpha,this.setSource(source),this},toGrayscale:function(){var source=this.getSource(),average=parseInt((source[0]*.3+source[1]*.59+source[2]*.11).toFixed(0),10),currentAlpha=source[3];return this.setSource([average,average,average,currentAlpha]),this},toBlackWhite:function(threshold){var source=this.getSource(),average=(source[0]*.3+source[1]*.59+source[2]*.11).toFixed(0),currentAlpha=source[3];return threshold=threshold||127,average=Number(average)<Number(threshold)?0:255,this.setSource([average,average,average,currentAlpha]),this},overlayWith:function(otherColor){otherColor instanceof Color||(otherColor=new Color(otherColor));var result=[],alpha=this.getAlpha(),otherAlpha=.5,source=this.getSource(),otherSource=otherColor.getSource(),i;for(i=0;i<3;i++)result.push(Math.round(source[i]*(1-otherAlpha)+otherSource[i]*otherAlpha));return result[3]=alpha,this.setSource(result),this}},fabric2.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,fabric2.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,fabric2.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,fabric2.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};function hue2rgb(p,q,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?p+(q-p)*6*t:t<1/2?q:t<2/3?p+(q-p)*(2/3-t)*6:p}fabric2.Color.fromRgb=function(color){return Color.fromSource(Color.sourceFromRgb(color))},fabric2.Color.sourceFromRgb=function(color){var match=color.match(Color.reRGBa);if(match){var r=parseInt(match[1],10)/(/%$/.test(match[1])?100:1)*(/%$/.test(match[1])?255:1),g=parseInt(match[2],10)/(/%$/.test(match[2])?100:1)*(/%$/.test(match[2])?255:1),b=parseInt(match[3],10)/(/%$/.test(match[3])?100:1)*(/%$/.test(match[3])?255:1);return[parseInt(r,10),parseInt(g,10),parseInt(b,10),match[4]?parseFloat(match[4]):1]}},fabric2.Color.fromRgba=Color.fromRgb,fabric2.Color.fromHsl=function(color){return Color.fromSource(Color.sourceFromHsl(color))},fabric2.Color.sourceFromHsl=function(color){var match=color.match(Color.reHSLa);if(match){var h=(parseFloat(match[1])%360+360)%360/360,s=parseFloat(match[2])/(/%$/.test(match[2])?100:1),l=parseFloat(match[3])/(/%$/.test(match[3])?100:1),r,g,b;if(s===0)r=g=b=l;else{var q=l<=.5?l*(s+1):l+s-l*s,p=l*2-q;r=hue2rgb(p,q,h+1/3),g=hue2rgb(p,q,h),b=hue2rgb(p,q,h-1/3)}return[Math.round(r*255),Math.round(g*255),Math.round(b*255),match[4]?parseFloat(match[4]):1]}},fabric2.Color.fromHsla=Color.fromHsl,fabric2.Color.fromHex=function(color){return Color.fromSource(Color.sourceFromHex(color))},fabric2.Color.sourceFromHex=function(color){if(color.match(Color.reHex)){var value=color.slice(color.indexOf("#")+1),isShortNotation=value.length===3||value.length===4,isRGBa=value.length===8||value.length===4,r=isShortNotation?value.charAt(0)+value.charAt(0):value.substring(0,2),g=isShortNotation?value.charAt(1)+value.charAt(1):value.substring(2,4),b=isShortNotation?value.charAt(2)+value.charAt(2):value.substring(4,6),a=isRGBa?isShortNotation?value.charAt(3)+value.charAt(3):value.substring(6,8):"FF";return[parseInt(r,16),parseInt(g,16),parseInt(b,16),parseFloat((parseInt(a,16)/255).toFixed(2))]}},fabric2.Color.fromSource=function(source){var oColor=new Color;return oColor.setSource(source),oColor}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),scaleMap=["e","se","s","sw","w","nw","n","ne","e"],skewMap=["ns","nesw","ew","nwse"],controls={},LEFT="left",TOP="top",RIGHT="right",BOTTOM="bottom",CENTER="center",opposite={top:BOTTOM,bottom:TOP,left:RIGHT,right:LEFT,center:CENTER},radiansToDegrees=fabric2.util.radiansToDegrees,sign=Math.sign||function(x){return(x>0)-(x<0)||+x};function findCornerQuadrant(fabricObject,control){var cornerAngle=fabricObject.angle+radiansToDegrees(Math.atan2(control.y,control.x))+360;return Math.round(cornerAngle%360/45)}function fireEvent(eventName,options){var target=options.transform.target,canvas=target.canvas,canasOptions=Object.assign({},options,{target:target});canvas&&canvas.fire("object:"+eventName,canasOptions),target.fire(eventName,options)}function scaleIsProportional(eventData,fabricObject){var canvas=fabricObject.canvas,uniScaleKey=canvas.uniScaleKey,uniformIsToggled=eventData[uniScaleKey];return canvas.uniformScaling&&!uniformIsToggled||!canvas.uniformScaling&&uniformIsToggled}function isTransformCentered(transform){return transform.originX===CENTER&&transform.originY===CENTER}function scalingIsForbidden(fabricObject,by,scaleProportionally){var lockX=fabricObject.lockScalingX,lockY=fabricObject.lockScalingY;return!!(lockX&&lockY||!by&&(lockX||lockY)&&scaleProportionally||lockX&&by==="x"||lockY&&by==="y")}function scaleCursorStyleHandler(eventData,control,fabricObject){var notAllowed="not-allowed",scaleProportionally=scaleIsProportional(eventData,fabricObject),by="";if(control.x!==0&&control.y===0?by="x":control.x===0&&control.y!==0&&(by="y"),scalingIsForbidden(fabricObject,by,scaleProportionally))return notAllowed;var n=findCornerQuadrant(fabricObject,control);return scaleMap[n]+"-resize"}function skewCursorStyleHandler(eventData,control,fabricObject){var notAllowed="not-allowed";if(control.x!==0&&fabricObject.lockSkewingY||control.y!==0&&fabricObject.lockSkewingX)return notAllowed;var n=findCornerQuadrant(fabricObject,control)%4;return skewMap[n]+"-resize"}function scaleSkewCursorStyleHandler(eventData,control,fabricObject){return eventData[fabricObject.canvas.altActionKey]?controls.skewCursorStyleHandler(eventData,control,fabricObject):controls.scaleCursorStyleHandler(eventData,control,fabricObject)}function scaleOrSkewActionName(eventData,control,fabricObject){var isAlternative=eventData[fabricObject.canvas.altActionKey];if(control.x===0)return isAlternative?"skewX":"scaleY";if(control.y===0)return isAlternative?"skewY":"scaleX"}function rotationStyleHandler(eventData,control,fabricObject){return fabricObject.lockRotation?"not-allowed":control.curs
1orStyle}function commonEventInfo(eventData,transform,x,y){return{e:eventData,transform:transform,pointer:{x:x,y:y}}}function wrapWithFixedAnchor(actionHandler){return function(eventData,transform,x,y){var target=transform.target,centerPoint=target.getCenterPoint(),constraint=target.translateToOriginPoint(centerPoint,transform.originX,transform.originY),actionPerformed=actionHandler(eventData,transform,x,y);return target.setPositionByOrigin(constraint,transform.originX,transform.originY),actionPerformed}}function getLocalPoint(transform,originX,originY,x,y){var target=transform.target,control=target.controls[transform.corner],zoom=target.canvas.getZoom(),padding=target.padding/zoom,localPoint=target.toLocalPoint(new fabric2.Point(x,y),originX,originY);return localPoint.x>=padding&&(localPoint.x-=padding),localPoint.x<=-padding&&(localPoint.x+=padding),localPoint.y>=padding&&(localPoint.y-=padding),localPoint.y<=padding&&(localPoint.y+=padding),localPoint.x-=control.offsetX,localPoint.y-=control.offsetY,localPoint}function targetHasOneFlip(target){return target.flipX&&!target.flipY||!target.flipX&&target.flipY}function compensateScaleForSkew(target,oppositeSkew,scaleToCompoensate,axis,reference){if(target[oppositeSkew]!==0){var newDim=target._getTransformedDimensions()[axis],newValue=reference/newDim*target[scaleToCompoensate];target.set(scaleToCompoensate,newValue)}}function skewObjectX(eventData,transform,x,y){var target=transform.target,dimNoSkew=target._getTransformedDimensions(0,target.skewY),localPoint=getLocalPoint(transform,transform.originX,transform.originY,x,y),totalSkewSize=Math.abs(localPoint.x*2)-dimNoSkew.x,currentSkew=target.skewX,newSkew;totalSkewSize<2?newSkew=0:(newSkew=radiansToDegrees(Math.atan2(totalSkewSize/target.scaleX,dimNoSkew.y/target.scaleY)),transform.originX===LEFT&&transform.originY===BOTTOM&&(newSkew=-newSkew),transform.originX===RIGHT&&transform.originY===TOP&&(newSkew=-newSkew),targetHasOneFlip(target)&&(newSkew=-newSkew));var hasSkewed=currentSkew!==newSkew;if(hasSkewed){var dimBeforeSkewing=target._getTransformedDimensions().y;target.set("skewX",newSkew),compensateScaleForSkew(target,"skewY","scaleY","y",dimBeforeSkewing),fireEvent("skewing",commonEventInfo(eventData,transform,x,y))}return hasSkewed}function skewObjectY(eventData,transform,x,y){var target=transform.target,dimNoSkew=target._getTransformedDimensions(target.skewX,0),localPoint=getLocalPoint(transform,transform.originX,transform.originY,x,y),totalSkewSize=Math.abs(localPoint.y*2)-dimNoSkew.y,currentSkew=target.skewY,newSkew;totalSkewSize<2?newSkew=0:(newSkew=radiansToDegrees(Math.atan2(totalSkewSize/target.scaleY,dimNoSkew.x/target.scaleX)),transform.originX===LEFT&&transform.originY===BOTTOM&&(newSkew=-newSkew),transform.originX===RIGHT&&transform.originY===TOP&&(newSkew=-newSkew),targetHasOneFlip(target)&&(newSkew=-newSkew));var hasSkewed=currentSkew!==newSkew;if(hasSkewed){var dimBeforeSkewing=target._getTransformedDimensions().x;target.set("skewY",newSkew),compensateScaleForSkew(target,"skewX","scaleX","x",dimBeforeSkewing),fireEvent("skewing",commonEventInfo(eventData,transform,x,y))}return hasSkewed}function skewHandlerX(eventData,transform,x,y){var target=transform.target,currentSkew=target.skewX,originX,originY=transform.originY;if(target.lockSkewingX)return!1;if(currentSkew===0){var localPointFromCenter=getLocalPoint(transform,CENTER,CENTER,x,y);localPointFromCenter.x>0?originX=LEFT:originX=RIGHT}else currentSkew>0&&(originX=originY===TOP?LEFT:RIGHT),currentSkew<0&&(originX=originY===TOP?RIGHT:LEFT),targetHasOneFlip(target)&&(originX=originX===LEFT?RIGHT:LEFT);transform.originX=originX;var finalHandler=wrapWithFixedAnchor(skewObjectX);return finalHandler(eventData,transform,x,y)}function skewHandlerY(eventData,transform,x,y){var target=transform.target,currentSkew=target.skewY,originY,originX=transform.originX;if(target.lockSkewingY)return!1;if(currentSkew===0){var localPointFromCenter=getLocalPoint(transform,CENTER,CENTER,x,y);localPointFromCenter.y>0?originY=TOP:originY=BOTTOM}else currentSkew>0&&(originY=originX===LEFT?TOP:BOTTOM),currentSkew<0&&(originY=originX===LEFT?BOTTOM:TOP),targetHasOneFlip(target)&&(originY=originY===TOP?BOTTOM:TOP);transform.originY=originY;
1var finalHandler=wrapWithFixedAnchor(skewObjectY);return finalHandler(eventData,transform,x,y)}function rotationWithSnapping(eventData,transform,x,y){var t=transform,target=t.target,pivotPoint=target.translateToOriginPoint(target.getCenterPoint(),t.originX,t.originY);if(target.lockRotation)return!1;var lastAngle=Math.atan2(t.ey-pivotPoint.y,t.ex-pivotPoint.x),curAngle=Math.atan2(y-pivotPoint.y,x-pivotPoint.x),angle=radiansToDegrees(curAngle-lastAngle+t.theta),hasRotated=!0;if(target.snapAngle>0){var snapAngle=target.snapAngle,snapThreshold=target.snapThreshold||snapAngle,rightAngleLocked=Math.ceil(angle/snapAngle)*snapAngle,leftAngleLocked=Math.floor(angle/snapAngle)*snapAngle;Math.abs(angle-leftAngleLocked)<snapThreshold?angle=leftAngleLocked:Math.abs(angle-rightAngleLocked)<snapThreshold&&(angle=rightAngleLocked)}return angle<0&&(angle=360+angle),angle%=360,hasRotated=target.angle!==angle,target.angle=angle,hasRotated&&fireEvent("rotating",commonEventInfo(eventData,transform,x,y)),hasRotated}function scaleObject(eventData,transform,x,y,options){options=options||{};var target=transform.target,lockScalingX=target.lockScalingX,lockScalingY=target.lockScalingY,by=options.by,newPoint,scaleX,scaleY,dim,scaleProportionally=scaleIsProportional(eventData,target),forbidScaling=scalingIsForbidden(target,by,scaleProportionally),signX,signY,gestureScale=transform.gestureScale;if(forbidScaling)return!1;if(gestureScale)scaleX=transform.scaleX*gestureScale,scaleY=transform.scaleY*gestureScale;else{if(newPoint=getLocalPoint(transform,transform.originX,transform.originY,x,y),signX=by!=="y"?sign(newPoint.x):1,signY=by!=="x"?sign(newPoint.y):1,transform.signX||(transform.signX=signX),transform.signY||(transform.signY=signY),target.lockScalingFlip&&(transform.signX!==signX||transform.signY!==signY))return!1;if(dim=target._getTransformedDimensions(),scaleProportionally&&!by){var distance=Math.abs(newPoint.x)+Math.abs(newPoint.y),original=transform.original,originalDistance=Math.abs(dim.x*original.scaleX/target.scaleX)+Math.abs(dim.y*original.scaleY/target.scaleY),scale=distance/originalDistance,hasScaled;scaleX=original.scaleX*scale,scaleY=original.scaleY*scale}else scaleX=Math.abs(newPoint.x*target.scaleX/dim.x),scaleY=Math.abs(newPoint.y*target.scaleY/dim.y);isTransformCentered(transform)&&(scaleX*=2,scaleY*=2),transform.signX!==signX&&by!=="y"&&(transform.originX=opposite[transform.originX],scaleX*=-1,transform.signX=signX),transform.signY!==signY&&by!=="x"&&(transform.originY=opposite[transform.originY],scaleY*=-1,transform.signY=signY)}var oldScaleX=target.scaleX,oldScaleY=target.scaleY;return by?(by==="x"&&target.set("scaleX",scaleX),by==="y"&&target.set("scaleY",scaleY)):(!lockScalingX&&target.set("scaleX",scaleX),!lockScalingY&&target.set("scaleY",scaleY)),hasScaled=oldScaleX!==target.scaleX||oldScaleY!==target.scaleY,hasScaled&&fireEvent("scaling",commonEventInfo(eventData,transform,x,y)),hasScaled}function scaleObjectFromCorner(eventData,transform,x,y){return scaleObject(eventData,transform,x,y)}function scaleObjectX(eventData,transform,x,y){return scaleObject(eventData,transform,x,y,{by:"x"})}function scaleObjectY(eventData,transform,x,y){return scaleObject(eventData,transform,x,y,{by:"y"})}function scalingYOrSkewingX(eventData,transform,x,y){return eventData[transform.target.canvas.altActionKey]?controls.skewHandlerX(eventData,transform,x,y):controls.scalingY(eventData,transform,x,y)}function scalingXOrSkewingY(eventData,transform,x,y){return eventData[transform.target.canvas.altActionKey]?controls.skewHandlerY(eventData,transform,x,y):controls.scalingX(eventData,transform,x,y)}function changeWidth(eventData,transform,x,y){var target=transform.target,localPoint=getLocalPoint(transform,transform.originX,transform.originY,x,y),strokePadding=target.strokeWidth/(target.strokeUniform?target.scaleX:1),multiplier=isTransformCentered(transform)?2:1,newWidth=Math.abs(localPoint.x*multiplier/target.scaleX)-strokePadding;return target.set("width",Math.max(newWidth,0)),!0}
1controls.scaleCursorStyleHandler=scaleCursorStyleHandler,controls.skewCursorStyleHandler=skewCursorStyleHandler,controls.scaleSkewCursorStyleHandler=scaleSkewCursorStyleHandler,controls.rotationWithSnapping=wrapWithFixedAnchor(rotationWithSnapping),controls.scalingEqually=wrapWithFixedAnchor(scaleObjectFromCorner),controls.scalingX=wrapWithFixedAnchor(scaleObjectX),controls.scalingY=wrapWithFixedAnchor(scaleObjectY),controls.scalingYOrSkewingX=scalingYOrSkewingX,controls.scalingXOrSkewingY=scalingXOrSkewingY,controls.changeWidth=wrapWithFixedAnchor(changeWidth),controls.skewHandlerX=skewHandlerX,controls.skewHandlerY=skewHandlerY,controls.scaleOrSkewActionName=scaleOrSkewActionName,controls.rotationStyleHandler=rotationStyleHandler,controls.fireEvent=fireEvent,controls.wrapWithFixedAnchor=wrapWithFixedAnchor,controls.getLocalPoint=getLocalPoint,fabric2.controlsUtils=controls})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),degreesToRadians=fabric2.util.degreesToRadians,controls=fabric2.controlsUtils;function renderCircleControl(ctx,left,top,styleOverride,fabricObject){styleOverride=styleOverride||{};var size=styleOverride.cornerSize||fabricObject.cornerSize,transparentCorners=typeof styleOverride.transparentCorners!="undefined"?styleOverride.transparentCorners:this.transparentCorners,methodName=transparentCorners?"stroke":"fill",stroke=!transparentCorners&&(styleOverride.cornerStrokeColor||fabricObject.cornerStrokeColor);ctx.save(),ctx.fillStyle=styleOverride.cornerColor||fabricObject.cornerColor,ctx.strokeStyle=styleOverride.cornerStrokeColor||fabricObject.cornerStrokeColor,ctx.lineWidth=1,ctx.beginPath(),ctx.arc(left,top,size/2,0,2*Math.PI,!1),ctx[methodName](),stroke&&ctx.stroke(),ctx.restore()}
1function renderSquareControl(ctx,left,top,styleOverride,fabricObject){styleOverride=styleOverride||{};var size=styleOverride.cornerSize||fabricObject.cornerSize,transparentCorners=typeof styleOverride.transparentCorners!="undefined"?styleOverride.transparentCorners:fabricObject.transparentCorners,methodName=transparentCorners?"stroke":"fill",stroke=!transparentCorners&&(styleOverride.cornerStrokeColor||fabricObject.cornerStrokeColor),sizeBy2=size/2;ctx.save(),ctx.fillStyle=styleOverride.cornerColor||fabricObject.cornerColor,ctx.strokeStyle=styleOverride.strokeCornerColor||fabricObject.strokeCornerColor,ctx.lineWidth=1,ctx.translate(left,top),ctx.rotate(degreesToRadians(fabricObject.angle)),ctx[methodName+"Rect"](-sizeBy2,-sizeBy2,size,size),stroke&&ctx.strokeRect(-sizeBy2,-sizeBy2,size,size),ctx.restore()}controls.renderCircleControl=renderCircleControl,controls.renderSquareControl=renderSquareControl})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});function Control(options){for(var i in options)this[i]=options[i]}fabric2.Control=Control,fabric2.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(eventData,control){return control.cursorStyle},getActionName:function(eventData,control){return control.actionName},getVisibility:function(fabricObject,controlKey){var objectVisibility=fabricObject._controlsVisibility;return objectVisibility&&typeof objectVisibility[controlKey]!="undefined"?objectVisibility[controlKey]:this.visible},setVisibility:function(visibility){this.visible=visibility},positionHandler:function(dim,finalMatrix){var point=fabric2.util.transformPoint({x:this.x*dim.x+this.offsetX,y:this.y*dim.y+this.offsetY},finalMatrix);return point},render:function(ctx,left,top,styleOverride,fabricObject){styleOverride=styleOverride||{},(styleOverride.cornerStyle||fabricObject.cornerStyle)==="circle"?fabric2.controlsUtils.renderCircleControl.call(this,ctx,left,top,styleOverride,fabricObject):fabric2.controlsUtils.renderSquareControl.call(this,ctx,left,top,styleOverride,fabricObject)}}})(typeof exports!="undefined"?exports:this),(function(){function getColorStop(el,multiplier){var style=el.getAttribute("style"),offset=el.getAttribute("offset")||0,color,colorAlpha,opacity,i;if(offset=parseFloat(offset)/(/%$/.test(offset)?100:1),offset=offset<0?0:offset>1?1:offset,style){var keyValuePairs=style.split(/\s*;\s*/);for(keyValuePairs[keyValuePairs.length-1]===""&&keyValuePairs.pop(),i=keyValuePairs.length;i--;){var split=keyValuePairs[i].split(/\s*:\s*/),key=split[0].trim(),value=split[1].trim();key==="stop-color"?color=value:key==="stop-opacity"&&(opacity=value)}}return color||(color=el.getAttribute("stop-color")||"rgb(0,0,0)"),opacity||(opacity=el.getAttribute("stop-opacity")),color=new fabric.Color(color),colorAlpha=color.getAlpha(),opacity=isNaN(parseFloat(opacity))?1:parseFloat(opacity),opacity*=colorAlpha*multiplier,{offset:offset,color:color.toRgb(),opacity:opacity}}function getLinearCoords(el){return{x1:el.getAttribute("x1")||0,y1:el.getAttribute("y1")||0,x2:el.getAttribute("x2")||"100%",y2:el.getAttribute("y2")||0}}function getRadialCoords(el){return{x1:el.getAttribute("fx")||el.getAttribute("cx")||"50%",y1:el.getAttribute("fy")||el.getAttribute("cy")||"50%",r1:0,x2:el.getAttribute("cx")||"50%",y2:el.getAttribute("cy")||"50%",r2:el.getAttribute("r")||"50%"}}var clone=fabric.util.object.clone;fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(options){options||(options={}),options.coords||(options.coords={});var coords,_this=this;Object.keys(options).forEach(function(option){_this[option]=options[option]}),this.id?this.id+="_"+fabric.Object.__uid++:this.id=fabric.Object.__uid++,coords={x1:options.coords.x1||0,y1:options.coords.y1||0,x2:options.coords.x2||0,y2:options.coords.y2||0},this.type==="radial"&&(coords.r1=options.coords.r1||0,coords.r2=options.coords.r2||0),this.coords=coords,this.colorStops=options.colorStops.slice()},addColorStop:function(colorStops){for(var position in colorStops){var color=new fabric.Color(colorStops[position]);this.colorStops.push({offset:parseFloat(position),color:color.toRgb(),opacity:color.getAlpha()})}return this}
1,toObject:function(propertiesToInclude){var object={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return fabric.util.populateWithProperties(this,object,propertiesToInclude),object},toSVG:function(object,options){var coords=clone(this.coords,!0),i,len,options=options||{},markup,commonAttributes,colorStops=clone(this.colorStops,!0),needsSwap=coords.r1>coords.r2,transform=this.gradientTransform?this.gradientTransform.concat():fabric.iMatrix.concat(),offsetX=-this.offsetX,offsetY=-this.offsetY,withViewport=!!options.additionalTransform,gradientUnits=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox";if(colorStops.sort(function(a,b){return a.offset-b.offset}),gradientUnits==="objectBoundingBox"?(offsetX/=object.width,offsetY/=object.height):(offsetX+=object.width/2,offsetY+=object.height/2),object.type==="path"&&(offsetX-=object.pathOffset.x,offsetY-=object.pathOffset.y),transform[4]-=offsetX,transform[5]-=offsetY,commonAttributes='id="SVGID_'+this.id+'" gradientUnits="'+gradientUnits+'"',commonAttributes+=' gradientTransform="'+(withViewport?options.additionalTransform+" ":"")+fabric.util.matrixToSVG(transform)+'" ',this.type==="linear"?markup=["<linearGradient ",commonAttributes,' x1="',coords.x1,'" y1="',coords.y1,'" x2="',coords.x2,'" y2="',coords.y2,'">\n']:this.type==="radial"&&(markup=["<radialGradient ",commonAttributes,' cx="',needsSwap?coords.x1:coords.x2,'" cy="',needsSwap?coords.y1:coords.y2,'" r="',needsSwap?coords.r1:coords.r2,'" fx="',needsSwap?coords.x2:coords.x1,'" fy="',needsSwap?coords.y2:coords.y1,'">\n']),this.type==="radial"){if(needsSwap)for(colorStops=colorStops.concat(),colorStops.reverse(),i=0,len=colorStops.length;i<len;i++)colorStops[i].offset=1-colorStops[i].offset;var minRadius=Math.min(coords.r1,coords.r2);if(minRadius>0){var maxRadius=Math.max(coords.r1,coords.r2),percentageShift=minRadius/maxRadius;for(i=0,len=colorStops.length;i<len;i++)colorStops[i].offset+=percentageShift*(1-colorStops[i].offset)}}for(i=0,len=colorStops.length;i<len;i++){var colorStop=colorStops[i];markup.push("<stop ",'offset="',colorStop.offset*100+"%",'" style="stop-color:',colorStop.color,typeof colorStop.opacity!="undefined"?";stop-opacity: "+colorStop.opacity:";",'"/>\n')}return markup.push(this.type==="linear"?"</linearGradient>\n":"</radialGradient>\n"),markup.join("")},toLive:function(ctx){var gradient,coords=fabric.util.object.clone(this.coords),i,len;if(this.type){for(this.type==="linear"?gradient=ctx.createLinearGradient(coords.x1,coords.y1,coords.x2,coords.y2):this.type==="radial"&&(gradient=ctx.createRadialGradient(coords.x1,coords.y1,coords.r1,coords.x2,coords.y2,coords.r2)),i=0,len=this.colorStops.length;i<len;i++){var color=this.colorStops[i].color,opacity=this.colorStops[i].opacity,offset=this.colorStops[i].offset;typeof opacity!="undefined"&&(color=new fabric.Color(color).setAlpha(opacity).toRgba()),gradient.addColorStop(offset,color)}return gradient}}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(el,instance,opacityAttr,svgOptions){var multiplier=parseFloat(opacityAttr)/(/%$/.test(opacityAttr)?100:1);multiplier=multiplier<0?0:multiplier>1?1:multiplier,isNaN(multiplier)&&(multiplier=1);var colorStopEls=el.getElementsByTagName("stop"),type,gradientUnits=el.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage",gradientTransform=el.getAttribute("gradientTransform")||"",colorStops=[],coords,i,offsetX=0,offsetY=0,transformMatrix;for(el.nodeName==="linearGradient"||el.nodeName==="LINEARGRADIENT"?(type="linear",coords=getLinearCoords(el)):(type="radial",coords=getRadialCoords(el)),i=colorStopEls.length;i--;)colorStops.push(getColorStop(colorStopEls[i],multiplier));transformMatrix=fabric.parseTransformAttribute(gradientTransform),__convertPercentUnitsToValues(instance,coords,svgOptions,gradientUnits),gradientUnits==="pixels"&&(offsetX=-instance.left,offsetY=-instance.top);var gradient=new fabric.Gradient({id:el.getAttribute("id"),type:type,coords:coords,colorStops:colorStops,gradientUnits:gradientUnits,gradientTransform:transformMatrix,offsetX:offsetX,offsetY:offsetY});return gradient}});function __convertPercentUnitsToValues(instance,options,svgOptions,gradientUnits){var propValue,finalValue;
1Object.keys(options).forEach(function(prop){propValue=options[prop],propValue==="Infinity"?finalValue=1:propValue==="-Infinity"?finalValue=0:(finalValue=parseFloat(options[prop],10),typeof propValue=="string"&&/^(\d+\.\d+)%|(\d+)%$/.test(propValue)&&(finalValue*=.01,gradientUnits==="pixels"&&((prop==="x1"||prop==="x2"||prop==="r2")&&(finalValue*=svgOptions.viewBoxWidth||svgOptions.width),(prop==="y1"||prop==="y2")&&(finalValue*=svgOptions.viewBoxHeight||svgOptions.height)))),options[prop]=finalValue})}})(),(function(){"use strict";var toFixed=fabric.util.toFixed;fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(options,callback){if(options||(options={}),this.id=fabric.Object.__uid++,this.setOptions(options),!options.source||options.source&&typeof options.source!="string"){callback&&callback(this);return}else{var _this=this;this.source=fabric.util.createImage(),fabric.util.loadImage(options.source,function(img,isError){_this.source=img,callback&&callback(_this,isError)},null,this.crossOrigin)}},toObject:function(propertiesToInclude){var NUM_FRACTION_DIGITS=fabric.Object.NUM_FRACTION_DIGITS,source,object;return typeof this.source.src=="string"?source=this.source.src:typeof this.source=="object"&&this.source.toDataURL&&(source=this.source.toDataURL()),object={type:"pattern",source:source,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:toFixed(this.offsetX,NUM_FRACTION_DIGITS),offsetY:toFixed(this.offsetY,NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?this.patternTransform.concat():null},fabric.util.populateWithProperties(this,object,propertiesToInclude),object},toSVG:function(object){var patternSource=typeof this.source=="function"?this.source():this.source,patternWidth=patternSource.width/object.width,patternHeight=patternSource.height/object.height,patternOffsetX=this.offsetX/object.width,patternOffsetY=this.offsetY/object.height,patternImgSrc="";return(this.repeat==="repeat-x"||this.repeat==="no-repeat")&&(patternHeight=1,patternOffsetY&&(patternHeight+=Math.abs(patternOffsetY))),(this.repeat==="repeat-y"||this.repeat==="no-repeat")&&(patternWidth=1,patternOffsetX&&(patternWidth+=Math.abs(patternOffsetX))),patternSource.src?patternImgSrc=patternSource.src:patternSource.toDataURL&&(patternImgSrc=patternSource.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+patternOffsetX+'" y="'+patternOffsetY+'" width="'+patternWidth+'" height="'+patternHeight+'">\n<image x="0" y="0" width="'+patternSource.width+'" height="'+patternSource.height+'" xlink:href="'+patternImgSrc+'"></image>\n</pattern>\n'},setOptions:function(options){for(var prop in options)this[prop]=options[prop]},toLive:function(ctx){var source=this.source;return!source||typeof source.src!="undefined"&&(!source.complete||source.naturalWidth===0||source.naturalHeight===0)?"":ctx.createPattern(source,this.repeat)}})})(),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),toFixed=fabric2.util.toFixed;if(fabric2.Shadow){fabric2.warn("fabric.Shadow is already defined.");return}fabric2.Shadow=fabric2.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(options){typeof options=="string"&&(options=this._parseShadow(options));for(var prop in options)this[prop]=options[prop];this.id=fabric2.Object.__uid++},_parseShadow:function(shadow){var shadowStr=shadow.trim(),offsetsAndBlur=fabric2.Shadow.reOffsetsAndBlur.exec(shadowStr)||[],color=shadowStr.replace(fabric2.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:color.trim(),offsetX:parseInt(offsetsAndBlur[1],10)||0,offsetY:parseInt(offsetsAndBlur[2],10)||0,blur:parseInt(offsetsAndBlur[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(object){var fBoxX=40,fBoxY=40,NUM_FRACTION_DIGITS=fabric2.Object.NUM_FRACTION_DIGITS,offset=fabric2.util.rotateVector({x:this.offsetX,y:this.offsetY},fabric2.util.degreesToRadians(-object.angle)),BLUR_BOX=20,color=new fabric2.Color(this.color);return object.width&&object.height&&(fBoxX=toFixed((Math.abs(offset.x)+this.blur)/object.width,NUM_FRACTION_DIGITS)*100+BLUR_BOX,fBoxY=toFixed((Math.abs(offset.y)+this.blur)/object.height,NUM_FRACTION_DIGITS)*100+BLUR_BOX),object.flipX&&(offset.x*=-1),object.flipY&&(offset.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+fBoxY+'%" height="'+(100+2*fBoxY)+'%" x="-'+fBoxX+'%" width="'+(100+2*fBoxX)+'%" >\n	<feGaussianBlur in="SourceAlpha" stdDeviation="'+toFixed(this.blur?this.blur/2:0,NUM_FRACTION_DIGITS)+'"></feGaussianBlur>\n	<feOffset dx="'+toFixed(offset.x,NUM_FRACTION_DIGITS)+'" dy="'+toFixed(offset.y,NUM_FRACTION_DIGITS)+'" result="oBlur" ></feOffset>\n	<feFlood flood-color="'+color.toRgb()+'" flood-opacity="'+color.getAlpha()+'"/>\n	<feComposite in2="oBlur" operator="in" />\n	<feMerge>\n		<feMergeNode></feMergeNode>\n		<feMergeNode in="SourceGraphic"></feMergeNode>\n	</feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var obj={},proto=fabric2.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(prop){this[prop]!==proto[prop]&&(obj[prop]=this[prop])},this),obj}}),fabric2.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/})(typeof exports!="undefined"?exports:this),(function(){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var extend=fabric.util.object.extend,getElementOffset=fabric.util.getElementOffset,removeFromArray=fabric.util.removeFromArray,toFixed=fabric.util.toFixed,transformPoint=fabric.util.transformPoint,invertTransform=fabric.util.invertTransform,getNodeCanvas=fabric.util.getNodeCanvas,createCanvasElement=fabric.util.createCanvasElement,CANVAS_INIT_ERROR=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass(fabric.CommonMethods,{initialize:function(el,options){options||(options={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(el,options)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,
1controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:fabric.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(el,options){var cb=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(el),this._initOptions(options),this.interactive||this._initRetinaScaling(),options.overlayImage&&this.setOverlayImage(options.overlayImage,cb),options.backgroundImage&&this.setBackgroundImage(options.backgroundImage,cb),options.backgroundColor&&this.setBackgroundColor(options.backgroundColor,cb),options.overlayColor&&this.setOverlayColor(options.overlayColor,cb),this.calcOffset()},_isRetinaScaling:function(){return fabric.devicePixelRatio!==1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?fabric.devicePixelRatio:1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var scaleRatio=fabric.devicePixelRatio;this.__initRetinaScaling(scaleRatio,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(scaleRatio,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(scaleRatio,canvas,context){canvas.setAttribute("width",this.width*scaleRatio),canvas.setAttribute("height",this.height*scaleRatio),context.scale(scaleRatio,scaleRatio)},calcOffset:function(){return this._offset=getElementOffset(this.lowerCanvasEl),this},setOverlayImage:function(image,callback,options){return this.__setBgOverlayImage("overlayImage",image,callback,options)},setBackgroundImage:function(image,callback,options){return this.__setBgOverlayImage("backgroundImage",image,callback,options)},setOverlayColor:function(overlayColor,callback){return this.__setBgOverlayColor("overlayColor",overlayColor,callback)},setBackgroundColor:function(backgroundColor,callback){return this.__setBgOverlayColor("backgroundColor",backgroundColor,callback)},__setBgOverlayImage:function(property,image,callback,options){return typeof image=="string"?fabric.util.loadImage(image,function(img,isError){if(img){var instance=new fabric.Image(img,options);this[property]=instance,instance.canvas=this}callback&&callback(img,isError)},this,options&&options.crossOrigin):(options&&image.setOptions(options),this[property]=image,image&&(image.canvas=this),callback&&callback(image,!1)),this},__setBgOverlayColor:function(property,color,callback){return this[property]=color,this._initGradient(color,property),this._initPattern(color,property,callback),this},_createCanvasElement:function(){var element=createCanvasElement();if(!element||(element.style||(element.style={}),typeof element.getContext=="undefined"))throw CANVAS_INIT_ERROR;return element},_initOptions:function(options){var lowerCanvasEl=this.lowerCanvasEl;this._setOptions(options),this.width=this.width||parseInt(lowerCanvasEl.width,10)||0,this.height=this.height||parseInt(lowerCanvasEl.height,10)||0,this.lowerCanvasEl.style&&(lowerCanvasEl.width=this.width,lowerCanvasEl.height=this.height,lowerCanvasEl.style.width=this.width+"px",lowerCanvasEl.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(canvasEl){canvasEl&&canvasEl.getContext?this.lowerCanvasEl=canvasEl:this.lowerCanvasEl=fabric.util.getById(canvasEl)||this._createCanvasElement(),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(value,options){return this.setDimensions({width:value},options)},setHeight:function(value,options){return this.setDimensions({height:value},options)},setDimensions:function(dimensions,options){var cssValue;options=options||{};for(var prop in dimensions)cssValue=dimensions[prop],options.cssOnly||(this._setBackstoreDimension(prop,dimensions[prop]),cssValue+="px",this.hasLostContext=!0),options.backstoreOnly||this._setCssDimension(prop,cssValue);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(),this._initRetinaScaling(),this.calcOffset(),options.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(prop,value){return this.lowerCanvasEl[prop]=value,this.up
1perCanvasEl&&(this.upperCanvasEl[prop]=value),this.cacheCanvasEl&&(this.cacheCanvasEl[prop]=value),this[prop]=value,this},_setCssDimension:function(prop,value){return this.lowerCanvasEl.style[prop]=value,this.upperCanvasEl&&(this.upperCanvasEl.style[prop]=value),this.wrapperEl&&(this.wrapperEl.style[prop]=value),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(vpt){var activeObject=this._activeObject,object,i,len;for(this.viewportTransform=vpt,i=0,len=this._objects.length;i<len;i++)object=this._objects[i],object.group||object.setCoords(!0);return activeObject&&activeObject.setCoords(),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(point,value){var before=point,vpt=this.viewportTransform.slice(0);point=transformPoint(point,invertTransform(this.viewportTransform)),vpt[0]=value,vpt[3]=value;var after=transformPoint(point,vpt);return vpt[4]+=before.x-after.x,vpt[5]+=before.y-after.y,this.setViewportTransform(vpt)},setZoom:function(value){return this.zoomToPoint(new fabric.Point(0,0),value),this},absolutePan:function(point){var vpt=this.viewportTransform.slice(0);
vendor: 8,084 bytes, line 1
1return vpt[4]=-point.x,vpt[5]=-point.y,this.setViewportTransform(vpt)},relativePan:function(point){return this.absolutePan(new fabric.Point(-point.x-this.viewportTransform[4],-point.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(obj){this.stateful&&obj.setupState(),obj._set("canvas",this),obj.setCoords(),this.fire("object:added",{target:obj}),obj.fire("added")},_onObjectRemoved:function(obj){this.fire("object:removed",{target:obj}),obj.fire("removed"),delete obj.canvas},clearContext:function(ctx){return ctx.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var canvasToDrawOn=this.contextContainer;return this.renderCanvas(canvasToDrawOn,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=fabric.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var points={},width=this.width,height=this.height,iVpt=invertTransform(this.viewportTransform);return points.tl=transformPoint({x:0,y:0},iVpt),points.br=transformPoint({x:width,y:height},iVpt),points.tr=new fabric.Point(points.br.x,points.tl.y),points.bl=new fabric.Point(points.tl.x,points.br.y),this.vptCoords=points,points},cancelRequestedRender:function(){this.isRendering&&(fabric.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(ctx,objects){var v=this.viewportTransform,path=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(ctx),fabric.util.setImageSmoothing(ctx,this.imageSmoothingEnabled),this.fire("before:render",{ctx:ctx}),this._renderBackground(ctx),ctx.save(),ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),this._renderObjects(ctx,objects),ctx.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(ctx),path&&(path.canvas=this,path.shouldCache(),path._transformDone=!0,path.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(ctx)),this._renderOverlay(ctx),this.controlsAboveOverlay&&this.interactive&&this.drawControls(ctx),this.fire("after:render",{ctx:ctx})},drawClipPathOnCanvas:function(ctx){var v=this.viewportTransform,path=this.clipPath;ctx.save(),ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),ctx.globalCompositeOperation="destination-in",path.transform(ctx),ctx.scale(1/path.zoomX,1/path.zoomY),ctx.drawImage(path._cacheCanvas,-path.cacheTranslationX,-path.cacheTranslationY),ctx.restore()},_renderObjects:function(ctx,objects){var i,len;for(i=0,len=objects.length;i<len;++i)objects[i]&&objects[i].render(ctx)},_renderBackgroundOrOverlay:function(ctx,property){var fill=this[property+"Color"],object=this[property+"Image"],v=this.viewportTransform,needsVpt=this[property+"Vpt"];if(!(!fill&&!object)){if(fill){ctx.save(),ctx.beginPath(),ctx.moveTo(0,0),ctx.lineTo(this.width,0),ctx.lineTo(this.width,this.height),ctx.lineTo(0,this.height),ctx.closePath(),ctx.fillStyle=fill.toLive?fill.toLive(ctx,this):fill,needsVpt&&ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),ctx.transform(1,0,0,1,fill.offsetX||0,fill.offsetY||0);var m=fill.gradientTransform||fill.patternTransform;m&&ctx.transform(m[0],m[1],m[2],m[3],m[4],m[5]),ctx.fill(),ctx.restore()}object&&(ctx.save(),needsVpt&&ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),object.render(ctx),ctx.restore())}},_renderBackground:function(ctx){this._renderBackgroundOrOverlay(ctx,"background")},_renderOverlay:function(ctx){this._renderBackgroundOrOverlay(ctx,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},centerObjectH:function(object){return this._centerObject(object,new fabric.Point(this.getCenter().left,object.getCenterPoint().y))},centerObjectV:function(object){return this._centerObject(object,new fabric.Point(object.getCenterPoint().x,this.getCenter().top))},centerObject:function(object){var center=this.getCenter();return this._centerObject(object,new fabric.Point(center.left,center.top))},viewportCenterObject:function(object){var vpCenter=this.getVpCenter();return this._centerObject(object,vpCenter)},viewportCenterObjectH:function(object){var vpCenter=this.getVpCenter();return this._centerObject(object,new fabric.Point(vpCenter.x,object.getCenterPoint().y)),this},viewportCenterObjectV:function(object){var vpCenter=this.getVpCenter();return this._centerObject(object,new fabric.Point(object.getCenterPoint().x,vpCenter.y))},getVpCenter:function(){var center=this.getCenter(),iVpt=invertTransform(this.viewportTransform);return transformPoint({x:center.left,y:center.top},iVpt)},_centerObject:function(object,center){return object.setPositionByOrigin(center,"center","center"),object.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(propertiesToInclude){return this.toDatalessObject(propertiesToInclude)},toObject:function(propertiesToInclude){return this._toObjectMethod("toObject",propertiesToInclude)},toDatalessObject:function(propertiesToInclude){return this._toObjectMethod("toDatalessObject",propertiesToInclude)},_toObjectMethod:function(methodName,propertiesToInclude){var clipPath=this.clipPath,data={version:fabric.version,objects:this._toObjects(methodName,propertiesToInclude)};return clipPath&&(data.clipPath=this._toObject(this.clipPath,methodName,propertiesToInclude)),extend(data,this.__serializeBgOverlay(methodName,propertiesToInclude)),fabric.util.populateWithProperties(this,data,propertiesToInclude),data},_toObjects:function(methodName,propertiesToInclude){return this._objects.filter(function(object){return!object.excludeFromExport}).map(function(instance){return this._toObject(instance,methodName,propertiesToInclude)},this)},_toObject:function(instance,methodName,propertiesToInclude){var originalValue;this.includeDefaultValues||(originalValue=instance.includeDefaultValues,instance.includeDefaultValues=!1);var object=instance[methodName](propertiesToInclude);return this.includeDefaultValues||(instance.includeDefaultValues=originalValue),object},__serializeBgOverlay:function(methodName,propertiesToInclude){var data={},bgImage=this.backgroundImage,overlay=this.overlayImage;return this.backgroundColor&&(data.background=this.backgroundColor.toObject?this.backgroundColor.toObject(propertiesToInclude):this.backgroundColor),this.overlayColor&&(data.overlay=this.overlayColor.toObject?this.overlayColor.toObject(propertiesToInclude):this.overlayColor),bgImage&&!bgImage.excludeFromExport&&(data.backgroundImage=this._toObject(bgImage,methodName,propertiesToInclude)),overlay&&!overlay.excludeFromExport&&(data.overlayImage=this._toObject(overlay,methodName,propertiesToInclude)),data},svgViewportTransformation:!0,toSVG:function(options,reviver){options||(options={}),options.reviver=reviver;var markup=[];return this._setSVGPreamble(markup,options),this._setSVGHeader(markup,options),this.clipPath&&markup.push('<g clip-path="url(#'+this.clipPath.clipPathId+')" >\n'),this._setSVGBgOverlayColor(markup,"background"),this._setSVGBgOverlayImage(markup,"backgroundImage",reviver),this._setSVGObjects(markup,reviver),this.clipPath&&markup.push("</g>\n"),this._setSVGBgOverlayColor(markup,"overlay"),this._setSVGBgOverlayImage(markup,"overlayImage",reviver),markup.push("</svg>"),markup.join("")},_setSVGPreamble:function(markup,options){options.suppressPreamble||markup.push('<?xml version="1.0" encoding="',options.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(markup,options){var width=options.width||this.width,height=options.height||this.height,vpt,viewBox='viewB
1ox="0 0 '+this.width+" "+this.height+'" ',NUM_FRACTION_DIGITS=fabric.Object.NUM_FRACTION_DIGITS;options.viewBox?viewBox='viewBox="'+options.viewBox.x+" "+options.viewBox.y+" "+options.viewBox.width+" "+options.viewBox.height+'" ':this.svgViewportTransformation&&(vpt=this.viewportTransform,viewBox='viewBox="'+toFixed(-vpt[4]/vpt[0],NUM_FRACTION_DIGITS)+" "+toFixed(-vpt[5]/vpt[3],NUM_FRACTION_DIGITS)+" "+toFixed(this.width/vpt[0],NUM_FRACTION_DIGITS)+" "+toFixed(this.height/vpt[3],NUM_FRACTION_DIGITS)+'" '),markup.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',width,'" ','height="',height,'" ',viewBox,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",fabric.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(options),"</defs>\n")},createSVGClipPathMarkup:function(options){var clipPath=this.clipPath;return clipPath?(clipPath.clipPathId="CLIPPATH_"+fabric.Object.__uid++,'<clipPath id="'+clipPath.clipPathId+'" >\n'+this.clipPath.toClipPathSVG(options.reviver)+"</clipPath>\n"):""},createSVGRefElementsMarkup:function(){var _this=this,markup=["background","overlay"].map(function(prop){var fill=_this[prop+"Color"];if(fill&&fill.toLive){var shouldTransform=_this[prop+"Vpt"],vpt=_this.viewportTransform,object={width:_this.width/(shouldTransform?vpt[0]:1),height:_this.height/(shouldTransform?vpt[3]:1)};return fill.toSVG(object,{additionalTransform:shouldTransform?fabric.util.matrixToSVG(vpt):""})}});return markup.join("")},createSVGFontFacesMarkup:function(){var markup="",fontList={},obj,fontFamily,style,row,rowIndex,_char,charIndex,i,len,fontPaths=fabric.fontPaths,objects=[];for(this._objects.forEach(function add(object){objects.push(object),object._objects&&object._objects.forEach(add)}),i=0,len=objects.length;i<len;i++)if(obj=objects[i],fontFamily=obj.fontFamily,!(obj.type.indexOf("text")===-1||fontList[fontFamily]||!fontPaths[fontFamily])&&(fontList[fontFamily]=!0,!!obj.styles)){style=obj.styles;for(rowIndex in style){row=style[rowIndex];for(charIndex in row)_char=row[charIndex],fontFamily=_char.fontFamily,!fontList[fontFamily]&&fontPaths[fontFamily]&&(fontList[fontFamily]=!0)}}for(var j in fontList)markup+=["		@font-face {\n","			font-family: '",j,"';\n","			src: url('",fontPaths[j],"');\n","		}\n"].join("");return markup&&(markup=['	<style type="text/css">',"<![CDATA[\n",markup,"]]>","</style>\n"].join("")),markup},_setSVGObjects:function(markup,reviver){var instance,i,len,objects=this._objects;for(i=0,len=objects.length;i<len;i++)instance=objects[i],!instance.excludeFromExport&&this._setSVGObject(markup,instance,reviver)},_setSVGObject:function(markup,instance,reviver){markup.push(instance.toSVG(reviver))},_setSVGBgOverlayImage:function(markup,property,reviver){this[property]&&!this[property].excludeFromExport&&this[property].toSVG&&markup.push(this[property].toSVG(reviver))},_setSVGBgOverlayColor:function(markup,property){var filler=this[property+"Color"],vpt=this.viewportTransform,finalWidth=this.width,finalHeight=this.height;if(filler)if(filler.toLive){var repeat=filler.repeat,iVpt=fabric.util.invertTransform(vpt),shouldInvert=this[property+"Vpt"],additionalTransform=shouldInvert?fabric.util.matrixToSVG(iVpt):"";markup.push('<rect transform="'+additionalTransform+" translate(",finalWidth/2,",",finalHeight/2,')"',' x="',filler.offsetX-finalWidth/2,'" y="',filler.offsetY-finalHeight/2,'" ','width="',repeat==="repeat-y"||repeat==="no-repeat"?filler.source.width:finalWidth,'" height="',repeat==="repeat-x"||repeat==="no-repeat"?filler.source.height:finalHeight,'" fill="url(#SVGID_'+filler.id+')"',"></rect>\n")}else markup.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',filler,'"',"></rect>\n")},sendToBack:function(object){if(!object)return this;var activeSelection=this._activeObject,i,obj,objs;if(object===activeSelection&&object.type==="activeSelection")for(objs=activeSelection._objects,i=objs.length;i--;)obj=objs[i],removeFromArray(this._objects,obj),this._objects.unshift(obj);else removeFromArray(this._objects,object),this._objects.unshift(object);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(object){if(!object)return this;var activeSelection=this._activeObject,i,obj,objs;if(object===activeSelection&&object.type==="activeSelection")for(objs=activeSelection._objects,i=0;i<objs.length;i++)obj=objs[i],removeFromArray(this._objects,obj),this._objects.push(obj);else removeFromArray(this._objects,object),this._objects.push(object);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(object,intersecting){if(!object)return this;var activeSelection=this._activeObject,i,obj,idx,newIdx,objs,objsMoved=0;if(object===activeSelection&&object.type==="activeSelection")for(objs=activeSelection._objects,i=0;i<objs.length;i++)obj=objs[i],idx=this._objects.indexOf(obj),idx>0+objsMoved&&(newIdx=idx-1,removeFromArray(this._objects,obj),this._objects.splice(newIdx,0,obj)),objsMoved++;else idx=this._objects.indexOf(object),idx!==0&&(newIdx=this._findNewLowerIndex(object,idx,intersecting),removeFromArray(this._objects,object),this._objects.splice(newIdx,0,object));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(object,idx,intersecting){var newIdx,i;if(intersecting)for(newIdx=idx,i=idx-1;i>=0;--i){var isIntersecting=object.intersectsWithObject(this._objects[i])||object.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(object);if(isIntersecting){newIdx=i;break}}else newIdx=idx-1;return newIdx},bringForward:function(object,intersecting){if(!object)return this;var activeSelection=this._activeObject,i,obj,idx,newIdx,objs,objsMoved=0;if(object===activeSelection&&object.type==="activeSelection")for(objs=activeSelection._objects,i=objs.length;i--;)obj=objs[i],idx=this._objects.indexOf(obj),idx<this._objects.length-1-objsMoved&&(newIdx=idx+1,removeFromArray(this._objects,obj),this._objects.splice(newIdx,0,obj)),objsMoved++;else idx=this._objects.indexOf(object),idx!==this._objects.length-1&&(newIdx=this._findNewUpperIndex(object,idx,intersecting),removeFromArray(this._objects,object),this._objects.splice(newIdx,0,object));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(object,idx,intersecting){var newIdx,i,len;if(intersecting)for(newIdx=idx,i=idx+1,len=this._objects.length;i<len;++i){var isIntersecting=object.intersectsWithObject(this._objects[i])||object.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(object);if(isIntersecting){newIdx=i;break}}else newIdx=idx+1;return newIdx},moveTo:function(object,index){return removeFromArray(this._objects,object),this._objects.splice(index,0,object),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(fabric.util.cancelAnimFrame
1(this.isRendering),this.isRendering=0),this.forEachObject(function(object){object.dispose&&object.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,fabric.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),extend(fabric.StaticCanvas.prototype,fabric.Observable),extend(fabric.StaticCanvas.prototype,fabric.Collection),extend(fabric.StaticCanvas.prototype,fabric.DataURLExporter),extend(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(methodName){var el=createCanvasElement();if(!el||!el.getContext)return null;var ctx=el.getContext("2d");return ctx&&methodName==="setLineDash"?typeof ctx.setLineDash!="undefined":null}}),fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject,fabric.isLikelyNode&&(fabric.StaticCanvas.prototype.createPNGStream=function(){var impl=getNodeCanvas(this.lowerCanvasEl);return impl&&impl.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(opts){var impl=getNodeCanvas(this.lowerCanvasEl);return impl&&impl.createJPEGStream(opts)})})(),fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,_setBrushStyles:function(){var ctx=this.canvas.contextTop;ctx.strokeStyle=this.color,ctx.lineWidth=this.width,ctx.lineCap=this.strokeLineCap,ctx.miterLimit=this.strokeMiterLimit,ctx.lineJoin=this.strokeLineJoin,fabric.StaticCanvas.supports("setLineDash")&&ctx.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(ctx){var v=this.canvas.viewportTransform;ctx.save(),ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5])},_setShadow:function(){if(this.shadow){var canvas=this.canvas,shadow=this.shadow,ctx=canvas.contextTop,zoom=canvas.getZoom();canvas&&canvas._isRetinaScaling()&&(zoom*=fabric.devicePixelRatio),ctx.shadowColor=shadow.color,ctx.shadowBlur=shadow.blur*zoom,ctx.shadowOffsetX=shadow.offsetX*zoom,ctx.shadowOffsetY=shadow.offsetY*zoom}},needsFullRender:function(){var color=new fabric.Color(this.color);return color.getAlpha()<1||!!this.shadow},_resetShadow:function(){var ctx=this.canvas.contextTop;ctx.shadowColor="",ctx.shadowBlur=ctx.shadowOffsetX=ctx.shadowOffsetY=0}}),(function(){fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{decimate:.4,initialize:function(canvas){this.canvas=canvas,this._points=[]},_drawSegment:function(ctx,p1,p2){var midPoint=p1.midPointFrom(p2);return ctx.quadraticCurveTo(p1.x,p1.y,midPoint.x,midPoint.y),midPoint},onMouseDown:function(pointer,options){this.canvas._isMainEvent(options.e)&&(this._prepareForDrawing(pointer),this._captureDrawingPath(pointer),this._render())},onMouseMove:function(pointer,options){if(this.canvas._isMainEvent(options.e)&&this._captureDrawingPath(pointer)&&this._points.length>1)if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var points=this._points,length=points.length,ctx=this.canvas.contextTop;this._saveAndTransform(ctx),this.oldEnd&&(ctx.beginPath(),ctx.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(ctx,points[length-2],points[length-1],!0),ctx.stroke(),ctx.restore()}},onMouseUp:function(options){return this.canvas._isMainEvent(options.e)?(this.oldEnd=void 0,this._finalizeAndAddPath(),!1):!0},_prepareForDrawing:function(pointer){var p=new fabric.Point(pointer.x,pointer.y);this._reset(),this._addPoint(p),this.canvas.contextTop.moveTo(p.x,p.y)},_addPoint:function(point){return this._points.length>1&&point.eq(this._points[this._points.length-1])?!1:(this._points.push(point),!0)},_reset:function(){this._points=[],this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(pointer){var pointerPoint=new fabric.Point(pointer.x,pointer.y);return this._addPoint(pointerPoint)},_render:function(){var ctx=this.canvas.contextTop,i,len,p1=this._points[0],p2=this._points[1];if(this._saveAndTransform(ctx),ctx.beginPath(),this._points.length===2&&p1.x===p2.x&&p1.y===p2.y){var width=this.width/1e3;p1=new fabric.Point(p1.x,p1.y),p2=new fabric.Point(p2.x,p2.y),p1.x-=width,p2.x+=width}for(ctx.moveTo(p1.x,p1.y),i=1,len=this._points.length;i<len;i++)this._drawSegment(ctx,p1,p2),p1=this._points[i],p2=this._points[i+1];
1ctx.lineTo(p1.x,p1.y),ctx.stroke(),ctx.restore()},convertPointsToSVGPath:function(points){var path=[],i,width=this.width/1e3,p1=new fabric.Point(points[0].x,points[0].y),p2=new fabric.Point(points[1].x,points[1].y),len=points.length,multSignX=1,multSignY=0,manyPoints=len>2;for(manyPoints&&(multSignX=points[2].x<p2.x?-1:points[2].x===p2.x?0:1,multSignY=points[2].y<p2.y?-1:points[2].y===p2.y?0:1),path.push("M ",p1.x-multSignX*width," ",p1.y-multSignY*width," "),i=1;i<len;i++){if(!p1.eq(p2)){var midPoint=p1.midPointFrom(p2);path.push("Q ",p1.x," ",p1.y," ",midPoint.x," ",midPoint.y," ")}p1=points[i],i+1<points.length&&(p2=points[i+1])}return manyPoints&&(multSignX=p1.x>points[i-2].x?1:p1.x===points[i-2].x?0:-1,multSignY=p1.y>points[i-2].y?1:p1.y===points[i-2].y?0:-1),path.push("L ",p1.x+multSignX*width," ",p1.y+multSignY*width),path},createPath:function(pathData){var path=new fabric.Path(pathData,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,path.shadow=new fabric.Shadow(this.shadow)),path},decimatePoints:function(points,distance){if(points.length<=2)return points;var zoom=this.canvas.getZoom(),adjustedDistance=Math.pow(distance/zoom,2),i,l=points.length-1,lastPoint=points[0],newPoints=[lastPoint],cDistance;for(i=1;i<l;i++)cDistance=Math.pow(lastPoint.x-points[i].x,2)+Math.pow(lastPoint.y-points[i].y,2),cDistance>=adjustedDistance&&(lastPoint=points[i],newPoints.push(lastPoint));return newPoints.length===1&&newPoints.push(new fabric.Point(newPoints[0].x,newPoints[0].y)),newPoints},_finalizeAndAddPath:function(){var ctx=this.canvas.contextTop;ctx.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var pathData=this.convertPointsToSVGPath(this._points).join("");if(pathData==="M 0 0 Q 0 0 0 0 L 0 0"){this.canvas.requestRenderAll();return}var path=this.createPath(pathData);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:path}),this.canvas.add(path),this.canvas.requestRenderAll(),path.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:path})}})})(),fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(canvas){this.canvas=canvas,this.points=[]},drawDot:function(pointer){var point=this.addPoint(pointer),ctx=this.canvas.contextTop;this._saveAndTransform(ctx),this.dot(ctx,point),ctx.restore()},dot:function(ctx,point){ctx.fillStyle=point.fill,ctx.beginPath(),ctx.arc(point.x,point.y,point.radius,0,Math.PI*2,!1),ctx.closePath(),ctx.fill()},onMouseDown:function(pointer){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(pointer)},_render:function(){var ctx=this.canvas.contextTop,i,len,points=this.points;for(this._saveAndTransform(ctx),i=0,len=points.length;i<len;i++)this.dot(ctx,points[i]);ctx.restore()},onMouseMove:function(pointer){this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(pointer),this._render()):this.drawDot(pointer)},onMouseUp:function(){var originalRenderOnAddRemove=this.canvas.renderOnAddRemove,i,len;this.canvas.renderOnAddRemove=!1;var circles=[];for(i=0,len=this.points.length;i<len;i++){var point=this.points[i],circle=new fabric.Circle({radius:point.radius,left:point.x,top:point.y,originX:"center",originY:"center",fill:point.fill});this.shadow&&(circle.shadow=new fabric.Shadow(this.shadow)),circles.push(circle)}var group=new fabric.Group(circles);group.canvas=this.canvas,this.canvas.fire("before:path:created",{path:group}),this.canvas.add(group),this.canvas.fire("path:created",{path:group}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=originalRenderOnAddRemove,this.canvas.requestRenderAll()},addPoint:function(pointer){var pointerPoint=new fabric.Point(pointer.x,pointer.y),circleRadius=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)
1/2,circleColor=new fabric.Color(this.color).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();return pointerPoint.radius=circleRadius,pointerPoint.fill=circleColor,this.points.push(pointerPoint),pointerPoint}}),fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(canvas){this.canvas=canvas,this.sprayChunks=[]},onMouseDown:function(pointer){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(pointer),this.render(this.sprayChunkPoints)},onMouseMove:function(pointer){this.addSprayChunk(pointer),this.render(this.sprayChunkPoints)},onMouseUp:function(){var originalRenderOnAddRemove=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var rects=[],i=0,ilen=this.sprayChunks.length;i<ilen;i++)for(var sprayChunk=this.sprayChunks[i],j=0,jlen=sprayChunk.length;j<jlen;j++){var rect=new fabric.Rect({width:sprayChunk[j].width,height:sprayChunk[j].width,left:sprayChunk[j].x+1,top:sprayChunk[j].y+1,originX:"center",originY:"center",fill:this.color});rects.push(rect)}this.optimizeOverlapping&&(rects=this._getOptimizedRects(rects));var group=new fabric.Group(rects);this.shadow&&group.set("shadow",new fabric.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:group}),this.canvas.add(group),this.canvas.fire("path:created",{path:group}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=originalRenderOnAddRemove,this.canvas.requestRenderAll()},_getOptimizedRects:function(rects){var uniqueRects={},key,i,len;for(i=0,len=rects.length;i<len;i++)key=rects[i].left+""+rects[i].top,uniqueRects[key]||(uniqueRects[key]=rects[i]);var uniqueRectsArray=[];for(key in uniqueRects)uniqueRectsArray.push(uniqueRects[key]);return uniqueRectsArray},render:function(sprayChunk){var ctx=this.canvas.contextTop,i,len;for(ctx.fillStyle=this.color,this._saveAndTransform(ctx),i=0,len=sprayChunk.length;i<len;i++){var point=sprayChunk[i];typeof point.opacity!="undefined"&&(ctx.globalAlpha=point.opacity),ctx.fillRect(point.x,point.y,point.width,point.width)}ctx.restore()},_render:function(){var ctx=this.canvas.contextTop,i,ilen;for(ctx.fillStyle=this.color,this._saveAndTransform(ctx),i=0,ilen=this.sprayChunks.length;i<ilen;i++)this.render(this.sprayChunks[i]);ctx.restore()},addSprayChunk:function(pointer){this.sprayChunkPoints=[];var x,y,width,radius=this.width/2,i;for(i=0;i<this.density;i++){x=fabric.util.getRandomInt(pointer.x-radius,pointer.x+radius),y=fabric.util.getRandomInt(pointer.y-radius,pointer.y+radius),this.dotWidthVariance?width=fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):width=this.dotWidth;var point=new fabric.Point(x,y);point.width=width,this.randomOpacity&&(point.opacity=fabric.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(point)}this.sprayChunks.push(this.sprayChunkPoints)}}),fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var dotWidth=20,dotDistance=5,patternCanvas=fabric.util.createCanvasElement(),patternCtx=patternCanvas.getContext("2d");return patternCanvas.width=patternCanvas.height=dotWidth+dotDistance,patternCtx.fillStyle=this.color,patternCtx.beginPath(),patternCtx.arc(dotWidth/2,dotWidth/2,dotWidth/2,0,Math.PI*2,!1),patternCtx.closePath(),patternCtx.fill(),patternCanvas},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles"),this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(pathData){var path=this.callSuper("createPath",pathData),topLeft=path._getLeftTopCoords().scalarAdd(path.strokeWidth/2);return path.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-topLeft.x,offsetY:-topLeft.y}),path}}),(function(){var getPointer=fabric.util.getPointer,degreesToRadians=fabric.util.degreesToRadians,abs=Math.abs,supportLineDash=fabric.StaticCanvas.supports("setLineDash"),isTouchEvent=fabric.util.isTouchEvent,STROKE_OFFSET=.5;fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(el,options){options||(options={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(el,options),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",
1interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var activeObjects=this.getActiveObjects(),object,objsToRender,activeGroupObjects;if(activeObjects.length>0&&!this.preserveObjectStacking){objsToRender=[],activeGroupObjects=[];for(var i=0,length=this._objects.length;i<length;i++)object=this._objects[i],activeObjects.indexOf(object)===-1?objsToRender.push(object):activeGroupObjects.push(object);activeObjects.length>1&&(this._activeObject._objects=activeGroupObjects),objsToRender.push.apply(objsToRender,activeGroupObjects)}else objsToRender=this._objects;return objsToRender},renderAll:function(){this.contextTopDirty&&!this._groupSelector&&!this.isDrawingMode&&(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&this.renderTopLayer(this.contextTop);var canvasToDrawOn=this.contextContainer;return this.renderCanvas(canvasToDrawOn,this._chooseObjectsToRender()),this},renderTopLayer:function(ctx){ctx.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(ctx),this.contextTopDirty=!0),ctx.restore()},renderTop:function(){var ctx=this.contextTop;return this.clearContext(ctx),this.renderTopLayer(ctx),this.fire("after:render"),this},_normalizePointer:function(object,pointer){var m=object.calcTransformMatrix(),invertedM=fabric.util.invertTransform(m),vptPointer=this.restorePointerVpt(pointer);return fabric.util.transformPoint(vptPointer,invertedM)},isTargetTransparent:function(target,x,y){if(target.shouldCache()&&target._cacheCanvas&&target!==this._activeObject){var normalizedPointer=this._normalizePointer(target,{x:x,y:y}),targetRelativeX=Math.max(target.cacheTranslationX+normalizedPointer.x*target.zoomX,0),targetRelativeY=Math.max(target.cacheTranslationY+normalizedPointer.y*target.zoomY,0),isTransparent=fabric.util.isTransparent(target._cacheContext,Math.round(targetRelativeX),Math.round(targetRelativeY),this.targetFindTolerance);return isTransparent}var ctx=this.contextCache,originalColor=target.selectionBackgroundColor,v=this.viewportTransform;target.selectionBackgroundColor="",this.clearContext(ctx),ctx.save(),ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),target.render(ctx),ctx.restore(),target===this._activeObject&&target._renderControls(ctx,{hasBorders:!1,transparentCorners:!1},{hasBorders:!1}),target.selectionBackgroundColor=originalColor;var isTransparent=fabric.util.isTransparent(ctx,x,y,this.targetFindTolerance);return isTransparent},_isSelectionKeyPressed:function(e){var selectionKeyPressed=!1;return Object.prototype.toString.call(this.selectionKey)==="[object Array]"?selectionKeyPressed=!!this.selectionKey.find(function(key){return e[key]===!0}):selectionKeyPressed=e[this.selectionKey],selectionKeyPressed},_shouldClearSelection:function(e,target){var activeObjects=this.getActiveObjects(),activeObject=this._activeObject;return!target||target&&activeObject&&activeObjects.length>1&&activeObjects.indexOf(target)===-1&&activeObject!==target&&!this._isSelectionKeyPressed(e)||target&&!target.evented||target&&!target.selectable&&activeObject&&activeObject!==target},_shouldCenterTransform:function(target,action,altKey){if(target){var centerTransform;return action==="scale"||action==="scaleX"||action==="scaleY"||action==="resizing"?centerTransform=this.centeredScaling||target.centeredScaling:action==="rotate"&&(centerTransform=this.centeredRotation||target.centeredRotation),centerTransform?!altKey:altKey}},_getOriginFromCorner:function(target,corner){var origin={x:target.originX,y:target.originY};return corner==="ml"||corner==="tl"||corner==="bl"?origin.x="right":(corner==="mr"||corner==="tr"||corner==="br")&&(origin.x="left"),corner==="tl"||corner==="mt"||corner==="tr"?origin.y="bottom":corner==="bl"||corner==="mb"||corner==="br"?origin.y="top":corner==="mtr"&&(origin.x="center",origin.y="center"),origin},_getActionFromCorner:function(alreadySelected,corner,e,target){if(!corner||!alreadySelected)return"drag";var control=target.controls[corner];return control.getActionName(e,control,target)},_setupCurrentTransform:function(e,target,alreadySelected){if(target){var pointer=this.getPointer(e),corner=target.__corner,actionHandler=!!corner&&target.controls[corner].getActionHandler(),action=this._getActionFromCorner(alreadySelected,corner,e,target),origin=this._getOriginFromCorner(target,corner),altKey=e[this.centeredKey],transform={target:target,action:action,actionHandler:actionHandler,corner:corner,scaleX:target.scaleX,scaleY:target.scaleY,skewX:target.skewX,skewY:target.skewY,offsetX:pointer.x-target.left,offsetY:pointer.y-target.top,originX:origin.x,originY:origin.y,ex:pointer.x,ey:pointer.y,lastX:pointer.x,lastY:pointer.y,theta:degreesToRadians(target.angle),width:target.width*target.scaleX,shiftKey:e.shiftKey,altKey:altKey,original:fabric.util.saveObjectTransform(target)};this._shouldCenterTransform(target,action,altKey)&&(transform.originX="center",transform.originY="center"),transform.original.originX=origin.x,transform.original.originY=origin.y,this._currentTransform=transform,this._beforeTransform(e)}}
1,_translateObject:function(x,y){var transform=this._currentTransform,target=transform.target,newLeft=x-transform.offsetX,newTop=y-transform.offsetY,moveX=!target.get("lockMovementX")&&target.left!==newLeft,moveY=!target.get("lockMovementY")&&target.top!==newTop;return moveX&&target.set("left",newLeft),moveY&&target.set("top",newTop),moveX||moveY},setCursor:function(value){this.upperCanvasEl.style.cursor=value},_drawSelection:function(ctx){var groupSelector=this._groupSelector,left=groupSelector.left,top=groupSelector.top,aleft=abs(left),atop=abs(top);if(this.selectionColor&&(ctx.fillStyle=this.selectionColor,ctx.fillRect(groupSelector.ex-(left>0?0:-left),groupSelector.ey-(top>0?0:-top),aleft,atop)),!(!this.selectionLineWidth||!this.selectionBorderColor))if(ctx.lineWidth=this.selectionLineWidth,ctx.strokeStyle=this.selectionBorderColor,this.selectionDashArray.length>1&&!supportLineDash){var px=groupSelector.ex+STROKE_OFFSET-(left>0?0:aleft),py=groupSelector.ey+STROKE_OFFSET-(top>0?0:atop);ctx.beginPath(),fabric.util.drawDashedLine(ctx,px,py,px+aleft,py,this.selectionDashArray),fabric.util.drawDashedLine(ctx,px,py+atop-1,px+aleft,py+atop-1,this.selectionDashArray),fabric.util.drawDashedLine(ctx,px,py,px,py+atop,this.selectionDashArray),fabric.util.drawDashedLine(ctx,px+aleft-1,py,px+aleft-1,py+atop,this.selectionDashArray),ctx.closePath(),ctx.stroke()}else fabric.Object.prototype._setLineDash.call(this,ctx,this.selectionDashArray),ctx.strokeRect(groupSelector.ex+STROKE_OFFSET-(left>0?0:aleft),groupSelector.ey+STROKE_OFFSET-(top>0?0:atop),aleft,atop)},findTarget:function(e,skipGroup){if(!this.skipTargetFind){var ignoreZoom=!0,pointer=this.getPointer(e,ignoreZoom),activeObject=this._activeObject,aObjects=this.getActiveObjects(),activeTarget,activeTargetSubs,isTouch=isTouchEvent(e);
1if(this.targets=[],aObjects.length>1&&!skipGroup&&activeObject===this._searchPossibleTargets([activeObject],pointer)||aObjects.length===1&&activeObject._findTargetCorner(pointer,isTouch))return activeObject;if(aObjects.length===1&&activeObject===this._searchPossibleTargets([activeObject],pointer))if(this.preserveObjectStacking)activeTarget=activeObject,activeTargetSubs=this.targets,this.targets=[];else return activeObject;var target=this._searchPossibleTargets(this._objects,pointer);return e[this.altSelectionKey]&&target&&activeTarget&&target!==activeTarget&&(target=activeTarget,this.targets=activeTargetSubs),target}},_checkTarget:function(pointer,obj,globalPointer){if(obj&&obj.visible&&obj.evented&&(obj.containsPoint(pointer)||obj._findTargetCorner(pointer)))if((this.perPixelTargetFind||obj.perPixelTargetFind)&&!obj.isEditing){var isTransparent=this.isTargetTransparent(obj,globalPointer.x,globalPointer.y);if(!isTransparent)return!0}else return!0},_searchPossibleTargets:function(objects,pointer){for(var target,i=objects.length,subTarget;i--;){var objToCheck=objects[i],pointerToUse=objToCheck.group?this._normalizePointer(objToCheck.group,pointer):pointer;if(this._checkTarget(pointerToUse,objToCheck,pointer)){target=objects[i],target.subTargetCheck&&target instanceof fabric.Group&&(subTarget=this._searchPossibleTargets(target._objects,pointer),subTarget&&this.targets.push(subTarget));break}}return target},restorePointerVpt:function(pointer){return fabric.util.transformPoint(pointer,fabric.util.invertTransform(this.viewportTransform))},getPointer:function(e,ignoreZoom){if(this._absolutePointer&&!ignoreZoom)return this._absolutePointer;if(this._pointer&&ignoreZoom)return this._pointer;var pointer=getPointer(e),upperCanvasEl=this.upperCanvasEl,bounds=upperCanvasEl.getBoundingClientRect(),boundsWidth=bounds.width||0,boundsHeight=bounds.height||0,cssScale;(!boundsWidth||!boundsHeight)&&("top"in bounds&&"bottom"in bounds&&(boundsHeight=Math.abs(bounds.top-bounds.bottom)),"right"in bounds&&"left"in bounds&&(boundsWidth=Math.abs(bounds.right-bounds.left))),this.calcOffset(),pointer.x=pointer.x-this._offset.left,pointer.y=pointer.y-this._offset.top,ignoreZoom||(pointer=this.restorePointerVpt(pointer));var retinaScaling=this.getRetinaScaling();return retinaScaling!==1&&(pointer.x/=retinaScaling,pointer.y/=retinaScaling),boundsWidth===0||boundsHeight===0?cssScale={width:1,height:1}:cssScale={width:upperCanvasEl.width/boundsWidth,height:upperCanvasEl.height/boundsHeight},{x:pointer.x*cssScale.width,y:pointer.y*cssScale.height}},_createUpperCanvas:function(){var lowerCanvasClass=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),lowerCanvasEl=this.lowerCanvasEl,upperCanvasEl=this.upperCanvasEl;upperCanvasEl?upperCanvasEl.className="":(upperCanvasEl=this._createCanvasElement(),this.upperCanvasEl=upperCanvasEl),fabric.util.addClass(upperCanvasEl,"upper-canvas "+lowerCanvasClass),this.wrapperEl.appendChild(upperCanvasEl),this._copyCanvasStyle(lowerCanvasEl,upperCanvasEl),this._applyCanvasStyle(upperCanvasEl),this.contextTop=upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),fabric.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(element){var width=this.width||element.width,height=this.height||element.height;fabric.util.setStyle(element,{position:"absolute",width:width+"px",height:height+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),element.width=width,element.height=height,fabric.util.makeElementUnselectable(element)},_copyCanvasStyle:function(fromEl,toEl){toEl.style.cssText=fromEl.style.cssText},getSelectionContext:function(){return this.contextTop}
1,getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var active=this._activeObject;return active?active.type==="activeSelection"&&active._objects?active._objects.slice(0):[active]:[]},_onObjectRemoved:function(obj){obj===this._activeObject&&(this.fire("before:selection:cleared",{target:obj}),this._discardActiveObject(),this.fire("selection:cleared",{target:obj}),obj.fire("deselected")),obj===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",obj)},_fireSelectionEvents:function(oldObjects,e){var somethingChanged=!1,objects=this.getActiveObjects(),added=[],removed=[],opt={e:e};oldObjects.forEach(function(oldObject){objects.indexOf(oldObject)===-1&&(somethingChanged=!0,oldObject.fire("deselected",opt),removed.push(oldObject))}),objects.forEach(function(object){oldObjects.indexOf(object)===-1&&(somethingChanged=!0,object.fire("selected",opt),added.push(object))}),oldObjects.length>0&&objects.length>0?(opt.selected=added,opt.deselected=removed,opt.updated=added[0]||removed[0],opt.target=this._activeObject,somethingChanged&&this.fire("selection:updated",opt)):objects.length>0?(opt.selected=added,opt.target=this._activeObject,this.fire("selection:created",opt)):oldObjects.length>0&&(opt.deselected=removed,this.fire("selection:cleared",opt))},setActiveObject:function(object,e){var currentActives=this.getActiveObjects();return this._setActiveObject(object,e),this._fireSelectionEvents(currentActives,e),this},_setActiveObject:function(object,e){return this._activeObject===object||!this._discardActiveObject(e,object)||object.onSelect({e:e})?!1:(this._activeObject=object,!0)},_discardActiveObject:function(e,object){var obj=this._activeObject;if(obj){if(obj.onDeselect({e:e,object:object}))return!1;this._activeObject=null}return!0},discardActiveObject:function(e){var currentActives=this.getActiveObjects(),activeObject=this.getActiveObject();return currentActives.length&&this.fire("before:selection:cleared",{target:activeObject,e:e}),this._discardActiveObject(e),this._fireSelectionEvents(currentActives,e),this},dispose:function(){var wrapper=this.wrapperEl;return this.removeListeners(),wrapper.removeChild(this.upperCanvasEl),wrapper.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach((function(element){fabric.util.cleanUpJsdomNode(this[element]),this[element]=void 0}).bind(this)),wrapper.parentNode&&wrapper.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,fabric.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(ctx){var activeObject=this._activeObject;activeObject&&activeObject._renderControls(ctx)},_toObject:function(instance,methodName,propertiesToInclude){var originalProperties=this._realizeGroupTransformOnObject(instance),object=this.callSuper("_toObject",instance,methodName,propertiesToInclude);return this._unwindGroupTransformOnObject(instance,originalProperties),object},_realizeGroupTransformOnObject:function(instance){if(instance.group&&instance.group.type==="activeSelection"&&this._activeObject===instance.group){var layoutProps=["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"],originalValues={};return layoutProps.forEach(function(prop2){originalValues[prop2]=instance[prop2]}),this._activeObject.realizeTransform(instance),originalValues}else return null},_unwindGroupTransformOnObject:function(instance,originalValues){originalValues&&instance.set(originalValues)},_setSVGObject:function(markup,instance,reviver){var originalProperties=this._realizeGroupTransformOnObject(instance);this.callSuper("_setSVGObject",markup,instance,reviver),this._unwindGroupTransformOnObject(instance,originalProperties)},setViewportTransform:function(vpt){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),fabric.StaticCanvas.prototype.setViewportTransform.call(this,vpt)}});for(var prop in fabric.StaticCanvas)prop!=="prototype"&&(fabric.Canvas[prop]=fabric.StaticCanvas[prop])})(),(function(){var addListener=fabric.util.addListener,removeListener=fabric.util.removeListener,RIGHT_CLICK=3,MIDDLE_CLICK=2,LEFT_CLICK=1,addEventOptions={passive:!1};function checkClick(e,value){return e.button&&e.button===value-1}fabric.util.object.extend(fabric.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(addListener,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(functor,eventjsFunctor){var canvasElement=this.upperCanvasEl,eventTypePrefix=this._getEventPrefix();functor(fabric.window,"resize",this._onResize),functor(canvasElement,eventTypePrefix+"down",this._onMouseDown),functor(canvasElement,eventTypePrefix+"move",this._onMouseMove,addEventOptions),functor(canvasElement,eventTypePrefix+"out",this._onMouseOut),functor(canvasElement,eventTypePrefix+"enter",this._onMouseEnter),functor(canvasElement,"wheel",this._onMouseWheel),functor(canvasElement,"contextmenu",this._onContextMenu),functor(canvasElement,"dblclick",this._onDoubleClick),functor(canvasElement,"dragover",this._onDragOver),functor(canvasElement,"dragenter",this._onDragEnter),functor(canvasElement,"dragleave",this._onDragLeave),functor(canvasElement,"drop",this._onDrop),this.enablePointerEvents||functor(canvasElement,"touchstart",this._onTouchStart,addEventOptions),typeof eventjs!="undefined"&&eventjsFunctor in eventjs&&(eventjs[eventjsFunctor](canvasElement,"gesture",this._onGesture),eventjs[eventjsFunctor](canvasElement,"drag",this._onDrag),eventjs[eventjsFunctor](canvasElement,"orientation",this._onOrientationChange),eventjs[eventjsFunctor](canvasElement,"shake",this._onShake),eventjs[eventjsFunctor](canvasElement,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(removeListener,"remove");var eventTypePrefix=this._getEventPrefix();removeListener(fabric.document,eventTypePrefix+"up",this._onMouseUp),removeListener(fabric.document,"touchend",this._onTouchEnd,addEventOptions),removeListener(fabric.document,eventTypePrefix+"move",this._onMouseMove,addEventOptions),removeListener(fabric.document,"touchmove",this._onMouseMove,addEventOptions)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._simpleEventHandler.bind(this,"drop"),this.eventsBound=!0)},_onGesture:function(e,self){this.__onTransformGesture&&this.__onTransformGesture(e,self)},_onDrag:function(e,self){this.__onDrag&&this.__onDrag(e,self)},_onMouseWheel:function(e){this.__onMouseWheel(e)},_onMouseOut:function(e){var target=this._hoveredTarget;this.fire("mouse:out",{target:target,e:e}),this._hoveredTarget=null,target&&target.fire("mouseout",{e:e});var _this=this;
1this._hoveredTargets.forEach(function(_target){_this.fire("mouse:out",{target:target,e:e}),_target&&target.fire("mouseout",{e:e})}),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach(function(obj){obj.isEditing&&obj.hiddenTextarea.focus()})},_onMouseEnter:function(e){!this.currentTransform&&!this.findTarget(e)&&(this.fire("mouse:over",{target:null,e:e}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(e,self){this.__onOrientationChange&&this.__onOrientationChange(e,self)},_onShake:function(e,self){this.__onShake&&this.__onShake(e,self)},_onLongPress:function(e,self){this.__onLongPress&&this.__onLongPress(e,self)},_onDragOver:function(e){e.preventDefault();var target=this._simpleEventHandler("dragover",e);this._fireEnterLeaveEvents(target,e)},_onContextMenu:function(e){return this.stopContextMenu&&(e.stopPropagation(),e.preventDefault()),!1},_onDoubleClick:function(e){this._cacheTransformEventData(e),this._handleEvent(e,"dblclick"),this._resetTransformEventData(e)},getPointerId:function(evt){var changedTouches=evt.changedTouches;return changedTouches?changedTouches[0]&&changedTouches[0].identifier:this.enablePointerEvents?evt.pointerId:-1},_isMainEvent:function(evt){return evt.isPrimary===!0?!0:evt.isPrimary===!1?!1:evt.type==="touchend"&&evt.touches.length===0?!0:evt.changedTouches?evt.changedTouches[0].identifier===this.mainTouchId:!0},_onTouchStart:function(e){e.preventDefault(),this.mainTouchId===null&&(this.mainTouchId=this.getPointerId(e)),this.__onMouseDown(e),this._resetTransformEventData();var canvasElement=this.upperCanvasEl,eventTypePrefix=this._getEventPrefix();addListener(fabric.document,"touchend",this._onTouchEnd,addEventOptions),addListener(fabric.document,"touchmove",this._onMouseMove,addEventOptions),removeListener(canvasElement,eventTypePrefix+"down",this._onMouseDown)},_onMouseDown:function(e){this.__onMouseDown(e),this._resetTransformEventData();var canvasElement=this.upperCanvasEl,eventTypePrefix=this._getEventPrefix();removeListener(canvasElement,eventTypePrefix+"move",this._onMouseMove,addEventOptions),addListener(fabric.document,eventTypePrefix+"up",this._onMouseUp),addListener(fabric.document,eventTypePrefix+"move",this._onMouseMove,addEventOptions)},_onTouchEnd:function(e){if(!(e.touches.length>0)){this.__onMouseUp(e),this._resetTransformEventData(),this.mainTouchId=null;var eventTypePrefix=this._getEventPrefix();removeListener(fabric.document,"touchend",this._onTouchEnd,addEventOptions),removeListener(fabric.document,"touchmove",this._onMouseMove,addEventOptions);var _this=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){addListener(_this.upperCanvasEl,eventTypePrefix+"down",_this._onMouseDown),_this._willAddMouseDown=0},400)}},_onMouseUp:function(e){this.__onMouseUp(e),this._resetTransformEventData();var canvasElement=this.upperCanvasEl,eventTypePrefix=this._getEventPrefix();this._isMainEvent(e)&&(removeListener(fabric.document,eventTypePrefix+"up",this._onMouseUp),removeListener(fabric.document,eventTypePrefix+"move",this._onMouseMove,addEventOptions),addListener(canvasElement,eventTypePrefix+"move",this._onMouseMove,addEventOptions))},_onMouseMove:function(e){!this.allowTouchScrolling&&e.preventDefault&&e.preventDefault(),this.__onMouseMove(e)},_onResize:function(){this.calcOffset()},_shouldRender:function(target){var activeObject=this._activeObject;return!!activeObject!=!!target||activeObject&&target&&activeObject!==target?!0:(activeObject&&activeObject.isEditing,!1)},__onMouseUp:function(e){var target,transform=this._currentTransform,groupSelector=this._groupSelector,shouldRender=!1,isClick=!groupSelector||groupSelector.left===0&&groupSelector.top===0;if(this._cacheTransformEventData(e),target=this._target,this._handleEvent(e,"up:before"),checkClick(e,RIGHT_CLICK)){this.fireRightClick&&this._handleEvent(e,"up",RIGHT_CLICK,isClick);return}if(checkClick(e,MIDDLE_CLICK)){this.fireMiddleClick&&this._handleEvent(e,"up",MIDDLE_CLICK,isClick),this._resetTransformEventData();return}if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(e);return}if(this._isMainEvent(e)){if(transform&&(this._finalizeCurrentTransform(e),shouldRender=transform.actionPerformed),!isClick){var targetWasActive=target===this._activeObject;this._maybeGroupObjects(e),shouldRender||(shouldRender=this._shouldRender(target)||!targetWasActive&&target===this._activeObject)}if(target){var corner=target._findTargetCorner(this.getPointer(e,!0),fabric.util.isTouchEvent(e)),control=target.controls[corner],mou
1seUpHandler=control&&control.getMouseUpHandler(e,target,control);mouseUpHandler&&mouseUpHandler(e,target,control),target.isMoving=!1}this._setCursorFromEvent(e,target),this._handleEvent(e,"up",LEFT_CLICK,isClick),this._groupSelector=null,this._currentTransform=null,target&&(target.__corner=0),shouldRender?this.requestRenderAll():isClick||this.renderTop()}},_simpleEventHandler:function(eventType,e){var target=this.findTarget(e),targets=this.targets,options={e:e,target:target,subTargets:targets};if(this.fire(eventType,options),target&&target.fire(eventType,options),!targets)return target;for(var i=0;i<targets.length;i++)targets[i].fire(eventType,options);return target},_handleEvent:function(e,eventType,button,isClick){var target=this._target,targets=this.targets||[],options={e:e,target:target,subTargets:targets,button:button||LEFT_CLICK,isClick:isClick||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};this.fire("mouse:"+eventType,options),target&&target.fire("mouse"+eventType,options);for(var i=0;i<targets.length;i++)targets[i].fire("mouse"+eventType,options)},_finalizeCurrentTransform:function(e){var transform=this._currentTransform,target=transform.target,eventName,options={e:e,target:target,transform:transform};target._scaling&&(target._scaling=!1),target.setCoords(),(transform.actionPerformed||this.stateful&&target.hasStateChanged())&&(transform.actionPerformed&&(eventName=this._addEventOptions(options,transform),this._fire(eventName,options)),this._fire("modified",options))},_addEventOptions:function(options,transform){var eventName,by;switch(transform.action){case"scaleX":eventName="scaled",by="x";break;case"scaleY":eventName="scaled",by="y";break;case"skewX":eventName="skewed",by="x";break;case"skewY":eventName="skewed",by="y";break;case"scale":eventName="scaled",by="equally";break;case"rotate":eventName="rotated";break;case"drag":eventName="moved";break}return options.by=by,eventName},_onMouseDownInDrawingMode:function(e){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(e).requestRenderAll();var pointer=this.getPointer(e);this.freeDrawingBrush.onMouseDown(pointer,{e:e,pointer:pointer}),this._handleEvent(e,"down")},_onMouseMoveInDrawingMode:function(e){if(this._isCurrentlyDrawing){var pointer=this.getPointer(e);this.freeDrawingBrush.onMouseMove(pointer,{e:e,pointer:pointer})}this.setCursor(this.freeDrawingCursor),this._handleEvent(e,"move")},_onMouseUpInDrawingMode:function(e){var pointer=this.getPointer(e);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:e,pointer:pointer}),this._handleEvent(e,"up")},__onMouseDown:function(e){this._cacheTransformEventData(e),this._handleEvent(e,"down:before");var target=this._target;if(checkClick(e,RIGHT_CLICK)){this.fireRightClick&&this._handleEvent(e,"down",RIGHT_CLICK);return}if(checkClick(e,MIDDLE_CLICK)){this.fireMiddleClick&&this._handleEvent(e,"down",MIDDLE_CLICK);return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(e);return}if(this._isMainEvent(e)&&!this._currentTransform){var pointer=this._pointer;this._previousPointer=pointer;var shouldRender=this._shouldRender(target),shouldGroup=this._shouldGroup(e,target);if(this._shouldClearSelection(e,target)?this.discardActiveObject(e):shouldGroup&&(this._handleGrouping(e,target),target=this._activeObject),this.selection&&(!target||!target.selectable&&!target.isEditing&&target!==this._activeObject)&&(this._groupSelector={ex:pointer.x,ey:pointer.y,top:0,left:0}),target){var alreadySelected=target===this._activeObject;target.selectable&&this.setActiveObject(target,e);var corner=target._findTargetCorner(this.getPointer(e,!0),fabric.util.isTouchEvent(e));if(target.__corner=corner,target===this._activeObject&&(corner||!shouldGroup)){var control=target.controls[corner],mouseDownHandler=control&&control.getMouseDownHandler(e,target,control);mouseDownHandler&&mouseDownHandler(e,target,control),this._setupCurrentTransform(e,target,alreadySelected)}}this._handleEvent(e,"down"),(shouldRender||shouldGroup)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(e){this._resetTransformEventData(),this._pointer=this.getPointer(e,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(e)||null},_beforeTransform:function(e){var t=this._currentTransform;this.stateful&&t.target.saveState(),this.fire("before:transform",{e:e,transform:t})},__onMouseMove:function(e){this._handleEvent(e,"move:before"),this._cacheTransformEventData(e);var target,pointer;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(e);return}if(this._isMainEvent(e)){var groupSelector=this._groupSelector;groupSelector?(pointer=this._pointer,groupSelector.left=pointer.x-groupSelector.ex,groupSelector.top=pointer.y-groupSelector.ey,this.renderTop()):this._currentTransform?this._transformObject(e):(target=this.findTarget(e)||null,this._setCursorFromEvent(e,target),this._fireOverOutEvents(target,e)),this._handleEvent(e,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(target,e){var _hoveredTarget=this._hoveredTarget,_hoveredTargets=this._hoveredTargets,targets=this.targets,length=Math.max(_hoveredTargets.length,targets.length);this.fireSyntheticInOutEvents(target,e,{oldTarget:_hoveredTarget,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var i=0;i<length;i++)this.fireSyntheticInOutEvents(targets[i],e,{oldTarget:_hoveredTargets[i],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=target,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(target,e){var _draggedoverTarget=this._draggedoverTarget,_hoveredTargets=this._hoveredTargets,targets=this.targets,length=Math.max(_hoveredTargets.length,targets.length);this.fireSyntheticInOutEvents(target,e,{oldTarget:_draggedoverTarget,evtOut:"dragleave",evtIn:"dragenter"});for(var i=0;i<length;i++)this.fireSyntheticInOutEvents(targets[i],e,{oldTarget:_hoveredTargets[i],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=target},fireSyntheticInOutEvents:function(target,e,config){var inOpt,outOpt,oldTarget=config.oldTarget,outFires,inFires,targetChanged=oldTarget!==target,canvasEvtIn=config.canvasEvtIn,canvasEvtOut=config.canvasEvtOut;targetChanged&&(inOpt={e:e,target:target,previousTarget:oldTarget},outOpt={e:e,target:oldTarget,nextTarget:target}),inFires=target&&targetChanged,outFires=oldTarget&&targetChanged,outFires&&(canvasEvtOut&&this.fire(canvasEvtOut,outOpt),oldTarget.fire(config.evtOut,outOpt)),inFires&&(canvasEvtIn&&this.fire(canvasEvtIn,inOpt),target.fire(config.evtIn,inOpt))},__onMouseWheel:function(e){this._cacheTransformEventData(e),this._handleEvent(e,"wheel"),this._resetTransformEventData()},_transformObject:function(e){var pointer=this.getPointer(e),transform=this._currentTransform;transform.reset=!1,transform.target.isMoving=!0,transform.shiftKey=e.shiftKey,transform.altKey=e[this.centeredKey],this._performTransformAction(e,transform,pointer),transform.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(e,transform,pointer){var x=pointer.x,y=pointer.y,action=transform.action,actionPerformed=!1,actionHandler=transform.actionHandler,options={target:transform.target,e:e,transform:transform,pointer:pointer};
1action==="drag"?(actionPerformed=this._translateObject(x,y),actionPerformed&&(this._fire("moving",options),this.setCursor(options.target.moveCursor||this.moveCursor))):actionHandler&&(actionPerformed=actionHandler(e,transform,x,y))&&this._fire(action,options),transform.actionPerformed=transform.actionPerformed||actionPerformed},_fire:fabric.controlsUtils.fireEvent,_setCursorFromEvent:function(e,target){if(!target)return this.setCursor(this.defaultCursor),!1;var hoverCursor=target.hoverCursor||this.hoverCursor,activeSelection=this._activeObject&&this._activeObject.type==="activeSelection"?this._activeObject:null,corner=(!activeSelection||!activeSelection.contains(target))&&target._findTargetCorner(this.getPointer(e,!0));corner?this.setCursor(this.getCornerCursor(corner,target,e)):(target.subTargetCheck&&this.targets.concat().reverse().map(function(_target){hoverCursor=_target.hoverCursor||hoverCursor}),this.setCursor(hoverCursor))},getCornerCursor:function(corner,target,e){var control=target.controls[corner];return control.cursorStyleHandler(e,control,target)}})})(),(function(){var min=Math.min,max=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(e,target){var activeObject=this._activeObject;return activeObject&&this._isSelectionKeyPressed(e)&&target&&target.selectable&&this.selection&&(activeObject!==target||activeObject.type==="activeSelection")&&!target.onSelect({e:e})},_handleGrouping:function(e,target){var activeObject=this._activeObject;activeObject.__corner||target===activeObject&&(target=this.findTarget(e,!0),!target||!target.selectable)||(activeObject&&activeObject.type==="activeSelection"?this._updateActiveSelection(target,e):this._createActiveSelection(target,e))},_updateActiveSelection:function(target,e){var activeSelection=this._activeObject,currentActiveObjects=activeSelection._objects.slice(0);activeSelection.contains(target)?(activeSelection.removeWithUpdate(target),this._hoveredTarget=target,this._hoveredTargets=this.targets.concat(),activeSelection.size()===1&&this._setActiveObject(activeSelection.item(0),e)):(activeSelection.addWithUpdate(target),this._hoveredTarget=activeSelection,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(currentActiveObjects,e)},_createActiveSelection:function(target,e){var currentActives=this.getActiveObjects(),group=this._createGroup(target);this._hoveredTarget=group,this._setActiveObject(group,e),this._fireSelectionEvents(currentActives,e)},_createGroup:function(target){var objects=this._objects,isActiveLower=objects.indexOf(this._activeObject)<objects.indexOf(target),groupObjects=isActiveLower?[this._activeObject,target]:[target,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new fabric.ActiveSelection(groupObjects,{canvas:this})},_groupSelectedObjects:function(e){var group=this._collectObjects(e),aGroup;group.length===1?this.setActiveObject(group[0],e):group.length>1&&(aGroup=new fabric.ActiveSelection(group.reverse(),{canvas:this}),this.setActiveObject(aGroup,e))},_collectObjects:function(e){for(var group=[],currentObject,x1=this._groupSelector.ex,y1=this._groupSelector.ey,x2=x1+this._groupSelector.left,y2=y1+this._groupSelector.top,selectionX1Y1=new fabric.Point(min(x1,x2),min(y1,y2)),selectionX2Y2=new fabric.Point(max(x1,x2),max(y1,y2)),allowIntersect=!this.selectionFullyContained,isClick=x1===x2&&y1===y2,i=this._objects.length;i--&&(currentObject=this._objects[i],!(!(!currentObject||!currentObject.selectable||!currentObject.visible)&&(allowIntersect&&currentObject.intersectsWithRect(selectionX1Y1,selectionX2Y2)||currentObject.isContainedWithinRect(selectionX1Y1,selectionX2Y2)||allowIntersect&&currentObject.containsPoint(selectionX1Y1)||allowIntersect&&currentObject.containsPoint(selectionX2Y2))&&(group.push(currentObject),isClick))););return group.length>1&&(group=group.filter(function(object){return!object.onSelect({e:e})})),group},_maybeGroupObjects:function(e){this.selection&&this._groupSelector&&this._groupSelectedObjects(e),this.setCursor(this.defaultCursor),this._groupSelector=null}})})(),(function(){fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(options){options||(options={});var format=options.format||"png",quality=options.quality||1,multiplier=(options.multiplier||1)*(options.enableRetinaScaling?this.getRetinaScaling():1),canvasEl=this.toCanvasElement(multiplier,options);return fabric.util.toDataURL(canvasEl,format,quality)},toCanvasElement:function(multiplier,cropping){multiplier=multiplier||1,cropping=cropping||{};var scaledWidth=(cropping.width||this.width)*multiplier,scaledHeight=(cropping.height||this.height)*multiplier,zoom=this.getZoom(),originalWidth=this.width,originalHeight=this.height,newZoom=zoom*multiplier,vp=this.viewportTransform,translateX=(vp[4]-(cropping.left||0))*multiplier,translateY=(vp[5]-(cropping.top||0))*multiplier,originalInteractive=this.interactive,newVp=[newZo
1om,0,0,newZoom,translateX,translateY],originalRetina=this.enableRetinaScaling,canvasEl=fabric.util.createCanvasElement(),originalContextTop=this.contextTop;return canvasEl.width=scaledWidth,canvasEl.height=scaledHeight,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=newVp,this.width=scaledWidth,this.height=scaledHeight,this.calcViewportBoundaries(),this.renderCanvas(canvasEl.getContext("2d"),this._objects),this.viewportTransform=vp,this.width=originalWidth,this.height=originalHeight,this.calcViewportBoundaries(),this.interactive=originalInteractive,this.enableRetinaScaling=originalRetina,this.contextTop=originalContextTop,canvasEl}})})(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromJSON:function(json,callback,reviver){if(json){var serialized=typeof json=="string"?JSON.parse(json):fabric.util.object.clone(json),_this=this,clipPath=serialized.clipPath,renderOnAddRemove=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete serialized.clipPath,this._enlivenObjects(serialized.objects,function(enlivenedObjects){_this.clear(),_this._setBgOverlay(serialized,function(){clipPath?_this._enlivenObjects([clipPath],function(enlivenedCanvasClip){_this.clipPath=enlivenedCanvasClip[0],_this.__setupCanvas.call(_this,serialized,enlivenedObjects,renderOnAddRemove,callback)}):_this.__setupCanvas.call(_this,serialized,enlivenedObjects,renderOnAddRemove,callback)})},reviver),this}},__setupCanvas:function(serialized,enlivenedObjects,renderOnAddRemove,callback){var _this=this;enlivenedObjects.forEach(function(obj,index){_this.insertAt(obj,index)}),this.renderOnAddRemove=renderOnAddRemove,delete serialized.objects,delete serialized.backgroundImage,delete serialized.overlayImage,delete serialized.background,delete serialized.overlay,this._setOptions(serialized),this.renderAll(),callback&&callback()},_setBgOverlay:function(serialized,callback){var loaded={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!serialized.backgroundImage&&!serialized.overlayImage&&!serialized.background&&!serialized.overlay){callback&&callback();return}var cbIfLoaded=function(){loaded.backgroundImage&&loaded.overlayImage&&loaded.backgroundColor&&loaded.overlayColor&&callback&&callback()};this.__setBgOverlay("backgroundImage",serialized.backgroundImage,loaded,cbIfLoaded),this.__setBgOverlay("overlayImage",serialized.overlayImage,loaded,cbIfLoaded),this.__setBgOverlay("backgroundColor",serialized.background,loaded,cbIfLoaded),this.__setBgOverlay("overlayColor",serialized.overlay,loaded,cbIfLoaded)},__setBgOverlay:function(property,value,loaded,callback){var _this=this;if(!value){loaded[property]=!0,callback&&callback();return}property==="backgroundImage"||property==="overlayImage"?fabric.util.enlivenObjects([value],function(enlivedObject){_this[property]=enlivedObject[0],loaded[property]=!0,callback&&callback()}):this["set"+fabric.util.string.capitalize(property,!0)](value,function(){loaded[property]=!0,callback&&callback()})},_enlivenObjects:function(objects,callback,reviver){if(!objects||objects.length===0){callback&&callback([]);return}fabric.util.enlivenObjects(objects,function(enlivenedObjects){callback&&callback(enlivenedObjects)},null,reviver)},_toDataURL:function(format,callback){this.clone(function(clone){callback(clone.toDataURL(format))})},_toDataURLWithMultiplier:function(format,multiplier,callback){this.clone(function(clone){callback(clone.toDataURLWithMultiplier(format,multiplier))})},clone:function(callback,properties){var data=JSON.stringify(this.toJSON(properties));this.cloneWithoutData(function(clone){clone.loadFromJSON(data,function(){callback&&callback(clone)})})},cloneWithoutData:function(callback){var el=fabric.util.createCanvasElement();el.width=this.width,el.height=this.height;var clone=new fabric.Canvas(el);this.backgroundImage?(clone.setBackgroundImage(this.backgroundImage.src,function(){clone.renderAll(),callback&&callback(clone)}),clone.backgroundImageOpacity=this.backgroundImageOpacity,clone.backgroundImageStretch=this.backgroundImageStretch):callback&&callback(clone)}}),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,clone=fabric2.util.object.clone,toFixed=fabric2.util.toFixed,capitalize=fabric2.util.string.capitalize,degreesToRadians=fabric2.util.degreesToRadians,supportsLineDash=fabric2.StaticCanvas.supports("setLineDash"),objectCaching=!fabric2.isLikelyNode,ALIASING_LIMIT=2;fabric2.Object||(fabric2.Object=fabric2.util.createClass(fabric2.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCurs
1or:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:objectCaching,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(options){options&&this.setOptions(options)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=fabric2.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(dims){var perfLimitSizeTotal=fabric2.perfLimitSizeTotal,width=dims.width,height=dims.height,max=fabric2.maxCacheSideLimit,min=fabric2.minCacheSideLimit;if(width<=max&&height<=max&&width*height<=perfLimitSizeTotal)return width<min&&(dims.width=min),height<min&&(dims.height=min),dims;var ar=width/height,limitedDims=fabric2.util.limitDimsByArea(ar,perfLimitSizeTotal),capValue=fabric2.util.capValue,x=capValue(min,limitedDims.x,max),y=capValue(min,limitedDims.y,max);return width>x&&(dims.zoomX/=width/x,dims.width=x,dims.capped=!0),height>y&&(dims.zoomY/=height/y,dims.height=y,dims.capped=!0),dims},_getCacheCanvasDimensions:function(){var objectScale=this.getTotalObjectScaling(),dim=this._getTransformedDimensions(0,0),neededX=dim.x*objectScale.scaleX/this.scaleX,neededY=dim.y*objectScale.scaleY/this.scaleY;return{width:neededX+ALIASING_LIMIT,height:neededY+ALIASING_LIMIT,zoomX:objectScale.scaleX,zoomY:objectScale.scaleY,x:neededX,y:neededY}},_updateCacheCanvas:function(){var targetCanvas=this.canvas;if(this.noScaleCache&&targetCanvas&&targetCanvas._currentTransform){var target=targetCanvas._currentTransform.target,action=targetCanvas._currentTransform.action;if(this===target&&action.slice&&action.slice(0,5)==="scale")return!1}var canvas=this._cacheCanvas,dims=this._limitCacheSize(this._getCacheCanvasDimensions()),minCacheSize=fabric2.minCacheSideLimit,width=dims.width,height=dims.height,drawingWidth,drawingHeight,zoomX=dims.zoomX,zoomY=dims.zoomY,dimensionsChanged=width!==this.cacheWidth||height!==this.cacheHeight,zoomChanged=this.zoomX!==zoomX||this.zoomY!==zoomY,shouldRedraw=dimensionsChanged||zoomChanged,additionalWidth=0,additionalHeight=0,shouldResizeCanvas=!1;if(dimensionsChanged){var canvasWidth=this._cacheCanvas.width,canvasHeight=this._cacheCanvas.height,sizeGrowing=width>canvasWidth||height>canvasHeight,sizeShrinking=(width<canvasWidth*.9||height<canvasHeight*.9)&&canvasWidth>minCacheSize&&canvasHeight>minCacheSize;shouldResizeCanvas=sizeGrowing||sizeShrinking,sizeGrowing&&!dims.capped&&(width>minCacheSize||height>minCacheSize)&&(additionalWidth=width*.1,additionalHeight=height*.1)}return shouldRedraw?(shouldResizeCanvas?(canvas.width=Math.ceil(width+additionalWidth),canvas.height=Math.ceil(height+additionalHeight)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,canvas.width,canvas.height)),drawingWidth=dims.x/2,drawingHeight=dims.y/2,this.cacheTranslationX=Math.round(canvas.width/2-drawingWidth)+drawingWidth,this.cacheTranslationY=Math.round(canvas.height/2-drawingHeight)+drawingHeight,this.cacheWidth=width,this.cacheHeight=height,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(zoomX,zoomY),this.zoomX=zoomX,this.zoomY=zoomY,!0):!1},setOptions:function(options){this._setOptions(options),this._initGradient(options.fill,"fill"),this._initGradient(options.stroke,"stroke"),this._initPattern(options.fill,"fill"),this._initPattern(options.stroke,"stroke")},transform:function(ctx){var needFullTransform=this.group&&!this.group._transformDone||this.group&&this.canvas&&ctx===this.canvas.contextTop,m=this.calcTransformMatrix(!needFullTransform);ctx.transform(m[0],m[1],m[2],m[3],m[4],m[5])},toObject:function(propertiesToInclude){var NUM_FRACTION_DIGITS=fabric2.Object.NUM_FRACTION_DIGITS,object={type:this.t
1ype,version:fabric2.version,originX:this.originX,originY:this.originY,left:toFixed(this.left,NUM_FRACTION_DIGITS),top:toFixed(this.top,NUM_FRACTION_DIGITS),width:toFixed(this.width,NUM_FRACTION_DIGITS),height:toFixed(this.height,NUM_FRACTION_DIGITS),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:toFixed(this.strokeWidth,NUM_FRACTION_DIGITS),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:toFixed(this.strokeMiterLimit,NUM_FRACTION_DIGITS),scaleX:toFixed(this.scaleX,NUM_FRACTION_DIGITS),scaleY:toFixed(this.scaleY,NUM_FRACTION_DIGITS),angle:toFixed(this.angle,NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:toFixed(this.opacity,NUM_FRACTION_DIGITS),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:toFixed(this.skewX,NUM_FRACTION_DIGITS),skewY:toFixed(this.skewY,NUM_FRACTION_DIGITS)};return this.clipPath&&(object.clipPath=this.clipPath.toObject(propertiesToInclude),object.clipPath.inverted=this.clipPath.inverted,object.clipPath.absolutePositioned=this.clipPath.absolutePositioned),fabric2.util.populateWithProperties(this,object,propertiesToInclude),this.includeDefaultValues||(object=this._removeDefaultValues(object)),object},toDatalessObject:function(propertiesToInclude){return this.toObject(propertiesToInclude)},_removeDefaultValues:function(object){var prototype=fabric2.util.getKlass(object.type).prototype,stateProperties=prototype.stateProperties;return stateProperties.forEach(function(prop){if(!(prop==="left"||prop==="top")){object[prop]===prototype[prop]&&delete object[prop];var isArray=Object.prototype.toString.call(object[prop])==="[object Array]"&&Object.prototype.toString.call(prototype[prop])==="[object Array]";isArray&&object[prop].length===0&&prototype[prop].length===0&&delete object[prop]}}),object},toString:function(){return"#<fabric."+capitalize(this.type)+">"},getObjectScaling:function(){var options=fabric2.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(options.scaleX),scaleY:Math.abs(options.scaleY)}},getTotalObjectScaling:function(){var scale=this.getObjectScaling(),scaleX=scale.scaleX,scaleY=scale.scaleY;if(this.canvas){var zoom=this.canvas.getZoom(),retina=this.canvas.getRetinaScaling();scaleX*=zoom*retina,scaleY*=zoom*retina}return{scaleX:scaleX,scaleY:scaleY}},getObjectOpacity:function(){var opacity=this.opacity;return this.group&&(opacity*=this.group.getObjectOpacity()),opacity},_set:function(key,value){var shouldConstrainValue=key==="scaleX"||key==="scaleY",isChanged=this[key]!==value,groupNeedsUpdate=!1;return shouldConstrainValue&&(value=this._constrainScale(value)),key==="scaleX"&&value<0?(this.flipX=!this.flipX,value*=-1):key==="scaleY"&&value<0?(this.flipY=!this.flipY,value*=-1):key==="shadow"&&value&&!(value instanceof fabric2.Shadow)?value=new fabric2.Shadow(value):key==="dirty"&&this.group&&this.group.set("dirty",value),this[key]=value,isChanged&&(groupNeedsUpdate=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(key)>-1?(this.dirty=!0,groupNeedsUpdate&&this.group.set("dirty",!0)):groupNeedsUpdate&&this.stateProperties.indexOf(key)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:fabric2.iMatrix.concat()},isNotVisible:function(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible},render:function(ctx){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(ctx.save(),this._setupCompositeOperation(ctx),this.drawSelectionBackground(ctx),this.transform(ctx),this._setOpacity(ctx),this._setShadow(ctx,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(ctx)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(ctx),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"}
1)),ctx.restore())},renderCache:function(options){options=options||{},this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,options.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0},hasFill:function(){return this.fill&&this.fill!=="transparent"},needsItsOwnCache:function(){return!!(this.paintFirst==="stroke"&&this.hasFill()&&this.hasStroke()&&typeof this.shadow=="object"||this.clipPath)},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)},drawClipPathOnCache:function(ctx){var path=this.clipPath;if(ctx.save(),path.inverted?ctx.globalCompositeOperation="destination-out":ctx.globalCompositeOperation="destination-in",path.absolutePositioned){var m=fabric2.util.invertTransform(this.calcTransformMatrix());ctx.transform(m[0],m[1],m[2],m[3],m[4],m[5])}path.transform(ctx),ctx.scale(1/path.zoomX,1/path.zoomY),ctx.drawImage(path._cacheCanvas,-path.cacheTranslationX,-path.cacheTranslationY),ctx.restore()},drawObject:function(ctx,forClipping){var originalFill=this.fill,originalStroke=this.stroke;forClipping?(this.fill="black",this.stroke="",this._setClippingProperties(ctx)):(this._renderBackground(ctx),this._setStrokeStyles(ctx,this),this._setFillStyles(ctx,this)),this._render(ctx),this._drawClipPath(ctx),this.fill=originalFill,this.stroke=originalStroke},_drawClipPath:function(ctx){var path=this.clipPath;path&&(path.canvas=this.canvas,path.shouldCache(),path._transformDone=!0,path.renderCache({forClipping:!0}),this.drawClipPathOnCache(ctx))},drawCacheOnCanvas:function(ctx){ctx.scale(1/this.zoomX,1/this.zoomY),ctx.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(skipCanvas){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!skipCanvas&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!skipCanvas){var width=this.cacheWidth/this.zoomX,height=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-width/2,-height/2,width,height)}return!0}return!1},_renderBackground:function(ctx){if(this.backgroundColor){var dim=this._getNonTransformedDimensions();ctx.fillStyle=this.backgroundColor,ctx.fillRect(-dim.x/2,-dim.y/2,dim.x,dim.y),this._removeShadow(ctx)}},_setOpacity:function(ctx){this.group&&!this.group._transformDone?ctx.globalAlpha=this.getObjectOpacity():ctx.globalAlpha*=this.opacity},_setStrokeStyles:function(ctx,decl){decl.stroke&&(ctx.lineWidth=decl.strokeWidth,ctx.lineCap=decl.strokeLineCap,ctx.lineDashOffset=decl.strokeDashOffset,ctx.lineJoin=decl.strokeLineJoin,ctx.miterLimit=decl.strokeMiterLimit,ctx.strokeStyle=decl.stroke.toLive?decl.stroke.toLive(ctx,this):decl.stroke)},_setFillStyles:function(ctx,decl){decl.fill&&(ctx.fillStyle=decl.fill.toLive?decl.fill.toLive(ctx,this):decl.fill)},_setClippingProperties:function(ctx){ctx.globalAlpha=1,ctx.strokeStyle="transparent",ctx.fillStyle="#000000"},_setLineDash:function(ctx,dashArray,alternative){!dashArray||dashArray.length===0||(1&dashArray.length&&dashArray.push.apply(dashArray,dashArray),supportsLineDash?ctx.setLineDash(dashArray):alternative&&alternative(ctx))},_renderControls:function(ctx,styleOverride){var vpt=this.getViewportTransform(),matrix=this.calcTransformMatrix(),options,drawBorders,drawControls;styleOverride=styleOverride||{},drawBorders=typeof styleOverride.hasBorders!="undefined"?styleOverride.hasBorders:this.hasBorders,drawControls=typeof styleOverride.hasControls!="undefined"?styleOverride.hasControls:this.hasControls,matrix=fabric2.util.multiplyTransformMatrices(vpt,matrix),options=fabric2.util.qrDecompose(matrix),ctx.save(),ctx.translate(options.translateX,options.translateY),ctx.lineWidth=1*this.borderScaleFactor,this.group||(ctx.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),styleOverride.forActiveSelection?(ctx.rotate(degreesToRadians(options.angle)),drawBorders&&this.drawBordersInGroup(ctx,options,styleOverride)):(ctx.rotate(degreesToRadians(this.angle)),drawBorders&&this.drawBorders(ctx,styleOverride)),drawControls&&this.drawControls(ctx,styleOverride),ctx.restore(
1)},_setShadow:function(ctx){if(this.shadow){var shadow=this.shadow,canvas=this.canvas,scaling,multX=canvas&&canvas.viewportTransform[0]||1,multY=canvas&&canvas.viewportTransform[3]||1;shadow.nonScaling?scaling={scaleX:1,scaleY:1}:scaling=this.getObjectScaling(),canvas&&canvas._isRetinaScaling()&&(multX*=fabric2.devicePixelRatio,multY*=fabric2.devicePixelRatio),ctx.shadowColor=shadow.color,ctx.shadowBlur=shadow.blur*fabric2.browserShadowBlurConstant*(multX+multY)*(scaling.scaleX+scaling.scaleY)/4,ctx.shadowOffsetX=shadow.offsetX*multX*scaling.scaleX,ctx.shadowOffsetY=shadow.offsetY*multY*scaling.scaleY}},_removeShadow:function(ctx){this.shadow&&(ctx.shadowColor="",ctx.shadowBlur=ctx.shadowOffsetX=ctx.shadowOffsetY=0)},_applyPatternGradientTransform:function(ctx,filler){if(!filler||!filler.toLive)return{offsetX:0,offsetY:0};var t=filler.gradientTransform||filler.patternTransform,offsetX=-this.width/2+filler.offsetX||0,offsetY=-this.height/2+filler.offsetY||0;return filler.gradientUnits==="percentage"?ctx.transform(this.width,0,0,this.height,offsetX,offsetY):ctx.transform(1,0,0,1,offsetX,offsetY),t&&ctx.transform(t[0],t[1],t[2],t[3],t[4],t[5]),{offsetX:offsetX,offsetY:offsetY}},_renderPaintInOrder:function(ctx){this.paintFirst==="stroke"?(this._renderStroke(ctx),this._renderFill(ctx)):(this._renderFill(ctx),this._renderStroke(ctx))},_render:function(){},_renderFill:function(ctx){this.fill&&(ctx.save(),this._applyPatternGradientTransform(ctx,this.fill),this.fillRule==="evenodd"?ctx.fill("evenodd"):ctx.fill(),ctx.restore())},_renderStroke:function(ctx){if(!(!this.stroke||this.strokeWidth===0)){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(ctx),ctx.save(),this.strokeUniform&&this.group){var scaling=this.getObjectScaling();ctx.scale(1/scaling.scaleX,1/scaling.scaleY)}else this.strokeUniform&&ctx.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(ctx,this.strokeDashArray,this._renderDashedStroke),this.stroke.toLive&&this.stroke.gradientUnits==="percentage"?this._applyPatternForTransformedGradient(ctx,this.stroke):this._applyPatternGradientTransform(ctx,this.stroke),ctx.stroke(),ctx.restore()}},_applyPatternForTransformedGradient:function(ctx,filler){var dims=this._limitCacheSize(this._getCacheCanvasDimensions()),pCanvas=fabric2.util.createCanvasElement(),pCtx,retinaScaling=this.canvas.getRetinaScaling(),width=dims.x/this.scaleX/retinaScaling,height=dims.y/this.scaleY/retinaScaling;pCanvas.width=width,pCanvas.height=height,pCtx=pCanvas.getContext("2d"),pCtx.beginPath(),pCtx.moveTo(0,0),pCtx.lineTo(width,0),pCtx.lineTo(width,height),pCtx.lineTo(0,height),pCtx.closePath(),pCtx.translate(width/2,height/2),pCtx.scale(dims.zoomX/this.scaleX/retinaScaling,dims.zoomY/this.scaleY/retinaScaling),this._applyPatternGradientTransform(pCtx,filler),pCtx.fillStyle=filler.toLive(ctx),pCtx.fill(),ctx.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),ctx.scale(retinaScaling*this.scaleX/dims.zoomX,retinaScaling*this.scaleY/dims.zoomY),ctx.strokeStyle=pCtx.createPattern(pCanvas,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var options=fabric2.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",options.scaleX),this.set("scaleY",options.scaleY),this.angle=options.angle,this.skewX=options.skewX,this.skewY=0}},_removeTransformMatrix:function(preserveAspectRatioOptions){var center=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),center=fabric2.util.transformPoint(center,this.transformMatrix)),this.transformMatrix=null,preserveAspectRatioOptions&&(this.scaleX*=preserveAspectRatioOptions.scaleX,this.scaleY*=preserveAspectRatioOptions.scaleY,this.cropX=preserveAspectRatioOptions.cropX,this.cropY=preserveAspectRatioOptions.cropY,center.x+=preserveAspectRatioOptions.offsetLeft,center.y+=preserveAspectRatioOptions.offsetTop,this.width=preserveAspectRatioOptions.width,this.height=preserveAspectRatioOptions.height),this.setPositionByOrigin(center,"center","center")},clone:function(callback,propertiesToInclude){var objectForm=this.toObject(propertiesToInclude);this.constructor.fromObject?this.constructor.fromObject(objectForm,callback):fabric2.Object._fromObject("Object",objectForm,callback)},cloneAsImage:function(callback,options){var canvasEl=this.toCanvasElement(options);return callback&&callback(new fabric2.Image(canvasEl)),this},toCanvasElement:function(options){options||(options={});var utils=fabric2.util,origParams=utils.saveObjectTransform(this),originalGroup=this.group,originalShadow=this.shadow,abs=Math.abs,multiplier=(options.multiplier||1)*(options.enableRetinaScaling?fabric2.devicePixelRatio:1);delete this.group,options.withoutTransform&&utils.resetObjectTransform(this),options.withoutShadow&&(this.shadow=null);var el=fabric2.util.createCanvasElement(),boundingRect=this.getBoundingRect
1(!0,!0),shadow=this.shadow,scaling,shadowOffset={x:0,y:0},shadowBlur,width,height;shadow&&(shadowBlur=shadow.blur,shadow.nonScaling?scaling={scaleX:1,scaleY:1}:scaling=this.getObjectScaling(),shadowOffset.x=2*Math.round(abs(shadow.offsetX)+shadowBlur)*abs(scaling.scaleX),shadowOffset.y=2*Math.round(abs(shadow.offsetY)+shadowBlur)*abs(scaling.scaleY)),width=boundingRect.width+shadowOffset.x,height=boundingRect.height+shadowOffset.y,el.width=Math.ceil(width),el.height=Math.ceil(height);var canvas=new fabric2.StaticCanvas(el,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});options.format==="jpeg"&&(canvas.backgroundColor="#fff"),this.setPositionByOrigin(new fabric2.Point(canvas.width/2,canvas.height/2),"center","center");var originalCanvas=this.canvas;canvas.add(this);var canvasEl=canvas.toCanvasElement(multiplier||1,options);return this.shadow=originalShadow,this.set("canvas",originalCanvas),originalGroup&&(this.group=originalGroup),this.set(origParams).setCoords(),canvas._objects=[],canvas.dispose(),canvas=null,canvasEl},toDataURL:function(options){return options||(options={}),fabric2.util.toDataURL(this.toCanvasElement(options),options.format||"png",options.quality||1)},isType:function(type){return this.type===type},complexity:function(){return 1},toJSON:function(propertiesToInclude){return this.toObject(propertiesToInclude)},rotate:function(angle){var shouldCenterOrigin=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;return shouldCenterOrigin&&this._setOriginToCenter(),this.set("angle",angle),shouldCenterOrigin&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(e,pointer){pointer=pointer||this.canvas.getPointer(e);var pClicked=new fabric2.Point(pointer.x,pointer.y),objectLeftTop=this._getLeftTopCoords();return this.angle&&(pClicked=fabric2.util.rotatePoint(pClicked,objectLeftTop,degreesToRadians(-this.angle))),{x:pClicked.x-objectLeftTop.x,y:pClicked.y-objectLeftTop.y}},_setupCompositeOperation:function(ctx){this.globalCompositeOperation&&(ctx.globalCompositeOperation=this.globalCompositeOperation)}}),fabric2.util.createAccessors&&fabric2.util.createAccessors(fabric2.Object),extend(fabric2.Object.prototype,fabric2.Observable),fabric2.Object.NUM_FRACTION_DIGITS=2,fabric2.Object._fromObject=function(className,object,callback,extraParam){var klass=fabric2[className];object=clone(object,!0),fabric2.util.enlivenPatterns([object.fill,object.stroke],function(patterns){typeof patterns[0]!="undefined"&&(object.fill=patterns[0]),typeof patterns[1]!="undefined"&&(object.stroke=patterns[1]),fabric2.util.enlivenObjects([object.clipPath],function(enlivedProps){object.clipPath=enlivedProps[0];var instance=extraParam?new klass(object[extraParam],object):new klass(object);callback&&callback(instance)})})},fabric2.Object.__uid=0)})(typeof exports!="undefined"?exports:this),(function(){var degreesToRadians=fabric.util.degreesToRadians,originXOffset={left:-.5,center:0,right:.5},originYOffset={top:-.5,center:0,bottom:.5};fabric.util.object.extend(fabric.Object.prototype,{translateToGivenOrigin:function(point,fromOriginX,fromOriginY,toOriginX,toOriginY){var x=point.x,y=point.y,offsetX,offsetY,dim;return typeof fromOriginX=="string"?fromOriginX=originXOffset[fromOriginX]:fromOriginX-=.5,typeof toOriginX=="string"?toOriginX=originXOffset[toOriginX]:toOriginX-=.5,offsetX=toOriginX-fromOriginX,typeof fromOriginY=="string"?fromOriginY=originYOffset[fromOriginY]:fromOriginY-=.5,typeof toOriginY=="string"?toOriginY=originYOffset[toOriginY]:toOriginY-=.5,offsetY=toOriginY-fromOriginY,(offsetX||offsetY)&&(dim=this._getTransformedDimensions(),x=point.x+offsetX*dim.x,y=point.y+offsetY*dim.
1y),new fabric.Point(x,y)},translateToCenterPoint:function(point,originX,originY){var p=this.translateToGivenOrigin(point,originX,originY,"center","center");return this.angle?fabric.util.rotatePoint(p,point,degreesToRadians(this.angle)):p},translateToOriginPoint:function(center,originX,originY){var p=this.translateToGivenOrigin(center,"center","center",originX,originY);return this.angle?fabric.util.rotatePoint(p,center,degreesToRadians(this.angle)):p},getCenterPoint:function(){var leftTop=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(leftTop,this.originX,this.originY)},getPointByOrigin:function(originX,originY){var center=this.getCenterPoint();return this.translateToOriginPoint(center,originX,originY)},toLocalPoint:function(point,originX,originY){var center=this.getCenterPoint(),p,p2;return typeof originX!="undefined"&&typeof originY!="undefined"?p=this.translateToGivenOrigin(center,"center","center",originX,originY):p=new fabric.Point(this.left,this.top),p2=new fabric.Point(point.x,point.y),this.angle&&(p2=fabric.util.rotatePoint(p2,center,-degreesToRadians(this.angle))),p2.subtractEquals(p)},setPositionByOrigin:function(pos,originX,originY){var center=this.translateToCenterPoint(pos,originX,originY),position=this.translateToOriginPoint(center,this.originX,this.originY);this.set("left",position.x),this.set("top",position.y)},adjustPosition:function(to){var angle=degreesToRadians(this.angle),hypotFull=this.getScaledWidth(),xFull=fabric.util.cos(angle)*hypotFull,yFull=fabric.util.sin(angle)*hypotFull,offsetFrom,offsetTo;typeof this.originX=="string"?offsetFrom=originXOffset[this.originX]:offsetFrom=this.originX-.5,typeof to=="string"?offsetTo=originXOffset[to]:offsetTo=to-.5,this.left+=xFull*(offsetTo-offsetFrom),this.top+=yFull*(offsetTo-offsetFrom),this.setCoords(),this.originX=to},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var center=this.getCenterPoint();this.originX="center",this.originY="center",this.left=center.x,this.top=center.y},_resetOrigin:function(){var originPoint=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=originPoint.x,this.top=originPoint.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})})(),(function(){function arrayFromCoords(coords){return[new fabric.Point(coords.tl.x,coords.tl.y),new fabric.Point(coords.tr.x,coords.tr.y),new fabric.Point(coords.br.x,coords.br.y),new fabric.Point(coords.bl.x,coords.bl.y)]}var util=fabric.util,degreesToRadians=util.degreesToRadians,multiplyMatrices=util.multiplyTransformMatrices,transformPoint=util.transformPoint;util.object.extend(fabric.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(absolute,calculate){return calculate?absolute?this.calcACoords():this.calcLineCoords():((!this.aCoords||!this.lineCoords)&&this.setCoords(!0),absolute?this.aCoords:this.lineCoords)},getCoords:function(absolute,calculate){return arrayFromCoords(this._getCoords(absolute,calculate))},intersectsWithRect:function(pointTL,pointBR,absolute,calculate){var coords=this.getCoords(absolute,calculate),intersection=fabric.Intersection.intersectPolygonRectangle(coords,pointTL,pointBR);return intersection.status==="Intersection"},intersectsWithObject:function(other,absolute,calculate){var intersection=fabric.Intersection.intersectPolygonPolygon(this.getCoords(absolute,calculate),other.getCoords(absolute,calculate));return intersection.status==="Intersection"||other.isContainedWithinObject(this,absolute,calculate)||this.isContainedWithinObject(other,absolute,calculate)},isContainedWithinObject:function(other,absolute,calculate){for(var points=this.getCoords(absolute,calculate),otherCoords=absolute?other.aCoords:other.lineCoords,i=0,lines=other._getImageLines(otherCoords);i<4;i++)if(!other.containsPoint(points[i],lines))return!1;return!0},isContainedWithinRect:function(pointTL,pointBR,absolute,calculate){var boundingRect=this.getBoundingRect
1(absolute,calculate);return boundingRect.left>=pointTL.x&&boundingRect.left+boundingRect.width<=pointBR.x&&boundingRect.top>=pointTL.y&&boundingRect.top+boundingRect.height<=pointBR.y},containsPoint:function(point,lines,absolute,calculate){var coords=this._getCoords(absolute,calculate),lines=lines||this._getImageLines(coords),xPoints=this._findCrossPoints(point,lines);return xPoints!==0&&xPoints%2===1},isOnScreen:function(calculate){if(!this.canvas)return!1;var pointTL=this.canvas.vptCoords.tl,pointBR=this.canvas.vptCoords.br,points=this.getCoords(!0,calculate);return points.some(function(point){return point.x<=pointBR.x&&point.x>=pointTL.x&&point.y<=pointBR.y&&point.y>=pointTL.y})||this.intersectsWithRect(pointTL,pointBR,!0,calculate)?!0:this._containsCenterOfCanvas(pointTL,pointBR,calculate)},_containsCenterOfCanvas:function(pointTL,pointBR,calculate){var centerPoint={x:(pointTL.x+pointBR.x)/2,y:(pointTL.y+pointBR.y)/2};return!!this.containsPoint(centerPoint,null,!0,calculate)},isPartiallyOnScreen:function(calculate){if(!this.canvas)return!1;var pointTL=this.canvas.vptCoords.tl,pointBR=this.canvas.vptCoords.br;if(this.intersectsWithRect(pointTL,pointBR,!0,calculate))return!0;var allPointsAreOutside=this.getCoords(!0,calculate).every(function(point){return(point.x>=pointBR.x||point.x<=pointTL.x)&&(point.y>=pointBR.y||point.y<=pointTL.y)});return allPointsAreOutside&&this._containsCenterOfCanvas(pointTL,pointBR,calculate)},_getImageLines:function(oCoords){var lines={topline:{o:oCoords.tl,d:oCoords.tr},rightline:{o:oCoords.tr,d:oCoords.br},bottomline:{o:oCoords.br,d:oCoords.bl},leftline:{o:oCoords.bl,d:oCoords.tl}};return lines},_findCrossPoints:function(point,lines){var b1,b2,a1,a2,xi,xcount=0,iLine;for(var lineKey in lines)if(iLine=lines[lineKey],!(iLine.o.y<point.y&&iLine.d.y<point.y)&&!(iLine.o.y>=point.y&&iLine.d.y>=point.y)&&(iLine.o.x===iLine.d.x&&iLine.o.x>=point.x?xi=iLine.o.x:(b1=0,b2=(iLine.d.y-iLine.o.y)/(iLine.d.x-iLine.o.x),a1=point.y-b1*point.x,a2=iLine.o.y-b2*iLine.o.x,xi=-(a1-a2)/(b1-b2)),xi>=point.x&&(xcount+=1),xcount===2))break;return xcount},getBoundingRect:function(absolute,calculate){var coords=this.getCoords(absolute,calculate);return util.makeBoundingBoxFromPoints(coords)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(value){return Math.abs(value)<this.minScaleLimit?value<0?-this.minScaleLimit:this.minScaleLimit:value===0?1e-4:value},scale:function(value){return this._set("scaleX",value),this._set("scaleY",value),this.setCoords()},scaleToWidth:function(value,absolute){var boundingRectFactor=this.getBoundingRect(absolute).width/this.getScaledWidth();return this.scale(value/this.width/boundingRectFactor)},scaleToHeight:function(value,absolute){var boundingRectFactor=this.getBoundingRect(absolute).height/this.getScaledHeight();return this.scale(value/this.height/boundingRectFactor)},calcCoords:function(absolute){return absolute?this.calcACoords():this.calcOCoords()},calcLineCoords:function(){var vpt=this.getViewportTransform(),padding=this.padding,angle=degreesToRadians(this.angle),cos=util.cos(angle),sin=util.sin(angle),cosP=cos*padding,sinP=sin*padding,cosPSinP=cosP+sinP,cosPMinusSinP=cosP-sinP,aCoords=this.calcACoords(),lineCoords={tl:transformPoint(aCoords.tl,vpt),tr:transformPoint(aCoords.tr,vpt),bl:transformPoint(aCoords.bl,vpt),br:transformPoint(aCoords.br,vpt)};return padding&&(lineCoords.tl.x-=cosPMinusSinP,lineCoords.tl.y-=cosPSinP,lineCoords.tr.x+=cosPSinP,lineCoords.tr.y-=cosPMinusSinP,lineCoords.bl.x-=cosPSinP,lineCoords.bl.y+=cosPMinusSinP,lineCoords.br.x+=cosPMinusSinP,lineCoords.br.y+=cosPSinP),lineCoords},calcOCoords:function(){var rotateMatrix=this._calcRotateMatrix(),translateMatrix=this._calcTranslateMatrix(),vpt=this.getViewportTransform(),startMatrix=multiplyMatrices(vpt,translateMatrix),finalMatrix=multiplyMatrices(startMatrix,rotateMatrix),finalMatrix=multiplyMatrices(finalMatrix,[1/vpt[0],0,0,1/vpt[3],0,0]),dim=this._calculateCurrentDimensions(),coords={};return this.forEachControl(function(control,key,fabricObject){coords[key]=control.positionHandler(dim,finalMatrix,fabricObject)}),coords},calcACoords:function(){var rotateMatrix=this._calcRotateMatrix(),translateMatrix=this._calcTranslateMatrix(),finalMatrix=multiplyMatrices(translateMatrix,rotateMatrix),dim=this._getTransformedDimensions(),w=dim.x/2,h=dim.y/2;return{tl:transformPoint({x:-w,y:-h},finalMatrix),tr:transformPoint({x:w,y:-h},finalMatrix),bl:transformPoint({x:-w,y:h},finalMatrix),br:transformPoint({x:w,y:h},finalMatrix)}}
1,setCoords:function(skipCorners){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),skipCorners?this:(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords(),this)},_calcRotateMatrix:function(){return util.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var center=this.getCenterPoint();return[1,0,0,1,center.x,center.y]},transformMatrixKey:function(skipGroup){var sep="_",prefix="";return!skipGroup&&this.group&&(prefix=this.group.transformMatrixKey(skipGroup)+sep),prefix+this.top+sep+this.left+sep+this.scaleX+sep+this.scaleY+sep+this.skewX+sep+this.skewY+sep+this.angle+sep+this.originX+sep+this.originY+sep+this.width+sep+this.height+sep+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(skipGroup){var matrix=this.calcOwnMatrix();if(skipGroup||!this.group)return matrix;var key=this.transformMatrixKey(skipGroup),cache=this.matrixCache||(this.matrixCache={});return cache.key===key?cache.value:(this.group&&(matrix=multiplyMatrices(this.group.calcTransformMatrix(!1),matrix)),cache.key=key,cache.value=matrix,matrix)},calcOwnMatrix:function(){var key=this.transformMatrixKey(!0),cache=this.ownMatrixCache||(this.ownMatrixCache={});if(cache.key===key)return cache.value;var tMatrix=this._calcTranslateMatrix(),options={angle:this.angle,translateX:tMatrix[4],translateY:tMatrix[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return cache.key=key,cache.value=util.composeMatrix(options),cache.value},_calcDimensionsTransformMatrix:function(skewX,skewY,flipping){return util.calcDimensionsMatrix({skewX:skewX,skewY:skewY,scaleX:this.scaleX*(flipping&&this.flipX?-1:1),scaleY:this.scaleY*(flipping&&this.flipY?-1:1)})},_getNonTransformedDimensions:function(){var strokeWidth=this.strokeWidth,w=this.width+strokeWidth,h=this.height+strokeWidth;return{x:w,y:h}},_getTransformedDimensions:function(skewX,skewY){typeof skewX=="undefined"&&(skewX=this.skewX),typeof skewY=="undefined"&&(skewY=this.skewY);var dimensions=this._getNonTransformedDimensions(),dimX,dimY,noSkew=skewX===0&&skewY===0;if(this.strokeUniform?(dimX=this.width,dimY=this.height):(dimX=dimensions.x,dimY=dimensions.y),noSkew)return this._finalizeDimensions(dimX*this.scaleX,dimY*this.scaleY);var bbox=util.sizeAfterTransform(dimX,dimY,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:skewX,skewY:skewY});return this._finalizeDimensions(bbox.x,bbox.y)},_finalizeDimensions:function(width,height){return this.strokeUniform?{x:width+this.strokeWidth,y:height+this.strokeWidth}:{x:width,y:height}},_calculateCurrentDimensions:function(){var vpt=this.getViewportTransform(),dim=this._getTransformedDimensions(),p=transformPoint(dim,vpt,!0);return p.scalarAdd(2*this.padding)}})})(),fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){return this.group?fabric.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?fabric.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(intersecting){return this.group?fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,intersecting):this.canvas&&this.canvas.sendBackwards(this,intersecting),this},bringForward:function(intersecting){return this.group?fabric.StaticCanvas.prototype.bringForward.call(this.group,this,intersecting):this.canvas&&this.canvas.bringForward(this,intersecting),this},moveTo:function(index){return this.group&&this.group.type!=="activeSelection"?fabric.StaticCanvas.prototype.moveTo.call(this.group,this,index):this.canvas&&this.canvas.moveTo(this,index),this}}),(function(){function getSvgColorString(prop,value){if(value){if(value.toLive)return prop+": url(#SVGID_"+value.id+"); ";var color=new fabric.Color(value),str=prop+": "+color.toRgb()+"; ",opacity=color.getAlpha();return opacity!==1&&(str+=prop+"-opacity: "+opacity.toString()+"; "),str}else return prop+": none; "}var toFixed=fabric.util.toFixed;fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(skipShadow){var fillRule=this.fillRule?this.fillRule:"nonzero",strokeWidth=this.strokeWidth?this.strokeWidth:"0",strokeDashArray=this.strokeDashArray?this.strokeDashArray.join(" "):"none",strokeDashOffset=this.strokeDashOffset?this.strokeDashOffset:"0",strokeLineCap=this.strokeLineCap?this.strokeLineCap:"butt",strokeLineJoin=this.strokeLineJoin?this.strokeLineJoin:"miter",strokeMiterLimit=this.strokeMiterLimit?this.strokeMiterLimit:"4",opacity=typeof this.opacity!="undefined"?this.opacity:"1",visibility=this.visible?"":" visibility: hidden;",filter=skipShadow?"":this.getSvgFilter(),fill=getSvgColorString("fill",this.fill),stroke=getSvgColorString("stroke",this.stroke);return[stroke,"stroke-width: ",strokeWidth,"; ","stroke-dasharray: ",strokeDashArray,"; ","stroke-linecap: ",strokeLineCap,"; ","stroke-dashoffset: ",strokeDashOffset,"; ","stroke-linejoin: ",strokeLineJoin,"; ","stroke-miterlimit: ",strokeMiterLimit,"; ",fill,"fill-rule: ",fillRule,"; ","opacity: ",opacity,";",filter,visibility].join("")},getSvgSpanStyles:function(style,useWhiteSpace){var term="; ",fontFamily=style.fontFamily?"font-family: "+(style.fontFamily.indexOf("'")===-1&&style.fontFamily.indexOf('"')===-1?"'"+style.fontFamily+"'":style.fontFamily)+term:"",strokeWidth=style.strokeWidth?"stroke-width: "+style.strokeWidth+term:"",fontFamily=fontFamily,fontSize=style.fontSize?"font-size: "+style.fontSize+"px"+term:"",fontStyle=style.fontStyle?"font-style: "+style.fontStyle+term:"",fontWeight=style.fontWeight?"font-weight: "+style.fontWeight+term:"",fill=style.fill?getSvgColorString("fill",style.fill):"",stroke=style.stroke?getSvgColorString("stroke",style.stroke):"",textDecoration=this.getSvgTextDecoration(style),deltaY=style.deltaY?"baseline-shift: "+-style.deltaY+"; ":"";return textDecoration&&(textDecoration="text-decoration: "+textDecoration+term),[stroke,strokeWidth,fontFamily,fontSize,fontStyle,fontWeight,textDecoration,fill,deltaY,useWhiteSpace?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(style){return["overline","underline","line-through"].filter(function(decoration){return style[decoration.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""}
1,getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(full,additionalTransform){var transform=full?this.calcTransformMatrix():this.calcOwnMatrix(),svgTransform='transform="'+fabric.util.matrixToSVG(transform);return svgTransform+(additionalTransform||"")+'" '},_setSVGBg:function(textBgRects){if(this.backgroundColor){var NUM_FRACTION_DIGITS=fabric.Object.NUM_FRACTION_DIGITS;textBgRects.push("		<rect ",this._getFillAttributes(this.backgroundColor),' x="',toFixed(-this.width/2,NUM_FRACTION_DIGITS),'" y="',toFixed(-this.height/2,NUM_FRACTION_DIGITS),'" width="',toFixed(this.width,NUM_FRACTION_DIGITS),'" height="',toFixed(this.height,NUM_FRACTION_DIGITS),'"></rect>\n')}},toSVG:function(reviver){return this._createBaseSVGMarkup(this._toSVG(reviver),{reviver:reviver})},toClipPathSVG:function(reviver){return"	"+this._createBaseClipPathSVGMarkup(this._toSVG(reviver),{reviver:reviver})},_createBaseClipPathSVGMarkup:function(objectMarkup,options){options=options||{};var reviver=options.reviver,additionalTransform=options.additionalTransform||"",commonPieces=[this.get
1SvgTransform(!0,additionalTransform),this.getSvgCommons()].join(""),index=objectMarkup.indexOf("COMMON_PARTS");return objectMarkup[index]=commonPieces,reviver?reviver(objectMarkup.join("")):objectMarkup.join("")},_createBaseSVGMarkup:function(objectMarkup,options){options=options||{};var noStyle=options.noStyle,reviver=options.reviver,styleInfo=noStyle?"":'style="'+this.getSvgStyles()+'" ',shadowInfo=options.withShadow?'style="'+this.getSvgFilter()+'" ':"",clipPath=this.clipPath,vectorEffect=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",absoluteClipPath=clipPath&&clipPath.absolutePositioned,stroke=this.stroke,fill=this.fill,shadow=this.shadow,commonPieces,markup=[],clipPathMarkup,index=objectMarkup.indexOf("COMMON_PARTS"),additionalTransform=options.additionalTransform;return clipPath&&(clipPath.clipPathId="CLIPPATH_"+fabric.Object.__uid++,clipPathMarkup='<clipPath id="'+clipPath.clipPathId+'" >\n'+clipPath.toClipPathSVG(reviver)+"</clipPath>\n"),absoluteClipPath&&markup.push("<g ",shadowInfo,this.getSvgCommons()," >\n"),markup.push("<g ",this.getSvgTransform(!1),absoluteClipPath?"":shadowInfo+this.getSvgCommons()," >\n"),commonPieces=[styleInfo,vectorEffect,noStyle?"":this.addPaintOrder()," ",additionalTransform?'transform="'+additionalTransform+'" ':""].join(""),objectMarkup[index]=commonPieces,fill&&fill.toLive&&markup.push(fill.toSVG(this)),stroke&&stroke.toLive&&markup.push(stroke.toSVG(this)),shadow&&markup.push(shadow.toSVG(this)),clipPath&&markup.push(clipPathMarkup),markup.push(objectMarkup.join("")),markup.push("</g>\n"),absoluteClipPath&&markup.push("</g>\n"),reviver?reviver(markup.join("")):markup.join("")},addPaintOrder:function(){return this.paintFirst!=="fill"?' paint-order="'+this.paintFirst+'" ':""}})})(),(function(){var extend=fabric.util.object.extend,originalSet="stateProperties";function saveProps(origin,destination,props){var tmpObj={},deep=!0;props.forEach(function(prop){tmpObj[prop]=origin[prop]}),extend(origin[destination],tmpObj,deep)}function _isEqual(origValue,currentValue,firstPass){if(origValue===currentValue)return!0;if(Array.isArray(origValue)){if(!Array.isArray(currentValue)||origValue.length!==currentValue.length)return!1;for(var i=0,len=origValue.length;i<len;i++)if(!_isEqual(origValue[i],currentValue[i]))return!1;return!0}else if(origValue&&typeof origValue=="object"){var keys=Object.keys(origValue),key;if(!currentValue||typeof currentValue!="object"||!firstPass&&keys.length!==Object.keys(currentValue).length)return!1;for(var i=0,len=keys.length;i<len;i++)if(key=keys[i],!(key==="canvas"||key==="group")&&!_isEqual(origValue[key],currentValue[key]))return!1;return!0}}fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(propertySet){propertySet=propertySet||originalSet;var dashedPropertySet="_"+propertySet;return Object.keys(this[dashedPropertySet]).length<this[propertySet].length?!0:!_isEqual(this[dashedPropertySet],this,!0)},saveState:function(options){var propertySet=options&&options.propertySet||originalSet,destination="_"+propertySet;return this[destination]?(saveProps(this,destination,this[propertySet]),options&&options.stateProperties&&saveProps(this,destination,options.stateProperties),this):this.setupState(options)},setupState:function(options){options=options||{};var propertySet=options.propertySet||originalSet;return options.propertySet=propertySet,this["_"+propertySet]={},this.saveState(options),this}})})(),(function(){var degreesToRadians=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{_findTargetCorner:function(pointer,forTouch){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var ex=pointer.x,ey=pointer.y,xPoints,lines,keys=Object.keys(this.oCoords),j=keys.length-1,i;for(this.__corner=0;j>=0;j--)if(i=keys[j],!!this.isControlVisible(i)&&(lines=this._getImageLines(forTouch?this.oCoords[i].touchCorner:this.oCoords[i].corner),xPoints=this._findCrossPoints({x:ex,y:ey},lines),xPoints!==0&&xPoints%2===1))return this.__corner=i,i;return!1},forEachControl:function(fn){for(var i in this.controls)fn(this.controls[i],i,this)},_setCornerCoords:function(){var coords=this.oCoords,newTheta=degreesToRadians(45-this.angle),cosTheta=fabric.util.cos(newTheta),sinTheta=fabric.util.sin(newTheta),cornerHypotenuse=this.cornerSize*.707106,touchHypotenuse=this.touchCornerSize*.707106,cosHalfOffset=cornerHypotenuse*cosTheta,sinHalfOffset=cornerHypotenuse*sinTheta,touchCosHalfOffset=touchHypotenuse*cosTheta,touchSinHalfOffset=touchHypotenuse*sinTheta,x,y;for(var control in coords)x=coords[control].x,y=coords[control].y,coords[control].corner={tl:{x:x-sinHalfOffset,y:y-cosHalfOffset},tr:{x:x+cosHalfOffset,y:y-sinHalfOffset},bl:{x:x-cosHalfOffset,y:y+sinHalfOffset},br:{x:x+sinHalfOffset,y:y+cosHalfOffset}},coords[control].touchCorner={tl:{x:x-touchSinHalfOffset,y:y-touchCosHalfOffset},tr:{x:x+touchCosHalfOffset,y:y-touchSinHalfOffset},bl:{x:x-touchCosHalfOffset,y:y+touchSinHalfOffset},br:{x:x+touchSinHalfOffset,y:y+touchCosHalfOffset}}}
1,drawSelectionBackground:function(ctx){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;ctx.save();var center=this.getCenterPoint(),wh=this._calculateCurrentDimensions(),vpt=this.canvas.viewportTransform;return ctx.translate(center.x,center.y),ctx.scale(1/vpt[0],1/vpt[3]),ctx.rotate(degreesToRadians(this.angle)),ctx.fillStyle=this.selectionBackgroundColor,ctx.fillRect(-wh.x/2,-wh.y/2,wh.x,wh.y),ctx.restore(),this},drawBorders:function(ctx,styleOverride){styleOverride=styleOverride||{};var wh=this._calculateCurrentDimensions(),strokeWidth=this.borderScaleFactor,width=wh.x+strokeWidth,height=wh.y+strokeWidth,hasControls=typeof styleOverride.hasControls!="undefined"?styleOverride.hasControls:this.hasControls,shouldStroke=!1;return ctx.save(),ctx.strokeStyle=styleOverride.borderColor||this.borderColor,this._setLineDash(ctx,styleOverride.borderDashArray||this.borderDashArray,null),ctx.strokeRect(-width/2,-height/2,width,height),hasControls&&(ctx.beginPath(),this.forEachControl(function(control,key,fabricObject){control.withConnection&&control.getVisibility(fabricObject,key)&&(shouldStroke=!0,ctx.moveTo(control.x*width,control.y*height),ctx.lineTo(control.x*width+control.offsetX,control.y*height+control.offsetY))}),shouldStroke&&ctx.stroke()),ctx.restore(),this},drawBordersInGroup:function(ctx,options,styleOverride){styleOverride=styleOverride||{};var bbox=fabric.util.sizeAfterTransform(this.width,this.height,options),strokeWidth=this.strokeWidth,strokeUniform=this.strokeUniform,borderScaleFactor=this.borderScaleFactor,width=bbox.x+strokeWidth*(strokeUniform?this.canvas.getZoom():options.scaleX)+borderScaleFactor,height=bbox.y+strokeWidth*(strokeUniform?this.canvas.getZoom():options.scaleY)+borderScaleFactor;return ctx.save(),this._setLineDash(ctx,styleOverride.borderDashArray||this.borderDashArray,null),ctx.strokeStyle=styleOverride.borderColor||this.borderColor,ctx.strokeRect(-width/2,-height/2,width,height),ctx.restore(),this},drawControls:function(ctx,styleOverride){return styleOverride=styleOverride||{},ctx.save(),ctx.setTransform(this.canvas.getRetinaScaling(),0,0,this.canvas.getRetinaScaling(),0,0),ctx.strokeStyle=ctx.fillStyle=styleOverride.cornerColor||this.cornerColor,this.transparentCorners||(ctx.strokeStyle=styleOverride.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(ctx,styleOverride.cornerDashArray||this.cornerDashArray,null),this.setCoords(),this.forEachControl(function(control,key,fabricObject){control.getVisibility(fabricObject,key)&&control.render(ctx,fabricObject.oCoords[key].x,fabricObject.oCoords[key].y,styleOverride,fabricObject)}),ctx.restore(),this},isControlVisible:function(controlKey){return this.controls[controlKey]&&this.controls[controlKey].getVisibility(this,controlKey)},setControlVisible:function(controlKey,visible){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[controlKey]=visible,this},setControlsVisibility:function(options){options||(options={});for(var p in options)this.setControlVisible(p,options[p]);return this},onDeselect:function(){},onSelect:function(){}})})(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(object,callbacks){callbacks=callbacks||{};var empty=function(){},onComplete=callbacks.onComplete||empty,onChange=callbacks.onChange||empty,_this=this;return fabric.util.animate({startValue:object.left,endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(value){object.set("left",value),_this.requestRenderAll(),onChange()},onComplete:function(){object.setCoords(),onComplete()}}),this},fxCenterObjectV:function(object,callbacks){callbacks=callbacks||{};var empty=function(){},onComplete=callbacks.onComplete||empty,onChange=callbacks.onChange||empty,_this=this;return fabric.util.animate({startValue:object.top,endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(value){object.set("top",value),_this.requestRenderAll(),onChange()},onComplete:function(){object.setCoords(),onComplete()}}),this},fxRemove:function(object,callbacks){callbacks=callbacks||{};var empty=function(){},onComplete=callbacks.onComplete||empty,onChange=callbacks.onChange||empty,_this=this;return fabric.util.animate({startValue:object.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(value){object.set("opacity",value),_this.requestRenderAll(),onChange()},onComplete:function(){_this.remove(object),onComplete()}}),this}}),fabric.util.object.extend(fabric.Object.prototype,{animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var propsToAnimate=[],prop,skipCallbacks;for(prop in arguments[0])propsToAnimate.push(prop);for(var i=0,len=propsToAnimate.length;i<len;i++)prop=propsToAnimate[i],skipCallbacks=i!==len-1,this._animate(prop,arguments[0][prop],arguments[1],skipCallbacks)}else this._animate.apply(this,arguments);return this},_animate:function(property,to,options,skipCallbacks){var _this=this,propPair;to=to.toString(),options?options=fabric.util.object.clone(options):options={},~property.indexOf(".")&&(propPair=property.split("."));var propIsColor=_this.colorProperties.indexOf(property)>-1||propPair&&_this.colorProperties.indexOf(propPair[1])>-1,currentValue=propPair?this.get(propPair[0])[propPair[1]]:this.get(property);"from"in options||(options.from=currentValue),propIsColor||(~to.indexOf("=")?to=currentValue+parseFloat(to.replace("=","")):to=parseFloat(to));var _options={startValue:options.from,endValue:to,byValue:options.by,easing:options.easing,duration:options.duration,abort:
1options.abort&&function(){return options.abort.call(_this)},onChange:function(value,valueProgress,timeProgress){propPair?_this[propPair[0]][propPair[1]]=value:_this.set(property,value),!skipCallbacks&&options.onChange&&options.onChange(value,valueProgress,timeProgress)},onComplete:function(value,valueProgress,timeProgress){skipCallbacks||(_this.setCoords(),options.onComplete&&options.onComplete(value,valueProgress,timeProgress))}};propIsColor?fabric.util.animateColor(_options.startValue,_options.endValue,_options.duration,_options):fabric.util.animate(_options)}}),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,clone=fabric2.util.object.clone,coordProps={x1:1,x2:1,y1:1,y2:1},supportsLineDash=fabric2.StaticCanvas.supports("setLineDash");if(fabric2.Line){fabric2.warn("fabric.Line is already defined");return}fabric2.Line=fabric2.util.createClass(fabric2.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(points,options){points||(points=[0,0,0,0]),this.callSuper("initialize",options),this.set("x1",points[0]),this.set("y1",points[1]),this.set("x2",points[2]),this.set("y2",points[3]),this._setWidthHeight(options)},_setWidthHeight:function(options){options||(options={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in options?options.left:this._getLeftToOriginX(),this.top="top"in options?options.top:this._getTopToOriginY()},_set:function(key,value){return this.callSuper("_set",key,value),typeof coordProps[key]!="undefined"&&this._setWidthHeight(),this},_getLeftToOriginX:makeEdgeToOriginGetter({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:makeEdgeToOriginGetter({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(ctx){if(ctx.beginPath(),!this.strokeDashArray||this.strokeDashArray&&supportsLineDash){var p=this.calcLinePoints();ctx.moveTo(p.x1,p.y1),ctx.lineTo(p.x2,p.y2)}ctx.lineWidth=this.strokeWidth;var origStrokeStyle=ctx.strokeStyle;ctx.strokeStyle=this.stroke||ctx.fillStyle,this.stroke&&this._renderStroke(ctx),ctx.strokeStyle=origStrokeStyle},_renderDashedStroke:function(ctx){var p=this.calcLinePoints();ctx.beginPath(),fabric2.util.drawDashedLine(ctx,p.x1,p.y1,p.x2,p.y2,this.strokeDashArray),ctx.closePath()},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(propertiesToInclude){return extend(this.callSuper("toObject",propertiesToInclude),this.calcLinePoints())},_getNonTransformedDimensions:function(){var dim=this.callSuper("_getNonTransformedDimensions");return this.strokeLineCap==="butt"&&(this.width===0&&(dim.y-=this.strokeWidth),this.height===0&&(dim.x-=this.strokeWidth)),dim},calcLinePoints:function(){var xMult=this.x1<=this.x2?-1:1,yMult=this.y1<=this.y2?-1:1,x1=xMult*this.width*.5,y1=yMult*this.height*.5,x2=xMult*this.width*-.5,y2=yMult*this.height*-.5;return{x1:x1,x2:x2,y1:y1,y2:y2}},_toSVG:function(){var p=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',p.x1,'" y1="',p.y1,'" x2="',p.x2,'" y2="',p.y2,'" />\n']}}),fabric2.Line.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),fabric2.Line.fromElement=function(element,callback,options){options=options||{};var parsedAttributes=fabric2.parseAttributes(element,fabric2.Line.ATTRIBUTE_NAMES),points=[parsedAttributes.x1||0,parsedAttributes.y1||0,parsedAttributes.x2||0,parsedAttributes.y2||0];callback(new fabric2.Line(points,extend(parsedAttributes,options)))},fabric2.Line.fromObject=function(object,callback){function _callback(instance){delete instance.points,callback&&callback(instance)}var options=clone(object,!0);options.points=[object.x1,object.y1,object.x2,object.y2],fabric2.Object._fromObject("Line",options,_callback,"points")};function makeEdgeToOriginGetter(propertyNames,originValues){var origin=propertyNames.origin,axis1=propertyNames.axis1,axis2=propertyNames.axis2,dimension=propertyNames.dimension,nearest=originValues.nearest,center=originValues.center,farthest=originValues.farthest;return function(){switch(this.get(origin)){case nearest:return Math.min(this.get(axis1),this.get(axis2));case center:return Math.min(this.get(axis1),this.get(axis2))+.5*this.get(dimension);case farthest:return Math.max(this.get(axis1),this.get(axis2))}}}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),pi=Math.PI;if(fabric2.Circle){fabric2.warn("fabric.Circle is already defined.");return}fabric2.Circle=fabric2.util.createClass(fabric2.Object,{type:"circle",radius:0,startAngle:0,endAngle:pi*2,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set
1:function(key,value){return this.callSuper("_set",key,value),key==="radius"&&this.setRadius(value),this},toObject:function(propertiesToInclude){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(propertiesToInclude))},_toSVG:function(){var svgString,x=0,y=0,angle=(this.endAngle-this.startAngle)%(2*pi);if(angle===0)svgString=["<circle ","COMMON_PARTS",'cx="'+x+'" cy="'+y+'" ','r="',this.radius,'" />\n'];else{var startX=fabric2.util.cos(this.startAngle)*this.radius,startY=fabric2.util.sin(this.startAngle)*this.radius,endX=fabric2.util.cos(this.endAngle)*this.radius,endY=fabric2.util.sin(this.endAngle)*this.radius,largeFlag=angle>pi?"1":"0";svgString=['<path d="M '+startX+" "+startY," A "+this.radius+" "+this.radius," 0 ",+largeFlag+" 1"," "+endX+" "+endY,'" ',"COMMON_PARTS"," />\n"]}return svgString},_render:function(ctx){ctx.beginPath(),ctx.arc(0,0,this.radius,this.startAngle,this.endAngle,!1),this._renderPaintInOrder(ctx)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(value){return this.radius=value,this.set("width",value*2).set("height",value*2)}}),fabric2.Circle.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),fabric2.Circle.fromElement=function(element,callback){var parsedAttributes=fabric2.parseAttributes(element,fabric2.Circle.ATTRIBUTE_NAMES);if(!isValidRadius(parsedAttributes))throw new Error("value of `r` attribute is required and can not be negative");parsedAttributes.left=(parsedAttributes.left||0)-parsedAttributes.radius,parsedAttributes.top=(parsedAttributes.top||0)-parsedAttributes.radius,callback(new fabric2.Circle(parsedAttributes))};function isValidRadius(attributes){return"radius"in attributes&&attributes.radius>=0}fabric2.Circle.fromObject=function(object,callback){return fabric2.Object._fromObject("Circle",object,callback)}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});if(fabric2.Triangle){fabric2.warn("fabric.Triangle is already defined");return}fabric2.Triangle=fabric2.util.createClass(fabric2.Object,{type:"triangle",width:100,height:100,_render:function(ctx){var widthBy2=this.width/2,heightBy2=this.height/2;ctx.beginPath(),ctx.moveTo(-widthBy2,heightBy2),ctx.lineTo(0,-heightBy2),ctx.lineTo(widthBy2,heightBy2),ctx.closePath(),this._renderPaintInOrder(ctx)},_renderDashedStroke:function(ctx){var widthBy2=this.width/2,heightBy2=this.height/2;ctx.beginPath(),fabric2.util.drawDashedLine(ctx,-widthBy2,heightBy2,0,-heightBy2,this.strokeDashArray),fabric2.util.drawDashedLine(ctx,
10,-heightBy2,widthBy2,heightBy2,this.strokeDashArray),fabric2.util.drawDashedLine(ctx,widthBy2,heightBy2,-widthBy2,heightBy2,this.strokeDashArray),ctx.closePath()},_toSVG:function(){var widthBy2=this.width/2,heightBy2=this.height/2,points=[-widthBy2+" "+heightBy2,"0 "+-heightBy2,widthBy2+" "+heightBy2].join(",");return["<polygon ","COMMON_PARTS",'points="',points,'" />']}}),fabric2.Triangle.fromObject=function(object,callback){return fabric2.Object._fromObject("Triangle",object,callback)}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),piBy2=Math.PI*2;if(fabric2.Ellipse){fabric2.warn("fabric.Ellipse is already defined.");return}fabric2.Ellipse=fabric2.util.createClass(fabric2.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(options){this.callSuper("initialize",options),this.set("rx",options&&options.rx||0),this.set("ry",options&&options.ry||0)},_set:function(key,value){switch(this.callSuper("_set",key,value),key){case"rx":this.rx=value,this.set("width",value*2);break;case"ry":this.ry=value,this.set("height",value*2);break}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(propertiesToInclude){return this.callSuper("toObject",["rx","ry"].concat(propertiesToInclude))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,'" />\n']},_render:function(ctx){ctx.beginPath(),ctx.save(),ctx.transform(1,0,0,this.ry/this.rx,0,0),ctx.arc(0,0,this.rx,0,piBy2,!1),ctx.restore(),this._renderPaintInOrder(ctx)}}),fabric2.Ellipse.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),fabric2.Ellipse.fromElement=function(element,callback){var parsedAttributes=fabric2.parseAttributes(element,fabric2.Ellipse.ATTRIBUTE_NAMES);parsedAttributes.left=(parsedAttributes.left||0)-parsedAttributes.rx,parsedAttributes.top=(parsedAttributes.top||0)-parsedAttributes.ry,callback(new fabric2.Ellipse(parsedAttributes))},fabric2.Ellipse.fromObject=function(object,callback){return fabric2.Object._fromObject("Ellipse",object,callback)}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend;if(fabric2.Rect){fabric2.warn("fabric.Rect is already defined");return}fabric2.Rect=fabric2.util.createClass(fabric2.Object,{stateProperties:fabric2.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(options){this.callSuper("initialize",options),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(ctx){var rx=this.rx?Math.min(this.rx,this.width/2):0,ry=this.ry?Math.min(this.ry,this.height/2):0,w=this.width,h=this.height,x=-this.width/2,y=-this.height/2,isRounded=rx!==0||ry!==0,k=1-.5522847498;ctx.beginPath(),ctx.moveTo(x+rx,y),ctx.lineTo(x+w-rx,y),isRounded&&ctx.bezierCurveTo(x+w-k*rx,y,x+w,y+k*ry,x+w,y+ry),ctx.lineTo(x+w,y+h-ry),isRounded&&ctx.bezierCurveTo(x+w,y+h-k*ry,x+w-k*rx,y+h,x+w-rx,y+h),ctx.lineTo(x+rx,y+h),isRounded&&ctx.bezierCurveTo(x+k*rx,y+h,x,y+h-k*ry,x,y+h-ry),ctx.lineTo(x,y+ry),isRounded&&ctx.bezierCurveTo(x,y+k*ry,x+k*rx,y,x+rx,y),ctx.closePath(),this._renderPaintInOrder(ctx)},_renderDashedStroke:function(ctx){var x=-this.width/2,y=-this.height/2,w=this.width,h=this.height;ctx.beginPath(),fabric2.util.drawDashedLine(ctx,x,y,x+w,y,this.strokeDashArray),fabric2.util.drawDashedLine(ctx,x+w,y,x+w,y+h,this.strokeDashArray),fabric2.util.drawDashedLine(ctx,x+w,y+h,x,y+h,this.strokeDashArray),fabric2.util.drawDashedLine(ctx,x,y+h,x,y,this.strokeDashArray),ctx.closePath()},toObject:function(propertiesToInclude){return this.callSuper("toObject",["rx","ry"].concat(propertiesToInclude))},_toSVG:function(){var x=-this.width/2,y=-this.height/2;return["<rect ","COMMON_PARTS",'x="',x,'" y="',y,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,'" />\n']}}),fabric2.Rect.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),fabric2.Rect.fromElement=function(element,callback,options){if(!element)return callback(null);
1options=options||{};var parsedAttributes=fabric2.parseAttributes(element,fabric2.Rect.ATTRIBUTE_NAMES);parsedAttributes.left=parsedAttributes.left||0,parsedAttributes.top=parsedAttributes.top||0,parsedAttributes.height=parsedAttributes.height||0,parsedAttributes.width=parsedAttributes.width||0;var rect=new fabric2.Rect(extend(options?fabric2.util.object.clone(options):{},parsedAttributes));rect.visible=rect.visible&&rect.width>0&&rect.height>0,callback(rect)},fabric2.Rect.fromObject=function(object,callback){return fabric2.Object._fromObject("Rect",object,callback)}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,min=fabric2.util.array.min,max=fabric2.util.array.max,toFixed=fabric2.util.toFixed;if(fabric2.Polyline){fabric2.warn("fabric.Polyline is already defined");return}fabric2.Polyline=fabric2.util.createClass(fabric2.Object,{type:"polyline",points:null,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("points"),initialize:function(points,options){options=options||{},this.points=points||[],this.callSuper("initialize",options),this._setPositionDimensions(options)},_setPositionDimensions:function(options){var calcDim=this._calcDimensions(options),correctLeftTop;this.width=calcDim.width,this.height=calcDim.height,options.fromSVG||(correctLeftTop=this.translateToGivenOrigin({x:calcDim.left-this.strokeWidth/2,y:calcDim.top-this.strokeWidth/2},"left","top",this.originX,this.originY)),typeof options.left=="undefined"&&(this.left=options.fromSVG?calcDim.left:correctLeftTop.x),typeof options.top=="undefined"&&(this.top=options.fromSVG?calcDim.top:correctLeftTop.y),this.pathOffset={x:calcDim.left+this.width/2,y:calcDim.top+this.height/2}},_calcDimensions:function(){var points=this.points,minX=min(points,"x")||0,minY=min(points,"y")||0,maxX=max(points,"x")||0,maxY=max(points,"y")||0,width=maxX-minX,height=maxY-minY;return{left:minX,top:minY,width:width,height:height}},toObject:function(propertiesToInclude){return extend(this.callSuper("toObject",propertiesToInclude),{points:this.points.concat()})},_toSVG:function(){for(var points=[],diffX=this.pathOffset.x,diffY=this.pathOffset.y,NUM_FRACTION_DIGITS=fabric2.Object.NUM_FRACTION_DIGITS,i=0,len=this.points.length;i<len;i++)points.push(toFixed(this.points[i].x-diffX,NUM_FRACTION_DIGITS),",",toFixed(this.points[i].y-diffY,NUM_FRACTION_DIGITS)," ");
1return["<"+this.type+" ","COMMON_PARTS",'points="',points.join(""),'" />\n']},commonRender:function(ctx){var point,len=this.points.length,x=this.pathOffset.x,y=this.pathOffset.y;if(!len||isNaN(this.points[len-1].y))return!1;ctx.beginPath(),ctx.moveTo(this.points[0].x-x,this.points[0].y-y);for(var i=0;i<len;i++)point=this.points[i],ctx.lineTo(point.x-x,point.y-y);return!0},_render:function(ctx){this.commonRender(ctx)&&this._renderPaintInOrder(ctx)},_renderDashedStroke:function(ctx){var p1,p2;ctx.beginPath();for(var i=0,len=this.points.length;i<len;i++)p1=this.points[i],p2=this.points[i+1]||p1,fabric2.util.drawDashedLine(ctx,p1.x,p1.y,p2.x,p2.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}}),fabric2.Polyline.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat(),fabric2.Polyline.fromElementGenerator=function(_class){return function(element,callback,options){if(!element)return callback(null);options||(options={});var points=fabric2.parsePointsAttribute(element.getAttribute("points")),parsedAttributes=fabric2.parseAttributes(element,fabric2[_class].ATTRIBUTE_NAMES);parsedAttributes.fromSVG=!0,callback(new fabric2[_class](points,extend(parsedAttributes,options)))}},fabric2.Polyline.fromElement=fabric2.Polyline.fromElementGenerator("Polyline"),fabric2.Polyline.fromObject=function(object,callback){return fabric2.Object._fromObject("Polyline",object,callback,"points")}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});if(fabric2.Polygon){fabric2.warn("fabric.Polygon is already defined");return}fabric2.Polygon=fabric2.util.createClass(fabric2.Polyline,{type:"polygon",_render:function(ctx){this.commonRender(ctx)&&(ctx.closePath(),this._renderPaintInOrder(ctx))},_renderDashedStroke:function(ctx){this.callSuper("_renderDashedStroke",ctx),ctx.closePath()}}),fabric2.Polygon.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat(),fabric2.Polygon.fromElement=fabric2.Polyline.fromElementGenerator("Polygon"),fabric2.Polygon.fromObject=function(object,callback){return fabric2.Object._fromObject("Polygon",object,callback,"points")}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),min=fabric2.util.array.min,max=fabric2.util.array.max,extend=fabric2.util.object.extend,_toString=Object.prototype.toString,toFixed=fabric2.util.toFixed;if(fabric2.Path){fabric2.warn("fabric.Path is already defined");return}fabric2.Path=fabric2.util.createClass(fabric2.Object,{type:"path",path:null,cacheProperties:fabric2.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:fabric2.Object.prototype.stateProperties.concat("path"),initialize:function(path,options){options=options||{},this.callSuper("initialize",options),path||(path=[]);var fromArray=_toString.call(path)==="[object Array]";this.path=fromArray?fabric2.util.makePathSimpler(path):fabric2.util.makePathSimpler(fabric2.util.parsePath(path)),this.path&&fabric2.Polyline.prototype._setPositionDimensions.call(this,options)},_renderPathCommands:function(ctx){var current,subpathStartX=0,subpathStartY=0,x=0,y=0,controlX=0,controlY=0,l=-this.pathOffset.x,t=-this.pathOffset.y;ctx.beginPath();for(var i=0,len=this.path.length;i<len;++i)switch(current=this.path[i],current[0]){case"L":x=current[1],y=current[2],ctx.lineTo(x+l,y+t);break;case"M":x=current[1],y=current[2],subpathStartX=x,subpathStartY=y,ctx.moveTo(x+l,y+t);break;case"C":x=current[5],y=current[6],controlX=current[3],controlY=current[4],ctx.bezierCurveTo(current[1]+l,current[2]+t,controlX+l,controlY+t,x+l,y+t);break;case"Q":ctx.quadraticCurveTo(current[1]+l,current[2]+t,current[3]+l,current[4]+t),x=current[3],y=current[4],controlX=current[1],controlY=current[2];break;case"z":case"Z":x=subpathStartX,y=subpathStartY,ctx.closePath();break}},_render:function(ctx){this._renderPathCommands(ctx),this._renderPaintInOrder(ctx)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(propertiesToInclude){return extend(this.callSuper("toObject",propertiesToInclude),{path:this.path.map(function(item){return item.slice()})})},toDatalessObject:function(propertiesToInclude){var o=this.toObject(["sourcePath"].concat(propertiesToInclude));return o.sourcePath&&delete o.path,o},_toSVG:function(){var path=this.path.map(function(path2){return path2.join(" ")}).join(" ");return["<path ","COMMON_PARTS",'d="',path,'" stroke-linecap="round" ',"/>\n"]},_getOffsetTransform:function(){var digits=fabric2.Object.NUM_FRACTION_DIGITS;return" translate("+toFixed(-this.pathOffset.x,digits)+", "+toFixed(-this.pathOffset.
1y,digits)+")"},toClipPathSVG:function(reviver){var additionalTransform=this._getOffsetTransform();return"	"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:reviver,additionalTransform:additionalTransform})},toSVG:function(reviver){var additionalTransform=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:reviver,additionalTransform:additionalTransform})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var aX=[],aY=[],current,subpathStartX=0,subpathStartY=0,x=0,y=0,bounds,i=0,len=this.path.length;i<len;++i){switch(current=this.path[i],current[0]){case"L":x=current[1],y=current[2],bounds=[];break;case"M":x=current[1],y=current[2],subpathStartX=x,subpathStartY=y,bounds=[];break;case"C":bounds=fabric2.util.getBoundsOfCurve(x,y,current[1],current[2],current[3],current[4],current[5],current[6]),x=current[5],y=current[6];break;case"Q":bounds=fabric2.util.getBoundsOfCurve(x,y,current[1],current[2],current[1],current[2],current[3],current[4]),x=current[3],y=current[4];break;case"z":case"Z":x=subpathStartX,y=subpathStartY;break}bounds.forEach(function(point){aX.push(point.x),aY.push(point.y)}),aX.push(x),aY.push(y)}var minX=min(aX)||0,minY=min(aY)||0,maxX=max(aX)||0,maxY=max(aY)||0,deltaX=maxX-minX,deltaY=maxY-minY;return{left:minX,top:minY,width:deltaX,height:deltaY}}}),fabric2.Path.fromObject=function(object,callback){if(typeof object.sourcePath=="string"){var pathUrl=object.sourcePath;fabric2.loadSVGFromURL(pathUrl,function(elements){var path=elements[0];path.setOptions(object),callback&&callback(path)})}else fabric2.Object._fromObject("Path",object,callback,"path")},fabric2.Path.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat(["d"]),fabric2.Path.fromElement=function(element,callback,options){var parsedAttributes=fabric2.parseAttributes(element,fabric2.Path.ATTRIBUTE_NAMES);parsedAttributes.fromSVG=!0,callback(new fabric2.Path(parsedAttributes.d,extend(parsedAttributes,options)))}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),min=fabric2.util.array.min,max=fabric2.util.array.max;fabric2.Group||(fabric2.Group=fabric2.util.createClass(fabric2.Object,fabric2.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(objects,options,isAlreadyGrouped){options=options||{},this._objects=[],isAlreadyGrouped&&this.callSuper("initialize",options),this._objects=objects||[];for(var i=this._objects.length;i--;)this._objects[i].group=this;if(isAlreadyGrouped)this._updateObjectsACoords();else{var center=options&&options.centerPoint;options.originX!==void 0&&(this.originX=options.originX),options.originY!==void 0&&(this.originY=options.originY),center||this._calcBounds(),this._updateObjectsCoords(center),delete options.centerPoint,this.callSuper("initialize",options)}this.setCoords()},_updateObjectsACoords:function(){for(var skipControls=!0,i=this._objects.length;i--;)this._objects[i].setCoords(skipControls)},_updateObjectsCoords:function(center){for(var center=center||this.getCenterPoint(),i=this._objects.length;i--;)this._updateObjectCoords(this._objects[i],center)},_updateObjectCoords:function(object,center){var objectLeft=object.left,objectTop=object.top,skipControls=!0;object.set({left:objectLeft-center.x,top:objectTop-center.y}),object.group=this,object.setCoords(skipControls)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(object){return this._restoreObjectsState(),fabric2.util.resetObjectTransform(this),object&&(this._objects.push(object),object.group=this,object._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},removeWithUpdate:function(object){return this._restoreObjectsState(),fabric2.util.resetObjectTransform(this),this.remove(object),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(object){this.dirty=!0,object.group=this,object._set("canvas",this.canvas)},_onObjectRemoved:function(object){this.dirty=!0,delete object.group},_set:function(key,value){var i=this._objects.length;if(this.useSetOnGroup)for(;i--;)this._objects[i].setOnGroup(key,value);if(key==="canvas")for(;i--;)this._objects[i]._set(key,value);fabric2.Object.prototype._set.call(this,key,value)},toObject:function(propertiesToInclude){var _includeDefaultValues=this.includeDefaultValues,objsToObject=this._objects.map(function(obj2){var originalDefaults=obj2.includeDefaultValues;obj2.includeDefaultValues=_includeDefaultValues;var _obj=obj2.toObject(propertiesToInclude);return obj2.includeDefaultValues=originalDefaults,_obj}),obj=fabric2.Object.prototype.toObject.call(this,propertiesToInclude);return obj.objects=objsToObject,obj},toDatalessObject:function(propertiesToInclude){var objsToObject,sourcePath=this.sourcePath;if(sourcePath)objsToObject=sourcePath;else{var _includeDefaultValues=this.includeDefaultValues;objsToObject=this._objects.map(function(obj2){var originalDefaults=obj2.includeDefaultValues;obj2.includeDefaultValues=_includeDefaultValues;var _obj=obj2.toDatalessObject(propertiesToInclude);return obj2.includeDefaultValues=originalDefaults,_obj})}var obj=fabric2.Object.prototype.toDatalessObject.call(this,propertiesToInclude);return obj.objects=objsToObject,obj},render:function(ctx){this._transformDone=!0,this.callSuper("render",ctx),this._transformDone=!1},shouldCache:function(){var ownCache=fabric2.Object.prototype.shouldCache.call(this);if(ownCache){for(var i=0,len=this._objects.length;i<len;i++)if(this._objects[i].willDrawShadow())return this.ownCaching=!1,!1}return ownCache},willDrawShadow:function(){if(fabric2.Object.prototype.willDrawShadow.call(this))return!0;for(var i=0,len=this._objects.length;i<len;i++)if(this._objects[i].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(ctx){for(var i=0,len=this._objects.length;i<len;i++)this._objects[i].render(ctx);this._drawClipPath(ctx)},isCacheDirty:function(skipCanvas){if(this.callSuper("isCacheDirty",skipCanvas))return!0;
1if(!this.statefullCache)return!1;for(var i=0,len=this._objects.length;i<len;i++)if(this._objects[i].isCacheDirty(!0)){if(this._cacheCanvas){var x=this.cacheWidth/this.zoomX,y=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-x/2,-y/2,x,y)}return!0}return!1},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},realizeTransform:function(object){var matrix=object.calcTransformMatrix(),options=fabric2.util.qrDecompose(matrix),center=new fabric2.Point(options.translateX,options.translateY);return object.flipX=!1,object.flipY=!1,object.set("scaleX",options.scaleX),object.set("scaleY",options.scaleY),object.skewX=options.skewX,object.skewY=options.skewY,object.angle=options.angle,object.setPositionByOrigin(center,"center","center"),object},_restoreObjectState:function(object){return this.realizeTransform(object),delete object.group,object.setCoords(),this},destroy:function(){return this._objects.forEach(function(object){object.set("dirty",!0)}),this._restoreObjectsState()},toActiveSelection:function(){if(this.canvas){var objects=this._objects,canvas=this.canvas;this._objects=[];var options=this.toObject();delete options.objects;var activeSelection=new fabric2.ActiveSelection([]);return activeSelection.set(options),activeSelection.type="activeSelection",canvas.remove(this),objects.forEach(function(object){object.group=activeSelection,object.dirty=!0,canvas.add(object)}),activeSelection.canvas=canvas,activeSelection._objects=objects,canvas._activeObject=activeSelection,activeSelection.setCoords(),activeSelection}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){var skipControls=!0;return this.forEachObject(function(object){object.setCoords(skipControls)}),this},_calcBounds:function(onlyWidthHeight){for(var aX=[],aY=[],o,prop,props=["tr","br","bl","tl"],i=0,iLen=this._objects.length,j,jLen=props.length;i<iLen;++i)for(o=this._objects[i],o.aCoords=o.calcACoords(),j=0;j<jLen;j++)prop=props[j],aX.push(o.aCoords[prop].x),aY.push(o.aCoords[prop].y);this._getBounds(aX,aY,onlyWidthHeight)},_getBounds:function(aX,aY,onlyWidthHeight){var minXY=new fabric2.Point(min(aX),min(aY)),maxXY=new fabric2.Point(max(aX),max(aY)),top=minXY.y||0,left=minXY.x||0,width=maxXY.x-minXY.x||0,height=maxXY.y-minXY.y||0;this.width=width,this.height=height,onlyWidthHeight||this.setPositionByOrigin({x:left,y:top},"left","top")},_toSVG:function(reviver){for(var svgString=["<g ","COMMON_PARTS"," >\n"],i=0,len=this._objects.length;i<len;i++)svgString.push("		",this._objects[i].toSVG(reviver));return svgString.push("</g>\n"),svgString},getSvgStyles:function(){var opacity=typeof this.opacity!="undefined"&&this.opacity!==1?"opacity: "+this.opacity+";":"",visibility=this.visible?"":" visibility: hidden;";
1return[opacity,this.getSvgFilter(),visibility].join("")},toClipPathSVG:function(reviver){for(var svgString=[],i=0,len=this._objects.length;i<len;i++)svgString.push("	",this._objects[i].toClipPathSVG(reviver));return this._createBaseClipPathSVGMarkup(svgString,{reviver:reviver})}}),fabric2.Group.fromObject=function(object,callback){var objects=object.objects,options=fabric2.util.object.clone(object,!0);if(delete options.objects,typeof objects=="string"){fabric2.loadSVGFromURL(objects,function(elements){var group=fabric2.util.groupSVGElements(elements,object,objects);group.set(options),callback&&callback(group)});return}fabric2.util.enlivenObjects(objects,function(enlivenedObjects){fabric2.util.enlivenObjects([object.clipPath],function(enlivedClipPath){var options2=fabric2.util.object.clone(object,!0);options2.clipPath=enlivedClipPath[0],delete options2.objects,callback&&callback(new fabric2.Group(enlivenedObjects,options2,!0))})})})})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});fabric2.ActiveSelection||(fabric2.ActiveSelection=fabric2.util.createClass(fabric2.Group,{type:"activeSelection",initialize:function(objects,options){options=options||{},this._objects=objects||[];for(var i=this._objects.length;i--;)this._objects[i].group=this;options.originX&&(this.originX=options.originX),options.originY&&(this.originY=options.originY),this._calcBounds(),this._updateObjectsCoords(),fabric2.Object.prototype.initialize.call(this,options),this.setCoords()},toGroup:function(){var objects=this._objects.concat();this._objects=[];var options=fabric2.Object.prototype.toObject.call(this),newGroup=new fabric2.Group([]);if(delete options.type,newGroup.set(options),objects.forEach(function(object){object.canvas.remove(object),object.group=newGroup}),newGroup._objects=objects,!this.canvas)return newGroup;var canvas=this.canvas;return canvas.add(newGroup),canvas._activeObject=newGroup,newGroup.setCoords(),newGroup},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(ctx,styleOverride,childrenOverride){ctx.save(),ctx.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",ctx,styleOverride),childrenOverride=childrenOverride||{},typeof childrenOverride.hasControls=="undefined"&&(childrenOverride.hasControls=!1),childrenOverride.forActiveSelection=!0;for(var i=0,len=this._objects.length;i<len;i++)this._objects[i]._renderControls(ctx,childrenOverride);ctx.restore()}}),fabric2.ActiveSelection.fromObject=function(object,callback){fabric2.util.enlivenObjects(object.objects,function(enlivenedObjects){delete object.objects,callback&&callback(new fabric2.ActiveSelection(enlivenedObjects,object,!0))})})})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var extend=fabric.util.object.extend;if(global.fabric||(global.fabric={}),global.fabric.Image){fabric.warn("fabric.Image is already defined.");return}fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:fabric.Object.prototype.stateProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(element,options){options||(options={}),this.filters=[],this.cacheKey="texture"+fabric.Object.__uid++,this.callSuper("initialize",options),this._initElement(element,options)},getElement:function(){return this._element||{}},setElement:function(element,options){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=element,this._originalElement=element,this._initConfig(options),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(key){var backend=fabric.filterBackend;backend&&backend.evictCachesForKey&&backend.evictCachesForKey(key)},dispose:function(){this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((function(element){fabric.util.cleanUpJsdomNode(this[element]),this[element]=void 0}).bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var element=this.getElement();
1return{width:element.naturalWidth||element.width,height:element.naturalHeight||element.height}},_stroke:function(ctx){if(!(!this.stroke||this.strokeWidth===0)){var w=this.width/2,h=this.height/2;ctx.beginPath(),ctx.moveTo(-w,-h),ctx.lineTo(w,-h),ctx.lineTo(w,h),ctx.lineTo(-w,h),ctx.lineTo(-w,-h),ctx.closePath()}},_renderDashedStroke:function(ctx){var x=-this.width/2,y=-this.height/2,w=this.width,h=this.height;ctx.save(),this._setStrokeStyles(ctx,this),ctx.beginPath(),fabric.util.drawDashedLine(ctx,x,y,x+w,y,this.strokeDashArray),fabric.util.drawDashedLine(ctx,x+w,y,x+w,y+h,this.strokeDashArray),fabric.util.drawDashedLine(ctx,x+w,y+h,x,y+h,this.strokeDashArray),fabric.util.drawDashedLine(ctx,x,y+h,x,y,this.strokeDashArray),ctx.closePath(),ctx.restore()},toObject:function(propertiesToInclude){var filters=[];this.filters.forEach(function(filterObj){filterObj&&filters.push(filterObj.toObject())});var object=extend(this.callSuper("toObject",["cropX","cropY"].concat(propertiesToInclude)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:filters});
1return this.resizeFilter&&(object.resizeFilter=this.resizeFilter.toObject()),object},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var svgString=[],imageMarkup=[],strokeSvg,element=this._element,x=-this.width/2,y=-this.height/2,clipPath="",imageRendering="";if(!element)return[];if(this.hasCrop()){var clipPathId=fabric.Object.__uid++;svgString.push('<clipPath id="imageCrop_'+clipPathId+'">\n','	<rect x="'+x+'" y="'+y+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),clipPath=' clip-path="url(#imageCrop_'+clipPathId+')" '}if(this.imageSmoothing||(imageRendering='" image-rendering="optimizeSpeed'),imageMarkup.push("	<image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',x-this.cropX,'" y="',y-this.cropY,'" width="',element.width||element.naturalWidth,'" height="',element.height||element.height,imageRendering,'"',clipPath,"></image>\n"),this.stroke||this.strokeDashArray){var origFill=this.fill;this.fill=null,strokeSvg=["	<rect ",'x="',x,'" y="',y,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'],this.fill=origFill}return this.paintFirst!=="fill"?svgString=svgString.concat(strokeSvg,imageMarkup):svgString=svgString.concat(imageMarkup,strokeSvg),svgString},getSrc:function(filtered){var element=filtered?this._element:this._originalElement;return element?element.toDataURL?element.toDataURL():this.srcFromAttribute?element.getAttribute("src"):element.src:this.src||""},setSrc:function(src,callback,options){return fabric.util.loadImage(src,function(img,isError){this.setElement(img,options),this._setWidthHeight(),callback&&callback(this,isError)},this,options&&options.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var filter=this.resizeFilter,minimumScale=this.minimumScaleTrigger,objectScale=this.getTotalObjectScaling(),scaleX=objectScale.scaleX,scaleY=objectScale.scaleY,elementToFilter=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!filter||scaleX>minimumScale&&scaleY>minimumScale){this._element=elementToFilter,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=scaleX,this._lastScaleY=scaleY;return}fabric.filterBackend||(fabric.filterBackend=fabric.initFilterBackend());var canvasEl=fabric.util.createCanvasElement(),cacheKey=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,sourceWidth=elementToFilter.width,sourceHeight=elementToFilter.height;canvasEl.width=sourceWidth,canvasEl.height=sourceHeight,this._element=canvasEl,this._lastScaleX=filter.scaleX=scaleX,this._lastScaleY=filter.scaleY=scaleY,fabric.filterBackend.applyFilters([filter],elementToFilter,sourceWidth,sourceHeight,this._element,cacheKey),this._filterScalingX=canvasEl.width/this._originalElement.width,this._filterScalingY=canvasEl.height/this._originalElement.height},applyFilters:function(filters){if(filters=filters||this.filters||[],filters=filters.filter(function(filter){return filter&&!filter.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),filters.length===0)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;
1var imgElement=this._originalElement,sourceWidth=imgElement.naturalWidth||imgElement.width,sourceHeight=imgElement.naturalHeight||imgElement.height;if(this._element===this._originalElement){var canvasEl=fabric.util.createCanvasElement();canvasEl.width=sourceWidth,canvasEl.height=sourceHeight,this._element=canvasEl,this._filteredEl=canvasEl}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,sourceWidth,sourceHeight),this._lastScaleX=1,this._lastScaleY=1;return fabric.filterBackend||(fabric.filterBackend=fabric.initFilterBackend()),fabric.filterBackend.applyFilters(filters,this._originalElement,sourceWidth,sourceHeight,this._element,this.cacheKey),(this._originalElement.width!==this._element.width||this._originalElement.height!==this._element.height)&&(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(ctx){fabric.util.setImageSmoothing(ctx,this.imageSmoothing),this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(ctx),this._renderPaintInOrder(ctx)},drawCacheOnCanvas:function(ctx){fabric.util.setImageSmoothing(ctx,this.imageSmoothing),fabric.Object.prototype.drawCacheOnCanvas.call(this,ctx)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(ctx){var elementToDraw=this._element;if(elementToDraw){var scaleX=this._filterScalingX,scaleY=this._filterScalingY,w=this.width,h=this.height,min=Math.min,max=Math.max,cropX=max(this.cropX,0),cropY=max(this.cropY,0),elWidth=elementToDraw.naturalWidth||elementToDraw.width,elHeight=elementToDraw.naturalHeight||elementToDraw.height,sX=cropX*scaleX,sY=cropY*scaleY,sW=min(w*scaleX,elWidth-sX),sH=min(h*scaleY,elHeight-sY),x=-w/2,y=-h/2,maxDestW=min(w,elWidth/scaleX-cropX),maxDestH=min(h,elHeight/scaleX-cropY);elementToDraw&&ctx.drawImage(elementToDraw,sX,sY,sW,sH,x,y,maxDestW,maxDestH)}},_needsResize:function(){var scale=this.getTotalObjectScaling();return scale.scaleX!==this._lastScaleX||scale.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(element,options){this.setElement(fabric.util.getById(element),options),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(options){options||(options={}),this.setOptions(options),this._setWidthHeight(options)},_initFilters:function(filters,callback){filters&&filters.length?fabric.util.enlivenObjects(filters,function(enlivenedObjects){callback&&callback(enlivenedObjects)},"fabric.Image.filters"):callback&&callback()},_setWidthHeight:function(options){options||(options={});var el=this.getElement();this.width=options.width||el.naturalWidth||el.width||0,this.height=options.height||el.naturalHeight||el.height||0},parsePreserveAspectRatioAttribute:function(){var pAR=fabric.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),rWidth=this._element.width,rHeight=this._element.height,scaleX=1,scaleY=1,offsetLeft=0,offsetTop=0,cropX=0,cropY=0,offset,pWidth=this.width,pHeight=this.height,parsedAttributes={width:pWidth,height:pHeight};return pAR&&(pAR.alignX!=="none"||pAR.alignY!=="none")?(pAR.meetOrSlice==="meet"&&(scaleX=scaleY=fabric.util.findScaleToFit(this._element,parsedAttributes),offset=(pWidth-rWidth*scaleX)/2,pAR.alignX==="Min"&&(offsetLeft=-offset),pAR.alignX==="Max"&&(offsetLeft=offset),offset=(pHeight-rHeight*scaleY)/2,pAR.alignY==="Min"&&(offsetTop=-offset),pAR.alignY==="Max"&&(offsetTop=offset)),pAR.meetOrSlice==="slice"&&(scaleX=scaleY=fabric.util.findScaleToCover(this._element,parsedAttributes),offset=rWidth-pWidth/scaleX,pAR.alignX==="Mid"&&(cropX=offset/2),pAR.alignX==="Max"&&(cropX=offset),offset=rHeight-pHeight/scaleY,pAR.alignY==="Mid"&&(cropY=offset/2),pAR.alignY==="Max"&&(cropY=offset),rWidth=pWidth/scaleX,rHeight=pHeight/scaleY)):(scaleX=pWidth/rWidth,scaleY=pHeight/rHeight),{width:rWidth,height:rHeight,scaleX:scaleX,scaleY:scaleY,offsetLeft:offsetLeft,offsetTop:offsetTop,cropX:cropX,cropY:cropY}}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(_object,callback){var object=fabric.util.object.clone(_object);fabric.util.loadImage(object.src,function(img,isError){if(isError){callback&&callback(null,!0);return}fabric.Image.prototype._initFilters.call(object,object.filters,function(filters){object.filters=filters||[],fabric.Image.prototype._initFilters.call(object,[object.resizeFilter],function(resizeFilters){object.resizeFilter=resizeFilters[0],fabric.util.enlivenObjects([object.clipPath],function(enlivedProps){object.clipPath=enlivedProps[0];var image=new fabric.Image(img,object);callback(image,!1)})})})},null,object.crossOrigin)},fabric.Image.fromURL=function(url,callback,imgOptions){fabric.util.loadImage(url,function(img,isError){callback&&callback(new fabric.Image(img,imgOptions),isError)},null,imgOptions&&imgOptions.crossOrigin)},fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),fabric.Image.fromElement=function(element,callback,options){var parsedAttributes=fabric.parseAttributes(element,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(parsedAttributes["xlink:href"],callback,extend(options?fabric.util.object.clone(options):{},parsedAttributes))}})(typeof exports!="undefined"?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var angle=this.angle%360;return angle>0?Math.round((angle-1)/90)*90:Math.round(angle/90)*90},straighten:function(){return this.rotate(this._getAngleValueForStraighten()),this},fxStraighten:function(callbacks){callbacks=callbacks||{};var empty=function(){},onComplete=callbacks.onComplete||empty,onChange=callbacks.onChange||empty,_this=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(value){_this.rotate(value),onChange()},onComplete:function(){_this.setCoords(),onComplete()}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(object){return object.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(object){return object.fxStraighten({onCh
1ange:this.requestRenderAllBound}),this}}),(function(){"use strict";function testPrecision(gl,precision){var fragmentSource="precision "+precision+" float;\nvoid main(){}",fragmentShader=gl.createShader(gl.FRAGMENT_SHADER);return gl.shaderSource(fragmentShader,fragmentSource),gl.compileShader(fragmentShader),!!gl.getShaderParameter(fragmentShader,gl.COMPILE_STATUS)}fabric.isWebglSupported=function(tileSize){if(fabric.isLikelyNode)return!1;tileSize=tileSize||fabric.WebglFilterBackend.prototype.tileSize;var canvas=document.createElement("canvas"),gl=canvas.getContext("webgl")||canvas.getContext("experimental-webgl"),isSupported=!1;if(gl){fabric.maxTextureSize=gl.getParameter(gl.MAX_TEXTURE_SIZE),isSupported=fabric.maxTextureSize>=tileSize;for(var precisions=["highp","mediump","lowp"],i=0;i<3;i++)if(testPrecision(gl,precisions[i])){fabric.webGlPrecision=precisions[i];break}}return this.isSupported=isSupported,isSupported},fabric.WebglFilterBackend=WebglFilterBackend;function WebglFilterBackend(options){options&&options.tileSize&&(this.tileSize=options.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}WebglFilterBackend.prototype={tileSize:2048,resources:{},setupGLContext:function(width,height){this.dispose(),this.createWebGLCanvas(width,height),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(width,height)},chooseFastestCopyGLTo2DMethod:function(width,height){var canMeasurePerf=typeof window.performance!="undefined",canUseImageData;try{new ImageData(1,1),canUseImageData=!0}catch(e){canUseImageData=!1}var canUseArrayBuffer=typeof ArrayBuffer!="undefined",canUseUint8Clamped=typeof Uint8ClampedArray!="undefined";if(canMeasurePerf&&canUseImageData&&canUseArrayBuffer&&canUseUint8Clamped){var targetCanvas=fabric.util.createCanvasElement(),imageBuffer=new ArrayBuffer(width*height*4);if(fabric.forceGLPutImageData){this.imageBuffer=imageBuffer,this.copyGLTo2D=copyGLTo2DPutImageData;return}var testContext={imageBuffer:imageBuffer,destinationWidth:width,destinationHeight:height,targetCanvas:targetCanvas},startTime,drawImageTime,putImageDataTime;targetCanvas.width=width,targetCanvas.height=height,startTime=window.performance.now(),copyGLTo2DDrawImage.call(testContext,this.gl,testContext),drawImageTime=window.performance.now()-startTime,startTime=window.performance.now(),copyGLTo2DPutImageData.call(testContext,this.gl,testContext),putImageDataTime=window.performance.now()-startTime,drawImageTime>putImageDataTime?(this.imageBuffer=imageBuffer,this.copyGLTo2D=copyGLTo2DPutImageData):this.copyGLTo2D=copyGLTo2DDrawImage}},createWebGLCanvas:function(width,height){var canvas=fabric.util.createCanvasElement();canvas.width=width,canvas.height=height;var glOptions={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},gl=canvas.getContext("webgl",glOptions);gl||(gl=canvas.getContext("experimental-webgl",glOptions)),gl&&(gl.clearColor(0,0,0,0),this.canvas=canvas,this.gl=gl)},applyFilters:function(filters,source,width,height,targetCanvas,cacheKey){var gl=this.gl,cachedTexture;cacheKey&&(cachedTexture=this.getCachedTexture(cacheKey,source));var pipelineState={originalWidth:source.width||source.originalWidth,originalHeight:source.height||source.originalHeight,sourceWidth:width,sourceHeight:height,destinationWidth:width,destinationHeight:height,context:gl,sourceTexture:this.createTexture(gl,width,height,!cachedTexture&&source),targetTexture:this.createTexture(gl,width,height),originalTexture:cachedTexture||this.createTexture(gl,width,height,!cachedTexture&&source),passes:filters.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:targetCanvas},tempFbo=gl.createFramebuffer();return gl.bindFramebuffer(gl.FRAMEBUFFER,tempFbo),filters.forEach(function(filter){filter&&filter.applyTo(pipelineState)}),resizeCanvasIfNeeded(pipelineState),this.copyGLTo2D(gl,pipelineState),gl.bindTexture(gl.TEXTURE_2D,null),gl.deleteTexture(pipelineState.sourceTexture),gl.deleteTexture(pipelineState.targetTexture),gl.deleteFramebuffer(tempFbo),targetCanvas.getContext("2d").setTransform(1,0,0,1,0,0),pipelineState},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(gl,width,height,textureImageSource){var texture=gl.createTexture();return gl.bindTexture(gl.TEXTURE_2D,texture),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE),textureImageSource?gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,textureImageSource):gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width,height,0,gl.RGBA,gl.UNSIGNED_BYTE,null),texture},getCachedTexture:function(uniqueId,textureImageSource){if(this.textureCache[uniqueId])return this.textureCache[uniqueId];var texture=this.createTexture(this.gl,textureImageSource.width,textureImageSource.height,textureImageSource);return this.textureCache[uniqueId]=texture,texture},evictCachesForKey:function(cacheKey){this.textureCache[cacheKey]&&(this.gl.deleteTexture(this.textureCache[cacheKey]),delete this.textureCache[cacheKey])},copyGLTo2D:copyGLTo2DDrawImage,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var gl=this.gl,gpuInfo={renderer:"",vendor:""};if(!gl)return gpuInfo;var ext=gl.getExtension("WEBGL_debug_renderer_info");if(ext){var renderer=gl.getParameter(ext.UNMASKED_RENDERER_WEBGL),vendor=gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);renderer&&(gpuInfo.renderer=renderer.toLowerCase()),vendor&&(gpuInfo.vendor=vendor.toLowerCase())}return this.gpuInfo=gpuInfo,gpuInfo}}})();function resizeCanvasIfNeeded(pipelineState){var targetCanvas=pipelineState.targetCanvas,width=targetCanvas.width,height=targetCanvas.height,dWidth=pipelineState.destinationWidth,dHeight=pipelineState.destinationHeight;(width!==dWidth||height!==dHeight)&&(targetCanvas.width=dWidth,targetCanvas.height=dHeight)}function copyGLTo2DDrawImage(gl,pipelineState){var glCanvas=gl.canvas,targetCanvas=pipelineState.targetCanvas,ctx=targetCanvas.getContext("2d");ctx.translate(0,targetCanvas.height),ctx.scale(1,-1);var sourceY=glCanvas.height-targetCanvas.height;ctx.drawImage(glCanvas,0,sourceY,targetCanvas.width,targetCanvas.height,0,0,targetCanvas.width,targetCanvas.height)}function copyGLTo2DPutImageData(gl,pipelineState){var targetCanvas=pipelineState.targetCanvas,ctx=targetCanvas.getContext("2d"),dWidth=pipelineState.destinationWidth,dHeight=pipelineState.destinationHeight,numBytes=dWidth*dHeight*4,u8=new Uint8Array(this.imageBuffer,0,numBytes),u8Clamped=new Uint8ClampedArray(this.imageBuffer,0,numBytes);gl.readPixels(0,0,dWidth,dHeight,gl.RGBA,gl.UNSIGNED_BYTE,u8);var imgData=new ImageData(u8Clamped,dWidth,dHeight);ctx.putImageData(imgData,0,0)}(function(){"use strict";var noop=function(){};fabric.Canvas2dFilterBackend=Canvas2dFilterBackend;function Canvas2dFilterBackend(){}Canvas2dFilterBackend.prototype={evictCachesForKey:noop,dispose:noop,clearWebGLCaches:noop,resources:{}
1,applyFilters:function(filters,sourceElement,sourceWidth,sourceHeight,targetCanvas){var ctx=targetCanvas.getContext("2d");ctx.drawImage(sourceElement,0,0,sourceWidth,sourceHeight);var imageData=ctx.getImageData(0,0,sourceWidth,sourceHeight),originalImageData=ctx.getImageData(0,0,sourceWidth,sourceHeight),pipelineState={sourceWidth:sourceWidth,sourceHeight:sourceHeight,imageData:imageData,originalEl:sourceElement,originalImageData:originalImageData,canvasEl:targetCanvas,ctx:ctx,filterBackend:this};return filters.forEach(function(filter){filter.applyTo(pipelineState)}),(pipelineState.imageData.width!==sourceWidth||pipelineState.imageData.height!==sourceHeight)&&(targetCanvas.width=pipelineState.imageData.width,targetCanvas.height=pipelineState.imageData.height),ctx.putImageData(pipelineState.imageData,0,0),pipelineState}}})(),fabric.Image=fabric.Image||{},fabric.Image.filters=fabric.Image.filters||{},fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(options){options&&this.setOptions(options)},setOptions:function(options){for(var prop in options)this[prop]=options[prop]},createProgram:function(gl,fragmentSource,vertexSource){fragmentSource=fragmentSource||this.fragmentSource,vertexSource=vertexSource||this.vertexSource,fabric.webGlPrecision!=="highp"&&(fragmentSource=fragmentSource.replace(/precision highp float/g,"precision "+fabric.webGlPrecision+" float"));var vertexShader=gl.createShader(gl.VERTEX_SHADER);if(gl.shaderSource(vertexShader,vertexSource),gl.compileShader(vertexShader),!gl.getShaderParameter(vertexShader,gl.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+gl.getShaderInfoLog(vertexShader));var fragmentShader=gl.createShader(gl.FRAGMENT_SHADER);if(gl.shaderSource(fragmentShader,fragmentSource),gl.compileShader(fragmentShader),!gl.getShaderParameter(fragmentShader,gl.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+gl.getShaderInfoLog(fragmentShader));var program=gl.createProgram();if(gl.attachShader(program,vertexShader),gl.attachShader(program,fragmentShader),gl.linkProgram(program),!gl.getProgramParameter(program,gl.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+gl.getProgramInfoLog(program));var attributeLocations=this.getAttributeLocations(gl,program),uniformLocations=this.getUniformLocations(gl,program)||{};return uniformLocations.uStepW=gl.getUniformLocation(program,"uStepW"),uniformLocations.uStepH=gl.getUniformLocation(program,"uStepH"),{program:program,attributeLocations:attributeLocations,uniformLocations:uniformLocations}},getAttributeLocations:function(gl,program){return{aPosition:gl.getAttribLocation(program,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(gl,attributeLocations,aPositionData){var attributeLocation=attributeLocations.aPosition,buffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,buffer),gl.enableVertexAttribArray(attributeLocation),gl.vertexAttribPointer(attributeLocation,2,gl.FLOAT,!1,0,0),gl.bufferData(gl.ARRAY_BUFFER,aPositionData,gl.STATIC_DRAW)},_setupFrameBuffer:function(options){var gl=options.context,width,height;options.passes>1?(width=options.destinationWidth,height=options.destinationHeight,(options.sourceWidth!==width||options.sourceHeight!==height)&&(gl.deleteTexture(options.targetTexture),options.targetTexture=options.filterBackend.createTexture(gl,width,height)),gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,options.targetTexture,0)):(gl.bindFramebuffer(gl.FRAMEBUFFER,null),gl.finish())},_swapTextures:function(options){options.passes--,options.pass++;var temp=options.targetTexture;options.targetTexture=options.sourceTexture,options.sourceTexture=temp},isNeutralState:function(){var main=this.mainParameter,_class=fabric.Image.filters[this.type].prototype;if(main)if(Array.isArray(_class[main])){for(var i=_class[main].length;i--;)if(this[main][i]!==_class[main][i])return!1;return!0}else return _class[main]===this[main];else return!1},applyTo:function(options){options.webgl?(this._setupFrameBuffer(options),this.applyToWebGL(options),this._swapTextures(options)):this.applyTo2d(options)},retrieveShader:function(options){return options.programCache.hasOwnProperty(this.type)||(options.programCache[this.type]=this.createProgram(options.context)),options.programCache[this.type]},applyToWebGL:function(options){var gl=options.context,shader=this.retrieveShader(options);options.pass===0&&options.originalTexture?gl.bindTexture(gl.TEXTURE_2D,options.originalTexture):gl.bindTexture(gl.TEXTURE_2D,options.sourceTexture),gl.useProgram(shader.program),this.sendAttributeData(gl,shader.attributeLocations,options.aPosition),gl.uniform1f(shader.uniformLocations.uStepW,1/options.sourceWidth),gl.uniform1f(shader.uniformLocations.uStepH,1/options.sourceHeight),this.sendUniformData(gl,shader.uniformLocations),gl.viewport(0,0,options.destinationWidth,options.destinationHeight),gl.drawArrays(gl.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(gl,texture,textureUnit){gl.activeTexture(textureUnit),gl.bindTexture(gl.TEXTURE_2D,texture),gl.activeTexture(gl.TEXTURE0)},unbindAdditionalTexture:function(gl,textureUnit){gl.activeTexture(textureUnit),gl.bindTexture(gl.TEXTURE_2D,null),gl.activeTexture(gl.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(value){this[this.mainParameter]=value},sendUniformData:function(){},createHelpLayer:function(options){if(!options.helpLayer){var helpLayer=document.createElement("canvas");helpLayer.width=options.sourceWidth,helpLayer.height=options.sourceHeight,options.helpLayer=helpLayer}}
1,toObject:function(){var object={type:this.type},mainP=this.mainParameter;return mainP&&(object[mainP]=this[mainP]),object},toJSON:function(){return this.toObject()}}),fabric.Image.filters.BaseFilter.fromObject=function(object,callback){var filter=new fabric.Image.filters[object.type](object);return callback&&callback(filter),filter},(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.ColorMatrix=createClass(filters.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(options){this.callSuper("initialize",options),this.matrix=this.matrix.slice(0)},applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,iLen=data.length,m=this.matrix,r,g,b,a,i,colorsOnly=this.colorsOnly;for(i=0;i<iLen;i+=4)r=data[i],g=data[i+1],b=data[i+2],colorsOnly?(data[i]=r*m[0]+g*m[1]+b*m[2]+m[4]*255,data[i+1]=r*m[5]+g*m[6]+b*m[7]+m[9]*255,data[i+2]=r*m[10]+g*m[11]+b*m[12]+m[14]*255):(a=data[i+3],data[i]=r*m[0]+g*m[1]+b*m[2]+a*m[3]+m[4]*255,data[i+1]=r*m[5]+g*m[6]+b*m[7]+a*m[8]+m[9]*255,data[i+2]=r*m[10]+g*m[11]+b*m[12]+a*m[13]+m[14]*255,data[i+3]=r*m[15]+g*m[16]+b*m[17]+a*m[18]+m[19]*255)},getUniformLocations:function(gl,program){return{uColorMatrix:gl.getUniformLocation(program,"uColorMatrix"),uConstants:gl.getUniformLocation(program,"uConstants")}},sendUniformData:function(gl,uniformLocations){var m=this.matrix,matrix=[m[0],m[1],m[2],m[3],m[5],m[6],m[7],m[8],m[10],m[11],m[12],m[13],m[15],m[16],m[17],m[18]],constants=[m[4],m[9],m[14],m[19]];gl.uniformMatrix4fv(uniformLocations.uColorMatrix,!1,matrix),gl.uniform4fv(uniformLocations.uConstants,constants)}}),fabric2.Image.filters.ColorMatrix.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Brightness=createClass(filters.BaseFilter,{type:"Brightness",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",brightness:0,mainParameter:"brightness",applyTo2d:function(options){if(this.brightness!==0){var imageData=options.imageData,data=imageData.data,i,len=data.length,brightness=Math.round(this.brightness*255);for(i=0;i<len;i+=4)data[i]=data[i]+brightness,data[i+1]=data[i+1]+brightness,data[i+2]=data[i+2]+brightness}},getUniformLocations:function(gl,program){return{uBrightness:gl.getUniformLocation(program,"uBrightness")}},sendUniformData:function(gl,uniformLocations){gl.uniform1f(uniformLocations.uBrightness,this.brightness)}}),fabric2.Image.filters.Brightness.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Convolute=createClass(filters.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_3_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_5_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_5_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_7_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_7_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_9_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_9_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}"},retrieveShader:function(options){var size=Math.sqrt(this.matrix.length),c
1acheKey=this.type+"_"+size+"_"+(this.opaque?1:0),shaderSource=this.fragmentSource[cacheKey];return options.programCache.hasOwnProperty(cacheKey)||(options.programCache[cacheKey]=this.createProgram(options.context,shaderSource)),options.programCache[cacheKey]},applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,weights=this.matrix,side=Math.round(Math.sqrt(weights.length)),halfSide=Math.floor(side/2),sw=imageData.width,sh=imageData.height,output=options.ctx.createImageData(sw,sh),dst=output.data,alphaFac=this.opaque?1:0,r,g,b,a,dstOff,scx,scy,srcOff,wt,x,y,cx,cy;for(y=0;y<sh;y++)for(x=0;x<sw;x++){for(dstOff=(y*sw+x)*4,r=0,g=0,b=0,a=0,cy=0;cy<side;cy++)for(cx=0;cx<side;cx++)scy=y+cy-halfSide,scx=x+cx-halfSide,!(scy<0||scy>=sh||scx<0||scx>=sw)&&(srcOff=(scy*sw+scx)*4,wt=weights[cy*side+cx],r+=data[srcOff]*wt,g+=data[srcOff+1]*wt,b+=data[srcOff+2]*wt,alphaFac||(a+=data[srcOff+3]*wt));dst[dstOff]=r,dst[dstOff+1]=g,dst[dstOff+2]=b,alphaFac?dst[dstOff+3]=data[dstOff+3]:dst[dstOff+3]=a}options.imageData=output},getUniformLocations:function(gl,program){return{uMatrix:gl.getUniformLocation(program,"uMatrix"),uOpaque:gl.getUniformLocation(program,"uOpaque"),uHalfSize:gl.getUniformLocation(program,"uHalfSize"),uSize:gl.getUniformLocation(program,"uSize")}},sendUniformData:function(gl,uniformLocations){gl.uniform1fv(uniformLocations.uMatrix,this.matrix)},toObject:function(){return extend(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),fabric2.Image.filters.Convolute.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Grayscale=createClass(filters.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,i,len=data.length,value,mode=this.mode;for(i=0;i<len;i+=4)mode==="average"?value=(data[i]+data[i+1]+data[i+2])/3:mode==="lightness"?value=(Math.min(data[i],data[i+1],data[i+2])+Math.max(data[i],data[i+1],data[i+2]))/2:mode==="luminosity"&&(value=.21*data[i]+.72*data[i+1]+.07*data[i+2]),data[i]=value,data[i+1]=value,data[i+2]=value},retrieveShader:function(options){var cacheKey=this.type+"_"+this.mode;if(!options.programCache.hasOwnProperty(cacheKey)){var shaderSource=this.fragmentSource[this.mode];options.programCache[cacheKey]=this.createProgram(options.context,shaderSource)}return options.programCache[cacheKey]},getUniformLocations:function(gl,program){return{uMode:gl.getUniformLocation(program,"uMode")}},sendUniformData:function(gl,uniformLocations){var mode=1;gl.uniform1i(uniformLocations.uMode,mode)},isNeutralState:function(){return!1}}),fabric2.Image.filters.Grayscale.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Invert=createClass(filters.BaseFilter,{type:"Invert",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",invert:!0,mainParameter:"invert",applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,i,len=data.length;for(i=0;i<len;i+=4)data[i]=255-data[i],data[i+1]=255-data[i+1],data[i+2]=255-data[i+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(gl,program){return{uInvert:gl.getUniformLocation(program,"uInvert")}},sendUniformData:function(gl,uniformLocations){gl.uniform1i(uniformLocations.uInvert,this.invert)}}),fabric2.Image.filters.Invert.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Noise=createClass(filters.BaseFilter,{type:"Noise",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",mainParameter:"noise",noise:0,applyTo2d:function(options){if(this.noise!==0){var imageData=options.imageData,data=imageData.data,i,len=data.length,noise=this.noise,rand;for(i=0,len=data.length;i<len;i+=4)rand=(.5-Math.random())*noise,data[i]+=rand,data[i+1]+=rand,data[i+2]+=rand}},getUniformLocations:function(gl,program){return{uNoise:gl.getUniformLocation(program,"uNoise"),uSeed:gl.getUniformLocation(program,"uSeed")}},sendUniformData:function(gl,uniformLocations){gl.uniform1f(uniformLocations.uNoise,this.noise/255),gl.uniform1f(uniformLocations.uSeed,Math.random())},toObject:function(){return extend(this.callSuper("toObject"),{noise:this.noise})}}),fabric2.Image.filters.Noise.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Pixelate=createClass(filters.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,iLen=imageData.height,jLen=imageData.width,index,i,j,r,g,b,a,_i,_j,_iLen,_jLen;for(i=0;i<iLen;i+=this.blocksize)for(j=0;j<jLen;j+=this.blocksize)for(index=i*4*jLen+j*4,r=data[index],g=data[index+1],b=data[index+2],a=data[index+3],_iLen=Math.min(i+this.blocksize,iLen),_jLen=Math.min(j+this.blocksize,jLen),_i=i;_i<_iLen;_i++)for(_j=j;_j<_jLen;_j++)index=_i*4*jLen+_j*4,data[index]=r,data[index+1]=g,data[index+2]=b,data[index+3]=a},isNeutralState:function(){return this.blocksize===1},getUniformLocations:function(gl,program){return{uBlocksize:gl.getUniformLocation(program,"uBlocksize"),uStepW:gl.getUniformLocation(program,"uStepW"),uStepH:gl.getUniformLocation(program,"uStepH")}},sendUniformData:function(gl,uniformLocations){gl.uniform1f(uniformLocations.uBlocksize,this.blocksize)}}),fabric2.Image.filters.Pixelate.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),extend=fabric2.util.object.extend,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.RemoveColor=createClass(filters.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",distance:.02,useAlpha:!1,applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,i,distance=this.distance*255,r,g,b,source=new fabric2.Color(this.color).getSource(),lowC=[source[0]-distance,source[1]-distance,source[2]-distance],highC=[source[0]+distance,source[1]+distance,source[2]+distance];for(i=0;i<data.length;i+=4)r=data[i],g=data[i+1],b=data[i+2],r>lowC[0]&&g>lowC[1]&&b>lowC[2]&&r<highC[0]&&g<highC[1]&&b<highC[2]&&(data[i+3]=0)},getUniformLocations:function(gl,program){return{uLow:gl.getUniformLocation(program,"uLow"),uHigh:gl.getUniformLocation(program,"uHigh")}},sendUniformData:function(gl,uniformLocations){var source=new fabric2.Color(this.color).getSource(),distance=parseFloat(this.distance),lowC=[0+source[0]/255-distance,0+source[1]/255-distance,0+source[2]/255-distance,1],highC=[source[0]/255+distance,source[1]/255+distance,source[2]/255+distance,1];gl.uniform4fv(uniformLocations.uLow,lowC),gl.uniform4fv(uniformLocations.uHigh,highC)},toObject:function(){return extend(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),fabric2.Image.filters.RemoveColor.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass,matrices={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var key in matrices)filters[key]=createClass(filters.ColorMatrix,{type:key,matrix:matrices[key],mainParameter:!1,colorsOnly:!0}),fabric2.Image.filters[key].fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.BlendColor=createClass(filters.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",diff:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",tint:"gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n"},buildSource:function(mode){return"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n"+this.fragmentSource[mode]+"}\n}"},retrieveShader:function(options){var cacheKey=this.type+"_"+this.mode,shaderSource;return options.programCache.hasOwnProperty(cacheKey)||(shaderSource=this.buildSource(this.mode),options.programCache[cacheKey]=this.createProgram(options.context,shaderSource)),options.programCache[cacheKey]},applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,iLen=data.length,tr,tg,tb,r,g,b,source,alpha1=1-this.alpha;source=new fabric2.Color(this.color).getSource(),tr=source[0]*this.alpha,tg=source[1]*this.alpha,tb=source[2]*this.alpha;for(var i=0;i<iLen;i+=4)switch(r=data[i],g=data[i+1],b=data[i+2],this.mode){case"multiply":data[i]=r*tr/255,data[i+1]=g*tg/255,data[i+2]=b*tb/255;break;case"screen":data[i]=255-(255-r)*(255-tr)/255,data[i+1]=255-(255-g)*(255-tg)/255,data[i+2]=255-(255-b)*(255-tb)/255;break;
vendor: 1,758 bytes, line 1
1case"add":data[i]=r+tr,data[i+1]=g+tg,data[i+2]=b+tb;break;case"diff":case"difference":data[i]=Math.abs(r-tr),data[i+1]=Math.abs(g-tg),data[i+2]=Math.abs(b-tb);break;case"subtract":data[i]=r-tr,data[i+1]=g-tg,data[i+2]=b-tb;break;case"darken":data[i]=Math.min(r,tr),data[i+1]=Math.min(g,tg),data[i+2]=Math.min(b,tb);break;case"lighten":data[i]=Math.max(r,tr),data[i+1]=Math.max(g,tg),data[i+2]=Math.max(b,tb);break;case"overlay":data[i]=tr<128?2*r*tr/255:255-2*(255-r)*(255-tr)/255,data[i+1]=tg<128?2*g*tg/255:255-2*(255-g)*(255-tg)/255,data[i+2]=tb<128?2*b*tb/255:255-2*(255-b)*(255-tb)/255;break;case"exclusion":data[i]=tr+r-2*tr*r/255,data[i+1]=tg+g-2*tg*g/255,data[i+2]=tb+b-2*tb*b/255;break;case"tint":data[i]=tr+r*alpha1,data[i+1]=tg+g*alpha1,data[i+2]=tb+b*alpha1}},getUniformLocations:function(gl,program){return{uColor:gl.getUniformLocation(program,"uColor")}},sendUniformData:function(gl,uniformLocations){var source=new fabric2.Color(this.color).getSource();source[0]=this.alpha*source[0]/255,source[1]=this.alpha*source[1]/255,source[2]=this.alpha*source[2]/255,source[3]=this.alpha,gl.uniform4fv(uniformLocations.uColor,source)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),fabric2.Image.filters.BlendColor.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.BlendImage=createClass(filters.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;
1\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:{multiply:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",mask:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}"},retrieveShader:function(options){var cacheKey=this.type+"_"+this.mode,shaderSource=this.fragmentSource[this.mode];return options.programCache.hasOwnProperty(cacheKey)||(options.programCache[cacheKey]=this.createProgram(options.context,shaderSource)),options.programCache[cacheKey]},applyToWebGL:function(options){var gl=options.context,texture=this.createTexture(options.filterBackend,this.image);this.bindAdditionalTexture(gl,texture,gl.TEXTURE1),this.callSuper("applyToWebGL",options),this.unbindAdditionalTexture(gl,gl.TEXTURE1)},createTexture:function(backend,image){return backend.getCachedTexture(image.cacheKey,image._element)},calculateMatrix:function(){var image=this.image,width=image._element.width,height=image._element.height;return[1/image.scaleX,0,0,0,1/image.scaleY,0,-image.left/width,-image.top/height,1]},applyTo2d:function(options){var imageData=options.imageData,resources=options.filterBackend.resources,data=imageData.data,iLen=data.length,width=imageData.width,height=imageData.height,tr,tg,tb,ta,r,g,b,a,canvas1,context,image=this.image,blendData;resources.blendImage||(resources.blendImage=fabric2.util.createCanvasElement()),canvas1=resources.blendImage,context=canvas1.getContext("2d"),canvas1.width!==width||canvas1.height!==height?(canvas1.width=width,canvas1.height=height):context.clearRect(0,0,width,height),context.setTransform(image.scaleX,0,0,image.scaleY,image.left,image.top),context.drawImage(image._element,0,0,width,height),blendData=context.getImageData(0,0,width,height).data;for(var i=0;i<iLen;i+=4)switch(r=data[i],g=data[i+1],b=data[i+2],a=data[i+3],tr=blendData[i],tg=blendData[i+1],tb=blendData[i+2],ta=blendData[i+3],this.mode){case"multiply":data[i]=r*tr/255,data[i+1]=g*tg/255,data[i+2]=b*tb/255,data[i+3]=a*ta/255;break;case"mask":data[i+3]=ta;break}},getUniformLocations:function(gl,program){return{uTransformMatrix:gl.getUniformLocation(program,"uTransformMatrix"),uImage:gl.getUniformLocation(program,"uImage")}},sendUniformData:function(gl,uniformLocations){var matrix=this.calculateMatrix();gl.uniform1i(uniformLocations.uImage,1),gl.uniformMatrix3fv(uniformLocations.uTransformMatrix,!1,matrix)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),fabric2.Image.filters.BlendImage.fromObject=function(object,callback){fabric2.Image.fromObject(object.image,function(image){var options=fabric2.util.object.clone(object);options.image=image,callback(new fabric2.Image.filters.BlendImage(options))})}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),pow=Math.pow,floor=Math.floor,sqrt=Math.sqrt,abs=Math.abs,round=Math.round,sin=Math.sin,ceil=Math.ceil,filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Resize=createClass(filters.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(gl,program){return{uDelta:gl.getUniformLocation(program,"uDelta"),uTaps:gl.getUniformLocation(program,"uTaps")}},sendUniformData:function(gl,uniformLocations){gl.uniform2fv(uniformLocations.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),gl.uniform1fv(uniformLocations.uTaps,this.taps)},retrieveShader:function(options){var filterWindow=this.getFilterWindow(),cacheKey=this.type+"_"+filterWindow;if(!options.programCache.hasOwnProperty(cacheKey)){var fragmentShader=this.generateShader(filterWindow);options.programCache[cacheKey]=this.createProgram(options.context,fragmentShader)}return options.programCache[cacheKey]},getFilterWindow:function(){var scale=this.tempScale;return Math.ceil(this.lanczosLobes/scale)},getTaps:function(){for(var lobeFunction=this.lanczosCreate(this.lanczosLobes),scale=this.tempScale,filterWindow=this.getFilterWindow(),taps=new Array(filterWindow),i=1;i<=filterWindow;i++)taps[i-1]=lobeFunction(i*scale);return taps},generateShader:function(filterWindow){for(var offsets=new Array(filterWindow),fragmentShader=this.fragmentSourceTOP,filterWindow,i=1;i<=filterWindow;i++)offsets[i-1]=i+".0 * uDelta";return fragmentShader+="uniform float uTaps["+filterWindow+"];\n",fragmentShader+="void main() {\n",fragmentShader+="  vec4 color = texture2D(uTexture, vTexCoord);\n",fragmentShader+="  float sum = 1.0;
1\n",offsets.forEach(function(offset,i2){fragmentShader+="  color += texture2D(uTexture, vTexCoord + "+offset+") * uTaps["+i2+"];\n",fragmentShader+="  color += texture2D(uTexture, vTexCoord - "+offset+") * uTaps["+i2+"];\n",fragmentShader+="  sum += 2.0 * uTaps["+i2+"];\n"}),fragmentShader+="  gl_FragColor = color / sum;\n",fragmentShader+="}",fragmentShader},fragmentSourceTOP:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",applyTo:function(options){options.webgl?(options.passes++,this.width=options.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=options.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),options.destinationWidth=this.dW,this._setupFrameBuffer(options),this.applyToWebGL(options),this._swapTextures(options),options.sourceWidth=options.destinationWidth,this.height=options.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),options.destinationHeight=this.dH,this._setupFrameBuffer(options),this.applyToWebGL(options),this._swapTextures(options),options.sourceHeight=options.destinationHeight):this.applyTo2d(options)},isNeutralState:function(){return this.scaleX===1&&this.scaleY===1},lanczosCreate:function(lobes){return function(x){if(x>=lobes||x<=-lobes)return 0;if(x<11920929e-14&&x>-11920929e-14)return 1;x*=Math.PI;var xx=x/lobes;return sin(x)/x*sin(xx)/xx}},applyTo2d:function(options){var imageData=options.imageData,scaleX=this.scaleX,scaleY=this.scaleY;this.rcpScaleX=1/scaleX,this.rcpScaleY=1/scaleY;var oW=imageData.width,oH=imageData.height,dW=round(oW*scaleX),dH=round(oH*scaleY),newData;this.resizeType==="sliceHack"?newData=this.sliceByTwo(options,oW,oH,dW,dH):this.resizeType==="hermite"?newData=this.hermiteFastResize(options,oW,oH,dW,dH):this.resizeType==="bilinear"?newData=this.bilinearFiltering(options,oW,oH,dW,dH):this.resizeType==="lanczos"&&(newData=this.lanczosResize(options,oW,oH,dW,dH)),options.imageData=newData},sliceByTwo:function(options,oW,oH,dW,dH){var imageData=options.imageData,mult=.5,doneW=!1,doneH=!1,stepW=oW*mult,stepH=oH*mult,resources=fabric2.filterBackend.resources,tmpCanvas,ctx,sX=0,sY=0,dX=oW,dY=0;for(resources.sliceByTwo||(resources.sliceByTwo=document.createElement("canvas")),tmpCanvas=resources.sliceByTwo,(tmpCanvas.width<oW*1.5||tmpCanvas.height<oH)&&(tmpCanvas.width=oW*1.5,tmpCanvas.height=oH),ctx=tmpCanvas.getContext("2d"),ctx.clearRect(0,0,oW*1.5,oH),ctx.putImageData(imageData,0,0),dW=floor(dW),dH=floor(dH);!doneW||!doneH;)oW=stepW,oH=stepH,dW<floor(stepW*mult)?stepW=floor(stepW*mult):(stepW=dW,doneW=!0),dH<floor(stepH*mult)?stepH=floor(stepH*mult):(stepH=dH,doneH=!0),ctx.drawImage(tmpCanvas,sX,sY,oW,oH,dX,dY,stepW,stepH),sX=dX,sY=dY,dY+=stepH;return ctx.getImageData(sX,sY,dW,dH)},lanczosResize:function(options,oW,oH,dW,dH){function process(u){var v,i,weight,idx,a,red,green,blue,alpha,fX,fY;for(center.x=(u+.5)*ratioX,icenter.x=floor(center.x),v=0;v<dH;v++){for(center.y=(v+.5)*ratioY,icenter.y=floor(center.y),a=0,red=0,green=0,blue=0,alpha=0,i=icenter.x-range2X;i<=icenter.x+range2X;i++)if(!(i<0||i>=oW)){fX=floor(1e3*abs(i-center.x)),cacheLanc[fX]||(cacheLanc[fX]={});for(var j=icenter.y-range2Y;j<=icenter.y+range2Y;j++)j<0||j>=oH||(fY=floor(1e3*abs(j-center.y)),cacheLanc[fX][fY]||(cacheLanc[fX][fY]=lanczos(sqrt(pow(fX*rcpRatioX,2)+pow(fY*rcpRatioY,2))/1e3)),weight=cacheLanc[fX][fY],weight>0&&(idx=(j*oW+i)*4,a+=weight,red+=weight*srcData[idx],green+=weight*srcData[idx+1],blue+=weight*srcData[idx+2],alpha+=weight*srcData[idx+3]))}idx=(v*dW+u)*4,destData[idx]=red/a,destData[idx+1]=green/a,destData[idx+2]=blue/a,destData[idx+3]=alpha/a}return++u<dW?process(u):destImg}var srcData=options.imageData.data,destImg=options.ctx.createImageData(dW,dH),destData=destImg.data,lanczos=this.lanczosCreate(this.lanczosLobes),ratioX=this.rcpScaleX,ratioY=this.rcpScaleY,rcpRatioX=2/this.rcpScaleX,rcpRatioY=2/this.rcpScaleY,range2X=ceil(ratioX*this.lanczosLobes/2),range2Y=ceil(ratioY*this.lanczosLobes/2),cacheLanc={},center={},icenter={};return process(0)},bilinearFiltering:function(options,oW,oH,dW,dH){var a,b,c,d,x,y,i,j,xDiff,yDiff,chnl,color,offset=0,origPix,ratioX=this.rcpScaleX,ratioY=this.rcpScaleY,w4=4*(oW-1),img=options.imageData,pixels=img.data,destImage=options.ctx.createImageData(dW,dH),destPixels=destImage.data;for(i=0;i<dH;i++)for(j=0;j<dW;j++)for(x=floor(ratioX*j),y=floor(ratioY*i),xDiff=ratioX*j-x,yDiff=ratioY*i-y,origPix=4*(y*oW+x),chnl=0;chnl<4;chnl++)a=pixels[origPix+chnl],b=pixels[origPix+4+chnl],c=pixels[origPix+w4+c
1hnl],d=pixels[origPix+w4+4+chnl],color=a*(1-xDiff)*(1-yDiff)+b*xDiff*(1-yDiff)+c*yDiff*(1-xDiff)+d*xDiff*yDiff,destPixels[offset++]=color;return destImage},hermiteFastResize:function(options,oW,oH,dW,dH){for(var ratioW=this.rcpScaleX,ratioH=this.rcpScaleY,ratioWHalf=ceil(ratioW/2),ratioHHalf=ceil(ratioH/2),img=options.imageData,data=img.data,img2=options.ctx.createImageData(dW,dH),data2=img2.data,j=0;j<dH;j++)for(var i=0;i<dW;i++){for(var x2=(i+j*dW)*4,weight=0,weights=0,weightsAlpha=0,gxR=0,gxG=0,gxB=0,gxA=0,centerY=(j+.5)*ratioH,yy=floor(j*ratioH);yy<(j+1)*ratioH;yy++)for(var dy=abs(centerY-(yy+.5))/ratioHHalf,centerX=(i+.5)*ratioW,w0=dy*dy,xx=floor(i*ratioW);xx<(i+1)*ratioW;xx++){var dx=abs(centerX-(xx+.5))/ratioWHalf,w=sqrt(w0+dx*dx);w>1&&w<-1||(weight=2*w*w*w-3*w*w+1,weight>0&&(dx=4*(xx+yy*oW),gxA+=weight*data[dx+3],weightsAlpha+=weight,data[dx+3]<255&&(weight=weight*data[dx+3]/250),gxR+=weight*data[dx],gxG+=weight*data[dx+1],gxB+=weight*data[dx+2],weights+=weight))}data2[x2]=gxR/weights,data2[x2+1]=gxG/weights,data2[x2+2]=gxB/weights,data2[x2+3]=gxA/weightsAlpha}return img2},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),fabric2.Image.filters.Resize.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Contrast=createClass(filters.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(options){if(this.contrast!==0){var imageData=options.imageData,i,len,data=imageData.data,len=data.length,contrast=Math.floor(this.contrast*255),contrastF=259*(contrast+255)/(255*(259-contrast));for(i=0;i<len;i+=4)data[i]=contrastF*(data[i]-128)+128,data[i+1]=contrastF*(data[i+1]-128)+128,data[i+2]=contrastF*(data[i+2]-128)+128}},getUniformLocations:function(gl,program){return{uContrast:gl.getUniformLocation(program,"uContrast")}},sendUniformData:function(gl,uniformLocations){gl.uniform1f(uniformLocations.uContrast,this.contrast)}}),fabric2.Image.filters.Contrast.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Saturation=createClass(filters.BaseFilter,{type:"Saturation",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",saturation:0,mainParameter:"saturation",applyTo2d:function(options){if(this.saturation!==0){var imageData=options.imageData,data=imageData.data,len=data.length,adjust=-this.saturation,i,max;for(i=0;i<len;i+=4)max=Math.max(data[i],data[i+1],data[i+2]),data[i]+=max!==data[i]?(max-data[i])*adjust:0,data[i+1]+=max!==data[i+1]?(max-data[i+1])*adjust:0,data[i+2]+=max!==data[i+2]?(max-data[i+2])*adjust:0}},getUniformLocations:function(gl,program){return{uSaturation:gl.getUniformLocation(program,"uSaturation")}},sendUniformData:function(gl,uniformLocations){gl.uniform1f(uniformLocations.uSaturation,-this.saturation)}}),fabric2.Image.filters.Saturation.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Blur=createClass(filters.BaseFilter,{type:"Blur",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",blur:0,mainParameter:"blur",applyTo:function(options){options.webgl?(this.aspectRatio=options.sourceWidth/options.sourceHeight,options.passes++,this._setupFrameBuffer(options),this.horizontal=!0,this.applyToWebGL(options),this._swapTextures(options),this._setupFrameBuffer(options),this.horizontal=!1,this.applyToWebGL(options),this._swapTextures(options)):this.applyTo2d(options)},applyTo2d:function(options){options.imageData=this.simpleBlur(options)},simpleBlur:function(options){var resources=options.filterBackend.resources,canvas1,canvas2,width=options.imageData.width,height=options.imageData.height;resources.blurLayer1||(resources.blurLayer1=fabric2.util.createCanvasElement(),resources.blurLayer2=fabric2.util.createCanvasElement()),canvas1=resources.blurLayer1,canvas2=resources.blurLayer2,(canvas1.width!==width||canvas1.height!==height)&&(canvas2.width=canvas1.width=width,canvas2.height=canvas1.height=height);var ctx1=canvas1.getContext("2d"),ctx2=canvas2.getContext("2d"),nSamples=15,random,percent,j,i,blur=this.blur*.06*.5;for(ctx1.putImageData(options.imageData,0,0),ctx2.clearRect(0,0,width,height),i=-nSamples;i<=nSamples;i++)random=(Math.random()-.5)/4,percent=i/nSamples,j=blur*percent*width+random,ctx2.globalAlpha=1-Math.abs(percent),ctx2.drawImage(canvas1,j,random),ctx1.drawImage(canvas2,0,0),ctx2.globalAlpha=1,ctx2.clearRect(0,0,canvas2.width,canvas2.height);for(i=-nSamples;i<=nSamples;i++)random=(Math.random()-.5)/4,percent=i/nSamples,j=blur*percent*height+random,ctx2.globalAlpha=1-Math.abs(percent),ctx2.drawImage(canvas1,random,j),ctx1.drawImage(canvas2,0,0),ctx2.globalAlpha=1,ctx2.clearRect(0,0,canvas2.width,canvas2.height);options.ctx.drawImage(canvas1,0,0);var newImageData=options.ctx.getImageData(0,0,canvas1.width,canvas1.height);return ctx1.globalAlpha=1,ctx1.clearRect(0,0,canvas1.width,canvas1.height),newImageData},getUniformLocations:function(gl,program){return{delta:gl.getUniformLocation(program,"uDelta")}},sendUniformData:function(gl,uniformLocations){var delta=this.chooseRightDelta();gl.uniform2fv(uniformLocations.delta,delta)},chooseRightDelta:function(){var blurScale=1,delta=[0,0],blur;return this.horizontal?this.aspectRatio>1&&(blurScale=1/this.aspectRatio):this.aspectRatio<1&&(blurScale=this.aspectRatio),blur=blurScale*this.blur*.
112,this.horizontal?delta[0]=blur:delta[1]=blur,delta}}),filters.Blur.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Gamma=createClass(filters.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(options){this.gamma=[1,1,1],filters.BaseFilter.prototype.initialize.call(this,options)},applyTo2d:function(options){var imageData=options.imageData,data=imageData.data,gamma=this.gamma,len=data.length,rInv=1/gamma[0],gInv=1/gamma[1],bInv=1/gamma[2],i;for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),i=0,len=256;i<len;i++)this.rVals[i]=Math.pow(i/255,rInv)*255,this.gVals[i]=Math.pow(i/255,gInv)*255,this.bVals[i]=Math.pow(i/255,bInv)*255;for(i=0,len=data.length;i<len;i+=4)data[i]=this.rVals[data[i]],data[i+1]=this.gVals[data[i+1]],data[i+2]=this.bVals[data[i+2]]},getUniformLocations:function(gl,program){return{uGamma:gl.getUniformLocation(program,"uGamma")}},sendUniformData:function(gl,uniformLocations){gl.uniform3fv(uniformLocations.uGamma,this.gamma)}}),fabric2.Image.filters.Gamma.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.Composed=createClass(filters.BaseFilter,{type:"Composed",subFilters:[],initialize:function(options){this.callSuper("initialize",options),this.subFilters=this.subFilters.slice(0)},applyTo:function(options){options.passes+=this.subFilters.length-1,this.subFilters.forEach(function(filter){filter.applyTo(options)})},toObject:function(){return fabric2.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(filter){return filter.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(filter){return!filter.isNeutralState()})}}),fabric2.Image.filters.Composed.fromObject=function(object,callback){var filters2=object.subFilters||[],subFilters=filters2.map(function(filter){return new fabric2.Image.filters[filter.type](filter)}),instance=new fabric2.Image.filters.Composed({subFilters:subFilters});return callback&&callback(instance),instance}})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),filters=fabric2.Image.filters,createClass=fabric2.util.createClass;filters.HueRotation=createClass(filters.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var rad=this.rotation*Math.PI,cos=fabric2.util.cos(rad),sin=fabric2.util.sin(rad),aThird=1/3,aThirdSqtSin=Math.sqrt(aThird)*sin,OneMinusCos=1-cos;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=cos+OneMinusCos/3,this.matrix[1]=aThird*OneMinusCos-aThirdSqtSin,this.matrix[2]=aThird*OneMinusCos+aThirdSqtSin,this.matrix[5]=aThird*OneMinusCos+aThirdSqtSin,this.matrix[6]=cos+aThird*OneMinusCos,this.matrix[7]=aThird*OneMinusCos-aThirdSqtSin,this.matrix[10]=aThird*OneMinusCos-aThirdSqtSin,this.matrix[11]=aThird*OneMinusCos+aThirdSqtSin,this.matrix[12]=cos+aThird*OneMinusCos},isNeutralState:function(options){return this.calculateMatrix(),filters.BaseFilter.prototype.isNeutralState.call(this,options)},applyTo:function(options){this.calculateMatrix(),filters.BaseFilter.prototype.applyTo.call(this,options)}}),fabric2.Image.filters.HueRotation.fromObject=fabric2.Image.filters.BaseFilter.fromObject})(typeof exports!="undefined"?exports:this),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={}),clone=fabric2.util.object.clone;if(fabric2.Text){fabric2.warn("fabric.Text is already defined");return}fabric2.Text=fabric2.util.createClass(fabric2.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11}
1,textBackgroundColor:"",stateProperties:fabric2.Object.prototype.stateProperties.concat("fontFamily","fontWeight","fontSize","text","underline","overline","linethrough","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing","styles"),cacheProperties:fabric2.Object.prototype.cacheProperties.concat("fontFamily","fontWeight","fontSize","text","underline","overline","linethrough","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing","styles"),stroke:null,shadow:null,_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(text,options){this.styles=options?options.styles||{}:{},this.text=text,this.__skipDimension=!0,this.callSuper("initialize",options),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},getMeasuringContext:function(){return fabric2._measuringContext||(fabric2._measuringContext=this.canvas&&this.canvas.contextCache||fabric2.util.createCanvasElement().getContext("2d")),fabric2._measuringContext},_splitText:function(){var newLines=this._splitTextIntoLines(this.text);return this.textLines=newLines.lines,this._textLines=newLines.graphemeLines,this._unwrappedTextLines=newLines._unwrappedLines,this._text=newLines.graphemeText,newLines},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var diffSpace,currentLineWidth,numberOfSpaces,accumulatedSpace,line,charBound,spaces,i=0,len=this._textLines.length;i<len;i++)if(!(this.textAlign!=="justify"&&(i===len-1||this.isEndOfWrapping(i)))&&(accumulatedSpace=0,line=this._textLines[i],currentLineWidth=this.getLineWidth(i),currentLineWidth<this.width&&(spaces=this.textLines[i].match(this._reSpacesAndTabs)))){numberOfSpaces=spaces.length,diffSpace=(this.width-currentLineWidth)/numberOfSpaces;for(var j=0,jlen=line.length;j<=jlen;j++)charBound=this.__charBounds[i][j],this._reSpaceAndTab.test(line[j])?(charBound.width+=diffSpace,charBound.kernedWidth+=diffSpace,charBound.left+=accumulatedSpace,accumulatedSpace+=diffSpace):charBound.left+=accumulatedSpace}},isEndOfWrapping:function(lineIndex){return lineIndex===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var dims=this.callSuper("_getCacheCanvasDimensions"),fontSize=this.fontSize;return dims.width+=fontSize*dims.zoomX,dims.height+=fontSize*dims.zoomY,dims},_render:function(ctx){this._setTextStyles(ctx),this._renderTextLinesBackground(ctx),this._renderTextDecoration(ctx,"underline"),this._renderText(ctx),this._renderTextDecoration(ctx,"overline"),this._renderTextDecoration(ctx,"linethrough")},_renderText:function(ctx){this.paintFirst==="stroke"?(this._renderTextStroke(ctx),this._renderTextFill(ctx)):(this._renderTextFill(ctx),this._renderTextStroke(ctx))},_setTextStyles:function(ctx,charStyle,forMeasuring){ctx.textBaseline="alphabetic",ctx.font=this._getFontDeclaration(ch
1arStyle,forMeasuring)},calcTextWidth:function(){for(var maxWidth=this.getLineWidth(0),i=1,len=this._textLines.length;i<len;i++){var currentLineWidth=this.getLineWidth(i);currentLineWidth>maxWidth&&(maxWidth=currentLineWidth)}return maxWidth},_renderTextLine:function(method,ctx,line,left,top,lineIndex){this._renderChars(method,ctx,line,left,top,lineIndex)},_renderTextLinesBackground:function(ctx){if(!(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))){for(var lineTopOffset=0,heightOfLine,lineLeftOffset,originalFill=ctx.fillStyle,line,lastColor,leftOffset=this._getLeftOffset(),topOffset=this._getTopOffset(),boxStart=0,boxWidth=0,charBox,currentColor,i=0,len=this._textLines.length;i<len;i++){if(heightOfLine=this.getHeightOfLine(i),!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",i)){lineTopOffset+=heightOfLine;continue}line=this._textLines[i],lineLeftOffset=this._getLineLeftOffset(i),boxWidth=0,boxStart=0,lastColor=this.getValueOfPropertyAt(i,0,"textBackgroundColor");for(var j=0,jlen=line.length;j<jlen;j++)charBox=this.__charBounds[i][j],currentColor=this.getValueOfPropertyAt(i,j,"textBackgroundColor"),currentColor!==lastColor?(ctx.fillStyle=lastColor,lastColor&&ctx.fillRect(leftOffset+lineLeftOffset+boxStart,topOffset+lineTopOffset,boxWidth,heightOfLine/this.lineHeight),boxStart=charBox.left,boxWidth=charBox.width,lastColor=currentColor):boxWidth+=charBox.kernedWidth;currentColor&&(ctx.fillStyle=currentColor,ctx.fillRect(leftOffset+lineLeftOffset+boxStart,topOffset+lineTopOffset,boxWidth,heightOfLine/this.lineHeight)),lineTopOffset+=heightOfLine}ctx.fillStyle=originalFill,this._removeShadow(ctx)}},getFontCache:function(decl){var fontFamily=decl.fontFamily.toLowerCase();fabric2.charWidthsCache[fontFamily]||(fabric2.charWidthsCache[fontFamily]={});var cache=fabric2.charWidthsCache[fontFamily],cacheProp=decl.fontStyle.toLowerCase()+"_"+(decl.fontWeight+"").toLowerCase();return cache[cacheProp]||(cache[cacheProp]={}),cache[cacheProp]},_applyCharStyles:function(method,ctx,lineIndex,charIndex,styleDeclaration){this._setFillStyles(ctx,styleDeclaration),this._setStrokeStyles(ctx,styleDeclaration),ctx.font=this._getFontDeclaration(styleDeclaration)},_measureChar:function(_char,charStyle,previousChar,prevCharStyle){var fontCache=this.getFontCache(charStyle),fontDeclaration=this._getFontDeclaration(ch
1arStyle),previousFontDeclaration=this._getFontDeclaration(prevCharStyle),couple=previousChar+_char,stylesAreEqual=fontDeclaration===previousFontDeclaration,width,coupleWidth,previousWidth,fontMultiplier=charStyle.fontSize/this.CACHE_FONT_SIZE,kernedWidth;if(previousChar&&fontCache[previousChar]!==void 0&&(previousWidth=fontCache[previousChar]),fontCache[_char]!==void 0&&(kernedWidth=width=fontCache[_char]),stylesAreEqual&&fontCache[couple]!==void 0&&(coupleWidth=fontCache[couple],kernedWidth=coupleWidth-previousWidth),width===void 0||previousWidth===void 0||coupleWidth===void 0){var ctx=this.getMeasuringContext();this._setTextStyles(ctx,charStyle,!0)}return width===void 0&&(kernedWidth=width=ctx.measureText(_char).width,fontCache[_char]=width),previousWidth===void 0&&stylesAreEqual&&previousChar&&(previousWidth=ctx.measureText(previousChar).width,fontCache[previousChar]=previousWidth),stylesAreEqual&&coupleWidth===void 0&&(coupleWidth=ctx.measureText(couple).width,fontCache[couple]=coupleWidth,kernedWidth=coupleWidth-previousWidth),{width:width*fontMultiplier,kernedWidth:kernedWidth*fontMultiplier}},getHeightOfChar:function(line,_char){return this.getValueOfPropertyAt(line,_char,"fontSize")},measureLine:function(lineIndex){var lineInfo=this._measureLine(lineIndex);return this.charSpacing!==0&&(lineInfo.width-=this._getWidthOfCharSpacing()),lineInfo.width<0&&(lineInfo.width=0),lineInfo},_measureLine:function(lineIndex){var width=0,i,grapheme,line=this._textLines[lineIndex],prevGrapheme,graphemeInfo,numOfSpaces=0,lineBounds=new Array(line.length);for(this.__charBounds[lineIndex]=lineBounds,i=0;i<line.length;i++)grapheme=line[i],graphemeInfo=this._getGraphemeBox(grapheme,lineIndex,i,prevGrapheme),lineBounds[i]=graphemeInfo,width+=graphemeInfo.kernedWidth,prevGrapheme=grapheme;return lineBounds[i]={left:graphemeInfo?graphemeInfo.left+graphemeInfo.width:0,width:0,kernedWidth:0,height:this.fontSize},{width:width,numOfSpaces:numOfSpaces}},_getGraphemeBox:function(grapheme,lineIndex,charIndex,prevGrapheme,skipLeft){var style=this.getCompleteStyleDeclaration(lineIndex,charIndex),prevStyle=prevGrapheme?this.getCompleteStyleDeclaration(lineIndex,charIndex-1):{},info=this._measureChar(grapheme,style,prevGrapheme,prevStyle),kernedWidth=info.kernedWidth,width=info.width,charSpacing;this.charSpacing!==0&&(charSpacing=this._getWidthOfCharSpacing(),width+=charSpacing,kernedWidth+=charSpacing);var box={width:width,left:0,height:style.fontSize,kernedWidth:kernedWidth,deltaY:style.deltaY};if(charIndex>0&&!skipLeft){var previousBox=this.__charBounds[lineIndex][charIndex-1];box.left=previousBox.left+previousBox.width+info.kernedWidth-info.width}return box},getHeightOfLine:function(lineIndex){if(this.__lineHeights[lineIndex])return this.__lineHeights[lineIndex];for(var line=this._textLines[lineIndex],maxHeight=this.getHeightOfChar(lineIndex,0),i=1,len=line.length;i<len;i++)maxHeight=Math.max(this.getHeightOfChar(lineIndex,i),maxHeight);return this.__lineHeights[lineIndex]=maxHeight*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var lineHeight,height=0,i=0,len=this._textLines.length;i<len;i++)lineHeight=this.getHeightOfLine(i),height+=i===len-1?lineHeight/this.lineHeight:lineHeight;return height},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(ctx,method){ctx.save();for(var lineHeights=0,left=this._getLeftOffset(),top=this._getTopOffset(),offsets=this._applyPatternGradientTransform(ctx,method==="fillText"?this.fill:this.stroke),i=0,len=this._textLines.length;i<len;i++){var heightOfLine=this.getHeightOfLine(i),maxHeight=heightOfLine/this.lineHeight,leftOffset=this._getLineLeftOffset(i);this._renderTextLine(method,ctx,this._textLines[i],left+leftOffset-offsets.offsetX,top+lineHeights+maxHeight-offsets.offsetY,i),lineHeights+=heightOfLine}ctx.restore()},_renderTextFill:function(ctx){!this.fill&&!this.styleHas("fill")||this._renderTextCommon(ctx,"fillText")},_renderTextStroke:function(ctx){(!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(ctx),ctx.save(),this._setLineDash(ctx,this.strokeDashArray),ctx.beginPath(),this._renderTextCommon(ctx,"strokeText"),ctx.closePath(),ctx.restore(
1))},_renderChars:function(method,ctx,line,left,top,lineIndex){var lineHeight=this.getHeightOfLine(lineIndex),isJustify=this.textAlign.indexOf("justify")!==-1,actualStyle,nextStyle,charsToRender="",charBox,boxWidth=0,timeToRender,shortCut=!isJustify&&this.charSpacing===0&&this.isEmptyStyles(lineIndex);if(ctx.save(),top-=lineHeight*this._fontSizeFraction/this.lineHeight,shortCut){this._renderChar(method,ctx,lineIndex,0,line.join(""),left,top,lineHeight),ctx.restore();return}for(var i=0,len=line.length-1;i<=len;i++)timeToRender=i===len||this.charSpacing,charsToRender+=line[i],charBox=this.__charBounds[lineIndex][i],boxWidth===0?(left+=charBox.kernedWidth-charBox.width,boxWidth+=charBox.width):boxWidth+=charBox.kernedWidth,isJustify&&!timeToRender&&this._reSpaceAndTab.test(line[i])&&(timeToRender=!0),timeToRender||(actualStyle=actualStyle||this.getCompleteStyleDeclaration(lineIndex,i),nextStyle=this.getCompleteStyleDeclaration(lineIndex,i+1),timeToRender=this._hasStyleChanged(actualStyle,nextStyle)),timeToRender&&(this._renderChar(method,ctx,lineIndex,i,charsToRender,left,top,lineHeight),charsToRender="",actualStyle=nextStyle,left+=boxWidth,boxWidth=0);ctx.restore()},_renderChar:function(method,ctx,lineIndex,charIndex,_char,left,top){var decl=this._getStyleDeclaration(lineIndex,charIndex),fullDecl=this.getCompleteStyleDeclaration(lineIndex,charIndex),shouldFill=method==="fillText"&&fullDecl.fill,shouldStroke=method==="strokeText"&&fullDecl.stroke&&fullDecl.strokeWidth;!shouldStroke&&!shouldFill||(decl&&ctx.save(),this._applyCharStyles(method,ctx,lineIndex,charIndex,fullDecl),decl&&decl.textBackgroundColor&&this._removeShadow(ctx),decl&&decl.deltaY&&(top+=decl.deltaY),shouldFill&&ctx.fillText(_char,left,top),shouldStroke&&ctx.strokeText(_char,left,top),decl&&ctx.restore())},setSuperscript:function(start,end){return this._setScript(start,end,this.superscript)},setSubscript:function(start,end){return this._setScript(start,end,this.subscript)},_setScript:function(start,end,schema){var loc=this.get2DCursorLocation(start,!0),fontSize=this.getValueOfPropertyAt(loc.lineIndex,loc.charIndex,"fontSize"),dy=this.getValueOfPropertyAt(loc.lineIndex,loc.charIndex,"deltaY"),style={fontSize:fontSize*schema.size,deltaY:dy+fontSize*schema.baseline};return this.setSelectionStyles(style,start,end),this},_hasStyleChanged:function(prevStyle,thisStyle){return prevStyle.fill!==thisStyle.fill||prevStyle.stroke!==thisStyle.stroke||prevStyle.strokeWidth!==thisStyle.strokeWidth||prevStyle.fontSize!==thisStyle.fontSize||prevStyle.fontFamily!==thisStyle.fontFamily||prevStyle.fontWeight!==thisStyle.fontWeight||prevStyle.fontStyle!==thisStyle.fontStyle||prevStyle.deltaY!==thisStyle.deltaY},_hasStyleChangedForSvg:function(prevStyle,thisStyle){return this._hasStyleChanged(prevStyle,thisStyle)||prevStyle.overline!==thisStyle.overline||prevStyle.underline!==thisStyle.underline||prevStyle.linethrough!==thisStyle.linethrough},_getLineLeftOffset:function(lineIndex){var lineWidth=this.getLineWidth(lineIndex);return this.textAlign==="center"?(this.width-lineWidth)/2:this.textAlign==="right"?this.width-lineWidth:this.textAlign==="justify-center"&&this.isEndOfWrapping(lineIndex)?(this.width-lineWidth)/2:this.textAlign==="justify-right"&&this.isEndOfWrapping(lineIndex)?this.width-lineWidth:0},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var shouldClear=this._forceClearCache;return shouldClear||(shouldClear=this.hasStateChanged("_dimensionAffectingProps")),shouldClear&&(this.dirty=!0,this._forceClearCache=!1),shouldClear},getLineWidth:function(lineIndex){if(this.__lineWidths[lineIndex])return this.__lineWidths[lineIndex];var width,line=this._textLines[lineIndex],lineInfo;return line===""?width=0:(lineInfo=this.measureLine(lineIndex),width=lineInfo.width),this.__lineWidths[lineIndex]=width,width},_getWidthOfCharSpacing:function(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(lineIndex,charIndex,property){var charStyle=this._getStyleDeclaration(lineIndex,charIndex);return charStyle&&typeof charStyle[property]!="undefined"?charStyle[property]:this[property]},_renderTextDecoration:function(ctx,type){if(!(!this[type]&&!this.styleHas(type))){for(var heightOfLine,size,_size,lineLeftOffset,dy,_dy,line,lastDecoration,leftOffset=this._getLeftOffset(),topOffset=this._getTopOffset(),top,boxStart,boxWidth,charBox,currentDecoration,maxHeight,currentFill,lastFill,charSpacing=this._getWidthOfCharSpacing(),i=0,len=this._textLines.length;i<len;i++){if(heightOfLine=this.getHeightOfLine(i),!this[type]&&!this.styleHas(type,i
1)){topOffset+=heightOfLine;continue}line=this._textLines[i],maxHeight=heightOfLine/this.lineHeight,lineLeftOffset=this._getLineLeftOffset(i),boxStart=0,boxWidth=0,lastDecoration=this.getValueOfPropertyAt(i,0,type),lastFill=this.getValueOfPropertyAt(i,0,"fill"),top=topOffset+maxHeight*(1-this._fontSizeFraction),size=this.getHeightOfChar(i,0),dy=this.getValueOfPropertyAt(i,0,"deltaY");for(var j=0,jlen=line.length;j<jlen;j++)charBox=this.__charBounds[i][j],currentDecoration=this.getValueOfPropertyAt(i,j,type),currentFill=this.getValueOfPropertyAt(i,j,"fill"),_size=this.getHeightOfChar(i,j),_dy=this.getValueOfPropertyAt(i,j,"deltaY"),(currentDecoration!==lastDecoration||currentFill!==lastFill||_size!==size||_dy!==dy)&&boxWidth>0?(ctx.fillStyle=lastFill,lastDecoration&&lastFill&&ctx.fillRect(leftOffset+lineLeftOffset+boxStart,top+this.offsets[type]*size+dy,boxWidth,this.fontSize/15),boxStart=charBox.left,boxWidth=charBox.width,lastDecoration=currentDecoration,lastFill=currentFill,size=_size,dy=_dy):boxWidth+=charBox.kernedWidth;ctx.fillStyle=currentFill,currentDecoration&&currentFill&&ctx.fillRect(leftOffset+lineLeftOffset+boxStart,top+this.offsets[type]*size+dy,boxWidth-charSpacing,this.fontSize/15),topOffset+=heightOfLine}this._removeShadow(ctx)}},_getFontDeclaration:function(styleObject,forMeasuring){var style=styleObject||this,family=this.fontFamily,fontIsGeneric=fabric2.Text.genericFonts.indexOf(family.toLowerCase())>-1,fontFamily=family===void 0||family.indexOf("'")>-1||family.indexOf(",")>-1||family.indexOf('"')>-1||fontIsGeneric?style.fontFamily:'"'+style.fontFamily+'"';return[fabric2.isLikelyNode?style.fontWeight:style.fontStyle,fabric2.isLikelyNode?style.fontStyle:style.fontWeight,forMeasuring?this.CACHE_FONT_SIZE+"px":style.fontSize+"px",fontFamily].join(" ")},render:function(ctx){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",ctx)))},_splitTextIntoLines:function(text){for(var lines=text.split(this._reNewline),newLines=new Array(lines.length),newLine=["\n"],newText=[],i=0;i<lines.length;i++)newLines[i]=fabric2.util.string.graphemeSplit(lines[i]),newText=newText.concat(newLines[i],newLine);return newText.pop(),{_unwrappedLines:newLines,lines:lines,graphemeText:newText,graphemeLines:newLines}},toObject:function(propertiesToInclude){var additionalProperties=["text","fontSize","fontWeight","fontFamily","fontStyle","lineHeight","underline","overline","linethrough","textAlign","textBackgroundColor","charSpacing"].concat(propertiesToInclude),obj=this.callSuper("toObject",additionalProperties);return obj.styles=clone(this.styles,!0),obj},set:function(key,value){this.callSuper("set",key,value);var needsDims=!1;if(typeof key=="object")for(var _key in key)needsDims=needsDims||this._dimensionAffectingProps.indexOf(_key)!==-1;else needsDims=this._dimensionAffectingProps.indexOf(key)!==-1;return needsDims&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),fabric2.Text.ATTRIBUTE_NAMES=fabric2.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),fabric2.Text.DEFAULT_SVG_FONT_SIZE=16,fabric2.Text.fromElement=function(element,callback,options){if(!element)return callback(null);var parsedAttributes=fabric2.parseAttributes(element,fabric2.Text.ATTRIBUTE_NAMES),parsedAnchor=parsedAttributes.textAnchor||"left";if(options=fabric2.util.object.extend(options?clone(options):{},parsedAttributes),options.top=options.top||0,options.left=options.left||0,parsedAttributes.textDecoration){var textDecoration=parsedAttributes.textDecoration;textDecoration.indexOf("underline")!==-1&&(options.underline=!0),textDecoration.indexOf("overline")!==-1&&(options.overline=!0),textDecoration.indexOf("line-through")!==-1&&(options.linethrough=!0),delete options.textDecoration}"dx"in parsedAttributes&&(options.left+=parsedAttributes.dx),"dy"in parsedAttributes&&(options.top+=parsedAttributes.dy),"fontSize"in options||(options.fontSize=fabric2.Text.DEFAULT_SVG_FONT_SIZE);var textContent="";"textContent"in element?textContent=element.textContent:"firstChild"in element&&element.firstChild!==null&&"data"in element.firstChild&&element.firstChild.data!==null&&(textContent=element.firstChild.data),textContent=textContent.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var originalStrokeWidth=options.strokeWidth;options.strokeWidth=0;var text=new fabric2.Text(textContent,options),textHeightScaleFactor=text.getScaledHeight()/text.height,lineHeightDiff=(text.height+text.strokeWidth)*text.lineHeight-text.height,scaledDiff=lineHeightDiff*textHeightScaleFactor,textHeight=text.getScaledHeight()+scaledDiff,offX=0;parsedAnchor==="center"&&(offX=text.getScaledWidth()/2),parsedAnchor==="right"&&(offX=text.getScaledWidth()),text.set({left:text.left-offX,top:text.top-(textHeight-text.fontSize*(.07+text._fontSizeFraction))/text.lineHeight,strokeWidth:typeof originalStrokeWidth!="undefined"?originalStrokeWidth:1}),callback(text)},fabric2.Text.fromObject=function(object,callback){return fabric2.Object._fromObject("Text",object,callback,"text")},fabric2.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],fabric2.util.createAccessors&&fabric2.util.createAccessors(fabric2.Text)})(typeof exports!="undefined"?exports:this),(function(){fabric.util.object.extend(fabric.Text.prototype,{isEmptyStyles:function(lineIndex){
1if(!this.styles||typeof lineIndex!="undefined"&&!this.styles[lineIndex])return!0;var obj=typeof lineIndex=="undefined"?this.styles:{line:this.styles[lineIndex]};for(var p1 in obj)for(var p2 in obj[p1])for(var p3 in obj[p1][p2])return!1;return!0},styleHas:function(property,lineIndex){if(!this.styles||!property||property===""||typeof lineIndex!="undefined"&&!this.styles[lineIndex])return!1;var obj=typeof lineIndex=="undefined"?this.styles:{0:this.styles[lineIndex]};for(var p1 in obj)for(var p2 in obj[p1])if(typeof obj[p1][p2][property]!="undefined")return!0;return!1},cleanStyle:function(property){if(!this.styles||!property||property==="")return!1;var obj=this.styles,stylesCount=0,letterCount,stylePropertyValue,allStyleObjectPropertiesMatch=!0,graphemeCount=0,styleObject;for(var p1 in obj){letterCount=0;for(var p2 in obj[p1]){var styleObject=obj[p1][p2],stylePropertyHasBeenSet=styleObject.hasOwnProperty(property);stylesCount++,stylePropertyHasBeenSet?(stylePropertyValue?styleObject[property]!==stylePropertyValue&&(allStyleObjectPropertiesMatch=!1):stylePropertyValue=styleObject[property],styleObject[property]===this[property]&&delete styleObject[property]):allStyleObjectPropertiesMatch=!1,Object.keys(styleObject).length!==0?letterCount++:delete obj[p1][p2]}letterCount===0&&delete obj[p1]}for(var i=0;i<this._textLines.length;i++)graphemeCount+=this._textLines[i].length;allStyleObjectPropertiesMatch&&stylesCount===graphemeCount&&(this[property]=stylePropertyValue,this.removeStyle(property))},removeStyle:function(property){if(!(!this.styles||!property||property==="")){var obj=this.styles,line,lineNum,charNum;for(lineNum in obj){line=obj[lineNum];for(charNum in line)delete line[charNum][property],Object.keys(line[charNum]).length===0&&delete line[charNum];Object.keys(line).length===0&&delete obj[lineNum]}}},_extendStyles:function(index,styles){var loc=this.get2DCursorLocation(index);this._getLineStyle(loc.lineIndex)||this._setLineStyle(loc.lineIndex),this._getStyleDeclaration(loc.lineIndex,loc.charIndex)||this._setStyleDeclaration(loc.lineIndex,loc.charIndex,{}),fabric.util.object.extend(this._getStyleDeclaration(loc.lineIndex,loc.charIndex),styles)}
1,get2DCursorLocation:function(selectionStart,skipWrapping){typeof selectionStart=="undefined"&&(selectionStart=this.selectionStart);for(var lines=skipWrapping?this._unwrappedTextLines:this._textLines,len=lines.length,i=0;i<len;i++){if(selectionStart<=lines[i].length)return{lineIndex:i,charIndex:selectionStart};selectionStart-=lines[i].length+this.missingNewlineOffset(i)}return{lineIndex:i-1,charIndex:lines[i-1].length<selectionStart?lines[i-1].length:selectionStart}},getSelectionStyles:function(startIndex,endIndex,complete){typeof startIndex=="undefined"&&(startIndex=this.selectionStart||0),typeof endIndex=="undefined"&&(endIndex=this.selectionEnd||startIndex);for(var styles=[],i=startIndex;i<endIndex;i++)styles.push(this.getStyleAtPosition(i,complete));return styles},getStyleAtPosition:function(position,complete){var loc=this.get2DCursorLocation(position),style=complete?this.getCompleteStyleDeclaration(loc.lineIndex,loc.charIndex):this._getStyleDeclaration(loc.lineIndex,loc.charIndex);return style||{}},setSelectionStyles:function(styles,startIndex,endIndex){typeof startIndex=="undefined"&&(startIndex=this.selectionStart||0),typeof endIndex=="undefined"&&(endIndex=this.selectionEnd||startIndex);for(var i=startIndex;i<endIndex;i++)this._extendStyles(i,styles);return this._forceClearCache=!0,this},_getStyleDeclaration:function(lineIndex,charIndex){var lineStyle=this.styles&&this.styles[lineIndex];return lineStyle?lineStyle[charIndex]:null},getCompleteStyleDeclaration:function(lineIndex,charIndex){for(var style=this._getStyleDeclaration(lineIndex,charIndex)||{},styleObject={},prop,i=0;i<this._styleProperties.length;i++)prop=this._styleProperties[i],styleObject[prop]=typeof style[prop]=="undefined"?this[prop]:style[prop];return styleObject},_setStyleDeclaration:function(lineIndex,charIndex,style){this.styles[lineIndex][charIndex]=style},_deleteStyleDeclaration:function(lineIndex,charIndex){delete this.styles[lineIndex][charIndex]},_getLineStyle:function(lineIndex){return!!this.styles[lineIndex]},_setLineStyle:function(lineIndex){this.styles[lineIndex]={}},_deleteLineStyle:function(lineIndex){delete this.styles[lineIndex]}})})(),(function(){function parseDecoration(object){object.textDecoration&&(object.textDecoration.indexOf("underline")>-1&&(object.underline=!0),object.textDecoration.indexOf("line-through")>-1&&(object.linethrough=!0),object.textDecoration.indexOf("overline")>-1&&(object.overline=!0),delete object.textDecoration)}fabric.IText=fabric.util.createClass(fabric.Text,fabric.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(text,options){this.callSuper("initialize",text,options),this.initBehavior()},setSelectionStart:function(index){index=Math.max(index,0),this._updateAndFire("selectionStart",index)},setSelectionEnd:function(index){index=Math.min(index,this.text.length),this._updateAndFire("selectionEnd",index)},_updateAndFire:function(property,index){this[property]!==index&&(this._fireSelectionChanged(),this[property]=index),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(ctx){this.clearContextTop(),this.callSuper("render",ctx),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(ctx){this.callSuper("_render",ctx)},clearContextTop:function(skipRestore){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var ctx=this.canvas.contextTop,v=this.canvas.viewportTransform;ctx.save(),ctx.transform(v[0],v[1],v[2],v[3],v[4],v[5]),this.transform(ctx),this._clearTextArea(ctx),skipRestore||ctx.restore()}},renderCursorOrSelection:function(){if(!(!this.isEditing||!this.canvas||!this.canvas.contextTop)){var boundaries=this._getCursorBoundaries(),ctx=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(boundaries,ctx):this.renderSelection(bou
1ndaries,ctx),ctx.restore()}},_clearTextArea:function(ctx){var width=this.width+4,height=this.height+4;ctx.clearRect(-width/2,-height/2,width,height)},_getCursorBoundaries:function(position){typeof position=="undefined"&&(position=this.selectionStart);var left=this._getLeftOffset(),top=this._getTopOffset(),offsets=this._getCursorBoundariesOffsets(position);return{left:left,top:top,leftOffset:offsets.left,topOffset:offsets.top}},_getCursorBoundariesOffsets:function(position){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var lineLeftOffset,lineIndex,charIndex,topOffset=0,leftOffset=0,boundaries,cursorPosition=this.get2DCursorLocation(position);charIndex=cursorPosition.charIndex,lineIndex=cursorPosition.lineIndex;for(var i=0;i<lineIndex;i++)topOffset+=this.getHeightOfLine(i);lineLeftOffset=this._getLineLeftOffset(lineIndex);var bound=this.__charBounds[lineIndex][charIndex];return bound&&(leftOffset=bound.left),this.charSpacing!==0&&charIndex===this._textLines[lineIndex].length&&(leftOffset-=this._getWidthOfCharSpacing()),boundaries={top:topOffset,left:lineLeftOffset+(leftOffset>0?leftOffset:0)},this.cursorOffsetCache=boundaries,this.cursorOffsetCache},renderCursor:function(boundaries,ctx){var cursorLocation=this.get2DCursorLocation(),lineIndex=cursorLocation.lineIndex,charIndex=cursorLocation.charIndex>0?cursorLocation.charIndex-1:0,charHeight=this.getValueOfPropertyAt(lineIndex,charIndex,"fontSize"),multiplier=this.scaleX*this.canvas.getZoom(),cursorWidth=this.cursorWidth/multiplier,topOffset=boundaries.topOffset,dy=this.getValueOfPropertyAt(lineIndex,charIndex,"deltaY");topOffset+=(1-this._fontSizeFraction)*this.getHeightOfLine(lineIndex)/this.lineHeight-charHeight*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(boundaries,ctx),ctx.fillStyle=this.cursorColor||this.getValueOfPropertyAt(lineIndex,charIndex,"fill"),ctx.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,ctx.fillRect(boundaries.left+boundaries.leftOffset-cursorWidth/2,topOffset+boundaries.top+dy,cursorWidth,charHeight)},renderSelection:function(boundaries,ctx){for(var selectionStart=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,isJustify=this.textAlign.indexOf("justify")!==-1,start=this.get2DCursorLocation(selectionStart),end=this.get2DCursorLocation(selectionEnd),startLine=start.lineIndex,endLine=end.lineIndex,startChar=start.charIndex<0?0:start.charIndex,endChar=end.charIndex<0?0:end.charIndex,i=startLine;i<=endLine;i++){var lineOffset=this._getLineLeftOffset(i)||0,lineHeight=this.getHeightOfLine(i),realLineHeight=0,boxStart=0,boxEnd=0;if(i===startLine&&(boxStart=this.__charBounds[startLine][startChar].left),i>=startLine&&i<endLine)boxEnd=isJustify&&!this.isEndOfWrapping(i)?this.width:this.getLineWidth(i)||5;else if(i===endLine)if(endChar===0)boxEnd=this.__charBounds[endLine][endChar].left;else{var charSpacing=this._getWidthOfCharSpacing();boxEnd=this.__charBounds[endLine][endChar-1].left+this.__charBounds[endLine][endChar-1].width-charSpacing}realLineHeight=lineHeight,(this.lineHeight<1||i===endLine&&this.lineHeight>1)&&(lineHeight/=this.lineHeight),this.inCompositionMode?(ctx.fillStyle=this.compositionColor||"black",ctx.fillRect(boundaries.left+lineOffset+boxStart,boundaries.top+boundaries.topOffset+lineHeight,boxEnd-boxStart,1)):(ctx.fillStyle=this.selectionColor,ctx.fillRect(boundaries.left+lineOffset+boxStart,boundaries.top+boundaries.topOffset,boxEnd-boxStart,lineHeight)),boundaries.topOffset+=realLineHeight}},getCurrentCharFontSize:function(){var cp=this._getCurrentCharIndex();return this.getValueOfPropertyAt(cp.l,cp.c,"fontSize")},getCurrentCharColor:function(){var cp=this._getCurrentCharIndex();return this.getValueOfPropertyAt(cp.l,cp.c,"fill")},_getCurrentCharIndex:function(){var cursorPosition=this.get2DCursorLocation(this.selectionStart,!0),charIndex=cursorPosition.charIndex>0?cursorPosition.charIndex-1:0;return{l:cursorPosition.lineIndex,c:charIndex}}}),fabric.IText.fromObject=function(object,callback){if(parseDecoration(object),object.styles)for(var i in object.styles)for(var j in object.styles[i])parseDecoration(object.styles[i][j]);fabric.Object._fromObject("IText",object,callback,"text")}})(),(function(){var clone=fabric.util.object.clone;fabric.util.object.extend(fabric.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var _this=this;this.on("added",function(){var canvas=_this.canvas;canvas&&(canvas._hasITextHandlers||(canvas._hasITextHandlers=!0,_this._initCanvasHandlers(canvas)),canvas._iTextInstances=canvas._iTextInstances||[],canvas._iTextInstances.push(_this))})},initRemovedHandler:function(){var _this=this;this.on("removed",function(){var canvas=_this.canvas;canvas&&(canvas._iTextInstances=canvas._iTextInstances||[],fabric.util.removeFromArray(canvas._iTextInstances,_this),canvas._iTextInstances.length===0&&(canvas._hasITextHandlers=!1,_this._removeCanvasHandlers(canvas)))})},_initCanvasHandlers:function(canvas){canvas._mouseUpITextHandler=function(){canvas._iTextInstances&&canvas._iTextInstances.forEac
vendor: 4,451 bytes, line 1
1h(function(obj){obj.__isMousedown=!1})},canvas.on("mouse:up",canvas._mouseUpITextHandler)},_removeCanvasHandlers:function(canvas){canvas.off("mouse:up",canvas._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(obj,targetOpacity,duration,completeMethod){var tickState;return tickState={isAborted:!1,abort:function(){this.isAborted=!0}},obj.animate("_currentCursorOpacity",targetOpacity,{duration:duration,onComplete:function(){tickState.isAborted||obj[completeMethod]()},onChange:function(){obj.canvas&&obj.selectionStart===obj.selectionEnd&&obj.renderCursorOrSelection()},abort:function(){return tickState.isAborted}}),tickState},_onTickComplete:function(){var _this=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){_this._currentTickCompleteState=_this._animateCursor(_this,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(restart){var _this=this,delay=restart?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){_this._tick()},delay)},abortCursorAnimation:function(){var shouldClear=this._currentTickState||this._currentTickCompleteState,canvas=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,shouldClear&&canvas&&canvas.clearContext(canvas.contextTop||canvas.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(startFrom){var offset=0,index=startFrom-1;if(this._reSpace.test(this._text[index]))for(;this._reSpace.test(this._text[index]);)offset++,index--;for(;/\S/.test(this._text[index])&&index>-1;)offset++,index--;return startFrom-offset},findWordBoundaryRight:function(startFrom){var offset=0,index=startFrom;if(this._reSpace.test(this._text[index]))for(;this._reSpace.test(this._text[index]);)offset++,index++;for(;/\S/.test(this._text[index])&&index<this._text.length;)offset++,index++;return startFrom+offset},findLineBoundaryLeft:function(startFrom){for(var offset=0,index=startFrom-1;!/\n/.test(this._text[index])&&index>-1;)offset++,index--;return startFrom-offset},findLineBoundaryRight:function(startFrom){for(var offset=0,index=startFrom;!/\n/.test(this._text[index])&&index<this._text.length;)offset++,index++;return startFrom+offset},searchWordBoundary:function(selectionStart,direction){for(var text=this._text,index=this._reSpace.test(text[selectionStart])?selectionStart-1:selectionStart,_char=text[index],reNonWord=fabric.reNonWord;!reNonWord.test(_char)&&index>0&&index<text.length;)index+=direction,_char=text[index];return reNonWord.test(_char)&&(index+=direction===1?0:1),index},selectWord:function(selectionStart){selectionStart=selectionStart||this.selectionStart;var newSelectionStart=this.searchWordBoundary(selectionStart,-1),newSelectionEnd=this.searchWordBoundary(selectionStart,1);this.selectionStart=newSelectionStart,this.selectionEnd=newSelectionEnd,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(selectionStart){selectionStart=selectionStart||this.selectionStart;var newSelectionStart=this.findLineBoundaryLeft(selectionStart),newSelectionEnd=this.findLineBoundaryRight(selectionStart);return this.selectionStart=newSelectionStart,this.selectionEnd=newSelectionEnd,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(e){if(!(this.isEditing||!this.editable))return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(e),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(canvas){canvas._iTextInstances&&canvas._iTextInstances.forEac
1h(function(obj){obj.selected=!1,obj.isEditing&&obj.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(options){if(!(!this.__isMousedown||!this.isEditing)){var newSelectionStart=this.getSelectionStartFromPointer(options.e),currentStart=this.selectionStart,currentEnd=this.selectionEnd;(newSelectionStart!==this.__selectionStartOnMouseDown||currentStart===currentEnd)&&(currentStart===newSelectionStart||currentEnd===newSelectionStart)||(newSelectionStart>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=newSelectionStart):(this.selectionStart=newSelectionStart,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==currentStart||this.selectionEnd!==currentEnd)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(start,end,text){var smallerTextStart=text.slice(0,start),graphemeStart=fabric.util.string.graphemeSplit(smallerTextStart).length;if(start===end)return{selectionStart:graphemeStart,selectionEnd:graphemeStart};var smallerTextEnd=text.slice(start,end),graphemeEnd=fabric.util.string.graphemeSplit(smallerTextEnd).length;return{selectionStart:graphemeStart,selectionEnd:graphemeStart+graphemeEnd}},fromGraphemeToStringSelection:function(start,end,_text){var smallerTextStart=_text.slice(0,start),graphemeStart=smallerTextStart.join("").length;if(start===end)return{selectionStart:graphemeStart,selectionEnd:graphemeStart};var smallerTextEnd=_text.slice(start,end),graphemeEnd=smallerTextEnd.join("").length;return{selectionStart:graphemeStart,selectionEnd:graphemeStart+graphemeEnd}},_updateTextarea:function(){if(this.cursorOffsetCache={},!!this.hiddenTextarea){if(!this.inCompositionMode){var newSelection=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=newSelection.selectionStart,this.hiddenTextarea.selectionEnd=newSelection.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var newSelection=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=newSelection.selectionEnd,this.inCompositionMode||(this.selectionStart=newSelection.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var style=this._calcTextareaPosition();this.hiddenTextarea.style.left=style.left,this.hiddenTextarea.style.top=style.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var desiredPosition=this.inCompositionMode?this.compositionStart:this.selectionStart,boundaries=this._getCursorBoundaries(desiredPosition),cursorLocation=this.get2DCursorLocation(desiredPosition),lineIndex=cursorLocation.lineIndex,charIndex=cursorLocation.charIndex,charHeight=this.getValueOfPropertyAt(lineIndex,charIndex,"fontSize")*this.lineHeight,leftOffset=boundaries.leftOffset,m=this.calcTransformMatrix(),p={x:boundaries.left+leftOffset,y:boundaries.top+boundaries.topOffset+charHeight},retinaScaling=this.canvas.getRetinaScaling(),upperCanvas=this.canvas.upperCanvasEl,upperCanvasWidth=upperCanvas.width/retinaScaling,upperCanvasHeight=upperCanvas.height/retinaScaling,maxWidth=upperCanvasWidth-charHeight,maxHeight=upperCanvasHeight-charHeight,scaleX=upperCanvas.clientWidth/upperCanvasWidth,scaleY=upperCanvas.clientHeight/upperCanvasHeight;return p=fabric.util.transformPoint(p,m),p=fabric.util.transformPoint(p,this.canvas.viewportTransform),p.x*=scaleX,p.y*=scaleY,p.x<0&&(p.x=0),p.x>maxWidth&&(p.x=maxWidth),p.y<0&&(p.y=0),p.y>maxHeight&&(p.y=maxHeight),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:p.x+"px",top:p.y+"px",fontSize:charHeight+"px",charHeight:charHeight}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCurs
1or:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var isTextChanged=this._textBeforeEdit!==this.text,hiddenTextarea=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,hiddenTextarea&&(hiddenTextarea.blur&&hiddenTextarea.blur(),hiddenTextarea.parentNode&&hiddenTextarea.parentNode.removeChild(hiddenTextarea)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),isTextChanged&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),isTextChanged&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var prop in this.styles)this._textLines[prop]||delete this.styles[prop]},removeStyleFromTo:function(start,end){var cursorStart=this.get2DCursorLocation(start,!0),cursorEnd=this.get2DCursorLocation(end,!0),lineStart=cursorStart.lineIndex,charStart=cursorStart.charIndex,lineEnd=cursorEnd.lineIndex,charEnd=cursorEnd.charIndex,i,styleObj;if(lineStart!==lineEnd){if(this.styles[lineStart])for(i=charStart;i<this._unwrappedTextLines[lineStart].length;i++)delete this.styles[lineStart][i];if(this.styles[lineEnd])for(i=charEnd;i<this._unwrappedTextLines[lineEnd].length;i++)styleObj=this.styles[lineEnd][i],styleObj&&(this.styles[lineStart]||(this.styles[lineStart]={}),this.styles[lineStart][charStart+i-charEnd]=styleObj);for(i=lineStart+1;i<=lineEnd;i++)delete this.styles[i];this.shiftLineStyles(lineEnd,lineStart-lineEnd)}else if(this.styles[lineStart]){styleObj=this.styles[lineStart];var diff=charEnd-charStart,numericChar,_char;for(i=charStart;i<charEnd;i++)delete styleObj[i];for(_char in this.styles[lineStart])numericChar=parseInt(_char,10),numericChar>=charEnd&&(styleObj[numericChar-diff]=styleObj[_char],delete styleObj[_char])}},shiftLineStyles:function(lineIndex,offset){var clonedStyles=clone(this.styles);for(var line in this.styles){var numericLine=parseInt(line,10);numericLine>lineIndex&&(this.styles[numericLine+offset]=clonedStyles[numericLine],clonedStyles[numericLine-offset]||delete this.styles[numericLine])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(lineIndex,charIndex,qty,copiedStyle){var currentCharStyle,newLineStyles={},somethingAdded=!1,isEndOfLine=this._unwrappedTextLines[lineIndex].length===charIndex;qty||(qty=1),this.shiftLineStyles(lineIndex,qty),this.styles[lineIndex]&&(currentCharStyle=this.styles[lineIndex][charIndex===0?charIndex:charIndex-1]);for(var index in this.styles[lineIndex]){var numIndex=parseInt(index,10);numIndex>=charIndex&&(somethingAdded=!0,newLineStyles[numIndex-charIndex]=this.styles[lineIndex][index],isEndOfLine&&charIndex===0||delete this.styles[lineIndex][index])}var styleCarriedOver=!1;for(somethingAdded&&!isEndOfLine&&(this.styles[lineIndex+qty]=newLineStyles,styleCarriedOver=!0),styleCarriedOver&&qty--;qty>0;)copiedStyle&&copiedStyle[qty-1]?this.styles[lineIndex+qty]={0:clone(copiedStyle[qty-1])}:currentCharStyle?this.styles[lineIndex+qty]={0:clone(currentCharStyle)}:delete this.styles[lineIndex+qty],qty--;this._forceClearCache=!0},insertCharStyleObject:function(lineIndex,charIndex,quantity,copiedStyle){this.styles||(this.styles={});var currentLineStyles=this.styles[lineIndex],currentLineStylesCloned=currentLineStyles?clone(currentLineStyles):{};quantity||(quantity=1);for(var index in currentLineStylesCloned){var numericIndex=parseInt(index,10);numericIndex>=charIndex&&(currentLineStyles[numericIndex+quantity]=currentLineStylesCloned[numericIndex],currentLineStylesCloned[numericIndex-quantity]||delete currentLineStyles[numericIndex])}if(this._forceClearCache=!0,copiedStyle){for(;quantity--;)Object.keys(copiedStyle[quantity]).length&&(this.styles[lineIndex]||(this.styles[lineIndex]={}),this.styles[lineIndex][charIndex+quantity]=clone(copiedStyle[quantity]));return}if(currentLineStyles)for(var newStyle=currentLineStyles[charIndex?charIndex-1:1];newStyle&&quantity--;)this.styles[lineIndex][charIndex+quantity]=clone(newStyle)},insertNewStyleBlock:function(insertedText,start,copiedStyle){for(var cursorLoc=this.get2DCursorLocation(start,!0),addedLines=[0],linesLength=0,i=0;i<insertedText.length;i++)insertedText[i]==="\n"?(linesLength++,addedLines[linesLength]=0):addedLines[linesLength]++;addedLines[0]>0&&(this.insertCharStyleObject(cursorLoc.lineIndex,cursorLoc.charIndex,addedLines[0],copiedStyle),copiedStyle=copiedStyle&&copiedStyle.slice(addedLines[0]+1)),linesLength&&this.insertNewlineStyleObject(cursorLoc.lineIndex,cursorLoc.charIndex+addedLines[0],linesLength);for(var i=1;i<linesLength;i++)addedLines[i]>0?this.insertCharStyleObject(cursorLoc.lineIndex+i,0,addedLines[i],copiedStyle):copiedStyle&&(this.styles[cursorLoc.lineIndex+i][0]=copiedStyle[0]),c
1opiedStyle=copiedStyle&&copiedStyle.slice(addedLines[i]+1);addedLines[i]>0&&this.insertCharStyleObject(cursorLoc.lineIndex+i,0,addedLines[i],copiedStyle)},setSelectionStartEndWithShift:function(start,end,newSelection){newSelection<=start?(end===start?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=start),this.selectionStart=newSelection):newSelection>start&&newSelection<end?this._selectionDirection==="right"?this.selectionEnd=newSelection:this.selectionStart=newSelection:(end===start?this._selectionDirection="right":this._selectionDirection==="left"&&(this._selectionDirection="right",this.selectionStart=end),this.selectionEnd=newSelection)},setSelectionInBoundaries:function(){var length=this.text.length;this.selectionStart>length?this.selectionStart=length:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>length?this.selectionEnd=length:this.selectionEnd<0&&(this.selectionEnd=0)}})})(),fabric.util.object.extend(fabric.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(options){if(this.canvas){this.__newClickTime=+new Date;var newPointer=options.pointer;this.isTripleClick(newPointer)&&(this.fire("tripleclick",options),this._stopEvent(options.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=newPointer,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(newPointer){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===newPointer.x&&this.__lastPointer.y===newPointer.y},_stopEvent:function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(options){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(options.e))},tripleClickHandler:function(options){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(options.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(options){!this.canvas||!this.editable||options.e.button&&options.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(options.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(options){!this.canvas||!this.editable||options.e.button&&options.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(options){if(this.__isMousedown=!1,!(!this.editable||this.group||options.transform&&options.transform.actionPerformed||options.e.button&&options.e.button!==1)){if(this.canvas){var currentActive=this.canvas._activeObject;if(currentActive&&currentActive!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(options.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(e){var newSelection=this.getSelectionStartFromPointer(e),start=this.selectionStart,end=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(start,end,newSelection):(this.selectionStart=newSelection,this.selectionEnd=newSelection),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(e){for(var mouseOffset=this.getLocalPointer(e),prevWidth=0,width=0,height=0,charIndex=0,lineIndex=0,lineLeftOffset,line,i=0,len=this._textLines.length;i<len&&height<=mouseOffset.y;i++)height+=this.getHeightOfLine(i)*this.scaleY,lineIndex=i,i>0&&(charIndex+=this._textLines[i-1].length+this.missingNewlineOffset(i-1));lineLeftOffset=this._getLineLeftOffset(lineIndex),width=lineLeftOffset*this.scaleX,line=this._textLines[lineIndex];for(var j=0,jlen=line.length;j<jlen&&(prevWidth=width,width+=this.__charBounds[lineIndex][j].kernedWidth*this.scaleX,width<=mouseOffset.x);j++)charIndex++;return this._getNewSelectionStartFromOffset(mouseOffset,prevWidth,width,charIndex,jlen)},_getNewSelectionStartFromOffset:function(mouseOffset,prevWidth,width,index,jlen){var distanceBtwLastCharAndCursor=mouseOffset.x-prevWidth,distanceBtwNextCharAndCursor=width-mouseOffset.x,offset=distanceBtwNextCharAndCursor>distanceBtwLastCharAndCursor||distanceBtwNextCharAndCursor<0?0:1,newSelectionStart=index+offset;return this.flipX&&(newSelectionStart=jlen-newSelectionStart),newSelectionStart>this._text.length&&(newSelectionStart=this._text.length),newSelectionStart}}),fabric.util.object.extend(fabric.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=fabric.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","fal
1se"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var style=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+style.top+"; left: "+style.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uFF70top: "+style.fontSize+";",fabric.document.body.appendChild(this.hiddenTextarea),fabric.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),fabric.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),fabric.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),fabric.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),fabric.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),fabric.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),fabric.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(fabric.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(e){if(this.isEditing){if(e.keyCode in this.keysMap)this[this.keysMap[e.keyCode]](e);else if(e.keyCode in this.ctrlKeysMapDown&&(e.ctrlKey||e.metaKey))this[this.ctrlKeysMapDown[e.keyCode]](e);else return;e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(e){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey))this[this.ctrlKeysMapUp[e.keyCode]](e);else return;e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(e){var fromPaste=this.fromPaste;if(this.fromPaste=!1,e&&e.stopPropagation(),!!this.isEditing){var nextText=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,charCount=this._text.length,nextCharCount=nextText.length,removedText,insertedText,charDiff=nextCharCount-charCount,selectionStart=this.selectionStart,selectionEnd=this.selectionEnd,selection=selectionStart!==selectionEnd,copiedStyle,removeFrom,removeTo;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var textareaSelection=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),backDelete=selectionStart>textareaSelection.selectionStart;selection?(removedText=this._text.slice(selectionStart,selectionEnd),charDiff+=selectionEnd-selectionStart):nextCharCount<charCount&&(backDelete?removedText=this._text.slice(selectionEnd+charDiff,selectionEnd):removedText=this._text.slice(selectionStart,selectionStart-charDiff)),insertedText=nextText.slice(textareaSelection.selectionEnd-charDiff,textareaSelection.selectionEnd),removedText&&removedText.length&&(insertedText.length&&(copiedStyle=this.getSelectionStyles(selectionStart,selectionStart+1,!1),copiedStyle=insertedText.map(function(){return copiedStyle[0]})),selection?(removeFrom=selectionStart,removeTo=selectionEnd):backDelete?(removeFrom=selectionEnd-removedText.length,removeTo=selectionEnd):(removeFrom=selectionEnd,removeTo=selectionEnd+removedText.length),this.removeStyleFromTo(removeFrom,removeTo)),insertedText.length&&(fromPaste&&insertedText.join("")===fabric.copiedText&&!fabric.disableStyleCopyPaste&&(copiedStyle=fabric.copiedTextStyle),this.insertNewStyleBlock(insertedText,selectionStart,copiedStyle)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(e){this.compositionStart=e.target.selectionStart,this.compositionEnd=e.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(fabric.copiedText=this.getSelectedText(),fabric.disableStyleCopyPaste?fabric.copiedTextStyle=null:fabric.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(e){return e&&e.clipboardData||fabric.window.clipboardData},_getWidthBeforeCursor:function(lineIndex,charIndex){var widthBeforeCursor=this._getLineLeftOffset(lineIndex),bound;return charIndex>0&&(bound=this.__charBounds[lineIndex][charIndex-1],widthBeforeCursor+=bou
1nd.left+bound.width),widthBeforeCursor},getDownCursorOffset:function(e,isRight){var selectionProp=this._getSelectionForOffset(e,isRight),cursorLocation=this.get2DCursorLocation(selectionProp),lineIndex=cursorLocation.lineIndex;if(lineIndex===this._textLines.length-1||e.metaKey||e.keyCode===34)return this._text.length-selectionProp;var charIndex=cursorLocation.charIndex,widthBeforeCursor=this._getWidthBeforeCursor(lineIndex,charIndex),indexOnOtherLine=this._getIndexOnLine(lineIndex+1,widthBeforeCursor),textAfterCursor=this._textLines[lineIndex].slice(charIndex);return textAfterCursor.length+indexOnOtherLine+1+this.missingNewlineOffset(lineIndex)},_getSelectionForOffset:function(e,isRight){return e.shiftKey&&this.selectionStart!==this.selectionEnd&&isRight?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(e,isRight){var selectionProp=this._getSelectionForOffset(e,isRight),cursorLocation=this.get2DCursorLocation(selectionProp),lineIndex=cursorLocation.lineIndex;if(lineIndex===0||e.metaKey||e.keyCode===33)return-selectionProp;var charIndex=cursorLocation.charIndex,widthBeforeCursor=this._getWidthBeforeCursor(lineIndex,charIndex),indexOnOtherLine=this._getIndexOnLine(lineIndex-1,widthBeforeCursor),textBeforeCursor=this._textLines[lineIndex].slice(0,charIndex),missingNewlineOffset=this.missingNewlineOffset(lineIndex-1);return-this._textLines[lineIndex-1].length+indexOnOtherLine-textBeforeCursor.length+(1-missingNewlineOffset)},_getIndexOnLine:function(lineIndex,width){for(var line=this._textLines[lineIndex],lineLeftOffset=this._getLineLeftOffset(lineIndex),widthOfCharsOnLine=lineLeftOffset,indexOnLine=0,charWidth,foundMatch,j=0,jlen=line.length;j<jlen;j++)if(charWidth=this.__charBounds[lineIndex][j].width,widthOfCharsOnLine+=charWidth,widthOfCharsOnLine>width){foundMatch=!0;var leftEdge=widthOfCharsOnLine-charWidth,rightEdge=widthOfCharsOnLine,offsetFromLeftEdge=Math.abs(leftEdge-width),offsetFromRightEdge=Math.abs(rightEdge-width);indexOnLine=offsetFromRightEdge<offsetFromLeftEdge?j:j-1;break}return foundMatch||(indexOnLine=line.length-1),indexOnLine},moveCursorDown:function(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",e)},moveCursorUp:function(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",e)},_moveCursorUpOrDown:function(direction,e){var action="get"+direction+"CursorOffset",offset=this[action](e,this._selectionDirection==="right");e.shiftKey?this.moveCursorWithShift(offset):this.moveCursorWithoutShift(offset),offset!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(offset){var newSelection=this._selectionDirection==="left"?this.selectionStart+offset:this.selectionEnd+offset;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,newSelection),offset!==0},moveCursorWithoutShift:function(offset){return offset<0?(this.selectionStart+=offset,this.selectionEnd=this.selectionStart):(this.selectionEnd+=offset,this.selectionStart=this.selectionEnd),offset!==0},moveCursorLeft:function(e){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",e)},_move:function(e,prop,direction){var newValue;if(e.altKey)newValue=this["findWordBoundary"+direction](this[prop]);else if(e.metaKey||e.keyCode===35||e.keyCode===36)newValue=this["findLineBoundary"+direction](this[prop]);else return this[prop]+=direction==="Left"?-1:1,!0;if(typeof newValue!==void 0&&this[prop]!==newValue)return this[prop]=newValue,!0},_moveLeft:function(e,prop){return this._move(e,prop,"Left")},_moveRight:function(e,prop){return this._move(e,prop,"Right")},moveCursorLeftWithoutShift:function(e){var change=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(change=this._moveLeft(e,"selectionStart")),this.selectionEnd=this.selectionStart,change},moveCursorLeftWithShift:function(e){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(e,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(e,"selectionStart")},moveCursorRight:function(e){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",e)},_moveCursorLeftOrRight:function(direction,e){var actionName="moveCursor"+direction+"With";this._currentCursorOpacity=1,e.shiftKey?actionName+="Shift":actionName+="outShift",this[actionName](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(e){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(e,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(e,"selectionEnd")},moveCursorRightWithoutShift:function(e){var changed=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(changed=this._moveRight(e,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,changed},removeChars:function(start,end){typeof end=="undefined"&&(end=start+1),this.removeStyleFromTo(start,end),this._text.splice(start,end-start),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(text,style,start,end){typeof end=="undefined"&&(end=start),end>start&&this.removeStyleFromTo(start,end);var graphemes=fabric.util.string.graphemeSplit(text);this.insertNewStyleBlock(graphemes,start,style),this._text=[].concat(this._text.slice(0,start),graphemes,this._text.slice(end)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}
1),(function(){var toFixed=fabric.util.toFixed,multipleSpacesRegex=/  +/g;fabric.util.object.extend(fabric.Text.prototype,{_toSVG:function(){var offsets=this._getSVGLeftTopOffsets(),textAndBg=this._getSVGTextAndBg(offsets.textTop,offsets.textLeft);return this._wrapSVGTextAndBg(textAndBg)},toSVG:function(reviver){return this._createBaseSVGMarkup(this._toSVG(),{reviver:reviver,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(textAndBg){var noShadow=!0,textDecoration=this.getSvgTextDecoration(this);return[textAndBg.textBgRects.join(""),'		<text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",textDecoration?'text-decoration="'+textDecoration+'" ':"",'style="',this.getSvgStyles(noShadow),'"',this.addPaintOrder()," >",textAndBg.textSpans.join(""),"</text>\n"]},_getSVGTextAndBg:function(textTopOffset,textLeftOffset){var textSpans=[],textBgRects=[],height=textTopOffset,lineOffset;this._setSVGBg(textBgRects);for(var i=0,len=this._textLines.length;i<len;i++)lineOffset=this._getLineLeftOffset(i),(this.textBackgroundColor||this.styleHas("textBackgroundColor",i))&&this._setSVGTextLineBg(textBgRects,i,textLeftOffset+lineOffset,height),this._setSVGTextLineText(textSpans,i,textLeftOffset+lineOffset,height),height+=this.getHeightOfLine(i);return{textSpans:textSpans,textBgRects:textBgRects}},_createTextCharSpan:function(_char,styleDecl,left,top){var shouldUseWhitespace=_char!==_char.trim()||_char.match(multipleSpacesRegex),styleProps=this.getSvgSpanStyles(styleDecl,shouldUseWhitespace),fillStyles=styleProps?'style="'+styleProps+'"':"",dy=styleDecl.deltaY,dySpan="",NUM_FRACTION_DIGITS=fabric.Object.NUM_FRACTION_DIGITS;return dy&&(dySpan=' dy="'+toFixed(dy,NUM_FRACTION_DIGITS)+'" '),['<tspan x="',toFixed(left,NUM_FRACTION_DIGITS),'" y="',toFixed(top,NUM_FRACTION_DIGITS),'" ',dySpan,fillStyles,">",fabric.util.string.escapeXml(_char),"</tspan>"].join("")},_setSVGTextLineText:function(textSpans,lineIndex,textLeftOffset,textTopOffset){var lineHeight=this.getHeightOfLine(lineIndex),isJustify=this.textAlign.indexOf("justify")!==-1,actualStyle,nextStyle,charsToRender="",charBox,style,boxWidth=0,line=this._textLines[lineIndex],timeToRender;textTopOffset+=lineHeight*(1-this._fontSizeFraction)/this.lineHeight;for(var i=0,len=line.length-1;i<=len;i++)timeToRender=i===len||this.charSpacing,charsToRender+=line[i],charBox=this.__charBounds[lineIndex][i],boxWidth===0?(textLeftOffset+=charBox.kernedWidth-charBox.width,boxWidth+=charBox.width):boxWidth+=charBox.kernedWidth,isJustify&&!timeToRender&&this._reSpaceAndTab.test(line[i])&&(timeToRender=!0),timeToRender||(actualStyle=actualStyle||this.getCompleteStyleDeclaration(lineIndex,i),nextStyle=this.getCompleteStyleDeclaration(lineIndex,i+1),timeToRender=this._hasStyleChangedForSvg(actualStyle,nextStyle)),timeToRender&&(style=this._getStyleDeclaration(lineIndex,i)||{},textSpans.push(this._createTextCharSpan(charsToRender,style,textLeftOffset,textTopOffset)),charsToRender="",actualStyle=nextStyle,textLeftOffset+=boxWidth,boxWidth=0)},_pushTextBgRect:function(textBgRects,color,left,top,width,height){var NUM_FRACTION_DIGITS=fabric.Object.NUM_FRACTION_DIGITS;textBgRects.push("		<rect ",this._getFillAttributes(color),' x="',toFixed(left,NUM_FRACTION_DIGITS),'" y="',toFixed(top,NUM_FRACTION_DIGITS),'" width="',toFixed(width,NUM_FRACTION_DIGITS),'" height="',toFixed(height,NUM_FRACTION_DIGITS),'"></rect>\n')},_setSVGTextLineBg:function(textBgRects,i,leftOffset,textTopOffset){for(var line=this._textLines[i],heightOfLine=this.getHeightOfLine(i)/this.lineHeight,boxWidth=0,boxStart=0,charBox,currentColor,lastColor=this.getValueOfPropertyAt(i,0,"textBackgroundColor"),j=0,jlen=line.length;j<jlen;j++)charBox=this.__charBounds[i][j],currentColor=this.getValueOfPropertyAt(i,j,"textBackgroundColor"),currentColor!==lastColor?(lastColor&&this._pushTextBgRect(textBgRects,lastColor,leftOffset+boxStart,textTopOffset,boxWidth,heightOfLine),boxStart=charBox.left,boxWidth=charBox.width,lastColor=currentColor):boxWidth+=charBox.kernedWidth;currentColor&&this._pushTextBgRect(textBgRects,currentColor,leftOffset+boxStart,textTopOffset,boxWidth,heightOfLine)},_getFillAttributes:function(value){var fillColor=value&&typeof value=="string"?new fabric.Color(value):"";return!fillColor||!fillColor.getSource()||fillColor.getAlpha()===1?'fill="'+value+'"'
1:'opacity="'+fillColor.getAlpha()+'" fill="'+fillColor.setAlpha(1).toRgb()+'"'},_getSVGLineTopOffset:function(lineIndex){for(var lineTopOffset=0,lastHeight=0,j=0;j<lineIndex;j++)lineTopOffset+=this.getHeightOfLine(j);return lastHeight=this.getHeightOfLine(j),{lineTop:lineTopOffset,offset:(this._fontSizeMult-this._fontSizeFraction)*lastHeight/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(skipShadow){var svgStyle=fabric.Object.prototype.getSvgStyles.call(this,skipShadow);return svgStyle+" white-space: pre;"}})})(),(function(global){"use strict";var fabric2=global.fabric||(global.fabric={});fabric2.Textbox=fabric2.util.createClass(fabric2.IText,fabric2.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:fabric2.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(textInfo){for(var realLineCount=0,realLineCharCount=0,charCount=0,map={},i=0;i<textInfo.graphemeLines.length;i++)textInfo.graphemeText[charCount]==="\n"&&i>0?(realLineCharCount=0,charCount++,realLineCount++):!this.splitByGrapheme&&this._reSpaceAndTab.test(textInfo.graphemeText[charCount])&&i>0&&(realLineCharCount++,charCount++),map[i]={line:realLineCount,offset:realLineCharCount},charCount+=textInfo.graphemeLines[i].length,realLineCharCount+=textInfo.graphemeLines[i].length;return map},styleHas:function(property,lineIndex){if(this._styleMap&&!this.isWrapping){var map=this._styleMap[lineIndex];map&&(lineIndex=map.line)}return fabric2.Text.prototype.styleHas.call(this,property,lineIndex)},isEmptyStyles:function(lineIndex){if(!this.styles)return!0;var offset=0,nextLineIndex=lineIndex+1,nextOffset,obj,shouldLimit=!1,map=this._styleMap[lineIndex],mapNextLine=this._styleMap[lineIndex+1];map&&(lineIndex=map.line,offset=map.offset),mapNextLine&&(nextLineIndex=mapNextLine.line,shouldLimit=nextLineIndex===lineIndex,nextOffset=mapNextLine.offset),obj=typeof lineIndex=="undefined"?this.styles:{line:this.styles[lineIndex]};for(var p1 in obj)for(var p2 in obj[p1])if(p2>=offset&&(!shouldLimit||p2<nextOffset))for(var p3 in obj[p1][p2])return!1;return!0},_getStyleDeclaration:function(lineIndex,charIndex){if(this._styleMap&&!this.isWrapping){var map=this._styleMap[lineIndex];if(!map)return null;lineIndex=map.line,charIndex=map.offset+charIndex}return this.callSuper("_getStyleDeclaration",lineIndex,charIndex)},_setStyleDeclaration:function(lineIndex,charIndex,style){var map=this._styleMap[lineIndex];lineIndex=map.line,charIndex=map.offset+charIndex,this.styles[lineIndex][charIndex]=style},_deleteStyleDeclaration:function(lineIndex,charIndex){var map=this._styleMap[lineIndex];lineIndex=map.line,charIndex=map.offset+charIndex,delete this.styles[lineIndex][charIndex]},_getLineStyle:function(lineIndex){var map=this._styleMap[lineIndex];return!!this.styles[map.line]},_setLineStyle:function(lineIndex){var map=this._styleMap[lineIndex];this.styles[map.line]={}},_wrapText:function(lines,desiredWidth){var wrapped=[],i;for(this.isWrapping=!0,i=0;i<lines.length;i++)wrapped=wrapped.concat(this._wrapLine(lines[i],i,desiredWidth));return this.isWrapping=!1,wrapped},_measureWord:function(word,lineIndex,charOffset){var width=0,prevGrapheme,skipLeft=!0;charOffset=charOffset||0;for(var i=0,len=word.length;i<len;i++){var box=this._getGraphemeBox(word[i],lineIndex,i+charOffset,prevGrapheme,skipLeft);width+=box.kernedWidth,prevGrapheme=word[i]}return width},_wrapLine:function(_line,lineIndex,desiredWidth,reservedSpace){var lineWidth=0,splitByGrapheme=this.splitByGrapheme,graphemeLines=[],line=[],words=splitByGrapheme?fabric2.util.string.graphemeSplit(_line):_line.split(this._wordJoiners),word="",offset=0,infix=splitByGrapheme?"":" ",wordWidth=0,infi
1xWidth=0,largestWordWidth=0,lineJustStarted=!0,additionalSpace=this._getWidthOfCharSpacing(),reservedSpace=reservedSpace||0;words.length===0&&words.push([]),desiredWidth-=reservedSpace;for(var i=0;i<words.length;i++)word=splitByGrapheme?words[i]:fabric2.util.string.graphemeSplit(words[i]),wordWidth=this._measureWord(word,lineIndex,offset),offset+=word.length,lineWidth+=infixWidth+wordWidth-additionalSpace,lineWidth>=desiredWidth&&!lineJustStarted?(graphemeLines.push(line),line=[],lineWidth=wordWidth,lineJustStarted=!0):lineWidth+=additionalSpace,!lineJustStarted&&!splitByGrapheme&&line.push(infix),line=line.concat(word),infixWidth=splitByGrapheme?0:this._measureWord([infix],lineIndex,offset),offset++,lineJustStarted=!1,wordWidth>largestWordWidth&&(largestWordWidth=wordWidth);return i&&graphemeLines.push(line),largestWordWidth+reservedSpace>this.dynamicMinWidth&&(this.dynamicMinWidth=largestWordWidth-additionalSpace+reservedSpace),graphemeLines},isEndOfWrapping:function(lineIndex){return!this._styleMap[lineIndex+1]||this._styleMap[lineIndex+1].line!==this._styleMap[lineIndex].line},missingNewlineOffset:function(lineIndex){return this.splitByGrapheme?this.isEndOfWrapping(lineIndex)?1:0:1},_splitTextIntoLines:function(text){for(var newText=fabric2.Text.prototype._splitTextIntoLines.call(this,text),graphemeLines=this._wrapText(newText.lines,this.width),lines=new Array(graphemeLines.length),i=0;i<graphemeLines.length;i++)lines[i]=graphemeLines[i].join("");return newText.lines=lines,newText.graphemeLines=graphemeLines,newText},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var linesToKeep={};for(var prop in this._styleMap)this._textLines[prop]&&(linesToKeep[this._styleMap[prop].line]=1);for(var prop in this.styles)linesToKeep[prop]||delete this.styles[prop]},toObject:function(propertiesToInclude){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(propertiesToInclude))}}),fabric2.Textbox.fromObject=function(object,callback){return fabric2.Object._fromObject("Textbox",object,callback,"text")}})(typeof exports!="undefined"?exports:this),(function(){var controlsUtils=fabric.controlsUtils,scaleSkewStyleHandler=controlsUtils.scaleSkewCursorStyleHandler,scaleStyleHandler=controlsUtils.scaleCursorStyleHandler,scalingEqually=controlsUtils.scalingEqually,scalingYOrSkewingX=controlsUtils.scalingYOrSkewingX,scalingXOrSkewingY=controlsUtils.scalingXOrSkewingY,scaleOrSkewActionName=controlsUtils.scaleOrSkewActionName,objectControls=fabric.Object.prototype.controls;if(objectControls.ml=new fabric.Control({x:-.5,y:0,cursorStyleHandler:scaleSkewStyleHandler,actionHandler:scalingXOrSkewingY,getActionName:scaleOrSkewActionName}),objectControls.mr=new fabric.Control({x:.5,y:0,cursorStyleHandler:scaleSkewStyleHandler,actionHandler:scalingXOrSkewingY,getActionName:scaleOrSkewActionName}),objectControls.mb=new fabric.Control({x:0,y:.5,cursorStyleHandler:scaleSkewStyleHandler,actionHandler:scalingYOrSkewingX,getActionName:scaleOrSkewActionName}),objectControls.mt=new fabric.Control({x:0,y:-.5,cursorStyleHandler:scaleSkewStyleHandler,actionHandler:scalingYOrSkewingX,getActionName:scaleOrSkewActionName}),objectControls.tl=new fabric.Control({x:-.5,y:-.5,cursorStyleHandler:scaleStyleHandler,actionHandler:scalingEqually}),objectControls.tr=new fabric.Control({x:.5,y:-.5,cursorStyleHandler:scaleStyleHandler,actionHandler:scalingEqually}),objectControls.bl=new fabric.Control({x:-.5,y:.5,cursorStyleHandler:scaleStyleHandler,actionHandler:scalingEqually}),objectControls.br=new fabric.Control({x:.5,y:.5,cursorStyleHandler:scaleStyleHandler,actionHandler:scalingEqually}),objectControls.mtr=new fabric.Control({x:0,y:-.5,actionHandler:controlsUtils.rotationWithSnapping,cursorStyleHandler:controlsUtils.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),fabric.Textbox){var textBoxControls=fabric.Textbox.prototype.controls={};textBoxControls.mtr=objectControls.mtr,textBoxControls.tr=objectControls.tr,textBoxControls.br=objectControls.br,textBoxControls.tl=objectControls.tl,textBoxControl
1s.bl=objectControls.bl,textBoxControls.mt=objectControls.mt,textBoxControls.mb=objectControls.mb,textBoxControls.mr=new fabric.Control({x:.5,y:0,actionHandler:controlsUtils.changeWidth,cursorStyleHandler:scaleSkewStyleHandler,actionName:"resizing"}),textBoxControls.ml=new fabric.Control({x:-.5,y:0,actionHandler:controlsUtils.changeWidth,cursorStyleHandler:scaleSkewStyleHandler,actionName:"resizing"})}})();
2//# sourceMappingURL=/cdn/shop/t/5/assets/fabric4.js.map?v=136006269476888978931689553324

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.