meme_captain 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,8 @@ module MemeCaptain
18
18
  last_metrics = metrics
19
19
  metrics = get_multiline_type_metrics(text)
20
20
 
21
- if metrics.width > width or metrics.height > height
21
+ if metrics.width + stroke_padding > width or
22
+ metrics.height + stroke_padding > height
22
23
  if current_pointsize > min_pointsize
23
24
  current_pointsize -= 1
24
25
  metrics = last_metrics
@@ -32,6 +33,22 @@ module MemeCaptain
32
33
  [current_pointsize, metrics]
33
34
  end
34
35
 
36
+ # Return the number of pixels of padding to account for this object's
37
+ # stroke width.
38
+ def stroke_padding
39
+ # Each side of the text needs stroke_width / 2 pixels of padding
40
+ # because half of the stroke goes inside the text and half goes
41
+ # outside. The / 2 and * 2 (each side) cancel.
42
+ @stroke_width.to_i
43
+ end
44
+
45
+ # Override and set instance variable because there is apparently no way to
46
+ # get the value of a Draw's current stroke width.
47
+ def stroke_width=(stroke_width)
48
+ @stroke_width = stroke_width
49
+ super
50
+ end
51
+
35
52
  end
36
53
 
37
54
  end
@@ -12,6 +12,8 @@ module MemeCaptain
12
12
 
13
13
  # Shrink image if necessary and add watermark.
14
14
  def prepare!(max_side, watermark_img)
15
+ auto_orient!
16
+
15
17
  if size == 1 and (columns > max_side or rows > max_side)
16
18
  resize_to_fit! max_side
17
19
  end
@@ -19,6 +19,8 @@ module MemeCaptain
19
19
  img.from_blob(input)
20
20
  end
21
21
 
22
+ img.auto_orient!
23
+
22
24
  super_sample = options[:super_sample] || 2.0
23
25
 
