forked from fabricjs/fabric.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.min.js
7 lines (7 loc) · 107 KB
/
all.min.js
1
2
3
4
5
6
7
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric=fabric||{version:"0.5.3"};if(typeof exports!="undefined"){exports.fabric=fabric}if(typeof document!="undefined"&&typeof window!="undefined"){fabric.document=document;fabric.window=window}else{fabric.document=require("jsdom").jsdom("<!DOCTYPE html><html><head></head><body></body></html>");fabric.window=fabric.document.createWindow()}if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());
/*!
* Copyright (c) 2009 Simo Kinnunen.
* Licensed under the MIT license.
*/
var Cufon=(function(){var k=function(){return k.replace.apply(null,arguments)};var u=k.DOM={ready:(function(){var z=false,B={loaded:1,complete:1};var y=[],A=function(){if(z){return}z=true;for(var C;C=y.shift();C()){}};if(fabric.document.addEventListener){fabric.document.addEventListener("DOMContentLoaded",A,false);fabric.window.addEventListener("pageshow",A,false)}if(!fabric.window.opera&&fabric.document.readyState){(function(){B[fabric.document.readyState]?A():setTimeout(arguments.callee,10)})()}if(fabric.document.readyState&&fabric.document.createStyleSheet){(function(){try{fabric.document.body.doScroll("left");A()}catch(C){setTimeout(arguments.callee,1)}})()}o(fabric.window,"load",A);return function(C){if(!arguments.length){A()}else{z?C():y.push(C)}}})()};var l=k.CSS={Size:function(z,y){this.value=parseFloat(z);this.unit=String(z).match(/[a-z%]*$/)[0]||"px";this.convert=function(A){return A/y*this.value};this.convertFrom=function(A){return A/this.value*y};this.toString=function(){return this.value+this.unit}},getStyle:function(y){return new a(y.style)},quotedList:i(function(B){var A=[],z=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,y;while(y=z.exec(B)){A.push(y[3]||y[1])}return A}),ready:(function(){var A=false;var z=[],B=function(){A=true;for(var D;D=z.shift();D()){}};var y=Object.prototype.propertyIsEnumerable?f("style"):{length:0};var C=f("link");u.ready(function(){var G=0,F;for(var E=0,D=C.length;F=C[E],E<D;++E){if(!F.disabled&&F.rel.toLowerCase()=="stylesheet"){++G}}if(fabric.document.styleSheets.length>=y.length+G){B()}else{setTimeout(arguments.callee,10)}});return function(D){if(A){D()}else{z.push(D)}}})(),supports:function(A,z){var y=fabric.document.createElement("span").style;if(y[A]===undefined){return false}y[A]=z;return y[A]===z},textAlign:function(B,A,y,z){if(A.get("textAlign")=="right"){if(y>0){B=" "+B}}else{if(y<z-1){B+=" "}}return B},textDecoration:function(D,C){if(!C){C=this.getStyle(D)}var z={underline:null,overline:null,"line-through":null};for(var y=D;y.parentNode&&y.parentNode.nodeType==1;){var B=true;for(var A in z){if(z[A]){continue}if(C.get("textDecoration").indexOf(A)!=-1){z[A]=C.get("color")}B=false}if(B){break}C=this.getStyle(y=y.parentNode)}return z},textShadow:i(function(C){if(C=="none"){return null}var B=[],D={},y,z=0;var A=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;while(y=A.exec(C)){if(y[0]==","){B.push(D);D={},z=0}else{if(y[1]){D.color=y[1]}else{D[["offX","offY","blur"][z++]]=y[2]}}}B.push(D);return B}),color:i(function(z){var y={};y.color=z.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(B,A,C){y.opacity=parseFloat(C);return"rgb("+A+")"});return y}),textTransform:function(z,y){return z[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[y.get("textTransform")]||"toString"]()}};function q(z){var y=this.face=z.face;this.glyphs=z.glyphs;this.w=z.w;this.baseSize=parseInt(y["units-per-em"],10);this.family=y["font-family"].toLowerCase();this.weight=y["font-weight"];this.style=y["font-style"]||"normal";this.viewBox=(function(){var B=y.bbox.split(/\s+/);var A={minX:parseInt(B[0],10),minY:parseInt(B[1],10),maxX:parseInt(B[2],10),maxY:parseInt(B[3],10)};A.width=A.maxX-A.minX,A.height=A.maxY-A.minY;A.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")};return A})();this.ascent=-parseInt(y.ascent,10);this.descent=-parseInt(y.descent,10);this.height=-this.ascent+this.descent}function e(){var z={},y={oblique:"italic",italic:"oblique"};this.add=function(A){(z[A.style]||(z[A.style]={}))[A.weight]=A};this.get=function(E,F){var D=z[E]||z[y[E]]||z.normal||z.italic||z.oblique;if(!D){return null}F={normal:400,bold:700}[F]||parseInt(F,10);if(D[F]){return D[F]}var B={1:1,99:0}[F%100],H=[],C,A;if(B===undefined){B=F>400}if(F==500){F=400}for(var G in D){G=parseInt(G,10);if(!C||G<C){C=G}if(!A||G>A){A=G}H.push(G)}if(F<C){F=C}if(F>A){F=A}H.sort(function(J,I){return(B?(J>F&&I>F)?J<I:J>I:(J<F&&I<F)?J>I:J<I)?-1:1});return D[H[0]]}}function p(){function A(C,D){if(C.contains){return C.contains(D)}return C.compareDocumentPosition(D)&16}function y(D){var C=D.relatedTarget;if(!C||A(this,C)){return}z(this)}function B(C){z(this)}function z(C){setTimeout(function(){k.replace(C,d.get(C).options,true)},10)}this.attach=function(C){if(C.onmouseenter===undefined){o(C,"mouseover",y);o(C,"mouseout",y)}else{o(C,"mouseenter",B);o(C,"mouseleave",B)}}}function x(){var A={},y=0;function z(B){return B.cufid||(B.cufid=++y)}this.get=function(B){var C=z(B);return A[C]||(A[C]={})}}function a(y){var A={},z={};this.get=function(B){return A[B]!=undefined?A[B]:y[B]};this.getSize=function(C,B){return z[C]||(z[C]=new l.Size(this.get(C),B))};this.extend=function(B){for(var C in B){A[C]=B[C]}return this}}function o(z,y,A){if(z.addEventListener){z.addEventListener(y,A,false)}else{if(z.attachEvent){z.attachEvent("on"+y,function(){return A.call(z,fabric.window.event)})}}}function r(z,y){var A=d.get(z);if(A.options){return z}if(y.hover&&y.hoverables[z.nodeName.toLowerCase()]){b.attach(z)}A.options=y;return z}function i(y){var z={};return function(A){if(!z.hasOwnProperty(A)){z[A]=y.apply(null,arguments)}return z[A]}}function c(D,C){if(!C){C=l.getStyle(D)}var z=l.quotedList(C.get("fontFamily").toLowerCase()),B;for(var A=0,y=z.length;A<y;++A){B=z[A];if(h[B]){return h[B].get(C.get("fontStyle"),C.get("fontWeight"))}}return null}function f(y){return fabric.document.getElementsByTagName(y)}function g(){var y={},B;for(var A=0,z=arguments.length;A<z;++A){for(B in arguments[A]){y[B]=arguments[A][B]}}return y}function m(B,J,z,K,C,A){var I=K.separate;if(I=="none"){return w[K.engine].apply(null,arguments)}var H=fabric.document.createDocumentFragment(),E;var F=J.split(n[I]),y=(I=="words");if(y&&s){if(/^\s/.test(J)){F.unshift("")}if(/\s$/.test(J)){F.push("")}}for(var G=0,D=F.length;G<D;++G){E=w[K.engine](B,y?l.textAlign(F[G],z,G,D):F[G],z,K,C,A,G<D-1);if(E){H.appendChild(E)}}return H}function j(z,G){var A,y,D,F;for(var B=r(z,G).firstChild;B;B=D){D=B.nextSibling;F=false;if(B.nodeType==1){if(!B.firstChild){continue}if(!/cufon/.test(B.className)){arguments.callee(B,G);continue}else{F=true}}if(!y){y=l.getStyle(z).extend(G)}if(!A){A=c(z,y)}if(!A){continue}if(F){w[G.engine](A,null,y,G,B,z);continue}var E=B.data;if(E===""){continue}var C=m(A,E,y,G,B,z);if(C){B.parentNode.replaceChild(C,B)}else{B.parentNode.removeChild(B)}}}var s=" ".split(/\s+/).length==0;var d=new x();var b=new p();var v=[];var w={},h={},t={enableTextDecoration:false,engine:null,hover:false,hoverables:{a:true},printable:true,selector:(fabric.window.Sizzle||(fabric.window.jQuery&&function(y){return jQuery(y)})||(fabric.window.dojo&&dojo.query)||(fabric.window.$$&&function(y){return $$(y)})||(fabric.window.$&&function(y){return $(y)})||(fabric.document.querySelectorAll&&function(y){return fabric.document.querySelectorAll(y)})||f),separate:"words",textShadow:"none"};var n={words:/\s+/,characters:""};k.now=function(){u.ready();return k};k.refresh=function(){var A=v.splice(0,v.length);for(var z=0,y=A.length;z<y;++z){k.replace.apply(null,A[z])}return k};k.registerEngine=function(z,y){if(!y){return k}w[z]=y;return k.set("engine",z)};k.registerFont=function(A){var y=new q(A),z=y.family;if(!h[z]){h[z]=new e()}h[z].add(y);return k.set("fontFamily",'"'+z+'"')};k.replace=function(A,z,y){z=g(t,z);if(!z.engine){return k}if(typeof z.textShadow=="string"&&z.textShadow){z.textShadow=l.textShadow(z.textShadow)}if(!y){v.push(arguments)}if(A.nodeType||typeof A=="string"){A=[A]}l.ready(function(){for(var C=0,B=A.length;C<B;++C){var D=A[C];if(typeof D=="string"){k.replace(z.selector(D),z,true)}else{j(D,z)}}});return k};k.replaceElement=function(z,y){y=g(t,y);if(typeof y.textShadow=="string"&&y.textShadow){y.textShadow=l.textShadow(y.textShadow)}return j(z,y)};k.engines=w;k.fonts=h;k.getOptions=function(){return g(t)};k.set=function(y,z){t[y]=z;return k};return k})();Cufon.registerEngine("canvas",(function(){var b=fabric.document.createElement("canvas");if(!b||!b.getContext||!b.getContext.apply){return}b=null;var a=Cufon.CSS.supports("display","inline-block");var e=!a&&(fabric.document.compatMode=="BackCompat"||/frameset|transitional/i.test(fabric.document.doctype.publicId));var f=fabric.document.createElement("style");f.type="text/css";f.appendChild(fabric.document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(e?"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(a?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}"));fabric.document.getElementsByTagName("head")[0].appendChild(f);function d(p,h){var n=0,m=0;var g=[],o=/([mrvxe])([^a-z]*)/g,k;generate:for(var j=0;k=o.exec(p);++j){var l=k[2].split(",");switch(k[1]){case"v":g[j]={m:"bezierCurveTo",a:[n+~~l[0],m+~~l[1],n+~~l[2],m+~~l[3],n+=~~l[4],m+=~~l[5]]};break;case"r":g[j]={m:"lineTo",a:[n+=~~l[0],m+=~~l[1]]};break;case"m":g[j]={m:"moveTo",a:[n=~~l[0],m=~~l[1]]};break;case"x":g[j]={m:"closePath"};break;case"e":break generate}h[g[j].m].apply(h,g[j].a)}return g}function c(m,k){for(var j=0,h=m.length;j<h;++j){var g=m[j];k[g.m].apply(k,g.a)}}return function(aa,D,V,z,I,ab){var n=(D===null);var G=aa.viewBox;var o=V.getSize("fontSize",aa.baseSize);var T=V.get("letterSpacing");T=(T=="normal")?0:o.convertFrom(parseInt(T,10));var H=0,U=0,S=0,B=0;var F=z.textShadow,Q=[];if(F){for(var Z=0,W=F.length;Z<W;++Z){var M=F[Z];var P=o.convertFrom(parseFloat(M.offX));var O=o.convertFrom(parseFloat(M.offY));Q[Z]=[P,O];if(O<H){H=O}if(P>U){U=P}if(O>S){S=O}if(P<B){B=P}}}var af=Cufon.CSS.textTransform(n?I.alt:D,V).split("");var h=0,C=null;var w=0,L=1,K=[];for(var Z=0,W=af.length;Z<W;++Z){if(af[Z]==="\n"){L++;if(h>w){w=h}K.push(h);h=0;continue}var A=aa.glyphs[af[Z]]||aa.missingGlyph;if(!A){continue}h+=C=Number(A.w||aa.w)+T}K.push(h);h=Math.max(w,h);var m=[];for(var Z=K.length;Z--;){m[Z]=h-K[Z]}if(C===null){return null}U+=(G.width-C);B+=G.minX;var v,p;if(n){v=I;p=I.firstChild}else{v=fabric.document.createElement("span");v.className="cufon cufon-canvas";v.alt=D;p=fabric.document.createElement("canvas");v.appendChild(p);if(z.printable){var X=fabric.document.createElement("span");X.className="cufon-alt";X.appendChild(fabric.document.createTextNode(D));v.appendChild(X)}}var ag=v.style;var N=p.style||{};var k=o.convert(G.height-H+S);var ae=Math.ceil(k);var R=ae/k;p.width=Math.ceil(o.convert(h+U-B)*R);p.height=ae;H+=G.minY;N.top=Math.round(o.convert(H-aa.ascent))+"px";N.left=Math.round(o.convert(B))+"px";var j=Math.ceil(o.convert(h*R));var t=j+"px";var s=o.convert(aa.height);var E=(z.lineHeight-1)*o.convert(-aa.ascent/5)*(L-1);Cufon.textOptions.width=j;Cufon.textOptions.height=(s*L)+E;Cufon.textOptions.lines=L;if(a){ag.width=t;ag.height=s+"px"}else{ag.paddingLeft=t;ag.paddingBottom=(s-1)+"px"}var ac=Cufon.textOptions.context||p.getContext("2d"),J=ae/G.height;ac.save();ac.scale(J,J);ac.translate(-B-((1/J*p.width)/2)+(Cufon.fonts[aa.family].offsetLeft||0),-H-(Cufon.textOptions.height/J)/2);ac.lineWidth=aa.face["underline-thickness"];ac.save();function q(i,g){ac.strokeStyle=g;ac.beginPath();ac.moveTo(0,i);ac.lineTo(h,i);ac.stroke()}var r=z.enableTextDecoration?Cufon.CSS.textDecoration(ab,V):{},u=z.fontStyle==="italic";function ad(){ac.save();ac.fillStyle=z.backgroundColor;var aj=0,ak=0;if(z.textAlign==="right"){ac.translate(m[ak],0)}else{if(z.textAlign==="center"){ac.translate(m[ak]/2,0)}}for(var ah=0,x=af.length;ah<x;++ah){if(af[ah]==="\n"){ak++;var y=-aa.ascent-((aa.ascent/5)*z.lineHeight);if(z.textAlign==="right"){ac.translate(-h,y);ac.translate(m[ak],0)}else{if(z.textAlign==="center"){ac.translate(-aj-(m[ak-1]/2),y);ac.translate(m[ak]/2,0)}else{ac.translate(-aj,y)}}aj=0;continue}var ai=aa.glyphs[af[ah]]||aa.missingGlyph;if(!ai){continue}var g=Number(ai.w||aa.w)+T;ac.save();ac.translate(0,aa.ascent);ac.fillRect(0,0,g+10,-aa.ascent+aa.descent);ac.restore();ac.translate(g,0);aj+=g}ac.restore()}function Y(){ac.fillStyle=Cufon.textOptions.color||V.get("color");var aj=0,ak=0;if(z.textAlign==="right"){ac.translate(m[ak],0)}else{if(z.textAlign==="center"){ac.translate(m[ak]/2,0)}}for(var ah=0,x=af.length;ah<x;++ah){if(af[ah]==="\n"){ak++;var y=-aa.ascent-((aa.ascent/5)*z.lineHeight);if(z.textAlign==="right"){ac.translate(-h,y);ac.translate(m[ak],0)}else{if(z.textAlign==="center"){ac.translate(-aj-(m[ak-1]/2),y);ac.translate(m[ak]/2,0)}else{ac.translate(-aj,y)}}aj=0;continue}var ai=aa.glyphs[af[ah]]||aa.missingGlyph;if(!ai){continue}var g=Number(ai.w||aa.w)+T;if(r){ac.save();ac.strokeStyle=ac.fillStyle;ac.beginPath();if(r.underline){ac.moveTo(0,-aa.face["underline-position"]);ac.lineTo(g,-aa.face["underline-position"])}if(r.overline){ac.moveTo(0,aa.ascent);ac.lineTo(g,aa.ascent)}if(r["line-through"]){ac.moveTo(0,-aa.descent);ac.lineTo(g,-aa.descent)}ac.stroke();ac.restore()}if(u){ac.save();ac.transform(1,0,-0.25,1,0,0)}ac.beginPath();if(ai.d){if(ai.code){c(ai.code,ac)}else{ai.code=d("m"+ai.d,ac)}}ac.fill();if(z.strokeStyle){ac.closePath();ac.save();ac.lineWidth=z.strokeWidth;ac.strokeStyle=z.strokeStyle;ac.stroke();ac.restore()}if(u){ac.restore()}ac.translate(g,0);aj+=g}}if(F){for(var Z=0,W=F.length;Z<W;++Z){var M=F[Z];ac.save();ac.fillStyle=M.color;ac.translate.apply(ac,Q[Z]);Y();ac.restore()}}ac.save();if(z.backgroundColor){ad()}Y();ac.restore();ac.restore();ac.restore();return v}})());Cufon.registerEngine("vml",(function(){if(!fabric.document.namespaces){return}var d=fabric.document.createElement("canvas");if(d&&d.getContext&&d.getContext.apply){return}if(fabric.document.namespaces.cvml==null){fabric.document.namespaces.add("cvml","urn:schemas-microsoft-com:vml")}var b=fabric.document.createElement("cvml:shape");b.style.behavior="url(#default#VML)";if(!b.coordsize){return}b=null;fabric.document.write('<style type="text/css">.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}</style>');function c(e,f){return a(e,/(?:em|ex|%)$/i.test(f)?"1em":f)}function a(h,i){if(/px$/i.test(i)){return parseFloat(i)}var g=h.style.left,f=h.runtimeStyle.left;h.runtimeStyle.left=h.currentStyle.left;h.style.left=i;var e=h.style.pixelLeft;h.style.left=g;h.runtimeStyle.left=f;return e}return function(T,z,O,w,D,U,M){var h=(z===null);if(h){z=D.alt}var B=T.viewBox;var j=O.computedFontSize||(O.computedFontSize=new Cufon.CSS.Size(c(U,O.get("fontSize"))+"px",T.baseSize));var L=O.computedLSpacing;if(L==undefined){L=O.get("letterSpacing");O.computedLSpacing=L=(L=="normal")?0:~~j.convertFrom(a(U,L))}var t,m;if(h){t=D;m=D.firstChild}else{t=fabric.document.createElement("span");t.className="cufon cufon-vml";t.alt=z;m=fabric.document.createElement("span");m.className="cufon-vml-canvas";t.appendChild(m);if(w.printable){var R=fabric.document.createElement("span");R.className="cufon-alt";R.appendChild(fabric.document.createTextNode(z));t.appendChild(R)}if(!M){t.appendChild(fabric.document.createElement("cvml:shape"))}}var Z=t.style;var G=m.style;var f=j.convert(B.height),W=Math.ceil(f);var K=W/f;var J=B.minX,I=B.minY;G.height=W;G.top=Math.round(j.convert(I-T.ascent));G.left=Math.round(j.convert(J));Z.height=j.convert(T.height)+"px";var p=w.enableTextDecoration?Cufon.CSS.textDecoration(U,O):{};var y=O.get("color");var X=Cufon.CSS.textTransform(z,O).split("");var e=0,H=0,q=null;var x,r,A=w.textShadow;for(var S=0,Q=0,P=X.length;S<P;++S){x=T.glyphs[X[S]]||T.missingGlyph;if(x){e+=q=~~(x.w||T.w)+L}}if(q===null){return null}var s=-J+e+(B.width-q);var Y=j.convert(s*K),N=Math.round(Y);var F=s+","+B.height,g;var C="r"+F+"nsnf";for(S=0;S<P;++S){x=T.glyphs[X[S]]||T.missingGlyph;if(!x){continue}if(h){r=m.childNodes[Q];if(r.firstChild){r.removeChild(r.firstChild)}}else{r=fabric.document.createElement("cvml:shape");m.appendChild(r)}r.stroked="f";r.coordsize=F;r.coordorigin=g=(J-H)+","+I;r.path=(x.d?"m"+x.d+"xe":"")+"m"+g+C;r.fillcolor=y;var V=r.style;V.width=N;V.height=W;if(A){var o=A[0],n=A[1];var v=Cufon.CSS.color(o.color),u;var E=fabric.document.createElement("cvml:shadow");E.on="t";E.color=v.color;E.offset=o.offX+","+o.offY;if(n){u=Cufon.CSS.color(n.color);E.type="double";E.color2=u.color;E.offset2=n.offX+","+n.offY}E.opacity=v.opacity||(u&&u.opacity)||1;r.appendChild(E)}H+=~~(x.w||T.w)+L;++Q}Z.width=Math.max(Math.ceil(j.convert(e*K)),0);return t}})());if(typeof exports!="undefined"){exports.Cufon=Cufon}fabric.log=function(){};fabric.warn=function(){};if(typeof console!=="undefined"){if(typeof console.log!=="undefined"&&console.log.apply){fabric.log=function(){return console.log.apply(console,arguments)}}if(typeof console.warn!=="undefined"&&console.warn.apply){fabric.warn=function(){return console.warn.apply(console,arguments)}}}fabric.Observable={observe:function(a,b){if(!this.__eventListeners){this.__eventListeners={}}if(arguments.length===1){for(var c in a){this.observe(c,a[c])}}else{if(!this.__eventListeners[a]){this.__eventListeners[a]=[]}this.__eventListeners[a].push(b)}},stopObserving:function(a,b){if(!this.__eventListeners){this.__eventListeners={}}if(this.__eventListeners[a]){fabric.util.removeFromArray(this.__eventListeners[a],b)}},fire:function(d,c){if(!this.__eventListeners){this.__eventListeners={}}var b=this.__eventListeners[d];if(!b){return}for(var e=0,a=b.length;e<a;e++){b[e]({memo:c})}}};(function(){fabric.util={};function g(j,i){var h=j.indexOf(i);if(h!==-1){j.splice(h,1)}return j}function e(i,h){return Math.floor(Math.random()*(h-i+1))+i}var b=Math.PI/180;function d(h){return h*b}function a(i,h){return parseFloat(Number(i).toFixed(h))}function f(){return false}function c(t){t||(t={});var i=+new Date(),m=t.duration||500,s=i+m,l,r,o=t.onChange||function(){},n=t.abort||function(){return false},p=t.easing||function(u){return(-Math.cos(u*Math.PI)/2)+0.5},h="startValue" in t?t.startValue:0,q="endValue" in t?t.endValue:100,k=h>q;t.onStart&&t.onStart();var j=setInterval(function(){l=+new Date();r=l>s?1:(l-i)/m;o(k?(h-(h-q)*p(r)):(h+(q-h)*p(r)));if(l>s||n()){clearInterval(j);t.onComplete&&t.onComplete()}},10);return j}fabric.util.removeFromArray=g;fabric.util.degreesToRadians=d;fabric.util.toFixed=a;fabric.util.getRandomInt=e;fabric.util.falseFunction=f;fabric.util.animate=c})();(function(){var d=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(f,g){var e=this.length>>>0;g=Number(g)||0;g=Math[g<0?"ceil":"floor"](g);if(g<0){g+=e}for(;g<e;g++){if(g in this&&this[g]===f){return g}}return -1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(h,g){for(var f=0,e=this.length>>>0;f<e;f++){if(f in this){h.call(g,this[f],f,this)}}}}if(!Array.prototype.map){Array.prototype.map=function(j,h){var f=[];for(var g=0,e=this.length>>>0;g<e;g++){if(g in this){f[g]=j.call(h,this[g],g,this)}}return f}}if(!Array.prototype.every){Array.prototype.every=function(h,g){for(var f=0,e=this.length>>>0;f<e;f++){if(f in this&&!h.call(g,this[f],f,this)){return false}}return true}}if(!Array.prototype.some){Array.prototype.some=function(h,g){for(var f=0,e=this.length>>>0;f<e;f++){if(f in this&&h.call(g,this[f],f,this)){return true}}return false}}if(!Array.prototype.filter){Array.prototype.filter=function(j,h){var f=[],k;for(var g=0,e=this.length>>>0;g<e;g++){if(g in this){k=this[g];if(j.call(h,k,g,this)){f.push(k)}}}return f}}if(!Array.prototype.reduce){Array.prototype.reduce=function(g){var e=this.length>>>0,f=0,h;if(arguments.length>1){h=arguments[1]}else{do{if(f in this){h=this[f++];break}if(++f>=e){throw new TypeError()}}while(true)}for(;f<e;f++){if(f in this){h=g.call(null,h,this[f],f,this)}}return h}}function b(k,j){var g=d.call(arguments,2),f=[];for(var h=0,e=k.length;h<e;h++){f[h]=g.length?k[h][j].apply(k[h],g):k[h][j].call(k[h])}return f}function a(h,g){var f=h.length-1,e=g?h[f][g]:h[f];if(g){while(f--){if(h[f][g]>=e){e=h[f][g]}}}else{while(f--){if(h[f]>=e){e=h[f]}}}return e}function c(h,g){var f=h.length-1,e=g?h[f][g]:h[f];if(g){while(f--){if(h[f][g]<e){e=h[f][g]}}}else{while(f--){if(h[f]<e){e=h[f]}}}return e}fabric.util.array={invoke:b,min:c,max:a}})();(function(){function b(c,e){for(var d in e){c[d]=e[d]}return c}function a(c){return b({},c)}fabric.util.object={extend:b,clone:a}})();if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}}function camelize(a){return a.replace(/-+(.)?/g,function(b,c){return c?c.toUpperCase():""})}function capitalize(a){return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()}fabric.util.string={camelize:camelize,capitalize:capitalize};(function(){var b=Array.prototype.slice,a=Function.prototype.apply;if(!Function.prototype.bind){Function.prototype.bind=function(c){var e=this,d=b.call(arguments,1);return d.length?function(){return a.call(e,c,d.concat(b.call(arguments)))}:function(){return a.call(e,c,arguments)}}}})();(function(){var e=Array.prototype.slice;var c=(function(){for(var f in {toString:1}){if(f==="toString"){return false}}return true})();var b;if(c){b=function(f,h){if(h.toString!==Object.prototype.toString){f.prototype.toString=h.toString}if(h.valueOf!==Object.prototype.valueOf){f.prototype.valueOf=h.valueOf}for(var g in h){f.prototype[g]=h[g]}}}else{b=function(f,h){for(var g in h){f.prototype[g]=h[g]}}}function a(){}function d(){var j=null,h=e.call(arguments,0);if(typeof h[0]==="function"){j=h.shift()}function f(){this.initialize.apply(this,arguments)}f.superclass=j;f.subclasses=[];if(j){a.prototype=j.prototype;f.prototype=new a;j.subclasses.push(f)}for(var g=0,k=h.length;g<k;g++){b(f,h[g])}if(!f.prototype.initialize){f.prototype.initialize=emptyFunction}f.prototype.constructor=f;return f}fabric.util.createClass=d})();(function(d){function h(s){var w=Array.prototype.slice.call(arguments,1),v,u,r=w.length;for(u=0;u<r;u++){v=typeof s[w[u]];if(!(/^(?:function|object|unknown)$/).test(v)){return false}}return true}var e=(function(){if(typeof fabric.document.documentElement.uniqueID!=="undefined"){return function(s){return s.uniqueID}}var r=0;return function(s){return s.__uniqueID||(s.__uniqueID="uniqueID__"+r++)}})();var f,c;(function(){var r={};f=function(s){return r[s]};c=function(t,s){r[t]=s}})();function i(r,s){return{handler:s,wrappedHandler:l(r,s)}}function l(r,s){return function(t){s.call(f(r),t||fabric.window.event)}}function j(s,r){return function(w){if(g[s]&&g[s][r]){var u=g[s][r];for(var v=0,t=u.length;v<t;v++){u[v].call(this,w||fabric.window.event)}}}}var o=(h(fabric.document.documentElement,"addEventListener","removeEventListener")&&h(fabric.window,"addEventListener","removeEventListener")),m=(h(fabric.document.documentElement,"attachEvent","detachEvent")&&h(fabric.window,"attachEvent","detachEvent")),n={},g={},b,k;if(o){b=function(s,r,t){s.addEventListener(r,t,false)};k=function(s,r,t){s.removeEventListener(r,t,false)}}else{if(m){b=function(t,r,u){var s=e(t);c(s,t);if(!n[s]){n[s]={}}if(!n[s][r]){n[s][r]=[]}var v=i(s,u);n[s][r].push(v);t.attachEvent("on"+r,v.wrappedHandler)};k=function(v,s,w){var u=e(v),x;if(n[u]&&n[u][s]){for(var t=0,r=n[u][s].length;t<r;t++){x=n[u][s][t];if(x&&x.handler===w){v.detachEvent("on"+s,x.wrappedHandler);n[u][s][t]=null}}}}}else{b=function(t,r,u){var s=e(t);if(!g[s]){g[s]={}}if(!g[s][r]){g[s][r]=[];var v=t["on"+r];if(v){g[s][r].push(v)}t["on"+r]=j(s,r)}g[s][r].push(u)};k=function(w,t,x){var v=e(w);if(g[v]&&g[v][t]){var s=g[v][t];for(var u=0,r=s.length;u<r;u++){if(s[u]===x){s.splice(u,1)}}}}}}fabric.util.addListener=b;fabric.util.removeListener=k;function q(r){return{x:a(r),y:p(r)}}function a(t){var s=fabric.document.documentElement,r=fabric.document.body||{scrollLeft:0};return t.pageX||((typeof t.clientX!="unknown"?t.clientX:0)+(s.scrollLeft||r.scrollLeft)-(s.clientLeft||0))}function p(t){var s=fabric.document.documentElement,r=fabric.document.body||{scrollTop:0};return t.pageY||((typeof t.clientY!="unknown"?t.clientY:0)+(s.scrollTop||r.scrollTop)-(s.clientTop||0))}fabric.util.getPointer=q;fabric.util.object.extend(fabric.util,fabric.Observable)})(this);(function(){function e(j,l){var n=j.style,i;if(typeof l==="string"){j.style.cssText+=";"+l;return l.indexOf("opacity")>-1?c(j,l.match(/opacity:\s*(\d?\.?\d*)/)[1]):j}for(var m in l){if(m==="opacity"){c(j,l[m])}else{var k=(m==="float"||m==="cssFloat")?(typeof n.styleFloat==="undefined"?"cssFloat":"styleFloat"):m;n[k]=l[m]}}return j}var h=fabric.document.createElement("div"),g=typeof h.style.opacity==="string",b=typeof h.style.filter==="string",a=fabric.document.defaultView,f=a&&typeof a.getComputedStyle!=="undefined",d=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,c=function(i){return i};if(g){c=function(i,j){i.style.opacity=j;return i}}else{if(b){c=function(i,j){var k=i.style;if(i.currentStyle&&!i.currentStyle.hasLayout){k.zoom=1}if(d.test(k.filter)){j=j>=0.9999?"":("alpha(opacity="+(j*100)+")");k.filter=k.filter.replace(d,j)}else{k.filter+=" alpha(opacity="+(j*100)+")"}return i}}}fabric.util.setStyle=e})();(function(){var h=Array.prototype.slice;function g(j){return typeof j==="string"?fabric.document.getElementById(j):j}function b(j){return h.call(j,0)}try{var i=b(fabric.document.childNodes) instanceof Array}catch(a){}if(!i){b=function(k){var j=new Array(k.length),l=k.length;while(l--){j[l]=k[l]}return j}}function c(k,j){var l=fabric.document.createElement(k);for(var m in j){if(m==="class"){l.className=j[m]}else{if(m==="for"){l.htmlFor=j[m]}else{l.setAttribute(m,j[m])}}}return l}function f(j,k){if((" "+j.className+" ").indexOf(" "+k+" ")===-1){j.className+=(j.className?" ":"")+k}}function e(k,l,j){if(typeof l==="string"){l=c(l,j)}if(k.parentNode){k.parentNode.replaceChild(l,k)}l.appendChild(k);return l}function d(k){var j=0,l=0;do{j+=k.offsetTop||0;l+=k.offsetLeft||0;k=k.offsetParent}while(k);return({left:l,top:j})}(function(){var j=fabric.document.documentElement.style;var k="userSelect" in j?"userSelect":"MozUserSelect" in j?"MozUserSelect":"WebkitUserSelect" in j?"WebkitUserSelect":"KhtmlUserSelect" in j?"KhtmlUserSelect":"";function l(m){if(typeof m.onselectstart!=="undefined"){m.onselectstart=fabric.util.falseFunction}if(k){m.style[k]="none"}else{if(typeof m.unselectable=="string"){m.unselectable="on"}}return m}fabric.util.makeElementUnselectable=l})();(function(){function j(k,o){var m=fabric.document.getElementsByTagName("head")[0],l=fabric.document.createElement("script"),n=true;l.type="text/javascript";l.setAttribute("runat","server");l.onload=l.onreadystatechange=function(p){if(n){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}n=false;o(p||fabric.window.event);l=l.onload=l.onreadystatechange=null}};l.src=k;m.appendChild(l)}fabric.util.getScript=j})();fabric.util.getById=g;fabric.util.toArray=b;fabric.util.makeElement=c;fabric.util.addClass=f;fabric.util.wrapElement=e;fabric.util.getElementOffset=d})();(function(){function d(e,f){return e+(/\?/.test(e)?"&":"?")+f}var c=(function(){var h=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest()}];for(var e=h.length;e--;){try{var g=h[e]();if(g){return h[e]}}catch(f){}}})();function a(){}function b(g,f){f||(f={});var j=f.method?f.method.toUpperCase():"GET",i=f.onComplete||function(){},h=c(),e;h.onreadystatechange=function(){if(h.readyState===4){i(h);h.onreadystatechange=a}};if(j==="GET"){e=null;if(typeof f.parameters=="string"){g=d(g,f.parameters)}}h.open(j,g,true);if(j==="POST"||j==="PUT"){h.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}h.send(e);return h}fabric.util.request=b})();(function(b){var c=b.fabric||(b.fabric={}),i=c.util.object.extend,f=c.util.string.capitalize,j=c.util.object.clone;var d={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function p(u,t){if(!u){return}var w,s,r={};if(u.parentNode&&/^g$/i.test(u.parentNode.nodeName)){r=c.parseAttributes(u.parentNode,t)}var v=t.reduce(function(y,x){w=u.getAttribute(x);s=parseFloat(w);if(w){if((x==="fill"||x==="stroke")&&w==="none"){w=""}if(x==="fill-rule"){w=(w==="evenodd")?"destination-over":w}if(x==="transform"){w=c.parseTransformAttribute(w)}if(x in d){x=d[x]}y[x]=isNaN(s)?w:s}return y},{});v=i(v,i(a(u),c.parseStyleAttribute(u)));return i(r,v)}c.parseTransformAttribute=(function(){function r(K,L){var M=L[0];K[0]=Math.cos(M);K[1]=Math.sin(M);K[2]=-Math.sin(M);K[3]=Math.cos(M)}function w(M,N){var L=N[0],K=(N.length===2)?N[1]:N[0];M[0]=L;M[3]=K}function H(K,L){K[2]=L[0]}function t(K,L){K[1]=L[0]}function E(K,L){K[4]=L[0];if(L.length===2){K[5]=L[1]}}var y=[1,0,0,1,0,0],s="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",I="(?:\\s+,?\\s*|,\\s*)",z="(?:(skewX)\\s*\\(\\s*("+s+")\\s*\\))",x="(?:(skewY)\\s*\\(\\s*("+s+")\\s*\\))",G="(?:(rotate)\\s*\\(\\s*("+s+")(?:"+I+"("+s+")"+I+"("+s+"))?\\s*\\))",J="(?:(scale)\\s*\\(\\s*("+s+")(?:"+I+"("+s+"))?\\s*\\))",C="(?:(translate)\\s*\\(\\s*("+s+")(?:"+I+"("+s+"))?\\s*\\))",F="(?:(matrix)\\s*\\(\\s*("+s+")"+I+"("+s+")"+I+"("+s+")"+I+"("+s+")"+I+"("+s+")"+I+"("+s+")\\s*\\))",D="(?:"+F+"|"+C+"|"+J+"|"+G+"|"+z+"|"+x+")",A="(?:"+D+"(?:"+I+D+")*)",u="^\\s*(?:"+A+"?)\\s*$",B=new RegExp(u),v=new RegExp(D);return function(L){var K=y.concat();if(!L||(L&&!B.test(L))){return K}L.replace(v,function(P){var M=new RegExp(D).exec(P).filter(function(Q){return(Q!==""&&Q!=null)}),N=M[1],O=M.slice(2).map(parseFloat);switch(N){case"translate":E(K,O);break;case"rotate":r(K,O);break;case"scale":w(K,O);break;case"skewX":H(K,O);break;case"skewY":t(K,O);break;case"matrix":K=O;break}});return K}})();function l(u){if(!u){return null}u=u.trim();var w=u.indexOf(",")>-1;u=u.split(/\s+/);var s=[];if(w){for(var t=0,r=u.length;t<r;t++){var v=u[t].split(",");s.push({x:parseFloat(v[0]),y:parseFloat(v[1])})}}else{for(var t=0,r=u.length;t<r;t+=2){s.push({x:parseFloat(u[t]),y:parseFloat(u[t+1])})}}if(s.length%2!==0){}return s}function h(s){var r={},t=s.getAttribute("style");if(t){if(typeof t=="string"){t=t.replace(/;$/,"").split(";");r=t.reduce(function(w,z){var v=z.split(":"),x=v[0].trim(),y=v[1].trim();w[x]=y;return w},{})}else{for(var u in t){if(typeof t[u]!=="undefined"){r[u]=t[u]}}}}return r}function o(w){var s=c.Canvas.activeInstance,r=s?s.getContext():null;if(!r){return}for(var t=w.length;t--;){var u=w[t].get("fill");if(/^url\(/.test(u)){var v=u.slice(5,u.length-1);if(c.gradientDefs[v]){w[t].set("fill",c.Gradient.fromElement(c.gradientDefs[v],r,w[t]))}}}}function e(s,A,B){var r=Array(s.length),v=s.length;function t(){if(--v===0){r=r.filter(function(C){return C!=null});o(r);A(r)}}for(var x=0,u,w=s.length;x<w;x++){u=s[x];var z=c[f(u.tagName)];if(z&&z.fromElement){try{if(z.fromElement.async){z.fromElement(u,(function(C){return function(D){r.splice(C,0,D);t()}})(x),B)}else{r.splice(x,0,z.fromElement(u,B));t()}}catch(y){c.log(y.message||y)}}else{t()}}}function n(w){var u=w.getElementsByTagName("style"),s={},x;for(var t=0,r=u.length;t<r;t++){var v=u[0].textContent;v=v.replace(/\/\*[\s\S]*?\*\//g,"");x=v.match(/[^{]*\{[\s\S]*?\}/g);x=x.map(function(y){return y.trim()});x.forEach(function(D){var B=D.match(/([\s\S]*?)\s*\{([^}]*)\}/),D=B[1],y=B[2].trim(),F=y.replace(/;$/,"").split(/\s*;\s*/);if(!s[D]){s[D]={}}for(var A=0,C=F.length;A<C;A++){var z=F[A].split(/\s*:\s*/),G=z[0],E=z[1];s[D][G]=E}})}return s}function a(s){var y=s.nodeName,t=s.getAttribute("class"),x=s.getAttribute("id"),u={};for(var w in c.cssRules){var r=(t&&new RegExp("^\\."+t).test(w))||(x&&new RegExp("^#"+x).test(w))||(new RegExp("^"+y).test(w));if(r){for(var v in c.cssRules[w]){u[v]=c.cssRules[w][v]}}}return u}c.parseSVGDocument=(function(){var r=/^(path|circle|polygon|polyline|ellipse|rect|line|image)$/;var s="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var t=new RegExp("^\\s*("+s+"+)\\s*,?\\s*("+s+"+)\\s*,?\\s*("+s+"+)\\s*,?\\s*("+s+"+)\\s*$");function u(v,w){while(v&&(v=v.parentNode)){if(w.test(v.nodeName)){return true}}return false}return function(H,J){if(!H){return}var z=new Date(),D=c.util.toArray(H.getElementsByTagName("*"));if(D.length===0){D=H.selectNodes("//*[name(.)!='svg']");var F=[];for(var E=0,G=D.length;E<G;E++){F[E]=D[E]}D=F}var v=D.filter(function(L){return r.test(L.tagName)&&!u(L,/^(?:pattern|defs)$/)});if(!v||(v&&!v.length)){return}var w=H.getAttribute("viewBox"),B=H.getAttribute("width"),y=H.getAttribute("height"),x=null,I=null,C,A;if(w&&(w=w.match(t))){C=parseInt(w[1],10);A=parseInt(w[2],10);x=parseInt(w[3],10);I=parseInt(w[4],10)}x=B?parseFloat(B):x;I=y?parseFloat(y):I;var K={width:x,height:I};c.gradientDefs=c.getGradientDefs(H);c.cssRules=n(H);c.parseElements(v,function(L){c.documentParsingTime=new Date()-z;if(J){J(L,K)}},j(K))}})();var m={has:function(r,s){s(false)},get:function(r,s){},set:function(s,r){}};function k(r,t){r=r.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();m.has(r,function(u){if(u){m.get(r,function(w){var v=q(w);t(v.objects,v.options)})}else{new c.util.request(r,{method:"get",onComplete:s})}});function s(v){var u=v.responseXML;if(!u){return}var w=u.documentElement;if(!w){return}c.parseSVGDocument(w,function(y,x){m.set(r,{objects:c.util.array.invoke(y,"toObject"),options:x});t(y,x)})}}function q(t){var s=t.objects,r=t.options;s=s.map(function(u){return c[f(u.type)].fromObject(u)});return({objects:s,options:r})}function g(r,u){r=r.trim();var s;if(typeof DOMParser!=="undefined"){var t=new DOMParser();if(t&&t.parseFromString){s=t.parseFromString(r,"text/xml")}}else{if(c.window.ActiveXObject){var s=new ActiveXObject("Microsoft.XMLDOM");if(s&&s.loadXML){s.async="false";s.loadXML(r)}}}c.parseSVGDocument(s.documentElement,function(w,v){u(w,v)})}i(c,{parseAttributes:p,parseElements:e,parseStyleAttribute:h,parsePointsAttribute:l,getCSSRules:n,loadSVGFromURL:k,loadSVGFromString:g})})(typeof exports!="undefined"?exports:this);(function(){function c(h){var g=h.getAttribute("style");if(g){var k=g.split(/\s*;\s*/);for(var f=k.length;f--;){var e=k[f].split(/\s*:\s*/),d=e[0].trim(),j=e[1].trim();if(d==="stop-color"){return j}}}}fabric.Gradient={create:function(l,m){m||(m={});var f=m.x1||0,k=m.y1||0,e=m.x2||l.canvas.width,i=m.y2||0,g=m.colorStops;var j=l.createLinearGradient(f,k,e,i);for(var h in g){var d=g[h];j.addColorStop(parseFloat(h),d)}return j},fromElement:function(d,m,l){var k=d.getElementsByTagName("stop"),d,f,e={},g;for(var h=k.length;h--;){d=k[h];f=parseInt(d.getAttribute("offset"),10)/100;e[f]=c(d)||d.getAttribute("stop-color")}var j={x1:d.getAttribute("x1")||0,y1:d.getAttribute("y1")||0,x2:d.getAttribute("x2")||"100%",y2:d.getAttribute("y2")||0};a(l,j);return fabric.Gradient.create(m,{x1:j.x1,y1:j.y1,x2:j.x2,y2:j.y2,colorStops:e})},forObject:function(g,d,e){e||(e={});a(g,e);var f=fabric.Gradient.create(d,{x1:e.x1-(g.width/2),y1:e.y1-(g.height/2),x2:e.x2-(g.width/2),y2:e.y2-(g.height/2),colorStops:e.colorStops});return f}};function a(f,e){for(var g in e){if(typeof e[g]==="string"&&/^\d+%$/.test(e[g])){var d=parseFloat(e[g],10);if(g==="x1"||g==="x2"){e[g]=f.width*d/100}else{if(g==="y1"||g==="y2"){e[g]=f.height*d/100}}}if(g==="x1"||g==="x2"){e[g]-=f.width/2}else{if(g==="y1"||g==="y2"){e[g]-=f.height/2}}}}function b(j){var f=j.getElementsByTagName("linearGradient"),d=j.getElementsByTagName("radialGradient"),g,h={};for(var e=f.length;e--;){g=f[e];h[g.id]=g}for(var e=d.length;e--;){g=d[e];h[g.id]=g}return h}fabric.getGradientDefs=b})();(function(b){var c=b.fabric||(b.fabric={});if(c.Point){c.warn("fabric.Point is already defined");return}c.Point=a;function a(d,e){if(arguments.length>0){this.init(d,e)}}a.prototype={constructor:a,init:function(d,e){this.x=d;this.y=e},add:function(d){return new a(this.x+d.x,this.y+d.y)},addEquals:function(d){this.x+=d.x;this.y+=d.y;return this},scalarAdd:function(d){return new a(this.x+d,this.y+d)},scalarAddEquals:function(d){this.x+=d;this.y+=d;return this},subtract:function(d){return new a(this.x-d.x,this.y-d.y)},subtractEquals:function(d){this.x-=d.x;this.y-=d.y;return this},scalarSubtract:function(d){return new a(this.x-d,this.y-d)},scalarSubtractEquals:function(d){this.x-=d;this.y-=d;return this},multiply:function(d){return new a(this.x*d,this.y*d)},multiplyEquals:function(d){this.x*=d;this.y*=d;return this},divide:function(d){return new a(this.x/d,this.y/d)},divideEquals:function(d){this.x/=d;this.y/=d;return this},eq:function(d){return(this.x==d.x&&this.y==d.y)},lt:function(d){return(this.x<d.x&&this.y<d.y)},lte:function(d){return(this.x<=d.x&&this.y<=d.y)},gt:function(d){return(this.x>d.x&&this.y>d.y)},gte:function(d){return(this.x>=d.x&&this.y>=d.y)},lerp:function(e,d){return new a(this.x+(e.x-this.x)*d,this.y+(e.y-this.y)*d)},distanceFrom:function(f){var e=this.x-f.x,d=this.y-f.y;return Math.sqrt(e*e+d*d)},min:function(d){return new a(Math.min(this.x,d.x),Math.min(this.y,d.y))},max:function(d){return new a(Math.max(this.x,d.x),Math.max(this.y,d.y))},toString:function(){return this.x+","+this.y},setXY:function(d,e){this.x=d;this.y=e},setFromPoint:function(d){this.x=d.x;this.y=d.y},swap:function(e){var d=this.x,f=this.y;this.x=e.x;this.y=e.y;e.x=d;e.y=f}}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Intersection){b.warn("fabric.Intersection is already defined");return}function c(d){if(arguments.length>0){this.init(d)}}b.Intersection=c;b.Intersection.prototype={init:function(d){this.status=d;this.points=[]},appendPoint:function(d){this.points.push(d)},appendPoints:function(d){this.points=this.points.concat(d)}};b.Intersection.intersectLineLine=function(h,f,l,k){var m,i=(k.x-l.x)*(h.y-l.y)-(k.y-l.y)*(h.x-l.x),j=(f.x-h.x)*(h.y-l.y)-(f.y-h.y)*(h.x-l.x),g=(k.y-l.y)*(f.x-h.x)-(k.x-l.x)*(f.y-h.y);if(g!=0){var e=i/g,d=j/g;if(0<=e&&e<=1&&0<=d&&d<=1){m=new c("Intersection");m.points.push(new b.Point(h.x+e*(f.x-h.x),h.y+e*(f.y-h.y)))}else{m=new c("No Intersection")}}else{if(i==0||j==0){m=new c("Coincident")}else{m=new c("Parallel")}}return m};b.Intersection.intersectLinePolygon=function(e,d,l){var m=new c("No Intersection"),f=l.length;for(var h=0;h<f;h++){var k=l[h],j=l[(h+1)%f],g=c.intersectLineLine(e,d,k,j);m.appendPoints(g.points)}if(m.points.length>0){m.status="Intersection"}return m};b.Intersection.intersectPolygonPolygon=function(j,h){var f=new c("No Intersection"),l=j.length;for(var k=0;k<l;k++){var g=j[k],e=j[(k+1)%l],d=c.intersectLinePolygon(g,e,h);f.appendPoints(d.points)}if(f.points.length>0){f.status="Intersection"}return f};b.Intersection.intersectPolygonRectangle=function(n,e,d){var g=e.min(d),m=e.max(d),f=new b.Point(m.x,g.y),l=new b.Point(g.x,m.y),k=c.intersectLinePolygon(g,f,n),j=c.intersectLinePolygon(f,m,n),i=c.intersectLinePolygon(m,l,n),h=c.intersectLinePolygon(l,g,n),o=new c("No Intersection");o.appendPoints(k.points);o.appendPoints(j.points);o.appendPoints(i.points);o.appendPoints(h.points);if(o.points.length>0){o.status="Intersection"}return o}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Color){b.warn("fabric.Color is already defined.");return}function c(d){if(!d){this.setSource([0,0,0,1])}else{this._tryParsingColor(d)}}b.Color=c;b.Color.prototype={_tryParsingColor:function(d){var e=c.sourceFromHex(d);if(!e){e=c.sourceFromRgb(d)}if(e){this.setSource(e)}},getSource:function(){return this._source},setSource:function(d){this._source=d},toRgb:function(){var d=this.getSource();return"rgb("+d[0]+","+d[1]+","+d[2]+")"},toRgba:function(){var d=this.getSource();return"rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")"},toHex:function(){var h=this.getSource();var f=h[0].toString(16);f=(f.length==1)?("0"+f):f;var e=h[1].toString(16);e=(e.length==1)?("0"+e):e;var d=h[2].toString(16);d=(d.length==1)?("0"+d):d;return f.toUpperCase()+e.toUpperCase()+d.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var d=this.getSource();d[3]=e;this.setSource(d);return this},toGrayscale:function(){var f=this.getSource(),e=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10),d=f[3];this.setSource([e,e,e,d]);return this},toBlackWhite:function(d){var g=this.getSource(),f=(g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),e=g[3],d=d||127;f=(Number(f)<Number(d))?0:255;this.setSource([f,f,f,e]);return this},overlayWith:function(k){if(!(k instanceof c)){k=new c(k)}var d=[],j=this.getAlpha(),g=0.5,h=this.getSource(),e=k.getSource();for(var f=0;f<3;f++){d.push(Math.round((h[f]*(1-g))+(e[f]*g)))}d[4]=j;this.setSource(d);return this}};b.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;b.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;b.Color.fromRgb=function(d){return c.fromSource(c.sourceFromRgb(d))};b.Color.sourceFromRgb=function(d){var e=d.match(c.reRGBa);if(e){return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),e[4]?parseFloat(e[4]):1]}};b.Color.fromRgba=c.fromRgb;b.Color.fromHex=function(d){return c.fromSource(c.sourceFromHex(d))};b.Color.sourceFromHex=function(f){if(f.match(c.reHex)){var j=f.slice(f.indexOf("#")+1),e=(j.length===3),i=e?(j.charAt(0)+j.charAt(0)):j.substring(0,2),h=e?(j.charAt(1)+j.charAt(1)):j.substring(2,4),d=e?(j.charAt(2)+j.charAt(2)):j.substring(4,6);return[parseInt(i,16),parseInt(h,16),parseInt(d,16),1]}};b.Color.fromSource=function(d){var e=new c();e.setSource(d);return e}})(typeof exports!="undefined"?exports:this);(function(o){if(fabric.Canvas){fabric.warn("fabric.Canvas is already defined.");return}var q=fabric.util.object.extend,g=fabric.util.string.capitalize,r=fabric.util.string.camelize,e=fabric.util.getPointer,m=fabric.util.getElementOffset,i=fabric.util.removeFromArray,h=fabric.util.addListener,d=fabric.util.removeListener,k=fabric.util.array.min,l=fabric.util.array.max,s=Math.sqrt,b=Math.pow,a=Math.atan2,j=Math.abs,n=Math.min,p=Math.max,f=new Error("Could not initialize `canvas` element"),c=0.5,t={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"};fabric.Canvas=function(v,u){u||(u={});this._groupSelector=null;this._objects=[];this._context=null;this._currentTransform=null;this._activeGroup=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._createUpperCanvas(v);this._initOptions(u);this._initWrapperElement();this._createLowerCanvas();this._initEvents();if(u.overlayImage){this.setOverlayImage(u.overlayImage)}this.calcOffset();fabric.Canvas.activeInstance=this};q(fabric.Canvas.prototype,fabric.Observable);q(fabric.Canvas.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",selection:true,selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,freeDrawingColor:"rgb(0, 0, 0)",freeDrawingLineWidth:1,includeDefaultValues:true,shouldCacheImages:false,stateful:true,renderOnAddition:true,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,CONTAINER_CLASS:"canvas-container",HOVER_CURSOR:"move",onBeforeScaleRotate:function(u){},onFpsUpdate:null,calcOffset:function(){this._offset=m(this.upperCanvasEl);return this},setOverlayImage:function(v,x){if(v){var w=this,u=new Image();u.onload=function(){w.overlayImage=u;if(x){x()}u=u.onload=null};u.src=v}return this},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.upperCanvasEl,"div",{"class":this.CONTAINER_CLASS});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(v){var w=this.getWidth()||v.width,u=this.getHeight()||v.height;fabric.util.setStyle(v,{position:"absolute",width:w+"px",height:u+"px",left:0,top:0});v.width=w;v.height=u;fabric.util.makeElementUnselectable(v)},_createCanvasElement:function(){var u=fabric.document.createElement("canvas");if(!u.style){u.style={}}if(!u){throw f}this._initCanvasElement(u);return u},_initCanvasElement:function(u){if(typeof u.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement){G_vmlCanvasManager.initElement(u)}if(typeof u.getContext==="undefined"){throw f}},_initOptions:function(u){for(var v in u){this[v]=u[v]}this.width=parseInt(this.upperCanvasEl.width,10)||0;this.height=parseInt(this.upperCanvasEl.height,10)||0;this.upperCanvasEl.style.width=this.width+"px";this.upperCanvasEl.style.height=this.height+"px"},_initEvents:function(){var u=this;this._onMouseDown=function(v){u.__onMouseDown(v);h(fabric.document,"mouseup",u._onMouseUp)};this._onMouseUp=function(v){u.__onMouseUp(v);d(fabric.document,"mouseup",u._onMouseUp)};this._onMouseMove=function(v){u.__onMouseMove(v)};this._onResize=function(v){u.calcOffset()};h(this.upperCanvasEl,"mousedown",this._onMouseDown);h(fabric.document,"mousemove",this._onMouseMove);h(fabric.window,"resize",this._onResize)},_createUpperCanvas:function(u){this.upperCanvasEl=fabric.util.getById(u)||this._createCanvasElement();this._initCanvasElement(this.upperCanvasEl);fabric.util.addClass(this.upperCanvasEl,"upper-canvas");this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_createLowerCanvas:function(){this.lowerCanvasEl=this._createCanvasElement();this.lowerCanvasEl.className="lower-canvas";this.wrapperEl.insertBefore(this.lowerCanvasEl,this.upperCanvasEl);this._applyCanvasStyle(this.lowerCanvasEl);this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(u){return this._setDimension("width",u)},setHeight:function(u){return this._setDimension("height",u)},setDimensions:function(u){for(var v in u){this._setDimension(v,u[v])}return this},_setDimension:function(v,u){this.lowerCanvasEl[v]=u;this.lowerCanvasEl.style[v]=u+"px";this.upperCanvasEl[v]=u;this.upperCanvasEl.style[v]=u+"px";this.wrapperEl.style[v]=u+"px";this[v]=u;this.calcOffset();this.renderAll();return this},__onMouseUp:function(y){if(this.isDrawingMode&&this._isCurrentlyDrawing){this._finalizeDrawingPath();return}if(this._currentTransform){var u=this._currentTransform,x=u.target;if(x._scaling){x._scaling=false}var v=this._objects.length;while(v--){this._objects[v].setCoords()}if(this.stateful&&x.hasStateChanged()){x.isMoving=false;this.fire("object:modified",{target:x})}}this._currentTransform=null;if(this._groupSelector){this._findSelectedObjects(y)}var w=this.getActiveGroup();if(w){w.setObjectsCoords();w.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(y,x);this._setCursor("");var z=this;setTimeout(function(){z._setCursorFromEvent(y,x)},50);this.fire("mouse:up",{target:x,e:y})},_shouldClearSelection:function(w){var v=this.findTarget(w),u=this.getActiveGroup();return(!v||(v&&u&&!u.contains(v)&&u!==v&&!w.shiftKey))},__onMouseDown:function(y){if(y.which!==1){return}if(this.isDrawingMode){this._prepareForDrawing(y);this._captureDrawingPath(y);return}if(this._currentTransform){return}var x=this.findTarget(y),z=this.getPointer(y),v=this.getActiveGroup(),w;if(this._shouldClearSelection(y)){this._groupSelector={ex:z.x,ey:z.y,top:0,left:0};this.deactivateAllWithDispatch()}else{this.stateful&&x.saveState();if(w=x._findTargetCorner(y,this._offset)){this.onBeforeScaleRotate(x)}this._setupCurrentTransform(y,x);var u=y.shiftKey&&(v||this.getActiveObject());if(u){this._handleGroupLogic(y,x)}else{if(x!==this.getActiveGroup()){this.deactivateAll()}this.setActiveObject(x)}}this.renderAll();this.fire("mouse:down",{target:x,e:y})},getElement:function(){return this.upperCanvasEl},deactivateAllWithDispatch:function(){var u=this.getActiveGroup()||this.getActiveObject();if(u){this.fire("before:selection:cleared",{target:u})}this.deactivateAll();if(u){this.fire("selection:cleared")}return this},_setupCurrentTransform:function(x,w){var v="drag",u,y=e(x);if(u=w._findTargetCorner(x,this._offset)){v=(u==="ml"||u==="mr")?"scaleX":(u==="mt"||u==="mb")?"scaleY":"rotate"}this._currentTransform={target:w,action:v,scaleX:w.scaleX,scaleY:w.scaleY,offsetX:y.x-w.left,offsetY:y.y-w.top,ex:y.x,ey:y.y,left:w.left,top:w.top,theta:w.theta,width:w.width*w.scaleX};this._currentTransform.original={left:w.left,top:w.top}},_handleGroupLogic:function(x,w){if(w.isType("group")){w=this.findTarget(x,true);if(!w||w.isType("group")){return}}var u=this.getActiveGroup();if(u){if(u.contains(w)){u.remove(w);w.setActive(false);if(u.size()===1){this.discardActiveGroup()}}else{u.add(w)}this.fire("selection:created",{target:u});u.setActive(true)}else{if(this._activeObject){if(w!==this._activeObject){var v=new fabric.Group([this._activeObject,w]);this.setActiveGroup(v);u=this.getActiveGroup()}}w.setActive(true)}if(u){u.saveCoords()}},_prepareForDrawing:function(u){this._isCurrentlyDrawing=true;this.discardActiveObject().renderAll();var v=this.getPointer(u);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(v.x);this._freeDrawingYPoints.push(v.y);this.contextTop.beginPath();this.contextTop.moveTo(v.x,v.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=this.contextTop.lineJoin="round"},_captureDrawingPath:function(u){var v=this.getPointer(u);this._freeDrawingXPoints.push(v.x);this._freeDrawingYPoints.push(v.y);this.contextTop.lineTo(v.x,v.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var z=k(this._freeDrawingXPoints),y=k(this._freeDrawingYPoints),w=l(this._freeDrawingXPoints),u=l(this._freeDrawingYPoints),E=this.contextTop,F=[],A,C,v=this._freeDrawingXPoints,D=this._freeDrawingYPoints;F.push("M ",v[0]-z," ",D[0]-y," ");for(var B=1;A=v[B],C=D[B];B++){F.push("L ",A-z," ",C-y," ")}F=F.join("");if(F==="M 0 0 L 0 0 "){return}var x=new fabric.Path(F);x.fill=null;x.stroke=this.freeDrawingColor;x.strokeWidth=this.freeDrawingLineWidth;this.add(x);x.set("left",z+(w-z)/2).set("top",y+(u-y)/2).setCoords();this.renderAll();this.fire("path:created",{path:x})},__onMouseMove:function(B){if(this.isDrawingMode){if(this._isCurrentlyDrawing){this._captureDrawingPath(B)}return}var v=this._groupSelector;if(v!==null){var C=e(B);v.left=C.x-this._offset.left-v.ex;v.top=C.y-this._offset.top-v.ey;this.renderTop()}else{if(!this._currentTransform){var z=this.upperCanvasEl.style;var A=this.findTarget(B);if(!A){for(var w=this._objects.length;w--;){if(!this._objects[w].active){this._objects[w].setActive(false)}}z.cursor="default"}else{this._setCursorFromEvent(B,A);if(A.isActive()){A.setCornersVisibility&&A.setCornersVisibility(true)}}}else{var C=e(B),u=C.x,D=C.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){if(!B.shiftKey){this._rotateObject(u,D)}this._scaleObject(u,D)}else{if(this._currentTransform.action==="scaleX"){this._scaleObject(u,D,"x")}else{if(this._currentTransform.action==="scaleY"){this._scaleObject(u,D,"y")}else{this._translateObject(u,D);this.fire("object:moving",{target:this._currentTransform.target})}}}this.renderAll()}}this.fire("mouse:move",{target:A,e:B})},_translateObject:function(u,w){var v=this._currentTransform.target;v.lockMovementX||v.set("left",u-this._currentTransform.offsetX);v.lockMovementY||v.set("top",w-this._currentTransform.offsetY)},_scaleObject:function(u,D,B){var v=this._currentTransform,C=this._offset,A=v.target;if(A.lockScalingX&&A.lockScalingY){return}var z=s(b(v.ey-v.top-C.top,2)+b(v.ex-v.left-C.left,2)),w=s(b(D-v.top-C.top,2)+b(u-v.left-C.left,2));A._scaling=true;if(!B){A.lockScalingX||A.set("scaleX",v.scaleX*w/z);A.lockScalingY||A.set("scaleY",v.scaleY*w/z)}else{if(B==="x"&&!A.lockUniScaling){A.lockScalingX||A.set("scaleX",v.scaleX*w/z)}else{if(B==="y"&&!A.lockUniScaling){A.lockScalingY||A.set("scaleY",v.scaleY*w/z)}}}},_rotateObject:function(u,B){var v=this._currentTransform,z=this._offset;if(v.target.lockRotation){return}var w=a(v.ey-v.top-z.top,v.ex-v.left-z.left),A=a(B-v.top-z.top,u-v.left-z.left);v.target.set("theta",(A-w)+v.theta)},_setCursor:function(u){this.upperCanvasEl.style.cursor=u},_setCursorFromEvent:function(y,x){var v=this.upperCanvasEl.style;if(!x){v.cursor="default";return false}else{var u=this.getActiveGroup();var w=!!x._findTargetCorner&&(!u||!u.contains(x))&&x._findTargetCorner(y,this._offset);if(!w){v.cursor=this.HOVER_CURSOR}else{if(w in t){v.cursor=t[w]}else{v.cursor="default";return false}}}return true},_draw:function(u,v){v&&v.render(u)},_drawSelection:function(){var u=this._groupSelector,y=u.left,x=u.top,w=j(y),v=j(x);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(u.ex-((y>0)?0:-y),u.ey-((x>0)?0:-x),w,v);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(u.ex+c-((y>0)?0:w),u.ey+c-((x>0)?0:v),w,v)},_findSelectedObjects:function(A){var B,w,G=[],v=this._groupSelector.ex,F=this._groupSelector.ey,u=v+this._groupSelector.left,D=F+this._groupSelector.top,C,z=new fabric.Point(n(v,u),n(F,D)),E=new fabric.Point(p(v,u),p(F,D));for(var x=0,y=this._objects.length;x<y;++x){C=this._objects[x];if(C.intersectsWithRect(z,E)||C.isContainedWithinRect(z,E)){if(this.selection&&C.selectable){C.setActive(true);G.push(C)}}}if(G.length===1){this.setActiveObject(G[0]);this.fire("object:selected",{target:G[0]})}else{if(G.length>1){var G=new fabric.Group(G);this.setActiveGroup(G);G.saveCoords();this.fire("selection:created",{target:G})}}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);for(var u=arguments.length;u--;){this.stateful&&arguments[u].setupState();arguments[u].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(v,u){this._objects.splice(u,0,v);this.stateful&&v.setupState();v.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(u){u.clearRect(0,0,this.width,this.height);return this},clear:function(){this._objects.length=0;this.clearContext(this.contextTop);this.clearContext(this.contextContainer);this.renderAll();return this},renderAll:function(v){var A=this[v?"contextTop":"contextContainer"];this.clearContext(this.contextTop);if(!v){this.clearContext(A)}var z=this._objects.length,y=this.getActiveGroup(),x=new Date();if(this.clipTo){A.save();A.beginPath();this.clipTo(A);A.clip()}A.fillStyle=this.backgroundColor;A.fillRect(0,0,this.width,this.height);if(z){for(var w=0;w<z;++w){if(!y||(y&&!y.contains(this._objects[w]))){this._draw(A,this._objects[w])}}}if(this.clipTo){A.restore()}if(y){this._draw(this.contextTop,y)}if(this.overlayImage){this.contextTop.drawImage(this.overlayImage,0,0)}if(this.onFpsUpdate){var u=new Date()-x;this.onFpsUpdate(~~(1000/u))}this.fire("after:render");return this},renderTop:function(){this.clearContext(this.contextTop);if(this.overlayImage){this.contextTop.drawImage(this.overlayImage,0,0)}if(this.selection&&this._groupSelector){this._drawSelection()}var u=this.getActiveGroup();if(u){u.render(this.contextTop)}this.fire("after:render");return this},containsPoint:function(B,A){var C=this.getPointer(B),z=this._normalizePointer(A,C),u=z.x,D=z.y;var v=A._getImageLines(A.oCoords),w=A._findCrossPoints(u,D,v);if((w&&w%2===1)||A._findTargetCorner(B,this._offset)){return true}return false},_normalizePointer:function(v,A){var z=this.getActiveGroup(),u=A.x,B=A.y;var w=(z&&v.type!=="group"&&z.contains(v));if(w){u-=z.left;B-=z.top}return{x:u,y:B}},findTarget:function(y,v){var x,z=this.getPointer(y);var w=this.getActiveGroup();if(w&&!v&&this.containsPoint(y,w)){x=w;return x}for(var u=this._objects.length;u--;){if(this.containsPoint(y,this._objects[u])){x=this._objects[u];this.relatedTarget=x;break}}if(this.selection&&x&&x.selectable){return x}},toDataURL:function(v){this.renderAll(true);var u=this.upperCanvasEl.toDataURL("image/"+v);this.renderAll();return u},toDataURLWithMultiplier:function(x,B){var A=this.getWidth(),z=this.getHeight(),v=A*B,w=z*B,u=this.getActiveObject();this.setWidth(v).setHeight(w);this.contextTop.scale(B,B);if(u){this.deactivateAll().renderAll()}var y=this.toDataURL(x);this.contextTop.scale(1/B,1/B);this.setWidth(A).setHeight(z);if(u){this.setActiveObject(u)}this.renderAll();return y},getPointer:function(u){var v=e(u);return{x:v.x-this._offset.left,y:v.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(u){u.set("left",this.getCenter().left);this.renderAll();return this},centerObjectV:function(u){u.set("top",this.getCenter().top);this.renderAll();return this},straightenObject:function(u){u.straighten();this.renderAll();return this},toDatalessJSON:function(){return this.toDatalessObject()},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(u){return{objects:this._objects.map(function(v){if(!this.includeDefaultValues){var w=v.includeDefaultValues;v.includeDefaultValues=false}var x=v[u]();if(!this.includeDefaultValues){v.includeDefaultValues=w}return x},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadImageFromURL:(function(){var u={};return function(v,z){var y=this;function w(){var A=fabric.document.getElementById(u[v]);if(A.width&&A.height){z(new fabric.Image(A))}else{setTimeout(w,50)}}if(u[v]){w()}else{var x=new Image();x.onload=function(){x.onload=null;setTimeout(function(){if(x.width&&x.height){z(new fabric.Image(x))}},0)};x.className="canvas-img-clone";x.style.cssText="position:absolute;left:-9999px;top:-9999px;";x.src=v;if(this.shouldCacheImages){u[v]=Element.identify(x)}fabric.document.body.appendChild(x)}}})(),remove:function(u){i(this._objects,u);if(this.getActiveObject()===u){this.discardActiveObject()}this.renderAll();return u},sendToBack:function(u){i(this._objects,u);this._objects.unshift(u);return this.renderAll()},bringToFront:function(u){i(this._objects,u);this._objects.push(u);return this.renderAll()},sendBackwards:function(w){var v=this._objects.indexOf(w),u=v;if(v!==0){for(var x=v-1;x>=0;--x){if(w.intersectsWithObject(this._objects[x])||w.isContainedWithinObject(this._objects[x])){u=x;break}}i(this._objects,w);this._objects.splice(u,0,w)}return this.renderAll()},bringForward:function(x){var z=this.getObjects(),v=z.indexOf(x),u=v;if(v!==z.length-1){for(var y=v+1,w=this._objects.length;y<w;++y){if(x.intersectsWithObject(z[y])||x.isContainedWithinObject(this._objects[y])){u=y;break}}i(z,x);z.splice(u,0,x)}this.renderAll()},setActiveObject:function(u){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=u;u.setActive(true);this.renderAll();this.fire("object:selected",{target:u});return this},getActiveObject:function(){return this._activeObject},discardActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(u){this._activeGroup=u;return this},getActiveGroup:function(){return this._activeGroup},discardActiveGroup:function(){var u=this.getActiveGroup();if(u){u.destroy()}return this.setActiveGroup(null)},item:function(u){return this.getObjects()[u]},deactivateAll:function(){var v=this.getObjects(),w=0,u=v.length;for(;w<u;w++){v[w].setActive(false)}this.discardActiveGroup();this.discardActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(u,v){u+=v.complexity?v.complexity():0;return u},0)},forEachObject:function(x,v){var w=this.getObjects(),u=w.length;while(u--){x.call(v,w[u],u,w)}return this},dispose:function(){this.clear();d(this.upperCanvasEl,"mousedown",this._onMouseDown);d(fabric.document,"mousemove",this._onMouseMove);d(fabric.window,"resize",this._onResize);return this},_resizeImageToFit:function(w){var v=w.width||w.offsetWidth,u=this.getWidth()/v;if(v){w.width=v*u}}});fabric.Canvas.prototype.toString=function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};q(fabric.Canvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(x){var w=x.getContext("2d"),u=w.getImageData(0,0,x.width,x.height),B=u.data,y=u.width,D=u.height,C,v,A,z;for(A=0;A<y;A++){for(z=0;z<D;z++){C=(A*4)*D+(z*4);v=(B[C]+B[C+1]+B[C+2])/3;B[C]=v;B[C+1]=v;B[C+2]=v}}w.putImageData(u,0,0)},supports:function(v){var w=fabric.document.createElement("canvas");if(typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(w)}if(!w||!w.getContext){return null}var u=w.getContext("2d");if(!u){return null}switch(v){case"getImageData":return typeof u.getImageData!=="undefined";case"toDataURL":return typeof w.toDataURL!=="undefined";default:return null}}});fabric.Canvas.prototype.toJSON=fabric.Canvas.prototype.toObject;fabric.Element=fabric.Canvas})(typeof exports!="undefined"?exports:this);fabric.util.object.extend(fabric.Canvas.prototype,{fxCenterObjectH:function(b,c){c=c||{};var d=function(){},e=c.onComplete||d,a=c.onChange||d,f=this;fabric.util.animate({startValue:b.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(g){b.set("left",g);f.renderAll();a()},onComplete:function(){b.setCoords();e()}});return this},fxCenterObjectV:function(b,c){c=c||{};var d=function(){},e=c.onComplete||d,a=c.onChange||d,f=this;fabric.util.animate({startValue:b.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(g){b.set("top",g);f.renderAll();a()},onComplete:function(){b.setCoords();e()}});return this},fxStraightenObject:function(a){a.fxStraighten({onChange:this.renderAll.bind(this)});return this},fxRemove:function(a,c){var b=this;a.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){b.remove(a);if(typeof c==="function"){c()}}});return this}});fabric.util.object.extend(fabric.Canvas.prototype,{loadFromDatalessJSON:function(a,c){if(!a){return}var b=(typeof a==="string")?JSON.parse(a):a;if(!b||(b&&!b.objects)){return}this.clear();this.backgroundColor=b.background;this._enlivenDatalessObjects(b.objects,c)},_enlivenDatalessObjects:function(b,h){function g(i,e){f.insertAt(i,e);i.setCoords();if(++d===a){h&&h()}}var f=this,d=0,a=b.length;if(a===0&&h){h()}try{b.forEach(function(n,l){var i=n.paths?"paths":"path";var m=n[i];delete n[i];if(typeof m!=="string"){switch(n.type){case"image":case"text":fabric[fabric.util.string.capitalize(n.type)].fromObject(n,function(p){g(p,l)});break;default:var e=fabric[fabric.util.string.camelize(fabric.util.string.capitalize(n.type))];if(e&&e.fromObject){if(m){n[i]=m}g(e.fromObject(n),l)}break}}else{if(n.type==="image"){f.loadImageFromURL(m,function(o){o.setSourcePath(m);fabric.util.object.extend(o,n);o.setAngle(n.angle);g(o,l)})}else{if(n.type==="text"){n.path=m;var k=fabric.Text.fromObject(n);var j=function(){if(Object.prototype.toString.call(fabric.window.opera)==="[object Opera]"){setTimeout(function(){g(k,l)},500)}else{g(k,l)}};fabric.util.getScript(m,j)}else{fabric.loadSVGFromURL(m,function(q,p){if(q.length>1){var o=new fabric.PathGroup(q,n)}else{var o=q[0]}o.setSourcePath(m);if(!(o instanceof fabric.PathGroup)){fabric.util.object.extend(o,n);if(typeof n.angle!=="undefined"){o.setAngle(n.angle)}}g(o,l)})}}}},this)}catch(c){fabric.log(c.message)}},loadFromJSON:function(a,d){if(!a){return}var b=JSON.parse(a);if(!b||(b&&!b.objects)){return}this.clear();var c=this;this._enlivenObjects(b.objects,function(){c.backgroundColor=b.background;if(d){d()}});return this},_enlivenObjects:function(b,e){var c=0,a=b.filter(function(f){return f.type==="image"}).length;var d=this;b.forEach(function(h,g){if(!h.type){return}switch(h.type){case"image":case"font":fabric[fabric.util.string.capitalize(h.type)].fromObject(h,function(i){d.insertAt(i,g);if(++c===a){if(e){e()}}});break;default:var f=fabric[fabric.util.string.camelize(fabric.util.string.capitalize(h.type))];if(f&&f.fromObject){d.insertAt(f.fromObject(h),g)}break}});if(a===0&&e){e()}},_toDataURL:function(a,b){this.clone(function(c){b(c.toDataURL(a))})},_toDataURLWithMultiplier:function(a,c,b){this.clone(function(d){b(d.toDataURLWithMultiplier(a,c))})},clone:function(c){var a=fabric.document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();var b=this.__clone||(this.__clone=new fabric.Canvas(a));b.clipTo=this.clipTo;return b.loadFromJSON(JSON.stringify(this.toJSON()),function(){if(c){c(b)}})}});(function(a){var d=a.fabric||(a.fabric={}),l=d.util.object.extend,m=d.util.object.clone,c=d.util.toFixed,k=d.util.string.capitalize,p=d.util.getPointer,b=d.util.degreesToRadians,o=Array.prototype.slice;if(d.Object){return}d.Object=d.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,MIN_SCALE_LIMIT:0.1,stateProperties:("top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix selectable").split(" "),top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:12,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",fillRule:"source-over",overlayFill:null,stroke:null,strokeWidth:1,borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null,selectable:true,hasControls:true,hasBorders:true,callSuper:function(i){var q=this.constructor.superclass.prototype[i];return(arguments.length>1)?q.apply(this,o.call(arguments,1)):q.call(this)},initialize:function(i){i&&this.setOptions(i)},setOptions:function(q){var r=this.stateProperties.length,s;while(r--){s=this.stateProperties[r];if(s in q){this.set(s,q[s])}}},transform:function(i){i.globalAlpha=this.opacity;i.translate(this.left,this.top);i.rotate(this.theta);i.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var i={type:this.type,left:c(this.left,this.NUM_FRACTION_DIGITS),top:c(this.top,this.NUM_FRACTION_DIGITS),width:c(this.width,this.NUM_FRACTION_DIGITS),height:c(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:c(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:c(this.scaleY,this.NUM_FRACTION_DIGITS),angle:c(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:c(this.opacity,this.NUM_FRACTION_DIGITS),selectable:this.selectable};if(!this.includeDefaultValues){i=this._removeDefaultValues(i)}return i},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(q){var i=d.Object.prototype.options;if(i){this.stateProperties.forEach(function(r){if(q[r]===i[r]){delete q[r]}})}return q},isActive:function(){return !!this.active},setActive:function(i){this.active=!!i;return this},toString:function(){return"#<fabric."+k(this.type)+">"},set:function(q,i){var s=(q==="scaleX"||q==="scaleY")&&i<this.MIN_SCALE_LIMIT;if(s){i=this.MIN_SCALE_LIMIT}if(typeof q=="object"){for(var r in q){this.set(r,q[r])}}else{if(q==="angle"){this.setAngle(i)}else{this[q]=i}}return this},toggle:function(q){var i=this.get(q);if(typeof i==="boolean"){this.set(q,!i)}return this},setSourcePath:function(i){this.sourcePath=i;return this},get:function(i){return(i==="angle")?this.getAngle():this[i]},render:function(q,r){if(this.width===0||this.height===0){return}q.save();var i=this.transformMatrix;if(i){q.setTransform(i[0],i[1],i[2],i[3],i[4],i[5])}if(!r){this.transform(q)}if(this.stroke){q.lineWidth=this.strokeWidth;q.strokeStyle=this.stroke}if(this.overlayFill){q.fillStyle=this.overlayFill}else{if(this.fill){q.fillStyle=this.fill}}if(this.group){q.translate(-this.group.width/2+this.width/2,-this.group.height/2+this.height/2)}this._render(q,r);if(this.active&&!r){this.drawBorders(q);this.hideCorners||this.drawCorners(q)}q.restore()},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},scale:function(i){this.scaleX=i;this.scaleY=i;return this},scaleToWidth:function(i){return this.scale(i/this.width)},scaleToHeight:function(i){return this.scale(i/this.height)},setOpacity:function(i){this.set("opacity",i);return this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(i){this.theta=i/180*Math.PI;this.angle=i;return this},setCoords:function(){this.currentWidth=this.width*this.scaleX;this.currentHeight=this.height*this.scaleY;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var v=Math.cos(this._angle+this.theta)*this._hypotenuse,u=Math.sin(this._angle+this.theta)*this._hypotenuse,r=this.theta,y=Math.sin(r),w=Math.cos(r);var B={x:this.left-v,y:this.top-u};var x={x:B.x+(this.currentWidth*w),y:B.y+(this.currentWidth*y)};var A={x:x.x-(this.currentHeight*y),y:x.y+(this.currentHeight*w)};var s={x:B.x-(this.currentHeight*y),y:B.y+(this.currentHeight*w)};var t={x:B.x-(this.currentHeight/2*y),y:B.y+(this.currentHeight/2*w)};var i={x:B.x+(this.currentWidth/2*w),y:B.y+(this.currentWidth/2*y)};var q={x:x.x-(this.currentHeight/2*y),y:x.y+(this.currentHeight/2*w)};var z={x:s.x+(this.currentWidth/2*w),y:s.y+(this.currentWidth/2*y)};this.oCoords={tl:B,tr:x,br:A,bl:s,ml:t,mt:i,mr:q,mb:z};this._setCornerCoords();return this},drawBorders:function(q){if(!this.hasBorders){return}var v=this.padding,s=v*2;q.save();q.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;q.strokeStyle=this.borderColor;var t=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX),r=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);q.lineWidth=1/this.borderScaleFactor;q.scale(t,r);var i=this.getWidth(),u=this.getHeight();q.strokeRect(~~(-(i/2)-v)+0.5,~~(-(u/2)-v)+0.5,~~(i+s),~~(u+s));q.restore();return this},drawCorners:function(B){if(!this.hasControls){return}var D=this.cornersize,y=D/2,x=this.padding,r=-(this.width/2),w=-(this.height/2),C,A,q=D/this.scaleX,i=D/this.scaleY,s=(x+y)/this.scaleY,t=(x+y)/this.scaleX,v=(x+y-D)/this.scaleX,u=(x+y-D)/this.scaleY,z=this.height;B.save();B.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;B.fillStyle=this.cornerColor;C=r-t;A=w-s;B.fillRect(C,A,q,i);C=r+this.width-t;A=w-s;B.fillRect(C,A,q,i);C=r-t;A=w+z+u;B.fillRect(C,A,q,i);C=r+this.width+v;A=w+z+u;B.fillRect(C,A,q,i);C=r+this.width/2-t;A=w-s;B.fillRect(C,A,q,i);C=r+this.width/2-t;A=w+z+u;B.fillRect(C,A,q,i);C=r+this.width+v;A=w+z/2-s;B.fillRect(C,A,q,i);C=r-t;A=w+z/2-s;B.fillRect(C,A,q,i);B.restore();return this},clone:function(i){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(),i)}return new d.Object(this.toObject())},cloneAsImage:function(s){if(d.Image){var q=new Image();q.onload=function(){if(s){s(new d.Image(q),r)}q=q.onload=null};var r={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);q.src=this.toDataURL()}return this},toDataURL:function(){var q=d.document.createElement("canvas");q.width=this.getWidth();q.height=this.getHeight();d.util.wrapElement(q,"div");var i=new d.Canvas(q);i.backgroundColor="transparent";i.renderAll();var s=this.clone();s.left=q.width/2;s.top=q.height/2;s.setActive(false);i.add(s);var r=i.toDataURL("png");i.dispose();i=s=null;return r},hasStateChanged:function(){return this.stateProperties.some(function(i){return this[i]!==this.originalState[i]},this)},saveState:function(){this.stateProperties.forEach(function(i){this.originalState[i]=this.get(i)},this);return this},setupState:function(){this.originalState={};this.saveState()},intersectsWithRect:function(r,t){var w=this.oCoords,i=new d.Point(w.tl.x,w.tl.y),s=new d.Point(w.tr.x,w.tr.y),v=new d.Point(w.bl.x,w.bl.y),q=new d.Point(w.br.x,w.br.y);var u=d.Intersection.intersectPolygonRectangle([i,s,q,v],r,t);return(u.status==="Intersection")},intersectsWithObject:function(i){function q(u){return{tl:new d.Point(u.tl.x,u.tl.y),tr:new d.Point(u.tr.x,u.tr.y),bl:new d.Point(u.bl.x,u.bl.y),br:new d.Point(u.br.x,u.br.y)}}var r=q(this.oCoords),t=q(i.oCoords);var s=d.Intersection.intersectPolygonPolygon([r.tl,r.tr,r.br,r.bl],[t.tl,t.tr,t.br,t.bl]);return(s.status==="Intersection")},isContainedWithinObject:function(i){return this.isContainedWithinRect(i.oCoords.tl,i.oCoords.br)},isContainedWithinRect:function(r,t){var v=this.oCoords,i=new d.Point(v.tl.x,v.tl.y),s=new d.Point(v.tr.x,v.tr.y),u=new d.Point(v.bl.x,v.bl.y),q=new d.Point(v.br.x,v.br.y);return i.x>r.x&&s.x<t.x&&i.y>r.y&&u.y<t.y},isType:function(i){return this.type===i},_findTargetCorner:function(v,x){if(!this.hasControls){return false}var w=p(v),u=w.x-x.left,r=w.y-x.top,t,q;for(var s in this.oCoords){q=this._getImageLines(this.oCoords[s].corner,s);t=this._findCrossPoints(u,r,q);if(t%2==1&&t!=0){this.__corner=s;return s}}return false},_findCrossPoints:function(w,v,i){var z,y,r,q,x,u,t=0,s;for(var A in i){s=i[A];if((s.o.y<v)&&(s.d.y<v)){continue}if((s.o.y>=v)&&(s.d.y>=v)){continue}if((s.o.x==s.d.x)&&(s.o.x>=w)){x=s.o.x;u=v}else{z=0;y=(s.d.y-s.o.y)/(s.d.x-s.o.x);r=v-z*w;q=s.o.y-y*s.o.x;x=-(r-q)/(z-y);u=r+z*x}if(x>=w){t+=1}if(t==2){break}}return t},_getImageLines:function(r,q){return{topline:{o:r.tl,d:r.tr},rightline:{o:r.tr,d:r.br},bottomline:{o:r.br,d:r.bl},leftline:{o:r.bl,d:r.tl}}},_setCornerCoords:function(){var t=this.oCoords,q=b(45-this.getAngle()),s=Math.sqrt(2*Math.pow(this.cornersize,2))/2,i=s*Math.cos(q),r=s*Math.sin(q);t.tl.corner={tl:{x:t.tl.x-r,y:t.tl.y-i},tr:{x:t.tl.x+i,y:t.tl.y-r},bl:{x:t.tl.x-i,y:t.tl.y+r},br:{x:t.tl.x+r,y:t.tl.y+i}};t.tr.corner={tl:{x:t.tr.x-r,y:t.tr.y-i},tr:{x:t.tr.x+i,y:t.tr.y-r},br:{x:t.tr.x+r,y:t.tr.y+i},bl:{x:t.tr.x-i,y:t.tr.y+r}};t.bl.corner={tl:{x:t.bl.x-r,y:t.bl.y-i},bl:{x:t.bl.x-i,y:t.bl.y+r},br:{x:t.bl.x+r,y:t.bl.y+i},tr:{x:t.bl.x+i,y:t.bl.y-r}};t.br.corner={tr:{x:t.br.x+i,y:t.br.y-r},bl:{x:t.br.x-i,y:t.br.y+r},br:{x:t.br.x+r,y:t.br.y+i},tl:{x:t.br.x-r,y:t.br.y-i}};t.ml.corner={tl:{x:t.ml.x-r,y:t.ml.y-i},tr:{x:t.ml.x+i,y:t.ml.y-r},bl:{x:t.ml.x-i,y:t.ml.y+r},br:{x:t.ml.x+r,y:t.ml.y+i}};t.mt.corner={tl:{x:t.mt.x-r,y:t.mt.y-i},tr:{x:t.mt.x+i,y:t.mt.y-r},bl:{x:t.mt.x-i,y:t.mt.y+r},br:{x:t.mt.x+r,y:t.mt.y+i}};t.mr.corner={tl:{x:t.mr.x-r,y:t.mr.y-i},tr:{x:t.mr.x+i,y:t.mr.y-r},bl:{x:t.mr.x-i,y:t.mr.y+r},br:{x:t.mr.x+r,y:t.mr.y+i}};t.mb.corner={tl:{x:t.mb.x-r,y:t.mb.y-i},tr:{x:t.mb.x+i,y:t.mb.y-r},bl:{x:t.mb.x-i,y:t.mb.y+r},br:{x:t.mb.x+r,y:t.mb.y+i}}},toGrayscale:function(){var i=this.get("fill");if(i){this.set("overlayFill",new d.Color(i).toGrayscale().toRgb())}return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){var i=this._getAngleValueForStraighten();this.setAngle(i);return this},fxStraighten:function(q){q=q||{};var r=function(){},s=q.onComplete||r,i=q.onChange||r,t=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(u){t.setAngle(u);i()},onComplete:function(){t.setCoords();s()},onStart:function(){t.setActive(false)}});return this},fxRemove:function(q){q||(q={});var r=function(){},s=q.onComplete||r,i=q.onChange||r,t=this;d.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(u){t.set("opacity",u);i()},onComplete:s,onStart:function(){t.setActive(false)}});return this},_getAngleValueForStraighten:function(){var i=this.get("angle");if(i>-225&&i<=-135){return -180}else{if(i>-135&&i<=-45){return -90}else{if(i>-45&&i<=45){return 0}else{if(i>45&&i<=135){return 90}else{if(i>135&&i<=225){return 180}else{if(i>225&&i<=315){return 270}else{if(i>315){return 360}}}}}}}return 0},toJSON:function(){return this.toObject()},setGradientFill:function(i,q){this.set("fill",d.Gradient.forObject(this,i,q))},animate:function(q,s,i){var r=this;if(!("from" in i)){i.from=this.get(q)}if(/[+-]/.test(s.charAt(0))){s=this.get(q)+parseFloat(s)}d.util.animate({startValue:i.from,endValue:s,duration:i.duration,onChange:function(t){r.set(q,t);i.onChange&&i.onChange()},onComplete:function(){r.setCoords();i.onComplete&&i.onComplete()}})}});d.Object.prototype.rotate=d.Object.prototype.setAngle;var j=d.Object.prototype;for(var g=j.stateProperties.length;g--;){var h=j.stateProperties[g],e=h.charAt(0).toUpperCase()+h.slice(1),f="set"+e,n="get"+e;if(!j[n]){j[n]=(function(i){return new Function('return this.get("'+i+'")')})(h)}if(!j[f]){j[f]=(function(i){return new Function("value",'return this.set("'+i+'", value)')})(h)}}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),c=b.util.object.extend;if(b.Line){b.warn("fabric.Line is already defined");return}b.Line=b.util.createClass(b.Object,{type:"line",initialize:function(e,d){if(!e){e=[0,0,0,0]}this.callSuper("initialize",d);this.set("x1",e[0]);this.set("y1",e[1]);this.set("x2",e[2]);this.set("y2",e[3]);this.set("width",(this.x2-this.x1)||1);this.set("height",(this.y2-this.y1)||1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(d){d.beginPath();d.moveTo(-this.width/2,-this.height/2);d.lineTo(this.width/2,this.height/2);d.lineWidth=this.strokeWidth;var e=d.strokeStyle;d.strokeStyle=d.fillStyle;d.stroke();d.strokeStyle=e},complexity:function(){return 1},toObject:function(){return c(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});b.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");b.Line.fromElement=function(e,d){var g=b.parseAttributes(e,b.Line.ATTRIBUTE_NAMES);var f=[g.x1||0,g.y1||0,g.x2||0,g.y2||0];return new b.Line(f,c(g,d))};b.Line.fromObject=function(d){var e=[d.x1,d.y1,d.x2,d.y2];return new b.Line(e,d)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),d=Math.PI*2,e=b.util.object.extend;if(b.Circle){b.warn("fabric.Circle is already defined.");return}b.Circle=b.util.createClass(b.Object,{type:"circle",initialize:function(f){f=f||{};this.set("radius",f.radius||0);this.callSuper("initialize",f);var g=this.get("radius")*2*this.get("scaleX");this.set("width",g).set("height",g)},toObject:function(){return e(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(f,g){f.beginPath();f.globalAlpha*=this.opacity;f.arc(g?this.left:0,g?this.top:0,this.radius,0,d,false);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},complexity:function(){return 1}});b.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Circle.fromElement=function(g,f){f||(f={});var h=b.parseAttributes(g,b.Circle.ATTRIBUTE_NAMES);if(!c(h)){throw Error("value of `r` attribute is required and can not be negative")}if("left" in h){h.left-=(f.width/2)||0}if("top" in h){h.top-=(f.height/2)||0}return new b.Circle(e(h,f))};function c(f){return(("radius" in f)&&(f.radius>0))}b.Circle.fromObject=function(f){return new b.Circle(f)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Triangle){b.warn("fabric.Triangle is already defined");return}b.Triangle=b.util.createClass(b.Object,{type:"triangle",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("width",c.width||100).set("height",c.height||100)},_render:function(c){var d=this.width/2,e=this.height/2;c.beginPath();c.moveTo(-d,e);c.lineTo(0,-e);c.lineTo(d,e);c.closePath();if(this.fill){c.fill()}if(this.stroke){c.stroke()}},complexity:function(){return 1}});b.Triangle.fromObject=function(c){return new b.Triangle(c)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),c=Math.PI*2,d=b.util.object.extend;if(b.Ellipse){b.warn("fabric.Ellipse is already defined.");return}b.Ellipse=b.util.createClass(b.Object,{type:"ellipse",initialize:function(e){e=e||{};this.callSuper("initialize",e);this.set("rx",e.rx||0);this.set("ry",e.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return d(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(e,f){if(this.rx===0||this.ry===0){return}return this.callSuper("render",e,f)},_render:function(e,f){e.beginPath();e.save();e.globalAlpha*=this.opacity;e.transform(1,0,0,this.ry/this.rx,0,0);e.arc(f?this.left:0,f?this.top:0,this.rx,0,c,false);if(this.stroke){e.stroke()}if(this.fill){e.fill()}e.restore()},complexity:function(){return 1}});b.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Ellipse.fromElement=function(f,e){e||(e={});var g=b.parseAttributes(f,b.Ellipse.ATTRIBUTE_NAMES);if("left" in g){g.left-=(e.width/2)||0}if("top" in g){g.top-=(e.height/2)||0}return new b.Ellipse(d(g,e))};b.Ellipse.fromObject=function(e){return new b.Ellipse(e)}})(typeof exports!="undefined"?exports:this);(function(b){var c=b.fabric||(b.fabric={});if(c.Rect){console.warn("fabric.Rect is already defined");return}c.Rect=c.util.createClass(c.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(d){this._initStateProperties();this.callSuper("initialize",d);this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else{if(this.ry&&!this.rx){this.rx=this.ry}}},_render:function(f){var j=this.rx||0,i=this.ry||0,d=-this.width/2,k=-this.height/2,e=this.width,g=this.height;f.beginPath();f.globalAlpha*=this.opacity;if(this.group){f.translate(this.x,this.y)}f.moveTo(d+j,k);f.lineTo(d+e-j,k);f.bezierCurveTo(d+e,k,d+e,k+i,d+e,k+i);f.lineTo(d+e,k+g-i);f.bezierCurveTo(d+e,k+g,d+e-j,k+g,d+e-j,k+g);f.lineTo(d+j,k+g);f.bezierCurveTo(d,k+g,d,k+g-i,d,k+g-i);f.lineTo(d,k+i);f.bezierCurveTo(d,k,d+j,k,d+j,k);f.closePath();if(this.fill){f.fill()}if(this.stroke){f.stroke()}},_normalizeLeftTopProperties:function(d){if(d.left){this.set("left",d.left+this.getWidth()/2)}this.set("x",d.left||0);if(d.top){this.set("top",d.top+this.getHeight()/2)}this.set("y",d.top||0);return this},complexity:function(){return 1}});c.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" ");function a(d){d.left=d.left||0;d.top=d.top||0;return d}c.Rect.fromElement=function(e,d){if(!e){return null}var g=c.parseAttributes(e,c.Rect.ATTRIBUTE_NAMES);g=a(g);var f=new c.Rect(c.util.object.extend((d?c.util.object.clone(d):{}),g));f._normalizeLeftTopProperties(g);return f};c.Rect.fromObject=function(d){return new c.Rect(d)}})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={});if(b.Polyline){b.warn("fabric.Polyline is already defined");return}b.Polyline=b.util.createClass(b.Object,{type:"polyline",initialize:function(d,c){c=c||{};this.set("points",d);this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){return b.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return b.Polygon.prototype.toObject.call(this)},_render:function(e){var d;e.beginPath();for(var f=0,c=this.points.length;f<c;f++){d=this.points[f];e.lineTo(d.x,d.y)}if(this.fill){e.fill()}if(this.stroke){e.stroke()}},complexity:function(){return this.get("points").length}});b.Polyline.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" ");b.Polyline.fromElement=function(f,d){if(!f){return null}d||(d={});var g=b.parsePointsAttribute(f.getAttribute("points")),h=b.parseAttributes(f,b.Polyline.ATTRIBUTE_NAMES);for(var e=0,c=g.length;e<c;e++){g[e].x-=(d.width/2)||0;g[e].y-=(d.height/2)||0}return new b.Polyline(g,b.util.object.extend(h,d))};b.Polyline.fromObject=function(c){var d=c.points;return new b.Polyline(d,c)}})(typeof exports!="undefined"?exports:this);(function(e){var f=e.fabric||(e.fabric={}),g=f.util.object.extend,d=f.util.array.min,a=f.util.array.max;if(f.Polygon){f.warn("fabric.Polygon is already defined");return}function c(h){return h.x}function b(h){return h.y}f.Polygon=f.util.createClass(f.Object,{type:"polygon",initialize:function(i,h){h=h||{};this.points=i;this.callSuper("initialize",h);this._calcDimensions()},_calcDimensions:function(){var i=this.points,h=d(i,"x"),l=d(i,"y"),k=a(i,"x"),j=a(i,"y");this.width=k-h;this.height=j-l;this.minX=h;this.minY=l},toObject:function(){return g(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(k){var j;k.beginPath();for(var l=0,h=this.points.length;l<h;l++){j=this.points[l];k.lineTo(j.x,j.y)}if(this.fill){k.fill()}if(this.stroke){k.closePath();k.stroke()}},complexity:function(){return this.points.length}});f.Polygon.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" ");f.Polygon.fromElement=function(l,j){if(!l){return null}j||(j={});var m=f.parsePointsAttribute(l.getAttribute("points")),n=f.parseAttributes(l,f.Polygon.ATTRIBUTE_NAMES);for(var k=0,h=m.length;k<h;k++){m[k].x-=(j.width/2)||0;m[k].y-=(j.height/2)||0}return new f.Polygon(m,g(n,j))};f.Polygon.fromObject=function(h){return new f.Polygon(h.points,h)}})(typeof exports!="undefined"?exports:this);(function(a){var l={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7};function k(F,B,z,A){var s=A[0];var q=A[1];var t=A[2];var D=A[3];var E=A[4];var w=A[5];var v=A[6];var r=i(w,v,s,q,D,E,t,B,z);for(var u=0;u<r.length;u++){var C=f.apply(this,r[u]);F.bezierCurveTo.apply(F,C)}}var b={},p={},o=Array.prototype.join,j;function i(T,S,O,N,J,P,G,M,L){j=o.call(arguments);if(b[j]){return b[j]}var r=G*(Math.PI/180);var W=Math.sin(r);var aa=Math.cos(r);O=Math.abs(O);N=Math.abs(N);var A=aa*(M-T)*0.5+W*(L-S)*0.5;var z=aa*(L-S)*0.5-W*(M-T)*0.5;var E=(A*A)/(O*O)+(z*z)/(N*N);if(E>1){E=Math.sqrt(E);O*=E;N*=E}var R=aa/O;var Q=W/O;var D=(-W)/N;var C=(aa)/N;var H=R*M+Q*L;var q=D*M+C*L;var F=R*T+Q*S;var ab=D*T+C*S;var Z=(F-H)*(F-H)+(ab-q)*(ab-q);var U=1/Z-0.25;if(U<0){U=0}var w=Math.sqrt(U);if(P==J){w=-w}var V=0.5*(H+F)-w*(ab-q);var K=0.5*(q+ab)+w*(F-H);var v=Math.atan2(q-K,H-V);var u=Math.atan2(ab-K,F-V);var Y=u-v;if(Y<0&&P==1){Y+=2*Math.PI}else{if(Y>0&&P==0){Y-=2*Math.PI}}var B=Math.ceil(Math.abs(Y/(Math.PI*0.5+0.001)));var I=[];for(var X=0;X<B;X++){var t=v+X*Y/B;var s=v+(X+1)*Y/B;I[X]=[V,K,t,s,O,N,W,aa]}return(b[j]=I)}function f(w,s,E,C,y,x,u,D){j=o.call(arguments);if(p[j]){return p[j]}var K=D*y;var J=-u*x;var A=u*y;var z=D*x;var F=0.5*(C-E);var B=(8/3)*Math.sin(F*0.5)*Math.sin(F*0.5)/Math.sin(F);var I=w+Math.cos(E)-B*Math.sin(E);var v=s+Math.sin(E)+B*Math.cos(E);var G=w+Math.cos(C);var q=s+Math.sin(C);var H=G+B*Math.sin(C);var r=q-B*Math.cos(C);return(p[j]=[K*I+J*v,A*I+z*v,K*H+J*r,A*H+z*r,K*G+J*q,A*G+z*q])}"use strict";var d=a.fabric||(a.fabric={}),e=d.util.array.min,h=d.util.array.max,g=d.util.object.extend,c=Object.prototype.toString;if(d.Path){d.warn("fabric.Path is already defined");return}if(!d.Object){d.warn("fabric.Path requires fabric.Object");return}function n(q){if(q[0]==="H"){return q[1]}return q[q.length-2]}function m(q){if(q[0]==="V"){return q[1]}return q[q.length-1]}d.Path=d.util.createClass(d.Object,{type:"path",initialize:function(s,r){r=r||{};this.setOptions(r);if(!s){throw Error("`path` argument is required")}var q=c.call(s)==="[object Array]";this.path=q?s:s.match&&s.match(/[a-zA-Z][^a-zA-Z]*/g);if(!this.path){return}if(!q){this._initializeFromArray(r)}if(r.sourcePath){this.setSourcePath(r.sourcePath)}},_initializeFromArray:function(r){var q="width" in r,s="height" in r;this.path=this._parsePath();if(!q||!s){g(this,this._parseDimensions());if(q){this.width=r.width}if(s){this.height=r.height}}},_render:function(D){var z,B=0,A=0,q=0,E=0,v,u,r=-(this.width/2),C=-(this.height/2);for(var s=0,w=this.path.length;s<w;++s){z=this.path[s];switch(z[0]){case"l":B+=z[1];A+=z[2];D.lineTo(B+r,A+C);break;case"L":B=z[1];A=z[2];D.lineTo(B+r,A+C);break;case"h":B+=z[1];D.lineTo(B+r,A+C);break;case"H":B=z[1];D.lineTo(B+r,A+C);break;case"v":A+=z[1];D.lineTo(B+r,A+C);break;case"V":A=z[1];D.lineTo(B+r,A+C);break;case"m":B+=z[1];A+=z[2];D.moveTo(B+r,A+C);break;case"M":B=z[1];A=z[2];D.moveTo(B+r,A+C);break;case"c":v=B+z[5];u=A+z[6];q=B+z[3];E=A+z[4];D.bezierCurveTo(B+z[1]+r,A+z[2]+C,q+r,E+C,v+r,u+C);B=v;A=u;break;case"C":B=z[5];A=z[6];q=z[3];E=z[4];D.bezierCurveTo(z[1]+r,z[2]+C,q+r,E+C,B+r,A+C);break;case"s":v=B+z[3];u=A+z[4];q=2*B-q;E=2*A-E;D.bezierCurveTo(q+r,E+C,B+z[1]+r,A+z[2]+C,v+r,u+C);B=v;A=u;break;case"S":v=z[3];u=z[4];q=2*B-q;E=2*A-E;D.bezierCurveTo(q+r,E+C,z[1]+r,z[2]+C,v+r,u+C);B=v;A=u;break;case"q":B+=z[3];A+=z[4];D.quadraticCurveTo(z[1]+r,z[2]+C,B+r,A+C);break;case"Q":B=z[3];A=z[4];q=z[1];E=z[2];D.quadraticCurveTo(q+r,E+C,B+r,A+C);break;case"T":v=B;u=A;B=z[1];A=z[2];q=-q+2*v;E=-E+2*u;D.quadraticCurveTo(q+r,E+C,B+r,A+C);break;case"a":k(D,B+r,A+C,[z[1],z[2],z[3],z[4],z[5],z[6]+B+r,z[7]+A+C]);B+=z[6];A+=z[7];break;case"A":k(D,B+r,A+C,[z[1],z[2],z[3],z[4],z[5],z[6]+r,z[7]+C]);B=z[6];A=z[7];break;case"z":case"Z":D.closePath();break}}},render:function(r,s){r.save();var q=this.transformMatrix;if(q){r.transform(q[0],q[1],q[2],q[3],q[4],q[5])}if(!s){this.transform(r)}if(this.overlayFill){r.fillStyle=this.overlayFill}else{if(this.fill){r.fillStyle=this.fill}}if(this.stroke){r.strokeStyle=this.stroke}r.beginPath();this._render(r);if(this.fill){r.fill()}if(this.stroke){r.strokeStyle=this.stroke;r.lineWidth=this.strokeWidth;r.lineCap=r.lineJoin="round";r.stroke()}if(!s&&this.active){this.drawBorders(r);this.hideCorners||this.drawCorners(r)}r.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(){var q=g(this.callSuper("toObject"),{path:this.path});if(this.sourcePath){q.sourcePath=this.sourcePath}if(this.transformMatrix){q.transformMatrix=this.transformMatrix}return q},toDatalessObject:function(){var q=this.toObject();if(this.sourcePath){q.path=this.sourcePath}delete q.sourcePath;return q},complexity:function(){return this.path.length},_parsePath:function(){var C=[],z,v,y;for(var u=0,t,q,w=this.path.length;u<w;u++){z=this.path[u];v=z.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);q=[z.charAt(0)];for(var t=0,A=v.length;t<A;t++){y=parseFloat(v[t]);if(!isNaN(y)){q.push(y)}}var s=q[0].toLowerCase(),B=l[s];if(q.length-1>B){for(var r=1,x=q.length;r<x;r+=B){C.push([s].concat(q.slice(r,r+B)))}}else{C.push(q)}}return C},_parseDimensions:function(){var z=[],v=[],A,w,B=false,D,C;this.path.forEach(function(y,x){if(y[0]!=="H"){A=(x===0)?n(y):n(this.path[x-1])}if(y[0]!=="V"){w=(x===0)?m(y):m(this.path[x-1])}if(y[0]===y[0].toLowerCase()){B=true}D=B?A+n(y):y[0]==="V"?A:n(y);C=B?w+m(y):y[0]==="H"?w:m(y);var E=parseInt(D,10);if(!isNaN(E)){z.push(E)}E=parseInt(C,10);if(!isNaN(E)){v.push(E)}},this);var s=e(z),r=e(v),u=0,t=0;var q={top:r-t,left:s-u,bottom:h(v)-t,right:h(z)-u};q.width=q.right-q.left;q.height=q.bottom-q.top;return q}});d.Path.fromObject=function(q){return new d.Path(q.path,q)};d.Path.ATTRIBUTE_NAMES="d fill fill-opacity opacity fill-rule stroke stroke-width transform".split(" ");d.Path.fromElement=function(r,q){var s=d.parseAttributes(r,d.Path.ATTRIBUTE_NAMES);return new d.Path(s.d,g(s,q))}})(typeof exports!="undefined"?exports:this);(function(a){var d=a.fabric||(a.fabric={}),h=d.util.object.extend,f=d.util.array.invoke,i=d.Object.prototype.set,e=d.Object.prototype.toObject,b=d.util.string.camelize,g=d.util.string.capitalize;if(d.PathGroup){d.warn("fabric.PathGroup is already defined");return}d.PathGroup=d.util.createClass(d.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(l,j){j=j||{};this.paths=l;for(var k=this.paths.length;k--;){this.paths[k].group=this}this.setOptions(j);this.setCoords();if(j.sourcePath){this.setSourcePath(j.sourcePath)}},render:function(n){if(this.stub){n.save();this.transform(n);this.stub.render(n,false);if(this.active){this.drawBorders(n);this.drawCorners(n)}n.restore()}else{n.save();var j=this.transformMatrix;if(j){n.transform(j[0],j[1],j[2],j[3],j[4],j[5])}this.transform(n);for(var o=0,k=this.paths.length;o<k;++o){this.paths[o].render(n,true)}if(this.active){this.drawBorders(n);this.hideCorners||this.drawCorners(n)}n.restore()}},set:function(l,k){if((l==="fill"||l==="overlayFill")&&this.isSameColor()){this[l]=k;var j=this.paths.length;while(j--){this.paths[j].set(l,k)}}else{i.call(this,l,k)}return this},toObject:function(){return h(e.call(this),{paths:f(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var j=this.toObject();if(this.sourcePath){j.paths=this.sourcePath}return j},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var j=this.getObjects()[0].get("fill");return this.getObjects().every(function(k){return k.get("fill")===j})},complexity:function(){return this.paths.reduce(function(j,k){return j+((k&&k.complexity)?k.complexity():0)},0)},toGrayscale:function(){var j=this.paths.length;while(j--){this.paths[j].toGrayscale()}return this},getObjects:function(){return this.paths}});function c(m){for(var l=0,j=m.length;l<j;l++){if(!(m[l] instanceof d.Object)){var k=b(g(m[l].type));m[l]=d[k].fromObject(m[l])}}return m}d.PathGroup.fromObject=function(j){var k=c(j.paths);return new d.PathGroup(k,j)}})(typeof exports!="undefined"?exports:this);(function(d){var e=d.fabric||(d.fabric={}),g=e.util.object.extend,c=e.util.array.min,a=e.util.array.max,b=e.util.array.invoke,f=e.util.removeFromArray;if(e.Group){return}e.Group=e.util.createClass(e.Object,{type:"group",initialize:function(i,h){this.objects=i||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();if(h){g(this,h)}this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var i=this.left,h=this.top;this.forEachObject(function(j){var k=j.get("left"),l=j.get("top");j.set("originalLeft",k);j.set("originalTop",l);j.set("left",k-i);j.set("top",l-h);j.setCoords();j.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(h){this._restoreObjectsState();this.objects.push(h);h.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(h){this._restoreObjectsState();f(this.objects,h);h.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(h,k){if(typeof k=="function"){this.set(h,k(this[h]))}else{if(h==="fill"||h==="opacity"){var j=this.objects.length;this[h]=k;while(j--){this.objects[j].set(h,k)}}else{this[h]=k}}return this},contains:function(h){return this.objects.indexOf(h)>-1},toObject:function(){return g(this.callSuper("toObject"),{objects:b(this.objects,"clone")})},render:function(j){j.save();this.transform(j);var n=Math.max(this.scaleX,this.scaleY);for(var l=0,h=this.objects.length,k;k=this.objects[l];l++){var m=k.borderScaleFactor;k.borderScaleFactor=n;k.render(j);k.borderScaleFactor=m}this.hideBorders||this.drawBorders(j);this.hideCorners||this.drawCorners(j);j.restore();this.setCoords()},item:function(h){return this.getObjects()[h]},complexity:function(){return this.getObjects().reduce(function(i,h){i+=(typeof h.complexity=="function")?h.complexity():0;return i},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(j){var l=this.get("left"),m=this.get("top"),h=this.getAngle()*(Math.PI/180),k=j.get("originalLeft"),n=j.get("originalTop"),i=Math.cos(h)*j.get("top")+Math.sin(h)*j.get("left"),o=-Math.sin(h)*j.get("top")+Math.cos(h)*j.get("left");j.setAngle(j.getAngle()+this.getAngle());j.set("left",l+o*this.get("scaleX"));j.set("top",m+i*this.get("scaleY"));j.set("scaleX",j.get("scaleX")*this.get("scaleX"));j.set("scaleY",j.get("scaleY")*this.get("scaleY"));j.setCoords();j.hideCorners=false;j.setActive(false);j.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(h){h.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(h){this.forEachObject(function(i){i.setActive(h)});return this},forEachObject:e.Canvas.prototype.forEachObject,_setOpacityIfSame:function(){var j=this.getObjects(),i=j[0]?j[0].get("opacity"):1;var h=j.every(function(k){return k.get("opacity")===i});if(h){this.opacity=i}},_calcBounds:function(){var s=[],q=[],p,n,k,h,m,l,u,r=0,t=this.objects.length;for(;r<t;++r){m=this.objects[r];m.setCoords();for(var j in m.oCoords){s.push(m.oCoords[j].x);q.push(m.oCoords[j].y)}}p=c(s);k=a(s);n=c(q);h=a(q);l=k-p;u=h-n;this.width=l;this.height=u;this.left=p+l/2;this.top=n+u/2},containsPoint:function(i){var l=this.get("width")/2,h=this.get("height")/2,k=this.get("left"),j=this.get("top");return k-l<i.x&&k+l>i.x&&j-h<i.y&&j+h>i.y},toGrayscale:function(){var h=this.objects.length;while(h--){this.objects[h].toGrayscale()}}});e.Group.fromObject=function(h){return new e.Group(h.objects,h)}})(typeof exports!="undefined"?exports:this);(function(a){var b=fabric.util.object.extend;if(!a.fabric){a.fabric={}}if(a.fabric.Image){fabric.warn("fabric.Image is already defined.");return}if(!fabric.Object){fabric.warn("fabric.Object is required for fabric.Image initialization");return}fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(d,c){this.callSuper("initialize",c);this._initElement(d);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(c){this._element=c;return this},getNormalizedSize:function(d,c,e){if(e&&c&&(d.width>d.height&&(d.width/d.height)<(c/e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(e&&((d.height==d.width)||(d.height>d.width)||(d.height>e))){normalizedWidth=~~((d.width*e)/d.height);normalizedHeight=e}else{if(c&&(c<d.width)){normalizedHeight=~~((d.height*c)/d.width);normalizedWidth=c}else{normalizedWidth=d.width;normalizedHeight=d.height}}}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var c=this.getElement();return{width:c.width,height:c.height}},setBorderVisibility:function(c){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(c){this.cornervisibility=!!c},render:function(c,d){c.save();if(!d){this.transform(c)}this._render(c);if(this.active&&!d){this.drawBorders(c);this.hideCorners||this.drawCorners(c)}c.restore()},toObject:function(){return b(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},toGrayscale:function(g){if(this.__isGrayscaled){return}var e=this.getElement(),c=fabric.document.createElement("canvas"),d=fabric.document.createElement("img"),f=this;c.width=e.width;c.height=e.height;c.getContext("2d").drawImage(e,0,0);fabric.Canvas.toGrayscale(c);d.onload=function(){f.setElement(d);g&&g();d.onload=c=e=imageData=null};d.width=e.width;d.height=e.height;d.src=c.toDataURL("image/png");this.__isGrayscaled=true;return this},_render:function(d){var c=this.getOriginalSize();d.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.height)},_adjustWidthHeightToBorders:function(c){if(c){this.currentBorder=this.borderwidth;this.width+=(2*this.currentBorder);this.height+=(2*this.currentBorder)}else{this.currentBorder=0}},_resetWidthHeight:function(){var c=this.getElement();this.set("width",c.width);this.set("height",c.height)},_initElement:function(c){this.setElement(fabric.util.getById(c));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(c){this.setOptions(c);this._setBorder();this._setWidthHeight(c)},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(c){var d=2*this.currentBorder;this.width=(this.getElement().width||0)+d;this.height=(this.getElement().height||0)+d},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(d,f){var c=fabric.document.createElement("img"),e=d.src;if(d.width){c.width=d.width}if(d.height){c.height=d.height}c.onload=function(){if(f){f(new fabric.Image(c,d))}c=c.onload=null};c.src=e};fabric.Image.fromURL=function(d,f,e){var c=fabric.document.createElement("img");c.onload=function(){if(f){f(new fabric.Image(c,e))}c=c.onload=null};c.src=d};fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" ");fabric.Image.fromElement=function(d,f,c){c||(c={});var e=fabric.parseAttributes(d,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(e["xlink:href"],f,b(e,c))};fabric.Image.fromElement.async=true})(typeof exports!="undefined"?exports:this);(function(a){var b=a.fabric||(a.fabric={}),d=b.util.object.extend,c=b.util.object.clone;if(b.Text){b.warn("fabric.Text is already defined");return}if(!b.Object){b.warn("fabric.Text requires fabric.Object");return}b.Text=b.util.createClass(b.Object,{fontSize:20,fontWeight:100,fontFamily:"Times_New_Roman",textDecoration:"",textShadow:null,textAlign:"left",fontStyle:"",lineHeight:1.6,strokeStyle:"",strokeWidth:1,backgroundColor:"",path:null,type:"text",initialize:function(f,e){this._initStateProperties();this.text=f;this.setOptions(e);this.theta=this.angle*Math.PI/180;this.width=this.getWidth();this.setCoords()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat();this.stateProperties.push("fontFamily","fontWeight","path","text","textDecoration","textShadow","textAlign","fontStyle","lineHeight","strokeStyle","strokeWidth","backgroundColor");b.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_render:function(e){var g=Cufon.textOptions||(Cufon.textOptions={});g.left=this.left;g.top=this.top;g.context=e;g.color=this.fill;var f=this._initDummyElement();this.transform(e);Cufon.replaceElement(f,{separate:"none",fontFamily:this.fontFamily,enableTextDecoration:true,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor});this.width=g.width;this.height=g.height;this.setCoords()},_initDummyElement:function(){var f=b.document.createElement("div"),e=b.document.createElement("div");e.appendChild(f);f.innerHTML=this.text;f.style.fontSize="40px";f.style.fontWeight="400";f.style.letterSpacing="normal";f.style.color="#000000";f.style.fontWeight="600";f.style.fontFamily="Verdana";return f},render:function(e,f){e.save();this._render(e);if(!f&&this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toObject:function(){return d(this.callSuper("toObject"),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,path:this.path,strokeStyle:this.strokeStyle,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor})},setColor:function(e){this.set("fill",e);return this},setFontsize:function(e){this.set("fontSize",e);this.setCoords();return this},getText:function(){return this.text},setText:function(e){this.set("text",e);this.setCoords();return this},set:function(e,f){if(typeof e=="object"){for(var g in e){this.set(g,e[g])}}else{this[e]=f;if(e==="fontFamily"&&this.path){this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+f+"$3")}}return this}});b.Text.fromObject=function(e){return new b.Text(e.text,c(e))};b.Text.fromElement=function(e){}})(typeof exports!="undefined"?exports:this);(function(){if(typeof document!="undefined"&&typeof window!="undefined"){return}var d=require("o3-xml"),c=require("url"),h=require("http"),b=require("canvas"),f=require("canvas").Image;function g(j,l,n){var m=c.parse(j),i=h.createClient(80,m.hostname),k=i.request("GET",m.pathname,{host:m.hostname});k.end();k.on("response",function(p){var o="";if(l){p.setEncoding(l)}p.on("end",function(){n(o)});p.on("data",function(q){if(p.statusCode==200){o+=q}})})}fabric.Canvas.prototype.loadImageFromURL=function(i,j){g(i,"binary",function(k){var l=new f();l.src=new Buffer(k,"binary");j(new fabric.Image(l))})};fabric.loadSVGFromURL=function(i,j){i=i.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();g(i,"",function(k){var l=d.parseFromString(k);fabric.parseSVGDocument(l.documentElement,function(n,m){j(n,m)})})};fabric.Image.fromObject=function(i,j){fabric.Canvas.prototype.loadImageFromURL(i.src,function(k){k._initConfig(i);j(k)})};fabric.createCanvasForNode=function(k,i){var j=fabric.document.createElement("canvas"),m=new b(k||600,i||600);j.style={};j.width=m.width;j.height=m.height;var l=new fabric.Canvas(j);l.contextContainer=m.getContext("2d");l.nodeCanvas=m;return l};fabric.Canvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};var e=fabric.Canvas.prototype.setWidth;fabric.Canvas.prototype.setWidth=function(i){e.call(this);this.nodeCanvas.width=i;return this};var a=fabric.Canvas.prototype.setHeight;fabric.Canvas.prototype.setHeight=function(i){a.call(this);this.nodeCanvas.height=i;return this}})();