function init(){w=window.innerWidth?window.innerWidth:$(window).width();h=window.innerHeight?window.innerHeight:$(window).height();canvas=new fabric.Canvas("container");canvas.setWidth(w);canvas.setHeight(h);canvas.calcOffset();canvas.on("object:added",function(n){setSelectionStyle(n.target)});canvas.on("selection:created",function(n){setSelectionStyle(n.target)});if(window.devicePixelRatio&&window.devicePixelRatio!==1){var n=canvas.getElement(),t=n.width,i=n.height;n.setAttribute("width",t*window.devicePixelRatio);n.setAttribute("height",i*window.devicePixelRatio);n.getContext("2d").scale(window.devicePixelRatio,window.devicePixelRatio)}createLineSetClass();createBackgroundObject();bindEvents();addSnappingLines();createInitialWall();gridFromSettings();styleFromSettings();reIndex();canvas.renderAll()}function loadCurrentPlan(){var n=1;supports_html5_storage()?localStorage.open_plan&&(localStorage.open_plan,current_plan=JSON.parse(localStorage.open_plan),jsonToCanvas(current_plan),n=0):readCookie("open_plan")&&(getPlan(readCookie("open_plan")),n=0);n&&(current_plan={UserId:udata.UserId,SessionId:udata.UserSession,Title:"Untitled RoomPlan",DealerId:udata.DealerId,CookieId:udata.UserCookie,SharedId:0,Objects:[{ObjectType:1,Corners:JSON.stringify(getWallArray())}]})}function newRoom(n,t,i,r){n=parseFloat(n);t=parseFloat(t);i=parseFloat(i);r=parseFloat(r);var f=i*12+r,e=n*12+t,o=canvas.getWidth()-$("#RoomPlanner1_RoomPlannerSideMenu").width(),h=canvas.getHeight()-$("#RoomPlanner1_RoomPlannerHeader").height(),u=e*settings.ppi,s=f*settings.ppi;(os-u?Math.round((o/u-.1)*10)/10:Math.round((h/s-.1)*10)/10);jsonToCanvas({Objects:[{ObjectType:1,Corners:JSON.stringify([[wall_left_offset,wall_top_offset],[wall_left_offset+e*settings.ppi*settings.CURSCALE,wall_top_offset],[wall_left_offset+e*settings.ppi*settings.CURSCALE,wall_top_offset+f*settings.ppi*settings.CURSCALE],[wall_left_offset,wall_top_offset+f*settings.ppi*settings.CURSCALE]])}],scale:settings.CURSCALE});delete current_plan.Id;current_plan.Title="Untitled RoomPlan"}function savePlanVar(){UpdateSaveStatus(!1);current_plan.UserId=udata.UserId;current_plan.SessionId=udata.UserSession;current_plan.DealerId=udata.DealerId;current_plan.CookieId=udata.UserCookie;current_plan.Objects=[{ObjectType:1,Corners:JSON.stringify(getWallArray())}];var n;current_plan.scale=settings.CURSCALE;canvas.forEachObject(function(t){t==backgroundObject||t.isLine||t.isTooltip||t.isSnapLine||t==gridObject||t.isPoint||t.isOnWall?t.isOnWall&&(n={ObjectType:t.Type,XCord:t.getLeft(),YCord:t.getTop(),Width:t.getWidth()/settings.ppi/settings.CURSCALE,Depth:t.getHeight()/settings.ppi/settings.CURSCALE,Rotation:t.get("angle")},current_plan.Objects.push(n)):(n={ObjectType:2,XCord:t.getLeft(),YCord:t.getTop(),Width:t.getWidth()/settings.ppi/settings.CURSCALE,Depth:t.getHeight()/settings.ppi/settings.CURSCALE,Rotation:t.get("angle")},t.itemid?(n.Gpid=t.itemid,n.IconId=t.iconid):n.GenericObjectType=t.producttype,current_plan.Objects.push(n))});supports_html5_storage()?localStorage.open_plan=JSON.stringify(current_plan):current_plan.Id&&createCookie("open_plan",current_plan.Id,365)}function savePlan(){savePlanVar();$.ajax({type:"POST",url:wsURL+"SavePlanData",dataType:"json",data:JSON.stringify(current_plan),success:function(n){current_plan.Id=n.Id;savePlanVar();UpdateSaveStatus(!0)}})}function getPlan(n){$.ajax({dataType:"jsonp",url:wsURL+"GetPlanData",data:{planid:n},success:function(n){jsonToCanvas(n);current_plan=n;udata.RoomPlannerId>0&&(!current_plan.SharedId||current_plan.SharedId!=udata.RoomPlannerId)&&(delete current_plan.Id,current_plan.SharedId=udata.RoomPlannerId);$("#roomPlanner_saveStatus_Title").html(current_plan.Title)}})}function jsonToCanvas(n){var i,t,r;if(n){settings.CURSCALE=Number(n.scale)||1;$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%");canvas.forEachObject(function(n){n==backgroundObject||n.isSnapLine||n==gridObject||canvas.remove(n)});canvas.renderAll();n.Objects=swapArray(n.Objects);n.Objects.unshift(n.Objects.pop());for(i in n.Objects)t=n.Objects[i],t.ObjectType==1?wall1=newWall(JSON.parse(t.Corners)):t.ObjectType==2?(t.GenericObjectType&&(r='[producttype="'+t.GenericObjectType+'"]',t.IconId=$(r).attr("iconid"),t.Gpid=0),t.GenericObjectType=t.GenericObjectType||0,addImg(t.XCord,t.YCord,t.Width*settings.ppi,t.Depth*settings.ppi,t.Rotation,"icon_"+t.IconId,t.Gpid,t.IconId,t.GenericObjectType)):t.ObjectType==3?(t.IconId="c",updateOnWall(addOnWall(t.XCord,t.YCord,t.Width*settings.ppi,3,"icon_"+t.IconId))):t.ObjectType==4?(t.IconId="b",updateOnWall(addOnWall(t.XCord,t.YCord,t.Width*settings.ppi*settings.CURSCALE,4,"icon_"+t.IconId))):t.ObjectType==5&&(t.IconId="a",updateOnWall(addOnWall(t.XCord,t.YCord,t.Width*settings.ppi*settings.CURSCALE,5,"icon_"+t.IconId)));reIndex();canvas.renderAll();savePlanVar()}}function bindDragging(n){n=n||"canvasObject";var t;$("."+n).draggable({revert:"true",helper:"clone",appendTo:"body",cursor:"move",scroll:!1,zIndex:999,opacity:.3,drag:function(i,r){var u,s,h;if(r.position.left>200-$("."+n).width()){u=r.helper.children("img");r.helper.children("span").hide();var f=u.width(),e=u.height(),v=f/e,l,a=0,o,c;u.hasClass("generic")?(o=u.attr("iconid"),f=parseInt(u.attr("width"),10),e=parseInt(u.attr("depth"),10),l=u.hasClass("structural"),c=u.attr("producttype")):(a=u.attr("itemgpid"),o=u.attr("iconid"),f=parseInt(u.attr("width"),10),e=parseInt(u.attr("depth"),10),u.attr("src",$("#icon_"+o).attr("src")),c=0);u.attr("id","current_image");s=$(canvas.wrapperEl).offset();t?(t.setLeft(r.position.left+f/2-s.left),t.setTop(r.position.top+e/2-s.top),canvas.renderAll()):(l?(o==="c"?h=3:o==="b"?h=4:o==="a"&&(h=5),t=addOnWall(r.position.left+f/2-s.left,r.position.top+e/2-s.top,f*settings.ppi,h,"current_image")):t=addImg(r.position.left+f/2-s.left,r.position.top+e/2-s.top,f*settings.ppi,e*settings.ppi,"0","current_image",a,o,c),t.setCoords(),canvas.calcOffset(),canvas.renderAll())}else t&&(canvas.remove(t),canvas.renderAll(),t=undefined)},stop:function(){t&&(t.isOnWall&&updateOnWall(t),t.setCoords(),t=undefined,reIndex())}})}function setSelectionStyle(n){n.set({borderColor:settings.style.selection.border.color,cornerColor:settings.style.selection.corner.color,cornerSize:settings.style.selection.corner.size,transparentCorners:settings.style.selection.corner.transparent});settings.style.selection.border.enabled||(n.hasBorders=!1)}function addOnWall(n,t,i,r,u){var e,o,s,f;return UpdateSaveStatus(!1),e=i,o="bottom",r==3&&(e=settings.style.walls.width,o="center"),s=document.getElementById(u),f=new fabric.Image(s,{left:n,top:t,width:i,height:e,scaleX:settings.CURSCALE,scaleY:settings.CURSCALE,padding:10,originX:"center",originY:o,centeredRotation:!1}),f.isOnWall=1,f.hasBorders=!1,f.Type=r,f.setControlsVisibility({tl:!1,bl:!0,tr:!1,mtr:!1,mb:!1,mt:!1,br:!0,InfoControl:!1,DepthMeasurement:!1}),(r==4||r==5)&&f.setControlsVisibility({tl:!1,bl:!0,tr:!1,mtr:!1,mb:!1,mt:!1,br:!0,mr:!1,ml:!1,InfoControl:!1,DepthMeasurement:!1}),canvas.add(f),canvas.renderAll(),f}function addImg(n,t,i,r,u,f,e,o,s){var c,h;return UpdateSaveStatus(!1),c=document.getElementById(f),c.crossOrigin="anonymous",h=new fabric.Image(c,{left:n,top:t,width:i,height:r,angle:u,scaleX:settings.CURSCALE,scaleY:settings.CURSCALE,originX:"center",originY:"center",producttype:s}),h.itemid=e,h.iconid=o,e?h.setControlsVisibility(controlsOptionsSpecific):h.setControlsVisibility(controlsOptions),h.padding=10,h.cornerSize=20,h.hasBorders=!1,canvas.add(h),h}function addRect(n,t,i,r,u){var f=new fabric.Rect({left:n,top:t,width:i,height:r,fill:u,scaleX:settings.CURSCALE,scaleY:settings.CURSCALE});return canvas.add(f),reIndex(),f}function infoPopup(){var n=selectedItem.itemid||0;if(current_popup=selectedItem,n)setTimeout(function(){ItemInfo(n,lastClick)},100);else{var t=selectedItem.iconid,i=selectedItem.producttype,r=$('[producttype="'+i+'"]').attr("ptn"),u=$("#icon_"+t).attr("src"),f=selectedItem.getWidth()/settings.ppi/settings.CURSCALE,e=selectedItem.getHeight()/settings.ppi/settings.CURSCALE,o=selectedItem.getAngle();setTimeout(function(){ItemInfoGeneric(r,f,e,o,u,lastClick)},100)}}function cloneThis(){if(UpdateSaveStatus(!1),!current_popup)return"no current popup";canvas.discardActiveObject();var n=fabric.util.object.clone(current_popup);n.setLeft(n.getLeft()+10);n.setTop(n.getTop()+10);canvas.add(n);canvas.setActiveObject(n);canvas.renderAll()}function updateFromPopup(n){if(!current_popup)return"no current popup";n.width&¤t_popup.setWidth(n.width*settings.ppi);n.height&¤t_popup.setHeight(n.height*settings.ppi);n.top&¤t_popup.setTop(n.top);n.left&¤t_popup.setLeft(n.left);n.angle&¤t_popup.setAngle(n.angle);current_popup.setCoords();canvas.renderAll()}function deleteThis(){if(!selectedItem){alert("no object selected");return}selectedItem.isPoint?deletePoint(selectedItem):canvas.remove(selectedItem);canvas.renderAll();selectedItem=undefined;return}function createInitialWall(){wall1=newWall([[wall_left_offset,wall_top_offset+wall_default_height_inches*settings.ppi],[wall_left_offset,wall_top_offset],[wall_default_width_inches*settings.ppi+wall_left_offset,wall_top_offset],[wall_default_width_inches*settings.ppi+wall_left_offset,wall_top_offset+wall_default_height_inches*settings.ppi]])}function reIndex(){var i=[],e,n,t,u,r,f;for(e in settings.indexes)i.push([]);n=canvas.getObjects();for(t in n)n[t]==backgroundObject?i[settings.indexes.background-1].push(n[t]):n[t].isLine?i[settings.indexes.walls-1].push(n[t]):n[t].isPoint?i[settings.indexes.corners-1].push(n[t]):n[t]==gridObject?i[settings.indexes.background-1].push(n[t]):n[t].isOnWall?i[settings.indexes.doorswindows-1].push(n[t]):i[settings.indexes.objects-1].push(n[t]);u=2;for(r in i)for(f in i[r])i[r][f].bringToFront(),u++;canvas.renderAll()}function getWallLength(n,t){var i=lineLength(n.x1/settings.CURSCALE,n.y1/settings.CURSCALE,n.x2/settings.CURSCALE,n.y2/settings.CURSCALE),r,u;return(i<0&&(i=0),t=="imperial")?(i=i/settings.ppi,i=Math.round(i*12)/12,r=Math.floor(i/12),u=Math.floor(i-r*12),r+"'"+u+'"'):t=="metric"?(i=Math.round(i/(settings.ppi/2.54)),i+"cm"):i}function distanceToLine(n,t,i,r,u,f){var o=i-n,s=r-t,v=o*o+s*s,e=((u-n)*o+(f-t)*s)/parseFloat(v);e>1?e=1:e<0&&(e=0);var h=n+e*o,c=t+e*s,l=h-u,a=c-f,y=Math.sqrt(l*l+a*a),p=Math.atan2(r-t,i-n)*(180/Math.PI);return{dist:y,x:h,y:c,angle:p}}function closestPointOnLine(n,t,i){var u,r,o,s;for(r in wall1)o=distanceToLine(wall1[r].line1.x1,wall1[r].line1.y1,wall1[r].line1.x2,wall1[r].line1.y2,n,t),s=distanceToLine(wall1[r].line2.x1,wall1[r].line2.y1,wall1[r].line2.x2,wall1[r].line2.y2,n,t),r==0&&(u=o),u.dist>o.dist&&(u=o),u.dist>s.dist&&(u=s);for(var h=i/360,f=u.angle/360,e=f+.5;e>1;)e--;while(e<0)e++;while(f>1)f--;while(f<0)f++;return Math.abs(f-h)>Math.abs(e-h)&&(u.angle=e*360),u}function updatePoints(n){var t,i;for(var r in wall1)wall1[r].line1==n&&(t=wall1[r]),wall1[r].line2==n&&(i=wall1[r]);t.setLeft(n.x1);t.setTop(n.y1);i.setLeft(n.x2);i.setTop(n.y2);t.setCoords();i.setCoords();canvas.fire("object:moving",{target:t});canvas.fire("object:moving",{target:i});updateWall(t);updateWall(i)}function updateWall(n){var f=n.left,e=n.top,o,t,i;n.group&&(o=n.group,f+=o.left,e+=o.top);n.line1.set({x1:f,y1:e});n.line1.setCoords();t=distanceToLine(n.line1.x1,n.line1.y1,n.line1.x2,n.line1.y2,n.line1.left,n.line1.top);(t.angle>90&&t.angle<=180||t.angle>=-180&&t.angle<-90)&&(t.angle+=180);var r=t.angle-90,u=20*settings.CURSCALE,s=Math.cos(r*(Math.PI/180))*u,h=Math.sin(r*(Math.PI/180))*u;n.line1.tooltip.setLeft(t.x+s);n.line1.tooltip.setTop(t.y+h);n.line1.tooltip.setAngle(t.angle);n.line1.tooltip.setCoords();n.line1.tooltip.setText(getWallLength(n.line1,settings.unitSystem));n.line2.set({x2:f,y2:e});n.line2.setCoords();i=distanceToLine(n.line2.x1,n.line2.y1,n.line2.x2,n.line2.y2,n.line2.left,n.line2.top);(i.angle>90&&i.angle<=180||i.angle>=-180&&i.angle<-90)&&(i.angle+=180);r=i.angle-90;s=Math.cos(r*(Math.PI/180))*u;h=Math.sin(r*(Math.PI/180))*u;n.line2.tooltip.setLeft(i.x+s);n.line2.tooltip.setTop(i.y+h);n.line2.tooltip.setAngle(i.angle);n.line2.tooltip.setCoords();n.line2.tooltip.setText(getWallLength(n.line2,settings.unitSystem));canvas.forEachObject(function(n){n.isOnWall&&updateOnWall(n)})}function getWallArray(){for(var i=[],u=wall1.length,n=wall1[0],r,t;n;){i.push([n.getLeft(),n.getTop()]);r=n.line1;for(t in wall1)wall1[t].line2==r&&(n=wall1[t]);n==wall1[0]&&(n=undefined)}return i}function newWall(n){var u=n.length,i=[],f,r,t,e;for(t in n)f=t+2<=u?addWall(n[t][0],n[t][1],n[parseFloat(t)+1][0],n[parseFloat(t)+1][1]):addWall(n[t][0],n[t][1],n[0][0],n[0][1]),i.push(f);r=[];for(t in n)e=parseFloat(t)+2<=u?addPoint(n[t][0],n[t][1],i[t],i[parseFloat(t)+1]):addPoint(n[t][0],n[t][1],i[t],i[0]),r.push(e);for(t in r)updateWall(r[t]);return r}function newWallOLD(n,t,i,r){var u=addWall(n[0],n[1],t[0],t[1]),f=addWall(r[0],r[1],i[0],i[1]),e=addWall(n[0],n[1],r[0],r[1]),o=addWall(t[0],t[1],i[0],i[1]),s=addPoint(n[0],n[1],u,e),h=addPoint(t[0],t[1],o,u),c=addPoint(r[0],r[1],e,f),l=addPoint(i[0],i[1],f,o);return updateWall(s),updateWall(h),updateWall(c),updateWall(l),[s,h,l,c]}function addWall(n,t,i,r){var u=new fabric.Line([n,t,i,r],{stroke:settings.style.walls.color,strokeWidth:settings.style.walls.width*settings.CURSCALE,selectable:!0,originX:"center",originY:"center"});return u.isLine=1,u.clicked=0,u.hasControls=u.hasBorders=!1,canvas.add(u),u.tooltip=new fabric.Text("10'5\"",{originX:"center",originY:"center",fontSize:settings.style.walls.tooltip.fontsize,fontFamily:"Arial",left:100,top:100}),canvas.add(u.tooltip),u.tooltip.hasControls=u.tooltip.hasBorders=u.tooltip.selectable=!1,u.tooltip.isTooltip=!0,u}function deletePoint(n){var t,f;if(!(wall1.length<3)){var i=n.line1,r=n.line2,u=addWall(100,100,200,200),e,o;for(t in wall1)(wall1[t].line1==i||wall1[t].line1==r)&&(wall1[t].line1=u,e=wall1[t]),(wall1[t].line2==i||wall1[t].line2==r)&&(wall1[t].line2=u,o=wall1[t]);wall1.splice(wall1.indexOf(n),1);canvas.remove(i);canvas.remove(i.tooltip);canvas.remove(r);canvas.remove(r.tooltip);canvas.remove(n);u.setCoords();canvas.renderAll();for(f in wall1)updateWall(wall1[f]);reIndex()}}function addPoint(n,t,i,r){var u=new fabric.Circle({left:n,top:t,strokeWidth:settings.style.walls.corners.strokeWidth,radius:settings.style.walls.corners.radius,fill:settings.style.walls.corners.fill,stroke:settings.style.walls.corners.stroke,originX:"center",originY:"center",scaleX:settings.CURSCALE,scaleY:settings.CURSCALE});return u.isPoint=1,u.line1=i,u.line2=r,u.hasBorders=!1,u.setControlsVisibility({tl:!1,bl:!1,tr:!1,mtr:!1,InfoControl:!1,mr:!1,mt:!1,ml:!1,mb:!1,br:!1,leftWall:!1,rightWall:!1}),canvas.add(u),u}function addSnappingLines(){snappingLinesX=[new fabric.Line([-2e3,130,2e3,130],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"}),new fabric.Line([-2e3,130,2e3,130],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"}),new fabric.Line([-2e3,130,2e3,130],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"})];snappingLinesY=[new fabric.Line([130,-2e3,130,2e3],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"}),new fabric.Line([130,-2e3,130,2e3],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"}),new fabric.Line([130,-2e3,130,2e3],{strokeWidth:1,stroke:"blue",selectable:!1,visible:!1,name:"snap"})];snappingLinesX[0].isSnapLine=snappingLinesX[1].isSnapLine=snappingLinesX[2].isSnapLine=snappingLinesY[0].isSnapLine=snappingLinesY[1].isSnapLine=snappingLinesY[2].isSnapLine=!0;canvas.add(snappingLinesX[0]);canvas.add(snappingLinesX[1]);canvas.add(snappingLinesX[2]);canvas.add(snappingLinesY[0]);canvas.add(snappingLinesY[1]);canvas.add(snappingLinesY[2])}function bindEvents(){canvas.on({"mouse:down":setHandleMousedown,"object:rotating":setHandleRotating,"object:moving":setHandleMoving,"mouse:up":setHandleMouseup,"object:scaling":setHandleScaling,"object:modified":setHandleModified,"selection:created":setHandleSelection,"object:selected":setHandleSelected});window.onresize=function(n){onResize(n)}}function setHandleSelected(n){if(selectedItem=n.target,n.target.isLine&&(n.target.oldx=n.target.left,n.target.oldy=n.target.top),n.target==backgroundObject||n.target.isLine){canvas.renderAll();selectedItem=undefined;return}reIndex();n.target.bringToFront()}function setHandleSelection(n){canvas.discardActiveObject();canvas.discardActiveGroup();canvas.remove(n.target);canvas.renderAll();return}function setHandleModified(n){n.target.isOnWall&&updateOnWall(n.target);savePlanVar()}function updateOnWall(n){var t=closestPointOnLine(n.getLeft(),n.getTop(),n.getAngle()),i=15,r=0,u=0;(n.Type==4||n.Type==5)&&(r=Math.cos((t.angle+90)/(180/Math.PI))*i,u=Math.sin((t.angle+90)/(180/Math.PI))*i);n.setLeft(t.x+r);n.setTop(t.y+u);n.angle=t.angle;n.setCoords()}function setHandleMousedown(n){lastClick.x=n.e.clientX;lastClick.y=n.e.clientY;obj=n.target;obj==backgroundObject&&(canvas.renderAll(),selectedItem=undefined,n.target.hasControls=n.target.hasBorders=!1,backgroundX=obj.getLeft(),backgroundY=obj.getTop());canvas.renderAll()}function setHandleMouseup(n){var u=canvas.getPointer(n.e).x,f=canvas.getPointer(n.e).y,t,e,s,h,i,r,o;if(n.target){if(n.target.isLine&&(t=n.target,t.clicked)){e=[addWall(u,f,u,f),addWall(u,f,u,f)];for(i in wall1)wall1[i].line1==t&&(r=e.shift(),wall1[i].line1=r,h=r,updateWall(wall1[i])),wall1[i].line2==t&&(r=e.shift(),wall1[i].line2=r,s=r,updateWall(wall1[i]));o=addPoint(u,f,s,h);wall1.push(o);t.tooltip.sendToBack();t.sendToBack();canvas.remove(t.tooltip);canvas.remove(t);canvas.fire("object:moving",{target:o});reIndex();canvas.renderAll()}n.target.clicked=1;setTimeout(function(){n.target.clicked=0},1e3);snappingLinesY[0].visible=!1;snappingLinesY[1].visible=!1;snappingLinesY[2].visible=!1;snappingLinesX[0].visible=!1;snappingLinesX[1].visible=!1;snappingLinesX[2].visible=!1;canvas.renderAll()}}function setHandleRotating(n){if(settings.snapping.rotating.enabled){for(obj=n.target;obj.angle>360;)obj.angle-=360;while(obj.angle<0)obj.angle+=360;var t=settings.snapping.rotating.sensitivity;Math.abs(obj.angle-90)2)return;a=o-h;obj.setLeft(t.left+t.width/2+a);obj.setCoords();obj.isPoint&&updateWall(obj);snappingLinesY[i].set({x1:o,x2:o});snappingLinesY[i].moveTo(1e3);snappedx.push(i);i++}}for(f in t.y){l=t.y[f];for(e in u.y)if((e==1||f!=1)&&(e!=1||f==1)&&(s=u.y[e],Math.abs(l-s)<=c)){if(r>2)return;v=s-l;obj.setTop(t.top+t.height/2+v);obj.setCoords();obj.isPoint&&updateWall(obj);snappingLinesX[r].set({y1:s,y2:s});snappingLinesX[r].moveTo(1e3);snappedy.push(r);r++}}snappingLinesY[0].visible=!1;snappingLinesY[1].visible=!1;snappingLinesY[2].visible=!1;snappingLinesX[0].visible=!1;snappingLinesX[1].visible=!1;snappingLinesX[2].visible=!1;for(y in snappedx)snappingLinesY[snappedx[y]].visible=!0;for(p in snappedy)snappingLinesX[snappedy[p]].visible=!0;obj.snappedx=0;obj.snappedy=0;obj.setCoords()}})}canvas.renderAll()}}function setHandleScaling(){settings.snapping.moving.enabled}function createBackgroundObject(){backgroundObject=new fabric.Rect({width:4e3,height:4e3,left:1e3,top:1e3,originX:"center",originY:"center",fill:settings.style.general.background});canvas.add(backgroundObject);backgroundObject.selectable=!0;backgroundObject.hasControls=backgroundObject.hasBorders=!1;backgroundObject.sendToBack()}function enableMoving(){$("#drag").addClass("selected");$("#select").removeClass("selected");canvas.discardActiveObject();canvas.discardActiveGroup();backgroundObject.selectable=!0;selectedGroup=undefined;canvas.renderAll()}function disableMoving(){$("#select").addClass("selected");$("#drag").removeClass("selected");backgroundObject.selectable=!1}function createLineSetClass(){LineSet=fabric.util.createClass(fabric.Rect,{initialize:function(n,t,i){this.points=n;this.width=t;this.color=i},render:function(n){var t,i;if(this.visible!==!1){n.beginPath();n.strokeStyle=this.color;n.lineWidth=this.width;t=this.points;for(i in t)n.moveTo(t[i][0][0],t[i][0][1]),n.lineTo(t[i][1][0],t[i][1][1]);n.closePath();n.stroke()}},setLeft:function(n){var t=this.points;for(var i in t)t[i][0][0]+=n,t[i][1][0]+=n;this.points=t},setTop:function(n){var t=this.points;for(var i in t)t[i][0][1]+=n,t[i][1][1]+=n;this.points=t}})}function styleFromSettings(){canvas.forEachObject(function(n){setSelectionStyle(n);n.isLine?(n.strokeWidth=settings.style.walls.width,n.stroke=settings.style.walls.color):n.isPoint&&(n.stroke=settings.style.walls.corners.stroke,n.fill=settings.style.walls.corners.fill,n.radius=settings.style.walls.corners.radius,n.strokeWidth=settings.style.walls.corners.strokeWidth)});backgroundObject.fill=settings.style.general.background;canvas.renderAll()}function gridFromSettings(){settings.grid.enabled?gridLines(settings.grid.spacing,settings.grid.width,settings.grid.color):gridObject&&(canvas.remove(gridObject),gridObject=undefined,canvas.renderAll())}function gridLines(n,t,i){var r,u,f;if(backgroundObject){for(settings.CURSCALE&&(n*=settings.CURSCALE),r=[],x=-2e3;x<=backgroundObject.width/2;x+=n)u=[[x,-2e3],[x,2e3]],f=[[-2e3,x],[2e3,x]],r.push(u),r.push(f);gridObject&&(canvas.remove(gridObject),gridObject=undefined);gridObject=new LineSet(r,t,i);gridObject.name="grid";canvas.add(gridObject);reIndex();canvas.renderAll()}}function afterZoom(n,t){var u=canvas.width*n,f=canvas.width*t,i=(u-f)/2,e=canvas.height*n,o=canvas.height*t,r=(e-o)/2;canvas.forEachObject(function(n){n.isLine?(n.x1+=i,n.x2+=i,n.y1+=r,n.y2+=r,n.set({x1:n.x1}),n.setCoords()):n!=backgroundObject&&(n.setLeft(n.getLeft()+i),n.setTop(n.getTop()+r),n.setCoords())})}function zoomIn(){var n,t,i;if(!(settings.CURSCALE>3)){n=canvas.getObjects();for(t in n)if(n[t].isLine||n[t].isTooltip)n[t].isLine&&(n[t].strokeWidth=n[t].strokeWidth/settings.CURSCALE*(settings.CURSCALE+.1));else{var r=n[t].scaleX,u=n[t].scaleY,f=n[t].left,e=n[t].top,o=r/settings.CURSCALE*(settings.CURSCALE+.1),s=u/settings.CURSCALE*(settings.CURSCALE+.1),h=f/settings.CURSCALE*(settings.CURSCALE+.1),c=e/settings.CURSCALE*(settings.CURSCALE+.1);n[t].scaleX=o;n[t].scaleY=s;n[t].left=h;n[t].top=c;n[t].setCoords()}settings.CURSCALE+=.1;for(i in wall1)updateWall(wall1[i]);gridFromSettings();afterZoom(settings.CURSCALE-.1,settings.CURSCALE);canvas.renderAll();$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%")}}function zoomOut(){var n,t,i;if(!(settings.CURSCALE<.5)){n=canvas.getObjects();for(t in n)if(n[t].isLine||n[t].isTooltip)n[t].isLine&&(n[t].strokeWidth=n[t].strokeWidth/settings.CURSCALE*(settings.CURSCALE-.1));else{var r=n[t].scaleX,u=n[t].scaleY,f=n[t].left,e=n[t].top,o=r/settings.CURSCALE*(settings.CURSCALE-.1),s=u/settings.CURSCALE*(settings.CURSCALE-.1),h=f/settings.CURSCALE*(settings.CURSCALE-.1),c=e/settings.CURSCALE*(settings.CURSCALE-.1);n[t].scaleX=o;n[t].scaleY=s;n[t].left=h;n[t].top=c;n[t].setCoords()}settings.CURSCALE-=.1;for(i in wall1)updateWall(wall1[i]);gridFromSettings();afterZoom(settings.CURSCALE+.1,settings.CURSCALE);canvas.renderAll();$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%")}}function onResize(){if(w=$(window).width(),h=$(window).height(),canvas.setWidth(w),canvas.setHeight(h),window.devicePixelRatio&&window.devicePixelRatio!==1){var n=canvas.getElement(),t=n.width,i=n.height;n.setAttribute("width",t*window.devicePixelRatio);n.setAttribute("height",i*window.devicePixelRatio);n.getContext("2d").scale(window.devicePixelRatio,window.devicePixelRatio)}canvas.calcOffset();canvas.renderAll()}function lineLength(n,t,i,r){return Math.sqrt((n-i)*(n-i)+(t-r)*(t-r))}function createCookie(n,t,i){var u,r;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString()):u="";document.cookie=n+"="+t+u+"; path=/"}function readCookie(n){for(var t,r=n+"=",u=document.cookie.split(";"),i=0;i0&&(u=$.ajax({url:wsURL+"GetProduct",type:"GET",cache:"true",jsonpCallback:"product_data_function",data:{gpid:n,dealerid:1},dataType:"jsonp",success:function(n){$(".roomPlanner_iteminfoImage img").attr("src",n.Image);$(".roomPlanner_iteminfoHeader").html(n.MDesc);$(".roomPlanner_itemInfoSDesc").html(n.SDesc);$("#roomPlanner_iteminfoViewItemPage").attr("href","Item.aspx?ItemId="+n.ItemId+"&ItemNum="+n.ItemNum);$("#roomPlanner_iteminfoRequestMoreInfo").attr("href","ContactUs.aspx?items="+n.ItemId+"~"+n.ItemNum);$("#roomPlanner_iteminfoProduct_Width").html(n.Width);$("#roomPlanner_iteminfoProduct_Depth").html(n.Depth);$("#roomPlanner_iteminfoProduct_Height").html(n.Height);$(".roomPlanner_iteminfoAddToCart").attr("rel","{'ItemId':'"+n.ItemId+"','ItemNum':'"+n.ItemNum+"','CollectionId':'"+n.CollectionId+"','CollectionNum':'"+n.CollectionNum+"','Type':'ShoppingCart'}");r+$("#roomPlanner_iteminfoProduct").height()>$(window).height()&&(r=r-$("#roomPlanner_iteminfoProduct").height());i+$("#roomPlanner_iteminfoProduct").width()>$(window).width()&&(i=i-$("#roomPlanner_iteminfoProduct").width());rpMobile&&(i=(window.innerWidth?window.innerWidth:$(window).width())/2-$("#roomPlanner_iteminfoProduct").width()/2,r=(window.innerHeight?window.innerHeight:$(window).height())/2-$("#roomPlanner_iteminfoProduct").height()/2);$("#roomPlanner_iteminfoProduct").css({left:i,top:r});$("#roomPlanner_iteminfoProduct").show()}}))}function ItemInfoGeneric(n,t,i,r,u,f){var e=f.x+50,o=f.y-20;$(".roomPlanner_iteminfo").hide();$(".roomPlanner_iteminfoImage img").attr("src",u);$(".roomPlanner_iteminfoHeader").html(n);$("#roomPlanner_iteminfoGeneric_Width").val(Math.round(t));$("#roomPlanner_iteminfoGeneric_Depth").val(Math.round(i));o+$("#roomPlanner_iteminfoGeneric").height()>$(window).height()&&(o=o-$("#roomPlanner_iteminfoGeneric").height());e+$("#roomPlanner_iteminfoGeneric").width()>$(window).width()&&(e=e-$("#roomPlanner_iteminfoGeneric").width());rpMobile&&(e=(window.innerWidth?window.innerWidth:$(window).width())/2-$("#roomPlanner_iteminfoGeneric").width()/2,o=(window.innerHeight?window.innerHeight:$(window).height())/2-$("#roomPlanner_iteminfoGeneric").height()/2);$("#roomPlanner_iteminfoGeneric").css({left:e,top:o}).show()}function CreateRoom(){var n=document.getElementById("NewRoom_WidthFt").value,t=document.getElementById("NewRoom_WidthIn").value,i=document.getElementById("NewRoom_HeightFt").value,r=document.getElementById("NewRoom_HeightIn").value;newRoom(n,t,i,r);$("#roomPlanner_saveStatus_Title").html(current_plan.Title);$(".roomPlanner_startpageWrapper").hide()}function GetSavedPlans(){var n="";$.ajax({dataType:"jsonp",url:wsURL+"GetSavedPlansList",jsonpCallback:"plans_data_function",data:{uId:udata.UserId,uSess:udata.UserSession},success:function(t){if(t.RoomPlans!=""){n+="

Click a room plan below to load it into the room planner<\/p>";n+='

';for(var i in t.RoomPlans)n+='
'+t.RoomPlans[i].Title+"<\/div>";n+="<\/div>"}else n="

You have no saved plans<\/p>";$(".roomPlanner_openSavedPlanData").html(n).parent().parent().show();savePlanVar()}})}function OpenPlan(n){getPlan(n);$(".roomPlanner_openSavedPlanWrapper").hide()}function OpenSavePlan(){current_plan.Title!=undefined&&(document.getElementById("SaveRoom_Title").value=current_plan.Title);$(".roomPlanner_saveroomplanWrapper").show()}function OpenRPHelp(){$(".roomPlanner_helpWrapper").show()}function saveRoomPlan(){current_plan.Title=document.getElementById("SaveRoom_Title").value;current_plan.Title.match(/^[A-Za-z0-9 _.-]+$/)?(savePlan(),$(".roomPlanner_saveroomplanWrapper").hide()):alert("Please enter only alphanumeric characters (letters A-Z, numbers 0-9, hyphens, underscores, and periods)")}function UpdateSaveStatus(n){n?($(".roomPlanner_saveStatus").addClass("roomPlanner_saveStatus_saved"),$("#roomPlanner_saveStatus_Text").html("Saved "),$("#roomPlanner_saveStatus_Title").html(current_plan.Title)):($(".roomPlanner_saveStatus").removeClass("roomPlanner_saveStatus_saved"),$("#roomPlanner_saveStatus_Text").html("Working on "));roomPlanSaved=n}function AddToRoomPlan(data){addToRoomPlanItemData=eval("("+$(data).attr("rel")+")");ToggleRoomPlanner()}function PrintRoomPlan(){window.open().document.write(canvas.toSVG())}function ItemInfoUpdate(){updateFromPopup({width:document.getElementById("roomPlanner_iteminfoGeneric_Width").value,height:document.getElementById("roomPlanner_iteminfoGeneric_Depth").value})}function buildSideMenu(n){refreshQuickList();$.ajax({type:"GET",url:"http://api.furnituredealer.net/RoomPlannerV1.svc/GetGenericProductTypes",dataType:"jsonp",success:function(t){var r=t.Icons,f="",i="",e=!0;for(var u in r)f!=r[u].RoomName&&(f=r[u].RoomName,e?e=!1:i+="<\/div>",i+=f==null?'

Miscellaneous<\/h3>
':'

'+r[u].RoomName+"<\/h3>
"),i+="

"+r[u].ProductType+"<\/span><\/p>";i+="<\/div>";i+='

Structural<\/h3>';i+="
";i+="

Door (Opens Right)<\/span><\/p>";i+="

Door (Opens Left)<\/span><\/p>";i+="

Window<\/span><\/p>";i+="

Fireplace<\/span><\/p>";i+="

French Doors<\/span><\/p>";i+="

Sliding Doors<\/span><\/p>";i+="

Stairs<\/span><\/p>";i+="<\/div>";$(".roomPlanner_sidemenuNav").height((window.innerHeight?window.innerHeight:$(window).height())-$(".roomPlanner_header").height()-$(".roomPlanner_sidemenuHeader").height());$("#roomPlanner_sidemenuProducts").html(i);n&&n()}})}function refreshQuickList(){var n,t;$(".quickListItem").length>0?(n='

Drag your QuickList items to add them to your room plan<\/div>',n+='
',$(".quickListItem").each(function(){n+=$(this).children(".quickListItemImageContainer").children(".quickListItemImage").attr("iconid")==0?'

'+$(this).children(".quickListItemImageContainer").html()+"<\/p>":'

'+$(this).children(".quickListItemImageContainer").html()+"<\/p>"}),n+="<\/div>",$("#roomPlanner_sidemenuQuickList").html(n),$(".roomPlanner_sidemenuQuickListContainer").height($(window).height()-$(".roomPlanner_header").height()-$(".roomPlanner_sidemenuHeader").height()-$(".roomPlanner_sidemenuQuickList_header").height()-20),bindDragging("roomPlanner_quickListItems"),SideMenuTab($(".roomPlanner_sidemenuHeaderTabs:eq(0)"),0)):(t='

No QuickList Items<\/b>',t+='

To get started, add items to your QuickList or click the ICONS tab for generic products.<\/p>',t+="<\/div>",$("#roomPlanner_sidemenuQuickList").html(t),SideMenuTab($(".roomPlanner_sidemenuHeaderTabs:eq(1)"),1))}function checkImagesLoaded(){var n=!0;$(".canvasObject").each(function(){return n=n&&this.complete});n?(loadCurrentPlan(),udata.RoomPlannerId>0&&(!current_plan.SharedId||current_plan.SharedId!=udata.RoomPlannerId)&&getPlan(udata.RoomPlannerId),bindDragging("canvasObjectContainer"),bindScrollZoom(),$(".roomPlanner_sidemenuHeaderTabs").show(),$(".roomPlanner_sidemenuHeader_pointer").css("left",$(".roomPlanner_sidemenuHeaderTabs:first-child").width()*.5-7.5).show(),$("#roomPlanner_saveStatus_Title").html(current_plan.Title),addToRoomPlanItemData&&(addImg(200,200,addToRoomPlanItemData.width*settings.ppi,addToRoomPlanItemData.depth*settings.ppi,0,"icon_"+addToRoomPlanItemData.iconid,addToRoomPlanItemData.gpid,addToRoomPlanItemData.iconid),canvas.renderAll(),addToRoomPlanItemData=""),$(".roomPlanner_quickListItems").length==0&&SideMenuTab($(".roomPlanner_sidemenuHeaderTabs:eq(1)"),1),$(".roomPlanner_loadingWrapper").fadeOut()):setTimeout(checkImagesLoaded,100)}function verticallyCenterProductIcons(){$(".roomPlanner_sidemenuActive > .canvasObjectContainer").each(function(){$(this).children(".canvasObject").css("margin-top",($(this).height()-$(this).children(".canvasObject").height())/2-$(this).children("span").height()/2)})}function sideMenuClick(n){var t=$("#roomPlanner_sidemenuProducts").height(),i=($("#roomPlanner_sidemenuProducts h3").height()+1)*$("#roomPlanner_sidemenuProducts h3").size();$(n).next().hasClass("roomPlanner_sidemenuActive")||($(".roomPlanner_sidemenuHeaderActive").removeClass("roomPlanner_sidemenuHeaderActive"),$(n).addClass("roomPlanner_sidemenuHeaderActive"),$(".roomPlanner_sidemenuActive").slideToggle().removeClass("roomPlanner_sidemenuActive"),$(n).next().css("height",t-i).addClass("roomPlanner_sidemenuActive").slideToggle(),verticallyCenterProductIcons())}function toggleSideMenu(){$(".roomPlanner_sidemenuWrapper").hasClass("roomPlanner_sidemenuWrapperClosed")?($(".roomPlanner_sidemenuWrapper").removeClass("roomPlanner_sidemenuWrapperClosed"),$(".roomPlanner_mainWrapper").removeClass("roomPlanner_sidemenuClosed"),$(".roomPlanner_sidemenuToggle").removeClass("roomPlanner_sidemenuToggleClosed")):($(".roomPlanner_sidemenuWrapper").addClass("roomPlanner_sidemenuWrapperClosed"),$(".roomPlanner_mainWrapper").addClass("roomPlanner_sidemenuClosed"),$(".roomPlanner_sidemenuToggle").addClass("roomPlanner_sidemenuToggleClosed"));setTimeout(function(){canvas.calcOffset();canvas.renderAll()},1e3)}function SideMenuTab(n,t){$(".roomPlanner_sidemenuNav > div").hide();$(".roomPlanner_sidemenuNav > div:eq("+t+")").show();$(".roomPlanner_sidemenuHeader_pointer").css("left",$(n).position().left+$(n).width()/2-7.5);t!=1||$("#roomPlanner_sidemenuProducts > h3").hasClass("roomPlanner_sidemenuHeaderActive")||sideMenuClick($("#roomPlanner_sidemenuProducts h3:first-child"))}function roomPlannerTip(n){n?$(".roomPlanner_helpTipActive").next(".roomPlanner_helpTip").length>0&&$(".roomPlanner_helpTipActive").removeClass("roomPlanner_helpTipActive").next().addClass("roomPlanner_helpTipActive"):$(".roomPlanner_helpTipActive").prev(".roomPlanner_helpTip").length>0?($(".roomPlanner_helpTipActive").removeClass("roomPlanner_helpTipActive").prev().addClass("roomPlanner_helpTipActive"),$(".roomPlanner_helpNav_prev").removeClass("roomPlanner_helpNav_end"),$(".roomPlanner_helpNav_prev").attr("aria-disabled","false")):($(".roomPlanner_helpNav_prev").addClass("roomPlanner_helpNav_end"),$(".roomPlanner_helpNav_prev").attr("aria-disabled","true"));$(".roomPlanner_helpTipActive").next(".roomPlanner_helpTip").length>0?$(".roomPlanner_helpNav_next").removeClass("roomPlanner_helpNav_end"):$(".roomPlanner_helpNav_next").addClass("roomPlanner_helpNav_end");$(".roomPlanner_helpTipActive").prev(".roomPlanner_helpTip").length>0?$(".roomPlanner_helpNav_prev").removeClass("roomPlanner_helpNav_end"):$(".roomPlanner_helpNav_prev").addClass("roomPlanner_helpNav_end")}function bindScrollZoom(){$(".roomPlanner_main").bind("DOMMouseScroll",function(n){n.originalEvent.detail>0?zoomOut():zoomIn()});$(".roomPlanner_main").bind("mousewheel",function(n){n.originalEvent.wheelDelta<0?zoomOut():zoomIn()})}var w,h,fabric,Cufon,JSON,eventjs,Event,addToRoomPlanItemData,roomPlanSaved,resizeCanvas;settings={CURSCALE:1,ppi:4.5,unitSystem:"imperial",snapping:{moving:{enabled:1,sensitivity:10},rotating:{enabled:1,sensitivity:15}},indexes:{background:1,walls:2,corners:3,objects:4,doorswindows:5},grid:{enabled:1,width:1,spacing:30,color:"#efefef"},style:{general:{background:"white"},selection:{border:{enabled:1,color:"black"},corner:{size:20,transparent:!0,color:"black"}},walls:{tooltip:{fontsize:18},color:"grey",width:15,corners:{stroke:"#666",fill:"white",radius:15,strokeWidth:3}}}};w=window.innerWidth?window.innerWidth:$(window).width();h=window.innerHeight?window.innerHeight:$(window).height();settings.CURSCALE=1;var controlsOptions={tl:!1,bl:!1,tr:!1,mtr:!1,leftWall:!1,rightWall:!1},controlsOptionsSpecific={tl:!1,bl:!1,tr:!1,mtr:!1,mb:!1,mt:!1,mr:!1,ml:!1,leftWall:!1,rightWall:!1},wall_left_offset=50,wall_top_offset=50,wall_default_width_inches=204,wall_default_height_inches=180,gridObject,canvas,current_popup,snappingLinesX,snappingLinesY,backgroundObject,backgroundX,backgroundY,selectedGroup,selectedItem,LineSet,wall1,lastClick={},current_plan={};$(window).load(function(){canvas});fabric=fabric||{version:"1.4.0"};typeof exports!="undefined"&&(exports.fabric=fabric);typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom("<\/head><\/body><\/html>"),fabric.window=fabric.document.createWindow());fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement;fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined";fabric.SHARED_ATTRIBUTES=["transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width"];Cufon=function(){function v(n){var t=this.face=n.face;this.glyphs=n.glyphs;this.w=n.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 i=t.bbox.split(/\s+/),n={minX:parseInt(i[0],10),minY:parseInt(i[1],10),maxX:parseInt(i[2],10),maxY:parseInt(i[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 y(){var n={},t={oblique:"italic",italic:"oblique"};this.add=function(t){(n[t.style]||(n[t.style]={}))[t.weight]=t};this.get=function(i,r){var f=n[i]||n[t[i]]||n.normal||n.italic||n.oblique,s,h,e,o,u;if(!f)return null;if(r={normal:400,bold:700}[r]||parseInt(r,10),f[r])return f[r];s={1:1,99:0}[r%100];h=[];s===undefined&&(s=r>400);r==500&&(r=400);for(u in f)u=parseInt(u,10),(!e||uo)&&(o=u),h.push(u);return ro&&(r=o),h.sort(function(n,t){return(s?n>r&&t>r?nt:nt:n=u.length+f?r():setTimeout(arguments.callee,10)}),function(i){n?i():t.push(i)}}(),supports:function(n,t){var i=fabric.document.createElement("span").style;return i[n]===undefined?!1:(i[n]=t,i[n]===t)},textAlign:function(n,t,i,r){return t.get("textAlign")=="right"?i>0&&(n=" "+n):ict&&(ct=a);et.push(a);a=0;continue}(lt=n.glyphs[y[h]]||n.missingGlyph,lt)&&(a+=ht=Number(lt.w||n.w)+k)}for(et.push(a),a=Math.max(ct,a),c=[],h=et.length;h--;)c[h]=a-et[h];if(ht===null)return null;wt+=g.width-ht;ut+=g.minX;pt?(p=o,w=o.firstChild):(p=fabric.document.createElement("span"),p.className="cufon cufon-canvas",p.alt=i,w=fabric.document.createElement("canvas"),p.appendChild(w),e.printable&&(ot=fabric.document.createElement("span"),ot.className="cufon-alt",ot.appendChild(fabric.document.createTextNode(i)),p.appendChild(ot)));var st=p.style,bt=w.style||{},kt=v.convert(g.height-rt+0),at=Math.ceil(kt),dt=at/kt;w.width=Math.ceil(v.convert(a+wt-ut)*dt);w.height=at;rt+=g.minY;bt.top=Math.round(v.convert(rt-n.ascent))+"px";bt.left=Math.round(v.convert(ut))+"px";var gt=Math.ceil(v.convert(a*dt)),ni=gt+"px",vt=v.convert(n.height),ti=(e.lineHeight-1)*v.convert(-n.ascent/5)*(tt-1);for(Cufon.textOptions.width=gt,Cufon.textOptions.height=vt*tt+ti,Cufon.textOptions.lines=tt,Cufon.textOptions.totalLineHeight=ti,t?(st.width=ni,st.height=vt+"px"):(st.paddingLeft=ni,st.paddingBottom=vt-1+"px"),s=Cufon.textOptions.context||w.getContext("2d"),l=at/g.height,Cufon.textOptions.fontAscent=n.ascent*l,Cufon.textOptions.boundaries=null,ii=Cufon.textOptions.shadowOffsets,h=nt.length;h--;)ii[h]=[nt[h][0]*l,nt[h][1]*l];if(s.save(),s.scale(l,l),s.translate(-ut-1/l*w.width/2+(Cufon.fonts[n.family].offsetLeft||0),-rt-Cufon.textOptions.height/l/2+(Cufon.fonts[n.family].offsetTop||0)),s.lineWidth=n.face["underline-thickness"],s.save(),it=Cufon.getTextDecoration(e),yt=e.fontStyle==="italic",s.save(),ei(),b)for(h=0,d=b.length;h.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(n,t,u,f,e,o,s){var nt=t===null,c,p,k,st;nt&&(t=e.alt);var b=n.viewBox,v=u.computedFontSize||(u.computedFontSize=new Cufon.CSS.Size(r(o,u.get("fontSize"))+"px",n.baseSize)),y=u.computedLSpacing;y==undefined&&(y=u.get("letterSpacing"),u.computedLSpacing=y=y=="normal"?0:~~v.convertFrom(i(o,y)));nt?(c=e,p=e.firstChild):(c=fabric.document.createElement("span"),c.className="cufon cufon-vml",c.alt=t,p=fabric.document.createElement("span"),p.className="cufon-vml-canvas",c.appendChild(p),f.printable&&(k=fabric.document.createElement("span"),k.className="cufon-alt",k.appendChild(fabric.document.createTextNode(t)),c.appendChild(k)),s||c.appendChild(fabric.document.createElement("cvml:shape")));var ct=c.style,tt=p.style,lt=v.convert(b.height),it=Math.ceil(lt),at=it/lt,rt=b.minX,vt=b.minY;tt.height=it;tt.top=Math.round(v.convert(vt-n.ascent));tt.left=Math.round(v.convert(rt));ct.height=v.convert(n.height)+"px";for(var ui=Cufon.getTextDecoration(f),ni=u.get("color"),ut=Cufon.CSS.textTransform(t,u).split(""),ft=0,yt=0,et=null,l,h,ot=f.textShadow,w=0,pt=0,wt=ut.length;wlt&&window.clearInterval(et);document.querySelector(s)&&(window.clearInterval(et),setTimeout(c,1))},at);return}if(typeof s=="string"){if(s=document.querySelectorAll(s),s.length===0)return u("Missing target on listener!",arguments);s.length===1&&(s=s[0])}if(nt={},s.length>0&&s!==window){for(tt=0,ot=s.length;tt=r.maxFingers){e=[];for(u in r.tracker)e.push(u);return i.identifier=e.join(","),a}y=0;for(l in f){if(f[l].up){delete f[l];s(o,u);r.cancel=!0;break}y++}if(f[u])continue;s(o,u)}else f=r.tracker={},i.bbox=r.bbox=n.getBoundingBox(r.target),r.fingers=0,r.cancel=!1,s(o,u);e=[];for(u in r.tracker)e.push(u);return i.identifier=e.join(","),a},n.pointerEnd=function(n,t,i,r){for(var c,f,o,u,s=n.touches||[],l=s.length,h={},e=0;e0&&h0&&c1)){i.state=t.gesture;for(h in t.tracker)break;s=t.tracker[h];i.x=s.start.x;i.y=s.start.y;t.listener(f,i)}clearTimeout(e);r=u=0}},i=n.pointerSetup(t),i.state="dblclick",Event.add(t.target,"mousedown",t.onPointerDown),i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.dbltap=n.dbltap,Event.Gesture._gestureHandlers.dblclick=n.dblclick,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.dragElement=function(t,i){n.drag({event:i,target:t,position:"move",listener:function(n,i){t.style.left=i.x+"px";t.style.top=i.y+"px";Event.prevent(n)}})},n.drag=function(t){t.gesture="drag";t.onPointerDown=function(r){n.pointerStart(r,i,t)&&(t.monitor||(Event.add(t.doc,"mousemove",t.onPointerMove),Event.add(t.doc,"mouseup",t.onPointerUp)));t.onPointerMove(r,"down")};t.onPointerMove=function(r,u){var e;if(!t.tracker)return t.onPointerDown(r);var s=t.bbox,h=r.changedTouches||n.getCoords(r),l=h.length;for(e=0;ef&&(p=v*d/g,nt=Math.abs(p+c.value),c.value&&nt=c&&o>i.threshold&&(s.x/=h,s.y/=h,r.start=s,r.x=p/h,r.y=w/h,r.angle=-(((e/i.snap+.5>>0)*i.snap||360)-360),r.velocity=o,r.fingers=c,r.state="swipe",i.listener(u,r))}};var r=n.pointerSetup(i);return Event.add(i.target,"mousedown",i.onPointerDown),r},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.swipe=n.swipe,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.longpress=function(t){return t.gesture="longpress",n.tap(t)},n.tap=function(t){var r,u,i;return t.delay=t.delay||500,t.timeout=t.timeout||250,t.driftDeviance=t.driftDeviance||10,t.gesture=t.gesture||"tap",t.onPointerDown=function(f){if(n.pointerStart(f,i,t)){if(r=(new Date).getTime(),Event.add(t.doc,"mousemove",t.onPointerMove).listener(f),Event.add(t.doc,"mouseup",t.onPointerUp),t.gesture!=="longpress")return;u=setTimeout(function(){var n,u,r;if(!f.cancelBubble||!(++f.bubble>1)){n=0;for(u in t.tracker){if(r=t.tracker[u],r.end===!0)return;if(t.cancel)return;n++}t.minFingers<=n&&t.maxFingers>=n&&(i.state="start",i.fingers=n,i.x=r.start.x,i.y=r.start.y,t.listener(f,i))}},t.delay)}},t.onPointerMove=function(i){for(var f,e,r=t.bbox,h=i.changedTouches||n.getCoords(i),a=h.length,o=0;o0&&f0&&e1)return;if(t.gesture==="longpress"){i.state==="start"&&(i.state="end",t.listener(f,i));return}if(t.cancel)return;if((new Date).getTime()-r>t.timeout)return;var e=t.gestureFingers;t.minFingers<=e&&t.maxFingers>=e&&(i.state="tap",i.fingers=t.gestureFingers,t.listener(f,i))}},i=n.pointerSetup(t),Event.add(t.target,"mousedown",t.onPointerDown),i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.tap=n.tap,Event.Gesture._gestureHandlers.longpress=n.longpress,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.wheel=function(n){var u,o=n.timeout||150,f=0,t={gesture:"wheel",state:"start",wheelDelta:0,target:n.target,listener:n.listener,preventElasticBounce:function(){var n=this.target,t=n.scrollTop,i=t+n.offsetHeight,r=n.scrollHeight;i===r&&this.wheelDelta<=0?Event.cancel(event):t===0&&this.wheelDelta>=0&&Event.cancel(event);Event.stop(event)},add:function(){n.target[e](r,i,!1)},remove:function(){n.target[s](r,i,!1)}},i=function(i){i=i||window.event;t.state=f++?"change":"start";t.wheelDelta=i.detail?i.detail*-20:i.wheelDelta;n.listener(i,t);clearTimeout(u);u=setTimeout(function(){f=0;t.state="end";t.wheelDelta=0;n.listener(i,t)},o)},e=document.addEventListener?"addEventListener":"attachEvent",s=document.removeEventListener?"removeEventListener":"detachEvent",r=Event.getEventSupport("mousewheel")?"mousewheel":"DOMMouseScroll";return n.target[e](r,i,!1),t},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.wheel=n.wheel,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.orientation=function(n){var t={gesture:"orientationchange",previous:null,current:window.orientation,target:n.target,listener:n.listener,remove:function(){window.removeEventListener("orientationchange",i,!1)}},i=function(i){if(t.previous=t.current,t.current=window.orientation,t.previous!==null&&t.previous!=t.current){n.listener(i,t);return}};return window.DeviceOrientationEvent&&window.addEventListener("orientationchange",i,!1),t},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.orientation=n.orientation,n}(Event.proxy),function(){function n(n,t){this.__eventListeners[n]&&(t?fabric.util.removeFromArray(this.__eventListeners[n],t):this.__eventListeners[n].length=0)}function t(n,t){if(this.__eventListeners||(this.__eventListeners={}),arguments.length===1)for(var i in n)this.on(i,n[i]);else this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t);return this}function i(t,i){if(this.__eventListeners){if(arguments.length===0)this.__eventListeners={};else if(arguments.length===1&&typeof arguments[0]=="object")for(var r in t)n.call(this,r,t[r]);else n.call(this,t,i);return this}}function r(n,t){var i,r,u;if(this.__eventListeners&&(i=this.__eventListeners[n],i)){for(r=0,u=i.length;r-1},complexity:function(){return this.getObjects().reduce(function(n,t){return n+(t.complexity?t.complexity():0)},0)}},function(n){var i=Math.sqrt,r=Math.atan2,t=Math.PI/180;fabric.util={removeFromArray:function(n,t){var i=n.indexOf(t);return i!==-1&&n.splice(i,1),n},getRandomInt:function(n,t){return Math.floor(Math.random()*(t-n+1))+n},degreesToRadians:function(n){return n*t},radiansToDegrees:function(n){return n/t},rotatePoint:function(n,t,i){var r=Math.sin(i),u=Math.cos(i),f,e;return n.subtractEquals(t),f=n.x*u-n.y*r,e=n.x*r+n.y*u,new fabric.Point(f,e).addEquals(t)},toFixed:function(n,t){return parseFloat(Number(n).toFixed(t))},falseFunction:function(){return!1},getKlass:function(n,t){return n=fabric.util.string.camelize(n.charAt(0).toUpperCase()+n.slice(1)),fabric.util.resolveNamespace(t)[n]},resolveNamespace:function(t){var i;if(!t)return fabric;var u=t.split("."),f=u.length,r=n||fabric.window;for(i=0;i1?new fabric.PathGroup(n,t):n[0],typeof i!="undefined"&&r.setSourcePath(i),r},populateWithProperties:function(n,t,i){if(i&&Object.prototype.toString.call(i)==="[object Array]")for(var r=0,u=i.length;rt;)t+=o[y++%v],t>c&&(t=c),n[l?"lineTo":"moveTo"](t,0),l=!l;n.restore()},createCanvasElement:function(n){return n||(n=fabric.document.createElement("canvas")),n.getContext||typeof G_vmlCanvasManager=="undefined"||G_vmlCanvasManager.initElement(n),n},createImage:function(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")},createAccessors:function(n){for(var t=n.prototype,r=t.stateProperties.length;r--;){var i=t.stateProperties[r],u=i.charAt(0).toUpperCase()+i.slice(1),f="set"+u,e="get"+u;t[e]||(t[e]=function(n){return new Function('return this.get("'+n+'")')}(i));t[f]||(t[f]=function(n){return new Function("value",'return this.set("'+n+'", value)')}(i))}},clipContext:function(n,t){t.save();t.beginPath();n.clipTo(t);t.clip()},multiplyTransformMatrices:function(n,t){for(var u,e,f,o=[[n[0],n[2],n[4]],[n[1],n[3],n[5]],[0,0,1]],s=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[],r=0;r<3;r++)for(i[r]=[],u=0;u<3;u++){for(e=0,f=0;f<3;f++)e+=o[r][f]*s[f][u];i[r][u]=e}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]},getFunctionBody:function(n){return(String(n).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},normalizePoints:function(n,t){var i=fabric.util.array.min(n,"x"),u=fabric.util.array.min(n,"y"),r,f;for(i=i<0?i:0,u=i<0?u:0,r=0,f=n.length;r0&&(t>r?t-=r:t=0,i>r?i-=r:i=0),u=!0,f=n.getImageData(t,i,r*2||1,r*2||1),e=3,o=f.data.length;e0&&h===0&&(y-=2*Math.PI),b=Math.ceil(Math.abs(y/(Math.PI*.5+.001))),k=[],p=0;p1&&(h=Math.sqrt(h),t*=h,i*=h);var v=s/t,y=o/t,p=-o/i,w=s/i;return{x0:v*r+y*u,y0:p*r+w*u,x1:v*f+y*e,y1:p*f+w*e,sin_th:o,cos_th:s}}function e(i,u,f,e,o,s,h,c){if(n=r.call(arguments),t[n])return t[n];var a=c*o,v=-h*s,y=h*o,p=c*s,w=.5*(e-f),l=8/3*Math.sin(w*.5)*Math.sin(w*.5)/Math.sin(w),d=i+Math.cos(f)-l*Math.sin(f),g=u+Math.sin(f)+l*Math.cos(f),b=i+Math.cos(e),k=u+Math.sin(e),nt=b+l*Math.sin(e),tt=k-l*Math.cos(e);return t[n]=[a*d+v*g,y*d+p*g,a*nt+v*tt,y*nt+p*tt,a*b+v*k,y*b+p*k],t[n]}var i={},t={},r=Array.prototype.join,n;fabric.util.drawArc=function(n,t,i,r){for(var s,h=r[0],c=r[1],l=r[2],a=r[3],v=r[4],y=r[5],p=r[6],o=u(y,p,h,c,a,v,l,t,i),f=0;f=t})}function u(t,i){return n(t,i,function(n,t){return n>>0,r===0)||(t=0,arguments.length>0&&(t=Number(arguments[1]),t!==t?t=0:t!==0&&t!==Number.POSITIVE_INFINITY&&t!==Number.NEGATIVE_INFINITY&&(t=(t>0||-1)*Math.floor(Math.abs(t)))),t>=r))return-1;for(i=t>=0?t:Math.max(r-Math.abs(t),0);i>>0;i>>0;i>>0;i>>0;i>>0;i>>0,t=0,i;if(arguments.length>1)i=arguments[1];else do{if(t in this){i=this[t++];break}if(++t>=r)throw new TypeError;}while(1);for(;t/g,">")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")});fabric.util.string={camelize:n,capitalize:t,escapeXml:i}}(),function(){var t=Array.prototype.slice,i=Function.prototype.apply,n=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var f=this,e=t.call(arguments,1),u;return u=e.length?function(){return i.call(f,this instanceof n?this:r,e.concat(t.call(arguments)))}:function(){return i.call(f,this instanceof n?this:r,arguments)},n.prototype=this.prototype,u.prototype=new n,u})}(),function(){function t(){}function f(t){var i=this.constructor.superclass.prototype[t];return arguments.length>1?i.apply(this,n.call(arguments,1)):i.call(this)}function e(){function r(){this.initialize.apply(this,arguments)}var e=null,o=n.call(arguments,0),s,h;for(typeof o[0]=="function"&&(e=o.shift()),r.superclass=e,r.subclasses=[],e&&(t.prototype=e.prototype,r.prototype=new t,e.subclasses.push(r)),s=0,h=o.length;s-1?function(n){return function(){var u=this.constructor.superclass,r;return this.constructor.superclass=i,r=t[n].apply(this,arguments),this.constructor.superclass=u,n!=="initialize"?r:void 0}}(u):t[u],r&&(t.toString!==Object.prototype.toString&&(n.prototype.toString=t.toString),t.valueOf!==Object.prototype.valueOf&&(n.prototype.valueOf=t.valueOf))};fabric.util.createClass=e}(),function(){function i(n){for(var i=Array.prototype.slice.call(arguments,1),r,u=i.length,t=0;t-1?n(t,i.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(r in i)r==="opacity"?n(t,i[r]):(f=r==="float"||r==="cssFloat"?typeof u.styleFloat=="undefined"?"cssFloat":"styleFloat":r,u[f]=i[r]);return t}var t=fabric.document.createElement("div"),u=typeof t.style.opacity=="string",f=typeof t.style.filter=="string",i=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(n){return n};u?n=function(n,t){return n.style.opacity=t,n}:f&&(n=function(n,t){var r=n.style;return n.currentStyle&&!n.currentStyle.hasLayout&&(r.zoom=1),i.test(r.filter)?(t=t>=.9999?"":"alpha(opacity="+t*100+")",r.filter=r.filter.replace(i,t)):r.filter+=" alpha(opacity="+t*100+")",n});fabric.util.setStyle=r}(),function(){function f(n){return typeof n=="string"?fabric.document.getElementById(n):n}function i(n,t){var r=fabric.document.createElement(n);for(var i in t)i==="class"?r.className=t[i]:i==="for"?r.htmlFor=t[i]:r.setAttribute(i,t[i]);return r}function e(n,t){(" "+n.className+" ").indexOf(" "+t+" ")===-1&&(n.className+=(n.className?" ":"")+t)}function o(n,t,r){return typeof t=="string"&&(t=i(t,r)),n.parentNode&&n.parentNode.replaceChild(t,n),t.appendChild(n),t}function s(n,t){for(var u,i=0,r=0,e=fabric.document.documentElement,o=fabric.document.body||{scrollLeft:0,scrollTop:0},f=n;n&&n.parentNode&&!u;)n=n.parentNode,n!==fabric.document&&fabric.util.getElementStyle(n,"position")==="fixed"&&(u=n),n!==fabric.document&&f!==t&&fabric.util.getElementStyle(n,"position")==="absolute"?(i=0,r=0):n===fabric.document?(i=o.scrollLeft||e.scrollLeft||0,r=o.scrollTop||e.scrollTop||0):(i+=n.scrollLeft||0,r+=n.scrollTop||0);return{left:i,top:r}}function h(n){var t,i={left:0,top:0},o=n&&n.ownerDocument,u={left:0,top:0},f,s={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"},e;if(!o)return{left:0,top:0};for(e in s)u[s[e]]+=parseInt(r(n,e),10)||0;return t=o.documentElement,typeof n.getBoundingClientRect!="undefined"&&(i=n.getBoundingClientRect()),f=fabric.util.getScrollLeftTop(n,null),{left:i.left+f.left-(t.clientLeft||0)+u.left,top:i.top+f.top-(t.clientTop||0)+u.top}}function r(n,t){if(n.style||(n.style={}),fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle)return fabric.document.defaultView.getComputedStyle(n,null)[t];var i=n.style[t];return!i&&n.currentStyle&&(i=n.currentStyle[t]),i}var u=Array.prototype.slice,n=function(n){return u.call(n,0)},t;try{t=n(fabric.document.childNodes)instanceof Array}catch(c){}t||(n=function(n){for(var i=new Array(n.length),t=n.length;t--;)i[t]=n[t];return i}),function(){function i(n){return typeof n.onselectstart!="undefined"&&(n.onselectstart=fabric.util.falseFunction),t?n.style[t]="none":typeof n.unselectable=="string"&&(n.unselectable="on"),n}function r(n){return typeof n.onselectstart!="undefined"&&(n.onselectstart=null),t?n.style[t]="":typeof n.unselectable=="string"&&(n.unselectable=""),n}var n=fabric.document.documentElement.style,t="userSelect"in n?"userSelect":"MozUserSelect"in n?"MozUserSelect":"WebkitUserSelect"in n?"WebkitUserSelect":"KhtmlUserSelect"in n?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=i;fabric.util.makeElementSelectable=r}(),function(){function n(n,t){var u=fabric.document.getElementsByTagName("head")[0],i=fabric.document.createElement("script"),r=!0;i.onload=i.onreadystatechange=function(n){if(r){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")return;r=!1;t(n||fabric.window.event);i=i.onload=i.onreadystatechange=null}};i.src=n;u.appendChild(i)}fabric.util.getScript=n}();fabric.util.getById=f;fabric.util.toArray=n;fabric.util.makeElement=i;fabric.util.addClass=e;fabric.util.wrapElement=o;fabric.util.getScrollLeftTop=s;fabric.util.getElementOffset=h;fabric.util.getElementStyle=r}(),function(){function n(n,t){return n+(/\?/.test(n)?"&":"?")+t}function i(){}function r(r,u){u||(u={});var e=u.method?u.method.toUpperCase():"GET",s=u.onComplete||function(){},f=t(),o;return f.onreadystatechange=function(){f.readyState===4&&(s(f),f.onreadystatechange=i)},e==="GET"&&(o=null,typeof u.parameters=="string"&&(r=n(r,u.parameters))),f.open(e,r,!0),(e==="POST"||e==="PUT")&&f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(o),f}var t=function(){for(var i,n=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],t=n.length;t--;)try{if(i=n[t](),i)return n[t]}catch(r){}}();fabric.util.request=r}();fabric.log=function(){};fabric.warn=function(){};typeof console!="undefined"&&["log","warn"].forEach(function(n){typeof console[n]!="undefined"&&console[n].apply&&(fabric[n]=function(){return console[n].apply(console,arguments)})}),function(){function n(n,t,i,r){return n','<\/image><\/pattern>')}var t=n.fabric||(n.fabric={}),i=t.util.object.extend,c=t.util.string.capitalize,l=t.util.object.clone,a=t.util.toFixed,v=t.util.multiplyTransformMatrices,o={"fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight",cx:"left",x:"left",r:"radius","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration",cy:"top",y:"top",transform:"transformMatrix"},r={stroke:"strokeOpacity",fill:"fillOpacity"},u;t.parseTransformAttribute=function(){function f(n,t){var i=t[0];n[0]=Math.cos(i);n[1]=Math.sin(i);n[2]=-Math.sin(i);n[3]=Math.cos(i)}function e(n,t){var i=t[0],r=t.length===2?t[1]:t[0];n[0]=i;n[3]=r}function o(n,t){n[2]=t[0]}function s(n,t){n[1]=t[0]}function h(n,t){n[4]=t[0];t.length===2&&(n[5]=t[1])}var u=[1,0,0,1,0,0],n="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",i="(?:\\s+,?\\s*|,\\s*)",c="(?:(skewX)\\s*\\(\\s*("+n+")\\s*\\))",l="(?:(skewY)\\s*\\(\\s*("+n+")\\s*\\))",a="(?:(rotate)\\s*\\(\\s*("+n+")(?:"+i+"("+n+")"+i+"("+n+"))?\\s*\\))",v="(?:(scale)\\s*\\(\\s*("+n+")(?:"+i+"("+n+"))?\\s*\\))",y="(?:(translate)\\s*\\(\\s*("+n+")(?:"+i+"("+n+"))?\\s*\\))",p="(?:(matrix)\\s*\\(\\s*("+n+")"+i+"("+n+")"+i+"("+n+")"+i+"("+n+")"+i+"("+n+")"+i+"("+n+")\\s*\\))",r="(?:"+p+"|"+y+"|"+v+"|"+a+"|"+c+"|"+l+")",w="(?:"+r+"(?:"+i+r+")*)",b="^\\s*(?:"+w+"?)\\s*$",k=new RegExp(b),d=new RegExp(r,"g");return function(n){var i=u.concat(),c=[],l;if(!n||n&&!k.test(n))return i;for(n.replace(d,function(n){var l=new RegExp(r).exec(n).filter(function(n){return n!==""&&n!=null}),a=l[1],t=l.slice(2).map(parseFloat);switch(a){case"translate":h(i,t);break;case"rotate":f(i,t);break;case"scale":e(i,t);break;case"skewX":o(i,t);break;case"skewY":s(i,t);break;case"matrix":i=t}c.push(i.concat());i=u.concat()}),l=c[0];c.length>1;)c.shift(),l=t.util.multiplyTransformMatrices(l,c[0]);return l}}();t.parseSVGDocument=function(){function u(n,t){while(n&&(n=n.parentNode))if(t.test(n.nodeName))return!0;return!1}var i=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/,n="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",r=new RegExp("^\\s*("+n+"+)\\s*,?\\s*("+n+"+)\\s*,?\\s*("+n+"+)\\s*,?\\s*("+n+"+)\\s*$");return function(n,f,e){var w,o,y,h,b,c,p;if(n){if(w=new Date,o=t.util.toArray(n.getElementsByTagName("*")),o.length===0){for(o=n.selectNodes("//*[name(.)!='svg']"),y=[],h=0,b=o.length;h-1,n=n.split(/\s+/),i=[],f)for(t=0,r=n.length;t/i,""))),e.documentElement)&&t.parseSVGDocument(e.documentElement,function(r,f){u.set(n,{objects:t.util.array.invoke(r,"toObject"),options:f});i(r,f)},r)}n=n.replace(/^\n\s*/,"").trim();u.has(n,function(r){r?u.get(n,function(n){var t=k(n);i(t.objects,t.options)}):new t.util.request(n,{method:"get",onComplete:f})})},loadSVGFromString:function(n,i,r){var u,f;n=n.trim();typeof DOMParser!="undefined"?(f=new DOMParser,f&&f.parseFromString&&(u=f.parseFromString(n,"text/xml"))):t.window.ActiveXObject&&(u=new ActiveXObject("Microsoft.XMLDOM"),u.async="false",u.loadXML(n.replace(//i,"")));t.parseSVGDocument(u.documentElement,function(n,t){i(n,t)},r)},createSVGFontFacesMarkup:function(n){for(var i="",t=0,r=n.length;t',"","<\/style>"].join("")),i},createSVGRefElementsMarkup:function(n){var t=[];return h(t,n,"backgroundColor"),h(t,n,"overlayColor"),t.join("")}})}(typeof exports!="undefined"?exports:this);fabric.ElementsParser={parse:function(n,t,i,r){this.elements=n;this.callback=t;this.options=i;this.reviver=r;this.instances=new Array(n.length);this.numElements=n.length;this.createObjects()},createObjects:function(){for(var n=0,t=this.elements.length;nn.x&&this.y>n.y},gte:function(n){return this.x>=n.x&&this.y>=n.y},lerp:function(n,i){return new t(this.x+(n.x-this.x)*i,this.y+(n.y-this.y)*i)},distanceFrom:function(n){var t=this.x-n.x,i=this.y-n.y;return Math.sqrt(t*t+i*i)},midPointFrom:function(n){return new t(this.x+(n.x-this.x)/2,this.y+(n.y-this.y)/2)},min:function(n){return new t(Math.min(this.x,n.x),Math.min(this.y,n.y))},max:function(n){return new t(Math.max(this.x,n.x),Math.max(this.y,n.y))},toString:function(){return this.x+","+this.y},setXY:function(n,t){this.x=n;this.y=t},setFromPoint:function(n){this.x=n.x;this.y=n.y},swap:function(n){var t=this.x,i=this.y;this.x=n.x;this.y=n.y;n.x=t;n.y=i}}}(typeof exports!="undefined"?exports:this),function(n){"use strict";function t(n){this.status=n;this.points=[]}var i=n.fabric||(n.fabric={});if(i.Intersection){i.warn("fabric.Intersection is already defined");return}i.Intersection=t;i.Intersection.prototype={appendPoint:function(n){this.points.push(n)},appendPoints:function(n){this.points=this.points.concat(n)}};i.Intersection.intersectLineLine=function(n,r,u,f){var e,c=(f.x-u.x)*(n.y-u.y)-(f.y-u.y)*(n.x-u.x),l=(r.x-n.x)*(n.y-u.y)-(r.y-n.y)*(n.x-u.x),s=(f.y-u.y)*(r.x-n.x)-(f.x-u.x)*(r.y-n.y),o,h;return s!==0?(o=c/s,h=l/s,0<=o&&o<=1&&0<=h&&h<=1?(e=new t("Intersection"),e.points.push(new i.Point(n.x+o*(r.x-n.x),n.y+o*(r.y-n.y)))):e=new t):e=c===0||l===0?new t("Coincident"):new t("Parallel"),e};i.Intersection.intersectLinePolygon=function(n,i,r){for(var u=new t,e=r.length,f=0;f0&&(u.status="Intersection"),u};i.Intersection.intersectPolygonPolygon=function(n,i){for(var r=new t,f=n.length,u=0;u0&&(r.status="Intersection"),r};i.Intersection.intersectPolygonRectangle=function(n,r,u){var e=r.min(u),o=r.max(u),s=new i.Point(o.x,e.y),h=new i.Point(e.x,o.y),c=t.intersectLinePolygon(e,s,n),l=t.intersectLinePolygon(s,o,n),a=t.intersectLinePolygon(o,h,n),v=t.intersectLinePolygon(h,e,n),f=new t;return f.appendPoints(c.points),f.appendPoints(l.points),f.appendPoints(a.points),f.appendPoints(v.points),f.points.length>0&&(f.status="Intersection"),f}}(typeof exports!="undefined"?exports:this),function(n){"use strict";function t(n){n?this._tryParsingColor(n):this.setSource([0,0,0,1])}function r(n,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?n+(t-n)*6*i:i<1/2?t:i<2/3?n+(t-n)*(2/3-i)*6:n}var i=n.fabric||(n.fabric={});if(i.Color){i.warn("fabric.Color is already defined.");return}i.Color=t;i.Color.prototype={_tryParsingColor:function(n){var i;n in t.colorNameMap&&(n=t.colorNameMap[n]);i=t.sourceFromHex(n);i||(i=t.sourceFromRgb(n));i||(i=t.sourceFromHsl(n));i&&this.setSource(i)},_rgbToHsl:function(n,t,r){var f,s,h,u,e,o;if(n/=255,t/=255,r/=255,u=i.util.array.max([n,t,r]),e=i.util.array.min([n,t,r]),h=(u+e)/2,u===e)f=s=0;else{o=u-e;s=h>.5?o/(2-u-e):o/(u+e);switch(u){case n:f=(t-r)/o+(t']:this.type==="radial"&&(u=["']),r=0;r');return u.push(this.type==="linear"?"<\/linearGradient>":"<\/radialGradient>"),u.join("")},toLive:function(n){var i,t,u;if(this.type){for(this.type==="linear"?i=n.createLinearGradient(this.coords.x1,this.coords.y1,this.coords.x2,this.coords.y2):this.type==="radial"&&(i=n.createRadialGradient(this.coords.x1,this.coords.y1,this.coords.r1,this.coords.x2,this.coords.y2,this.coords.r2)),t=0,u=this.colorStops.length;t<\/image><\/pattern>'},toLive:function(n){var t=typeof this.source=="function"?this.source():this.source;return typeof t.src!="undefined"&&(!t.complete||t.naturalWidth===0||t.naturalHeight===0)?"":n.createPattern(t,this.repeat)}}),function(n){"use strict";var t=n.fabric||(n.fabric={});if(t.Shadow){t.warn("fabric.Shadow is already defined.");return}t.Shadow=t.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,initialize:function(n){typeof n=="string"&&(n=this._parseShadow(n));for(var i in n)this[i]=n[i];this.id=t.Object.__uid++},_parseShadow:function(n){var r=n.trim(),i=t.Shadow.reOffsetsAndBlur.exec(r)||[],u=r.replace(t.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:u.trim(),offsetX:parseInt(i[1],10)||0,offsetY:parseInt(i[2],10)||0,blur:parseInt(i[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(n){var t="SourceAlpha";return n&&(n.fill===this.color||n.stroke===this.color)&&(t="SourceGraphic"),'<\/feGaussianBlur><\/feOffset><\/feMergeNode><\/feMergeNode><\/feMerge><\/filter>'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY};var n={},i=t.Shadow.prototype;return this.color!==i.color&&(n.color=this.color),this.blur!==i.blur&&(n.blur=this.blur),this.offsetX!==i.offsetX&&(n.offsetX=this.offsetX),this.offsetY!==i.offsetY&&(n.offsetY=this.offsetY),n}});t.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/}(typeof exports!="undefined"?exports:this),function(){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var n=fabric.util.object.extend,r=fabric.util.getElementOffset,t=fabric.util.removeFromArray,i=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass({initialize:function(n,t){t||(t={});this._initStatic(n,t);fabric.StaticCanvas.activeInstance=this},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!0,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,onBeforeScaleRotate:function(){},_initStatic:function(n,t){this._objects=[];this._createLowerCanvas(n);this._initOptions(t);t.overlayImage&&this.setOverlayImage(t.overlayImage,this.renderAll.bind(this));t.backgroundImage&&this.setBackgroundImage(t.backgroundImage,this.renderAll.bind(this));t.backgroundColor&&this.setBackgroundColor(t.backgroundColor,this.renderAll.bind(this));t.overlayColor&&this.setOverlayColor(t.overlayColor,this.renderAll.bind(this));this.calcOffset()},calcOffset:function(){return this._offset=r(this.lowerCanvasEl),this},setOverlayImage:function(n,t,i){return this.__setBgOverlayImage("overlayImage",n,t,i)},setBackgroundImage:function(n,t,i){return this.__setBgOverlayImage("backgroundImage",n,t,i)},setOverlayColor:function(n,t){return this.__setBgOverlayColor("overlayColor",n,t)},setBackgroundColor:function(n,t){return this.__setBgOverlayColor("backgroundColor",n,t)},__setBgOverlayImage:function(n,t,i,r){return typeof t=="string"?fabric.util.loadImage(t,function(t){this[n]=new fabric.Image(t,r);i&&i()},this):(this[n]=t,i&&i()),this},__setBgOverlayColor:function(n,t,i){if(t.source){var r=this;fabric.util.loadImage(t.source,function(u){r[n]=new fabric.Pattern({source:u,repeat:t.repeat,offsetX:t.offsetX,offsetY:t.offsetY});i&&i()})}else this[n]=t,i&&i();return this},_createCanvasElement:function(){var n=fabric.document.createElement("canvas");if(n.style||(n.style={}),!n)throw i;return this._initCanvasElement(n),n},_initCanvasElement:function(n){if(fabric.util.createCanvasElement(n),typeof n.getContext=="undefined")throw i;},_initOptions:function(n){for(var t in n)this[t]=n[t];(this.width=parseInt(this.lowerCanvasEl.width,10)||0,this.height=parseInt(this.lowerCanvasEl.height,10)||0,this.lowerCanvasEl.style)&&(this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px")},_createLowerCanvas:function(n){this.lowerCanvasEl=fabric.util.getById(n)||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(n){return this._setDimension("width",n)},setHeight:function(n){return this._setDimension("height",n)},setDimensions:function(n){for(var t in n)this._setDimension(t,n[t]);return this},_setDimension:function(n,t){return this.lowerCanvasEl[n]=t,this.lowerCanvasEl.style[n]=t+"px",this.upperCanvasEl&&(this.upperCanvasEl[n]=t,this.upperCanvasEl.style[n]=t+"px"),this.cacheCanvasEl&&(this.cacheCanvasEl[n]=t),this.wrapperEl&&(this.wrapperEl.style[n]=t+"px"),this[n]=t,this.calcOffset(),this.renderAll(),this},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_draw:function(n,t){if(t)if(this.controlsAboveOverlay){var i=t.hasBorders,r=t.hasControls;t.hasBorders=t.hasControls=!1;t.render(n);t.hasBorders=i;t.hasControls=r}else t.render(n)},_onObjectAdded:function(n){this.stateful&&n.setupState();n.setCoords();n.canvas=this;this.fire("object:added",{target:n});n.fire("added")},_onObjectRemoved:function(n){this.getActiveObject()===n&&(this.fire("before:selection:cleared",{target:n}),this._discardActiveObject(),this.fire("selection:cleared"));this.fire("object:removed",{target:n});n.fire("removed")},clearContext:function(n){return n.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.discardActiveGroup&&this.discardActiveGroup(),this.discardActiveObject&&this.discardActiveObject(),this.clearContext(this.contextContainer),this.contextTop&&this.clearContext(this.contextTop),this.fire("canvas:cleared"),this.renderAll(),this},renderAll:function(n){var t=this[n===!0&&this.interactive?"contextTop":"contextContainer"],i=this.getActiveGroup();return this.contextTop&&this.selection&&!this._groupSelector&&this.clearContext(this.contextTop),n||this.clearContext(t),this.fire("before:render"),this.clipTo&&fabric.util.clipContext(this,t),this._renderBackground(t),this._renderObjects(t,i),this._renderActiveGroup(t,i),this.clipTo&&t.restore(),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render"),this},_renderObjects:function(n,t){for(var i=0,r=this._objects.length;i"),i.join("")},_setSVGPreamble:function(n,t){t.suppressPreamble||n.push('','\n')},_setSVGHeader:function(n,t){n.push("',"Created with Fabric.js ",fabric.version,"<\/desc>","",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),"<\/defs>")},_setSVGObjects:function(n,t){var i=this.getActiveGroup();i&&this.discardActiveGroup();for(var r=0,u=this.getObjects(),f=u.length;r<\/rect>"):this[t]&&t==="overlayColor"&&n.push('<\/rect>")},sendToBack:function(n){return t(this._objects,n),this._objects.unshift(n),this.renderAll&&this.renderAll()},bringToFront:function(n){return t(this._objects,n),this._objects.push(n),this.renderAll&&this.renderAll()},sendBackwards:function(n,i){var r=this._objects.indexOf(n),u;return r!==0&&(u=this._findNewLowerIndex(n,r,i),t(this._objects,n),this._objects.splice(u,0,n),this.renderAll&&this.renderAll()),this},_findNewLowerIndex:function(n,t,i){var u,r,f;if(i){for(u=t,r=t-1;r>=0;--r)if(f=n.intersectsWithObject(this._objects[r])||n.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(n),f){u=r;break}}else u=t-1;return u},bringForward:function(n,i){var r=this._objects.indexOf(n),u;return r!==this._objects.length-1&&(u=this._findNewUpperIndex(n,r,i),t(this._objects,n),this._objects.splice(u,0,n),this.renderAll&&this.renderAll()),this},_findNewUpperIndex:function(n,t,i){var u,r,f;if(i){for(u=t,r=t+1;r"}});n(fabric.StaticCanvas.prototype,fabric.Observable);n(fabric.StaticCanvas.prototype,fabric.Collection);n(fabric.StaticCanvas.prototype,fabric.DataURLExporter);n(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(n){var t=fabric.util.createCanvasElement(),i;if(!t||!t.getContext||(i=t.getContext("2d"),!i))return null;switch(n){case"getImageData":return typeof i.getImageData!="undefined";case"setLineDash":return typeof i.setLineDash!="undefined";case"toDataURL":return typeof t.toDataURL!="undefined";case"toDataURLWithQuality":try{return t.toDataURL("image/jpeg",0),!0}catch(r){}return!1;default:return null}}});fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject}();fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",setShadow:function(n){return this.shadow=new fabric.Shadow(n),this},_setBrushStyles:function(){var n=this.canvas.contextTop;n.strokeStyle=this.color;n.lineWidth=this.width;n.lineCap=this.strokeLineCap;n.lineJoin=this.strokeLineJoin},_setShadow:function(){if(this.shadow){var n=this.canvas.contextTop;n.shadowColor=this.shadow.color;n.shadowBlur=this.shadow.blur;n.shadowOffsetX=this.shadow.offsetX;n.shadowOffsetY=this.shadow.offsetY}},_resetShadow:function(){var n=this.canvas.contextTop;n.shadowColor="";n.shadowBlur=n.shadowOffsetX=n.shadowOffsetY=0}}),function(){var n=fabric.util.array.min,t=fabric.util.array.max;fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{initialize:function(n){this.canvas=n;this._points=[]},onMouseDown:function(n){this._prepareForDrawing(n);this._captureDrawingPath(n);this._render()},onMouseMove:function(n){this._captureDrawingPath(n);this.canvas.clearContext(this.canvas.contextTop);this._render()},onMouseUp:function(){this._finalizeAndAddPath()},_prepareForDrawing:function(n){var t=new fabric.Point(n.x,n.y);this._reset();this._addPoint(t);this.canvas.contextTop.moveTo(t.x,t.y)},_addPoint:function(n){this._points.push(n)},_reset:function(){this._points.length=0;this._setBrushStyles();this._setShadow()},_captureDrawingPath:function(n){var t=new fabric.Point(n.x,n.y);this._addPoint(t)},_render:function(){var i=this.canvas.contextTop,n,t,r,f,u;for(i.beginPath(),n=this._points[0],t=this._points[1],this._points.length===2&&n.x===t.x&&n.y===t.y&&(n.x-=.5,t.x+=.5),i.moveTo(n.x,n.y),r=1,f=this._points.length;rr.padding?t.x<0?t.x+=r.padding:t.x-=r.padding:t.x=0;n(t.y)>r.padding?t.y<0?t.y+=r.padding:t.y-=r.padding:t.y=0},_rotateObject:function(n,t){var i=this._currentTransform,r=this._offset;if(!i.target.get("lockRotation")){var o=u(i.ey-i.top-r.top,i.ex-i.left-r.left),s=u(t-i.top-r.top,n-i.left-r.left),f=e(s-o+i.theta);f<0&&(f=360+f);i.target.angle=f}},_setCursor:function(n){this.upperCanvasEl.style.cursor=n},_resetObjectTransform:function(n){n.scaleX=1;n.scaleY=1;n.setAngle(0)},_drawSelection:function(){var i=this.contextTop,f=this._groupSelector,s=f.left,h=f.top,e=n(s),o=n(h),r,u;i.fillStyle=this.selectionColor;i.fillRect(f.ex-(s>0?0:-s),f.ey-(h>0?0:-h),e,o);i.lineWidth=this.selectionLineWidth;i.strokeStyle=this.selectionBorderColor;this.selectionDashArray.length>1?(r=f.ex+t-(s>0?0:e),u=f.ey+t-(h>0?0:o),i.beginPath(),fabric.util.drawDashedLine(i,r,u,r+e,u,this.selectionDashArray),fabric.util.drawDashedLine(i,r,u+o-1,r+e,u+o-1,this.selectionDashArray),fabric.util.drawDashedLine(i,r,u,r,u+o,this.selectionDashArray),fabric.util.drawDashedLine(i,r+e-1,u,r+e-1,u+o,this.selectionDashArray),i.closePath(),i.stroke()):i.strokeRect(f.ex+t-(s>0?0:e),f.ey+t-(h>0?0:o),e,o)},_isLastRenderedObject:function(n){return this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(n,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(n,this._offset)},findTarget:function(n,t){if(!this.skipTargetFind){if(this._isLastRenderedObject(n))return this.lastRenderedObjectWithControlsAboveOverlay;var i=this.getActiveGroup();return i&&!t&&this.containsPoint(n,i)?i:this._searchPossibleTargets(n)}},_searchPossibleTargets:function(n){for(var u,e,o,i=[],r,f=this.getPointer(n),t=this._objects.length;t--;)if(this._objects[t]&&this._objects[t].visible&&this._objects[t].evented&&this.containsPoint(n,this._objects[t]))if(this.perPixelTargetFind||this._objects[t].perPixelTargetFind)i[i.length]=this._objects[t];else{r=this._objects[t];this.relatedTarget=r;break}for(u=0,e=i.length;u1&&(t=new fabric.Group(t.reverse(),{originX:"center",originY:"center"}),this.setActiveGroup(t,n),t.saveCoords(),this.fire("selection:created",{target:t}),this.renderAll())},_collectObjects:function(){for(var h=[],i,r=this._groupSelector.ex,u=this._groupSelector.ey,f=r+this._groupSelector.left,e=u+this._groupSelector.top,o=new fabric.Point(n(r,f),n(u,e)),s=new fabric.Point(t(r,f),t(u,e)),l=r===f&&u===e,c=this._objects.length;c--;)if((i=this._objects[c],i&&i.selectable&&i.visible)&&(i.intersectsWithRect(o,s)||i.isContainedWithinRect(o,s)||i.containsPoint(o)||i.containsPoint(s))&&(i.set("active",!0),h.push(i),l))break;return h},_maybeGroupObjects:function(n){this.selection&&this._groupSelector&&this._groupSelectedObjects(n);var t=this.getActiveGroup();t&&(t.setObjectsCoords().setCoords(),t.isMoving=!1,this._setCursor(this.defaultCursor));this._groupSelector=null;this._currentTransform=null}})}();fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(n){n||(n={});var t=n.format||"png",i=n.quality||1,r=n.multiplier||1,u={left:n.left,top:n.top,width:n.width,height:n.height};return r!==1?this.__toDataURLWithMultiplier(t,i,u,r):this.__toDataURL(t,i,u)},__toDataURL:function(n,t,i){var u,r,f;return this.renderAll(!0),u=this.upperCanvasEl||this.lowerCanvasEl,r=this.__getCroppedCanvas(u,i),n==="jpg"&&(n="jpeg"),f=fabric.StaticCanvas.supports("toDataURLWithQuality")?(r||u).toDataURL("image/"+n,t):(r||u).toDataURL("image/"+n),this.contextTop&&this.clearContext(this.contextTop),this.renderAll(),r&&(r=null),f},__getCroppedCanvas:function(n,t){var i,r,u="left"in t||"top"in t||"width"in t||"height"in t;return u&&(i=fabric.util.createCanvasElement(),r=i.getContext("2d"),i.width=t.width||this.width,i.height=t.height||this.height,r.drawImage(n,-t.left||0,-t.top||0)),i},__toDataURLWithMultiplier:function(n,t,i,r){var f=this.getWidth(),e=this.getHeight(),c=f*r,l=e*r,o=this.getActiveObject(),u=this.getActiveGroup(),s=this.contextTop||this.contextContainer,h;return this.setWidth(c).setHeight(l),s.scale(r,r),i.left&&(i.left*=r),i.top&&(i.top*=r),i.width&&(i.width*=r),i.height&&(i.height*=r),u?this._tempRemoveBordersControlsFromGroup(u):o&&this.deactivateAll&&this.deactivateAll(),this.renderAll(!0),h=this.__toDataURL(n,t,i),this.width=f,this.height=e,s.scale(1/r,1/r),this.setWidth(f).setHeight(e),u?this._restoreBordersControlsOnGroup(u):o&&this.setActiveObject&&this.setActiveObject(o),this.contextTop&&this.clearContext(this.contextTop),this.renderAll(),h},toDataURLWithMultiplier:function(n,t,i){return this.toDataURL({format:n,multiplier:t,quality:i})},_tempRemoveBordersControlsFromGroup:function(n){n.origHasControls=n.hasControls;n.origBorderColor=n.borderColor;n.hasControls=!0;n.borderColor="rgba(0,0,0,0)";n.forEachObject(function(n){n.origBorderColor=n.borderColor;n.borderColor="rgba(0,0,0,0)"})},_restoreBordersControlsOnGroup:function(n){n.hideControls=n.origHideControls;n.borderColor=n.origBorderColor;n.forEachObject(function(n){n.borderColor=n.origBorderColor;delete n.origBorderColor})}});fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(n,t,i){return this.loadFromJSON(n,t,i)},loadFromJSON:function(n,t,i){var r,u;if(n)return r=typeof n=="string"?JSON.parse(n):n,this.clear(),u=this,this._enlivenObjects(r.objects,function(){u._setBgOverlay(r,t)},i),this},_setBgOverlay:function(n,t){var u=this,i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1},r;if(!n.backgroundImage&&!n.overlayImage&&!n.background&&!n.overlay){t&&t();return}r=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&(u.renderAll(),t&&t())};this.__setBgOverlay("backgroundImage",n.backgroundImage,i,r);this.__setBgOverlay("overlayImage",n.overlayImage,i,r);this.__setBgOverlay("backgroundColor",n.background,i,r);this.__setBgOverlay("overlayColor",n.overlay,i,r);r()},__setBgOverlay:function(n,t,i,r){var u=this;if(!t){i[n]=!0;return}n==="backgroundImage"||n==="overlayImage"?fabric.Image.fromObject(t,function(t){u[n]=t;i[n]=!0;r&&r()}):this["set"+fabric.util.string.capitalize(n,!0)](t,function(){i[n]=!0;r&&r()})},_enlivenObjects:function(n,t,i){var r=this,u;n.length===0&&t&&t();u=this.renderOnAddRemove;this.renderOnAddRemove=!1;fabric.util.enlivenObjects(n,function(n){n.forEach(function(n,t){r.insertAt(n,t,!0)});r.renderOnAddRemove=u;t&&t()},null,i)},_toDataURL:function(n,t){this.clone(function(i){t(i.toDataURL(n))})},_toDataURLWithMultiplier:function(n,t,i){this.clone(function(r){i(r.toDataURLWithMultiplier(n,t))})},clone:function(n,t){var i=JSON.stringify(this.toJSON(t));this.cloneWithoutData(function(t){t.loadFromJSON(i,function(){n&&n(t)})})},cloneWithoutData:function(n){var i=fabric.document.createElement("canvas"),t;i.width=this.getWidth();i.height=this.getHeight();t=new fabric.Canvas(i);t.clipTo=this.clipTo;this.backgroundImage?(t.setBackgroundImage(this.backgroundImage.src,function(){t.renderAll();n&&n(t)}),t.backgroundImageOpacity=this.backgroundImageOpacity,t.backgroundImageStretch=this.backgroundImageStretch):n&&n(t)}}),function(){var n=fabric.util.degreesToRadians,t=fabric.util.radiansToDegrees;fabric.util.object.extend(fabric.Canvas.prototype,{__onTransformGesture:function(n,t){if(!this.isDrawingMode&&n.touches.length===2&&"gesture"===t.gesture){var i=this.findTarget(n);if("undefined"!=typeof i){this.onBeforeScaleRotate(i);this._rotateObjectByAngle(t.rotation);this._scaleObjectBy(t.scale)}this.fire("touch:gesture",{target:i,e:n,self:t})}},__onDrag:function(n,t){this.fire("touch:drag",{e:n,self:t})},__onOrientationChange:function(n,t){this.fire("touch:orientation",{e:n,self:t})},__onShake:function(n,t){this.fire("touch:shake",{e:n,self:t})},_scaleObjectBy:function(n,t){var r=this._currentTransform,i=r.target,u=i.get("lockScalingX"),f=i.get("lockScalingY");u&&f||(i._scaling=!0,t?t!=="x"||i.get("lockUniScaling")?t!=="y"||i.get("lockUniScaling")||f||i.set("scaleY",r.scaleY*n):u||i.set("scaleX",r.scaleX*n):(u||i.set("scaleX",r.scaleX*n),f||i.set("scaleY",r.scaleY*n)))},_rotateObjectByAngle:function(i){var r=this._currentTransform;r.target.get("lockRotation")||(r.target.angle=t(n(i)+r.theta))}})}(),function(n){"use strict";var t=n.fabric||(n.fabric={}),r=t.util.object.extend,i=t.util.toFixed,u=t.util.string.capitalize,f=t.util.degreesToRadians,e=t.StaticCanvas.supports("setLineDash");t.Object||(t.Object=t.util.createClass({type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,cornerSize:12,transparentCorners:!0,hoverCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"source-over",backgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:10,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:.01,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,mtImage:null,mbImage:null,mlImage:null,mrImage:null,brImage:null,DeleteImage:null,InfoImage:null,mtImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/uparrow.png",mbImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/downarrow.png",mlImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/leftarrow.png",mrImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/rightarrow.png",brImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/rotate.png",DeleteImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/close.png",InfoImageSrc:"http://helpfurniture.com/delaware/roomplanner/images/info.png",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeLineJoin strokeMiterLimit angle opacity fill fillRule shadow clipTo visible backgroundColor".split(" "),initialize:function(n){n&&this.setOptions(n);this.mtImage=new Image;this.mtImage.src=this.mtImageSrc;this.mbImage=new Image;this.mbImage.src=this.mbImageSrc;this.mlImage=new Image;this.mlImage.src=this.mlImageSrc;this.mrImage=new Image;this.mrImage.src=this.mrImageSrc;this.brImage=new Image;this.brImage.src=this.brImageSrc;this.DeleteImage=new Image;this.DeleteImage.src=this.DeleteImageSrc;this.InfoImage=new Image;this.InfoImage.src=this.InfoImageSrc},_initGradient:function(n){!n.fill||!n.fill.colorStops||n.fill instanceof t.Gradient||this.set("fill",new t.Gradient(n.fill))},_initPattern:function(n){!n.fill||!n.fill.source||n.fill instanceof t.Pattern||this.set("fill",new t.Pattern(n.fill));!n.stroke||!n.stroke.source||n.stroke instanceof t.Pattern||this.set("stroke",new t.Pattern(n.stroke))},_initClipping:function(n){if(n.clipTo&&typeof n.clipTo=="string"){var i=t.util.getFunctionBody(n.clipTo);typeof i!="undefined"&&(this.clipTo=new Function("ctx",i))}},setOptions:function(n){for(var t in n)this.set(t,n[t]);this._initGradient(n);this._initPattern(n);this._initClipping(n)},transform:function(n,t){n.globalAlpha=this.opacity;var i=t?this._getLeftTopCoords():this.getCenterPoint();n.translate(i.x,i.y);n.rotate(f(this.angle));n.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(n){var r=t.Object.NUM_FRACTION_DIGITS,u={type:this.type,originX:this.originX,originY:this.originY,left:i(this.left,r),top:i(this.top,r),width:i(this.width,r),height:i(this.height,r),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:i(this.strokeWidth,r),strokeDashArray:this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:i(this.strokeMiterLimit,r),scaleX:i(this.scaleX,r),scaleY:i(this.scaleY,r),angle:i(this.getAngle(),r),flipX:this.flipX,flipY:this.flipY,opacity:i(this.opacity,r),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor};return this.includeDefaultValues||(u=this._removeDefaultValues(u)),t.util.populateWithProperties(this,u,n),u},toDatalessObject:function(n){return this.toObject(n)},_removeDefaultValues:function(n){var i=t.util.getKlass(n.type).prototype,r=i.stateProperties;return r.forEach(function(t){n[t]===i[t]&&delete n[t]}),n},toString:function(){return"#"},get:function(n){return this[n]},set:function(n,t){if(typeof n=="object")for(var i in n)this._set(i,n[i]);else typeof t=="function"&&n!=="clipTo"?this._set(n,t(this.get(n))):this._set(n,t);return this},_set:function(n,r){var u=n==="scaleX"||n==="scaleY";return u&&(r=this._constrainScale(r)),n==="scaleX"&&r<0?(this.flipX=!this.flipX,r*=-1):n==="scaleY"&&r<0?(this.flipY=!this.flipY,r*=-1):n==="width"||n==="height"?this.minScaleLimit=i(Math.min(.1,1/Math.max(this.width,this.height)),2):n!=="shadow"||!r||r instanceof t.Shadow||(r=new t.Shadow(r)),this[n]=r,this},toggle:function(n){var t=this.get(n);return typeof t=="boolean"&&this.set(n,!t),this},setSourcePath:function(n){return this.sourcePath=n,this},render:function(n,i){if(this.width!==0&&this.height!==0&&this.visible){n.save();this._transform(n,i);this._setStrokeStyles(n);this._setFillStyles(n);var r=this.transformMatrix;r&&this.group&&(n.translate(-this.group.width/2,-this.group.height/2),n.transform(r[0],r[1],r[2],r[3],r[4],r[5]));this._setShadow(n);this.clipTo&&t.util.clipContext(this,n);this._render(n,i);this.clipTo&&n.restore();this._removeShadow(n);this.active&&!i&&(this.drawBorders(n),this.drawControls(n));n.restore()}},_transform:function(n,t){var i=this.transformMatrix;i&&!this.group&&n.setTransform(i[0],i[1],i[2],i[3],i[4],i[5]);t||this.transform(n)},_setStrokeStyles:function(n){this.stroke&&(n.lineWidth=this.strokeWidth,n.lineCap=this.strokeLineCap,n.lineJoin=this.strokeLineJoin,n.miterLimit=this.strokeMiterLimit,n.strokeStyle=this.stroke.toLive?this.stroke.toLive(n):this.stroke)},_setFillStyles:function(n){this.fill&&(n.fillStyle=this.fill.toLive?this.fill.toLive(n):this.fill)},_setShadow:function(n){this.shadow&&(n.shadowColor=this.shadow.color,n.shadowBlur=this.shadow.blur,n.shadowOffsetX=this.shadow.offsetX,n.shadowOffsetY=this.shadow.offsetY)},_removeShadow:function(n){n.shadowColor="";n.shadowBlur=n.shadowOffsetX=n.shadowOffsetY=0},_renderFill:function(n){this.fill&&(this.fill.toLive&&(n.save(),n.translate(-this.width/2+this.fill.offsetX||0,-this.height/2+this.fill.offsetY||0)),n.fill(),this.fill.toLive&&n.restore(),this.shadow&&!this.shadow.affectStroke&&this._removeShadow(n))},_renderStroke:function(n){this.stroke&&(n.save(),this.strokeDashArray?(1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray),e?(n.setLineDash(this.strokeDashArray),this._stroke&&this._stroke(n)):this._renderDashedStroke&&this._renderDashedStroke(n),n.stroke()):this._stroke?this._stroke(n):n.stroke(),this._removeShadow(n),n.restore())},clone:function(n,i){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(i),n):new t.Object(this.toObject(i))},cloneAsImage:function(n){var i=this.toDataURL();return t.util.loadImage(i,function(i){n&&n(new t.Image(i))}),this},toDataURL:function(n){var i,u,r,f,e,o;return n||(n={}),i=t.util.createCanvasElement(),u=this.getBoundingRect(),i.width=u.width,i.height=u.height,t.util.wrapElement(i,"div"),r=new t.Canvas(i),n.format==="jpg"&&(n.format="jpeg"),n.format==="jpeg"&&(r.backgroundColor="#fff"),f={active:this.get("active"),left:this.getLeft(),top:this.getTop()},this.set("active",!1),this.setPositionByOrigin(new t.Point(i.width/2,i.height/2),"center","center"),e=this.canvas,r.add(this),o=r.toDataURL(n),this.set(f).setCoords(),this.canvas=e,r.dispose(),r=null,o},isType:function(n){return this.type===n},complexity:function(){return 0},toJSON:function(n){return this.toObject(n)},setGradient:function(n,i){var r,u,f;i||(i={});r={colorStops:[]};r.type=i.type||(i.r1||i.r2?"radial":"linear");r.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2};(i.r1||i.r2)&&(r.coords.r1=i.r1,r.coords.r2=i.r2);for(u in i.colorStops)f=new t.Color(i.colorStops[u]),r.colorStops.push({offset:u,color:f.toRgb(),opacity:f.getAlpha()});return this.set(n,t.Gradient.forObject(this,r))},setPatternFill:function(n){return this.set("fill",new t.Pattern(n))},setShadow:function(n){return this.set("shadow",new t.Shadow(n))},setColor:function(n){return this.set("fill",n),this},centerH:function(){return this.canvas.centerObjectH(this),this},centerV:function(){return this.canvas.centerObjectV(this),this},center:function(){return this.canvas.centerObject(this),this},remove:function(){return this.canvas.remove(this)},getLocalPointer:function(n,t){t=t||this.canvas.getPointer(n);var i=this.translateToOriginPoint(this.getCenterPoint(),"left","top");return{x:t.x-i.x,y:t.y-i.y}}}),t.util.createAccessors(t.Object),t.Object.prototype.rotate=t.Object.prototype.setAngle,r(t.Object.prototype,t.Observable),t.Object.NUM_FRACTION_DIGITS=2,t.Object.__uid=0)}(typeof exports!="undefined"?exports:this),function(){var n=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{translateToCenterPoint:function(t,i,r){var f=t.x,e=t.y,u=this.stroke?this.strokeWidth:0;return i==="left"?f=t.x+(this.getWidth()+u*this.scaleX)/2:i==="right"&&(f=t.x-(this.getWidth()+u*this.scaleX)/2),r==="top"?e=t.y+(this.getHeight()+u*this.scaleY)/2:r==="bottom"&&(e=t.y-(this.getHeight()+u*this.scaleY)/2),fabric.util.rotatePoint(new fabric.Point(f,e),t,n(this.angle))},translateToOriginPoint:function(t,i,r){var f=t.x,e=t.y,u=this.stroke?this.strokeWidth:0;return i==="left"?f=t.x-(this.getWidth()+u*this.scaleX)/2:i==="right"&&(f=t.x+(this.getWidth()+u*this.scaleX)/2),r==="top"?e=t.y-(this.getHeight()+u*this.scaleY)/2:r==="bottom"&&(e=t.y+(this.getHeight()+u*this.scaleY)/2),fabric.util.rotatePoint(new fabric.Point(f,e),t,n(this.angle))},getCenterPoint:function(){var n=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(n,this.originX,this.originY)},getPointByOrigin:function(n,t){var i=this.getCenterPoint();return this.translateToOriginPoint(i,n,t)},toLocalPoint:function(t,i,r){var u=this.getCenterPoint(),f=this.stroke?this.strokeWidth:0,e,o;return i&&r?(e=i==="left"?u.x-(this.getWidth()+f*this.scaleX)/2:i==="right"?u.x+(this.getWidth()+f*this.scaleX)/2:u.x,o=r==="top"?u.y-(this.getHeight()+f*this.scaleY)/2:r==="bottom"?u.y+(this.getHeight()+f*this.scaleY)/2:u.y):(e=this.left,o=this.top),fabric.util.rotatePoint(new fabric.Point(t.x,t.y),u,-n(this.angle)).subtractEquals(new fabric.Point(e,o))},setPositionByOrigin:function(n,t,i){var u=this.translateToCenterPoint(n,t,i),r=this.translateToOriginPoint(u,this.originX,this.originY);this.set("left",r.x);this.set("top",r.y)},adjustPosition:function(t){var i=n(this.angle),r=this.getWidth()/2,u=Math.cos(i)*r,f=Math.sin(i)*r,e=this.getWidth(),o=Math.cos(i)*e,s=Math.sin(i)*e;this.originX==="center"&&t==="left"||this.originX==="right"&&t==="center"?(this.left-=u,this.top-=f):this.originX==="left"&&t==="center"||this.originX==="center"&&t==="right"?(this.left+=u,this.top+=f):this.originX==="left"&&t==="right"?(this.left+=o,this.top+=s):this.originX==="right"&&t==="left"&&(this.left-=o,this.top-=s);this.setCoords();this.originX=t},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","center")}})}(),function(){var n=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{oCoords:null,intersectsWithRect:function(n,t){var i=this.oCoords,r=new fabric.Point(i.tl.x,i.tl.y),u=new fabric.Point(i.tr.x,i.tr.y),f=new fabric.Point(i.bl.x,i.bl.y),e=new fabric.Point(i.br.x,i.br.y),o=fabric.Intersection.intersectPolygonRectangle([r,u,e,f],n,t);return o.status==="Intersection"},intersectsWithObject:function(n){function r(n){return{tl:new fabric.Point(n.tl.x,n.tl.y),tr:new fabric.Point(n.tr.x,n.tr.y),bl:new fabric.Point(n.bl.x,n.bl.y),br:new fabric.Point(n.br.x,n.br.y)}}var t=r(this.oCoords),i=r(n.oCoords),u=fabric.Intersection.intersectPolygonPolygon([t.tl,t.tr,t.br,t.bl],[i.tl,i.tr,i.br,i.bl]);return u.status==="Intersection"},isContainedWithinObject:function(n){var t=n.getBoundingRect(),i=new fabric.Point(t.left,t.top),r=new fabric.Point(t.left+t.width,t.top+t.height);return this.isContainedWithinRect(i,r)},isContainedWithinRect:function(n,t){var i=this.getBoundingRect();return i.left>n.x&&i.left+i.widthn.y&&i.top+i.height=n.y)||!(i.d.y>=n.y))&&(i.o.x===i.d.x&&i.o.x>=n.x?(u=i.o.x,h=n.y):(r=0,f=(i.d.y-i.o.y)/(i.d.x-i.o.x),e=n.y-r*n.x,s=i.o.y-f*i.o.x,u=-(e-s)/(r-f),h=e+r*u),u>=n.x&&(o+=1),o===2))break;return o},getBoundingRectWidth:function(){return this.getBoundingRect().width},getBoundingRectHeight:function(){return this.getBoundingRect().height},getBoundingRect:function(){this.oCoords||this.setCoords();var n=[this.oCoords.tl.x,this.oCoords.tr.x,this.oCoords.br.x,this.oCoords.bl.x],t=fabric.util.array.min(n),u=fabric.util.array.max(n),f=Math.abs(t-u),i=[this.oCoords.tl.y,this.oCoords.tr.y,this.oCoords.br.y,this.oCoords.bl.y],r=fabric.util.array.min(i),e=fabric.util.array.max(i),o=Math.abs(r-e);return{left:t,top:r,width:f,height:o}},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*this.scaleY},_constrainScale:function(n){return Math.abs(n)1?this.strokeWidth:0,h=this.padding,f=n(this.angle);this.currentWidth=(this.width+s)*this.scaleX+h*2;this.currentHeight=(this.height+s)*this.scaleY+h*2;this.currentWidth<0&&(this.currentWidth=Math.abs(this.currentWidth));var c=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2)),l=Math.atan(isFinite(this.currentHeight/this.currentWidth)?this.currentHeight/this.currentWidth:0),v=Math.cos(l+f)*c,y=Math.sin(l+f)*c,i=Math.sin(f),r=Math.cos(f),a=this.getCenterPoint(),t={x:a.x-v,y:a.y-y},u={x:t.x+this.currentWidth*r,y:t.y+this.currentWidth*i},p={x:u.x-this.currentHeight*i,y:u.y+this.currentHeight*r},e={x:t.x-this.currentHeight*i,y:t.y+this.currentHeight*r},w={x:t.x-this.currentHeight/2*i,y:t.y+this.currentHeight/2*r},o={x:t.x+this.currentWidth/2*r,y:t.y+this.currentWidth/2*i},b={x:u.x-this.currentHeight/2*i,y:u.y+this.currentHeight/2*r},k={x:e.x+this.currentWidth/2*r,y:e.y+this.currentWidth/2*i},d={x:o.x,y:o.y},g={x:t.x+(this.currentWidth-0)*r,y:t.y+(this.currentWidth-0)*i},nt={x:t.x+(this.currentWidth-30)*r,y:t.y+(this.currentWidth-30)*i};return this.oCoords={tl:t,tr:u,br:p,bl:e,ml:w,mt:o,mr:b,mb:k,mtr:d,DeleteControl:g,InfoControl:nt},this._setCornerCoords&&this._setCornerCoords(),this}})}();fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){return this.group?fabric.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?fabric.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas.bringToFront(this),this},sendBackwards:function(n){return this.group?fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,n):this.canvas.sendBackwards(this,n),this},bringForward:function(n){return this.group?fabric.StaticCanvas.prototype.bringForward.call(this.group,this,n):this.canvas.bringForward(this,n),this},moveTo:function(n){return this.group?fabric.StaticCanvas.prototype.moveTo.call(this.group,this,n):this.canvas.moveTo(this,n),this}});fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(){var n=this.fill?this.fill.toLive?"url(#SVGID_"+this.fill.id+")":this.fill:"none",t=this.stroke?this.stroke.toLive?"url(#SVGID_"+this.stroke.id+")":this.stroke:"none",i=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):"",u=this.strokeLineCap?this.strokeLineCap:"butt",f=this.strokeLineJoin?this.strokeLineJoin:"miter",e=this.strokeMiterLimit?this.strokeMiterLimit:"4",o=typeof this.opacity!="undefined"?this.opacity:"1",s=this.visible?"":" visibility: hidden;",h=this.shadow&&this.type!=="text"?"filter: url(#SVGID_"+this.shadow.id+");":"";return["stroke: ",t,"; ","stroke-width: ",i,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",u,"; ","stroke-linejoin: ",f,"; ","stroke-miterlimit: ",e,"; ","fill: ",n,"; ","opacity: ",o,";",h,s].join("")},getSvgTransform:function(){var n=fabric.util.toFixed,i=this.getAngle(),r=this.getCenterPoint(),t=fabric.Object.NUM_FRACTION_DIGITS,u="translate("+n(r.x,t)+" "+n(r.y,t)+")",f=i!==0?" rotate("+n(i,t)+")":"",e=this.scaleX===1&&this.scaleY===1?"":" scale("+n(this.scaleX,t)+" "+n(this.scaleY,t)+")",o=this.flipX?"matrix(-1 0 0 1 0 0) ":"",s=this.flipY?"matrix(1 0 0 -1 0 0)":"";return[u,f,e,o,s].join("")},_createBaseSVGMarkup:function(){var n=[];return this.fill&&this.fill.toLive&&n.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&n.push(this.stroke.toSVG(this,!1)),this.shadow&&n.push(this.shadow.toSVG(this)),n}});fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(){return this.stateProperties.some(function(n){return this.get(n)!==this.originalState[n]},this)},saveState:function(n){return this.stateProperties.forEach(function(n){this.originalState[n]=this.get(n)},this),n&&n.stateProperties&&n.stateProperties.forEach(function(n){this.originalState[n]=this.get(n)},this),this},setupState:function(){return this.originalState={},this.saveState(),this}}),function(){var t=fabric.util.getPointer,n=fabric.util.degreesToRadians,i=typeof G_vmlCanvasManager!="undefined";fabric.util.object.extend(fabric.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(n,i){var r;if(!this.hasControls||!this.active)return!1;var f=t(n,this.canvas.upperCanvasEl),o=f.x-i.left,s=f.y-i.top,u,e;for(r in this.oCoords)if(this.isControlVisible(r)&&(r!=="mtr"||this.hasRotatingPoint)&&(!this.get("lockUniScaling")||r!=="mt"&&r!=="mr"&&r!=="mb"&&r!=="ml")&&(e=this._getImageLines(this.oCoords[r].corner),u=this._findCrossPoints({x:o,y:s},e),u!==0&&u%2==1))return this.__corner=r,r;return!1},_setCornerCoords:function(){var t=this.oCoords,e=n(this.angle),o=n(45-this.angle),s=Math.sqrt(2*Math.pow(this.cornerSize,2))/2,h=4,i=s*Math.cos(o)+h,r=s*Math.sin(o)+h,u=Math.sin(e),f=Math.cos(e);t.DeleteControl.corner={tl:{x:t.DeleteControl.x-r,y:t.DeleteControl.y-i},tr:{x:t.DeleteControl.x+i,y:t.DeleteControl.y-r},br:{x:t.DeleteControl.x+r,y:t.DeleteControl.y+i},bl:{x:t.DeleteControl.x-i,y:t.DeleteControl.y+r}};t.InfoControl.corner={tl:{x:t.InfoControl.x-r,y:t.InfoControl.y-i},tr:{x:t.InfoControl.x+i,y:t.InfoControl.y-r},br:{x:t.InfoControl.x+r,y:t.InfoControl.y+i},bl:{x:t.InfoControl.x-i,y:t.InfoControl.y+r}};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}};t.mtr.corner={tl:{x:t.mtr.x-r+u*this.rotatingPointOffset,y:t.mtr.y-i-f*this.rotatingPointOffset},tr:{x:t.mtr.x+i+u*this.rotatingPointOffset,y:t.mtr.y-r-f*this.rotatingPointOffset},bl:{x:t.mtr.x-i+u*this.rotatingPointOffset,y:t.mtr.y+r-f*this.rotatingPointOffset},br:{x:t.mtr.x+r+u*this.rotatingPointOffset,y:t.mtr.y+i-f*this.rotatingPointOffset}}},drawBorders:function(n){var o,s,u,r,f;if(!this.hasBorders)return this;var i=this.padding,e=i*2,t=~~(this.strokeWidth/2)*2;return n.save(),n.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,n.strokeStyle=this.borderColor,o=1/this._constrainScale(this.scaleX),s=1/this._constrainScale(this.scaleY),n.lineWidth=1/this.borderScaleFactor,n.scale(o,s),u=this.getWidth(),r=this.getHeight(),n.strokeRect(~~(-(u/2)-i-t/2*this.scaleX)-.5,~~(-(r/2)-i-t/2*this.scaleY)-.5,~~(u+e+t*this.scaleX)+1,~~(r+e+t*this.scaleY)+1),this.hasRotatingPoint&&this.isControlVisible("mtr")&&!this.get("lockRotation")&&this.hasControls&&(f=(this.flipY?r+t*this.scaleY+i*2:-r-t*this.scaleY-i*2)/2,n.beginPath(),n.moveTo(0,f),n.lineTo(0,f+(this.flipY?this.rotatingPointOffset:-this.rotatingPointOffset)),n.closePath(),n.stroke()),n.restore(),this},drawDimensionInfo:function(n){var e,o,k,d;if(this.isControlVisible("WidthMeasurement")||this.isControlVisible("DepthMeasurement")){var h=this.cornerSize,b=h/2,r=~~(this.strokeWidth/2),c=-(this.width/2),l=-(this.height/2),t,i,g=h/this.scaleX,nt=h/this.scaleY,a=this.padding/this.scaleX,v=this.padding/this.scaleY,tt=b/this.scaleY,it=b/this.scaleX,y=(b-h)/this.scaleX,p=(b-h)/this.scaleY,s=this.height,w=this.width,rt=this.transparentCorners?"strokeRect":"fillRect",ut=this.transparentCorners,ft=typeof G_vmlCanvasManager!="undefined",u=1/this.scaleY,f=w;n.save();this.isControlVisible("WidthMeasurement")&&(t=c+0+y+r+a,i=l+s+p+r+v+30/this.scaleY,u=1/this.scaleY,f=w,n.fillRect(t,i,f,u),u=1/this.scaleX,f=10/this.scaleY,n.fillRect(t,i-5/this.scaleY,u,f),n.fillRect(t+w,i-5/this.scaleY,u,f));this.isControlVisible("DepthMeasurement")&&(t=c+y+r+a-30/this.scaleX,i=l+0+p+r+v,u=1/this.scaleX,f=s,n.fillRect(t,i,u,f),u=1/this.scaleY,f=10/this.scaleX,n.fillRect(t-5/this.scaleX,i,f,u),n.fillRect(t-5/this.scaleX,i+s,f,u));n.scale(1/this.scaleX,1/this.scaleY);n.font="18px Arial";e=0;o=0;this.isControlVisible("WidthMeasurement")&&(k=Math.round(w*this.scaleX/settings.ppi/settings.CURSCALE)+'"',e=55,o=0,this.angle>90&&this.angle<270&&(o=180,e=30),t=c+y+r+a+w/2-n.measureText(k).width/2,i=l/(1/this.scaleY)+s/(1/this.scaleY)+p+r+v+e,this.drawSomeRotatedText(n,t,i,k,0,o));this.isControlVisible("DepthMeasurement")&&(t=c+y+r+a-30/this.scaleX,i=l+0+p+r+v,d=Math.round(s*this.scaleY/settings.ppi/settings.CURSCALE)+'"',e=70,o=90,this.angle>0&&this.angle<180&&(o=270,e=45),t=c/(1/this.scaleX)+y+r+a-e,i=l+0+p+r+v+s/2-n.measureText(d).width/2,this.drawSomeRotatedText(n,t,i,d,0,o));n.restore()}return this},inchesToFeetAndInches:function(n){var t=parseInt(n/12),i=parseInt(n%12);return t+"' "+i+'"'},drawSomeRotatedText:function(n,t,i,r,u,f){var s=n.measureText(r),e,o;n.save();u!=null&&s.width>u&&(e=t+s.width/2,o=i+5,n.translate(e,o),n.rotate(f*Math.PI/180),n.translate(-e,-o));n.fillText(r,t,i);n.restore()},drawControls_original:function(n){if(!this.hasControls)return this;var a=this.cornerSize,l=a/2,t=~~(this.strokeWidth/2),r=-(this.width/2),i=-(this.height/2),o=this.padding/this.scaleX,f=this.padding/this.scaleY,c=l/this.scaleY,e=l/this.scaleX,y=(l-a)/this.scaleX,v=(l-a)/this.scaleY,s=this.height,h=this.width,u=this.transparentCorners?"strokeRect":"fillRect";return n.save(),n.lineWidth=1/Math.max(this.scaleX,this.scaleY),n.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,n.strokeStyle=n.fillStyle=this.cornerColor,this._drawControl("tl",n,u,r-e-t-o,i-c-t-f),this._drawControl("tr",n,u,r+h-e+t+o,i-c-t-f),this._drawControl("tr",n,u,r-e-t-o,i+s+v+t+f),this._drawControl("br",n,u,r+h+y+t+o,i+s+v+t+f),this.get("lockUniScaling")||(this._drawControl("mt",n,u,r+h/2-e,i-c-t-f),this._drawControl("mb",n,u,r+h/2-e,i+s+v+t+f),this._drawControl("mb",n,u,r+h+y+t+o,i+s/2-c),this._drawControl("ml",n,u,r-e-t-o,i+s/2-c)),this.hasRotatingPoint&&this._drawControl("mtr",n,u,r+h/2-e,this.flipY?i+s+this.rotatingPointOffset/this.scaleY-this.cornerSize/this.scaleX/2+t+f:i-this.rotatingPointOffset/this.scaleY-this.cornerSize/this.scaleY/2-t-f),n.restore(),this},drawControls:function(n){if(!this.hasControls)return this;var a=this.cornerSize,b=a/2,r=~~(this.strokeWidth/2),o=-(this.width/2),e=-(this.height/2),t,i,u=a/this.scaleX,f=a/this.scaleY,c=this.padding/this.scaleX,s=this.padding/this.scaleY,l=b/this.scaleY,v=b/this.scaleX,k=(b-a)/this.scaleX,d=(b-a)/this.scaleY,y=this.height,h=this.width,g=this.transparentCorners?"strokeRect":"fillRect",p=this.transparentCorners,w=typeof G_vmlCanvasManager!="undefined";return n.save(),n.lineWidth=1/Math.max(this.scaleX,this.scaleY),n.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,n.strokeStyle=n.fillStyle=this.cornerColor,this.isControlVisible("mt")&&(t=o+h/2-v,i=e-l-r-s,w||p||n.clearRect(t,i,u,f),n.drawImage(this.mtImage,t,i,u,f)),this.isControlVisible("mb")&&(t=o+h/2-v,i=e+y+d+r+s,w||p||n.clearRect(t,i,u,f),n.drawImage(this.mbImage,t,i,u,f)),this.isControlVisible("mr")&&(t=o+h+k+r+c,i=e+y/2-l,w||p||n.clearRect(t,i,u,f),n.drawImage(this.mrImage,t,i,u,f)),this.isControlVisible("ml")&&(t=o-v-r-c,i=e+y/2-l,w||p||n.clearRect(t,i,u,f),n.drawImage(this.mlImage,t,i,u,f)),this.isControlVisible("br")&&(t=o+h+k+r+c,i=e+y+d+r+s,w||p||n.clearRect(t,i,u,f),n.drawImage(this.brImage,t,i,u,f)),this.isControlVisible("DeleteControl")&&(t=o+h+k+r+c-0/this.scaleX,i=e-l-r-s,n.drawImage(this.DeleteImage,t,i,u,f)),this.isControlVisible("InfoControl")&&(t=o+h+k+r+c-30/this.scaleX,i=e-l-r-s,n.drawImage(this.InfoImage,t,i,u,f)),this._drawControl("tl",n,g,o-v-r-c,e-l-r-s),!this.get("lockUniScaling"),this.hasRotatingPoint&&this._drawControl("mtr",n,g,o+h/2-v,this.flipY?e+y+this.rotatingPointOffset/this.scaleY-this.cornerSize/this.scaleX/2+r+s:e-this.rotatingPointOffset/this.scaleY-this.cornerSize/this.scaleY/2-r-s),n.restore(),this},_drawControl:function(n,t,r,u,f){var e=this.cornerSize/this.scaleX,o=this.cornerSize/this.scaleY;this.isControlVisible(n)&&(i||this.transparentCorners||t.clearRect(u,f,e,o),t[r](u,f,e,o))},isControlVisible:function(n){return this._getControlsVisibility()[n]},setControlVisible:function(n,t){return this._getControlsVisibility()[n]=t,this},setControlsVisibility:function(n){n||(n={});for(var t in n)this.setControlVisible(t,n[t]);return this},_getControlsVisibility:function(){return this._controlsVisibility||(this._controlsVisibility={tl:!0,tr:!0,br:!0,bl:!0,ml:!0,mt:!0,mr:!0,mb:!0,mtr:!0,DeleteControl:!0,InfoControl:!0,WidthMeasurement:!0,DepthMeasurement:!0}),this._controlsVisibility}})}(),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend,r={x1:1,x2:1,y1:1,y2:1},u=t.StaticCanvas.supports("setLineDash");if(t.Line){t.warn("fabric.Line is already defined");return}t.Line=t.util.createClass(t.Object,{type:"line",initialize:function(n,t){t=t||{};n||(n=[0,0,0,0]);this.callSuper("initialize",t);this.set("x1",n[0]);this.set("y1",n[1]);this.set("x2",n[2]);this.set("y2",n[3]);this._setWidthHeight(t)},_setWidthHeight:function(n){n||(n={});this.set("width",Math.abs(this.x2-this.x1)||1);this.set("height",Math.abs(this.y2-this.y1)||1);this.set("left","left"in n?n.left:Math.min(this.x1,this.x2)+this.width/2);this.set("top","top"in n?n.top:Math.min(this.y1,this.y2)+this.height/2)},_set:function(n,t){return this[n]=t,n in r&&this._setWidthHeight(),this},_render:function(n){var r,t,i,f;n.beginPath();r=this.group&&this.group.type==="path-group";r&&!this.transformMatrix&&n.translate(-this.group.width/2+this.left,-this.group.height/2+this.top);(!this.strokeDashArray||this.strokeDashArray&&u)&&(t=this.x1<=this.x2?-1:1,i=this.y1<=this.y2?-1:1,n.moveTo(this.width===1?0:t*this.width/2,this.height===1?0:i*this.height/2),n.lineTo(this.width===1?0:t*-1*this.width/2,this.height===1?0:i*-1*this.height/2));n.lineWidth=this.strokeWidth;f=n.strokeStyle;n.strokeStyle=this.stroke||n.fillStyle;this._renderStroke(n);n.strokeStyle=f},_renderDashedStroke:function(n){var u=this.x1<=this.x2?-1:1,f=this.y1<=this.y2?-1:1,i=this.width===1?0:u*this.width/2,r=this.height===1?0:f*this.height/2;n.beginPath();t.util.drawDashedLine(n,i,r,-i,-r,this.strokeDashArray);n.closePath()},toObject:function(n){return i(this.callSuper("toObject",n),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(n){var t=this._createBaseSVGMarkup();return t.push("'),n?n(t.join("")):t.join("")},complexity:function(){return 1}});t.Line.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" "));t.Line.fromElement=function(n,r){var u=t.parseAttributes(n,t.Line.ATTRIBUTE_NAMES),f=[u.x1||0,u.y1||0,u.x2||0,u.y2||0];return new t.Line(f,i(u,r))};t.Line.fromObject=function(n){var i=[n.x1,n.y1,n.x2,n.y2];return new t.Line(i,n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";function u(n){return"radius"in n&&n.radius>0}var t=n.fabric||(n.fabric={}),r=Math.PI*2,i=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(n){n=n||{};this.set("radius",n.radius||0);this.callSuper("initialize",n)},_set:function(n,t){return this.callSuper("_set",n,t),n==="radius"&&this.setRadius(t),this},toObject:function(n){return i(this.callSuper("toObject",n),{radius:this.get("radius")})},toSVG:function(n){var t=this._createBaseSVGMarkup();return t.push("'),n?n(t.join("")):t.join("")},_render:function(n,t){n.beginPath();n.globalAlpha=this.group?n.globalAlpha*this.opacity:this.opacity;n.arc(t?this.left:0,t?this.top:0,this.radius,0,r,!1);n.closePath();this._renderFill(n);this._renderStroke(n)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(n){this.radius=n;this.set("width",n*2).set("height",n*2)},complexity:function(){return 1}});t.Circle.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("cx cy r".split(" "));t.Circle.fromElement=function(n,r){var f,e;if(r||(r={}),f=t.parseAttributes(n,t.Circle.ATTRIBUTE_NAMES),!u(f))throw new Error("value of `r` attribute is required and can not be negative");return"left"in f&&(f.left-=r.width/2||0),"top"in f&&(f.top-=r.height/2||0),e=new t.Circle(i(f,r)),e.cx=parseFloat(n.getAttribute("cx"))||0,e.cy=parseFloat(n.getAttribute("cy"))||0,e};t.Circle.fromObject=function(n){return new t.Circle(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={});if(t.Triangle){t.warn("fabric.Triangle is already defined");return}t.Triangle=t.util.createClass(t.Object,{type:"triangle",initialize:function(n){n=n||{};this.callSuper("initialize",n);this.set("width",n.width||100).set("height",n.height||100)},_render:function(n){var i=this.width/2,t=this.height/2;n.beginPath();n.moveTo(-i,t);n.lineTo(0,-t);n.lineTo(i,t);n.closePath();this._renderFill(n);this._renderStroke(n)},_renderDashedStroke:function(n){var r=this.width/2,i=this.height/2;n.beginPath();t.util.drawDashedLine(n,-r,i,0,-i,this.strokeDashArray);t.util.drawDashedLine(n,0,-i,r,i,this.strokeDashArray);t.util.drawDashedLine(n,r,i,-r,i,this.strokeDashArray);n.closePath()},toSVG:function(n){var t=this._createBaseSVGMarkup(),r=this.width/2,i=this.height/2,u=[-r+" "+i,"0 "+-i,r+" "+i].join(",");return t.push("'),n?n(t.join("")):t.join("")},complexity:function(){return 1}});t.Triangle.fromObject=function(n){return new t.Triangle(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),r=Math.PI*2,i=t.util.object.extend;if(t.Ellipse){t.warn("fabric.Ellipse is already defined.");return}t.Ellipse=t.util.createClass(t.Object,{type:"ellipse",rx:0,ry:0,initialize:function(n){n=n||{};this.callSuper("initialize",n);this.set("rx",n.rx||0);this.set("ry",n.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(n){return i(this.callSuper("toObject",n),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(n){var t=this._createBaseSVGMarkup();return t.push("'),n?n(t.join("")):t.join("")},render:function(n,t){if(this.rx!==0&&this.ry!==0)return this.callSuper("render",n,t)},_render:function(n,t){n.beginPath();n.save();n.globalAlpha=this.group?n.globalAlpha*this.opacity:this.opacity;this.transformMatrix&&this.group&&n.translate(this.cx,this.cy);n.transform(1,0,0,this.ry/this.rx,0,0);n.arc(t?this.left:0,t?this.top:0,this.rx,0,r,!1);this._renderFill(n);this._renderStroke(n);n.restore()},complexity:function(){return 1}});t.Ellipse.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" "));t.Ellipse.fromElement=function(n,r){var f;r||(r={});var u=t.parseAttributes(n,t.Ellipse.ATTRIBUTE_NAMES),e=u.left,o=u.top;return"left"in u&&(u.left-=r.width/2||0),"top"in u&&(u.top-=r.height/2||0),f=new t.Ellipse(i(u,r)),f.cx=e||0,f.cy=o||0,f};t.Ellipse.fromObject=function(n){return new t.Ellipse(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";function u(n){return n.left=n.left||0,n.top=n.top||0,n}var t=n.fabric||(n.fabric={}),r=t.util.object.extend,i;if(t.Rect){console.warn("fabric.Rect is already defined");return}i=t.Object.prototype.stateProperties.concat();i.push("rx","ry","x","y");t.Rect=t.util.createClass(t.Object,{stateProperties:i,type:"rect",rx:0,ry:0,x:0,y:0,strokeDashArray:null,initialize:function(n){n=n||{};this.callSuper("initialize",n);this._initRxRy();this.x=n.x||0;this.y=n.y||0},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(n){var r=this.rx||0,e=this.ry||0,t=-this.width/2,i=-this.height/2,u=this.width,f=this.height,s=this.group&&this.group.type==="path-group",o;n.beginPath();n.globalAlpha=s?n.globalAlpha*this.opacity:this.opacity;this.transformMatrix&&s&&n.translate(this.width/2+this.x,this.height/2+this.y);!this.transformMatrix&&s&&n.translate(-this.group.width/2+this.width/2+this.x,-this.group.height/2+this.height/2+this.y);o=r!==0||e!==0;n.moveTo(t+r,i);n.lineTo(t+u-r,i);o&&n.quadraticCurveTo(t+u,i,t+u,i+e,t+u,i+e);n.lineTo(t+u,i+f-e);o&&n.quadraticCurveTo(t+u,i+f,t+u-r,i+f,t+u-r,i+f);n.lineTo(t+r,i+f);o&&n.quadraticCurveTo(t,i+f,t,i+f-e,t,i+f-e);n.lineTo(t,i+e);o&&n.quadraticCurveTo(t,i,t+r,i,t+r,i);n.closePath();this._renderFill(n);this._renderStroke(n)},_renderDashedStroke:function(n){var i=-this.width/2,r=-this.height/2,u=this.width,f=this.height;n.beginPath();t.util.drawDashedLine(n,i,r,i+u,r,this.strokeDashArray);t.util.drawDashedLine(n,i+u,r,i+u,r+f,this.strokeDashArray);t.util.drawDashedLine(n,i+u,r+f,i,r+f,this.strokeDashArray);t.util.drawDashedLine(n,i,r+f,i,r,this.strokeDashArray);n.closePath()},_normalizeLeftTopProperties:function(n){return"left"in n&&this.set("left",n.left+this.getWidth()/2),this.set("x",n.left||0),"top"in n&&this.set("top",n.top+this.getHeight()/2),this.set("y",n.top||0),this},toObject:function(n){var t=r(this.callSuper("toObject",n),{rx:this.get("rx")||0,ry:this.get("ry")||0,x:this.get("x"),y:this.get("y")});return this.includeDefaultValues||this._removeDefaultValues(t),t},toSVG:function(n){var t=this._createBaseSVGMarkup();return t.push("'),n?n(t.join("")):t.join("")},complexity:function(){return 1}});t.Rect.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" "));t.Rect.fromElement=function(n,i){var f,e;return n?(f=t.parseAttributes(n,t.Rect.ATTRIBUTE_NAMES),f=u(f),e=new t.Rect(r(i?t.util.object.clone(i):{},f)),e._normalizeLeftTopProperties(f),e):null};t.Rect.fromObject=function(n){return new t.Rect(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=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(n,t,i){t=t||{};this.set("points",n);this.callSuper("initialize",t);this._calcDimensions(i)},_calcDimensions:function(n){return t.Polygon.prototype._calcDimensions.call(this,n)},toObject:function(n){return t.Polygon.prototype.toObject.call(this,n)},toSVG:function(n){for(var u=[],r=this._createBaseSVGMarkup(),t=0,f=this.points.length;t'),n?n(r.join("")):r.join("")},_render:function(n){var i,t,r;for(n.beginPath(),n.moveTo(this.points[0].x,this.points[0].y),t=0,r=this.points.length;t'),n?n(i.join("")):i.join("")},_render:function(n){var i,t,r;for(n.beginPath(),n.moveTo(this.points[0].x,this.points[0].y),t=0,r=this.points.length;t"},toObject:function(n){var t=u(this.callSuper("toObject",n),{path:this.path,pathOffset:this.pathOffset});return this.sourcePath&&(t.sourcePath=this.sourcePath),this.transformMatrix&&(t.transformMatrix=this.transformMatrix),t},toDatalessObject:function(n){var t=this.toObject(n);return this.sourcePath&&(t.path=this.sourcePath),delete t.sourcePath,t},toSVG:function(n){for(var u,r=[],t=this._createBaseSVGMarkup(),i=0,f=this.path.length;i',"","<\/g>"),n?n(t.join("")):t.join("")},complexity:function(){return this.path.length},_parsePath:function(){for(var r,a,v,u,t,y,f=[],i=[],e,o,p=/(-?\.\d+)|(-?\d+(\.\d+)?)/g,c,l,h=0,n,w=this.path.length;hu)for(t=1,y=n.length;t"],i=0,u=r.length;i"),n?n(t.join("")):t.join("")},toString:function(){return"#"},isSameColor:function(){var n=this.getObjects()[0].get("fill");return this.getObjects().every(function(t){return t.get("fill")===n})},complexity:function(){return this.paths.reduce(function(n,t){return n+(t&&t.complexity?t.complexity():0)},0)},getObjects:function(){return this.paths}});t.PathGroup.fromObject=function(n,i){typeof n.paths=="string"?t.loadSVGFromURL(n.paths,function(r){var f=n.paths,u;delete n.paths;u=t.util.groupSVGElements(r,n,f);i(u)}):t.util.enlivenObjects(n.paths,function(r){delete n.paths;i(new t.PathGroup(r,n))})};t.PathGroup.async=!0}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend,r=t.util.array.min,u=t.util.array.max,e=t.util.array.invoke,f;t.Group||(f={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0},t.Group=t.util.createClass(t.Object,t.Collection,{type:"group",initialize:function(n,t){t=t||{};this._objects=n||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();t&&i(this,t);this._setOpacityIfSame();this.setCoords(!0);this.saveCoords()},_updateObjectsCoords:function(){this.forEachObject(this._updateObjectCoords,this)},_updateObjectCoords:function(n){var t=n.getLeft(),i=n.getTop();n.set({originalLeft:t,originalTop:i,left:t-this.left,top:i-this.top});n.setCoords();n.__origHasControls=n.hasControls;n.hasControls=!1},toString:function(){return"#"},addWithUpdate:function(n){return this._restoreObjectsState(),this._objects.push(n),n.group=this,this.forEachObject(this._setObjectActive,this),this._calcBounds(),this._updateObjectsCoords(),this},_setObjectActive:function(n){n.set("active",!0);n.group=this},removeWithUpdate:function(n){return this._moveFlippedObject(n),this._restoreObjectsState(),this.forEachObject(this._setObjectActive,this),this.remove(n),this._calcBounds(),this._updateObjectsCoords(),this},_onObjectAdded:function(n){n.group=this},_onObjectRemoved:function(n){delete n.group;n.set("active",!1)},delegatedProperties:{fill:!0,opacity:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textAlign:!0,backgroundColor:!0},_set:function(n,t){if(n in this.delegatedProperties){var i=this._objects.length;for(this[n]=t;i--;)this._objects[i].set(n,t)}else this[n]=t},toObject:function(n){return i(this.callSuper("toObject",n),{objects:e(this._objects,"toObject",n)})},render:function(n,i){if(this.visible){n.save();this.transform(n);this.clipTo&&t.util.clipContext(this,n);for(var r=0,u=this._objects.length;r'],i=0,r=this._objects.length;i"),n?n(t.join("")):t.join("")},get:function(n){if(n in f){if(this[n])return this[n];for(var t=0,i=this._objects.length;t','<\/image>"),(this.stroke||this.strokeDashArray)&&(i=this.fill,this.fill=null,t.push("'),this.fill=i),t.push("<\/g>"),n?n(t.join("")):t.join("")},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#'},clone:function(n,t){this.constructor.fromObject(this.toObject(t),n)},applyFilters:function(n){if(this.filters.length===0){this._element=this._originalElement;n&&n();return}var t=this._originalElement,r=fabric.util.createCanvasElement(),i=fabric.util.createImage(),u=this;return r.width=t.width,r.height=t.height,r.getContext("2d").drawImage(t,0,0,t.width,t.height),this.filters.forEach(function(n){n&&n.applyTo(r)}),i.width=t.width,i.height=t.height,fabric.isLikelyNode?(i.src=r.toBuffer(undefined,fabric.Image.pngCompression),u._element=i,n&&n()):(i.onload=function(){u._element=i;n&&n();i.onload=r=t=null},i.src=r.toDataURL("image/png")),this},_render:function(n){n.drawImage(this._element,-this.width/2,-this.height/2,this.width,this.height)},_resetWidthHeight:function(){var n=this.getElement();this.set("width",n.width);this.set("height",n.height)},_initElement:function(n){this.setElement(fabric.util.getById(n));fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(n){n||(n={});this.setOptions(n);this._setWidthHeight(n);this._element.crossOrigin=this.crossOrigin},_initFilters:function(n,t){n.filters&&n.filters.length?fabric.util.enlivenObjects(n.filters,function(n){t&&t(n)},"fabric.Image.filters"):t&&t()},_setWidthHeight:function(n){this.width="width"in n?n.width:this.getElement().width||0;this.height="height"in n?n.height:this.getElement().height||0},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc;fabric.Image.fromObject=function(n,t){fabric.util.loadImage(n.src,function(i){fabric.Image.prototype._initFilters.call(n,n,function(r){n.filters=r||[];var u=new fabric.Image(i,n);t&&t(u)})},null,n.crossOrigin)};fabric.Image.fromURL=function(n,t,i){fabric.util.loadImage(n,function(n){t(new fabric.Image(n,i))},null,i&&i.crossOrigin)};fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height xlink:href".split(" "));fabric.Image.fromElement=function(n,i,r){var u=fabric.parseAttributes(n,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(u["xlink:href"],i,t(r?fabric.util.object.clone(r):{},u))};fabric.Image.async=!0;fabric.Image.pngCompression=1}(typeof exports!="undefined"?exports:this);fabric.Image.filters=fabric.Image.filters||{};fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",toObject:function(){return{type:this.type}},toJSON:function(){return this.toObject()}}),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Brightness=t.util.createClass(t.Image.filters.BaseFilter,{type:"Brightness",initialize:function(n){n=n||{};this.brightness=n.brightness||100},applyTo:function(n){for(var u=n.getContext("2d"),f=u.getImageData(0,0,n.width,n.height),i=f.data,r=this.brightness,t=0,e=i.length;tg||a<0||a>y)||(u=(l*y+a)*4,f=b[i*e+r],it+=o[u]*f,rt+=o[u+1]*f,ut+=o[u+2]*f,w+=o[u+3]*f);s[c]=it;s[c+1]=rt;s[c+2]=ut;s[c+3]=w+ft*(255-w)}k.putImageData(tt,0,0)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}});t.Image.filters.Convolute.fromObject=function(n){return new t.Image.filters.Convolute(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.GradientTransparency=t.util.createClass(t.Image.filters.BaseFilter,{type:"GradientTransparency",initialize:function(n){n=n||{};this.threshold=n.threshold||100},applyTo:function(n){for(var r=n.getContext("2d"),u=r.getImageData(0,0,n.width,n.height),i=u.data,e=this.threshold,f=i.length,t=0,o=i.length;t-1?n.channel:0},applyTo:function(n){var o,s;if(this.mask){var e=n.getContext("2d"),u=e.getImageData(0,0,n.width,n.height),h=u.data,i=this.mask.getElement(),f=t.util.createCanvasElement(),c=this.channel,r,l=u.width*u.height*4;for(f.width=i.width,f.height=i.height,f.getContext("2d").drawImage(i,0,0,i.width,i.height),o=f.getContext("2d").getImageData(0,0,i.width,i.height),s=o.data,r=0;ro&&u>o&&f>o&&s(r-u)'},_render:function(n){var t=this.group&&this.group.type==="path-group";t&&!this.transformMatrix?n.translate(-this.group.width/2+this.left,-this.group.height/2+this.top):t&&this.transformMatrix&&n.translate(-this.group.width/2,-this.group.height/2);typeof Cufon=="undefined"||this.useNative===!0?this._renderViaNative(n):this._renderViaCufon(n)},_renderViaNative:function(n){var i=this.text.split(this._reNewline);this.transform(n,t.isLikelyNode);this._setTextStyles(n);this.width=this._getTextWidth(n,i);this.height=this._getTextHeight(n,i);this.clipTo&&t.util.clipContext(this,n);this._renderTextBackground(n,i);this._translateForTextAlign(n);this._renderText(n,i);this.textAlign!=="left"&&this.textAlign!=="justify"&&n.restore();this._renderTextDecoration(n,i);this.clipTo&&n.restore();this._setBoundaries(n,i);this._totalLineHeight=0},_renderText:function(n,t){n.save();this._setShadow(n);this._renderTextFill(n,t);this._renderTextStroke(n,t);this._removeShadow(n);n.restore()},_translateForTextAlign:function(n){this.textAlign!=="left"&&this.textAlign!=="justify"&&(n.save(),n.translate(this.textAlign==="center"?this.width/2:this.width,0))},_setBoundaries:function(n,t){var i,u,r,f;for(this._boundaries=[],i=0,u=t.length;ii&&(i=u);return i},_renderChars:function(n,t,i,r,u){t[n](i,r,u)},_renderTextLine:function(n,t,i,r,u,f){var h,s,e,l;if(u-=this.fontSize/4,this.textAlign!=="justify"){this._renderChars(n,t,i,r,u,f);return}if(h=t.measureText(i).width,s=this.width,s>h){var o=i.split(/\s+/),a=t.measureText(i.replace(/\s+/g,"")).width,v=s-a,y=o.length-1,p=v/y,c=0;for(e=0,l=o.length;e-1&&r(this.fontSize*this.lineHeight);this.textDecoration.indexOf("line-through")>-1&&r(this.fontSize*this.lineHeight-this.fontSize/2);this.textDecoration.indexOf("overline")>-1&&r(this.fontSize*this.lineHeight-this.fontSize)}},_getFontDeclaration:function(){return[t.isLikelyNode?this.fontWeight:this.fontStyle,t.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",t.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},render:function(n,t){this.visible&&(n.save(),this._render(n),!t&&this.active&&(this.drawBorders(n),this.drawControls(n)),n.restore())},toObject:function(n){var t=u(this.callSuper("toObject",n),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textAlign:this.textAlign,path:this.path,textBackgroundColor:this.textBackgroundColor,useNative:this.useNative});return this.includeDefaultValues||this._removeDefaultValues(t),t},toSVG:function(n){var i=[],r=this.text.split(this._reNewline),t=this._getSVGLeftTopOffsets(r),u=this._getSVGTextAndBg(t.lineTop,t.textLeft,r),f=this._getSVGShadows(t.lineTop,r);return t.textTop+=this._fontAscent?this._fontAscent/5*this.lineHeight:0,this._wrapSVGTextAndBg(i,u,f,t),n?n(i.join("")):i.join("")},_getSVGLeftTopOffsets:function(n){var t=this.useNative?this.fontSize*this.lineHeight:-this._fontAscent-this._fontAscent/5*this.lineHeight,i=-(this.width/2),r=this.useNative?this.fontSize-1:this.height/2-n.length*this.fontSize-this._totalLineHeight;return{textLeft:i,textTop:r,lineTop:t}},_wrapSVGTextAndBg:function(n,t,r,u){n.push('',t.textBgRects.join(""),"',r.join(""),t.textSpans.join(""),"<\/text>","<\/g>")},_getSVGShadows:function(n,r){var f=[],u,o,e=1,s;if(!this.shadow||!this._boundaries)return f;for(u=0,o=r.length;u",t.util.string.escapeXml(r[u]),"<\/tspan>"),e=1):e++;return f},_getSVGTextAndBg:function(n,t,i){var e=[],u=[],f=1,r,o;for(this._setSVGBg(u),r=0,o=i.length;r",t.util.string.escapeXml(n),"<\/tspan>")},_setSVGTextLineBg:function(n,t,r,u){n.push("<\/rect>')},_setSVGBg:function(n){this.backgroundColor&&this._boundaries&&n.push("<\/rect>')},_getFillAttributes:function(n){var i=n&&typeof n=="string"?new t.Color(n):"";return!i||!i.getSource()||i.getAlpha()===1?'fill="'+n+'"':'opacity="'+i.getAlpha()+'" fill="'+i.setAlpha(1).toRgb()+'"'},_set:function(n,t){n==="fontFamily"&&this.path&&(this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+t+"$3"));this.callSuper("_set",n,t);n in this._dimensionAffectingProps&&(this._initDimensions(),this.setCoords())},complexity:function(){return 1}});t.Text.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat("x y font-family font-style font-weight font-size text-decoration".split(" "));t.Text.fromElement=function(n,i){var u,r;return n?(u=t.parseAttributes(n,t.Text.ATTRIBUTE_NAMES),i=t.util.object.extend(i?t.util.object.clone(i):{},u),r=new t.Text(n.textContent,i),r.set({left:r.getLeft()+r.getWidth()/2,top:r.getTop()-r.getHeight()/2}),r):null};t.Text.fromObject=function(n){return new t.Text(n.text,f(n))};t.util.createAccessors(t.Text)}(typeof exports!="undefined"?exports:this);fabric.util.object.extend(fabric.Text.prototype,{_renderViaCufon:function(n){var t=Cufon.textOptions||(Cufon.textOptions={}),i;t.left=this.left;t.top=this.top;t.context=n;t.color=this.fill;i=this._initDummyElementForCufon();this.transform(n);Cufon.replaceElement(i,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,textDecoration:this.textDecoration,textShadow:this.shadow&&this.shadow.toString(),textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,stroke:this.stroke,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,textBackgroundColor:this.textBackgroundColor});this.width=t.width;this.height=t.height;this._totalLineHeight=t.totalLineHeight;this._fontAscent=t.fontAscent;this._boundaries=t.boundaries;i=null;this.setCoords()},_initDummyElementForCufon:function(){var n=fabric.document.createElement("pre"),t=fabric.document.createElement("div");return t.appendChild(n),typeof G_vmlCanvasManager=="undefined"?n.innerHTML=this.text:n.innerText=this.text.replace(/\r?\n/gi,"\r"),n.style.fontSize=this.fontSize+"px",n.style.letterSpacing="normal",n}}),function(){function n(n,t,i){var r=e.parse(n),f,u;r.port||(r.port=r.protocol.indexOf("https:")===0?443:80);f=r.port===443?s:o;u=f.request({hostname:r.hostname,port:r.port,path:r.path,method:"GET"},function(n){var r="";t&&n.setEncoding(t);n.on("end",function(){i(r)});n.on("data",function(t){n.statusCode===200&&(r+=t)})});u.on("error",function(n){n.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(n.message)});u.end()}function i(n,t){var i=require("fs");i.readFile(n,function(n,i){if(n){fabric.log(n);throw n;}else t(i)})}var r,u;if(typeof document=="undefined"||typeof window=="undefined"){var f=new require("xmldom").DOMParser,e=require("url"),o=require("http"),s=require("https"),t=require("canvas"),h=require("canvas").Image;fabric.util.loadImage=function(t,r,u){var e=function(n){f.src=new Buffer(n,"binary");f._src=t;r&&r.call(u,f)},f=new h;t&&(t instanceof Buffer||t.indexOf("data")===0)?(f.src=f._src=t,r&&r.call(u,f)):t&&t.indexOf("http")!==0?i(t,e):t?n(t,"binary",e):r&&r.call(u,t)};fabric.loadSVGFromURL=function(t,r,u){t=t.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();t.indexOf("http")!==0?i(t,function(n){fabric.loadSVGFromString(n,r,u)}):n(t,"",function(n){fabric.loadSVGFromString(n,r,u)})};fabric.loadSVGFromString=function(n,t,i){var r=(new f).parseFromString(n);fabric.parseSVGDocument(r.documentElement,function(n,i){t&&t(n,i)},i)};fabric.util.getScript=function(t,i){n(t,"",function(body){eval(body);i&&i()})};fabric.Image.fromObject=function(n,t){fabric.util.loadImage(n.src,function(i){var r=new fabric.Image(i);r._initConfig(n);r._initFilters(n,function(n){r.filters=n||[];t&&t(r)})})};fabric.createCanvasForNode=function(n,i){var u=fabric.document.createElement("canvas"),f=new t(n||600,i||600),e,r;return u.style={},u.width=f.width,u.height=f.height,e=fabric.Canvas||fabric.StaticCanvas,r=new e(u),r.contextContainer=f.getContext("2d"),r.nodeCanvas=f,r.Font=t.Font,r};fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};fabric.StaticCanvas.prototype.createJPEGStream=function(n){return this.nodeCanvas.createJPEGStream(n)};r=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(n){return r.call(this,n),this.nodeCanvas.width=n,this};fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);u=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(n){return u.call(this,n),this.nodeCanvas.height=n,this};fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}}();Modernizr.localstorage&&(localStorage.open_plan||readCookie("open_plan"))&&$(".quickList_roomPlannerButtonText").html("VIEW YOUR"),function(){"use strict";var n=document.createElement("link"),t=document.getElementsByTagName("head")[0],i=Utils.IsDev?".css":".min.css";n.setAttribute("rel","stylesheet");n.setAttribute("href",Utils.BaseURL+"StyleSheets/RoomPlannerV2"+i);n.setAttribute("type","text/css");t.appendChild(n);try{document.getElementsByClassName("roomPlanner")[0].style.display="block"}catch(r){console.error(r)}}();roomPlanSaved=!0;resizeCanvas=!0;window.addEventListener("orientationchange",function(){$(".roomPlanner_sidemenuNav").height(window.innerHeight-$(".roomPlanner_header").height()-$(".roomPlanner_sidemenuHeader").height());var n=$(".roomPlanner_sidemenuNav").height(),t=($("#roomPlanner_sidemenuProducts h3").height()+1)*$("#roomPlanner_sidemenuProducts h3").size();$(".roomPlanner_sidemenuActive").css("height",n-t)},!1);$(window).bind("beforeunload",function(){if($(".roomPlanner").hasClass("roomPlannerOpen")&&!roomPlanSaved)return"You are about to leave this page. Any unsaved changes may be lost."});$.fn.forceNumeric=function(){return this.each(function(){$(this).keydown(function(n){var t=n.which||n.keyCode;return!n.shiftKey&&!n.altKey&&!n.ctrlKey&&t>=48&&t<=57||t>=96&&t<=105||t==190||t==188||t==109||t==110||t==8||t==9||t==13||t==35||t==36||t==37||t==39||t==46||t==45?!0:!1})})},function(){"use strict";var t=0,n=new StopWatch;$(".quickList_roomPlannerButton").on("click",function(){n.start();TrackEvent("Room Planner","Open","",!0)});$("body").on("click",".roomPlanner_close",function(){n.stop();TrackEvent("Room Planner","Close","",!0,parseFloat(n.getSeconds()))});$(".itemPage12_addToRoomPlan").on("click",function(){var n=parseInt($(this).attr("rel").split("iconid")[1].replace(/^\D+/,"").trim(),10);TrackEvent("Room Planner","Add Item",n,!0);t=new Date})}()