24
26
  text_layer = Magick::Image.new(
@@ -48,19 +50,17 @@ module MemeCaptain
48
50
 
49
51
  min_pointsize = text_pos.min_pointsize * super_sample
50
52
 
51
- draw = Magick::Draw.new {
52
- text_pos.draw_options.each do |k,v|
53
- # options that need to be scaled by super sample
54
- if [
55
- :stroke_width
56
- ].include?(k)
57
- v *= super_sample
58
- end
59
- self.send("#{k}=", v)
60
- end
61
- }
53
+ draw = Magick::Draw.new.extend(Draw)
62
54
 
63
- draw.extend Draw
55
+ text_pos.draw_options.each do |k,v|
56
+ # options that need to be scaled by super sample
57
+ if [
58
+ :stroke_width
59
+ ].include?(k)
60
+ v *= super_sample
61
+ end
62
+ draw.send("#{k}=", v)
63
+ end
64
64
 
65
65
  choices = wrap_tries.map do |wrap_try|
66
66
  pointsize, metrics = draw.calc_pointsize(text_width, text_height,
@@ -217,6 +217,14 @@ module MemeCaptain
217
217
  def serve_img(meme_data)
218
218
  meme_data.requested!
219
219
 
220
+ if meme_data.respond_to?(:texts)
221
+ meme_text = meme_data.texts.map do |text|
222
+ Rack::Utils.escape(text['text'])
223
+ end.join('&')
224
+
225
+ headers 'Meme-Text' => meme_text
226
+ end
227
+
220
228
  send_file meme_data.fs_path, :type => meme_data.mime_type
221
229
  end
222
230
 
@@ -1,3 +1,3 @@
1
1
  module MemeCaptain
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/meme_captain.gemspec CHANGED
@@ -6,7 +6,6 @@ require 'meme_captain/version'
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = 'meme_captain'
9
- s.version = '0.0.6'
10
9
  s.version = MemeCaptain::VERSION
11
10
  s.summary = 'create meme images'
12
11
  s.description = s.summary
@@ -1,7 +1,4 @@
1
- /* Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
2
- var fabric=fabric||{version:"0.7.11"};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()}fabric.isTouchSupported="ontouchstart" in fabric.document.documentElement;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")}}}());
3
- /*
4
- * Copyright (c) 2009 Simo Kinnunen.
5
- * Licensed under the MIT license.
6
- */
7
- 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={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(ab,E,W,A,J,ac){var n=(E===null);var H=ab.viewBox;var o=W.getSize("fontSize",ab.baseSize);var U=W.get("letterSpacing");U=(U=="normal")?0:o.convertFrom(parseInt(U,10));var I=0,V=0,T=0,C=0;var G=A.textShadow,R=[];Cufon.textOptions.shadowOffsets=[];Cufon.textOptions.shadows=null;if(G){Cufon.textOptions.shadows=G;for(var aa=0,X=G.length;aa<X;++aa){var N=G[aa];var Q=o.convertFrom(parseFloat(N.offX));var P=o.convertFrom(parseFloat(N.offY));R[aa]=[Q,P];if(P<I){I=P}if(Q>V){V=Q}if(P>T){T=P}if(Q<C){C=Q}}}var ag=Cufon.CSS.textTransform(n?J.alt:E,W).split("");var h=0,D=null;var z=0,M=1,L=[];for(var aa=0,X=ag.length;aa<X;++aa){if(ag[aa]==="\n"){M++;if(h>z){z=h}L.push(h);h=0;continue}var B=ab.glyphs[ag[aa]]||ab.missingGlyph;if(!B){continue}h+=D=Number(B.w||ab.w)+U}L.push(h);h=Math.max(z,h);var m=[];for(var aa=L.length;aa--;){m[aa]=h-L[aa]}if(D===null){return null}V+=(H.width-D);C+=H.minX;var v,p;if(n){v=J;p=J.firstChild}else{v=fabric.document.createElement("span");v.className="cufon cufon-canvas";v.alt=E;p=fabric.document.createElement("canvas");v.appendChild(p);if(A.printable){var Y=fabric.document.createElement("span");Y.className="cufon-alt";Y.appendChild(fabric.document.createTextNode(E));v.appendChild(Y)}}var ah=v.style;var O=p.style||{};var k=o.convert(H.height-I+T);var af=Math.ceil(k);var S=af/k;p.width=Math.ceil(o.convert(h+V-C)*S);p.height=af;I+=H.minY;O.top=Math.round(o.convert(I-ab.ascent))+"px";O.left=Math.round(o.convert(C))+"px";var j=Math.ceil(o.convert(h*S));var t=j+"px";var s=o.convert(ab.height);var F=(A.lineHeight-1)*o.convert(-ab.ascent/5)*(M-1);Cufon.textOptions.width=j;Cufon.textOptions.height=(s*M)+F;Cufon.textOptions.lines=M;Cufon.textOptions.totalLineHeight=F;if(a){ah.width=t;ah.height=s+"px"}else{ah.paddingLeft=t;ah.paddingBottom=(s-1)+"px"}var ad=Cufon.textOptions.context||p.getContext("2d"),K=af/H.height;Cufon.textOptions.fontAscent=ab.ascent*K;Cufon.textOptions.boundaries=null;for(var w=Cufon.textOptions.shadowOffsets,aa=R.length;aa--;){w[aa]=[R[aa][0]*K,R[aa][1]*K]}ad.save();ad.scale(K,K);ad.translate(-C-((1/K*p.width)/2)+(Cufon.fonts[ab.family].offsetLeft||0),-I-(Cufon.textOptions.height/K)/2);ad.lineWidth=ab.face["underline-thickness"];ad.save();function q(i,g){ad.strokeStyle=g;ad.beginPath();ad.moveTo(0,i);ad.lineTo(h,i);ad.stroke()}var r=Cufon.getTextDecoration(A),u=A.fontStyle==="italic";function ae(){ad.save();ad.fillStyle=A.backgroundColor;var ai=0,am=0,x=[{left:0}];if(A.textAlign==="right"){ad.translate(m[am],0);x[0].left=m[am]*K}else{if(A.textAlign==="center"){ad.translate(m[am]/2,0);x[0].left=m[am]/2*K}}for(var ak=0,aj=ag.length;ak<aj;++ak){if(ag[ak]==="\n"){am++;var al=-ab.ascent-((ab.ascent/5)*A.lineHeight);var g=x[x.length-1];var y={left:0};g.width=ai*K;g.height=(-ab.ascent+ab.descent)*K;if(A.textAlign==="right"){ad.translate(-h,al);ad.translate(m[am],0);y.left=m[am]*K}else{if(A.textAlign==="center"){ad.translate(-ai-(m[am-1]/2),al);ad.translate(m[am]/2,0);y.left=m[am]/2*K}else{ad.translate(-ai,al)}}x.push(y);ai=0;continue}var ao=ab.glyphs[ag[ak]]||ab.missingGlyph;if(!ao){continue}var an=Number(ao.w||ab.w)+U;if(A.backgroundColor){ad.save();ad.translate(0,ab.ascent);ad.fillRect(0,0,an+10,-ab.ascent+ab.descent);ad.restore()}ad.translate(an,0);ai+=an;if(ak==aj-1){x[x.length-1].width=ai*K;x[x.length-1].height=(-ab.ascent+ab.descent)*K}}ad.restore();Cufon.textOptions.boundaries=x}function Z(y){ad.fillStyle=y||Cufon.textOptions.color||W.get("color");var al=0,am=0;if(A.textAlign==="right"){ad.translate(m[am],0)}else{if(A.textAlign==="center"){ad.translate(m[am]/2,0)}}for(var aj=0,x=ag.length;aj<x;++aj){if(ag[aj]==="\n"){am++;var ai=-ab.ascent-((ab.ascent/5)*A.lineHeight);if(A.textAlign==="right"){ad.translate(-h,ai);ad.translate(m[am],0)}else{if(A.textAlign==="center"){ad.translate(-al-(m[am-1]/2),ai);ad.translate(m[am]/2,0)}else{ad.translate(-al,ai)}}al=0;continue}var ak=ab.glyphs[ag[aj]]||ab.missingGlyph;if(!ak){continue}var g=Number(ak.w||ab.w)+U;if(r){ad.save();ad.strokeStyle=ad.fillStyle;ad.lineWidth+=ad.lineWidth;ad.beginPath();if(r.underline){ad.moveTo(0,-ab.face["underline-position"]+0.5);ad.lineTo(g,-ab.face["underline-position"]+0.5)}if(r.overline){ad.moveTo(0,ab.ascent+0.5);ad.lineTo(g,ab.ascent+0.5)}if(r["line-through"]){ad.moveTo(0,-ab.descent+0.5);ad.lineTo(g,-ab.descent+0.5)}ad.stroke();ad.restore()}if(u){ad.save();ad.transform(1,0,-0.25,1,0,0)}ad.beginPath();if(ak.d){if(ak.code){c(ak.code,ad)}else{ak.code=d("m"+ak.d,ad)}}ad.fill();if(A.strokeStyle){ad.closePath();ad.save();ad.lineWidth=A.strokeWidth;ad.strokeStyle=A.strokeStyle;ad.stroke();ad.restore()}if(u){ad.restore()}ad.translate(g,0);al+=g}}if(G){for(var aa=0,X=G.length;aa<X;++aa){var N=G[aa];ad.save();ad.translate.apply(ad,R[aa]);Z(N.color);ad.restore()}}ad.save();ae();Z();ad.restore();ad.restore();ad.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=Cufon.getTextDecoration(w);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}})());Cufon.getTextDecoration=function(a){return{underline:a.textDecoration==="underline",overline:a.textDecoration==="overline","line-through":a.textDecoration==="line-through"}};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(l,k){var j=l.indexOf(k);if(j!==-1){l.splice(j,1)}return l}function e(k,j){return Math.floor(Math.random()*(j-k+1))+k}var f=Math.PI/180;function b(j){return j*f}function d(k,j){return parseFloat(Number(k).toFixed(j))}function i(){return false}function c(u){u||(u={});var k=+new Date(),m=u.duration||500,t=k+m,l,s,p=u.onChange||function(){},n=u.abort||function(){return false},q=u.easing||function(v){return(-Math.cos(v*Math.PI)/2)+0.5},j="startValue" in u?u.startValue:0,r="endValue" in u?u.endValue:100;u.onStart&&u.onStart();(function o(){l=+new Date();s=l>t?1:(l-k)/m;p(j+(r-j)*q(s));if(l>t||n()){u.onComplete&&u.onComplete();return}h(o)})()}var h=(function(){return fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(k,j){fabric.window.setTimeout(k,1000/60)}})();function a(k,m,l){if(k){var j=new Image();j.onload=function(){m&&m.call(l,j);j=j.onload=null};j.src=k}}fabric.util.removeFromArray=g;fabric.util.degreesToRadians=b;fabric.util.toFixed=d;fabric.util.getRandomInt=e;fabric.util.falseFunction=i;fabric.util.animate=c;fabric.util.requestAnimFrame=h;fabric.util.loadImage=a})();(function(){var d=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(g){if(this===void 0||this===null){throw new TypeError()}var h=Object(this),e=h.length>>>0;if(e===0){return -1}var i=0;if(arguments.length>0){i=Number(arguments[1]);if(i!==i){i=0}else{if(i!==0&&i!==(1/0)&&i!==-(1/0)){i=(i>0||-1)*Math.floor(Math.abs(i))}}}if(i>=e){return -1}var f=i>=0?i:Math.max(e-Math.abs(i),0);for(;f<e;f++){if(f in h&&h[f]===g){return f}}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){if(!h||h.length===0){return undefined}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){if(!h||h.length===0){return undefined}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 c=Array.prototype.slice,a=Function.prototype.apply,b=function(){};if(!Function.prototype.bind){Function.prototype.bind=function(d){var g=this,e=c.call(arguments,1),f;if(e.length){f=function(){return a.call(g,this instanceof b?this:d,e.concat(c.call(arguments)))}}else{f=function(){return a.call(g,this instanceof b?this:d,arguments)}}b.prototype=this.prototype;f.prototype=new b;return f}}})();(function(){var f=Array.prototype.slice,e=function(){};var c=(function(){for(var g in {toString:1}){if(g==="toString"){return false}}return true})();var b;if(c){b=function(g,i){if(i.toString!==Object.prototype.toString){g.prototype.toString=i.toString}if(i.valueOf!==Object.prototype.valueOf){g.prototype.valueOf=i.valueOf}for(var h in i){g.prototype[h]=i[h]}}}else{b=function(g,i){for(var h in i){g.prototype[h]=i[h]}}}function a(){}function d(){var k=null,j=f.call(arguments,0);if(typeof j[0]==="function"){k=j.shift()}function g(){this.initialize.apply(this,arguments)}g.superclass=k;g.subclasses=[];if(k){a.prototype=k.prototype;g.prototype=new a;k.subclasses.push(g)}for(var h=0,l=j.length;h<l;h++){b(g,j[h])}if(!g.prototype.initialize){g.prototype.initialize=e}g.prototype.constructor=g;return g}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))}if(fabric.isTouchSupported){a=function(r){return r.touches&&r.touches[0].pageX};p=function(r){return r.touches&&r.touches[0].pageY}}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 k=fabric.document.documentElement.style;var l="userSelect" in k?"userSelect":"MozUserSelect" in k?"MozUserSelect":"WebkitUserSelect" in k?"WebkitUserSelect":"KhtmlUserSelect" in k?"KhtmlUserSelect":"";function m(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=fabric.util.falseFunction}if(l){n.style[l]="none"}else{if(typeof n.unselectable=="string"){n.unselectable="on"}}return n}function j(n){if(typeof n.onselectstart!=="undefined"){n.onselectstart=null}if(l){n.style[l]=""}else{if(typeof n.unselectable=="string"){n.unselectable=""}}return n}fabric.util.makeElementUnselectable=m;fabric.util.makeElementSelectable=j})();(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(i){var g=i.fabric||(i.fabric={}),o=g.util.object.extend,e=g.util.string.capitalize,p=g.util.object.clone;var k={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};function d(v,u){if(!v){return}var x,t,s={};if(v.parentNode&&/^g$/i.test(v.parentNode.nodeName)){s=g.parseAttributes(v.parentNode,u)}var w=u.reduce(function(z,y){x=v.getAttribute(y);t=parseFloat(x);if(x){if((y==="fill"||y==="stroke")&&x==="none"){x=""}if(y==="fill-rule"){x=(x==="evenodd")?"destination-over":x}if(y==="transform"){x=g.parseTransformAttribute(x)}if(y in k){y=k[y]}z[y]=isNaN(t)?x:t}return z},{});w=o(w,o(n(v),g.parseStyleAttribute(v)));return o(s,w)}g.parseTransformAttribute=(function(){function s(L,M){var N=M[0];L[0]=Math.cos(N);L[1]=Math.sin(N);L[2]=-Math.sin(N);L[3]=Math.cos(N)}function x(N,O){var M=O[0],L=(O.length===2)?O[1]:O[0];N[0]=M;N[3]=L}function I(L,M){L[2]=M[0]}function u(L,M){L[1]=M[0]}function F(L,M){L[4]=M[0];if(M.length===2){L[5]=M[1]}}var z=[1,0,0,1,0,0],t="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",J="(?:\\s+,?\\s*|,\\s*)",A="(?:(skewX)\\s*\\(\\s*("+t+")\\s*\\))",y="(?:(skewY)\\s*\\(\\s*("+t+")\\s*\\))",H="(?:(rotate)\\s*\\(\\s*("+t+")(?:"+J+"("+t+")"+J+"("+t+"))?\\s*\\))",K="(?:(scale)\\s*\\(\\s*("+t+")(?:"+J+"("+t+"))?\\s*\\))",D="(?:(translate)\\s*\\(\\s*("+t+")(?:"+J+"("+t+"))?\\s*\\))",G="(?:(matrix)\\s*\\(\\s*("+t+")"+J+"("+t+")"+J+"("+t+")"+J+"("+t+")"+J+"("+t+")"+J+"("+t+")\\s*\\))",E="(?:"+G+"|"+D+"|"+K+"|"+H+"|"+A+"|"+y+")",B="(?:"+E+"(?:"+J+E+")*)",v="^\\s*(?:"+B+"?)\\s*$",C=new RegExp(v),w=new RegExp(E);return function(M){var L=z.concat();if(!M||(M&&!C.test(M))){return L}M.replace(w,function(Q){var N=new RegExp(E).exec(Q).filter(function(R){return(R!==""&&R!=null)}),O=N[1],P=N.slice(2).map(parseFloat);switch(O){case"translate":F(L,P);break;case"rotate":s(L,P);break;case"scale":x(L,P);break;case"skewX":I(L,P);break;case"skewY":u(L,P);break;case"matrix":L=P;break}});return L}})();function r(v){if(!v){return null}v=v.trim();var x=v.indexOf(",")>-1;v=v.split(/\s+/);var t=[];if(x){for(var u=0,s=v.length;u<s;u++){var w=v[u].split(",");t.push({x:parseFloat(w[0]),y:parseFloat(w[1])})}}else{for(var u=0,s=v.length;u<s;u+=2){t.push({x:parseFloat(v[u]),y:parseFloat(v[u+1])})}}if(t.length%2!==0){}return t}function h(t){var s={},u=t.getAttribute("style");if(u){if(typeof u=="string"){u=u.replace(/;$/,"").split(";");s=u.reduce(function(x,A){var w=A.split(":"),y=w[0].trim(),z=w[1].trim();x[y]=z;return x},{})}else{for(var v in u){if(typeof u[v]!=="undefined"){s[v]=u[v]}}}}return s}function q(x){var t=g.Canvas.activeInstance,s=t?t.getContext():null;if(!s){return}for(var u=x.length;u--;){var v=x[u].get("fill");if(/^url\(/.test(v)){var w=v.slice(5,v.length-1);if(g.gradientDefs[w]){x[u].set("fill",g.Gradient.fromElement(g.gradientDefs[w],s,x[u]))}}}}function f(t,B,C){var s=Array(t.length),w=t.length;function u(){if(--w===0){s=s.filter(function(D){return D!=null});q(s);B(s)}}for(var y=0,v,x=t.length;y<x;y++){v=t[y];var A=g[e(v.tagName)];if(A&&A.fromElement){try{if(A.async){A.fromElement(v,(function(D){return function(E){s.splice(D,0,E);u()}})(y),C)}else{s.splice(y,0,A.fromElement(v,C));u()}}catch(z){g.log(z.message||z)}}else{u()}}}function c(x){var v=x.getElementsByTagName("style"),t={},y;for(var u=0,s=v.length;u<s;u++){var w=v[0].textContent;w=w.replace(/\/\*[\s\S]*?\*\//g,"");y=w.match(/[^{]*\{[\s\S]*?\}/g);y=y.map(function(z){return z.trim()});y.forEach(function(E){var C=E.match(/([\s\S]*?)\s*\{([^}]*)\}/),E=C[1],z=C[2].trim(),G=z.replace(/;$/,"").split(/\s*;\s*/);if(!t[E]){t[E]={}}for(var B=0,D=G.length;B<D;B++){var A=G[B].split(/\s*:\s*/),H=A[0],F=A[1];t[E][H]=F}})}return t}function n(t){var z=t.nodeName,u=t.getAttribute("class"),y=t.getAttribute("id"),v={};for(var x in g.cssRules){var s=(u&&new RegExp("^\\."+u).test(x))||(y&&new RegExp("^#"+y).test(x))||(new RegExp("^"+z).test(x));if(s){for(var w in g.cssRules[x]){v[w]=g.cssRules[x][w]}}}return v}g.parseSVGDocument=(function(){var s=/^(path|circle|polygon|polyline|ellipse|rect|line|image)$/;var t="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)";var u=new RegExp("^\\s*("+t+"+)\\s*,?\\s*("+t+"+)\\s*,?\\s*("+t+"+)\\s*,?\\s*("+t+"+)\\s*$");function v(w,x){while(w&&(w=w.parentNode)){if(x.test(w.nodeName)){return true}}return false}return function(I,K){if(!I){return}var A=new Date(),E=g.util.toArray(I.getElementsByTagName("*"));if(E.length===0){E=I.selectNodes("//*[name(.)!='svg']");var G=[];for(var F=0,H=E.length;F<H;F++){G[F]=E[F]}E=G}var w=E.filter(function(M){return s.test(M.tagName)&&!v(M,/^(?:pattern|defs)$/)});if(!w||(w&&!w.length)){return}var x=I.getAttribute("viewBox"),C=I.getAttribute("width"),z=I.getAttribute("height"),y=null,J=null,D,B;if(x&&(x=x.match(u))){D=parseInt(x[1],10);B=parseInt(x[2],10);y=parseInt(x[3],10);J=parseInt(x[4],10)}y=C?parseFloat(C):y;J=z?parseFloat(z):J;var L={width:y,height:J};g.gradientDefs=g.getGradientDefs(I);g.cssRules=c(I);g.parseElements(w,function(M){g.documentParsingTime=new Date()-A;if(K){K(M,L)}},p(L))}})();var j={has:function(s,t){t(false)},get:function(s,t){},set:function(t,s){}};function b(s,u){s=s.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();j.has(s,function(v){if(v){j.get(s,function(x){var w=a(x);u(w.objects,w.options)})}else{new g.util.request(s,{method:"get",onComplete:t})}});function t(w){var v=w.responseXML;if(!v){return}var x=v.documentElement;if(!x){return}g.parseSVGDocument(x,function(z,y){j.set(s,{objects:g.util.array.invoke(z,"toObject"),options:y});u(z,y)})}}function a(u){var t=u.objects,s=u.options;t=t.map(function(v){return g[e(v.type)].fromObject(v)});return({objects:t,options:s})}function m(s,v){s=s.trim();var t;if(typeof DOMParser!=="undefined"){var u=new DOMParser();if(u&&u.parseFromString){t=u.parseFromString(s,"text/xml")}}else{if(g.window.ActiveXObject){var t=new ActiveXObject("Microsoft.XMLDOM");if(t&&t.loadXML){t.async="false";t.loadXML(s)}}}g.parseSVGDocument(t.documentElement,function(x,w){v(x,w)})}function l(v){var t="";for(var u=0,s=v.length;u<s;u++){if(v[u].type!=="text"||!v[u].path){continue}t+=["@font-face {","font-family: ",v[u].fontFamily,"; ","src: url('",v[u].path,"')","}"].join("")}if(t){t=["<defs>",'<style type="text/css">',"<![CDATA[",t,"]]>","</style>","</defs>"].join("")}return t}o(g,{parseAttributes:d,parseElements:f,parseStyleAttribute:h,parsePointsAttribute:r,getCSSRules:c,loadSVGFromURL:b,loadSVGFromString:m,createSVGFontFacesMarkup:l})})(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,y1:e.y1,x2:e.x2,y2:e.y2,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[3]=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(c){if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var f=fabric.util.object.extend,d=fabric.util.getElementOffset,e=fabric.util.removeFromArray,b=fabric.util.removeListener,a=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=function(h,g){g||(g={});this._initStatic(h,g);fabric.StaticCanvas.activeInstance=this};f(fabric.StaticCanvas.prototype,fabric.Observable);f(fabric.StaticCanvas.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",backgroundImage:"",includeDefaultValues:true,stateful:true,renderOnAddition:true,clipTo:null,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(g){},onFpsUpdate:null,_initStatic:function(h,g){this._objects=[];this._createLowerCanvas(h);this._initOptions(g);if(g.overlayImage){this.setOverlayImage(g.overlayImage,this.renderAll.bind(this))}if(g.backgroundImage){this.setBackgroundImage(g.backgroundImage,this.renderAll.bind(this))}this.calcOffset()},calcOffset:function(){this._offset=d(this.lowerCanvasEl);return this},setOverlayImage:function(g,h){return fabric.util.loadImage(g,function(i){this.overlayImage=i;h&&h()},this)},setBackgroundImage:function(g,h){return fabric.util.loadImage(g,function(i){this.backgroundImage=i;h&&h()},this)},_createCanvasElement:function(){var g=fabric.document.createElement("canvas");if(!g.style){g.style={}}if(!g){throw a}this._initCanvasElement(g);return g},_initCanvasElement:function(g){if(typeof g.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement){G_vmlCanvasManager.initElement(g)}if(typeof g.getContext==="undefined"){throw a}},_initOptions:function(g){for(var h in g){this[h]=g[h]}this.width=parseInt(this.lowerCanvasEl.width,10)||0;this.height=parseInt(this.lowerCanvasEl.height,10)||0;this.lowerCanvasEl.style.width=this.width+"px";this.lowerCanvasEl.style.height=this.height+"px"},_createLowerCanvas:function(g){this.lowerCanvasEl=fabric.util.getById(g)||this._createCanvasElement();this._initCanvasElement(this.lowerCanvasEl);fabric.util.addClass(this.lowerCanvasEl,"lower-canvas");if(this.interactive){this._applyCanvasStyle(this.lowerCanvasEl)}this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(g){return this._setDimension("width",g)},setHeight:function(g){return this._setDimension("height",g)},setDimensions:function(g){for(var h in g){this._setDimension(h,g[h])}return this},_setDimension:function(h,g){this.lowerCanvasEl[h]=g;this.lowerCanvasEl.style[h]=g+"px";if(this.upperCanvasEl){this.upperCanvasEl[h]=g;this.upperCanvasEl.style[h]=g+"px"}if(this.wrapperEl){this.wrapperEl.style[h]=g+"px"}this[h]=g;this.calcOffset();this.renderAll();return this},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_draw:function(g,h){h&&h.render(g)},add:function(){this._objects.push.apply(this._objects,arguments);for(var g=arguments.length;g--;){this.stateful&&arguments[g].setupState();arguments[g].setCoords()}this.renderOnAddition&&this.renderAll();return this},insertAt:function(h,g,i){if(i){this._objects[g]=h}else{this._objects.splice(g,0,h)}this.stateful&&h.setupState();h.setCoords();this.renderAll();return this},getObjects:function(){return this._objects},clearContext:function(g){g.clearRect(0,0,this.width,this.height);return this},clear:function(){this._objects.length=0;this.clearContext(this.contextContainer);if(this.contextTop){this.clearContext(this.contextTop)}this.renderAll();return this},renderAll:function(h){var j=this[(h&&this.interactive)?"contextTop":"contextContainer"];if(this.contextTop){this.clearContext(this.contextTop)}if(!h){this.clearContext(j)}var n=this._objects.length,m=this.getActiveGroup(),l=new Date();if(this.clipTo){j.save();j.beginPath();this.clipTo(j);j.clip()}j.fillStyle=this.backgroundColor;j.fillRect(0,0,this.width,this.height);if(typeof this.backgroundImage=="object"){j.drawImage(this.backgroundImage,0,0,this.width,this.height)}if(n){for(var k=0;k<n;++k){if(!m||(m&&this._objects[k]&&!m.contains(this._objects[k]))){this._draw(j,this._objects[k])}}}if(this.clipTo){j.restore()}if(m){this._draw(this.contextTop,m)}if(this.overlayImage){this.contextTop.drawImage(this.overlayImage,0,0)}if(this.onFpsUpdate){var g=new Date()-l;this.onFpsUpdate(~~(1000/g))}this.fire("after:render");return this},renderTop:function(){this.clearContext(this.contextTop||this.contextContainer);if(this.overlayImage){(this.contextTop||this.contextContainer).drawImage(this.overlayImage,0,0)}if(this.selection&&this._groupSelector){this._drawSelection()}var g=this.getActiveGroup();if(g){g.render(this.contextTop)}this.fire("after:render");return this},toDataURL:function(h){this.renderAll(true);var g=(this.upperCanvasEl||this.lowerCanvasEl).toDataURL("image/"+h);this.renderAll();return g},toDataURLWithMultiplier:function(j,n){var m=this.getWidth(),l=this.getHeight(),h=m*n,i=l*n,g=this.getActiveObject();this.setWidth(h).setHeight(i);this.contextTop.scale(n,n);if(g){this.deactivateAll()}this.width=m;this.height=l;this.renderAll(true);var k=this.toDataURL(j);this.contextTop.scale(1/n,1/n);this.setWidth(m).setHeight(l);if(g){this.setActiveObject(g)}this.renderAll();return k},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(g){g.set("left",this.getCenter().left);this.renderAll();return this},centerObjectV:function(g){g.set("top",this.getCenter().top);this.renderAll();return this},centerObject:function(g){return this.centerObjectH(g).centerObjectV(g)},straightenObject:function(g){g.straighten();this.renderAll();return this},toDatalessJSON:function(){return this.toDatalessObject()},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(g){return{objects:this._objects.map(function(h){if(!this.includeDefaultValues){var i=h.includeDefaultValues;h.includeDefaultValues=false}var j=h[g]();if(!this.includeDefaultValues){h.includeDefaultValues=i}return j},this),background:this.backgroundColor}},toSVG:function(){var h=['<?xml version="1.0" standalone="no" ?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ','"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',"<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',this.width,'" ','height="',this.height,'" ','xml:space="preserve">',"<desc>Created with Fabric.js ",fabric.version,"</desc>",fabric.createSVGFontFacesMarkup(this.getObjects()),];for(var j=0,k=this.getObjects(),g=k.length;j<g;j++){h.push(k[j].toSVG())}h.push("</svg>");return h.join("")},isEmpty:function(){return this._objects.length===0},remove:function(g){e(this._objects,g);if(this.getActiveObject()===g){this.discardActiveObject()}this.renderAll();return g},sendToBack:function(g){e(this._objects,g);this._objects.unshift(g);return this.renderAll()},bringToFront:function(g){e(this._objects,g);this._objects.push(g);return this.renderAll()},sendBackwards:function(j){var h=this._objects.indexOf(j),g=h;if(h!==0){for(var k=h-1;k>=0;--k){if(j.intersectsWithObject(this._objects[k])||j.isContainedWithinObject(this._objects[k])){g=k;break}}e(this._objects,j);this._objects.splice(g,0,j)}return this.renderAll()},bringForward:function(k){var n=this.getObjects(),h=n.indexOf(k),g=h;if(h!==n.length-1){for(var m=h+1,j=this._objects.length;m<j;++m){if(k.intersectsWithObject(n[m])||k.isContainedWithinObject(this._objects[m])){g=m;break}}e(n,k);n.splice(g,0,k)}this.renderAll()},item:function(g){return this.getObjects()[g]},complexity:function(){return this.getObjects().reduce(function(g,h){g+=h.complexity?h.complexity():0;return g},0)},forEachObject:function(k,h){var j=this.getObjects(),g=j.length;while(g--){k.call(h,j[g],g,j)}return this},dispose:function(){this.clear();if(this.interactive){b(this.upperCanvasEl,"mousedown",this._onMouseDown);b(this.upperCanvasEl,"mousemove",this._onMouseMove);b(fabric.window,"resize",this._onResize)}return this},_resizeImageToFit:function(i){var h=i.width||i.offsetWidth,g=this.getWidth()/h;if(h){i.width=h*g}}});fabric.StaticCanvas.prototype.toString=function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};f(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(l){var k=l.getContext("2d"),g=k.getImageData(0,0,l.width,l.height),p=g.data,m=g.width,r=g.height,q,h,o,n;for(o=0;o<m;o++){for(n=0;n<r;n++){q=(o*4)*r+(n*4);h=(p[q]+p[q+1]+p[q+2])/3;p[q]=h;p[q+1]=h;p[q+2]=h}}k.putImageData(g,0,0)},supports:function(h){var i=fabric.document.createElement("canvas");if(typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(i)}if(!i||!i.getContext){return null}var g=i.getContext("2d");if(!g){return null}switch(h){case"getImageData":return typeof g.getImageData!=="undefined";case"toDataURL":return typeof i.toDataURL!=="undefined";default:return null}}});fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject})(typeof exports!="undefined"?exports:this);(function(){var j=fabric.util.object.extend,q=fabric.util.getPointer,b=fabric.util.addListener,g=fabric.util.removeListener,m={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"},d=fabric.util.array.min,h=fabric.util.array.max,n=Math.sqrt,i=Math.pow,o=Math.atan2,p=Math.abs,f=Math.min,l=Math.max,a=0.5;fabric.Canvas=function(s,r){r||(r={});this._initStatic(s,r);this._initInteractive();fabric.Canvas.activeInstance=this};function k(){}k.prototype=fabric.StaticCanvas.prototype;fabric.Canvas.prototype=new k;var e={interactive:true,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,HOVER_CURSOR:"move",CURSOR:"default",CONTAINER_CLASS:"canvas-container",_initInteractive:function(){this._currentTransform=null;this._groupSelector=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._initWrapperElement();this._createUpperCanvas();this._initEvents();this.calcOffset()},_initEvents:function(){var r=this;this._onMouseDown=function(s){r.__onMouseDown(s);b(fabric.document,"mouseup",r._onMouseUp);fabric.isTouchSupported&&b(fabric.document,"touchend",r._onMouseUp);b(fabric.document,"mousemove",r._onMouseMove);fabric.isTouchSupported&&b(fabric.document,"touchmove",r._onMouseMove);g(r.upperCanvasEl,"mousemove",r._onMouseMove);fabric.isTouchSupported&&g(r.upperCanvasEl,"touchmove",r._onMouseMove)};this._onMouseUp=function(s){r.__onMouseUp(s);g(fabric.document,"mouseup",r._onMouseUp);fabric.isTouchSupported&&g(fabric.document,"touchend",r._onMouseUp);g(fabric.document,"mousemove",r._onMouseMove);fabric.isTouchSupported&&g(fabric.document,"touchmove",r._onMouseMove);b(r.upperCanvasEl,"mousemove",r._onMouseMove);fabric.isTouchSupported&&b(r.upperCanvasEl,"touchmove",r._onMouseMove)};this._onMouseMove=function(s){s.preventDefault&&s.preventDefault();r.__onMouseMove(s)};this._onResize=function(s){r.calcOffset()};b(fabric.window,"resize",this._onResize);if(fabric.isTouchSupported){b(this.upperCanvasEl,"touchstart",this._onMouseDown);b(this.upperCanvasEl,"touchmove",this._onMouseMove)}else{b(this.upperCanvasEl,"mousedown",this._onMouseDown);b(this.upperCanvasEl,"mousemove",this._onMouseMove)}},__onMouseUp:function(v){if(this.isDrawingMode&&this._isCurrentlyDrawing){this._finalizeDrawingPath();return}if(this._currentTransform){var r=this._currentTransform,u=r.target;if(u._scaling){u._scaling=false}var s=this._objects.length;while(s--){this._objects[s].setCoords()}if(this.stateful&&u.hasStateChanged()){u.isMoving=false;this.fire("object:modified",{target:u})}}this._currentTransform=null;if(this._groupSelector){this._findSelectedObjects(v)}var t=this.getActiveGroup();if(t){t.setObjectsCoords();t.set("isMoving",false);this._setCursor(this.CURSOR)}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(v,u);this._setCursor("");var w=this;setTimeout(function(){w._setCursorFromEvent(v,u)},50);this.fire("mouse:up",{target:u,e:v})},__onMouseDown:function(v){if(v.which!==1&&!fabric.isTouchSupported){return}if(this.isDrawingMode){this._prepareForDrawing(v);this._captureDrawingPath(v);return}if(this._currentTransform){return}var u=this.findTarget(v),w=this.getPointer(v),s=this.getActiveGroup(),t;if(this._shouldClearSelection(v)){this._groupSelector={ex:w.x,ey:w.y,top:0,left:0};this.deactivateAllWithDispatch()}else{this.stateful&&u.saveState();if(t=u._findTargetCorner(v,this._offset)){this.onBeforeScaleRotate(u)}this._setupCurrentTransform(v,u);var r=v.shiftKey&&(s||this.getActiveObject());if(r){this._handleGroupLogic(v,u)}else{if(u!==this.getActiveGroup()){this.deactivateAll()}this.setActiveObject(u,v)}}this.renderAll();this.fire("mouse:down",{target:u,e:v})},__onMouseMove:function(w){if(this.isDrawingMode){if(this._isCurrentlyDrawing){this._captureDrawingPath(w)}return}var s=this._groupSelector;if(s!==null){var z=q(w);s.left=z.x-this._offset.left-s.ex;s.top=z.y-this._offset.top-s.ey;this.renderTop()}else{if(!this._currentTransform){var u=this.upperCanvasEl.style;var v=this.findTarget(w);if(!v){for(var t=this._objects.length;t--;){if(this._objects[t]&&!this._objects[t].active){this._objects[t].setActive(false)}}u.cursor=this.CURSOR}else{this._setCursorFromEvent(w,v);if(v.isActive()){v.setCornersVisibility&&v.setCornersVisibility(true)}}}else{var z=q(w),r=z.x,A=z.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){if(!w.shiftKey){this._rotateObject(r,A);this.fire("object:rotating",{target:this._currentTransform.target})}this._scaleObject(r,A);this.fire("object:scaling",{target:this._currentTransform.target})}else{if(this._currentTransform.action==="scaleX"){this._scaleObject(r,A,"x");this.fire("object:scaling",{target:this._currentTransform.target})}else{if(this._currentTransform.action==="scaleY"){this._scaleObject(r,A,"y");this.fire("object:scaling",{target:this._currentTransform.target})}else{this._translateObject(r,A);this.fire("object:moving",{target:this._currentTransform.target})}}}this.renderAll()}}this.fire("mouse:move",{target:v,e:w})},containsPoint:function(w,v){var z=this.getPointer(w),u=this._normalizePointer(v,z),r=u.x,A=u.y;var s=v._getImageLines(v.oCoords),t=v._findCrossPoints(r,A,s);if((t&&t%2===1)||v._findTargetCorner(w,this._offset)){return true}return false},_normalizePointer:function(s,v){var u=this.getActiveGroup(),r=v.x,w=v.y;var t=(u&&s.type!=="group"&&u.contains(s));if(t){r-=u.left;w-=u.top}return{x:r,y:w}},_shouldClearSelection:function(t){var s=this.findTarget(t),r=this.getActiveGroup();return(!s||(s&&r&&!r.contains(s)&&r!==s&&!t.shiftKey))},_setupCurrentTransform:function(u,t){var s="drag",r,v=q(u);if(r=t._findTargetCorner(u,this._offset)){s=(r==="ml"||r==="mr")?"scaleX":(r==="mt"||r==="mb")?"scaleY":"rotate"}this._currentTransform={target:t,action:s,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:v.x-t.left,offsetY:v.y-t.top,ex:v.x,ey:v.y,left:t.left,top:t.top,theta:t.theta,width:t.width*t.scaleX};this._currentTransform.original={left:t.left,top:t.top}},_handleGroupLogic:function(u,t){if(t.isType("group")){t=this.findTarget(u,true);if(!t||t.isType("group")){return}}var r=this.getActiveGroup();if(r){if(r.contains(t)){r.remove(t);t.setActive(false);if(r.size()===1){this.discardActiveGroup()}}else{r.add(t)}this.fire("selection:created",{target:r,e:u});r.setActive(true)}else{if(this._activeObject){if(t!==this._activeObject){var s=new fabric.Group([this._activeObject,t]);this.setActiveGroup(s);r=this.getActiveGroup()}}t.setActive(true)}if(r){r.saveCoords()}},_prepareForDrawing:function(r){this._isCurrentlyDrawing=true;this.discardActiveObject().renderAll();var s=this.getPointer(r);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(s.x);this._freeDrawingYPoints.push(s.y);this.contextTop.beginPath();this.contextTop.moveTo(s.x,s.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=this.contextTop.lineJoin="round"},_captureDrawingPath:function(r){var s=this.getPointer(r);this._freeDrawingXPoints.push(s.x);this._freeDrawingYPoints.push(s.y);this.contextTop.lineTo(s.x,s.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var w=d(this._freeDrawingXPoints),v=d(this._freeDrawingYPoints),t=h(this._freeDrawingXPoints),r=h(this._freeDrawingYPoints),B=this.contextTop,C=[],x,z,s=this._freeDrawingXPoints,A=this._freeDrawingYPoints;C.push("M ",s[0]-w," ",A[0]-v," ");for(var y=1;x=s[y],z=A[y];y++){C.push("L ",x-w," ",z-v," ")}C=C.join("");if(C==="M 0 0 L 0 0 "){return}var u=new fabric.Path(C);u.fill=null;u.stroke=this.freeDrawingColor;u.strokeWidth=this.freeDrawingLineWidth;this.add(u);u.set("left",w+(t-w)/2).set("top",v+(r-v)/2).setCoords();this.renderAll();this.fire("path:created",{path:u})},_translateObject:function(r,t){var s=this._currentTransform.target;s.lockMovementX||s.set("left",r-this._currentTransform.offsetX);s.lockMovementY||s.set("top",t-this._currentTransform.offsetY)},_scaleObject:function(r,B,z){var s=this._currentTransform,A=this._offset,w=s.target;if(w.lockScalingX&&w.lockScalingY){return}var v=n(i(s.ey-s.top-A.top,2)+i(s.ex-s.left-A.left,2)),u=n(i(B-s.top-A.top,2)+i(r-s.left-A.left,2));w._scaling=true;if(!z){w.lockScalingX||w.set("scaleX",s.scaleX*u/v);w.lockScalingY||w.set("scaleY",s.scaleY*u/v)}else{if(z==="x"&&!w.lockUniScaling){w.lockScalingX||w.set("scaleX",s.scaleX*u/v)}else{if(z==="y"&&!w.lockUniScaling){w.lockScalingY||w.set("scaleY",s.scaleY*u/v)}}}},_rotateObject:function(r,z){var s=this._currentTransform,v=this._offset;if(s.target.lockRotation){return}var u=o(s.ey-s.top-v.top,s.ex-s.left-v.left),w=o(z-s.top-v.top,r-s.left-v.left);s.target.set("theta",(w-u)+s.theta)},_setCursor:function(r){this.upperCanvasEl.style.cursor=r},_setCursorFromEvent:function(w,v){var t=this.upperCanvasEl.style;if(!v){t.cursor=this.CURSOR;return false}else{var r=this.getActiveGroup();var u=!!v._findTargetCorner&&(!r||!r.contains(v))&&v._findTargetCorner(w,this._offset);if(!u){t.cursor=this.HOVER_CURSOR}else{if(u in m){t.cursor=m[u]}else{t.cursor=this.CURSOR;return false}}}return true},_drawSelection:function(){var r=this._groupSelector,v=r.left,u=r.top,t=p(v),s=p(u);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(r.ex-((v>0)?0:-v),r.ey-((u>0)?0:-u),t,s);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(r.ex+a-((v>0)?0:t),r.ey+a-((u>0)?0:s),t,s)},_findSelectedObjects:function(x){var y,t,D=[],s=this._groupSelector.ex,C=this._groupSelector.ey,r=s+this._groupSelector.left,A=C+this._groupSelector.top,z,w=new fabric.Point(f(s,r),f(C,A)),B=new fabric.Point(l(s,r),l(C,A));for(var u=0,v=this._objects.length;u<v;++u){z=this._objects[u];if(!z){continue}if(z.intersectsWithRect(w,B)||z.isContainedWithinRect(w,B)){if(this.selection&&z.selectable){z.setActive(true);D.push(z)}}}if(D.length===1){this.setActiveObject(D[0],x)}else{if(D.length>1){var D=new fabric.Group(D);this.setActiveGroup(D);D.saveCoords();this.fire("selection:created",{target:D})}}this.renderAll()},findTarget:function(v,s){var u,w=this.getPointer(v);var t=this.getActiveGroup();if(t&&!s&&this.containsPoint(v,t)){u=t;return u}for(var r=this._objects.length;r--;){if(this._objects[r]&&this.containsPoint(v,this._objects[r])){u=this._objects[r];this.relatedTarget=u;break}}if(u&&u.selectable){return u}},getPointer:function(r){var s=q(r);return{x:s.x-this._offset.left,y:s.y-this._offset.top}},_createUpperCanvas:function(){this.upperCanvasEl=this._createCanvasElement();this.upperCanvasEl.className="upper-canvas";this.wrapperEl.appendChild(this.upperCanvasEl);this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"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(s){var t=this.getWidth()||s.width,r=this.getHeight()||s.height;fabric.util.setStyle(s,{position:"absolute",width:t+"px",height:r+"px",left:0,top:0});s.width=t;s.height=r;fabric.util.makeElementUnselectable(s)},getContext:function(){return this.contextTop},setActiveObject:function(r,s){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=r;r.setActive(true);this.renderAll();this.fire("object:selected",{target:r,e:s});return this},getActiveObject:function(){return this._activeObject},discardActiveObject:function(){if(this._activeObject){this._activeObject.setActive(false)}this._activeObject=null;return this},setActiveGroup:function(r){this._activeGroup=r;return this},getActiveGroup:function(){return this._activeGroup},discardActiveGroup:function(){var r=this.getActiveGroup();if(r){r.destroy()}return this.setActiveGroup(null)},deactivateAll:function(){var s=this.getObjects(),t=0,r=s.length;for(;t<r;t++){s[t].setActive(false)}this.discardActiveGroup();this.discardActiveObject();return this},deactivateAllWithDispatch:function(){var r=this.getActiveGroup()||this.getActiveObject();if(r){this.fire("before:selection:cleared",{target:r})}this.deactivateAll();if(r){this.fire("selection:cleared")}return this}};fabric.Canvas.prototype.toString=fabric.StaticCanvas.prototype.toString;j(fabric.Canvas.prototype,e);for(var c in fabric.StaticCanvas){if(c!=="prototype"){fabric.Canvas[c]=fabric.StaticCanvas[c]}}if(fabric.isTouchSupported){fabric.Canvas.prototype._setCursorFromEvent=function(){}}fabric.Element=fabric.Canvas})();fabric.util.object.extend(fabric.StaticCanvas.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.StaticCanvas.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,true);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"){fabric.util.loadImage(m,function(p){var o=new fabric.Image(p);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,true);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,true)}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()},getSvgStyles:function(){return["stroke: ",(this.stroke?this.stroke:"none"),"; ","stroke-width: ",(this.strokeWidth?this.strokeWidth:"0"),"; ","fill: ",(this.fill?this.fill:"none"),"; ","opacity: ",(this.opacity?this.opacity:"1"),";",].join("")},getSvgTransform:function(){var i=this.getAngle();return["translate(",this.left," ",this.top,")",i!==0?(" rotate("+i+")"):"",(this.scaleX===1&&this.scaleY===1)?"":(" scale("+c(this.scaleX,"2")+" "+c(this.scaleY,"2")+")")].join("")},_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){}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);this.toDataURL(function(i){q.src=i})}return this},toDataURL:function(s){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();if(this.constructor.async){this.clone(r)}else{r(this.clone())}function r(u){u.left=q.width/2;u.top=q.height/2;u.setActive(false);i.add(u);var t=i.toDataURL("png");i.dispose();i=u=null;s&&s(t)}},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},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(b){var c=b.fabric||(b.fabric={}),e=c.util.object.extend,d=c.Object.prototype.set,a={x1:1,x2:1,y1:1,y2:1};if(c.Line){c.warn("fabric.Line is already defined");return}c.Line=c.util.createClass(c.Object,{type:"line",initialize:function(g,f){if(!g){g=[0,0,0,0]}this.callSuper("initialize",f);this.set("x1",g[0]);this.set("y1",g[1]);this.set("x2",g[2]);this.set("y2",g[3]);this._setWidthHeight()},_setWidthHeight:function(){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)},set:function(f,g){d.call(this,f,g);if(f in a){this._setWidthHeight()}return this},_render:function(f){f.beginPath();f.moveTo(this.width===1?0:(-this.width/2),this.height===1?0:(-this.height/2));f.lineTo(this.width===1?0:(this.width/2),this.height===1?0:(this.height/2));f.lineWidth=this.strokeWidth;var g=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=g},complexity:function(){return 1},toObject:function(){return e(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){return["<line ",'x1="',this.get("x1"),'" ','y1="',this.get("y1"),'" ','x2="',this.get("x2"),'" ','y2="',this.get("y2"),'" ','style="',this.getSvgStyles(),'" ',"/>"].join("")}});c.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");c.Line.fromElement=function(g,f){var i=c.parseAttributes(g,c.Line.ATTRIBUTE_NAMES);var h=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new c.Line(h,e(i,f))};c.Line.fromObject=function(f){var g=[f.x1,f.y1,f.x2,f.y2];return new c.Line(g,f)}})(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")})},toSVG:function(){return('<circle cx="0" cy="0" r="'+this.radius+'" style="'+this.getSvgStyles()+'" transform="'+this.getSvgTransform()+'" />')},_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},toSVG:function(){var c=this.width/2,d=this.height/2;var e=[-c+" "+d,"0 "+-d,c+" "+d].join(",");return'<polygon points="'+e+'" style="'+this.getSvgStyles()+'" transform="'+this.getSvgTransform()+'" />'}});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")})},toSVG:function(){return["<ellipse ",'rx="',this.get("rx"),'" ','ry="',this.get("ry"),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},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||0,this.y||0)}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},toSVG:function(){return'<rect x="'+(-1*this.width/2)+'" y="'+(-1*this.height/2)+'" width="'+this.width+'" height="'+this.height+'" style="'+this.getSvgStyles()+'" transform="'+this.getSvgTransform()+'" />'}});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(b){var c=b.fabric||(b.fabric={}),a=c.util.toFixed;if(c.Polyline){c.warn("fabric.Polyline is already defined");return}c.Polyline=c.util.createClass(c.Object,{type:"polyline",initialize:function(e,d){d=d||{};this.set("points",e);this.callSuper("initialize",d);this._calcDimensions()},_calcDimensions:function(){return c.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return c.Polygon.prototype.toObject.call(this)},toSVG:function(){var f=[];for(var e=0,d=this.points.length;e<d;e++){f.push(a(this.points[e].x,2),",",a(this.points[e].y,2)," ")}return["<polyline ",'points="',f.join(""),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},_render:function(f){var e;f.beginPath();for(var g=0,d=this.points.length;g<d;g++){e=this.points[g];f.lineTo(e.x,e.y)}if(this.fill){f.fill()}if(this.stroke){f.stroke()}},complexity:function(){return this.get("points").length}});c.Polyline.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" ");c.Polyline.fromElement=function(g,e){if(!g){return null}e||(e={});var h=c.parsePointsAttribute(g.getAttribute("points")),j=c.parseAttributes(g,c.Polyline.ATTRIBUTE_NAMES);for(var f=0,d=h.length;f<d;f++){h[f].x-=(e.width/2)||0;h[f].y-=(e.height/2)||0}return new c.Polyline(h,c.util.object.extend(j,e))};c.Polyline.fromObject=function(d){var e=d.points;return new c.Polyline(e,d)}})(typeof exports!="undefined"?exports:this);(function(f){var g=f.fabric||(f.fabric={}),h=g.util.object.extend,e=g.util.array.min,b=g.util.array.max,a=g.util.toFixed;if(g.Polygon){g.warn("fabric.Polygon is already defined");return}function d(i){return i.x}function c(i){return i.y}g.Polygon=g.util.createClass(g.Object,{type:"polygon",initialize:function(j,i){i=i||{};this.points=j;this.callSuper("initialize",i);this._calcDimensions()},_calcDimensions:function(){var j=this.points,i=e(j,"x"),m=e(j,"y"),l=b(j,"x"),k=b(j,"y");this.width=l-i;this.height=k-m;this.minX=i;this.minY=m},toObject:function(){return h(this.callSuper("toObject"),{points:this.points.concat()})},toSVG:function(){var l=[];for(var k=0,j=this.points.length;k<j;k++){l.push(a(this.points[k].x,2),",",a(this.points[k].y,2)," ")}return["<polygon ",'points="',l.join(""),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},_render:function(l){var k;l.beginPath();for(var m=0,j=this.points.length;m<j;m++){k=this.points[m];l.lineTo(k.x,k.y)}if(this.fill){l.fill()}if(this.stroke){l.closePath();l.stroke()}},complexity:function(){return this.points.length}});g.Polygon.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" ");g.Polygon.fromElement=function(m,k){if(!m){return null}k||(k={});var n=g.parsePointsAttribute(m.getAttribute("points")),o=g.parseAttributes(m,g.Polygon.ATTRIBUTE_NAMES);for(var l=0,j=n.length;l<j;l++){n[l].x-=(k.width/2)||0;n[l].y-=(k.height/2)||0}return new g.Polygon(n,h(o,k))};g.Polygon.fromObject=function(i){return new g.Polygon(i.points,i)}})(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},toSVG:function(){var t=[];for(var r=0,q=this.path.length;r<q;r++){t.push(this.path[r].join(" "))}var s=t.join(" ");return['<g transform="',this.getSvgTransform(),'">',"<path ",'width="',this.width,'" height="',this.height,'" ','d="',s,'" ','style="',this.getSvgStyles(),'" ','transform="translate(',(-this.width/2)," ",(-this.height/2),')" />',"</g>"].join("")},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},toSVG:function(){var m=this.getObjects();var k=["<g ",'width="',this.width,'" ','height="',this.height,'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',">"];for(var l=0,j=m.length;l<j;l++){k.push(m[l].toSVG())}k.push("</g>");return k.join("")},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.StaticCanvas.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)||0;u=(h-n)||0;this.width=l;this.height=u;this.left=(p+l/2)||0;this.top=(n+u/2)||0},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",filters:[],initialize:function(d,c){c||(c={});this.callSuper("initialize",c);this._initElement(d);this._originalImage=this.getElement();this._initConfig(c);if(c.filters){this.filters=c.filters;this.applyFilters()}},getElement:function(){return this._element},setElement:function(c){this._element=c;this._initConfig();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._originalImage.src,filters:this.filters.concat()})},toSVG:function(){return'<g transform="'+this.getSvgTransform()+'"><image xlink:href="'+this.getSrc()+'" style="'+this.getSvgStyles()+'" transform="translate('+(-this.width/2)+" "+(-this.height/2)+')" width="'+this.width+'" height="'+this.height+'"/></g>'},getSrc:function(){return this.getElement().src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(c){this.constructor.fromObject(this.toObject(),c)},applyFilters:function(i){if(this.filters.length===0){this.setElement(this._originalImage);i&&i();return}var c=typeof Buffer!=="undefined"&&typeof window==="undefined",g=this._originalImage,e=fabric.document.createElement("canvas"),f=c?new (require("canvas").Image):fabric.document.createElement("img"),h=this;e.width=g.width;e.height=g.height;e.getContext("2d").drawImage(g,0,0);this.filters.forEach(function(j){j&&j.applyTo(e)});f.onload=function(){h.setElement(f);i&&i();f.onload=e=g=null};f.width=g.width;f.height=g.height;if(c){var d=e.toDataURL("image/png").replace(/data:image\/png;base64,/,"");f.src=new Buffer(d,"base64");h.setElement(f);i&&i()}else{f.src=e.toDataURL("image/png")}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()},_initFilters:function(c){if(c.filters&&c.filters.length){this.filters=c.filters.map(function(d){return fabric.Image.filters[d.type].fromObject(d)})}},_setBorder:function(){if(this.bordervisibility){this.currentBorder=this.borderwidth}else{this.currentBorder=0}},_setWidthHeight:function(){var c=2*this.currentBorder;this.width=(this.getElement().width||0)+c;this.height=(this.getElement().height||0)+c},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(){fabric.Image.prototype._initFilters.call(d,d);var g=new fabric.Image(c,d);f&&f(g);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.async=true})(typeof exports!="undefined"?exports:this);fabric.Image.filters={};fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(d){var c=d.getContext("2d"),a=c.getImageData(0,0,d.width,d.height),h=a.data,e=a.width,l=a.height,k,b,g,f;for(g=0;g<e;g++){for(f=0;f<l;f++){k=(g*4)*l+(f*4);b=(h[k]+h[k+1]+h[k+2])/3;h[k]=b;h[k+1]=b;h[k+2]=b}}c.putImageData(a,0,0)},toJSON:function(){return{type:this.type}}});fabric.Image.filters.Grayscale.fromObject=function(){return new fabric.Image.filters.Grayscale()};fabric.Image.filters.RemoveWhite=fabric.util.createClass({type:"RemoveWhite",initialize:function(a){a||(a={});this.threshold=a.threshold||30;this.distance=a.distance||20},applyTo:function(f){var e=f.getContext("2d"),c=e.getImageData(0,0,f.width,f.height),k=c.data,l=this.threshold,d=this.distance,h=255-l,p=Math.abs,a,m,o;for(var j=0,n=k.length;j<n;j+=4){a=k[j];m=k[j+1];o=k[j+2];if(a>h&&m>h&&o>h&&p(a-m)<d&&p(a-o)<d&&p(m-o)<d){k[j+3]=1}}e.putImageData(c,0,0)},toJSON:function(){return{type:this.type,threshold:this.threshold,distance:this.distance}}});fabric.Image.filters.RemoveWhite.fromObject=function(a){return new fabric.Image.filters.RemoveWhite(a)};fabric.Image.filters.Invert=fabric.util.createClass({type:"Invert",applyTo:function(d){var c=d.getContext("2d"),f=c.getImageData(0,0,d.width,d.height),e=f.data,a=e.length,b;for(b=0;b<a;b+=4){e[b]=255-e[b];e[b+1]=255-e[b+1];e[b+2]=255-e[b+2]}c.putImageData(f,0,0)},toJSON:function(){return{type:this.type}}});fabric.Image.filters.Invert.fromObject=function(){return new fabric.Image.filters.Invert()};(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:40,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","fontSize","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,fontWeight:this.fontWeight,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._totalLineHeight=g.totalLineHeight;this._fontAscent=g.fontAscent;this._boundaries=g.boundaries;this._shadowOffsets=g.shadowOffsets;this._shadows=g.shadows||[];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=this.fontSize+"px";f.style.letterSpacing="normal";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})},toSVG:function(){var h=this.text.split("\n"),i=-this._fontAscent-((this._fontAscent/5)*this.lineHeight),f=-(this.width/2),e=(this.height/2)-(h.length*this.fontSize)-this._totalLineHeight,g=this._getSVGTextAndBg(i,f,h),j=this._getSVGShadows(i,h);return['<g transform="',this.getSvgTransform(),'">',g.textBgRects.join(""),"<text ",(this.fontFamily?"font-family=\"'"+this.fontFamily+"'\" ":""),(this.fontSize?'font-size="'+this.fontSize+'" ':""),(this.fontStyle?'font-style="'+this.fontStyle+'" ':""),(this.fontWeight?'font-weight="'+this.fontWeight+'" ':""),(this.textDecoration?'text-decoration="'+this.textDecoration+'" ':""),'style="',this.getSvgStyles(),'" ','transform="translate(',f," ",e,')">',j.join(""),g.textSpans.join(""),"</text>","</g>"].join("")},_getSVGShadows:function(l,k){var n=[];for(var f=0,e=this._shadows.length;f<e;f++){for(var h=0,g=k.length;h<g;h++){var m=(this._boundaries&&this._boundaries[h])?this._boundaries[h].left:0;n.push('<tspan x="',m+this._shadowOffsets[f][0],(h===0?'" y':'" dy'),'="',l+(h===0?this._shadowOffsets[f][1]:0),'" fill="',this._shadows[f].color,'">',k[h],"</tspan>")}}return n},_getSVGTextAndBg:function(k,f,h){var m=[],j=[];for(var g=0,e=h.length;g<e;g++){var l=(this._boundaries&&this._boundaries[g])?this._boundaries[g].left:0;m.push('<tspan x="',l,'" ',(g===0?"y":"dy"),'="',k,'">',h[g],"</tspan>");if(!this.backgroundColor){continue}j.push('<rect fill="',this.backgroundColor,'" x="',f+this._boundaries[g].left,'" y="',(k*g)-this.height/2+(this.lineHeight*2.6),'" width="',this._boundaries[g].width,'" height="',this._boundaries[g].height,'"></rect>')}return{textSpans:m,textBgRects:j}},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 XML=require("o3-xml"),URL=require("url"),HTTP=require("http"),Canvas=require("canvas"),Image=require("canvas").Image;function request(url,encoding,callback){var oURL=URL.parse(url),client=HTTP.createClient(80,oURL.hostname),request=client.request("GET",oURL.pathname,{host:oURL.hostname});client.addListener("error",function(err){if(err.errno===process.ECONNREFUSED){fabric.log("ECONNREFUSED: connection refused to "+client.host+":"+client.port)}else{fabric.log(err.message)}});request.end();request.on("response",function(response){var body="";if(encoding){response.setEncoding(encoding)}response.on("end",function(){callback(body)});response.on("data",function(chunk){if(response.statusCode==200){body+=chunk}})})}fabric.util.loadImage=function(url,callback){request(url,"binary",function(body){var img=new Image();img.src=new Buffer(body,"binary");callback(img)})};fabric.loadSVGFromURL=function(url,callback){url=url.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();request(url,"",function(body){var doc=XML.parseFromString(body);fabric.parseSVGDocument(doc.documentElement,function(results,options){callback(results,options)})})};fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body);callback&&callback()})};fabric.Image.fromObject=function(object,callback){fabric.util.loadImage(object.src,function(img){var oImg=new fabric.Image(img);oImg._initConfig(object);oImg._initFilters(object);callback(oImg)})};fabric.createCanvasForNode=function(width,height){var canvasEl=fabric.document.createElement("canvas"),nodeCanvas=new Canvas(width||600,height||600);canvasEl.style={};canvasEl.width=nodeCanvas.width;canvasEl.height=nodeCanvas.height;var canvas=fabric.Canvas||fabric.StaticCanvas;var fabricCanvas=new canvas(canvasEl);fabricCanvas.contextContainer=nodeCanvas.getContext("2d");fabricCanvas.nodeCanvas=nodeCanvas;return fabricCanvas};fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};if(fabric.Canvas){fabric.Canvas.prototype.createPNGStream}var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(width){origSetWidth.call(this);this.nodeCanvas.width=width;return this};if(fabric.Canvas){fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth}var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(height){origSetHeight.call(this);this.nodeCanvas.height=height;return this};if(fabric.Canvas){fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight}})();
1
+ /*! Fabric.js Copyright 2008-2012, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"0.8.13"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom("<!DOCTYPE html><html><head></head><body></body></html>"),fabric.window=fabric.document.createWindow()),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,this.JSON||(this.JSON={}),function(){function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||"null";return i=u.length===0?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+o+"]":"["+u.join(",")+"]",gap=o,i}if(rep&&typeof rep=="object"){s=rep.length;for(n=0;n<s;n+=1)r=rep[n],typeof r=="string"&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i))}else for(r in a)Object.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i));return i=u.length===0?"{}":gap?"{\n"+gap+u.join(",\n"+gap)+"\n"+o+"}":"{"+u.join(",")+"}",gap=o,i}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(e){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(e){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","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(e,t,n){var r;gap="",indent="";if(typeof n=="number")for(r=0;r<n;r+=1)indent+=" ";else typeof n=="string"&&(indent=n);rep=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return str("",{"":e});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i=="object")for(n in i)Object.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.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,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();var Cufon=function(){function r(e){var t=this.face=e.face;this.glyphs=e.glyphs,this.w=e.w,this.baseSize=parseInt(t["units-per-em"],10),this.family=t["font-family"].toLowerCase(),this.weight=t["font-weight"],this.style=t["font-style"]||"normal",this.viewBox=function(){var e=t.bbox.split(/\s+/),n={minX:parseInt(e[0],10),minY:parseInt(e[1],10),maxX:parseInt(e[2],10),maxY:parseInt(e[3],10)};return n.width=n.maxX-n.minX,n.height=n.maxY-n.minY,n.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")},n}(),this.ascent=-parseInt(t.ascent,10),this.descent=-parseInt(t.descent,10),this.height=-this.ascent+this.descent}function i(){var e={},t={oblique:"italic",italic:"oblique"};this.add=function(t){(e[t.style]||(e[t.style]={}))[t.weight]=t},this.get=function(n,r){var i=e[n]||e[t[n]]||e.normal||e.italic||e.oblique;if(!i)return null;r={normal:400,bold:700}[r]||parseInt(r,10);if(i[r])return i[r];var s={1:1,99:0}[r%100],o=[],u,a;s===undefined&&(s=r>400),r==500&&(r=400);for(var f in i){f=parseInt(f,10);if(!u||f<u)u=f;if(!a||f>a)a=f;o.push(f)}return r<u&&(r=u),r>a&&(r=a),o.sort(function(e,t){return(s?e>r&&t>r?e<t:e>t:e<r&&t<r?e>t:e<t)?-1:1}),i[o[0]]}}function s(){function t(e,t){return e.contains?e.contains(t):e.compareDocumentPosition(t)&16}function n(e){var n=e.relatedTarget;if(!n||t(this,n))return;i(this)}function r(e){i(this)}function i(t){setTimeout(function(){e.replace(t,g.get(t).options,!0)},10)}this.attach=function(e){e.onmouseenter===undefined?(a(e,"mouseover",n),a(e,"mouseout",n)):(a(e,"mouseenter",r),a(e,"mouseleave",r))}}function o(){function n(e){return e.cufid||(e.cufid=++t)}var e={},t=0;this.get=function(t){var r=n(t);return e[r]||(e[r]={})}}function u(e){var t={},r={};this.get=function(n){return t[n]!=undefined?t[n]:e[n]},this.getSize=function(e,t){return r[e]||(r[e]=new n.Size(this.get(e),t))},this.extend=function(e){for(var n in e)t[n]=e[n];return this}}function a(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,function(){return n.call(e,fabric.window.event)})}function f(e,t){var n=g.get(e);return n.options?e:(t.hover&&t.hoverables[e.nodeName.toLowerCase()]&&y.attach(e),n.options=t,e)}function l(e){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]=e.apply(null,arguments)),t[n]}}function c(e,t){t||(t=n.getStyle(e));var r=n.quotedList(t.get("fontFamily").toLowerCase()),i;for(var s=0,o=r.length;s<o;++s){i=r[s];if(E[i])return E[i].get(t.get("fontStyle"),t.get("fontWeight"))}return null}function h(e){return fabric.document.getElementsByTagName(e)}function p(){var e={},t;for(var n=0,r=arguments.length;n<r;++n)for(t in arguments[n])e[t]=arguments[n][t];return e}function d(e,t,r,i,s,o){var u=i.separate;if(u=="none")return w[i.engine].apply(null,arguments);var a=fabric.document.createDocumentFragment(),f,l=t.split(x[u]),c=u=="words";c&&m&&(/^\s/.test(t)&&l.unshift(""),/\s$/.test(t)&&l.push(""));for(var h=0,p=l.length;h<p;++h)f=w[i.engine](e,c?n.textAlign(l[h],r,h,p):l[h],r,i,s,o,h<p-1),f&&a.appendChild(f);return a}function v(e,t){var r,i,s,o;for(var u=f(e,t).firstChild;u;u=s){s=u.nextSibling,o=!1;if(u.nodeType==1){if(!u.firstChild)continue;if(!/cufon/.test(u.className)){arguments.callee(u,t);continue}o=!0}i||(i=n.getStyle(e).extend(t)),r||(r=c(e,i));if(!r)continue;if(o){w[t.engine](r,null,i,t,u,e);continue}var a=u.data;typeof G_vmlCanvasManager!="undefined"&&(a=a.replace(/\r/g,"\n"));if(a==="")continue;var l=d(r,a,i,t,u,e);l?u.parentNode.replaceChild(l,u):u.parentNode.removeChild(u)}}var e=function(){return e.replace.apply(null,arguments)},t=e.DOM={ready:function(){var e=!1,t={loaded:1,complete:1},n=[],r=function(){if(e)return;e=!0;for(var t;t=n.shift();t());};return fabric.document.addEventListener&&(fabric.document.addEventListener("DOMContentLoaded",r,!1),fabric.window.addEventListener("pageshow",r,!1)),!fabric.window.opera&&fabric.document.readyState&&function(){t[fabric.document.readyState]?r():setTimeout(arguments.callee,10)}(),fabric.document.readyState&&fabric.document.createStyleSheet&&function(){try{fabric.document.body.doScroll("left"),r()}catch(e){setTimeout(arguments.callee,1)}}(),a(fabric.window,"load",r),function(t){arguments.length?e?t():n.push(t):r()}}()},n=e.CSS={Size:function(e,t){this.value=parseFloat(e),this.unit=String(e).match(/[a-z%]*$/)[0]||"px",this.convert=function(e){return e/t*this.value},this.convertFrom=function(e){return e/this.value*t},this.toString=function(){return this.value+this.unit}},getStyle:function(e){return new u(e.style)},quotedList:l(function(e){var t=[],n=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,r;while(r=n.exec(e))t.push(r[3]||r[1]);return t}),ready:function(){var e=!1,n=[],r=function(){e=!0;for(var t;t=n.shift();t());},i=Object.prototype.propertyIsEnumerable?h("style"):{length:0},s=h("link");return t.ready(function(){var e=0,t;for(var n=0,o=s.length;t=s[n],n<o;++n)!t.disabled&&t.rel.toLowerCase()=="stylesheet"&&++e;fabric.document.styleSheets.length>=i.length+e?r():setTimeout(arguments.callee,10)}),function(t){e?t():n.push(t)}}(),supports:function(e,t){var n=fabric.document.createElement("span").style;return n[e]===undefined?!1:(n[e]=t,n[e]===t)},textAlign:function(e,t,n,r){return t.get("textAlign")=="right"?n>0&&(e=" "+e):n<r-1&&(e+=" "),e},textDecoration:function(e,t){t||(t=this.getStyle(e));var n={underline:null,overline:null,"line-through":null};for(var r=e;r.parentNode&&r.parentNode.nodeType==1;){var i=!0;for(var s in n){if(n[s])continue;t.get("textDecoration").indexOf(s)!=-1&&(n[s]=t.get("color")),i=!1}if(i)break;t=this.getStyle(r=r.parentNode)}return n},textShadow:l(function(e){if(e=="none")return null;var t=[],n={},r,i=0,s=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;while(r=s.exec(e))r[0]==","?(t.push(n),n={},i=0):r[1]?n.color=r[1]:n[["offX","offY","blur"][i++]]=r[2];return t.push(n),t}),color:l(function(e){var t={};return t.color=e.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(e,n,r){return t.opacity=parseFloat(r),"rgb("+n+")"}),t}),textTransform:function(e,t){return e[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[t.get("textTransform")]||"toString"]()}},m=" ".split(/\s+/).length==0,g=new o,y=new s,b=[],w={},E={},S={engine:null,hover:!1,hoverables:{a:!0},printable:!0,selector:fabric.window.Sizzle||fabric.window.jQuery&&function(e){return jQuery(e)}||fabric.window.dojo&&dojo.query||fabric.window.$$&&function(e){return $$(e)}||fabric.window.$&&function(e){return $(e)}||fabric.document.querySelectorAll&&function(e){return fabric.document.querySelectorAll(e)}||h,separate:"words",textShadow:"none"},x={words:/\s+/,characters:""};return e.now=function(){return t.ready(),e},e.refresh=function(){var t=b.splice(0,b.length);for(var n=0,r=t.length;n<r;++n)e.replace.apply(null,t[n]);return e},e.registerEngine=function(t,n){return n?(w[t]=n,e.set("engine",t)):e},e.registerFont=function(t){var n=new r(t),s=n.family;return E[s]||(E[s]=new i),E[s].add(n),e.set("fontFamily",'"'+s+'"')},e.replace=function(t,r,i){r=p(S,r);if(!r.engine)return e;typeof r.textShadow=="string"&&r.textShadow&&(r.textShadow=n.textShadow(r.textShadow)),i||b.push(arguments);if(t.nodeType||typeof t=="string")t=[t];return n.ready(function(){for(var n=0,i=t.length;n<i;++n){var s=t[n];typeof s=="string"?e.replace(r.selector(s),r,!0):v(s,r)}}),e},e.replaceElement=function(e,t){return t=p(S,t),typeof t.textShadow=="string"&&t.textShadow&&(t.textShadow=n.textShadow(t.textShadow)),v(e,t)},e.engines=w,e.fonts=E,e.getOptions=function(){return p(S)},e.set=function(t,n){return S[t]=n,e},e}();Cufon.registerEngine("canvas",function(){function s(e,t){var n=0,r=0,i=[],s=/([mrvxe])([^a-z]*)/g,o;e:for(var u=0;o=s.exec(e);++u){var a=o[2].split(",");switch(o[1]){case"v":i[u]={m:"bezierCurveTo",a:[n+~~a[0],r+~~a[1],n+~~a[2],r+~~a[3],n+=~~a[4],r+=~~a[5]]};break;case"r":i[u]={m:"lineTo",a:[n+=~~a[0],r+=~~a[1]]};break;case"m":i[u]={m:"moveTo",a:[n=~~a[0],r=~~a[1]]};break;case"x":i[u]={m:"closePath",a:[]};break;case"e":break e}t[i[u].m].apply(t,i[u].a)}return i}function o(e,t){for(var n=0,r=e.length;n<r;++n){var i=e[n];t[i.m].apply(t,i.a)}}var e=Cufon.CSS.supports("display","inline-block"),t=!e&&(fabric.document.compatMode=="BackCompat"||/frameset|transitional/i.test(fabric.document.doctype.publicId)),n=fabric.document.createElement("style");n.type="text/css";var r=fabric.document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(t?"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(e?".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}"+"}");try{n.appendChild(r)}catch(i){n.setAttribute("type","text/css"),n.styleSheet.cssText=r.data}return fabric.document.getElementsByTagName("head")[0].appendChild(n),function(t,n,r,i,u,a){function $(e,t){W.strokeStyle=t,W.beginPath(),W.moveTo(0,e),W.lineTo(N,e),W.stroke()}function Q(){W.save(),W.fillStyle=i.backgroundColor;var e=0,n=0,r=[{left:0}];i.textAlign==="right"?(W.translate(M[n],0),r[0].left=M[n]*X):i.textAlign==="center"&&(W.translate(M[n]/2,0),r[0].left=M[n]/2*X);for(var s=0,o=T.length;s<o;++s){if(T[s]==="\n"){n++;var u=-t.ascent-t.ascent/5*i.lineHeight,a=r[r.length-1],f={left:0};a.width=e*X,a.height=(-t.ascent+t.descent)*X,i.textAlign==="right"?(W.translate(-N,u),W.translate(M[n],0),f.left=M[n]*X):i.textAlign==="center"?(W.translate(-e-M[n-1]/2,u),W.translate(M[n]/2,0),f.left=M[n]/2*X):W.translate(-e,u),r.push(f),e=0;continue}var l=t.glyphs[T[s]]||t.missingGlyph;if(!l)continue;var c=Number(l.w||t.w)+h;i.backgroundColor&&(W.save(),W.translate(0,t.ascent),W.fillRect(0,0,c+10,-t.ascent+t.descent),W.restore()),W.translate(c,0),e+=c,s==o-1&&(r[r.length-1].width=e*X,r[r.length-1].height=(-t.ascent+t.descent)*X)}W.restore(),Cufon.textOptions.boundaries=r}function G(e){W.fillStyle=e||Cufon.textOptions.color||r.get("color");var n=0,u=0;i.textAlign==="right"?W.translate(M[u],0):i.textAlign==="center"&&W.translate(M[u]/2,0);for(var a=0,f=T.length;a<f;++a){if(T[a]==="\n"){u++;var l=-t.ascent-t.ascent/5*i.lineHeight;i.textAlign==="right"?(W.translate(-N,l),W.translate(M[u],0)):i.textAlign==="center"?(W.translate(-n-M[u-1]/2,l),W.translate(M[u]/2,0)):W.translate(-n,l),n=0;continue}var c=t.glyphs[T[a]]||t.missingGlyph;if(!c)continue;var p=Number(c.w||t.w)+h;J&&(W.save(),W.strokeStyle=W.fillStyle,W.lineWidth+=W.lineWidth,W.beginPath(),J.underline&&(W.moveTo(0,-t.face["underline-position"]+.5),W.lineTo(p,-t.face["underline-position"]+.5)),J.overline&&(W.moveTo(0,t.ascent+.5),W.lineTo(p,t.ascent+.5)),J["line-through"]&&(W.moveTo(0,-t.descent+.5),W.lineTo(p,-t.descent+.5)),W.stroke(),W.restore()),K&&(W.save(),W.transform(1,0,-0.25,1,0,0)),W.beginPath(),c.d&&(c.code?o(c.code,W):c.code=s("m"+c.d,W)),W.fill(),i.strokeStyle&&(W.closePath(),W.save(),W.lineWidth=i.strokeWidth,W.strokeStyle=i.strokeStyle,W.stroke(),W.restore()),K&&W.restore(),W.translate(p,0),n+=p}}var f=n===null,l=t.viewBox,c=r.getSize("fontSize",t.baseSize),h=r.get("letterSpacing");h=h=="normal"?0:c.convertFrom(parseInt(h,10));var p=0,d=0,v=0,m=0,g=i.textShadow,y=[];Cufon.textOptions.shadowOffsets=[],Cufon.textOptions.shadows=null;if(g){Cufon.textOptions.shadows=g;for(var b=0,w=g.length;b<w;++b){var E=g[b],S=c.convertFrom(parseFloat(E.offX)),x=c.convertFrom(parseFloat(E.offY));y[b]=[S,x],x<p&&(p=x),S>d&&(d=S),x>v&&(v=x),S<m&&(m=S)}}var T=Cufon.CSS.textTransform(f?u.alt:n,r).split(""),N=0,C=null,k=0,L=1,A=[];for(var b=0,w=T.length;b<w;++b){if(T[b]==="\n"){L++,N>k&&(k=N),A.push(N),N=0;continue}var O=t.glyphs[T[b]]||t.missingGlyph;if(!O)continue;N+=C=Number(O.w||t.w)+h}A.push(N),N=Math.max(k,N);var M=[];for(var b=A.length;b--;)M[b]=N-A[b];if(C===null)return null;d+=l.width-C,m+=l.minX;var _,D;if(f)_=u,D=u.firstChild;else{_=fabric.document.createElement("span"),_.className="cufon cufon-canvas",_.alt=n,D=fabric.document.createElement("canvas"),_.appendChild(D);if(i.printable){var P=fabric.document.createElement("span");P.className="cufon-alt",P.appendChild(fabric.document.createTextNode(n)),_.appendChild(P)}}var H=_.style,B=D.style||{},j=c.convert(l.height-p+v),F=Math.ceil(j),I=F/j;D.width=Math.ceil(c.convert(N+d-m)*I),D.height=F,p+=l.minY,B.top=Math.round(c.convert(p-t.ascent))+"px",B.left=Math.round(c.convert(m))+"px";var q=Math.ceil(c.convert(N*I)),R=q+"px",U=c.convert(t.height),z=(i.lineHeight-1)*c.convert(-t.ascent/5)*(L-1);Cufon.textOptions.width=q,Cufon.textOptions.height=U*L+z,Cufon.textOptions.lines=L,Cufon.textOptions.totalLineHeight=z,e?(H.width=R,H.height=U+"px"):(H.paddingLeft=R,H.paddingBottom=U-1+"px");var W=Cufon.textOptions.context||D.getContext("2d"),X=F/l.height;Cufon.textOptions.fontAscent=t.ascent*X,Cufon.textOptions.boundaries=null;for(var V=Cufon.textOptions.shadowOffsets,b=y.length;b--;)V[b]=[y[b][0]*X,y[b][1]*X];W.save(),W.scale(X,X),W.translate(-m-1/X*D.width/2+(Cufon.fonts[t.family].offsetLeft||0),-p-Cufon.textOptions.height/X/2),W.lineWidth=t.face["underline-thickness"],W.save();var J=Cufon.getTextDecoration(i),K=i.fontStyle==="italic";if(g)for(var b=0,w=g.length;b<w;++b){var E=g[b];W.save(),W.translate.apply(W,y[b]),G(E.color),W.restore()}return W.save(),Q(),G(),W.restore(),W.restore(),W.restore(),_}}()),Cufon.registerEngine("vml",function(){function n(e,t){return r(e,/(?:em|ex|%)$/i.test(t)?"1em":t)}function r(e,t){if(/px$/i.test(t))return parseFloat(t);var n=e.style.left,r=e.runtimeStyle.left;e.runtimeStyle.left=e.currentStyle.left,e.style.left=t;var i=e.style.pixelLeft;return e.style.left=n,e.runtimeStyle.left=r,i}if(!fabric.document.namespaces)return;var e=fabric.document.createElement("canvas");if(e&&e.getContext&&e.getContext.apply)return;fabric.document.namespaces.cvml==null&&fabric.document.namespaces.add("cvml","urn:schemas-microsoft-com:vml");var t=fabric.document.createElement("cvml:shape");t.style.behavior="url(#default#VML)";if(!t.coordsize)return;return t=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(e,t,i,s,o,u,a){var f=t===null;f&&(t=o.alt);var l=e.viewBox,c=i.computedFontSize||(i.computedFontSize=new Cufon.CSS.Size(n(u,i.get("fontSize"))+"px",e.baseSize)),h=i.computedLSpacing;h==undefined&&(h=i.get("letterSpacing"),i.computedLSpacing=h=h=="normal"?0:~~c.convertFrom(r(u,h)));var p,d;if(f)p=o,d=o.firstChild;else{p=fabric.document.createElement("span"),p.className="cufon cufon-vml",p.alt=t,d=fabric.document.createElement("span"),d.className="cufon-vml-canvas",p.appendChild(d);if(s.printable){var v=fabric.document.createElement("span");v.className="cufon-alt",v.appendChild(fabric.document.createTextNode(t)),p.appendChild(v)}a||p.appendChild(fabric.document.createElement("cvml:shape"))}var m=p.style,g=d.style,y=c.convert(l.height),b=Math.ceil(y),w=b/y,E=l.minX,S=l.minY;g.height=b,g.top=Math.round(c.convert(S-e.ascent)),g.left=Math.round(c.convert(E)),m.height=c.convert(e.height)+"px";var x=Cufon.getTextDecoration(s),T=i.get("color"),N=Cufon.CSS.textTransform(t,i).split(""),C=0,k=0,L=null,A,O,M=s.textShadow;for(var _=0,D=0,P=N.length;_<P;++_)A=e.glyphs[N[_]]||e.missingGlyph,A&&(C+=L=~~(A.w||e.w)+h);if(L===null)return null;var H=-E+C+(l.width-L),B=c.convert(H*w),j=Math.round(B),F=H+","+l.height,I,q="r"+F+"nsnf";for(_=0;_<P;++_){A=e.glyphs[N[_]]||e.missingGlyph;if(!A)continue;f?(O=d.childNodes[D],O.firstChild&&O.removeChild(O.firstChild)):(O=fabric.document.createElement("cvml:shape"),d.appendChild(O)),O.stroked="f",O.coordsize=F,O.coordorigin=I=E-k+","+S,O.path=(A.d?"m"+A.d+"xe":"")+"m"+I+q,O.fillcolor=T;var R=O.style;R.width=j,R.height=b;if(M){var U=M[0],z=M[1],W=Cufon.CSS.color(U.color),X,V=fabric.document.createElement("cvml:shadow");V.on="t",V.color=W.color,V.offset=U.offX+","+U.offY,z&&(X=Cufon.CSS.color(z.color),V.type="double",V.color2=X.color,V.offset2=z.offX+","+z.offY),V.opacity=W.opacity||X&&X.opacity||1,O.appendChild(V)}k+=~~(A.w||e.w)+h,++D}return m.width=Math.max(Math.ceil(c.convert(C*w)),0),p}}()),Cufon.getTextDecoration=function(e){return{underline:e.textDecoration==="underline",overline:e.textDecoration==="overline","line-through":e.textDecoration==="line-through"}},typeof exports!="undefined"&&(exports.Cufon=Cufon),fabric.log=function(){},fabric.warn=function(){},typeof console!="undefined"&&(typeof console.log!="undefined"&&console.log.apply&&(fabric.log=function(){return console.log.apply(console,arguments)}),typeof console.warn!="undefined"&&console.warn.apply&&(fabric.warn=function(){return console.warn.apply(console,arguments)})),fabric.Observable={observe:function(e,t){this.__eventListeners||(this.__eventListeners={});if(arguments.length===1)for(var n in e)this.observe(n,e[n]);else this.__eventListeners[e]||(this.__eventListeners[e]=[]),this.__eventListeners[e].push(t)},stopObserving:function(e,t){this.__eventListeners||(this.__eventListeners={}),this.__eventListeners[e]&&fabric.util.removeFromArray(this.__eventListeners[e],t)},fire:function(e,t){this.__eventListeners||(this.__eventListeners={});var n=this.__eventListeners[e];if(!n)return;for(var r=0,i=n.length;r<i;r++)n[r](t||{})}},function(){function e(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e}function t(e,t){return Math.floor(Math.random()*(t-e+1))+e}function r(e){return e*n}function i(e,t){return parseFloat(Number(e).toFixed(t))}function s(){return!1}function o(e){e||(e={});var t=+(new Date),n=e.duration||500,r=t+n,i,s,o=e.onChange||function(){},a=e.abort||function(){return!1},f=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},l="startValue"in e?e.startValue:0,c="endValue"in e?e.endValue:100;byValue=e.byValue||c-l,e.onStart&&e.onStart(),function h(){i=+(new Date),currentTime=i>r?n:i-t,o(f(currentTime,l,byValue,n));if(i>r||a()){e.onComplete&&e.onComplete();return}u(h)}()}function a(e,t,n){if(e){var r=new Image;r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}fabric.util={};var n=Math.PI/180,u=function(){return fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e,t){fabric.window.setTimeout(e,1e3/60)}}();fabric.util.removeFromArray=e,fabric.util.degreesToRadians=r,fabric.util.toFixed=i,fabric.util.getRandomInt=t,fabric.util.falseFunction=s,fabric.util.animate=o,fabric.util.requestAnimFrame=u,fabric.util.loadImage=a}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s<o;s++)i[s]=r.length?t[s][n].apply(t[s],r):t[s][n].call(t[s]);return i}function n(e,t){if(!e||e.length===0)return undefined;var n=e.length-1,r=t?e[n][t]:e[n];if(t)while(n--)e[n][t]>=r&&(r=e[n][t]);else while(n--)e[n]>=r&&(r=e[n]);return r}function r(e,t){if(!e||e.length===0)return undefined;var n=e.length-1,r=t?e[n][t]:e[n];if(t)while(n--)e[n][t]<r&&(r=e[n][t]);else while(n--)e[n]<r&&(r=e[n]);return r}var e=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(this===void 0||this===null)throw new TypeError;var t=Object(this),n=t.length>>>0;if(n===0)return-1;var r=0;arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:r!==0&&r!==1/0&&r!==-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r))));if(r>=n)return-1;var i=r>=0?r:Math.max(n-Math.abs(r),0);for(;i<n;i++)if(i in t&&t[i]===e)return i;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)n in this&&e.call(t,this[n],n,this)}),Array.prototype.map||(Array.prototype.map=function(e,t){var n=[];for(var r=0,i=this.length>>>0;r<i;r++)r in this&&(n[r]=e.call(t,this[r],r,this));return n}),Array.prototype.every||(Array.prototype.every=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&!e.call(t,this[n],n,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e,t){for(var n=0,r=this.length>>>0;n<r;n++)if(n in this&&e.call(t,this[n],n,this))return!0;return!1}),Array.prototype.filter||(Array.prototype.filter=function(e,t){var n=[],r;for(var i=0,s=this.length>>>0;i<s;i++)i in this&&(r=this[i],e.call(t,r,i,this)&&n.push(r));return n}),Array.prototype.reduce||(Array.prototype.reduce=function(e){var t=this.length>>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n<t;n++)n in this&&(r=e.call(null,r,this[n],n,this));return r}),fabric.util.array={invoke:t,min:r,max:n}}(),function(){function e(e,t){for(var n in t)e[n]=t[n];return e}function t(t){return e({},t)}fabric.util.object={extend:e,clone:t}}(),function(){function e(e){return e.replace(/-+(.)?/g,function(e,t){return t?t.toUpperCase():""})}function t(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function n(e){return e.replace("&","&amp;").replace('"',"&quot;").replace("'","&apos;").replace("<","&lt;").replace(">","&gt;")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:e,capitalize:t,escapeXml:n}}(),function(){var e=Array.prototype.slice,t=Function.prototype.apply,n=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var i=this,s=e.call(arguments,1),o;return s.length?o=function(){return t.call(i,this instanceof n?this:r,s.concat(e.call(arguments)))}:o=function(){return t.call(i,this instanceof n?this:r,arguments)},n.prototype=this.prototype,o.prototype=new n,o})}(),function(){function i(){}function s(){function o(){this.initialize.apply(this,arguments)}var n=null,s=e.call(arguments,0);typeof s[0]=="function"&&(n=s.shift()),o.superclass=n,o.subclasses=[],n&&(i.prototype=n.prototype,o.prototype=new i,n.subclasses.push(o));for(var u=0,a=s.length;u<a;u++)r(o,s[u]);return o.prototype.initialize||(o.prototype.initialize=t),o.prototype.constructor=o,o}var e=Array.prototype.slice,t=function(){},n=function(){for(var e in{toString:1})if(e==="toString")return!1;return!0}(),r;n?r=function(e,t){t.toString!==Object.prototype.toString&&(e.prototype.toString=t.toString),t.valueOf!==Object.prototype.valueOf&&(e.prototype.valueOf=t.valueOf);for(var n in t)e.prototype[n]=t[n]}:r=function(e,t){for(var n in t)e.prototype[n]=t[n]},fabric.util.createClass=s}(),function(e){function t(e){var t=Array.prototype.slice.call(arguments,1),n,r,i=t.length;for(r=0;r<i;r++){n=typeof e[t[r]];if(!/^(?:function|object|unknown)$/.test(n))return!1}return!0}function s(e,t){return{handler:t,wrappedHandler:o(e,t)}}function o(e,t){return function(n){t.call(r(e),n||fabric.window.event)}}function u(e,t){return function(n){if(c[e]&&c[e][t]){var r=c[e][t];for(var i=0,s=r.length;i<s;i++)r[i].call(this,n||fabric.window.event)}}}function d(e){return{x:v(e),y:m(e)}}function v(e){var t=fabric.document.documentElement,n=fabric.document.body||{scrollLeft:0};return e.pageX||(typeof e.clientX!="unknown"?e.clientX:0)+(t.scrollLeft||n.scrollLeft)-(t.clientLeft||0)}function m(e){var t=fabric.document.documentElement,n=fabric.document.body||{scrollTop:0};return e.pageY||(typeof e.clientY!="unknown"?e.clientY:0)+(t.scrollTop||n.scrollTop)-(t.clientTop||0)}var n=function(){if(typeof fabric.document.documentElement.uniqueID!="undefined")return function(e){return e.uniqueID};var e=0;return function(t){return t.__uniqueID||(t.__uniqueID="uniqueID__"+e++)}}(),r,i;(function(){var e={};r=function(t){return e[t]},i=function(t,n){e[t]=n}})();var a=t(fabric.document.documentElement,"addEventListener","removeEventListener")&&t(fabric.window,"addEventListener","removeEventListener"),f=t(fabric.document.documentElement,"attachEvent","detachEvent")&&t(fabric.window,"attachEvent","detachEvent"),l={},c={},h,p;a?(h=function(e,t,n){e.addEventListener(t,n,!1)},p=function(e,t,n){e.removeEventListener(t,n,!1)}):f?(h=function(e,t,r){var o=n(e);i(o,e),l[o]||(l[o]={}),l[o][t]||(l[o][t]=[]);var u=s(o,r);l[o][t].push(u),e.attachEvent("on"+t,u.wrappedHandler)},p=function(e,t,r){var i=n(e),s;if(l[i]&&l[i][t])for(var o=0,u=l[i][t].length;o<u;o++)s=l[i][t][o],s&&s.handler===r&&(e.detachEvent("on"+t,s.wrappedHandler),l[i][t][o]=null)}):(h=function(e,t,r){var i=n(e);c[i]||(c[i]={});if(!c[i][t]){c[i][t]=[];var s=e["on"+t];s&&c[i][t].push(s),e["on"+t]=u(i,t)}c[i][t].push(r)},p=function(e,t,r){var i=n(e);if(c[i]&&c[i][t]){var s=c[i][t];for(var o=0,u=s.length;o<u;o++)s[o]===r&&s.splice(o,1)}}),fabric.util.addListener=h,fabric.util.removeListener=p,fabric.isTouchSupported&&(v=function(e){return e.touches&&e.touches[0]&&e.touches[0].pageX},m=function(e){return e.touches&&e.touches[0]&&e.touches[0].pageY}),fabric.util.getPointer=d,fabric.util.object.extend(fabric.util,fabric.Observable)}(this),function(){function e(e,t){var n=e.style,r;if(typeof t=="string")return e.style.cssText+=";"+t,t.indexOf("opacity")>-1?u(e,t.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var i in t)if(i==="opacity")u(e,t[i]);else{var s=i==="float"||i==="cssFloat"?typeof n.styleFloat=="undefined"?"cssFloat":"styleFloat":i;n[s]=t[i]}return e}var t=fabric.document.createElement("div"),n=typeof t.style.opacity=="string",r=typeof t.style.filter=="string",i=fabric.document.defaultView,s=i&&typeof i.getComputedStyle!="undefined",o=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,u=function(e){return e};n?u=function(e,t){return e.style.opacity=t,e}:r&&(u=function(e,t){var n=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(n.zoom=1),o.test(n.filter)?(t=t>=.9999?"":"alpha(opacity="+t*100+")",n.filter=n.filter.replace(o,t)):n.filter+=" alpha(opacity="+t*100+")",e}),fabric.util.setStyle=e}(),function(){function t(e){return typeof e=="string"?fabric.document.getElementById(e):e}function n(t){return e.call(t,0)}function s(e,t){var n=fabric.document.createElement(e);for(var r in t)r==="class"?n.className=t[r]:r==="for"?n.htmlFor=t[r]:n.setAttribute(r,t[r]);return n}function o(e,t){(" "+e.className+" ").indexOf(" "+t+" ")===-1&&(e.className+=(e.className?" ":"")+t)}function u(e,t,n){return typeof t=="string"&&(t=s(t,n)),e.parentNode&&e.parentNode.replaceChild(t,e),t.appendChild(e),t}function a(e){var t=0,n=0;do t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent;while(e);return{left:n,top:t}}var e=Array.prototype.slice;try{var r=n(fabric.document.childNodes)instanceof Array}catch(i){}r||(n=function(e){var t=new Array(e.length),n=e.length;while(n--)t[n]=e[n];return t}),function(){function n(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=fabric.util.falseFunction),t?e.style[t]="none":typeof e.unselectable=="string"&&(e.unselectable="on"),e}function r(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=null),t?e.style[t]="":typeof e.unselectable=="string"&&(e.unselectable=""),e}var e=fabric.document.documentElement.style,t="userSelect"in e?"userSelect":"MozUserSelect"in e?"MozUserSelect":"WebkitUserSelect"in e?"WebkitUserSelect":"KhtmlUserSelect"in e?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=n,fabric.util.makeElementSelectable=r}(),function(){function e(e,t){var n=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),i=!0;r.type="text/javascript",r.setAttribute("runat","server"),r.onload=r.onreadystatechange=function(e){if(i){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")return;i=!1,t(e||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=e,n.appendChild(r)}fabric.util.getScript=e}(),fabric.util.getById=t,fabric.util.toArray=n,fabric.util.makeElement=s,fabric.util.addClass=o,fabric.util.wrapElement=u,fabric.util.getElementOffset=a}(),function(){function e(e,t){return e+(/\?/.test(e)?"&":"?")+t}function n(){}function r(r,i){i||(i={});var s=i.method?i.method.toUpperCase():"GET",o=i.onComplete||function(){},u=t(),a;return u.onreadystatechange=function(){u.readyState===4&&(o(u),u.onreadystatechange=n)},s==="GET"&&(a=null,typeof i.parameters=="string"&&(r=e(r,i.parameters))),u.open(s,r,!0),(s==="POST"||s==="PUT")&&u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(a),u}var t=function(){var e=[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 t=e.length;t--;)try{var n=e[t]();if(n)return e[t]}catch(r){}}();fabric.util.request=r}(),function(){function e(e,t,n,r){return n*(e/=r)*e+t}function t(e,t,n,r){return-n*(e/=r)*(e-2)+t}function n(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function r(e,t,n,r){return n*(e/=r)*e*e+t}function i(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function s(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function o(e,t,n,r){return n*(e/=r)*e*e*e+t}function u(e,t,n,r){return-n*((e=e/r-1)*e*e*e-1)+t}function a(e,t,n,r){return(e/=r/2)<1?n/2*
2
+ e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t}function f(e,t,n,r){return n*(e/=r)*e*e*e*e+t}function l(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t}function c(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t}function h(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t}function p(e,t,n,r){return n*Math.sin(e/r*(Math.PI/2))+t}function d(e,t,n,r){return-n/2*(Math.cos(Math.PI*e/r)-1)+t}function v(e,t,n,r){return e==0?t:n*Math.pow(2,10*(e/r-1))+t}function m(e,t,n,r){return e==r?t+n:n*(-Math.pow(2,-10*e/r)+1)+t}function g(e,t,n,r){return e==0?t:e==r?t+n:(e/=r/2)<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t}function y(e,t,n,r){return-n*(Math.sqrt(1-(e/=r)*e)-1)+t}function b(e,t,n,r){return n*Math.sqrt(1-(e=e/r-1)*e)+t}function w(e,t,n,r){return(e/=r/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t}function E(e,t,n,r){var i=1.70158,s=0,o=n;if(e==0)return t;if((e/=r)==1)return t+n;s||(s=r*.3);if(o<Math.abs(n)){o=n;var i=s/4}else var i=s/(2*Math.PI)*Math.asin(n/o);return-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-i)*2*Math.PI/s))+t}function S(e,t,n,r){var i=1.70158,s=0,o=n;if(e==0)return t;if((e/=r)==1)return t+n;s||(s=r*.3);if(o<Math.abs(n)){o=n;var i=s/4}else var i=s/(2*Math.PI)*Math.asin(n/o);return o*Math.pow(2,-10*e)*Math.sin((e*r-i)*2*Math.PI/s)+n+t}function x(e,t,n,r){var i=1.70158,s=0,o=n;if(e==0)return t;if((e/=r/2)==2)return t+n;s||(s=r*.3*1.5);if(o<Math.abs(n)){o=n;var i=s/4}else var i=s/(2*Math.PI)*Math.asin(n/o);return e<1?-0.5*o*Math.pow(2,10*(e-=1))*Math.sin((e*r-i)*2*Math.PI/s)+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-i)*2*Math.PI/s)*.5+n+t}function T(e,t,n,r,i){return i==undefined&&(i=1.70158),n*(e/=r)*e*((i+1)*e-i)+t}function N(e,t,n,r,i){return i==undefined&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function C(e,t,n,r,i){return i==undefined&&(i=1.70158),(e/=r/2)<1?n/2*e*e*(((i*=1.525)+1)*e-i)+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t}function k(e,t,n,r){return n-L(r-e,0,n,r)+t}function L(e,t,n,r){return(e/=r)<1/2.75?n*7.5625*e*e+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}function A(e,t,n,r){return e<r/2?k(e*2,0,n,r)*.5+t:L(e*2-r,0,n,r)*.5+n*.5+t}fabric.util.ease={},fabric.util.ease={easeInQuad:e,easeOutQuad:t,easeInOutQuad:n,easeInCubic:r,easeOutCubic:i,easeInOutCubic:s,easeInQuart:o,easeOutQuart:u,easeInOutQuart:a,easeInQuint:f,easeOutQuint:l,easeInOutQuint:c,easeInSine:h,easeOutSine:p,easeInOutSine:d,easeInExpo:v,easeOutExpo:m,easeInOutExpo:g,easeInCirc:y,easeOutCirc:b,easeInOutCirc:w,easeInElastic:E,easeOutElastic:S,easeInOutElastic:x,easeInBack:T,easeOutBack:N,easeInOutBack:C,easeInBounce:k,easeOutBounce:L,easeInOutBounce:A}}(),function(e){"use strict";function o(e,r){if(!e)return;var i,o,u={};e.parentNode&&/^g$/i.test(e.parentNode.nodeName)&&(u=t.parseAttributes(e.parentNode,r));var a=r.reduce(function(n,r){return i=e.getAttribute(r),o=parseFloat(i),i&&((r==="fill"||r==="stroke")&&i==="none"&&(i=""),r==="fill-rule"&&(i=i==="evenodd"?"destination-over":i),r==="transform"&&(i=t.parseTransformAttribute(i)),r in s&&(r=s[r]),n[r]=isNaN(o)?i:o),n},{});return a=n(a,n(h(e),t.parseStyleAttribute(e))),n(u,a)}function u(e){if(!e)return null;e=e.trim();var t=e.indexOf(",")>-1;e=e.split(/\s+/);var n=[];if(t)for(var r=0,i=e.length;r<i;r++){var s=e[r].split(",");n.push({x:parseFloat(s[0]),y:parseFloat(s[1])})}else for(var r=0,i=e.length;r<i;r+=2)n.push({x:parseFloat(e[r]),y:parseFloat(e[r+1])});return n.length%2!==0,n}function a(e){var t={},n=e.getAttribute("style");if(n)if(typeof n=="string")n=n.replace(/;$/,"").split(";").forEach(function(e){var n=e.split(":");t[n[0].trim().toLowerCase()]=n[1].trim()});else for(var r in n)typeof n[r]!="undefined"&&(t[r.toLowerCase()]=n[r]);return t}function f(e){var n=t.Canvas.activeInstance,r=n?n.getContext():null;if(!r)return;for(var i=e.length;i--;){var s=e[i].get("fill");if(/^url\(/.test(s)){var o=s.slice(5,s.length-1);t.gradientDefs[o]&&e[i].set("fill",t.Gradient.fromElement(t.gradientDefs[o],r,e[i]))}}}function l(e,n,i){function u(){--o===0&&(s=s.filter(function(e){return e!=null}),f(s),n(s))}var s=Array(e.length),o=e.length;for(var a=0,l,c=e.length;a<c;a++){l=e[a];var h=t[r(l.tagName)];if(h&&h.fromElement)try{h.async?h.fromElement(l,function(e){return function(t){s.splice(e,0,t),u()}}(a),i):(s.splice(a,0,h.fromElement(l,i)),u())}catch(p){t.log(p.message||p)}else u()}}function c(e){var t=e.getElementsByTagName("style"),n={},r;for(var i=0,s=t.length;i<s;i++){var o=t[0].textContent;o=o.replace(/\/\*[\s\S]*?\*\//g,""),r=o.match(/[^{]*\{[\s\S]*?\}/g),r=r.map(function(e){return e.trim()}),r.forEach(function(e){var t=e.match(/([\s\S]*?)\s*\{([^}]*)\}/),e=t[1],r=t[2].trim(),i=r.replace(/;$/,"").split(/\s*;\s*/);n[e]||(n[e]={});for(var s=0,o=i.length;s<o;s++){var u=i[s].split(/\s*:\s*/),a=u[0],f=u[1];n[e][a]=f}})}return n}function h(e){var n=e.nodeName,r=e.getAttribute("class"),i=e.getAttribute("id"),s={};for(var o in t.cssRules){var u=r&&(new RegExp("^\\."+r)).test(o)||i&&(new RegExp("^#"+i)).test(o)||(new RegExp("^"+n)).test(o);if(u)for(var a in t.cssRules[o])s[a]=t.cssRules[o][a]}return s}function d(e,n){function r(r){var i=r.responseXML;!i.documentElement&&t.window.ActiveXObject&&r.responseText&&(i=new ActiveXObject("Microsoft.XMLDOM"),i.async="false",i.loadXML(r.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));if(!i.documentElement)return;t.parseSVGDocument(i.documentElement,function(r,i){p.set(e,{objects:t.util.array.invoke(r,"toObject"),options:i}),n(r,i)})}e=e.replace(/^\n\s*/,"").trim(),p.has(e,function(i){i?p.get(e,function(e){var t=v(e);n(t.objects,t.options)}):new t.util.request(e,{method:"get",onComplete:r})})}function v(e){var n=e.objects,i=e.options;return n=n.map(function(e){return t[r(e.type)].fromObject(e)}),{objects:n,options:i}}function m(e,n){e=e.trim();var r;if(typeof DOMParser!="undefined"){var i=new DOMParser;i&&i.parseFromString&&(r=i.parseFromString(e,"text/xml"))}else if(t.window.ActiveXObject){var r=new ActiveXObject("Microsoft.XMLDOM");r.async="false",r.loadXML(e.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))}t.parseSVGDocument(r.documentElement,function(e,t){n(e,t)})}function g(e){var t="";for(var n=0,r=e.length;n<r;n++){if(e[n].type!=="text"||!e[n].path)continue;t+=["@font-face {","font-family: ",e[n].fontFamily,"; ","src: url('",e[n].path,"')","}"].join("")}return t&&(t=["<defs>",'<style type="text/css">',"<![CDATA[",t,"]]>","</style>","</defs>"].join("")),t}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.string.capitalize,i=t.util.object.clone,s={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};t.parseTransformAttribute=function(){function e(e,t){var n=t[0];e[0]=Math.cos(n),e[1]=Math.sin(n),e[2]=-Math.sin(n),e[3]=Math.cos(n)}function t(e,t){var n=t[0],r=t.length===2?t[1]:t[0];e[0]=n,e[3]=r}function n(e,t){e[2]=t[0]}function r(e,t){e[1]=t[0]}function i(e,t){e[4]=t[0],t.length===2&&(e[5]=t[1])}var s=[1,0,0,1,0,0],o="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",u="(?:\\s+,?\\s*|,\\s*)",a="(?:(skewX)\\s*\\(\\s*("+o+")\\s*\\))",f="(?:(skewY)\\s*\\(\\s*("+o+")\\s*\\))",l="(?:(rotate)\\s*\\(\\s*("+o+")(?:"+u+"("+o+")"+u+"("+o+"))?\\s*\\))",c="(?:(scale)\\s*\\(\\s*("+o+")(?:"+u+"("+o+"))?\\s*\\))",h="(?:(translate)\\s*\\(\\s*("+o+")(?:"+u+"("+o+"))?\\s*\\))",p="(?:(matrix)\\s*\\(\\s*("+o+")"+u+"("+o+")"+u+"("+o+")"+u+"("+o+")"+u+"("+o+")"+u+"("+o+")"+"\\s*\\))",d="(?:"+p+"|"+h+"|"+c+"|"+l+"|"+a+"|"+f+")",v="(?:"+d+"(?:"+u+d+")*"+")",m="^\\s*(?:"+v+"?)\\s*$",g=new RegExp(m),y=new RegExp(d);return function(o){var u=s.concat();return!o||o&&!g.test(o)?u:(o.replace(y,function(s){var o=(new RegExp(d)).exec(s).filter(function(e){return e!==""&&e!=null}),a=o[1],f=o.slice(2).map(parseFloat);switch(a){case"translate":i(u,f);break;case"rotate":e(u,f);break;case"scale":t(u,f);break;case"skewX":n(u,f);break;case"skewY":r(u,f);break;case"matrix":u=f}}),u)}}(),t.parseSVGDocument=function(){function s(e,t){while(e&&(e=e.parentNode))if(t.test(e.nodeName))return!0;return!1}var e=/^(path|circle|polygon|polyline|ellipse|rect|line|image)$/,n="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",r=new RegExp("^\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*"+"$");return function(n,o){if(!n)return;var u=new Date,a=t.util.toArray(n.getElementsByTagName("*"));if(a.length===0){a=n.selectNodes("//*[name(.)!='svg']");var f=[];for(var l=0,h=a.length;l<h;l++)f[l]=a[l];a=f}var p=a.filter(function(t){return e.test(t.tagName)&&!s(t,/^(?:pattern|defs)$/)});if(!p||p&&!p.length)return;var d=n.getAttribute("viewBox"),v=n.getAttribute("width"),m=n.getAttribute("height"),g=null,y=null,b,w;d&&(d=d.match(r))&&(b=parseInt(d[1],10),w=parseInt(d[2],10),g=parseInt(d[3],10),y=parseInt(d[4],10)),g=v?parseFloat(v):g,y=m?parseFloat(m):y;var E={width:g,height:y};t.gradientDefs=t.getGradientDefs(n),t.cssRules=c(n),t.parseElements(p,function(e){t.documentParsingTime=new Date-u,o&&o(e,E)},i(E))}}();var p={has:function(e,t){t(!1)},get:function(e,t){},set:function(e,t){}};n(t,{parseAttributes:o,parseElements:l,parseStyleAttribute:a,parsePointsAttribute:u,getCSSRules:c,loadSVGFromURL:d,loadSVGFromString:m,createSVGFontFacesMarkup:g})}(typeof exports!="undefined"?exports:this),function(){function e(e){var t=e.getAttribute("style");if(t){var n=t.split(/\s*;\s*/);for(var r=n.length;r--;){var i=n[r].split(/\s*:\s*/),s=i[0].trim(),o=i[1].trim();if(s==="stop-color")return o}}}function t(e,t){for(var n in t){if(typeof t[n]=="string"&&/^\d+%$/.test(t[n])){var r=parseFloat(t[n],10);if(n==="x1"||n==="x2")t[n]=e.width*r/100;else if(n==="y1"||n==="y2")t[n]=e.height*r/100}if(n==="x1"||n==="x2")t[n]-=e.width/2;else if(n==="y1"||n==="y2")t[n]-=e.height/2}}function n(e){var t=e.getElementsByTagName("linearGradient"),n=e.getElementsByTagName("radialGradient"),r,i={};for(var s=t.length;s--;)r=t[s],i[r.id]=r;for(var s=n.length;s--;)r=n[s],i[r.id]=r;return i}fabric.Gradient={create:function(e,t){t||(t={});var n=t.x1||0,r=t.y1||0,i=t.x2||e.canvas.width,s=t.y2||0,o=t.colorStops,u=e.createLinearGradient(n,r,i,s);for(var a in o){var f=o[a];u.addColorStop(parseFloat(a),f)}return u},fromElement:function(n,r,i){var s=n.getElementsByTagName("stop"),n,o,u={},a,f={x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0};for(var l=s.length;l--;)n=s[l],o=n.getAttribute("offset"),o=parseFloat(o)/(/%$/.test(o)?100:1),u[o]=e(n)||n.getAttribute("stop-color");return t(i,f),fabric.Gradient.create(r,{x1:f.x1,y1:f.y1,x2:f.x2,y2:f.y2,colorStops:u})},forObject:function(e,n,r){r||(r={}),t(e,r);var i=fabric.Gradient.create(n,{x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,colorStops:r.colorStops});return i}},fabric.getGradientDefs=n}(),function(e){"use strict";function n(e,t){arguments.length>0&&this.init(e,t)}var t=e.fabric||(e.fabric={});if(t.Point){t.warn("fabric.Point is already defined");return}t.Point=n,n.prototype={constructor:n,init:function(e,t){this.x=e,this.y=t},add:function(e){return new n(this.x+e.x,this.y+e.y)},addEquals:function(e){return this.x+=e.x,this.y+=e.y,this},scalarAdd:function(e){return new n(this.x+e,this.y+e)},scalarAddEquals:function(e){return this.x+=e,this.y+=e,this},subtract:function(e){return new n(this.x-e.x,this.y-e.y)},subtractEquals:function(e){return this.x-=e.x,this.y-=e.y,this},scalarSubtract:function(e){return new n(this.x-e,this.y-e)},scalarSubtractEquals:function(e){return this.x-=e,this.y-=e,this},multiply:function(e){return new n(this.x*e,this.y*e)},multiplyEquals:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return new n(this.x/e,this.y/e)},divideEquals:function(e){return this.x/=e,this.y/=e,this},eq:function(e){return this.x==e.x&&this.y==e.y},lt:function(e){return this.x<e.x&&this.y<e.y},lte:function(e){return this.x<=e.x&&this.y<=e.y},gt:function(e){return this.x>e.x&&this.y>e.y},gte:function(e){return this.x>=e.x&&this.y>=e.y},lerp:function(e,t){return new n(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)},distanceFrom:function(e){var t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)},min:function(e){return new n(Math.min(this.x,e.x),Math.min(this.y,e.y))},max:function(e){return new n(Math.max(this.x,e.x),Math.max(this.y,e.y))},toString:function(){return this.x+","+this.y},setXY:function(e,t){this.x=e,this.y=t},setFromPoint:function(e){this.x=e.x,this.y=e.y},swap:function(e){var t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){arguments.length>0&&this.init(e)}var t=e.fabric||(e.fabric={});if(t.Intersection){t.warn("fabric.Intersection is already defined");return}t.Intersection=n,t.Intersection.prototype={init:function(e){this.status=e,this.points=[]},appendPoint:function(e){this.points.push(e)},appendPoints:function(e){this.points=this.points.concat(e)}},t.Intersection.intersectLineLine=function(e,r,i,s){var o,u=(s.x-i.x)*(e.y-i.y)-(s.y-i.y)*(e.x-i.x),a=(r.x-e.x)*(e.y-i.y)-(r.y-e.y)*(e.x-i.x),f=(s.y-i.y)*(r.x-e.x)-(s.x-i.x)*(r.y-e.y);if(f!=0){var l=u/f,c=a/f;0<=l&&l<=1&&0<=c&&c<=1?(o=new n("Intersection"),o.points.push(new t.Point(e.x+l*(r.x-e.x),e.y+l*(r.y-e.y)))):o=new n("No Intersection")}else u==0||a==0?o=new n("Coincident"):o=new n("Parallel");return o},t.Intersection.intersectLinePolygon=function(e,t,r){var i=new n("No Intersection"),s=r.length;for(var o=0;o<s;o++){var u=r[o],a=r[(o+1)%s],f=n.intersectLineLine(e,t,u,a);i.appendPoints(f.points)}return i.points.length>0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n("No Intersection"),i=e.length;for(var s=0;s<i;s++){var o=e[s],u=e[(s+1)%i],a=n.intersectLinePolygon(o,u,t);r.appendPoints(a.points)}return r.points.length>0&&(r.status="Intersection"),r},t.Intersection.intersectPolygonRectangle=function(e,r,i){var s=r.min(i),o=r.max(i),u=new t.Point(o.x,s.y),a=new t.Point(s.x,o.y),f=n.intersectLinePolygon(s,u,e),l=n.intersectLinePolygon(u,o,e),c=n.intersectLinePolygon(o,a,e),h=n.intersectLinePolygon(a,s,e),p=new n("No Intersection");return p.appendPoints(f.points),p.appendPoints(l.points),p.appendPoints(c.points),p.appendPoints(h.points),p.points.length>0&&(p.status="Intersection"),p}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){e?this._tryParsingColor(e):this.setSource([0,0,0,1])}var t=e.fabric||(e.fabric={});if(t.Color){t.warn("fabric.Color is already defined.");return}t.Color=n,t.Color.prototype={_tryParsingColor:function(e){var t=n.sourceFromHex(e);t||(t=n.sourceFromRgb(e)),t&&this.setSource(t)},getSource:function(){return this._source},setSource:function(e){this._source=e},toRgb:function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"},toRgba:function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},toHex:function(){var e=this.getSource(),t=e[0].toString(16);t=t.length==1?"0"+t:t;var n=e[1].toString(16);n=n.length==1?"0"+n:n;var r=e[2].toString(16);return r=r.length==1?"0"+r:r,t.toUpperCase()+n.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var t=this.getSource();return t[3]=e,this.setSource(t),this},toGrayscale:function(){var e=this.getSource(),t=parseInt((e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),10),n=e[3];return this.setSource([t,t,t,n]),this},toBlackWhite:function(e){var t=this.getSource(),n=(t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),r=t[3],e=e||127;return n=Number(n)<Number(e)?0:255,this.setSource([n,n,n,r]),this},overlayWith:function(e){e instanceof n||(e=new n(e));var t=[],r=this.getAlpha(),i=.5,s=this.getSource(),o=e.getSource();for(var u=0;u<3;u++)t.push(Math.round(s[u]*(1-i)+o[u]*i));return t[3]=r,this.setSource(t),this}},t.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/,t.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i,t.Color.fromRgb=function(e){return n.fromSource(n.sourceFromRgb(e))},t.Color.sourceFromRgb=function(e){var t=e.match(n.reRGBa);if(t)return[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10),t[4]?parseFloat(t[4]):1]},t.Color.fromRgba=n.fromRgb,t.Color.fromHex=function(e){return n.fromSource(n.sourceFromHex(e))},t.Color.sourceFromHex=function(e){if(e.match(n.reHex)){var t=e.slice(e.indexOf("#")+1),r=t.length===3,i=r?t.charAt(0)+t.charAt(0):t.substring(0,2),s=r?t.charAt(1)+t.charAt(1):t.substring(2,4),o=r?t.charAt(2)+t.charAt(2):t.substring(4,6);return[parseInt(i,16),parseInt(s,16),parseInt(o,16),1]}},t.Color.fromSource=function(e){var t=new n;return t.setSource(e),t}}(typeof exports!="undefined"?exports:this),function(e){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var t=fabric.util.object.extend,n=fabric.util.getElementOffset,r=fabric.util.removeFromArray,i=fabric.util.removeListener,s=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=function(e,t){t||(t={}),this._initStatic(e,t),fabric.StaticCanvas.activeInstance=this},t(fabric.StaticCanvas.prototype,fabric.Observable),t(fabric.StaticCanvas.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",backgroundImage:"",backgroundImageOpacity:1,backgroundImageStretch:!0,includeDefaultValues:!0,stateful:!0,renderOnAddition:!0,clipTo:null,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(e){},onFpsUpdate:null,_initStatic:function(e,t){this._objects=[],this._createLowerCanvas(e),this._initOptions(t),t.overlayImage&&this.setOverlayImage(t.overlayImage,this.renderAll.bind(this)),t.backgroundImage&&this.setBackgroundImage(t.backgroundImage,this.renderAll.bind(this)),this.calcOffset()},calcOffset:function(){return this._offset=n(this.lowerCanvasEl),this},setOverlayImage:function(e,t){return fabric.util.loadImage(e,function(e){this.overlayImage=e,t&&t()},this)},setBackgroundImage:function(e,t,n){return fabric.util.loadImage(e,function(e){this.backgroundImage=e,n&&n.backgroundOpacity&&(this.backgroundOpacity=n.backgroundOpacity),n&&n.backgroundStretch&&(this.backgroundStretch=n.backgroundStretch),t&&t()},this)},_createCanvasElement:function(){var e=fabric.document.createElement("canvas");e.style||(e.style={});if(!e)throw s;return this._initCanvasElement(e),e},_initCanvasElement:function(e){typeof e.getContext=="undefined"&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement&&G_vmlCanvasManager.initElement(e);if(typeof e.getContext=="undefined")throw s},_initOptions:function(e){for(var t in e)this[t]=e[t];this.width=parseInt(this.lowerCanvasEl.width,10)||0,this.height=parseInt(this.lowerCanvasEl.height,10)||0,this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px"},_createLowerCanvas:function(e){this.lowerCanvasEl=fabric.util.getById(e)||this._createCanvasElement(),this._initCanvasElement(this.lowerCanvasEl),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(e){return this._setDimension("width",e)},setHeight:function(e){return this._setDimension("height",e)},setDimensions:function(e){for(var t in e)this._setDimension(t,e[t]);return this},_setDimension:function(e,t){return this.lowerCanvasEl[e]=t,this.lowerCanvasEl.style[e]=t+"px",this.upperCanvasEl&&(this.upperCanvasEl[e]=t,this.upperCanvasEl.style[e]=t+"px"),this.wrapperEl&&(this.wrapperEl.style[e]=t+"px"),this[e]=t,this.calcOffset(),this.renderAll(),this},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_draw:function(e,t){t&&t.render(e)},add:function(){this._objects.push.apply(this._objects,arguments);for(var e=arguments.length;e--;)this.stateful&&arguments[e].setupState(),arguments[e].setCoords();return this.renderOnAddition&&this.renderAll(),this},insertAt:function(e,t,n){return n?this._objects[t]=e:this._objects.splice(t,0,e),this.stateful&&e.setupState(),e.setCoords(),this.renderAll(),this},getObjects:function(){return this._objects},clearContext:function(e){return e.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.clearContext(this.contextContainer),this.contextTop&&this.clearContext(this.contextTop),this.renderAll(),this},renderAll:function(e){var t=this[e===!0&&this.interactive?"contextTop":"contextContainer"];this.contextTop&&this.clearContext(this.contextTop),(e===!1||typeof e=="undefined")&&this.clearContext(t);var n=this._objects.length,r=this.getActiveGroup(),i=new Date;this.clipTo&&(t.save(),t.beginPath(),this.clipTo(t),t.clip()),t.fillStyle=this.backgroundColor,t.fillRect(0,0,this.width,this.height),typeof this.backgroundImage=="object"&&(t.save(),t.globalAlpha=this.backgroundImageOpacity,this.backgroundImageStretch?t.drawImage(this.backgroundImage,0,0,this.width,this.height):t.drawImage(this.backgroundImage,0,0),t.restore());if(n)for(var s=0;s<n;++s)(!r||r&&this._objects[s]&&!r.contains(this._objects[s]))&&this._draw(t,this._objects[s]);this.clipTo&&t.restore(),r&&this._draw(this.contextTop,r),this.overlayImage&&(this.contextTop||this.contextContainer).drawImage(this.overlayImage,0,0);if(this.onFpsUpdate){var o=new Date-i;this.onFpsUpdate(~~(1e3/o))}return this.fire("after:render"),this},renderTop:function(){this.clearContext(this.contextTop||this.contextContainer),this.overlayImage&&(this.contextTop||this.contextContainer).drawImage(this.overlayImage,0,0),this.selection&&this._groupSelector&&this._drawSelection();var e=this.getActiveGroup();return e&&e.render(this.contextTop),this.fire("after:render"),this},toDataURL:function(e){this.renderAll(!0);var t=(this.upperCanvasEl||this.lowerCanvasEl).toDataURL("image/"+e);return this.renderAll(),t},toDataURLWithMultiplier:function(e,t){var n=this.getWidth(),r=this.getHeight(),i=n*t,s=r*t,o=this.getActiveObject();this.setWidth(i).setHeight(s),this.contextTop.scale(t,t),o&&this.deactivateAll(),this.width=n,this.height=r,this.renderAll(!0);var u=this.toDataURL(e);return this.contextTop.scale(1/t,1/t),this.setWidth(n).setHeight(r),o&&this.setActiveObject(o),this.renderAll(),u},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(e){return e.set("left",this.getCenter().left),this.renderAll(),this},centerObjectV:function(e){return e.set("top",this.getCenter().top),this.renderAll(),this},centerObject:function(e){return this.centerObjectH(e).centerObjectV(e)},toDatalessJSON:function(){return this.toDatalessObject()},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(e){var t={objects:this._objects.map(function(t){if(!this.includeDefaultValues){var n=t.includeDefaultValues;t.includeDefaultValues=!1}var r=t[e]();return this.includeDefaultValues||(t.includeDefaultValues=n),r},this),background:this.backgroundColor};return this.backgroundImage&&(t.backgroundImage=this.backgroundImage.src,t.backgroundImageOpacity=this.backgroundImageOpacity,t.backgroundImageStretch=this.backgroundImageStretch),t},toSVG:function(){var e=['<?xml version="1.0" standalone="no" ?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ','"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',"<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',this.width,'" ','height="',this.height,'" ','xml:space="preserve">',"<desc>Created with Fabric.js ",fabric.version,"</desc>",fabric.createSVGFontFacesMarkup(this.getObjects())];this.backgroundImage&&e.push('<image x="0" y="0" ','width="',this.width,'" height="',this.height,'" preserveAspectRatio="',this.backgroundImageStretch?"none":"defer",'" xlink:href="',this.backgroundImage.src,'" style="opacity:',this.backgroundImageOpacity,'"></image>');for(var t=0,n=this.getObjects(),r=n.length;t<r;t++)e.push(n[t].toSVG());return e.push("</svg>"),e.join("")},isEmpty:function(){return this._objects.length===0},remove:function(e){return r(this._objects,e),this.getActiveObject()===e&&this.discardActiveObject(),this.renderAll(),e},sendToBack:function(e){return r(this._objects,e),this._objects.unshift(e),this.renderAll()},bringToFront:function(e){return r(this._objects,e),this._objects.push(e),this.renderAll()},sendBackwards:function(e){var t=this._objects.indexOf(e),n=t;if(t!==0){for(var i=t-1;i>=0;--i)if(e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])){n=i;break}r(this._objects,e),this._objects.splice(n,0,e)}return this.renderAll()},bringForward:function(e){var t=this.getObjects(),n=t.indexOf(e),i=n;if(n!==t.length-1){for(var s=n+1,o=this._objects.length;s<o;++s)if(e.intersectsWithObject(t[s])||e.isContainedWithinObject(this._objects[s])){i=s;break}r(t,e),t.splice(i,0,e)}this.renderAll()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)},forEachObject:function(e,t){var n=this.getObjects(),r=n.length;while(r--)e.call(t,n[r],r,n);return this},dispose:function(){return this.clear(),this.interactive&&(i(this.upperCanvasEl,"mousedown",this._onMouseDown),i(this.upperCanvasEl,"mousemove",this._onMouseMove),i(fabric.window,"resize",this._onResize)),this},_resizeImageToFit:function(e){var t=e.width||e.offsetWidth,n=this.getWidth()/t;t&&(e.width=t*n)}}),fabric.StaticCanvas.prototype.toString=function(){return"#<fabric.Canvas ("+this.complexity()+"): "+"{ objects: "+this.getObjects().length+" }>"},t(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;a<i;a++)for(f=0;f<s;f++)o=a*4*s+f*4,u=(r[o]+r[o+1]+r[o+2])/3,r[o]=u,r[o+1]=u,r[o+2]=u;t.putImageData(n,0,0)},supports:function(e){var t=fabric.document.createElement("canvas");typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(t);if(!t||!t.getContext)return null;var n=t.getContext("2d");if(!n)return null;switch(e){case"getImageData":return typeof n.getImageData!="undefined";case"toDataURL":return typeof t.toDataURL!="undefined";default:return null}}}),fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject}(typeof exports!="undefined"?exports:this),function(){function d(){}var e=fabric.util.object.extend,t=fabric.util.getPointer,n=fabric.util.addListener,r=fabric.util.removeListener,i={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"},s=fabric.util.array.min,o=fabric.util.array.max,u=Math.sqrt,a=Math.pow,f=Math.atan2,l=Math.abs,c=Math.min,h=Math.max,p=.5;fabric.Canvas=function(e,t){t||(t={}),this._initStatic(e,t),this._initInteractive(),fabric.Canvas.activeInstance=this},d.prototype=fabric.StaticCanvas.prototype,fabric.Canvas.prototype=new d;var v={interactive:!0,selection:!0,selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,freeDrawingColor:"rgb(0, 0, 0)",freeDrawingLineWidth:1,HOVER_CURSOR:"move",CURSOR:"default",ROTATION_CURSOR:"crosshair",CONTAINER_CLASS:"canvas-container",_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._freeDrawingXPoints=[],this._freeDrawingYPoints=[],this._initWrapperElement(),this._createUpperCanvas(),this._initEvents(),this.calcOffset()},_initEvents:function(){var e=this;this._onMouseDown=function(t){e.__onMouseDown(t),n(fabric.document,"mouseup",e._onMouseUp),fabric.isTouchSupported&&n(fabric.document,"touchend",e._onMouseUp),n(fabric.document,"mousemove",e._onMouseMove),fabric.isTouchSupported&&n(fabric.document,"touchmove",e._onMouseMove),r(e.upperCanvasEl,"mousemove",e._onMouseMove),fabric.isTouchSupported&&r(e.upperCanvasEl,"touchmove",e._onMouseMove)},this._onMouseUp=function(t){e.__onMouseUp(t),r(fabric.document,"mouseup",e._onMouseUp),fabric.isTouchSupported&&r(fabric.document,"touchend",e._onMouseUp),r(fabric.document,"mousemove",e._onMouseMove),fabric.isTouchSupported&&r(fabric.document,"touchmove",e._onMouseMove),n(e.upperCanvasEl,"mousemove",e._onMouseMove),fabric.isTouchSupported&&n(e.upperCanvasEl,"touchmove",e._onMouseMove)},this._onMouseMove=function(t){t.preventDefault&&t.preventDefault(),e.__onMouseMove(t)},this._onResize=function(t){e.calcOffset()},n(fabric.window,"resize",this._onResize),fabric.isTouchSupported?(n(this.upperCanvasEl,"touchstart",this._onMouseDown),n(this.upperCanvasEl,"touchmove",this._onMouseMove)):(n(this.upperCanvasEl,"mousedown",this._onMouseDown),n(this.upperCanvasEl,"mousemove",this._onMouseMove))},__onMouseUp:function(e){if(this.isDrawingMode&&this._isCurrentlyDrawing){this._finalizeDrawingPath();return}if(this._currentTransform){var t=this._currentTransform,n=t.target;n._scaling&&(n._scaling=!1);var r=this._objects.length;while(r--)this._objects[r].setCoords();this.stateful&&n.hasStateChanged()&&(n.isMoving=!1,this.fire("object:modified",{target:n}))}this._currentTransform=null,this._groupSelector&&this._findSelectedObjects(e);var i=this.getActiveGroup();i&&(i.setObjectsCoords(),i.set("isMoving",!1),this._setCursor(this.CURSOR)),this._groupSelector=null,this.renderAll(),this._setCursorFromEvent(e,n),this._setCursor("");var s=this;setTimeout(function(){s._setCursorFromEvent(e,n)},50),this.fire("mouse:up",{target:n,e:e})},__onMouseDown:function(e){var t="which"in e?e.which==1:e.button==1;if(!t&&!fabric.isTouchSupported)return;if(this.isDrawingMode){this._prepareForDrawing(e),this._captureDrawingPath(e);return}if(this._currentTransform)return;var n=this.findTarget(e),r=this.getPointer(e),i=this.getActiveGroup(),s;if(this._shouldClearSelection(e))this._groupSelector={ex:r.x,ey:r.y,top:0,left:0},this.deactivateAllWithDispatch();else{this.stateful&&n.saveState(),(s=n._findTargetCorner(e,this._offset))&&this.onBeforeScaleRotate(n),this._setupCurrentTransform(e,n);var o=e.shiftKey&&(i||this.getActiveObject())&&this.selection;o?this._handleGroupLogic(e,n):(n!==this.getActiveGroup()&&this.deactivateAll(),this.setActiveObject(n,e))}this.renderAll(),this.fire("mouse:down",{target:n,e:e})},__onMouseMove:function(e){if(this.isDrawingMode){this._isCurrentlyDrawing&&this._captureDrawingPath(e);return}var n=this._groupSelector;if(n!==null){var r=t(e);n.left=r.x-this._offset.left-n.ex,n.top=r.y-this._offset.top-n.ey,this.renderTop()}else if(!this._currentTransform){var i=this.upperCanvasEl.style,s=this.findTarget(e);if(!s){for(var o=this._objects.length;o--;)this._objects[o]&&!this._objects[o].active&&this._objects[o].setActive(!1);i.cursor=this.CURSOR}else this._setCursorFromEvent(e,s),s.isActive()&&s.setCornersVisibility&&s.setCornersVisibility(!0)}else{var r=t(e),u=r.x,a=r.y;this._currentTransform.target.isMoving=!0,this._currentTransform.action==="rotate"?(e.shiftKey||(this._rotateObject(u,a),this.fire("object:rotating",{target:this._currentTransform.target})),this._currentTransform.target.hasRotatingPoint||(this._scaleObject(u,a),this.fire("object:scaling",{target:this._currentTransform.target}))):this._currentTransform.action==="scale"?(this._scaleObject(u,a),this.fire("object:scaling",{target:this._currentTransform.target})):this._currentTransform.action==="scaleX"?(this._scaleObject(u,a,"x"),this.fire("object:scaling",{target:this._currentTransform.target})):this._currentTransform.action==="scaleY"?(this._scaleObject(u,a,"y"),this.fire("object:scaling",{target:this._currentTransform.target})):(this._translateObject(u,a),this.fire("object:moving",{target:this._currentTransform.target})),this.renderAll()}this.fire("mouse:move",{target:s,e:e})},containsPoint:function(e,t){var n=this.getPointer(e),r=this._normalizePointer(t,n),i=r.x,s=r.y,o=t._getImageLines(t.oCoords),u=t._findCrossPoints(i,s,o);return u&&u%2===1||t._findTargetCorner(e,this._offset)?!0:!1},_normalizePointer:function(e,t){var n=this.getActiveGroup(),r=t.x,i=t.y,s=n&&e.type!=="group"&&n.contains(e);return s&&(r-=n.left,i-=n.top),{x:r,y:i}},_shouldClearSelection:function(e){var t=this.findTarget(e),n=this.getActiveGroup();return!t||t&&n&&!n.contains(t)&&n!==t&&!e.shiftKey},_setupCurrentTransform:function(e,n){var r="drag",i,s=t(e);if(i=n._findTargetCorner(e,this._offset))r=i==="ml"||i==="mr"?"scaleX":i==="mt"||i==="mb"?"scaleY":i==="mtr"||i==="mbr"?"rotate":n.hasRotatingPoint?"scale":"rotate";this._currentTransform={target:n,action:r,scaleX:n.scaleX,scaleY:n.scaleY,offsetX:s.x-n.left,offsetY:s.y-n.top,ex:s.x,ey:s.y,left:n.left,top:n.top,theta:n.theta,width:n.width*n.scaleX}
3
+ ,this._currentTransform.original={left:n.left,top:n.top}},_handleGroupLogic:function(e,t){if(t.isType("group")){t=this.findTarget(e,!0);if(!t||t.isType("group"))return}var n=this.getActiveGroup();if(n)n.contains(t)?(n.remove(t),t.setActive(!1),n.size()===1&&this.discardActiveGroup()):n.add(t),this.fire("selection:created",{target:n,e:e}),n.setActive(!0);else{if(this._activeObject&&t!==this._activeObject){var r=new fabric.Group([this._activeObject,t]);this.setActiveGroup(r),n=this.getActiveGroup()}t.setActive(!0)}n&&n.saveCoords()},_prepareForDrawing:function(e){this._isCurrentlyDrawing=!0,this.discardActiveObject().renderAll();var t=this.getPointer(e);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0,this._freeDrawingXPoints.push(t.x),this._freeDrawingYPoints.push(t.y),this.contextTop.beginPath(),this.contextTop.moveTo(t.x,t.y),this.contextTop.strokeStyle=this.freeDrawingColor,this.contextTop.lineWidth=this.freeDrawingLineWidth,this.contextTop.lineCap=this.contextTop.lineJoin="round"},_captureDrawingPath:function(e){var t=this.getPointer(e);this._freeDrawingXPoints.push(t.x),this._freeDrawingYPoints.push(t.y),this.contextTop.lineTo(t.x,t.y),this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath(),this._isCurrentlyDrawing=!1;var e=s(this._freeDrawingXPoints),t=s(this._freeDrawingYPoints),n=o(this._freeDrawingXPoints),r=o(this._freeDrawingYPoints),i=this.contextTop,u=[],a,f,l=this._freeDrawingXPoints,c=this._freeDrawingYPoints;u.push("M ",l[0]-e," ",c[0]-t," ");for(var h=1;a=l[h],f=c[h];h++)u.push("L ",a-e," ",f-t," ");u=u.join("");if(u==="M 0 0 L 0 0 ")return;var p=new fabric.Path(u);p.fill=null,p.stroke=this.freeDrawingColor,p.strokeWidth=this.freeDrawingLineWidth,this.add(p),p.set("left",e+(n-e)/2).set("top",t+(r-t)/2).setCoords(),this.renderAll(),this.fire("path:created",{path:p})},_translateObject:function(e,t){var n=this._currentTransform.target;n.lockMovementX||n.set("left",e-this._currentTransform.offsetX),n.lockMovementY||n.set("top",t-this._currentTransform.offsetY)},_scaleObject:function(e,t,n){var r=this._currentTransform,i=this._offset,s=r.target;if(s.lockScalingX&&s.lockScalingY)return;var o=u(a(r.ey-r.top-i.top,2)+a(r.ex-r.left-i.left,2)),f=u(a(t-r.top-i.top,2)+a(e-r.left-i.left,2));s._scaling=!0,n?n==="x"&&!s.lockUniScaling?s.lockScalingX||s.set("scaleX",r.scaleX*f/o):n==="y"&&!s.lockUniScaling&&(s.lockScalingY||s.set("scaleY",r.scaleY*f/o)):(s.lockScalingX||s.set("scaleX",r.scaleX*f/o),s.lockScalingY||s.set("scaleY",r.scaleY*f/o))},_rotateObject:function(e,t){var n=this._currentTransform,r=this._offset;if(n.target.lockRotation)return;var i=f(n.ey-n.top-r.top,n.ex-n.left-r.left),s=f(t-n.top-r.top,e-n.left-r.left);n.target.set("theta",s-i+n.theta)},_setCursor:function(e){this.upperCanvasEl.style.cursor=e},_setCursorFromEvent:function(e,t){var n=this.upperCanvasEl.style;if(!t)return n.cursor=this.CURSOR,!1;var r=this.getActiveGroup(),s=!!t._findTargetCorner&&(!r||!r.contains(t))&&t._findTargetCorner(e,this._offset);if(!s)n.cursor=this.HOVER_CURSOR;else if(s in i)n.cursor=i[s];else{if(s!=="mtr"&&s!=="mbr")return n.cursor=this.CURSOR,!1;n.cursor=this.ROTATION_CURSOR}return!0},_drawSelection:function(){var e=this._groupSelector,t=e.left,n=e.top,r=l(t),i=l(n);this.contextTop.fillStyle=this.selectionColor,this.contextTop.fillRect(e.ex-(t>0?0:-t),e.ey-(n>0?0:-n),r,i),this.contextTop.lineWidth=this.selectionLineWidth,this.contextTop.strokeStyle=this.selectionBorderColor,this.contextTop.strokeRect(e.ex+p-(t>0?0:r),e.ey+p-(n>0?0:i),r,i)},_findSelectedObjects:function(e){var t,n,r=[],i=this._groupSelector.ex,s=this._groupSelector.ey,o=i+this._groupSelector.left,u=s+this._groupSelector.top,a,f=new fabric.Point(c(i,o),c(s,u)),l=new fabric.Point(h(i,o),h(s,u));for(var p=0,d=this._objects.length;p<d;++p){a=this._objects[p];if(!a)continue;(a.intersectsWithRect(f,l)||a.isContainedWithinRect(f,l))&&this.selection&&a.selectable&&(a.setActive(!0),r.push(a))}if(r.length===1)this.setActiveObject(r[0],e);else if(r.length>1){var r=new fabric.Group(r);this.setActiveGroup(r),r.saveCoords(),this.fire("selection:created",{target:r})}this.renderAll()},findTarget:function(e,t){var n,r=this.getPointer(e),i=this.getActiveGroup();if(i&&!t&&this.containsPoint(e,i))return n=i,n;for(var s=this._objects.length;s--;)if(this._objects[s]&&this.containsPoint(e,this._objects[s])){n=this._objects[s],this.relatedTarget=n;break}if(n&&n.selectable)return n},getPointer:function(e){var n=t(e);return{x:n.x-this._offset.left,y:n.y-this._offset.top}},_createUpperCanvas:function(){this.upperCanvasEl=this._createCanvasElement(),this.upperCanvasEl.className="upper-canvas",this.wrapperEl.appendChild(this.upperCanvasEl),this._applyCanvasStyle(this.upperCanvasEl),this.contextTop=this.upperCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"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(e){var t=this.getWidth()||e.width,n=this.getHeight()||e.height;fabric.util.setStyle(e,{position:"absolute",width:t+"px",height:n+"px",left:0,top:0}),e.width=t,e.height=n,fabric.util.makeElementUnselectable(e)},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},setActiveObject:function(e,t){return this._activeObject&&this._activeObject.setActive(!1),this._activeObject=e,e.setActive(!0),this.renderAll(),this.fire("object:selected",{target:e,e:t}),this},getActiveObject:function(){return this._activeObject},discardActiveObject:function(){return this._activeObject&&this._activeObject.setActive(!1),this._activeObject=null,this},setActiveGroup:function(e){return this._activeGroup=e,this},getActiveGroup:function(){return this._activeGroup},discardActiveGroup:function(){var e=this.getActiveGroup();return e&&e.destroy(),this.setActiveGroup(null)},deactivateAll:function(){var e=this.getObjects(),t=0,n=e.length;for(;t<n;t++)e[t].setActive(!1);return this.discardActiveGroup(),this.discardActiveObject(),this},deactivateAllWithDispatch:function(){var e=this.getActiveGroup()||this.getActiveObject();return e&&this.fire("before:selection:cleared",{target:e}),this.deactivateAll(),e&&this.fire("selection:cleared"),this}};fabric.Canvas.prototype.toString=fabric.StaticCanvas.prototype.toString,e(fabric.Canvas.prototype,v);for(var m in fabric.StaticCanvas)m!=="prototype"&&(fabric.Canvas[m]=fabric.StaticCanvas[m]);fabric.isTouchSupported&&(fabric.Canvas.prototype._setCursorFromEvent=function(){}),fabric.Element=fabric.Canvas}(),fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(t){e.set("left",t),s.renderAll(),i()},onComplete:function(){e.setCoords(),r()}}),this},fxCenterObjectV:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(t){e.set("top",t),s.renderAll(),i()},onComplete:function(){e.setCoords(),r()}}),this},fxRemove:function(e,t){t=t||{};var n=function(){},r=t.onComplete||n,i=t.onChange||n,s=this;return fabric.util.animate({startValue:e.get("opacity"),endValue:0,duration:this.FX_DURATION,onStart:function(){e.setActive(!1)},onChange:function(t){e.set("opacity",t),s.renderAll(),i()},onComplete:function(){s.remove(e),r()}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(e,t){if(!e)return;var n=typeof e=="string"?JSON.parse(e):e;if(!n||n&&!n.objects)return;this.clear(),this.backgroundColor=n.background,this._enlivenDatalessObjects(n.objects,t)},_enlivenDatalessObjects:function(e,t){function n(e,n){r.insertAt(e,n,!0),e.setCoords(),++i===s&&t&&t()}var r=this,i=0,s=e.length;s===0&&t&&t();try{e.forEach(function(e,t){var r=e.paths?"paths":"path",i=e[r];delete e[r];if(typeof i!="string")switch(e.type){case"image":fabric[fabric.util.string.capitalize(e.type)].fromObject(e,function(e){n(e,t)});break;default:var s=fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e.type))];s&&s.fromObject&&(i&&(e[r]=i),n(s.fromObject(e),t))}else if(e.type==="image")fabric.util.loadImage(i,function(r){var s=new fabric.Image(r);s.setSourcePath(i),fabric.util.object.extend(s,e),s.setAngle(e.angle),n(s,t)});else if(e.type==="text"){e.path=i;var o=fabric.Text.fromObject(e),u=function(){Object.prototype.toString.call(fabric.window.opera)==="[object Opera]"?setTimeout(function(){n(o,t)},500):n(o,t)};fabric.util.getScript(i,u)}else fabric.loadSVGFromURL(i,function(r,s){if(r.length>1)var o=new fabric.PathGroup(r,e);else var o=r[0];o.setSourcePath(i),o instanceof fabric.PathGroup||(fabric.util.object.extend(o,e),typeof e.angle!="undefined"&&o.setAngle(e.angle)),n(o,t)})},this)}catch(o){fabric.log(o.message)}},loadFromJSON:function(e,t){if(!e)return;var n=JSON.parse(e);if(!n||n&&!n.objects)return;this.clear();var r=this;return this._enlivenObjects(n.objects,function(){r.backgroundColor=n.background,n.backgroundImage&&(r.setBackgroundImage(n.backgroundImage),r.backgroundImageOpacity=n.backgroundImageOpacity,r.backgroundImageStretch=n.backgroundImageStretch),t&&t()}),this},_enlivenObjects:function(e,t){var n=0,r=e.filter(function(e){return e.type==="image"}).length,i=this;e.forEach(function(e,s){if(!e.type)return;switch(e.type){case"image":case"font":fabric[fabric.util.string.capitalize(e.type)].fromObject(e,function(e){i.insertAt(e,s,!0),++n===r&&t&&t()});break;default:var o=fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e.type))];o&&o.fromObject&&i.insertAt(o.fromObject(e),s,!0)}}),r===0&&t&&t()},_toDataURL:function(e,t){this.clone(function(n){t(n.toDataURL(e))})},_toDataURLWithMultiplier:function(e,t,n){this.clone(function(r){n(r.toDataURLWithMultiplier(e,t))})},clone:function(e){var t=JSON.stringify(this);this.cloneWithoutData(function(n){n.loadFromJSON(t,function(){e&&e(n)})})},cloneWithoutData:function(e){var t=fabric.document.createElement("canvas");t.width=this.getWidth(),t.height=this.getHeight();var n=this.__clone||(this.__clone=new fabric.Canvas(t));n.clipTo=this.clipTo,e&&e(n)}}),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.object.clone,i=t.util.toFixed,s=t.util.string.capitalize,o=t.util.getPointer,u=t.util.degreesToRadians,a=Array.prototype.slice;if(t.Object)return;t.Object=t.util.createClass({type:"object",includeDefaultValues:!0,NUM_FRACTION_DIGITS:2,MIN_SCALE_LIMIT:.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:!1,flipY:!1,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:.4,borderScaleFactor:1,transformMatrix:null,selectable:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!1,callSuper:function(e){var t=this.constructor.superclass.prototype[e];return arguments.length>1?t.apply(this,a.call(arguments,1)):t.call(this)},initialize:function(e){e&&this.setOptions(e)},setOptions:function(e){var t=this.stateProperties.length,n;while(t--)n=this.stateProperties[t],n in e&&this.set(n,e[n])},transform:function(e){e.globalAlpha=this.opacity,e.translate(this.left,this.top),e.rotate(this.theta),e.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var e={type:this.type,left:i(this.left,this.NUM_FRACTION_DIGITS),top:i(this.top,this.NUM_FRACTION_DIGITS),width:i(this.width,this.NUM_FRACTION_DIGITS),height:i(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:i(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:i(this.scaleY,this.NUM_FRACTION_DIGITS),angle:i(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:i(this.opacity,this.NUM_FRACTION_DIGITS),selectable:this.selectable,hasControls:this.hasControls,hasBorders:this.hasBorders,hasRotatingPoint:this.hasRotatingPoint};return this.includeDefaultValues||(e=this._removeDefaultValues(e)),e},toDatalessObject:function(){return this.toObject()},getSvgStyles:function(){return["stroke: ",this.stroke?this.stroke:"none","; ","stroke-width: ",this.strokeWidth?this.strokeWidth:"0","; ","fill: ",this.fill?this.fill:"none","; ","opacity: ",this.opacity?this.opacity:"1",";"].join("")},getSvgTransform:function(){var e=this.getAngle();return["translate(",i(this.left,2)," ",i(this.top,2),")",e!==0?" rotate("+i(e,2)+")":"",this.scaleX===1&&this.scaleY===1?"":" scale("+i(this.scaleX,2)+" "+i(this.scaleY,2)+")"].join("")},_removeDefaultValues:function(e){var n=t.Object.prototype.options;return n&&this.stateProperties.forEach(function(t){e[t]===n[t]&&delete e[t]}),e},isActive:function(){return!!this.active},setActive:function(e){return this.active=!!e,this},toString:function(){return"#<fabric."+s(this.type)+">"},set:function(e,t){var n=(e==="scaleX"||e==="scaleY")&&t<this.MIN_SCALE_LIMIT;n&&(t=this.MIN_SCALE_LIMIT);if(typeof e=="object")for(var r in e)this.set(r,e[r]);else e==="angle"?this.setAngle(t):this[e]=t;return this},toggle:function(e){var t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this},setSourcePath:function(e){return this.sourcePath=e,this},get:function(e){return e==="angle"?this.getAngle():this[e]},render:function(e,t){if(this.width===0||this.height===0)return;e.save();var n=this.transformMatrix;n&&e.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]),t||this.transform(e),this.stroke&&(e.lineWidth=this.strokeWidth,e.strokeStyle=this.stroke),this.overlayFill?e.fillStyle=this.overlayFill:this.fill&&(e.fillStyle=this.fill),this._render(e,t),this.active&&!t&&(this.drawBorders(e),this.hideCorners||this.drawCorners(e)),e.restore()},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},scale:function(e){return this.scaleX=e,this.scaleY=e,this},scaleToWidth:function(e){return this.scale(e/this.width)},scaleToHeight:function(e){return this.scale(e/this.height)},setOpacity:function(e){return this.set("opacity",e),this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(e){return this.theta=e/180*Math.PI,this.angle=e,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 e=Math.cos(this._angle+this.theta)*this._hypotenuse,t=Math.sin(this._angle+this.theta)*this._hypotenuse,n=this.theta,r=Math.sin(n),i=Math.cos(n),s={x:this.left-e,y:this.top-t},o={x:s.x+this.currentWidth*i,y:s.y+this.currentWidth*r},u={x:o.x-this.currentHeight*r,y:o.y+this.currentHeight*i},a={x:s.x-this.currentHeight*r,y:s.y+this.currentHeight*i},f={x:s.x-this.currentHeight/2*r,y:s.y+this.currentHeight/2*i},l={x:s.x+this.currentWidth/2*i,y:s.y+this.currentWidth/2*r},c={x:o.x-this.currentHeight/2*r,y:o.y+this.currentHeight/2*i},h={x:a.x+this.currentWidth/2*i,y:a.y+this.currentWidth/2*r},p={x:s.x+this.currentWidth/2*i,y:s.y+this.currentWidth/2*r},d={x:s.x+this.currentWidth/2*i,y:s.y+this.currentWidth/2*r};return this.oCoords={tl:s,tr:o,br:u,bl:a,ml:f,mt:l,mr:c,mb:h,mtr:p,mbr:d},this._setCornerCoords(),this},drawBorders:function(e){if(!this.hasBorders)return;var t=this.padding,n=t*2;e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=this.borderColor;var r=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX),i=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);e.lineWidth=1/this.borderScaleFactor,e.scale(r,i);var s=this.getWidth(),o=this.getHeight();e.strokeRect(~~(-(s/2)-t)+.5,~~(-(o/2)-t)+.5,~~(s+n),~~(o+n));if(this.hasRotatingPoint&&!this.hideCorners&&!this.lockRotation){var u=-o/2,a=-s/2;e.beginPath(),e.moveTo(0,u),e.lineTo(0,u-40),e.closePath(),e.stroke()}return e.restore(),this},drawCorners:function(e){if(!this.hasControls)return;var t=this.cornersize,n=t/2,r=this.padding,i=-(this.width/2),s=-(this.height/2),o,u,a=t/this.scaleX,f=t/this.scaleY,l=(r+n)/this.scaleY,c=(r+n)/this.scaleX,h=(r+n-t)/this.scaleX,p=(r+n-t)/this.scaleY,d=this.height;return e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.fillStyle=this.cornerColor,o=i-c,u=s-l,e.fillRect(o,u,a,f),o=i+this.width-c,u=s-l,e.fillRect(o,u,a,f),o=i-c,u=s+d+p,e.fillRect(o,u,a,f),o=i+this.width+h,u=s+d+p,e.fillRect(o,u,a,f),o=i+this.width/2-c,u=s-l,e.fillRect(o,u,a,f),o=i+this.width/2-c,u=s+d+p,e.fillRect(o,u,a,f),o=i+this.width+h,u=s+d/2-l,e.fillRect(o,u,a,f),o=i-c,u=s+d/2-l,e.fillRect(o,u,a,f),this.hasRotatingPoint&&(o=i+this.width/2-c,u=s-45/this.scaleY,e.fillRect(o,u,a,f)),e.restore(),this},clone:function(e){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(),e):new t.Object(this.toObject())},cloneAsImage:function(e){if(t.Image){var n=new Image;n.onload=function(){e&&e(new t.Image(n),r),n=n.onload=null};var r={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",!1).set("flipY",!1),this.toDataURL(function(e){n.src=e})}return this},toDataURL:function(e){function i(t){t.left=n.width/2,t.top=n.height/2,t.setActive(!1),r.add(t);var i=r.toDataURL("png");r.dispose(),r=t=null,e&&e(i)}var n=t.document.createElement("canvas");!n.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(n),n.width=this.getWidth(),n.height=this.getHeight(),t.util.wrapElement(n,"div");var r=new t.Canvas(n);r.backgroundColor="transparent",r.renderAll(),this.constructor.async?this.clone(i):i(this.clone())},hasStateChanged:function(){return this.stateProperties.some(function(e){return this[e]!==this.originalState[e]},this)},saveState:function(){return this.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),this},setupState:function(){this.originalState={},this.saveState()},intersectsWithRect:function(e,n){var r=this.oCoords,i=new t.Point(r.tl.x,r.tl.y),s=new t.Point(r.tr.x,r.tr.y),o=new t.Point(r.bl.x,r.bl.y),u=new t.Point(r.br.x,r.br.y),a=t.Intersection.intersectPolygonRectangle([i,s,u,o],e,n);return a.status==="Intersection"},intersectsWithObject:function(e){function n(e){return{tl:new t.Point(e.tl.x,e.tl.y),tr:new t.Point(e.tr.x,e.tr.y),bl:new t.Point(e.bl.x,e.bl.y),br:new t.Point(e.br.x,e.br.y)}}var r=n(this.oCoords),i=n(e.oCoords),s=t.Intersection.intersectPolygonPolygon([r.tl,r.tr,r.br,r.bl],[i.tl,i.tr,i.br,i.bl]);return s.status==="Intersection"},isContainedWithinObject:function(e){return this.isContainedWithinRect(e.oCoords.tl,e.oCoords.br)},isContainedWithinRect:function(e,n){var r=this.oCoords,i=new t.Point(r.tl.x,r.tl.y),s=new t.Point(r.tr.x,r.tr.y),o=new t.Point(r.bl.x,r.bl.y),u=new t.Point(r.br.x,r.br.y);return i.x>e.x&&s.x<n.x&&i.y>e.y&&o.y<n.y},isType:function(e){return this.type===e},_findTargetCorner:function(e,t){if(!this.hasControls)return!1;var n=o(e),r=n.x-t.left,i=n.y-t.top,s,u;for(var a in this.oCoords){u=this._getImageLines(this.oCoords[a].corner,a),s=this._findCrossPoints(r,i,u);if(s%2==1&&s!=0)return this.__corner=a,a}return!1},_findCrossPoints:function(e,t,n){var r,i,s,o,u,a,f=0,l;for(var c in n){l=n[c];if(l.o.y<t&&l.d.y<t)continue;if(l.o.y>=t&&l.d.y>=t)continue;l.o.x==l.d.x&&l.o.x>=e?(u=l.o.x,a=t):(r=0,i=(l.d.y-l.o.y)/(l.d.x-l.o.x),s=t-r*e,o=l.o.y-i*l.o.x,u=-(s-o)/(r-i),a=s+r*u),u>=e&&(f+=1);if(f==2)break}return f},_getImageLines:function(e,t){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var e=this.oCoords,t=u(45-this.getAngle()),n=Math.sqrt(2*Math.pow(this.cornersize,2))/2,r=n*Math.cos(t),i=n*Math.sin(t),s=Math.sin(this.theta),o=Math.cos(this.theta);e.tl.corner={tl:{x:e.tl.x-i,y:e.tl.y-r},tr:{x:e.tl.x+r,y:e.tl.y-i},bl:{x:e.tl.x-r,y:e.tl.y+i},br:{x:e.tl.x+i,y:e.tl.y+r}},e.tr.corner={tl:{x:e.tr.x-i,y:e.tr.y-r},tr:{x:e.tr.x+r,y:e.tr.y-i},br:{x:e.tr.x+i,y:e.tr.y+r},bl:{x:e.tr.x-r,y:e.tr.y+i}},e.bl.corner={tl:{x:e.bl.x-i,y:e.bl.y-r},bl:{x:e.bl.x-r,y:e.bl.y+i},br:{x:e.bl.x+i,y:e.bl.y+r},tr:{x:e.bl.x+r,y:e.bl.y-i}},e.br.corner={tr:{x:e.br.x+r,y:e.br.y-i},bl:{x:e.br.x-r,y:e.br.y+i},br:{x:e.br.x+i,y:e.br.y+r},tl:{x:e.br.x-i,y:e.br.y-r}},e.ml.corner={tl:{x:e.ml.x-i,y:e.ml.y-r},tr:{x:e.ml.x+r,y:e.ml.y-i},bl:{x:e.ml.x-r,y:e.ml.y+i},br:{x:e.ml.x+i,y:e.ml.y+r}},e.mt.corner={tl:{x:e.mt.x-i,y:e.mt.y-r},tr:{x:e.mt.x+r,y:e.mt.y-i},bl:{x:e.mt.x-r,y:e.mt.y+i},br:{x:e.mt.x+i,y:e.mt.y+r}},e.mr.corner={tl:{x:e.mr.x-i,y:e.mr.y-r},tr:{x:e.mr.x+r,y:e.mr.y-i},bl:{x:e.mr.x-r,y:e.mr.y+i},br:{x:e.mr.x+i,y:e.mr.y+r}},e.mb.corner={tl:{x:e.mb.x-i,y:e.mb.y-r},tr:{x:e.mb.x+r,y:e.mb.y-i},bl:{x:e.mb.x-r,y:e.mb.y+i},br:{x:e.mb.x+i,y:e.mb.y+r}};var a=40;e.mtr.corner={tl:{x:e.mtr.x-i+s*a,y:e.mtr.y-r-o*a},tr:{x:e.mtr.x+r+s*a,y:e.mtr.y-i-o*a},bl:{x:e.mtr.x-r+s*a,y:e.mtr.y+i-o*a},br:{x:e.mtr.x+i+s*a,y:e.mtr.y+r-o*a}};var f=-a-this.currentHeight;e.mbr.corner={tl:{x:e.mbr.x-i+s*f,y:e.mbr.y-r-o*f},tr:{x:e.mbr.x+r+s*f,y:e.mbr.y-i-o*f},bl:{x:e.mbr.x-r+s*f,y:e.mbr.y+i-o*f},br:{x:e.mbr.x+i+s*f,y:e.mbr.y+r-o*f}}},toGrayscale:function(){var e=this.get("fill");return e&&this.set("overlayFill",(new t.Color(e)).toGrayscale().toRgb()),this},complexity:function(){return 0},toJSON:function(){return this.toObject()},setGradientFill:function(e,n){this.set("fill",t.Gradient.forObject(this,e,n))},animate:function(e,n,r){var i=this;"from"in r||(r.from=this.get(e)),/[+-]/.test(n.charAt(0))&&(n=this.get(e)+parseFloat(n)),t.util.animate({startValue:r.from,endValue:n,byValue:r.by,easing:r.easing,duration:r.duration,onChange:function(t){i.set(e,t),r.onChange&&r.onChange()},onComplete:function(){i.setCoords(),r.onComplete&&r.onComplete()}})}}),t.Object.prototype.rotate=t.Object.prototype.setAngle;var f=t.Object.prototype;for(var l=f.stateProperties.length;l--;){var c=f.stateProperties[l],h=c.charAt(0).toUpperCase()+c.slice(1),p="set"+h,d="get"+h;f[d]||(f[d]=function(e){return new Function('return this.get("'+e+'")')}(c)),f[p]||(f[p]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(c))}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.Object.prototype.set,i={x1:1,x2:1,y1:1,y2:1};if(t.Line){t.warn("fabric.Line is already defined");return}t.Line=t.util.createClass(t.Object,{type:"line",initialize:function(e,t){e||(e=[0,0,0,0]),this.callSuper("initialize",t),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight()},_setWidthHeight:function(){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)},set:function(e,t){return r.call(this,e,t),e in i&&this._setWidthHeight(),this},_render:function(e){e.beginPath(),e.moveTo(this.width===1?0:-this.width/2,this.height===1?0:-this.height/2),e.lineTo(this.width===1?0:this.width/2,this.height===1?0:this.height/2),e.lineWidth=this.strokeWidth;var t=e.strokeStyle;e.strokeStyle=e.fillStyle,e.stroke(),e.strokeStyle=t},complexity:function(){return 1},toObject:function(){return n(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){return["<line ",'x1="',this.get("x1"),'" ','y1="',this.get("y1"),'" ','x2="',this.get("x2"),'" ','y2="',this.get("y2"),'" ','style="',this.getSvgStyles(),'" ',"/>"].join("")}}),t.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" "),t.Line.fromElement=function(e,r){var i=t.parseAttributes(e,t.Line.ATTRIBUTE_NAMES),s=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new t.Line(s,n(i,r))},t.Line.fromObject=function(e){var n=[e.x1,e.y1,e.x2,e.y2];return new t.Line(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function i(e){return"radius"in e&&e.radius>0}var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Circle){t.warn("fabric.Circle is already defined.");return}t.Circle=t.util.createClass(t.Object,{type:"circle",initialize:function(e){e=e||{},this.set("radius",e.radius||0),this.callSuper("initialize",e);var t=this.get("radius")*2;this.set("width",t).set("height",t)},toObject:function(){return r(this.callSuper("toObject"),{radius:this.get("radius")})},toSVG:function(){return'<circle cx="0" cy="0" r="'+this.radius+'" '+'style="'+this.getSvgStyles()+'" '+'transform="'+this.getSvgTransform()+'" '+"/>"},_render:function(e,t){e.beginPath(),e.globalAlpha*=this.opacity,e.arc(t?this.left:0,t?this.top:0,this.radius,0,n,!1),e.closePath(),this.fill&&e.fill(),this.stroke&&e.stroke()},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(e){this.radius=e,this.set("width",e*2).set("height",e*2)},complexity:function(){return 1}}),t.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Circle.fromElement=function(e,n){n||(n={});var s=t.parseAttributes(e,t.Circle.ATTRIBUTE_NAMES);if(!i(s))throw Error("value of `r` attribute is required and can not be negative");return"left"in s&&(s.left-=n.width/2||0),"top"in s&&(s.top-=n.height/2||0),new t.Circle(r(s,n))},t.Circle.fromObject=function(e){return new t.Circle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Triangle){t.warn("fabric.Triangle is already defined");return}t.Triangle=t.util.createClass(t.Object,{type:"triangle",initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("width",e.width||100).set("height",e.height||100)},_render:function(e){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this.fill&&e.fill(),this.stroke&&e.stroke()},complexity:function(){return 1},toSVG:function(){var e=this.width/2,t=this.height/2,n=[-e+" "+t,"0 "+ -t,e+" "+t].join(",");return'<polygon points="'+n+'" '+'style="'+this.getSvgStyles()+'" '+'transform="'+this.getSvgTransform()+'" '+"/>"}}),t.Triangle.fromObject=function(e){return new t.Triangle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Ellipse){t.warn("fabric.Ellipse is already defined.");return}t.Ellipse=t.util.createClass(t.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 r(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(){return["<ellipse ",'rx="',this.get("rx"),'" ','ry="',this.get("ry"),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},render:function(e,t){if(this.rx===0||this.ry===0)return;return this.callSuper("render",e,t)},_render:function(e,t){e.beginPath(),e.save(),e.globalAlpha*=this.opacity,e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(t?this.left:0,t?this.top:0,this.rx,0,n,!1),this.stroke&&e.stroke(),this.fill&&e.fill(),e.restore()},complexity:function(){return 1}}),t.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Ellipse.fromElement=function(e,n){n||(n={});var i=t.parseAttributes(e,t.Ellipse.ATTRIBUTE_NAMES);return"left"in i&&(i.left-=n.width/2||0),"top"in i&&(i.top-=n.height/2||0),new t.Ellipse(r(i,n))},t.Ellipse.fromObject=function(e){return new t.Ellipse(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){return e.left=e.left||0,e.top=e.top||0,e}var t=e.fabric||(e.fabric={});if(t.Rect){console.warn("fabric.Rect is already defined");return}t.Rect=t.util.createClass(t.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(e){this._initStateProperties(),this.callSuper("initialize",e),this._initRxRy()},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(e){var t=this.rx||0,n=this.ry||0,r=-this.width/2,i=-this.height/2,s=this.width,o=this.height;e.beginPath(),e.globalAlpha*=this.opacity,this.group&&e.translate(this.x||0,this.y||0),e.moveTo(r+t,i),e.lineTo(r+s-t,i),e.bezierCurveTo(r+s,i,r+s,i+n,r+s,i+n),e.lineTo(r+s,i+o-n),e.bezierCurveTo(r+s,i+o,r+s-t,i+o,r+s-t,i+o),e.lineTo(r+t,i+o),e.bezierCurveTo(r,i+o,r,i+o-n,r,i+o-n),e.lineTo(r,i+n),e.bezierCurveTo(r,i,r+t,i,r+t,i),e.closePath(),this.fill&&e.fill(),this.stroke&&e.stroke()},_normalizeLeftTopProperties:function(e){return e.left&&this.set("left",e.left+this.getWidth()/2),this.set("x",e.left||0),e.top&&this.set("top",e.top+this.getHeight()/2),this.set("y",e.top||0),this},complexity:function(){return 1},toObject:function(){return t.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx")||0,ry:this.get("ry")||0})},toSVG:function(){return'<rect x="'+ -1*this.width/2+'" y="'+ -1*this.height/2+'" '+'rx="'+this.get("rx")+'" ry="'+this.get("ry")+'" '+'width="'+this.width+'" height="'+this.height+'" '+'style="'+this.getSvgStyles()+'" '+'transform="'+this.getSvgTransform()+'" '+"/>"}}),t.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Rect.fromElement=function(e,r){if(!e)return null;var i=t.parseAttributes(e,t.Rect.ATTRIBUTE_NAMES);i=n(i);var s=new t.Rect(t.util.object.extend(r?t.util.object.clone(r):{},i));return s._normalizeLeftTopProperties(i),s},t.Rect.fromObject=function(e){return new t.Rect(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.toFixed;if(t.Polyline){t.warn("fabric.Polyline is already defined");return}t.Polyline=t.util.createClass(t.Object,{type:"polyline",initialize:function(e,t){t=t||{},this.set("points",e),this.callSuper("initialize",t),this._calcDimensions()},_calcDimensions:function(){return t.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return t.Polygon.prototype.toObject.call(this)},toSVG:function(){var e=[];for(var t=0,r=this.points.length;t<r;t++)e.push(n(this.points[t].x,2),",",n(this.points[t].y,2)," ");return["<polyline ",'points="',e.join(""),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},_render:function(e){var t;e.beginPath();for(var n=0,r=this.points.length;n<r;n++)t=this.points[n],e.lineTo(t.x,t.y);this.fill&&e.fill(),this.stroke&&e.stroke()},complexity:function(){return this.get("points").length}}),t.Polyline.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Polyline.fromElement=function(e,n){if(!e)return null;n||(n={});var r=t.parsePointsAttribute(e.getAttribute("points")),i=t.parseAttributes(e,t.Polyline.ATTRIBUTE_NAMES);for(var s=0,o=r.length;s<o;s++)r[s].x-=n.width/2||0,r[s].y-=n.height/2||0;return new t.Polyline(r,t.util.object.extend(i,n))},t.Polyline.fromObject=function(e){var n=e.points;return new t.Polyline(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function o(e){return e.x}function u(e){return e.y}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.toFixed;if(t.Polygon){t.warn("fabric.Polygon is already defined");return}t.Polygon=t.util.createClass(t.Object,{type:"polygon",initialize:function(e,t){t=t||{},this.points=e,this.callSuper("initialize",t),this._calcDimensions()},_calcDimensions:function(){var e=this.points,t=r(e,"x"),n=r(e,"y"),s=i(e,"x"),o=i(e,"y");this.width=s-t,this.height=o-n,this.minX=t,this.minY=n},toObject:function(){return n(this.callSuper("toObject"),{points:this.points.concat()})},toSVG:function(){var e=[];for(var t=0,n=this.points.length;t<n;t++)e.push(s(this.points[t].x,2),",",s(this.points[t].y,2)," ");return["<polygon ",'points="',e.join(""),'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',"/>"].join("")},_render:function(e){var t;e.beginPath();for(var n=0,r=this.points.length;n<r;n++)t=this.points[n],e.lineTo(t.x,t.y);this.fill&&e.fill(),this.stroke&&(e.closePath
4
+ (),e.stroke())},complexity:function(){return this.points.length}}),t.Polygon.ATTRIBUTE_NAMES="fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Polygon.fromElement=function(e,r){if(!e)return null;r||(r={});var i=t.parsePointsAttribute(e.getAttribute("points")),s=t.parseAttributes(e,t.Polygon.ATTRIBUTE_NAMES);for(var o=0,u=i.length;o<u;o++)i[o].x-=r.width/2||0,i[o].y-=r.height/2||0;return new t.Polygon(i,n(s,r))},t.Polygon.fromObject=function(e){return new t.Polygon(e.points,e)}}(typeof exports!="undefined"?exports:this),function(e){function n(e,t,n,r){var i=r[0],s=r[1],o=r[2],f=r[3],l=r[4],c=r[5],h=r[6],p=u(c,h,i,s,f,l,o,t,n);for(var d=0;d<p.length;d++){var v=a.apply(this,p[d]);e.bezierCurveTo.apply(e,v)}}function u(e,t,n,i,u,a,f,l,c){o=s.call(arguments);if(r[o])return r[o];var h=f*(Math.PI/180),p=Math.sin(h),d=Math.cos(h);n=Math.abs(n),i=Math.abs(i);var v=d*(l-e)*.5+p*(c-t)*.5,m=d*(c-t)*.5-p*(l-e)*.5,g=v*v/(n*n)+m*m/(i*i);g>1&&(g=Math.sqrt(g),n*=g,i*=g);var y=d/n,b=p/n,w=-p/i,E=d/i,S=y*l+b*c,x=w*l+E*c,T=y*e+b*t,N=w*e+E*t,C=(T-S)*(T-S)+(N-x)*(N-x),k=1/C-.25;k<0&&(k=0);var L=Math.sqrt(k);a==u&&(L=-L);var A=.5*(S+T)-L*(N-x),O=.5*(x+N)+L*(T-S),M=Math.atan2(x-O,S-A),_=Math.atan2(N-O,T-A),D=_-M;D<0&&a==1?D+=2*Math.PI:D>0&&a==0&&(D-=2*Math.PI);var P=Math.ceil(Math.abs(D/(Math.PI*.5+.001))),H=[];for(var B=0;B<P;B++){var j=M+B*D/P,F=M+(B+1)*D/P;H[B]=[A,O,j,F,n,i,p,d]}return r[o]=H}function a(e,t,n,r,u,a,f,l){o=s.call(arguments);if(i[o])return i[o];var c=l*u,h=-f*a,p=f*u,d=l*a,v=.5*(r-n),m=8/3*Math.sin(v*.5)*Math.sin(v*.5)/Math.sin(v),g=e+Math.cos(n)-m*Math.sin(n),y=t+Math.sin(n)+m*Math.cos(n),b=e+Math.cos(r),w=t+Math.sin(r),E=b+m*Math.sin(r),S=w-m*Math.cos(r);return i[o]=[c*g+h*y,p*g+d*y,c*E+h*S,p*E+d*S,c*b+h*w,p*b+d*w]}function d(e){return e[0]==="H"?e[1]:e[e.length-2]}function v(e){return e[0]==="V"?e[1]:e[e.length-1]}var t={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},r={},i={},s=Array.prototype.join,o;"use strict";var f=e.fabric||(e.fabric={}),l=f.util.array.min,c=f.util.array.max,h=f.util.object.extend,p=Object.prototype.toString;if(f.Path){f.warn("fabric.Path is already defined");return}if(!f.Object){f.warn("fabric.Path requires fabric.Object");return}f.Path=f.util.createClass(f.Object,{type:"path",initialize:function(e,t){t=t||{},this.setOptions(t);if(!e)throw Error("`path` argument is required");var n=p.call(e)==="[object Array]";this.path=n?e:e.match&&e.match(/[a-zA-Z][^a-zA-Z]*/g);if(!this.path)return;n||this._initializeFromArray(t),t.sourcePath&&this.setSourcePath(t.sourcePath)},_initializeFromArray:function(e){var t="width"in e,n="height"in e;this.path=this._parsePath();if(!t||!n)h(this,this._parseDimensions()),t&&(this.width=e.width),n&&(this.height=e.height)},_render:function(e){var t,r=0,i=0,s=0,o=0,u,a,f=-(this.width/2),l=-(this.height/2);for(var c=0,h=this.path.length;c<h;++c){t=this.path[c];switch(t[0]){case"l":r+=t[1],i+=t[2],e.lineTo(r+f,i+l);break;case"L":r=t[1],i=t[2],e.lineTo(r+f,i+l);break;case"h":r+=t[1],e.lineTo(r+f,i+l);break;case"H":r=t[1],e.lineTo(r+f,i+l);break;case"v":i+=t[1],e.lineTo(r+f,i+l);break;case"V":i=t[1],e.lineTo(r+f,i+l);break;case"m":r+=t[1],i+=t[2],e.moveTo(r+f,i+l);break;case"M":r=t[1],i=t[2],e.moveTo(r+f,i+l);break;case"c":u=r+t[5],a=i+t[6],s=r+t[3],o=i+t[4],e.bezierCurveTo(r+t[1]+f,i+t[2]+l,s+f,o+l,u+f,a+l),r=u,i=a;break;case"C":r=t[5],i=t[6],s=t[3],o=t[4],e.bezierCurveTo(t[1]+f,t[2]+l,s+f,o+l,r+f,i+l);break;case"s":u=r+t[3],a=i+t[4],s=2*r-s,o=2*i-o,e.bezierCurveTo(s+f,o+l,r+t[1]+f,i+t[2]+l,u+f,a+l),r=u,i=a;break;case"S":u=t[3],a=t[4],s=2*r-s,o=2*i-o,e.bezierCurveTo(s+f,o+l,t[1]+f,t[2]+l,u+f,a+l),r=u,i=a;break;case"q":r+=t[3],i+=t[4],e.quadraticCurveTo(t[1]+f,t[2]+l,r+f,i+l);break;case"Q":r=t[3],i=t[4],s=t[1],o=t[2],e.quadraticCurveTo(s+f,o+l,r+f,i+l);break;case"T":u=r,a=i,r=t[1],i=t[2],s=-s+2*u,o=-o+2*a,e.quadraticCurveTo(s+f,o+l,r+f,i+l);break;case"a":n(e,r+f,i+l,[t[1],t[2],t[3],t[4],t[5],t[6]+r+f,t[7]+i+l]),r+=t[6],i+=t[7];break;case"A":n(e,r+f,i+l,[t[1],t[2],t[3],t[4],t[5],t[6]+f,t[7]+l]),r=t[6],i=t[7];break;case"z":case"Z":e.closePath()}}},render:function(e,t){e.save();var n=this.transformMatrix;n&&e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t||this.transform(e),this.overlayFill?e.fillStyle=this.overlayFill:this.fill&&(e.fillStyle=this.fill),this.stroke&&(e.strokeStyle=this.stroke),e.beginPath(),this._render(e),this.fill&&e.fill(),this.stroke&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.lineCap=e.lineJoin="round",e.stroke()),!t&&this.active&&(this.drawBorders(e),this.hideCorners||this.drawCorners(e)),e.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(){var e=h(this.callSuper("toObject"),{path:this.path});return this.sourcePath&&(e.sourcePath=this.sourcePath),this.transformMatrix&&(e.transformMatrix=this.transformMatrix),e},toDatalessObject:function(){var e=this.toObject();return this.sourcePath&&(e.path=this.sourcePath),delete e.sourcePath,e},toSVG:function(){var e=[];for(var t=0,n=this.path.length;t<n;t++)e.push(this.path[t].join(" "));var r=e.join(" ");return['<g transform="',this.getSvgTransform(),'">',"<path ",'width="',this.width,'" height="',this.height,'" ','d="',r,'" ','style="',this.getSvgStyles(),'" ','transform="translate(',-this.width/2," ",-this.height/2,')" />',"</g>"].join("")},complexity:function(){return this.path.length},_parsePath:function(){var e=[],n,r,i;for(var s=0,o,u,a=this.path.length;s<a;s++){n=this.path[s],r=n.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/),u=[n.charAt(0)];for(var o=0,f=r.length;o<f;o++)i=parseFloat(r[o]),isNaN(i)||u.push(i);var l=u[0].toLowerCase(),c=t[l];if(u.length-1>c)for(var h=1,p=u.length;h<p;h+=c)e.push([u[0]].concat(u.slice(h,h+c)));else e.push(u)}return e},_parseDimensions:function(){var e=[],t=[],n,r,i=!1,s,o;this.path.forEach(function(u,a){u[0]!=="H"&&(n=a===0?d(u):d(this.path[a-1])),u[0]!=="V"&&(r=a===0?v(u):v(this.path[a-1])),u[0]===u[0].toLowerCase()&&(i=!0),s=i?n+d(u):u[0]==="V"?n:d(u),o=i?r+v(u):u[0]==="H"?r:v(u);var f=parseInt(s,10);isNaN(f)||e.push(f),f=parseInt(o,10),isNaN(f)||t.push(f)},this);var u=l(e),a=l(t),f=0,h=0,p={top:a-h,left:u-f,bottom:c(t)-h,right:c(e)-f};return p.width=p.right-p.left,p.height=p.bottom-p.top,p}}),f.Path.fromObject=function(e){return new f.Path(e.path,e)},f.Path.ATTRIBUTE_NAMES="d fill fill-opacity opacity fill-rule stroke stroke-width transform".split(" "),f.Path.fromElement=function(e,t){var n=f.parseAttributes(e,f.Path.ATTRIBUTE_NAMES);return new f.Path(n.d,h(n,t))}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function a(e){for(var n=0,r=e.length;n<r;n++)if(!(e[n]instanceof t.Object)){var i=o(u(e[n].type));e[n]=t[i].fromObject(e[n])}return e}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.invoke,i=t.Object.prototype.set,s=t.Object.prototype.toObject,o=t.util.string.camelize,u=t.util.string.capitalize;if(t.PathGroup){t.warn("fabric.PathGroup is already defined");return}t.PathGroup=t.util.createClass(t.Path,{type:"path-group",forceFillOverwrite:!1,initialize:function(e,t){t=t||{},this.paths=e||[];for(var n=this.paths.length;n--;)this.paths[n].group=this;this.setOptions(t),this.setCoords(),t.sourcePath&&this.setSourcePath(t.sourcePath)},render:function(e){if(this.stub)e.save(),this.transform(e),this.stub.render(e,!1),this.active&&(this.drawBorders(e),this.drawCorners(e)),e.restore();else{e.save();var t=this.transformMatrix;t&&e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this.transform(e);for(var n=0,r=this.paths.length;n<r;++n)this.paths[n].render(e,!0);this.active&&(this.drawBorders(e),this.hideCorners||this.drawCorners(e)),e.restore()}},set:function(e,t){if(e!=="fill"&&e!=="overlayFill"||!this.isSameColor())i.call(this,e,t);else{this[e]=t;var n=this.paths.length;while(n--)this.paths[n].set(e,t)}return this},toObject:function(){return n(s.call(this),{paths:r(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var e=this.toObject();return this.sourcePath&&(e.paths=this.sourcePath),e},toSVG:function(){var e=this.getObjects(),t=["<g ",'width="',this.width,'" ','height="',this.height,'" ','style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',">"];for(var n=0,r=e.length;n<r;n++)t.push(e[n].toSVG());return t.push("</g>"),t.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var e=this.getObjects()[0].get("fill");return this.getObjects().every(function(t){return t.get("fill")===e})},complexity:function(){return this.paths.reduce(function(e,t){return e+(t&&t.complexity?t.complexity():0)},0)},toGrayscale:function(){var e=this.paths.length;while(e--)this.paths[e].toGrayscale();return this},getObjects:function(){return this.paths}}),t.PathGroup.fromObject=function(e){var n=a(e.paths);return new t.PathGroup(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.array.invoke,o=t.util.removeFromArray;if(t.Group)return;t.Group=t.util.createClass(t.Object,{type:"group",initialize:function(e,t){this.objects=e||[],this.originalState={},this.callSuper("initialize"),this._calcBounds(),this._updateObjectsCoords(),t&&n(this,t),this._setOpacityIfSame(),this.setCoords(!0),this.saveCoords(),this.activateAllObjects()},_updateObjectsCoords:function(){var e=this.left,t=this.top;this.forEachObject(function(n){var r=n.get("left"),i=n.get("top");n.set("originalLeft",r),n.set("originalTop",i),n.set("left",r-e),n.set("top",i-t),n.setCoords(),n.hideCorners=!0},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(e){return this._restoreObjectsState(),this.objects.push(e),e.setActive(!0),this._calcBounds(),this._updateObjectsCoords(),this},remove:function(e){return this._restoreObjectsState(),o(this.objects,e),e.setActive(!1),this._calcBounds(),this._updateObjectsCoords(),this},size:function(){return this.getObjects().length},set:function(e,t){if(typeof t=="function")this.set(e,t(this[e]));else if(e==="fill"||e==="opacity"){var n=this.objects.length;this[e]=t;while(n--)this.objects[n].set(e,t)}else this[e]=t;return this},contains:function(e){return this.objects.indexOf(e)>-1},toObject:function(){return n(this.callSuper("toObject"),{objects:s(this.objects,"clone")})},render:function(e){e.save(),this.transform(e);var t=Math.max(this.scaleX,this.scaleY);for(var n=0,r=this.objects.length,i;i=this.objects[n];n++){var s=i.borderScaleFactor;i.borderScaleFactor=t,i.render(e),i.borderScaleFactor=s}this.hideBorders||this.drawBorders(e),this.hideCorners||this.drawCorners(e),e.restore(),this.setCoords()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=typeof t.complexity=="function"?t.complexity():0,e},0)},_restoreObjectsState:function(){return this.objects.forEach(this._restoreObjectState,this),this},_restoreObjectState:function(e){var t=this.get("left"),n=this.get("top"),r=this.getAngle()*(Math.PI/180),i=e.get("originalLeft"),s=e.get("originalTop"),o=Math.cos(r)*e.get("top")+Math.sin(r)*e.get("left"),u=-Math.sin(r)*e.get("top")+Math.cos(r)*e.get("left");return e.setAngle(e.getAngle()+this.getAngle()),e.set("left",t+u*this.get("scaleX")),e.set("top",n+o*this.get("scaleY")),e.set("scaleX",e.get("scaleX")*this.get("scaleX")),e.set("scaleY",e.get("scaleY")*this.get("scaleY")),e.setCoords(),e.hideCorners=!1,e.setActive(!1),e.setCoords(),this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){return this._originalLeft=this.get("left"),this._originalTop=this.get("top"),this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){return this.forEachObject(function(e){e.setCoords()}),this},activateAllObjects:function(){return this.setActive(!0)},setActive:function(e){return this.forEachObject(function(t){t.setActive(e)}),this},forEachObject:t.StaticCanvas.prototype.forEachObject,_setOpacityIfSame:function(){var e=this.getObjects(),t=e[0]?e[0].get("opacity"):1,n=e.every(function(e){return e.get("opacity")===t});n&&(this.opacity=t)},_calcBounds:function(){var e=[],t=[],n,s,o,u,a,f,l,c=0,h=this.objects.length;for(;c<h;++c){a=this.objects[c],a.setCoords();for(var p in a.oCoords)e.push(a.oCoords[p].x),t.push(a.oCoords[p].y)}n=r(e),o=i(e),s=r(t),u=i(t),f=o-n||0,l=u-s||0,this.width=f,this.height=l,this.left=n+f/2||0,this.top=s+l/2||0},containsPoint:function(e){var t=this.get("width")/2,n=this.get("height")/2,r=this.get("left"),i=this.get("top");return r-t<e.x&&r+t>e.x&&i-n<e.y&&i+n>e.y},toGrayscale:function(){var e=this.objects.length;while(e--)this.objects[e].toGrayscale()}}),t.Group.fromObject=function(e){return new t.Group(e.objects,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=fabric.util.object.extend;e.fabric||(e.fabric={});if(e.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,{active:!1,bordervisibility:!1,cornervisibility:!1,type:"image",filters:[],initialize:function(e,t){t||(t={}),this.callSuper("initialize",t),this._initElement(e),this._originalImage=this.getElement(),this._initConfig(t),t.filters&&(this.filters=t.filters,this.applyFilters())},getElement:function(){return this._element},setElement:function(e){return this._element=e,this._initConfig(),this},getOriginalSize:function(){var e=this.getElement();return{width:e.width,height:e.height}},setBorderVisibility:function(e){this._resetWidthHeight(),this._adjustWidthHeightToBorders(showBorder),this.setCoords()},setCornersVisibility:function(e){this.cornervisibility=!!e},render:function(e,t){e.save(),t||this.transform(e),this._render(e),this.active&&!t&&(this.drawBorders(e),this.hideCorners||this.drawCorners(e)),e.restore()},toObject:function(){return t(this.callSuper("toObject"),{src:this._originalImage.src||this._originalImage._src,filters:this.filters.concat()})},toSVG:function(){return'<g transform="'+this.getSvgTransform()+'">'+'<image xlink:href="'+this.getSvgSrc()+'" '+'style="'+this.getSvgStyles()+'" '+'transform="translate('+ -this.width/2+" "+ -this.height/2+')" '+'width="'+this.width+'" '+'height="'+this.height+'"'+"/>"+"</g>"},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(e){this.constructor.fromObject(this.toObject(),e)},applyFilters:function(e){if(this.filters.length===0){this.setElement(this._originalImage),e&&e();return}var t=typeof Buffer!="undefined"&&typeof window=="undefined",n=this._originalImage,r=fabric.document.createElement("canvas"),i=t?new(require("canvas").Image):fabric.document.createElement("img"),s=this;!r.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(r),r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),this.filters.forEach(function(e){e&&e.applyTo(r)}),i.onload=function(){s.setElement(i),e&&e(),i.onload=r=n=null},i.width=n.width,i.height=n.height;if(t){var o=r.toDataURL("image/png").replace(/data:image\/png;base64,/,"");i.src=new Buffer(o,"base64"),s.setElement(i),e&&e()}else i.src=r.toDataURL("image/png");return this},_render:function(e){e.drawImage(this.getElement(),-this.width/2,-this.height/2,this.width,this.height)},_adjustWidthHeightToBorders:function(e){e?(this.currentBorder=this.borderwidth,this.width+=2*this.currentBorder,this.height+=2*this.currentBorder):this.currentBorder=0},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width),this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e)),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){this.setOptions(e||{}),this._setBorder(),this._setWidthHeight()},_initFilters:function(e){e.filters&&e.filters.length&&(this.filters=e.filters.map(function(e){return fabric.Image.filters[e.type].fromObject(e)}))},_setBorder:function(){this.bordervisibility?this.currentBorder=this.borderwidth:this.currentBorder=0},_setWidthHeight:function(){var e=2*this.currentBorder;this.width=(this.getElement().width||0)+e,this.height=(this.getElement().height||0)+e},complexity:function(){return 1}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(e,t){var n=fabric.document.createElement("img"),r=e.src;e.width&&(n.width=e.width),e.height&&(n.height=e.height),n.onload=function(){fabric.Image.prototype._initFilters.call(e,e);var r=new fabric.Image(n,e);t&&t(r),n=n.onload=null},n.src=r},fabric.Image.fromURL=function(e,t,n){var r=fabric.document.createElement("img");r.onload=function(){t&&t(new fabric.Image(r,n)),r=r.onload=null},r.src=e},fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" "),fabric.Image.fromElement=function(e,n,r){r||(r={});var i=fabric.parseAttributes(e,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(i["xlink:href"],n,t(i,r))},fabric.Image.async=!0}(typeof exports!="undefined"?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var e=this.get("angle");return e>-225&&e<=-135?-180:e>-135&&e<=-45?-90:e>-45&&e<=45?0:e>45&&e<=135?90:e>135&&e<=225?180:e>225&&e<=315?270:e>315?360:0},straighten:function(){var e=this._getAngleValueForStraighten();return this.setAngle(e),this},fxStraighten:function(e){e=e||{};var t=function(){},n=e.onComplete||t,r=e.onChange||t,i=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(e){i.setAngle(e),r()},onComplete:function(){i.setCoords(),n()},onStart:function(){i.setActive(!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(e){return e.straighten(),this.renderAll(),this},fxStraightenObject:function(e){return e.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters={},fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;a<i;a++)for(f=0;f<s;f++)o=a*4*s+f*4,u=(r[o]+r[o+1]+r[o+2])/3,r[o]=u,r[o+1]=u,r[o+2]=u;t.putImageData(n,0,0)},toJSON:function(){return{type:this.type}}}),fabric.Image.filters.Grayscale.fromObject=function(){return new fabric.Image.filters.Grayscale},fabric.Image.filters.RemoveWhite=fabric.util.createClass({type:"RemoveWhite",initialize:function(e){e||(e={}),this.threshold=e.threshold||30,this.distance=e.distance||20},applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=this.threshold,s=this.distance,o=255-i,u=Math.abs,a,f,l;for(var c=0,h=r.length;c<h;c+=4)a=r[c],f=r[c+1],l=r[c+2],a>o&&f>o&&l>o&&u(a-f)<s&&u(a-l)<s&&u(f-l)<s&&(r[c+3]=1);t.putImageData(n,0,0)},toJSON:function(){return{type:this.type,threshold:this.threshold,distance:this.distance}}}),fabric.Image.filters.RemoveWhite.fromObject=function(e){return new fabric.Image.filters.RemoveWhite(e)},fabric.Image.filters.Invert=fabric.util.createClass({type:"Invert",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=r.length,s;for(s=0;s<i;s+=4)r[s]=255-r[s],r[s+1]=255-r[s+1],r[s+2]=255-r[s+2];t.putImageData(n,0,0)},toJSON:function(){return{type:this.type}}}),fabric.Image.filters.Invert.fromObject=function(){return new fabric.Image.filters.Invert},function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.object.clone,i=t.util.toFixed;if(t.Text){t.warn("fabric.Text is already defined");return}if(!t.Object){t.warn("fabric.Text requires fabric.Object");return}t.Text=t.util.createClass(t.Object,{fontSize:40,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(e,t){this._initStateProperties(),this.text=e,this.setOptions(t),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","fontSize","path","text","textDecoration","textShadow","textAlign","fontStyle","lineHeight","strokeStyle","strokeWidth","backgroundColor"),t.util.removeFromArray(this.stateProperties,"width")},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_render:function(e){var t=Cufon.textOptions||(Cufon.textOptions={});t.left=this.left,t.top=this.top,t.context=e,t.color=this.fill;var n=this._initDummyElement();this.transform(e),Cufon.replaceElement(n,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,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=t.width,this.height=t.height,this._totalLineHeight=t.totalLineHeight,this._fontAscent=t.fontAscent,this._boundaries=t.boundaries,this._shadowOffsets=t.shadowOffsets,this._shadows=t.shadows||[],this.setCoords()},_initDummyElement:function(){var e=t.document.createElement("pre"),n=t.document.createElement("div");return n.appendChild(e),typeof G_vmlCanvasManager=="undefined"?e.innerHTML=this.text:e.innerText=this.text.replace(/\r?\n/gi,"\r"),e.style.fontSize=this.fontSize+"px",e.style.letterSpacing="normal",e},render:function(e,t){e.save(),this._render(e),!t&&this.active&&(this.drawBorders(e),this.hideCorners||this.drawCorners(e)),e.restore()},toObject:function(){return n(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})},toSVG:function(){var e=this.text.split(/\r?\n/),t=-this._fontAscent-this._fontAscent/5*this.lineHeight,n=-(this.width/2),r=this.height/2-e.length*this.fontSize-this._totalLineHeight,s=this._getSVGTextAndBg(t,n,e),o=this._getSVGShadows(t,e);return r+=this._fontAscent/5*this.lineHeight,['<g transform="',this.getSvgTransform(),'">',s.textBgRects.join(""),"<text ",this.fontFamily?"font-family=\"'"+this.fontFamily+"'\" ":"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(),'" ','transform="translate(',i(n,2)," ",i(r,2),')">',o.join(""),s.textSpans.join(""),"</text>","</g>"].join("")},_getSVGShadows:function(e,n){var r=[],s,o,u,a,f=1;for(s=0,u=this._shadows.length;s<u;s++)for(o=0,a=n.length;o<a;o++)if(n[o]!==""){var l=this._boundaries&&this._boundaries[o]?this._boundaries[o].left:0;r.push('<tspan x="',i(l+f+this._shadowOffsets[s][0],2),o===0?'" y':'" dy','="',i(e+(o===0?this._shadowOffsets[s][1]:0),2),'" ',this._getFillAttributes(this._shadows[s].color),">",t.util.string.escapeXml(n[o]),"</tspan>"),f=1}else f++;return r},_getSVGTextAndBg:function(e,n,r){var s=[],o=[],u,a,f,l=1;for(u=0,f=r.length;u<f;u++){r[u]!==""?(a=this._boundaries&&this._boundaries[u]?i(this._boundaries[u].left,2):0,s.push('<tspan x="',a,'" ',u===0?"y":"dy",'="',i(e*l,2),'" ',this._getFillAttributes(this.fill),">",t.util.string.escapeXml(r[u]),"</tspan>"),l=1):l++;if(!this.backgroundColor)continue;o.push("<rect ",this._getFillAttributes(this.backgroundColor),' x="',i(n+this._boundaries[u].left,2),'" y="',i(e*u-this.height/2,2),'" width="',i(this._boundaries[u].width,2),'" height="',i(this._boundaries[u].height,2),'"></rect>')}return{textSpans:s,textBgRects:o}},_getFillAttributes:function(e){var n=e?new t.Color(e):"";return!n||!n.getSource()||n.getAlpha()===1?'fill="'+e+'"':'opacity="'+n.getAlpha()+'" fill="'+n.setAlpha(1).toRgb()+'"'},setColor:function(e){return this.set("fill",e),this},setFontsize:function(e){return this.set("fontSize",e),this.setCoords(),this},getText:function(){return this.text},setText:function(e){return this.set("text",e),this.setCoords(),this},set:function(e,t){if(typeof e=="object")for(var n in e)this.set(n,e[n]);else this[e]=t,e==="fontFamily"&&this.path&&(this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+t+"$3"));return this}}),t.Text.fromObject=function(e){return new t.Text(e.text,r(e))},t.Text.fromElement=function(e){}}(typeof exports!="undefined"?exports:this),function(){function request(e,t,n){var r=URL.parse(e),i=HTTP.createClient(80,r.hostname),s=i.request("GET",r.pathname,{host:r.hostname});i.addListener("error",function(e){e.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+i.host+":"+i.port):fabric.log(e.message)}),s.end(),s.on("response",function(e){var r="";t&&e.setEncoding(t),e.on("end",function(){n(r)}),e.on("data",function(t){e.statusCode==200&&(r+=t)})})}if(typeof document!="undefined"&&typeof window!="undefined")return;var DOMParser=(new require("xmldom")).DOMParser,URL=require("url"),HTTP=require("http"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(e,t){request(e,"binary",function(n){var r=new Image;r.src=new Buffer(n,"binary"),r._src=e,t(r)})},fabric.loadSVGFromURL=function(e,t){e=e.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim(),request(e,"",function(e){var n=(new DOMParser).parseFromString(e);fabric.parseSVGDocument(n.documentElement,function(e,n){t(e,n)})})},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.Image.fromObject=function(e,t){fabric.util.loadImage(e.src,function(n){var r=new fabric.Image(n);r._initConfig(e),r._initFilters(e),t(r)})},fabric.createCanvasForNode=function(e,t){var n=fabric.document.createElement("canvas"),r=new Canvas(e||600,t||600);n.style={},n.width=r.width,n.height=r.height;var i=fabric.Canvas||fabric.StaticCanvas,s=new i(n);return s.contextContainer=r.getContext("2d"),s.nodeCanvas=r,s},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.Canvas&&fabric.Canvas.prototype.createPNGStream;var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(e){return origSetWidth.call(this),this.nodeCanvas.width=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(e){return origSetHeight.call(this),this.nodeCanvas.height=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}();
@@ -3,7 +3,6 @@ var MEMECAPTAIN = (function (window, $, fabric) {
3
3
 
4
4
  var my = {},
5
5
 
6
- bingAppId = 'A120380275E87F0071F163210211F0592D0E964C',
7
6
  facebookAppId = '108445492580525',
8
7
  googleApiKey = 'ABQIAAAA-E0uJIHoMJX6M6atCgYANRS1DzXPXMqKnKNRJm2Z_PRWxvtqGBSOvBqyXOwxGZU5jLxExg_5ym69rw',
9
8
  genUrl = '/g',
@@ -53,27 +52,6 @@ var MEMECAPTAIN = (function (window, $, fabric) {
53
52
  return thumbnailImage.click(function () { setSourceUrl(imgUrl); });
54
53
  }
55
54
 
56
- function showBingImages(resp) {
57
- var div = $('#imageSearchResults'),
58
- searchResponse = resp.SearchResponse,
59
- image = searchResponse.Image;
60
-
61
- if (image.Total > 0) {
62
- $.each(image.Results, function (i, img) {
63
- div.append(searchThumbnail(
64
- img.Thumbnail.Url,
65
- img.MediaUrl,
66
- img.Width,
67
- img.Height
68
- ));
69
- });
70
- } else {
71
- div.append($('<p />').append(
72
- 'No Bing results for "' + searchResponse.Query.SearchTerms + '".'
73
- ));
74
- }
75
- }
76
-
77
55
  function showGoogleImages(resp) {
78
56
  var div = $('#imageSearchResults'),
79
57
  searchResults = resp.responseData.results;
@@ -116,25 +94,6 @@ var MEMECAPTAIN = (function (window, $, fabric) {
116
94
  imageSearchInput.val('');
117
95
  $('#imageSearchResults').empty();
118
96
 
119
- $.ajax({
120
- type : 'GET',
121
- url : 'http://api.bing.net/json.aspx',
122
- data : {
123
- AppId : bingAppId,
124
- Query : imageSearchVal,
125
- Sources : 'Image',
126
- Version : '2.0',
127
- Market : 'en-us',
128
- 'Image.Count' : 5,
129
- 'Image.Filters' : 'Size:Large',
130
- 'Image.Offset' : 0,
131
- JsonType : 'callback'
132
- },
133
- dataType : 'jsonp',
134
- jsonp : 'JsonCallback',
135
- success : showBingImages
136
- });
137
-
138
97
  $.ajax({
139
98
  type : 'GET',
140
99
  url : 'http://ajax.googleapis.com/ajax/services/search/images',
@@ -142,7 +101,7 @@ var MEMECAPTAIN = (function (window, $, fabric) {
142
101
  imgsz : 'large',
143
102
  key : googleApiKey,
144
103
  q : imageSearchVal,
145
- rsz : '5',
104
+ rsz : '8',
146
105
  v : '1.0'
147
106
  },
148
107
  dataType : 'jsonp',
@@ -184,7 +143,8 @@ var MEMECAPTAIN = (function (window, $, fabric) {
184
143
  left : canvas.getWidth() / 2.0,
185
144
  width : textWidth,
186
145
  height : textHeight,
187
- fill : 'red'
146
+ fill : 'red',
147
+ cornersize : 20
188
148
  });
189
149
 
190
150
  rect1.name = '1';
@@ -197,7 +157,8 @@ var MEMECAPTAIN = (function (window, $, fabric) {
197
157
  left : canvas.getWidth() / 2.0,
198
158
  width : textWidth,
199
159
  height : textHeight,
200
- fill: 'red'
160
+ fill : 'red',
161
+ cornersize : 20
201
162
  });
202
163
 
203
164
  rect2.name = '2';
@@ -206,7 +167,7 @@ var MEMECAPTAIN = (function (window, $, fabric) {
206
167
  canvas.add(rect2);
207
168
 
208
169
  canvas.observe('object:moving', function (o) {
209
- var target = o.memo.target,
170
+ var target = o.target,
210
171
 
211
172
  halfWidth = target.getWidth() / 2,
212
173
  leftSide = Math.round(target.getLeft() - halfWidth),
@@ -231,7 +192,7 @@ var MEMECAPTAIN = (function (window, $, fabric) {
231
192
  });
232
193
 
233
194
  canvas.observe('object:modified', function (o) {
234
- var target = o.memo.target;
195
+ var target = o.target;
235
196
 
236
197
  $('#t' + target.name + 'x').val(
237
198
  Math.round(target.getLeft() - (target.getWidth() / 2))
@@ -243,12 +204,34 @@ var MEMECAPTAIN = (function (window, $, fabric) {
243
204
  $('#t' + target.name + 'h').val(Math.round(target.getHeight()));
244
205
  });
245
206
 
207
+ canvas.observe('object:scaling', function (o) {
208
+ var target = o.target,
209
+ maxScaleX = canvas.width / target.width,
210
+ maxScaleY = canvas.height / target.height;
211
+
212
+ if (target.scaleX > maxScaleX) {
213
+ target.scaleX = maxScaleX;
214
+ }
215
+
216
+ if (target.scaleY > maxScaleY) {
217
+ target.scaleY = maxScaleY;
218
+ }
219
+
220
+ canvas.fire('object:moving', { target : target });
221
+ });
222
+
246
223
  canvas.fire('object:modified', { target : rect1 });
247
224
  canvas.fire('object:modified', { target : rect2 });
248
225
  });
249
226
  }
250
227
  }
251
228
 
229
+ function imgurLink(url) {
230
+ return $('<a />').attr('href',
231
+ 'http://api.imgur.com/2/upload?url=' +
232
+ encodeURIComponent(url)).append('imgur');
233
+ }
234
+
252
235
  function redditLink(url) {
253
236
  return $('<a />').attr('href',
254
237
  'http://www.reddit.com/submit?url=' +
@@ -348,6 +331,11 @@ var MEMECAPTAIN = (function (window, $, fabric) {
348
331
  append(templateLink)
349
332
  );
350
333
 
334
+ // imgur link
335
+ createdImageDiv.append($('<div />').addClass(
336
+ 'share'
337
+ ).append(imgurLink(data.imageUrl)));
338
+
351
339
  // reddit link
352
340
  createdImageDiv.append($('<div />').addClass(
353
341
  'share'
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "thumbHeight": 50,
3
- "thumbSpritesUrl": "http://memecaptain.com/thumbs_1334973608.jpg",
3
+ "thumbSpritesUrl": "http://memecaptain.com/thumbs_1339811279.jpg",
4
4
  "images": [
5
+ {
6
+ "url": "http://memecaptain.com/aliens.jpg",
7
+ "thumbWidth": 57
8
+ },
5
9
  {
6
10
  "url": "http://memecaptain.com/all_the_things.jpg",
7
11
  "thumbWidth": 67
@@ -58,6 +62,10 @@
58
62
  "url": "http://memecaptain.com/dwight_schrute.jpg",
59
63
  "thumbWidth": 73
60
64
  },
65
+ {
66
+ "url": "http://memecaptain.com/first_day_on_the_internet_kid.jpg",
67
+ "thumbWidth": 38
68
+ },
61
69
  {
62
70
  "url": "http://memecaptain.com/first_world_problems.jpg",
63
71
  "thumbWidth": 72
@@ -94,6 +102,10 @@
94
102
  "url": "http://memecaptain.com/me_gusta.png",
95
103
  "thumbWidth": 50
96
104
  },
105
+ {
106
+ "url": "http://memecaptain.com/megaman_derp.jpg",
107
+ "thumbWidth": 80
108
+ },
97
109
  {
98
110
  "url": "http://memecaptain.com/most_interesting.jpg",
99
111
  "thumbWidth": 40
@@ -118,6 +130,10 @@
118
130
  "url": "http://memecaptain.com/paranoid_parrot.jpg",
119
131
  "thumbWidth": 50
120
132
  },
133
+ {
134
+ "url": "http://memecaptain.com/patrick.jpg",
135
+ "thumbWidth": 28
136
+ },
121
137
  {
122
138
  "url": "http://memecaptain.com/philosoraptor.jpg",
123
139
  "thumbWidth": 50
@@ -162,6 +178,10 @@
162
178
  "url": "http://memecaptain.com/ti_duck.jpg",
163
179
  "thumbWidth": 50
164
180
  },
181
+ {
182
+ "url": "http://memecaptain.com/too_damn_high.jpg",
183
+ "thumbWidth": 61
184
+ },
165
185
  {
166
186
  "url": "http://memecaptain.com/town_crier.jpg",
167
187
  "thumbWidth": 75
@@ -170,6 +190,10 @@
170
190
  "url": "http://memecaptain.com/troll_face.jpg",
171
191
  "thumbWidth": 55
172
192
  },
193
+ {
194
+ "url": "http://memecaptain.com/troll_hunter.jpg",
195
+ "thumbWidth": 89
196
+ },
173
197
  {
174
198
  "url": "http://memecaptain.com/trolldad.png",
175
199
  "thumbWidth": 50
@@ -182,6 +206,10 @@
182
206
  "url": "http://memecaptain.com/tyler_durden.jpg",
183
207
  "thumbWidth": 50
184
208
  },
209
+ {
210
+ "url": "http://memecaptain.com/walter.jpg",
211
+ "thumbWidth": 67
212
+ },
185
213
  {
186
214
  "url": "http://memecaptain.com/wonka.jpg",
187
215
  "thumbWidth": 50
Binary file
Binary file
Binary file
data/views/index.erb CHANGED
@@ -31,7 +31,7 @@ then click its thumbnail.
31
31
 
32
32
  <p>
33
33
  <input type="text" id="imageSearch" />
34
- <input type="button" id="imageSearchButton" value="Image Search" /> powered by Bing and Google
34
+ <input type="button" id="imageSearchButton" value="Image Search" /> powered by Google
35
35
  </p>
36
36
 
37
37
  <div id="imageSearchResults"></div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meme_captain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
16
- requirement: &12380480 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12380480
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: curb
27
- requirement: &12334320 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *12334320
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: json
38
- requirement: &12333620 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *12333620
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: mime-types
49
- requirement: &12332760 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *12332760
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: mongo
60
- requirement: &12332260 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *12332260
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: mongo_mapper
71
- requirement: &12331800 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *12331800
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rack
82
- requirement: &12331360 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *12331360
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: rack-contrib
93
- requirement: &12330960 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: '0'
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *12330960
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: rack-rewrite
104
- requirement: &12330560 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ! '>='
@@ -109,10 +149,15 @@ dependencies:
109
149
  version: '0'
110
150
  type: :runtime
111
151
  prerelease: false
112
- version_requirements: *12330560
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: rmagick
115
- requirement: &12330160 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ! '>='
@@ -120,10 +165,15 @@ dependencies:
120
165
  version: '0'
121
166
  type: :runtime
122
167
  prerelease: false
123
- version_requirements: *12330160
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
124
174
  - !ruby/object:Gem::Dependency
125
175
  name: sinatra
126
- requirement: &12329760 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
127
177
  none: false
128
178
  requirements:
129
179
  - - ! '>='
@@ -131,10 +181,15 @@ dependencies:
131
181
  version: '0'
132
182
  type: :runtime
133
183
  prerelease: false
134
- version_requirements: *12329760
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
135
190
  - !ruby/object:Gem::Dependency
136
191
  name: rspec
137
- requirement: &12329240 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ! '>='
@@ -142,10 +197,15 @@ dependencies:
142
197
  version: '0'
143
198
  type: :development
144
199
  prerelease: false
145
- version_requirements: *12329240
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
146
206
  - !ruby/object:Gem::Dependency
147
207
  name: webmock
148
- requirement: &12328840 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
149
209
  none: false
150
210
  requirements:
151
211
  - - ! '>='
@@ -153,7 +213,12 @@ dependencies:
153
213
  version: '0'
154
214
  type: :development
155
215
  prerelease: false
156
- version_requirements: *12328840
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
157
222
  description: create meme images
158
223
  email:
159
224
  - matthewm@boedicker.org
@@ -203,6 +268,9 @@ files:
203
268
  - public/thumbs_1333591668.jpg
204
269
  - public/thumbs_1334189407.jpg
205
270
  - public/thumbs_1334973608.jpg
271
+ - public/thumbs_1336623277.jpg
272
+ - public/thumbs_1336624196.jpg
273
+ - public/thumbs_1339811279.jpg
206
274
  - public/tmp/.gitignore
207
275
  - script/thumb_sprites.rb
208
276
  - spec/caption_choice_spec.rb
@@ -236,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
304
  version: '0'
237
305
  requirements: []
238
306
  rubyforge_project:
239
- rubygems_version: 1.8.17
307
+ rubygems_version: 1.8.23
240
308
  signing_key:
241
309
  specification_version: 3
242
310
  summary: create meme images