function AddToShoppingCart(n,t){var i='{"gpid":'+n+"}";$.ajax({type:"POST",url:Utils.BaseURL+"AjaxItemService.asmx/AddToShoppingCart",data:i,contentType:"application/json; charset=utf-8",dataType:"json",success:function(i){var r=JSON.parse(i.d),u;window.fbPixel.done(function(){fbq("track","AddToCart",{content_type:"product",content_ids:[n.toString()]})});u=parseInt($(".js-cart-count").first().text().replace(/\D/g,""),10)+1;$(".cart-status-v4").length>0?$(".js-cart-count").text(u):$(".js-cart-count").text("("+u+")");typeof laurentideTracker!="undefined"&&Laurentide_AddToCart(r,u);t(r);GaAddToCart(r);TrackItemEvent("Shopping Cart","Add",r.GPID,r)},error:function(n){console.log(n.responseText)}})}function clearTextBoxText(n){n.value=""}function RecentlyViewedSlider(n){var t=$(n).closest(".recently-viewed"),i=$(t).data("slidesperview"),r=$(t).data("spacebetween"),u=new Swiper(t,{calculateHeight:!0,preloadImages:!0,scrollbar:{el:".swiper-scrollbar",hide:!1,dragSize:50},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},freeMode:!0,slidesPerView:i,spaceBetween:r,slidesPerGroup:3,watchOverflow:!0,breakpoints:{1024:{slidesPerView:4.25},768:{slidesPerView:3.25,spaceBetween:4},465:{slidesPerView:1.5,spaceBetween:4}}})}function AddToRoomPlan(n){RoomPlannerV2.AddToRoomPlan(n)}var QuickListV2,Cufon,JSON,eventjs,Event,RoomPlannerV2;(function(){var n=function(n,t,i){var r=t+"/"+n,u;return typeof i=="object"&&i!==null&&"area"in i&&(r=i.area+"/"+r),u={url:Utils.BaseURL+r,dataType:"html"},typeof i=="object"&&i!==null&&(u.data=i),$.ajax(u)},t=function(n){if(n!==null&&n.length>0){var t=window[n];if(typeof t=="function")try{t()}catch(i){console.log("error executing callback");console.log(i)}else console.log("callback is not a function")}};$(function(){$(".js-ajax-partial").each(function(){var i=$(this),r=i.data("action"),u=i.data("controller"),f=i.data("routeValues"),e=i.data("callback");n(r,u,f).then(function(n){i.replaceWith(n);t(e)}).fail(function(n){console.log("ERROR loading partial");console.log(n)})})})})(),function(n,t,i){typeof define=="function"&&define.amd?define(["jquery"],function(r){return i(r,n,t),r.mobile}):i(n.jQuery,n,t)}(this,document,function(n,t,i){(function(n,t,i,r){function a(n){while(n&&typeof n.originalEvent!="undefined")n=n.originalEvent;return n}function wt(t,i){var u=t.type,e,o,c,f,s,l,v,h,y;if(t=n.Event(t),t.type=i,e=t.originalEvent,o=n.event.props,u.search(/^(mouse|click)/)>-1&&(o=yt),e)for(v=o.length,f;v;)f=o[--v],t[f]=e[f];if(u.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),u.search(/^touch/)!==-1&&(c=a(e),u=c.touches,s=c.changedTouches,l=u&&u.length?u[0]:s&&s.length?s[0]:r,l))for(h=0,y=tt.length;h<y;h++)f=tt[h],t[f]=l[f];return t}function p(t){for(var i={},r,u;t;){r=n.data(t,o);for(u in r)r[u]&&(i[u]=i.hasVirtualBinding=!0);t=t.parentNode}return i}function bt(t,i){for(var r;t;){if(r=n.data(t,o),r&&(!i||r[i]))return t;t=t.parentNode}return null}function kt(){c=!1}function ut(){c=!0}function dt(){s=0;v.length=0;k=!1;ut()}function gt(){kt()}function nt(){ft();h=setTimeout(function(){h=0;dt()},n.vmouse.resetTimerDuration)}function ft(){h&&(clearTimeout(h),h=0)}function e(t,i,r){var u;return(r&&r[t]||!r&&bt(i.target,t))&&(u=wt(i,t),n(i.target).trigger(u)),u}function et(t){var r=n.data(t.target,w),i;k||s&&s===r||(i=e("v"+t.type,t),i&&(i.isDefaultPrevented()&&t.preventDefault(),i.isPropagationStopped()&&t.stopPropagation(),i.isImmediatePropagationStopped()&&t.stopImmediatePropagation()))}function ot(t){var o=a(t).touches,r,i,u;o&&o.length===1&&(r=t.target,i=p(r),i.hasVirtualBinding&&(s=pt++,n.data(r,w,s),ft(),gt(),f=!1,u=a(t).touches[0],it=u.pageX,rt=u.pageY,e("vmouseover",t,i),e("vmousedown",t,i)))}function st(n){c||(f||e("vmousecancel",n,p(n.target)),f=!0,nt())}function ht(t){if(!c){var i=a(t).touches[0],o=f,r=n.vmouse.moveDistanceThreshold,u=p(t.target);f=f||Math.abs(i.pageX-it)>r||Math.abs(i.pageY-rt)>r;f&&!o&&e("vmousecancel",t,u);e("vmousemove",t,u);nt()}}function ct(n){if(!c){ut();var t=p(n.target),i,r;e("vmouseup",n,t);f||(i=e("vclick",n,t),i&&i.isDefaultPrevented()&&(r=a(n).changedTouches[0],v.push({touchID:s,x:r.clientX,y:r.clientY}),k=!0));e("vmouseout",n,t);f=!1;nt()}}function lt(t){var i=n.data(t,o),r;if(i)for(r in i)if(i[r])return!0;return!1}function at(){}function ni(t){var i=t.substr(1);return{setup:function(){lt(this)||n.data(this,o,{});var r=n.data(this,o);r[t]=!0;u[t]=(u[t]||0)+1;u[t]===1&&y.bind(i,et);n(this).bind(i,at);d&&(u.touchstart=(u.touchstart||0)+1,u.touchstart===1&&y.bind("touchstart",ot).bind("touchend",ct).bind("touchmove",ht).bind("scroll",st))},teardown:function(){--u[t];u[t]||y.unbind(i,et);d&&(--u.touchstart,u.touchstart||y.unbind("touchstart",ot).unbind("touchmove",ht).unbind("touchend",ct).unbind("scroll",st));var r=n(this),f=n.data(this,o);f&&(f[t]=!1);r.unbind(i,at);lt(this)||r.removeData(o)}}}var o="virtualMouseBindings",w="virtualTouchID",b="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),tt="clientX clientY pageX pageY screenX screenY".split(" "),vt=n.event.mouseHooks?n.event.mouseHooks.props:[],yt=n.event.props.concat(vt),u={},h=0,it=0,rt=0,f=!1,v=[],k=!1,c=!1,d="addEventListener"in i,y=n(i),pt=1,s=0,g,l;for(n.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500},l=0;l<b.length;l++)n.event.special[b[l]]=ni(b[l]);d&&i.addEventListener("click",function(t){var f=v.length,e=t.target,o,s,i,r,u,h;if(f)for(o=t.clientX,s=t.clientY,g=n.vmouse.clickDistanceThreshold,i=e;i;){for(r=0;r<f;r++)if(u=v[r],h=0,i===e&&Math.abs(u.x-o)<g&&Math.abs(u.y-s)<g||n.data(i,w)===u.touchID){t.preventDefault();t.stopPropagation();return}i=i.parentNode}},!0)})(n,t,i),function(n){n.mobile={}}(n),function(n){var t={touch:"ontouchend"in i};n.mobile.support=n.mobile.support||{};n.extend(n.support,t);n.extend(n.mobile.support,t)}(n),function(n,t,r){function f(t,i,u,f){var e=u.type;u.type=i;f?n.event.trigger(u,r,t):n.event.dispatch.call(t,u);u.type=e}var u=n(i),e=n.mobile.support.touch,s="touchmove scroll",h=e?"touchstart":"mousedown",c=e?"touchend":"mouseup",o=e?"touchmove":"mousemove";n.each("touchstart touchmove touchend tap taphold swipe swipeleft swiperight scrollstart scrollstop".split(" "),function(t,i){n.fn[i]=function(n){return n?this.bind(i,n):this.trigger(i)}});n.event.special.scrollstart={enabled:!0,setup:function(){function u(n,r){t=r;f(i,t?"scrollstart":"scrollstop",n)}var i=this,e=n(i),t,r;e.bind(s,function(i){n.event.special.scrollstart.enabled&&(t||u(i,!0),clearTimeout(r),r=setTimeout(function(){u(i,!1)},50))})},teardown:function(){n(this).unbind(s)}};n.event.special.tap={tapholdThreshold:750,emitTapOnTaphold:!0,setup:function(){var i=this,r=n(i),t=!1;r.bind("vmousedown",function(e){function o(){clearTimeout(c)}function s(){o();r.unbind("vclick",l).unbind("vmouseup",o);u.unbind("vmousecancel",s)}function l(n){s();t||h!==n.target?t&&n.preventDefault():f(i,"tap",n)}if(t=!1,e.which&&e.which!==1)return!1;var h=e.target,c;r.bind("vmouseup",o).bind("vclick",l);u.bind("vmousecancel",s);c=setTimeout(function(){n.event.special.tap.emitTapOnTaphold||(t=!0);f(i,"taphold",n.Event("taphold",{target:h}))},n.event.special.tap.tapholdThreshold)})},teardown:function(){n(this).unbind("vmousedown").unbind("vclick").unbind("vmouseup");u.unbind("vmousecancel")}};n.event.special.swipe={scrollSupressionThreshold:30,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:30,getLocation:function(n){var u=t.pageXOffset,f=t.pageYOffset,i=n.clientX,r=n.clientY;return n.pageY===0&&Math.floor(r)>Math.floor(n.pageY)||n.pageX===0&&Math.floor(i)>Math.floor(n.pageX)?(i=i-u,r=r-f):(r<n.pageY-f||i<n.pageX-u)&&(i=n.pageX-u,r=n.pageY-f),{x:i,y:r}},start:function(t){var r=t.originalEvent.touches?t.originalEvent.touches[0]:t,i=n.event.special.swipe.getLocation(r);return{time:(new Date).getTime(),coords:[i.x,i.y],origin:n(t.target)}},stop:function(t){var r=t.originalEvent.touches?t.originalEvent.touches[0]:t,i=n.event.special.swipe.getLocation(r);return{time:(new Date).getTime(),coords:[i.x,i.y]}},handleSwipe:function(t,i,r,u){if(i.time-t.time<n.event.special.swipe.durationThreshold&&Math.abs(t.coords[0]-i.coords[0])>n.event.special.swipe.horizontalDistanceThreshold&&Math.abs(t.coords[1]-i.coords[1])<n.event.special.swipe.verticalDistanceThreshold){var e=t.coords[0]>i.coords[0]?"swipeleft":"swiperight";return f(r,"swipe",n.Event("swipe",{target:u,swipestart:t,swipestop:i}),!0),f(r,e,n.Event(e,{target:u,swipestart:t,swipestop:i}),!0),!0}return!1},eventInProgress:!1,setup:function(){var i,r=this,f=n(r),t={};i=n.data(this,"mobile-events");i||(i={length:0},n.data(this,"mobile-events",i));i.length++;i.swipe=t;t.start=function(i){if(!n.event.special.swipe.eventInProgress){n.event.special.swipe.eventInProgress=!0;var e,s=n.event.special.swipe.start(i),h=i.target,f=!1;t.move=function(t){s&&!t.isDefaultPrevented()&&(e=n.event.special.swipe.stop(t),f||(f=n.event.special.swipe.handleSwipe(s,e,r,h),f&&(n.event.special.swipe.eventInProgress=!1)),Math.abs(s.coords[0]-e.coords[0])>n.event.special.swipe.scrollSupressionThreshold&&t.preventDefault())};t.stop=function(){f=!0;n.event.special.swipe.eventInProgress=!1;u.off(o,t.move);t.move=null};u.on(o,t.move).one(c,t.stop)}};f.on(h,t.start)},teardown:function(){var i,t;i=n.data(this,"mobile-events");i&&(t=i.swipe,delete i.swipe,i.length--,i.length===0&&n.removeData(this,"mobile-events"));t&&(t.start&&n(this).off(h,t.start),t.move&&u.off(o,t.move),t.stop&&u.off(c,t.stop))}};n.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe.left",swiperight:"swipe.right"},function(t,i){n.event.special[t]={setup:function(){n(this).bind(i,n.noop)},teardown:function(){n(this).unbind(i)}}})}(n,this)}),function(){"use strict";function n(n){n.bind(clickEvent,function(n){n.preventDefault();$(this).next(".Responsive_ExpandableContainer").length?$(this).toggleClass("isActiveButton").next(".Responsive_ExpandableContainer").slideToggle():$(this).children(".Responsive_ExpandableContainer").length?$(this).toggleClass("isActiveButton").children(".Responsive_ExpandableContainer").slideToggle():console.error("Responsive_ExpandableContainer could not be found--must be sibling or immediate child")})}function t(n){n.unbind(clickEvent);n.each(function(){$(this).next(".Responsive_ExpandableContainer").length?$(this).removeClass("isActiveButton").next(".Responsive_ExpandableContainer").attr("style","").slideDown():$(this).children(".Responsive_ExpandableContainer").length&&$(this).removeClass("isActiveButton").children(".Responsive_ExpandableContainer").attr("style","").slideDown()})}enquire.register("only screen and (max-width: 47.9375em)",{match:function(){n($(".Responsive_Button"))},unmatch:function(){t($(".Responsive_Button"))}})}(),function(n){function i(t){var s=this,u,f,e,h,c,l,i,r,o,a,v;t.click(function(n){f&&toggleZoom(n)});t.hover(function(){h=!0});n.extend(s,{load:function(n){return u=n,endZoom(),s}});toggleZoom=function(n){return e?endZoom():startZoom(n)};startZoom=function(n){t.html("");t.css({background:"url('"+u+"') no-repeat",cursor:"url('https://images.furnituredealer.net/img/commonimages/imagezoom/zoomout.cur'), pointer"});moveBackground(n,!0);l=window.setInterval(function(){c=!0},10);t.mousemove(function(n){c&&moveBackground(n)});e=!0};endZoom=function(){function o(){n("#LoadingImage").css({display:"block",position:"absolute",top:t.height()/2-n("#LoadingImage").height()/2,left:t.width()/2-n("#LoadingImage").width()/2})}function s(){i=n("#ImageZoom_UnZoomed").width();r=n("#ImageZoom_UnZoomed").height();var u,e;i>t.width()||r>t.height()?(t.width()/i<=t.height()/r?(u=t.width(),e=t.width()/i*r):(e=t.height(),u=t.height()/r*i),t.css("cursor","url('https://images.furnituredealer.net/img/commonimages/imagezoom/zoomin.cur'), pointer"),f=!0):(u=i,e=r,t.css("cursor","default"),f=!1);n("#LoadingImage").css("display","none");n("#ImageZoom_UnZoomed").css({width:u,height:e,display:"block",position:"absolute",background:"#fff",top:t.height()/2-e/2,left:t.width()/2-u/2})}t.css({background:"#fff",position:"relative"});t.html('<img id="LoadingImage" style="display:none;"><img id="ImageZoom_UnZoomed" style="display:none;" alt="zoomed image">');n("#LoadingImage").attr("src","https://images.furnituredealer.net/img/commonimages/imagezoom/ajax-loader.gif").ready(function(){o()});n("#ImageZoom_UnZoomed").attr("src",u).load(function(){s()});t.unbind("mousemove");clearInterval(l);e=!1};moveBackground=function(n){h?(o=t.offset(),a=100*(n.pageX-o.left)/t.width(),v=100*(n.pageY-o.top)/t.height(),newPos=parseInt(a)+"% "+parseInt(v)+"%"):newPos="0 0";t.css("background-position",newPos)}}n.imagezoom={conf:{target:null,api:!0}};var t=[];n.fn.imagezoom=function(r){var u=this.eq(typeof r=="number"?r:0).data("imagezoom"),f;return u?u:(f=n.extend({},n.imagezoom.conf),r=n.extend(!0,f,r),this.each(function(){u=new i(n(this),r);t.push(u);n(this).data("imagezoom",u)}),r.api?u:this)}}(jQuery);$(function(){function h(s,h){var l=r!=e(s),c={suggestions:[]},a;(l||s.length!==1||isNaN(s.charAt(0)))&&(!l&&n!==""&&n.length<s.length&&s.indexOf(n)!==-1?(a=u(t,s),c.suggestions=f(a).slice(0,i),h(c)):(r=e(s),$.ajax({method:"POST",url:o,dataType:"json",contentType:"application/json; charset=utf-8",data:JSON.stringify({query:s,dealerId:CurrentDealer.Id}),success:function(r){n=s;t=r.d;c.suggestions=f(u(t,s)).slice(0,i);h(c)},error:function(n){console.log(n.responseText)}})))}function u(n,i){var r=[];return $.each(t,function(n,t){var f=t.name,u=t.items.filter(function(n){return n.kw.toLowerCase().indexOf(i.toLowerCase())!==-1});u=u.sort(function(n,t){var r=n.kw.indexOf(i),u=t.kw.indexOf(i);return r===0&&u!=0?-1:r!==0&&u===0?1:n.c===t.c?n.kw.length<t.kw.length?-1:n.kw.length>t.kw.length?1:0:n.c>t.c?-1:n.c<t.c?1:0});u=u.filter(function(n,t){return t<s});r=r.concat({name:f,items:u})}),r}function f(n){var t=[];return $.each(n,function(n,i){i.items.length>0&&(t=t.concat(i.items.map(function(n){return{v:n.kw,data:{g:i.name}}})))}),t}function e(n){return n.length>1?n.split("").some(function(n){return!isNaN(n)}):!1}function c(n){var t=n.replace(/\./g,"_pp_").replace(/\//g,"_sl_").replace(/#/g,"_h_").replace(/\+/g,"_pl_").replace(/\?/g,"_q_").replace(/&/g,"_and_").replace(/®/g,"_r_").replace(/:/g,"_c_").replace(/%/g,"_pc_").replace(/\*/g,"_a_"),i=Utils.BaseURL+"search/keyword/"+t.trim()+"?kwd="+encodeURIComponent(n);window.location.href=i}var o=Utils.BaseURL+"AjaxItemService.asmx/GetAutoCompleteKeywords",i=10,s=5,n="",r=!1,t=[],l=window.innerWidth<880?"97.2%":"300px";$(".js-search-auto-complete").each(function(){$(this).autocomplete({lookup:h,deferRequestBy:100,groupBy:"g",orientation:"auto",triggerSelectOnValidInput:!1,onSelect:function(){$(this).siblings(".search-submit-btn").trigger("click")},containerClass:$(this).parent().data("autocompletecontainerclass")})});$(".js-search-auto-complete").on("keypress",function(n){if(n.which==13)return $(this).closest(".keyword-search").find(".search-submit-btn").trigger("click"),!1});$(".search-submit-btn").on("click",function(){var n=$(this).closest(".keyword-search").find('[type="search"]').val();n.trim().length>0&&c(n)})});Math.trunc||(Math.trunc=function(n){return(n=+n,!isFinite(n))?n:n-n%1||(n<0?-0:n===0?n:0)});$.fn.scrollTo=function(n,t,i){typeof t=="function"&&arguments.length===2&&(i=t,t=n);var r=$.extend({scrollTarget:n,offsetTop:50,duration:500,easing:"swing"},t);return this.each(function(){var t=$(this),n=typeof r.scrollTarget=="number"?r.scrollTarget:$(r.scrollTarget),u=typeof n=="number"?n:n.offset().top-parseInt(r.offsetTop);t.animate({scrollTop:u},parseInt(r.duration),r.easing,function(){typeof i=="function"&&i.call(this)})})};$(window).on("load",function(){$(".recently-viewed .swiper-wrapper .content-slider:first-child img").each(function(){$(this).get(0).src.indexOf("data:image/png;base64")==-1&&RecentlyViewedSlider($(this))});$(".recently-viewed .swiper-wrapper .content-slider:first-child img").on("load",function(){RecentlyViewedSlider($(this))})});(function(n,t){n.RegisterToken=function(n,i,r){dataObj={};dataObj.username=n.Email;dataObj.password=n.Password;dataObj.dealerid=CurrentDealer.Id;reqData=JSON.stringify(dataObj);var u=Utils.IsDev?"http://helpfurniture.com/ws1/customersv1.svc/GetRegistrationToken/":"https://api.furnituredealer.net/CustomersV1.svc/GetRegistrationToken/";t.ajax({url:u+CurrentDealer.Id,type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:reqData,success:function(t){t.status==1?i&&i(n,t.token):r&&r(t.status)},error:function(n){console.log(n.responseText);r("There was an error creating your account.")}})};n.SimpleRegister=function(n,i){var r=JSON.stringify(n);t.ajax({url:Utils.BaseURL+"Registration/SimpleRegisterSubmit",type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:r,success:function(n){console.log(n);n.status===1?(TrackEvent("Signup","Simple","",!0),i?i():window.location=n.redirectUrl):(FormButtonSpinnerRemove(t("#SimpleRegisterSubmit")),t("#statusmessage").html(n.message))},error:function(n){console.log(n.responseText);FormButtonSpinnerRemove()}})};n.EmailOnlyRegister=function(n,i){var r=JSON.stringify(n);t.ajax({url:Utils.BaseURL+"Registration/EmailOnlyRegisterSubmit",type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:r,success:function(n){console.log(n);n.status===1?(TrackEvent("Signup","Email Only","",!0),i?i():window.location=n.redirectUrl):(FormButtonSpinnerRemove(t("#EmailOnlyRegisterSubmit")),setRegStatusMessage(n.message))},error:function(n){console.log(n.responseText)}})}})(window.registration=window.registration||{},jQuery);typeof CurrentDealer.GoogleAuthClientId!="undefined"&&CurrentDealer.GoogleAuthClientId.length>1?$.getScript("https://apis.google.com/js/api:client.js",function(){gapi.load("auth2",function(){auth2=gapi.auth2.init({client_id:CurrentDealer.GoogleAuthClientId});window.googleSignInApi.resolve()})}):window.googleSignInApi.reject();typeof CurrentDealer.FacebookAppId!="undefined"&&CurrentDealer.FacebookAppId!==""?$.getScript("https://connect.facebook.net/en_US/sdk.js",function(){FB.init({appId:CurrentDealer.FacebookAppId,version:"v2.9",cookie:!0,xfbml:!0});window.fbLoaded.resolve();FB.Event.subscribe("edge.create",function(){TrackEvent("Social","Facebook Like",window.location.pathname+window.location.search,!0)})}):(window.fbLoaded.reject(),console.log("fbLoaded - reject"));typeof CurrentDealer.FacebookPixelId!="undefined"&&CurrentDealer.FacebookPixelId.length>0?(!function(n,t,i,r,u,f,e){n.fbq||(u=n.fbq=function(){u.callMethod?u.callMethod.apply(u,arguments):u.queue.push(arguments)},n._fbq||(n._fbq=u),u.push=u,u.loaded=!0,u.version="2.0",u.queue=[],f=t.createElement(i),f.async=!0,f.src=r,e=t.getElementsByTagName(i)[0],e.parentNode.insertBefore(f,e))}(window,document,"script","//connect.facebook.net/en_US/fbevents.js"),fbq("init",CurrentDealer.FacebookPixelId),fbq("track","PageView"),window.fbPixel.resolve()):(console.log("fbPixel - reject"),window.fbPixel.reject()),function(){$(".js-add-to-shopping-cart__collection-item").one("click",function(){var n=$(this);AddToShoppingCart($(this).data("gpid"),function(t){n.addClass("added");n.attr("data-tooltip","Item added!");n.find(".RelatedItem__cart-text").text("Added!");$("body").append('<iframe src="'+Utils.BaseURL+'goalcomplete_shoppingcartaddition.aspx" height="1" width="1"><\/iframe>');GaAddToCart(t);TrackItemEvent("Shopping Cart","Add",t.GPID,t)})});$("body").on("click",".js-add-to-shopping-cart",function(){var n=$(this);n.hasClass("added")||(n.data("cart-context")==="browse3-btn"&&n.append('<div class="loading-spinner loading-spinner--sm"><\/div>'),AddToShoppingCart($(this).data("gpid"),function(){var t=n.data("cart-context");t=typeof t=="undefined"?"default":t;n.addClass("added");switch(t){case"browse-btn":n.addClass("btn-green").removeClass("btn-blue").find(".fdnicon-cart").removeClass("fdnicon-cart").addClass("fdnicon-checkmark");n.find(".cart-status-text").text("Item Added!");setTimeout(function(){n.find(".cart-status-text").text("In Cart")},3e3);break;case"browse3-btn":n.html('<i class="material-icons">shopping_cart<\/i>');n.attr("title","Item in Cart");n.prepend('<div class="animated fast slideInUp item__add-to-cart__status">Item Added!<\/div>');setTimeout(function(){n.find(".item__add-to-cart__status").fadeOut().removeClass("slideInUp").addClass("slideOutDown")},2500)}$("body").append('<iframe src="'+Utils.BaseURL+'goalcomplete_shoppingcartaddition.aspx" height="1" width="1"><\/iframe>')}))});$(".AddItemToCartTrigger,.js-add-to-cart").one("click",function(){var n=$(this),t=$(".item-cart-popup-mask");return n.data("context")==="itempage14"&&(n.addClass("__loading"),n.append('<div class="loading-spinner--dots"><div class="bounce1"><\/div><div class="bounce2"><\/div><div class="bounce3"><\/div><\/div>')),AddToShoppingCart(n.data("gpid"),function(i){n.data("context")==="itempage14"?(n.removeClass("__loading").html('<span class="loading-complete--checkmark draw"><\/span> Item Added to Cart'),$(t).appendTo("body").show(),$(".shopping-cart-item__addon").length>0&&$(".item-cart-popup__addons").show(),$(".item-cart-popup.shopping-cart-parent-item").attr("data-cartitemid",i.CartItemId),$(".item-cart-popup__title").focus()):(n.children(".addToCartText").html('<span class="fdnicon-checkmark"><\/span> Item In Cart'),$(t).appendTo("body").show(),$(".shopping-cart-item__addon").length>0&&$(".item-cart-popup__addons").show(),$(".item-cart-popup.shopping-cart-parent-item").attr("data-cartitemid",i.CartItemId),$(".item-cart-popup__title").focus());$("body").append('<iframe src="'+Utils.BaseURL+'goalcomplete_shoppingcartaddition.aspx" height="1" width="1"><\/iframe>')}),!1});$("body").on("click",".shopping-cart-item__addon-btn",function(){var n=$(this),t=jQuery.parseJSON(n.attr("rel"));return t.ParentCartItemId=n.closest(".shopping-cart-parent-item").attr("data-cartitemid"),n.html('<span class="fdn-spinner fdn-spinner--xs" role="status" aria-hidden="true"><\/span>'),$.ajax({type:"POST",url:Utils.BaseURL+"AjaxItemService.asmx/AddItemToCartExtended",data:JSON.stringify(t),contentType:"application/json; charset=utf-8",dataType:"json",success:function(){var item,item2;n.html('<span class="fdnicon-checkmark" style="color:#fff;"><\/span> Added!');window.location.href.indexOf("viewcart.aspx")>-1?UpdateCartItem(t.ParentCartItemId,1):$(".view-cart-v4").length&&(ShoppingCartV4.LoadViewCartItems(),ShoppingCartV4.LoadViewCartTotals());try{item=eval("("+$("#itemData-main").attr("rel")+")");GaAddToCart(item);TrackItemEvent("Shopping Cart","Add",item.GPID,item)}catch(e){console.log(e)}try{item2=eval("("+$("#itemData-main").attr("rel")+")");typeof laurentideTracker!="undefined"&&Laurentide_AddToCart(item2)}catch(e){console.log(e)}},error:function(t){n.html("Add to Cart");alert(t.responseText)}}),!1});$("body").on("click",".item-cart-popup__close--trigger",function(){return $(".item-cart-popup-mask").remove(),!1});$("body").on("mouseenter",".cart-status-container",function(){var n=$(this).data("url");parseInt($(".js-cart-count").text().replace(/\D/g,""),10)>0&&window.location.href.indexOf("viewcart.aspx")===-1&&Modernizr.mq("only screen and (min-width: 67.500em)")&&($(".cart-status-popup__items").children().length===0&&$.ajax({url:n,type:"GET",contentType:!1,processData:!1,success:function(n){$(".cart-status-popup").html(n)},error:function(){}}),$(this).addClass("__active"))});$("body").on("mouseleave",".cart-status-container, .cart-status-container-v4",function(){$(this).removeClass("__active")});$("body").on("mouseenter",".cart-status-container-v4",function(){var n=$(this);if(parseInt($(".js-cart-count").text().replace(/\D/g,""),10)>0&&window.location.href.toLowerCase().indexOf("shoppingcart")===-1&&Modernizr.mq("only screen and (min-width: 67.500em)")){if($(".cart-status-popup__items-v4").children().length===0)return $.ajax({type:"GET",url:Utils.BaseURL+"ShoppingCart/ShoppingCart/CartStatusPopupV4",cache:!1}).then(function(t){$(".cart-status-popup-v4").html(t);$(n).addClass("__active")});$(n).addClass("__active")}});$(".tooltip-trigger").tooltip({position:"bottom center",relative:!0,tip:".tooltip-text"});$(".OverlayTrigger").overlay({color:"#ccc",start:{top:300},expose:{color:"#333",opacity:.7,closeSpeed:300}});var n="";$(".AjaxItemPreviewTrigger").length&&!$("#ItemPreviewContentPlaceHolder").length&&($(".SectionMenu").append('<div id="AjaxItemPreviewOverlay"><div id="ItemPreviewContentPlaceHolder"><\/div><a class="close" aria-label="Click to close this pop-up"><\/a><\/div>'),n=$("#AjaxItemPreviewOverlay").overlay({top:"center",api:!0,absolute:!0,expose:{color:"#5b5b5b",loadSpeed:1,opacity:.7}}));$(".AjaxItemPreviewTrigger").on("click",function(){var self=$(this),itemData=eval("("+$(this).attr("rel")+")"),data=self.data("preview"),requestUrl,gpid=typeof data!="undefined"?data.GPID:itemData.GPID;requestUrl=gpid?Utils.BaseURL+"AjaxItemService.asmx/GetItemPreviewHtmlFromGPID":Utils.BaseURL+"AjaxItemService.asmx/GetItemPreviewHtmlFromNum";n.load();$.ajax({type:"POST",url:requestUrl,data:$(this).attr("rel"),contentType:"application/json; charset=utf-8",dataType:"json",success:function(n){$("#ItemPreviewContentPlaceHolder").html(n.d)},error:function(n){alert(n.responseText)}})});$("body").on("input",".zipcodeLookupInput",function(){var n=$(".zipcodeLookupInput").val();console.log(n);$(".delivery-lookup__submit").prop("disabled",n.length<3)});$("body").on("keypress",".delivery-lookup__input input",function(n){n.keyCode===13&&$(".delivery-lookup__submit").click()});$("body").on("click",".delivery-lookup__submit",function(){$(this).html('<span class="fdn-spinner fdn-spinner--xs" role="status" aria-hidden="true"><\/span>');var n=$(this).siblings("#ZipCode").val(),t=$(this).data("gpid");return $.ajax({type:"POST",url:Utils.BaseURL+"ShoppingCart/Delivery/ZipCodeLookup",contentType:"application/json; charset=utf-8",data:JSON.stringify({zipCode:n,gpid:t})}).then(function(n){$(".delivery-lookup").replaceWith(n)})});$("body").on("click",".delivery-lookup__change-zip",function(){$(".delivery-lookup__input").addClass("__active")})}(),function(){"use strict";function t(){$(".hlv3-mobile-search.hlv3-search-trigger--active").trigger("vclick")}function i(){$(".hlv3-mobile-locations__btn.hlv3-locations-trigger--active").trigger("vclick")}function r(){$(".hlv3-nav-btns__btn--close.hlv3-trigger--active").trigger("vclick")}function n(){var n=$(".hlv3-primary-container").height();$(".hlv3-nav-overlay").css("top",n).show();$(".hlv3-primary-nav-container").css("top",n)}$(".hlv3-nav-btns__btn--open").on("vclick",function(){t();i()});$(".hlv3-mobile-search").on("vclick",function(){$(".hlv3-mobile-search").hasClass("hlv3-search-trigger--active")?$(".hlv3-search__text-box").blur():(r(),i(),$(".hlv3-search__text-box").focus())});$(".hlv3-mobile-locations__btn").on("vclick",function(){$(".hlv3-mobile-locations__btn").hasClass("hlv3-locations-trigger--active")||(r(),t())});$(".hlv3-nav-btns__btn--close, .hlv3-nav-overlay").on("vclick",function(n){n.preventDefault();$(".hlv3-primary-nav .nav-builder-trigger--active").removeClass("nav-builder-trigger--active")});$(".hlv3-nav-btns__btn--open").fdnToggle({triggers:".hlv3-nav-btns__btn--close",targets:"body",persist:!0,className:"hlv3",relatives:".hlv3-primary-nav-container"});$(".hlv3-mobile-search").fdnToggle({targets:".hlv3-search-container",className:"hlv3-search",closeOnClick:!1});$(".hlv3-mobile-locations__btn").fdnToggle({targets:"body",className:"hlv3-locations",relatives:".hlv3-locations__wrapper"});var s=$(".hlv3-container"),o=$(".hlv3-static-nav"),u=$(".hlv3-search-container"),f=$(".hlv3-locations__wrapper"),h=$(".SectionOuter"),e=$(".nav-builder-single-level.hlv3-secondary-nav__item");n();Utils.IsResponsivePage&&enquire.register("only screen and (max-width: 55em)",{match:function(){u.insertAfter(".hlv3-main__left");f.insertAfter(".hlv3-mobile-locations__btn");$(".SectionMenu").removeClass("x-header");n();$(".SectionMenu").css("margin-top",$(".hlv3-container").height());e.insertAfter(".hlv3-primary-nav .nav-builder-sub-menu .nav-builder-1:last-child");$(".hlv3-mobile-search").hasClass("hlv3-mobile-search__open")&&$(".hlv3-mobile-search").trigger("vclick")},unmatch:function(){u.insertBefore(o);f.insertAfter(".hlv3-secondary-nav__item.hlv3-locations > a");$(".SectionMenu").addClass("x-header");n();$(".SectionMenu").css("margin-top","auto");e.insertBefore(".hlv3-secondary-nav__item.hlv3-locations")}});enquire.register("only screen and (min-width: 55em)",{match:function(){$(".hlv3-primary-nav > .nav-builder-0 > .nav-builder-trigger").on("click",function(n){n.preventDefault();$("body").hasClass("hlv3-primary-nav__active")?$("body").removeClass("hlv3-primary-nav__active"):$("body").addClass("hlv3-primary-nav__active")})}});enquire.register("only screen and (min-width: 55em)",{match:function(){$(".hlv3-nav-overlay").on("click",function(){$("body").removeClass("hlv3-primary-nav__active")})}});Utils.IsResponsivePage&&enquire.register("only screen and (max-width: 55em)",{match:function(){$(".hlv3-primary-nav .nav-builder-trigger").on("click",function(n){n.preventDefault();$(this).hasClass("nav-builder-trigger--active")?$(this).removeClass("nav-builder-trigger--active"):$(this).addClass("nav-builder-trigger--active")})},unmatch:function(){$(".hlv3-primary-nav .nav-builder-trigger").off()}});Utils.IsResponsivePage&&enquire.register("only screen and (max-width: 55em)",{match:function(){var n;$(window).scroll(function(){if(!($("body.hlv3-target--active").length||$("body.hlv3-locations-target--active").length)){var t=$(this).scrollTop(),i=$(".hlv3-container").height();t>i&&t>n?$(".hlv3-container.__scroll").length||$(".hlv3-container").addClass("__scroll"):t+$(window).height()<$(document).height()-100&&$(".hlv3-container.__scroll").length&&$(".hlv3-container").removeClass("__scroll");n=t}})}})}(),function(){"use strict";if(Utils.IsResponsivePage){$(".flv3-nav__links .nav-builder-trigger").on("click",function(){if(Modernizr.mq("only screen and (max-width: 48em)")){var n=!1;$(this).hasClass("_active")&&(n=!0);$(".nav-builder-trigger._active").siblings(".nav-builder-sub-menu").slideUp();$(".nav-builder-trigger._active").removeClass("_active");n||($(this).addClass("_active"),$(this).siblings(".nav-builder-sub-menu").slideDown())}});enquire.register("only screen and (max-width: 48em)",{unmatch:function(){$(".flv3-nav__links .nav-builder-sub-menu").removeClass("_active").attr("style","")}});$(window).load(function(){var n=new Swiper(".flv3-store-locations #storeList",{calculateHeight:!0,updateOnImagesReady:!0,scrollbar:{el:".swiper-scrollbar",hide:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},freeMode:!0,slidesPerView:5,spaceBetween:10,centerInsufficientSlides:!0,watchOverflow:!0,breakpoints:{1024:{slidesPerView:4,spaceBetween:40},768:{slidesPerView:3.25,spaceBetween:30},465:{slidesPerView:2.25,spaceBetween:10}}})})}}();QuickListV2=function(){function l(){$("body").addClass("ql__open");$.cookie("ql-open","1",{expires:365,path:"/"});Modernizr.mq("(max-width: 30em)")&&$("body").addClass("ql__no-scroll")}function f(){$("body").removeClass("ql__open");u();Modernizr.mq("(max-width: 30em)")&&$("body").removeClass("ql__no-scroll");$.removeCookie("ql-open",{expires:365,path:"/"})}function w(){window.location.pathname.indexOf("Login.aspx")==-1&&$(n).addClass("__auth")}function b(n){$(".quicklist-unauthenticated").hasClass("__active")?($(".quicklist-unauthenticated").removeClass("__active"),$(n).html("expand for more options"),u()):($(".quicklist-unauthenticated").addClass("__active"),$(n).html("hide options"))}function k(t){if($(t).hasClass("__active"))u();else{var i="QuickListV2.AuthCallback";$(".quicklist-abalt").length&&(i="QuickListV2.AuthRequiredCallback");$(n).removeClass("__new");$(".quicklist-unauthenticated__btns a.__active").removeClass("__active");$(t).addClass("__active");$(".quicklist-unauthenticated").append(r);$.ajax({type:"GET",url:Utils.BaseURL+"Authentication/Login?jscb="+i,cache:!1,success:function(n){$(".quicklist__loading").remove();$(".quicklist-unauthenticated").addClass("__active");$(".quicklist-form").html(n)},error:function(){}})}}function d(n){if($(n).hasClass("__active"))u();else{var t="QuickListV2.AuthCallback";$(".quicklist-abalt").length&&(t="QuickListV2.AuthRequiredCallback");$(".quicklist-unauthenticated__btns a.__active").removeClass("__active");$(n).addClass("__active");$(".quicklist-unauthenticated").append(r);$.ajax({type:"GET",url:Utils.BaseURL+"Registration/SimpleRegister?jscb="+t,cache:!1,success:function(n){$(".quicklist__loading").remove();$(".quicklist-unauthenticated").addClass("__active");$(".quicklist-form").html(n)},error:function(){}})}}function u(){$(".quicklist-unauthenticated").removeClass("__active");$(".quicklist-form").html("");$(".quicklist-unauthenticated__btns a.__active").removeClass("__active")}function e(t){$(n).append(r);o();$(n).addClass("__loaded");t&&t()}function o(t){var i="";i=t!=undefined?Utils.BaseURL+"Quicklist/QuickListPanel/"+t:Utils.BaseURL+"Quicklist/QuickListPanel";$.ajax({type:"GET",url:i,cache:!1,success:function(i){$(".quicklist__loading").remove();$(".quicklist").html(i);$(".quicklist-manage").length==0&&$(n).addClass("__new __no-list");a(t)},error:function(){}})}function a(n){var t="";t=n!=undefined?Utils.BaseURL+"Quicklist/QuickListItems/"+n:Utils.BaseURL+"Quicklist/QuickListItems";$.ajax({type:"GET",url:t,cache:!1,success:function(n){$(".quicklist-items").html(n);var t;if($(".quicklist-sticky").hasClass("quicklist-sticky-v2")){t='<span class="quicklist-count">'+$(".quicklist-item-count").data("item-count")+"<\/span>";$(".quicklist-sticky").html(t);$(".js-toggle-ql-item--v2").length&&$(".quicklist-sticky.quicklist-sticky-v2").show();$(".quicklist-sticky.quicklist-sticky-v2").addClass("animated bounceIn");$(".quicklist-sticky.quicklist-sticky-v2").on("animationend",function(){$(this).removeClass("animated bounceIn")})}else t='<span class="quicklist-count animated bounceIn">'+$(".quicklist-item-count").data("item-count")+"<\/span>",$(".quicklist-sticky").html(t);$(".quicklist-header__icon").html(t);$.cookie("ql-count",t,{expires:365,path:"/"});$(".quicklist-items .quicklist-item").on("swipeleft",function(){$(this).addClass("__open")});$(".quicklist-items .quicklist-item").on("swiperight",function(){$(this).removeClass("__open")})},error:function(){}})}function v(n,t){$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/RemoveItem",contentType:"application/json; charset=utf-8",data:JSON.stringify({QuickListItemId:n.data("qlitemid")}),success:function(){t&&t(n);TrackQuicklist("Remove","QuickList Delete",{GPID:n.data("qlitemid")})},error:function(){h("Item failed to delete")}})}function g(n){a($(n).parent().data("qlid"))}function nt(n){quickListId=$(n).closest(".quicklist-view__index").data("quicklistid");$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/QuickListItemsLayout?QuickListId="+quickListId,cache:!1,success:function(n){$(".quicklist-view__items").html(n);$(".quicklist-item-layout img.lz-ld").lazyload({effect:"show",threshold:200,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})},error:function(){}})}function y(){var n=$("#quicklist-new__title").val().trim();n.length>0&&tt(n)}function tt(t){$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/CreateNewQuicklist",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListName:t,setAsDefault:!0}),success:function(t){var i=JSON.parse(t);i.Status>0&&($(n).removeClass("__new __no-list"),$(".quicklist-items").html(""),$("#quicklist-new__title").val(""),e())},error:function(){console.log("FAILURE")}})}function it(n,t){t==!0?$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/SetPrimaryQuickList",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListId:n}),success:function(n){var t=JSON.parse(n);t.Status>0&&o()},error:function(){$(".quicklist-lists__ddl").val($(".quicklist-lists__ddl").data("current"))}}):o(n)}function rt(n){$(n).hasClass("__open")?$(n).removeClass("__open"):$(n).addClass("__open")}function p(n){var t=confirm("Are you sure that you want to delete this list?");t&&ut(n)}function ut(n){$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/ArchiveQuicklist",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListId:n.data("quicklistid")}),success:function(){window.location.href=Utils.BaseURL+"quicklist/list"},error:function(n){console.log(n)}})}function ft(n,t,i){$(window).width()>991&&$(n).sortable({helper:"clone",appendTo:"body",placeholder:t,start:function(n,t){t.item.startPos=t.item.index()},stop:function(n,t){var f=t.item.startPos,r=t.item.index(),u;f!=r&&(u=t.item.data("qlitemid"),s(u,r),i&&i())}})}function et(){var n=1;$(".quicklist-browse__count").each(function(){$(this).html(n+".");n++})}function ot(n){var t=$(n).closest(".quicklist-item-layout").data("gpid");$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/AddQuickListItemToCart",contentType:"application/json; charset=utf-8",data:JSON.stringify({GPID:t}),success:function(t){var i=JSON.parse(t);$(n).html('<div class="item__add-to-cart"><span class="addToCartText" title="Item in Cart" ><span class="fdnicon-checkmark"><\/span><\/span><\/div>');$(".js-cart-count").text("("+(parseInt($(".js-cart-count").text().replace(/\D/g,""),10)+1)+")");$("body").append(i.CartPopup);$(".item-cart-popup-mask").show();$(".shopping-cart-item__addon").length>0&&$(".item-cart-popup__addons").show();GaAddToCart(i.CartItem,"addProduct","add");TrackItemEvent("Shopping Cart","Add",i.CartItem.GPID,i.CartItem);typeof laurentideTracker!="undefined"&&Laurentide_AddToCart(i.CartItem)},error:function(){h("Item failed to add to cart")}})}function st(n){$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/AddQuickListToCart",contentType:"application/json; charset=utf-8",data:JSON.stringify({quicklistId:n}),success:function(n){var t=JSON.parse(n),r,u;if(t.Status>0){StatusDialog.show("good",2e3,"Available list items added to cart");r=0;for(i in t.CartItems)GaAddToCart(t.CartItems[i],"addProduct","add"),TrackItemEvent("Shopping Cart","Add",t.CartItems[i].GPID,t.CartItems[i]),typeof laurentideTracker!="undefined"&&Laurentide_AddToCart(t.CartItems[i]),u=$(".quicklist-item-layout[data-gpid='"+t.CartItems[i].GPID+"']").find(".quicklist-item-layout__cart"),$(u).html('<div class="item__add-to-cart"><span class="addToCartText" title="Item in Cart" ><span class="fdnicon-checkmark"><\/span><\/span><\/div>'),r++;$(".js-cart-count").text("("+(parseInt($(".js-cart-count").text().replace(/\D/g,""),10)+r)+")")}},error:function(){h("Items failed to add to cart")}})}function at(){TrackEvent("Quicklist","Ql-Reg-Login-Opt","",!0);location.reload()}function vt(){TrackEvent("Quicklist","Ql-Reg-Login-Req","",!0);CurrentUser.IsAuthenticated=!0;$(n).removeClass("__auth");t($(".quicklist-abalt").data("pendinggpid"));$(".quicklist-abalt").remove()}function h(n){var t=$(".quicklist-error");$(t).html(n).addClass("__show");setTimeout(function(){$(t).removeClass("__show")},2e3)}var n,r,c,t,s;templates={ql:"",qlItem:""};data={quicklists:""};n=$(".quicklist");r='<div class="quicklist__loading"><span class="fdn-spinner fdn-spinner--lg"><\/span><\/div>';$(".quicklist--trigger").on("click",function(){t()});$("body").on("click",".quicklist-close",function(){f()});$("body").on("click",".quicklist-lists__add",function(){$(n).addClass("__new")});$("body").on("click",".quicklist-new__cancel",function(){$(n).removeClass("__new")});$("body").on("click",".quicklist-unauthenticated__btns--trigger",function(){b(this)});$("body").on("click",".quicklist-item__more",function(){rt($(this).parent())});$("body").on("click",".quicklist-item__delete",function(){v($(this).parent(),QuickListV2.QuicklistPanelDeleteItemCallback)});$("body").on("click",".quicklist-item-layout__delete",function(){v($(this).closest(".quicklist-item-layout"),QuickListV2.LoadQuicklistIndexItems)});$("body").on("click",".quicklist-loginbtn",function(){k(this)});$("body").on("click",".quicklist-registerbtn",function(){d(this)});$("body").on("click",".quicklist-view__list-group__toggle",function(){ht($(this))});$("body").on("click",".quicklist-new__save",function(){y()});$("body").on("keyup","#quicklist-new__title",function(n){n.keyCode==13&&y()});$("body").on("click",".quicklist-manage__active-list",function(){f()});$("body").on("click",".quicklist-manage__all-lists",function(){f()});$("body").on("change",".quicklist-lists__ddl",function(){it(this.value,$(this).find(":selected").data("owner"))});$("body").on("swipe",".quicklist-items .quicklist-item",function(){$(this).addClass("__open")});$("body").on("click",".quicklist-view__delete-btn",function(){p($(this).closest(".quicklist-view__index"))});$("body").on("click",".quicklist-view__list-group__delete",function(){p($(this).closest(".quicklist-view__list-group"))});$("body").on("click",".quicklist-item-layout__cart",function(){ot(this)});$("body").on("click",".quicklist-view__nav-link__cart-btn",function(){st($(".quicklist-view__index").data("quicklistid"))});Modernizr.mq("(max-width: 55em)")&&$(window).scroll(function(){var n=$(this).scrollTop();n>100&&n>c?$(".quicklist-sticky.__bottom").length||($(".quicklist-sticky").addClass("__bottom"),$(".room-planner-v2__sticky").addClass("__bottom")):n+$(window).height()<$(document).height()-100&&$(".quicklist-sticky.__bottom").length&&($(".quicklist-sticky").removeClass("__bottom"),$(".room-planner-v2__sticky").removeClass("__bottom"));c=n});$(window).load(function(){$.cookie("ql-open")!=undefined?t():$.cookie("ql-count")!=undefined&&($(".quicklist-sticky").html($.cookie("ql-count")),$(".js-toggle-ql-item--v2").length&&$(".quicklist-sticky.quicklist-sticky-v2").show())});t=function(){$(n).hasClass("__loaded")?l():e(l);CurrentUser.IsAuthenticated||w()};s=function(n,t){var i={quickListItemId:n,newOrder:t},r=JSON.stringify(i);$.ajax({url:Utils.BaseURL+"Quicklist/UpdateQuickListItemOrder",type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:r,success:function(){},error:function(n){console.log(n)}})};var ht=function(n){var t=$(n).closest(".quicklist-view__list-group");console.log(t);$(t).hasClass("__active")?lt(t):ct(t)},ct=function(n){var t,i;console.log("showdetails");t=n;t.addClass("__active");i=t.attr("id");$.cookie(i,!1)},lt=function(n){var t,i;console.log("hideDetails");t=n;t.removeClass("__active");i=t.attr("id");$.cookie(i,!0)};return{init:t,AuthCallback:at,AuthRequiredCallback:vt,LoadData:e,QuicklistPanelDeleteItemCallback:g,LoadQuicklistIndexItems:nt,InitReorderListItem:ft,UpdateReorderListItemCount:et,ReorderListItem:s}}();"use strict";var AddToListWidget=function(){var t={gpid:""},n=1,u=Modernizr.mq("only screen and (max-width: 47.938em)")?!0:!1,l='<div class="quicklist__loading"><span class="fdn-spinner fdn-spinner--lg"><\/span><\/div>',f='<div class="loading-spinner loading-spinner--sm"><\/div>',e='<div class="loading-spinner--dots"><div class="bounce1"><\/div><div class="bounce2"><\/div><div class="bounce3"><\/div><\/div>',a=function(){$("body").on("click","#add-to-list-overlay",function(){i()});$("body").on("click",".quicklist-view__add-to-list__close",function(){i()});$("body").on("click",".quicklist-view__add-to-list__list-items",function(){s($(this))});$("body").on("click",".quicklist-view__add-to-list__create-new",function(){c()});$("#add-to-list-widget").on("click",".quicklist-view__add-to-list__save-btn",function(){r($(this))});$("#add-to-list-widget").on("keyup","#quicklist-view__add-to-list__new-title",function(n){n.keyCode==13?r($(this)):$("#quicklist-new_message").remove()});$("body").on("click",".quicklist-view__add-to-list--v2__close",function(){i()});$("body").on("click",".quicklist-view__add-to-list--v2__list-item",function(){s($(this))});$("body").on("click",".quicklist-view__add-to-list--v2__create-new",function(){c()});$("#add-to-list-widget").on("click",".quicklist-view__add-to-list--v2__create-new__input-btn",function(){r($(this))});$("#add-to-list-widget").on("keyup",".quicklist-view__add-to-list--v2__create-new__input-text",function(n){n.keyCode==13?r($(this)):$("#quicklist-new_message").remove()});$("body").on("click",".js-toggle-ql-item",function(){$(this).hasClass("js-toggle-ql-item--v2")&&(n=2);o($(this))})},o=function(i){var e=i.data("gpid"),f,r;t.gpid=e;f=n==2?"Quicklist/AddToListWidgetV2":"Quicklist/AddToListWidget";r="animated fast";r+=u?" slideInUp":" fadeIn";$("#add-to-list-widget").attr("class",r).append(l);$("body").append('<div id="add-to-list-overlay" class="animated fadeIn"><\/div>');$.ajax({type:"GET",url:Utils.BaseURL+f,cache:!1,success:function(n){$(".quicklist__loading").remove();$("#add-to-list-widget").html(n);v(i)},error:function(){}})},v=function(n){if($("#add-to-list-widget").addClass("__open"),$(n).closest(".ResultsLarge_Object").addClass("add-to-list__hover"),$(n).closest(".quicklist-item-layout").addClass("add-to-list__hover"),$(window).width()>767){var t=$(n);$(n).closest(".dropdown").length>0&&(t=$(n).closest(".dropdown"));$("#add-to-list-widget").position({my:"center bottom-12",at:"center top",of:t,collision:"flipfit"})}else $("#add-to-list-widget").addClass("__mobile");$(".quicklist-view__add-to-list__create-new").focus()},i=function(n){u?$("#add-to-list-widget").removeClass("slideInUp").addClass("slideOutDown"):$("#add-to-list-widget").removeClass("fadeIn").addClass("fadeOut");$("#add-to-list-overlay").addClass("fadeOut");$(".add-to-list__hover").removeClass("add-to-list__hover");setTimeout(function(){y(n)},500)},y=function(n){$("#add-to-list-widget").removeClass("__open fadeOut slideOutDown");$(".quicklist-view__add-to-list").remove();$("#add-to-list-overlay").remove();n&&n()},s=function(r){n==2?$(r).append(e):$(r).append(f);$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/AddItem",contentType:"application/json; charset=utf-8",data:JSON.stringify({GPID:t.gpid,listId:r.data("listid")}),success:function(u){var e,f,o,s;$(".loading-spinner").remove();$(".loading-spinner--dots").remove();e=$(".quicklist-view__add-to-list__list-items[data-listid="+r.data("listid")+"]");n==2&&(e=$(".quicklist-view__add-to-list--v2__list-item[data-listid="+r.data("listid")+"]"));f=JSON.parse(u);f.Status==0?(h(f.Message,e),setTimeout(function(){i(QuickListV2.LoadData)},500),typeof laurentideTracker!="undefined"&&Laurentide_AddToList(f.QuickListItem,f.QuickListItemCount),o=$('.js-toggle-ql-item[data-gpid="'+t.gpid+'"]'),s=o.data("ga-method"),TrackQuicklist("Add",s,f.QuickListItem),n==1&&$(".quicklist--trigger").click()):h(f.Message,e)},error:function(){console.log("FAILURE")}})},h=function(n,t){$("#quicklist_message").length>0&&$("#quicklist_message").remove();$(t).append('<div id="quicklist_message" aria-live="polite"><\/div>');$("#quicklist_message").html(n);$(".quicklist-view__add-to-list__main").scrollTop($(".quicklist-view__add-to-list__main").scrollTop()+$("#quicklist_message").position().top-50)},c=function(){n==2?($(".quicklist-view__add-to-list--v2__lists").addClass("__create"),$(".quicklist-view__add-to-list--v2__create-new__input-text").focus()):$(".quicklist-view__add-to-list__new").hasClass("__open")?($(".quicklist-view__add-to-list__new").removeClass("__open"),$(".quicklist-view__add-to-list__create-new").removeClass("__open")):($(".quicklist-view__add-to-list__new").addClass("__open"),$(".quicklist-view__add-to-list__create-new").addClass("__open"))},r=function(t){var u=n==2?".quicklist-view__add-to-list--v2__create-new__input-text":"#quicklist-view__add-to-list__new-title",i=n==2?".quicklist-view__add-to-list--v2__create-new__input":".quicklist-view__add-to-list__new",r=$(u).val().trim();r.length>0?(n==2?$(t).addClass("__loading").append(e):$(t).addClass("__loading").append(f),p(r)):($(i).append('<div id="quicklist-new_message">Please enter a title first.<\/div>'),$(i).addClass("__message"))},p=function(r){var u=n==2?".quicklist-view__add-to-list--v2__create-new__input":".quicklist-view__add-to-list__new";$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/CreateNewQuicklistAndAddItem",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListName:r,setAsDefault:!0,GPID:t.gpid}),success:function(r){var f=JSON.parse(r),e,o;f.Status==1&&($(".loading-spinner").remove(),$(".loading-spinner--dots").remove(),$(".__loading").removeClass("__loading"),$("#quicklist-new_message").length>0&&$("#quicklist-new_message").remove(),$(u).append('<div id="quicklist-new_message">Saved!<\/div>'),$(u).addClass("__message"));setTimeout(function(){$(".quicklist").removeClass("__new __no-list");i(QuickListV2.LoadData)},500);typeof laurentideTracker!="undefined"&&Laurentide_AddToList(f.QuickListItem,f.QuickListItemCount);e=$('.js-toggle-ql-item[data-gpid="'+t.gpid+'"]');o=e.data("ga-method");TrackQuicklist("Add",o,f.QuickListItem);n==1&&$(".quicklist--trigger").click()},error:function(){console.log("FAILURE")}})};return a(),{LoadAddToListWidget:o}}(),QuickListV2Sharing=function(){function v(n){return n.length>0?Utils.validateEmail(n)?(u(""),!0):(u("Please enter a valid email address."),!1):(u("Please enter an email address first."),!1)}function u(n){$("#statusmessage").html(n)}function y(n){$(".quicklist-share__submit-btn").html("Loading...");$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/SubmitPublicLink",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListId:t.qlid,isPublic:n}),success:function(n){var t=JSON.parse(n);r();StatusDialog.show("good",2e3,t.Message)},error:function(n){var t=JSON.parse(n);StatusDialog.show("good",2e3,t.Message)}})}function p(n,t){$.ajax({type:"POST",url:Utils.BaseURL+"QuickList/RemoveCollaborator",data:{id:n},success:function(){$(t).remove()},error:function(n){console.log(n)}})}function w(n){var t;t=$(n).is("#used-code")?"QuickListV2Sharing.NoClaimCallback":"QuickListV2Sharing.AuthCallback";$.ajax({type:"GET",url:Utils.BaseURL+"Authentication/FDNLogin?jscb="+t,cache:!1,success:function(n){$(".quicklist-form").html(n)},error:function(){}})}function b(){$.ajax({type:"GET",url:Utils.BaseURL+"Registration/SimpleRegister?jscb=QuickListV2Sharing.AuthCallback",cache:!1,success:function(n){$(".quicklist-form").html(n)},error:function(){}})}function k(){TrackEvent("Quicklist","Ql-Reg-Login-Opt","",!0);var n=location.href;n=n.substring(0,n.indexOf("?"));window.location.href=n}function d(){TrackEvent("Quicklist","Ql-Reg-Login-Opt","",!0);var n=location.href,t=Utils.getUrlParameter("guid");$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/CollaboratorSignInCallBack?guid="+t,contentType:"application/json; charset=utf-8",success:function(t){var i=JSON.parse(t);i.Status>0?i.isOwner==!0?(n=n.substring(0,n.indexOf("?"))+"?isowner="+i.isOwner,window.location.href=n):(n=n.substring(0,n.indexOf("?")),window.location.href=n):console.log(i.Message)},error:function(){}})}var t={qlid:""},n='<span class="quicklist-sharing__loading fdn-spinner fdn-spinner--xs fdn-spinner--absolute"><\/span>',i=function(i,r,u){t.qlid=i;$(".quicklist-view__share-btn").append(n);r=="true"?($("body").append('<div id="quicklist-share-overlay"><\/div><div class="quicklist-share"><\/div>'),$("body").addClass("ql-sharing__blur ql-sharing__open"),s()):u=="true"?($("body").append('<div id="quicklist-share-overlay"><\/div><div class="quicklist-share"><\/div>'),$("body").addClass("ql-sharing__blur ql-sharing__open"),a()):$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/GetShareOptions?QuickListId="+i,cache:!1,success:function(n){$("body").append('<div id="quicklist-share-overlay"><\/div><div class="quicklist-share"><\/div>');$("body").addClass("ql-sharing__blur ql-sharing__open");$(".quicklist-sharing__loading").remove();$(".quicklist-share").html(n);$(".quicklist-share__edit-public").focus()},error:function(){}})},f;$("body").on("click",".quicklist-share .quicklist-share__close",function(){r()});$("body").on("click",".quicklist-share .quicklist-share__btn-done",function(){r()});$("body").on("click",".quicklist-share__edit-public",function(){h()});$("body").on("click",".quicklist-share__edit-owner",function(){c()});$("body").on("click",".quicklist-share__edit-collaborators",function(){e()});$("body").on("click",".quicklist-share__btn-add",function(){e()});$("body").on("click",".quicklist-sharing__public-options .quicklist-share__submit-btn",function(){y($("input[name=isPublic]:checked").val())});$("body").on("click",".quicklist-share__back-btn",function(){l()});$("body").on("click",".quicklist-share__submit-addcollaborator",function(){o($(".quicklist-share__textboxemail").val(),$("#submit").data("isowner"))});$("body").on("keypress",".quicklist-share__textboxemail",function(n){n.keyCode==13&&o($(".quicklist-share__textboxemail").val(),$("#submit").data("isowner"))});$("body").on("click",".quicklist-Sharing__loginbtn",function(){w(this)});$("body").on("click",".quicklist-Sharing__registerbtn",function(){b()});$("body").on("click",".removecollaborator",function(){var i=confirm("Are you sure you want to remove this collaborator?"),n,t;i&&(n=$(this).closest(".quicklist-share__current-collabs"),t=$(this).data("id"),p(t,n))});var r=function(){$("body").removeClass("ql-sharing__open ql-sharing__blur");$("#quicklist-share-overlay").remove();$(window).width()<768?setTimeout(function(){$(".quicklist-share").remove()},1e3):$(".quicklist-share").remove()},s=function(){var t=Utils.getUrlParameter("guid");$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/GetCollaboratorSignIn?guid="+t,cache:!1,success:function(t){$("body").addClass("ql-sharing__open");$(n).remove();$(".quicklist-share").html(t)},error:function(){}})},h=function(){$(".quicklist-share__edit-public").append(n);$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/GetPublicLink?QuickListId="+t.qlid,cache:!1,success:function(t){$(n).remove();$(".quicklist-share").html(t)},error:function(){}})},c=function(){$(".quicklist-share__edit-owner").before(n);$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/ChangeOwnership?QuickListId="+t.qlid,cache:!1,success:function(t){$(n).remove();$(".quicklist-share").html(t)},error:function(){}})},e=function(){$(".quicklist-share__edit-collaborators").before(n);$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/AddCollaboratorForm?QuickListId="+t.qlid,cache:!1,success:function(t){$(n).remove();$(".quicklist-share").html(t)},error:function(){}})},l=function(){$(".quicklist-share__back-btn").html("Loading...");$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/GetShareOptions?QuickListId="+t.qlid,cache:!1,success:function(n){$(".quicklist-share").html(n)},error:function(){}})},a=function(){$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/EditExistingCollaborators?QuickListId="+t.qlid,cache:!1,success:function(t){$(n).remove();$(".quicklist-share").html(t)},error:function(){}})},o=function(n,i){v(n)&&($(".quicklist-share__submit-addcollaborator").html("Loading..."),$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/SubmitCollaboratorForm",contentType:"application/json; charset=utf-8",data:JSON.stringify({QuickListId:t.qlid,email:n,boolean:i}),success:function(n){$(".quicklist-share").html(n)},error:function(n){console.log(n)}}))};return f=function(){var n=window.location.href,t=n.lastIndexOf("/"),r=n.indexOf("?"),i;return t>0&&n.length-1!=t&&(i=n.substring(t+1,r)),i},$(document).ready(function(){var n=Utils.getUrlParameter("invite"),t=Utils.getUrlParameter("isowner"),r;typeof n!="undefined"&&n.length>0&&(r=f(),i(r,n,t));typeof t!="undefined"&&t.length>0&&(r=f(),i(r,n,t))}),{LoadQuickListSharing:i,AuthCallback:d,NoClaimCallback:k}}(),QuickListV2CuratedGroup=function(){function f(t,i){$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/SetQuickListCuratedLayout",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListId:t,quickListLayout:i}),success:function(){n(t,i)},error:function(){}})}function n(n,t){$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/CuratedGroupItemLayout?QuickListId="+n+"&IsEditable=true",cache:!1,success:function(n){$(".quicklist-curated__browse-items").html(n);$("textarea").each(function(){$(this).height($(this)[0].scrollHeight)});t==="NumberedList"?QuickListV2.InitReorderListItem(".quicklist-browse-layout","quicklist-browse_item--placeholder",QuickListV2.UpdateReorderListItemCount):(t==="Clean"||t==="Normal")&&QuickListV2.InitReorderListItem(".quicklist-browse-layout","quicklist-browse_item--placeholder l-grid-xl-3 l-grid-lg-4 l-grid-md-6")},error:function(){}})}function i(n){var t=$(n).closest(".quicklist-curated").data("quicklistid"),i=$(n).data("filename"),r=encodeURIComponent(i);e(t,r)}function e(n,t){$.ajax({type:"GET",url:Utils.BaseURL+"Quicklist/CropCoverPhoto?id="+n+"&coverImage="+t,cache:!1,success:function(n){$(".quicklist-curated__crop-img").html(n);$("body,html").scrollTo(".quicklist-curated__crop-img");r()},error:function(){}})}function o(n){var t=$(n).closest(".quicklist-curated").data("quicklistid");$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/RemoveCoverPhoto",contentType:"application/json; charset=utf-8",data:JSON.stringify({id:t}),success:function(n){n>0&&(window.location.href=Utils.BaseURL+"Quicklist/CreateCuratedGroup/"+t)},error:function(){Error("Item failed to delete")}})}function s(t){var i=$(t).closest(".quicklist-browse_item").data("qlitemid"),r=$(t).closest(".quicklist-curated").data("quicklistid"),u=$(t).closest(".quicklist-curated__browse-items").data("layout");$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/RemoveItem",contentType:"application/json; charset=utf-8",data:JSON.stringify({QuickListItemId:i}),success:function(t){t>0&&(StatusDialog.show("good",1e3,"Item Deleted"),n(r,u),TrackQuicklist("Remove","QuickList Delete",{GPID:i}))},error:function(){Error("Item failed to delete")}})}function r(){$(window).width()>1080&&$("#curated-group__crop").Jcrop({onSelect:h})}function h(n){$("#curated-group__crop-save").data("coords",n)}function c(n){var t=JSON.stringify(n);$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/CropAndSaveCoverPhoto",contentType:"application/json; charset=utf-8",dataType:"json",data:t,success:function(t){t.Status>0?window.location.href=Utils.BaseURL+"Quicklist/CreateCuratedGroup/"+n.id:StatusDialog.bad("good",2e3,t.Message)},error:function(){}})}function l(n){var i=$(".quicklist-curated").data("quicklistid"),t,r,u;if(!a()){console.log("validate test");return}if($(n).siblings(".quicklist-curated__save-error").length>0&&$(".quicklist-curated__save-error").remove(),$(n).parent().find(".quicklist-curated__input-error").length>0){$(".quicklist-curated__save-btn").after('<div class="quicklist-curated__save-error">Fix invalid html before saving<\/div>');return}t={QuickListId:i};$(".quicklist-curated__edit-checkbox").length>0&&(console.log("checkbox"),r=$(n).siblings(".quicklist-curated__edit-checkbox").find("input.quicklist-curated__checkbox").is(":checked"),t.ShowOnBrowseItemPage=r,console.log(t));$.each($(".quicklist-curated__input"),function(){var n=$(this).data("propname");t[n]=$(this).val()});u=JSON.stringify(t);$.ajax({url:Utils.BaseURL+"Quicklist/UpdateCuratedGroupProperties",type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:u,success:function(n){window.location.href=Utils.BaseURL+"Quicklist/CreateCuratedGroup/"+i;console.log(n)},error:function(n){console.log(n)}})}function a(){var n=!0,t=$(".quicklist-curated__input#RoutePath").val(),i;return t!=" "&&(i=/^[a-zA-Z0-9\-]*$/,n=i.test(t),n||$(".quicklist-curated_page-path-error").html("Invalid Page Path")),n}function u(n){$(n).siblings(".quicklist-curated__input-error").length>0&&$(n).siblings(".quicklist-curated__input-error").remove();var t=!0,i=$(n).val();return t=!/<[^>]*>/.test(i),t||$(n).parent().append('<div class="quicklist-curated__input-error">Title can not have html tags<\/div>'),console.log("title: "+t),t}function t(n,t){var i=$(n).val();$(n).siblings(".quicklist-curated__input-error").length>0&&$(n).siblings(".quicklist-curated__input-error").remove();$.ajax({url:Utils.BaseURL+"Quicklist/ValidateHtml",type:"POST",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify({html:i}),success:function(i){if(i.Status>0)for(j in i.Errors)$(n).parent().append('<div class="quicklist-curated__input-error">'+i.Errors[j].ErrorMessage+" at line "+i.Errors[j].LineNumber+"<\/div>");else t&&t()},error:function(n){console.log(n)}})}$("body").on("click",".quicklist-curated__img-trigger",function(){i(this)});$("body").on("click",".quicklist-curated__img-cancel-btn",function(){i(this)});$("body").on("click",".quicklist-curated__delete-img-btn",function(){o(this)});$("body").on("click",".quicklist-browse-layout__delete-btn",function(){s($(this))});$("body").on("click",".quicklist-curated__save-btn",function(){l(this)});$(".quicklist-curated__input#Title").focusout(function(){u(this)});$(".quicklist-curated__input#ShortDesc").focusout(function(){t(this)});$(".quicklist-curated__input#LongDesc").focusout(function(){t(this)});$(".quicklist-curated__input#RoutePath").focus(function(){$(this).select()});$(".quicklist-curated__input#Title").keyup(function(){$(".quicklist-curated_title-count").html($(this).val().length+"/60")});$(".quicklist-curated__input#ShortDesc").keyup(function(){$(".quicklist-curated_short-desc-count").html($(this).val().length+"/160")});$(".quicklist-curated__input#LongDesc").keyup(function(){$(".quicklist-curated_long-desc-count").html($(this).val().length+"/350")});$("body").on("change",".quicklist-curated__layout-ddl",function(){var n=$(this).closest(".quicklist-curated").data("quicklistid"),t=this.value;f(n,t)});$("body").on("click","#curated-group__crop-save",function(){var i=$(this).data("filename"),r=$(this).closest(".quicklist-curated").data("quicklistid"),t=$(this).data("coords"),n;i?t?(n={},n.imagePath=i,n.id=r,n.xCoord=Math.round(t.x),n.yCoord=Math.round(t.y),n.width=Math.round(t.w),n.height=Math.round(t.h),c(n)):$(".quicklist-curated__crop-msg").html("Width and height must be greater than 0"):$(".quicklist-curated__crop-msg").html("Select an image to continue")});return{initJcrop:r,validateHtmlProperties:t,validateTitle:u,LoadCuratedLayout:n}}(),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("<!DOCTYPE html><html><head><\/head><body><\/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||u<e)&&(e=u),(!o||u>o)&&(o=u),h.push(u);return r<e&&(r=e),r>o&&(r=o),h.sort(function(n,t){return(s?n>r&&t>r?n<t:n>t:n<r&&t<r?n>t:n<t)?-1:1}),f[h[0]]}}function p(){function f(n,t){return n.contains?n.contains(t):n.compareDocumentPosition(t)&16}function t(n){var t=n.relatedTarget;t&&!f(this,t)&&u(this)}function i(){u(this)}function u(t){setTimeout(function(){n.replace(t,a.get(t).options,!0)},10)}this.attach=function(n){n.onmouseenter===undefined?(r(n,"mouseover",t),r(n,"mouseout",t)):(r(n,"mouseenter",i),r(n,"mouseleave",i))}}function w(){function i(n){return n.cufid||(n.cufid=++t)}var n={},t=0;this.get=function(t){var r=i(t);return n[r]||(n[r]={})}}function b(n){var i={},r={};this.get=function(t){return i[t]!=undefined?i[t]:n[t]};this.getSize=function(n,i){return r[n]||(r[n]=new t.Size(this.get(n),i))};this.extend=function(n){for(var t in n)i[t]=n[t];return this}}function r(n,t,i){n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent&&n.attachEvent("on"+t,function(){return i.call(n,fabric.window.event)})}function k(n,t){var i=a.get(n);return i.options?n:(t.hover&&t.hoverables[n.nodeName.toLowerCase()]&&tt.attach(n),i.options=t,n)}function e(n){var t={};return function(i){return t.hasOwnProperty(i)||(t[i]=n.apply(null,arguments)),t[i]}}function d(n,r){var f,e,u,o;for(r||(r=t.getStyle(n)),f=t.quotedList(r.get("fontFamily").toLowerCase()),u=0,o=f.length;u<o;++u)if(e=f[u],i[e])return i[e].get(r.get("fontStyle"),r.get("fontWeight"));return null}function o(n){return fabric.document.getElementsByTagName(n)}function s(){for(var i={},t,n=0,r=arguments.length;n<r;++n)for(t in arguments[n])i[t]=arguments[n][t];return i}function g(n,i,r,f,e,o){var l=f.separate,s,c;if(l=="none")return u[f.engine].apply(null,arguments);var v=fabric.document.createDocumentFragment(),a,h=i.split(it[l]),y=l=="words";for(y&&nt&&(/^\s/.test(i)&&h.unshift(""),/\s$/.test(i)&&h.push("")),s=0,c=h.length;s<c;++s)a=u[f.engine](n,y?t.textAlign(h[s],r,s,c):h[s],r,f,e,o,s<c-1),a&&v.appendChild(a);return v}function l(n,i){for(var o,h,f,e,c,s,r=k(n,i).firstChild;r;r=c){if(c=r.nextSibling,s=!1,r.nodeType==1){if(!r.firstChild)continue;if(/cufon/.test(r.className))s=!0;else{arguments.callee(r,i);continue}}if(e||(e=t.getStyle(n).extend(i)),f||(f=d(n,e)),f){if(s){u[i.engine](f,null,e,i,r,n);continue}(o=r.data,typeof G_vmlCanvasManager!="undefined"&&(o=o.replace(/\r/g,"\n")),o!=="")&&(h=g(f,o,e,i,r,n),h?r.parentNode.replaceChild(h,r):r.parentNode.removeChild(r))}}}var n=function(){return n.replace.apply(null,arguments)},c=n.DOM={ready:function(){var t=!1,u={loaded:1,complete:1},i=[],n=function(){if(!t){t=!0;for(var n;n=i.shift();n());}};return fabric.document.addEventListener&&(fabric.document.addEventListener("DOMContentLoaded",n,!1),fabric.window.addEventListener("pageshow",n,!1)),!fabric.window.opera&&fabric.document.readyState&&function(){u[fabric.document.readyState]?n():setTimeout(arguments.callee,10)}(),fabric.document.readyState&&fabric.document.createStyleSheet&&function(){try{fabric.document.body.doScroll("left");n()}catch(t){setTimeout(arguments.callee,1)}}(),r(fabric.window,"load",n),function(r){arguments.length?t?r():i.push(r):n()}}()},t=n.CSS={Size:function(n,t){this.value=parseFloat(n);this.unit=String(n).match(/[a-z%]*$/)[0]||"px";this.convert=function(n){return n/t*this.value};this.convertFrom=function(n){return n/this.value*t};this.toString=function(){return this.value+this.unit}},getStyle:function(n){return new b(n.style)},quotedList:e(function(n){for(var i=[],r=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,t;t=r.exec(n);)i.push(t[3]||t[1]);return i}),ready:function(){var n=!1,t=[],r=function(){n=!0;for(var i;i=t.shift();i());},u=Object.prototype.propertyIsEnumerable?o("style"):{length:0},i=o("link");return c.ready(function(){for(var f=0,n,t=0,e=i.length;n=i[t],t<e;++t)n.disabled||n.rel.toLowerCase()!="stylesheet"||++f;fabric.document.styleSheets.length>=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):i<r-1&&(n+=" "),n},textDecoration:function(n,t){var i,r,f,u;for(t||(t=this.getStyle(n)),i={underline:null,overline:null,"line-through":null},r=n;r.parentNode&&r.parentNode.nodeType==1;){f=!0;for(u in i)i[u]||(t.get("textDecoration").indexOf(u)!=-1&&(i[u]=t.get("color")),f=!1);if(f)break;t=this.getStyle(r=r.parentNode)}return i},textShadow:e(function(n){if(n=="none")return null;for(var r=[],t={},i,u=0,f=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;i=f.exec(n);)i[0]==","?(r.push(t),t={},u=0):i[1]?t.color=i[1]:t[["offX","offY","blur"][u++]]=i[2];return r.push(t),r}),color:e(function(n){var t={};return t.color=n.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(n,i,r){return t.opacity=parseFloat(r),"rgb("+i+")"}),t}),textTransform:function(n,t){return n[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[t.get("textTransform")]||"toString"]()}},nt=" ".split(/\s+/).length==0,a=new w,tt=new p,h=[],u={},i={},f={engine:null,hover:!1,hoverables:{a:!0},printable:!0,selector:fabric.window.Sizzle||fabric.window.jQuery&&function(n){return jQuery(n)}||fabric.window.dojo&&dojo.query||fabric.window.$$&&function(n){return $$(n)}||fabric.window.$&&function(n){return $(n)}||fabric.document.querySelectorAll&&function(n){return fabric.document.querySelectorAll(n)}||o,separate:"words",textShadow:"none"},it={words:/\s+/,characters:""};return n.now=function(){return c.ready(),n},n.refresh=function(){for(var i=h.splice(0,h.length),t=0,r=i.length;t<r;++t)n.replace.apply(null,i[t]);return n},n.registerEngine=function(t,i){return i?(u[t]=i,n.set("engine",t)):n},n.registerFont=function(t){var u=new v(t),r=u.family;return i[r]||(i[r]=new y),i[r].add(u),n.set("fontFamily",'"'+r+'"')},n.replace=function(i,r,u){return(r=s(f,r),!r.engine)?n:(typeof r.textShadow=="string"&&r.textShadow&&(r.textShadow=t.textShadow(r.textShadow)),u||h.push(arguments),(i.nodeType||typeof i=="string")&&(i=[i]),t.ready(function(){for(var u,t=0,f=i.length;t<f;++t)u=i[t],typeof u=="string"?n.replace(r.selector(u),r,!0):l(u,r)}),n)},n.replaceElement=function(n,i){return i=s(f,i),typeof i.textShadow=="string"&&i.textShadow&&(i.textShadow=t.textShadow(i.textShadow)),l(n,i)},n.engines=u,n.fonts=i,n.getOptions=function(){return s(f)},n.set=function(t,i){return f[t]=i,n},n}();Cufon.registerEngine("canvas",function(){function u(n,t){var f=0,e=0,u=[],s=/([mrvxe])([^a-z]*)/g,o,r,i;n:for(r=0;o=s.exec(n);++r){i=o[2].split(",");switch(o[1]){case"v":u[r]={m:"bezierCurveTo",a:[f+~~i[0],e+~~i[1],f+~~i[2],e+~~i[3],f+=~~i[4],e+=~~i[5]]};break;case"r":u[r]={m:"lineTo",a:[f+=~~i[0],e+=~~i[1]]};break;case"m":u[r]={m:"moveTo",a:[f=~~i[0],e=~~i[1]]};break;case"x":u[r]={m:"closePath",a:[]};break;case"e":break n}t[u[r].m].apply(t,u[r].a)}return u}function f(n,t){for(var r,i=0,u=n.length;i<u;++i)r=n[i],t[r.m].apply(t,r.a)}var t=Cufon.CSS.supports("display","inline-block"),r=!t&&(fabric.document.compatMode=="BackCompat"||/frameset|transitional/i.test(fabric.document.doctype.publicId)),n=fabric.document.createElement("style"),i;n.type="text/css";i=fabric.document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(r?"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(t?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}");try{n.appendChild(i)}catch(e){n.setAttribute("type","text/css");n.styleSheet.cssText=i.data}return fabric.document.getElementsByTagName("head")[0].appendChild(n),function(n,i,r,e,o){function ei(){var u,o,p,f;s.save();var r=0,t=0,i=[{left:0}];for(e.backgroundColor&&(s.save(),s.fillStyle=e.backgroundColor,s.translate(0,n.ascent),s.fillRect(0,0,a+10,(-n.ascent+n.descent)*tt),s.restore()),e.textAlign==="right"?(s.translate(c[t],0),i[0].left=c[t]*l):e.textAlign==="center"&&(s.translate(c[t]/2,0),i[0].left=c[t]/2*l),u=0,o=y.length;u<o;++u){if(y[u]==="\n"){t++;var h=-n.ascent-n.ascent/5*e.lineHeight,w=i[i.length-1],v={left:0};w.width=r*l;w.height=(-n.ascent+n.descent)*l;e.textAlign==="right"?(s.translate(-a,h),s.translate(c[t],0),v.left=c[t]*l):e.textAlign==="center"?(s.translate(-r-c[t-1]/2,h),s.translate(c[t]/2,0),v.left=c[t]/2*l):s.translate(-r,h);i.push(v);r=0;continue}(p=n.glyphs[y[u]]||n.missingGlyph,p)&&(f=Number(p.w||n.w)+k,e.textBackgroundColor&&(s.save(),s.fillStyle=e.textBackgroundColor,s.translate(0,n.ascent),s.fillRect(0,0,f+10,-n.ascent+n.descent),s.restore()),s.translate(f,0),r+=f,u==o-1&&(i[i.length-1].width=r*l,i[i.length-1].height=(-n.ascent+n.descent)*l))}s.restore();Cufon.textOptions.boundaries=i}function ri(t){var l,o,v,w,p,i,h;for(s.fillStyle=t||Cufon.textOptions.color||r.get("color"),l=0,o=0,e.textAlign==="right"?s.translate(c[o],0):e.textAlign==="center"&&s.translate(c[o]/2,0),v=0,w=y.length;v<w;++v){if(y[v]==="\n"){o++;p=-n.ascent-n.ascent/5*e.lineHeight;e.textAlign==="right"?(s.translate(-a,p),s.translate(c[o],0)):e.textAlign==="center"?(s.translate(-l-c[o-1]/2,p),s.translate(c[o]/2,0)):s.translate(-l,p);l=0;continue}(i=n.glyphs[y[v]]||n.missingGlyph,i)&&(h=Number(i.w||n.w)+k,it&&(s.save(),s.strokeStyle=s.fillStyle,s.lineWidth+=s.lineWidth,s.beginPath(),it.underline&&(s.moveTo(0,-n.face["underline-position"]+.5),s.lineTo(h,-n.face["underline-position"]+.5)),it.overline&&(s.moveTo(0,n.ascent+.5),s.lineTo(h,n.ascent+.5)),it["line-through"]&&(s.moveTo(0,-n.descent+.5),s.lineTo(h,-n.descent+.5)),s.stroke(),s.restore()),yt&&(s.save(),s.transform(1,0,-.25,1,0,0)),s.beginPath(),i.d&&(i.code?f(i.code,s):i.code=u("m"+i.d,s)),s.fill(),e.strokeStyle&&(s.closePath(),s.save(),s.lineWidth=e.strokeWidth,s.strokeStyle=e.strokeStyle,s.stroke(),s.restore()),yt&&s.restore(),s.translate(h,0),l+=h)}}var pt=i===null,g=n.viewBox,v=r.getSize("fontSize",n.baseSize),k=r.get("letterSpacing"),lt,c,p,w,ot,s,l,ii,it,yt,h,d,ft;k=k=="normal"?0:v.convertFrom(parseInt(k,10));var rt=0,wt=0,ut=0,b=e.textShadow,nt=[];if(Cufon.textOptions.shadowOffsets=[],Cufon.textOptions.shadows=null,b)for(Cufon.textOptions.shadows=b,h=0,d=b.length;h<d;++h){var ft=b[h],ui=v.convertFrom(parseFloat(ft.offX)),fi=v.convertFrom(parseFloat(ft.offY));nt[h]=[ui,fi]}var y=Cufon.CSS.textTransform(pt?o.alt:i,r).split(""),a=0,ht=null,ct=0,tt=1,et=[];for(h=0,d=y.length;h<d;++h){if(y[h]==="\n"){tt++;a>ct&&(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<d;++h)ft=b[h],s.save(),s.translate.apply(s,nt[h]),ri(ft.color),s.restore();return ri(),s.restore(),s.restore(),s.restore(),p}}());Cufon.registerEngine("vml",function(){function r(n,t){return i(n,/(?:em|ex|%)$/i.test(t)?"1em":t)}function i(n,t){var i,r,u;return/px$/i.test(t)?parseFloat(t):(i=n.style.left,r=n.runtimeStyle.left,n.runtimeStyle.left=n.currentStyle.left,n.style.left=t,u=n.style.pixelLeft,n.style.left=i,n.runtimeStyle.left=r,u)}var n,t;if(fabric.document.namespaces)return(n=fabric.document.createElement("canvas"),n&&n.getContext&&n.getContext.apply)?void 0:(fabric.document.namespaces.cvml==null&&fabric.document.namespaces.add("cvml","urn:schemas-microsoft-com:vml"),t=fabric.document.createElement("cvml:shape"),t.style.behavior="url(#default#VML)",!t.coordsize)?void 0:(t=null,fabric.document.write('<style type="text/css">.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}<\/style>'),function(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;w<wt;++w)l=n.glyphs[ut[w]]||n.missingGlyph,l&&(ft+=et=~~(l.w||n.w)+y);if(et===null)return null;var bt=-rt+ft+(b.width-et),ti=v.convert(bt*at),ii=Math.round(ti),kt=bt+","+b.height,dt,ri="r"+kt+"nsnf";for(w=0;w<wt;++w)if(l=n.glyphs[ut[w]]||n.missingGlyph,l){if(nt?(h=p.childNodes[pt],h.firstChild&&h.removeChild(h.firstChild)):(h=fabric.document.createElement("cvml:shape"),p.appendChild(h)),h.stroked="f",h.coordsize=kt,h.coordorigin=dt=rt-yt+","+vt,h.path=(l.d?"m"+l.d+"xe":"")+"m"+dt+ri,h.fillcolor=ni,st=h.style,st.width=ii,st.height=it,ot){var ht=ot[0],d=ot[1],gt=Cufon.CSS.color(ht.color),g,a=fabric.document.createElement("cvml:shadow");a.on="t";a.color=gt.color;a.offset=ht.offX+","+ht.offY;d&&(g=Cufon.CSS.color(d.color),a.type="double",a.color2=g.color,a.offset2=d.offX+","+d.offY);a.opacity=gt.opacity||g&&g.opacity||1;h.appendChild(a)}yt+=~~(l.w||n.w)+y;++pt}return ct.width=Math.max(Math.ceil(v.convert(ft*at)),0),c})}());Cufon.getTextDecoration=function(n){return{underline:n.textDecoration==="underline",overline:n.textDecoration==="overline","line-through":n.textDecoration==="line-through"}};typeof exports!="undefined"&&(exports.Cufon=Cufon);JSON||(JSON={}),function(){"use strict";function i(n){return n<10?"0"+n:n}function o(n){return e.lastIndex=0,e.test(n)?'"'+n.replace(e,function(n){var t=s[n];return typeof t=="string"?t:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'}function u(i,f){var s,l,h,a,v=n,c,e=f[i];e&&typeof e=="object"&&typeof e.toJSON=="function"&&(e=e.toJSON(i));typeof t=="function"&&(e=t.call(f,i,e));switch(typeof e){case"string":return o(e);case"number":return isFinite(e)?String(e):"null";case"boolean":case"null":return String(e);case"object":if(!e)return"null";if(n+=r,c=[],Object.prototype.toString.apply(e)==="[object Array]"){for(a=e.length,s=0;s<a;s+=1)c[s]=u(s,e)||"null";return h=c.length===0?"[]":n?"[\n"+n+c.join(",\n"+n)+"\n"+v+"]":"["+c.join(",")+"]",n=v,h}if(t&&typeof t=="object")for(a=t.length,s=0;s<a;s+=1)typeof t[s]=="string"&&(l=t[s],h=u(l,e),h&&c.push(o(l)+(n?": ":":")+h));else for(l in e)Object.prototype.hasOwnProperty.call(e,l)&&(h=u(l,e),h&&c.push(o(l)+(n?": ":":")+h));return h=c.length===0?"{}":n?"{\n"+n+c.join(",\n"+n)+"\n"+v+"}":"{"+c.join(",")+"}",n=v,h}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+i(this.getUTCMonth()+1)+"-"+i(this.getUTCDate())+"T"+i(this.getUTCHours())+":"+i(this.getUTCMinutes())+":"+i(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var f=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,r,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},t;typeof JSON.stringify!="function"&&(JSON.stringify=function(i,f,e){var o;if(n="",r="",typeof e=="number")for(o=0;o<e;o+=1)r+=" ";else typeof e=="string"&&(r=e);if(t=f,f&&typeof f!="function"&&(typeof f!="object"||typeof f.length!="number"))throw new Error("JSON.stringify");return u("",{"":i})});typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(n,t){var r,u,i=n[t];if(i&&typeof i=="object")for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(u=walk(i,r),u!==undefined?i[r]=u:delete i[r]);return reviver.call(n,t,i)}var j;if(text=String(text),f.lastIndex=0,f.test(text)&&(text=text.replace(f,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse");})}();typeof Event=="undefined"&&(Event={});typeof eventjs=="undefined"&&(eventjs=Event),function(n){"use strict";n.modifyEventListener=!1;n.modifySelectors=!0;n.add=function(n,t,r,u){return i(n,t,r,u,"add")};n.remove=function(n,t,r,u){return i(n,t,r,u,"remove")};n.stop=function(n){n&&(n.stopPropagation&&n.stopPropagation(),n.cancelBubble=!0,n.bubble=0)};n.prevent=function(n){n&&(n.preventDefault&&n.preventDefault(),n.preventManipulation&&n.preventManipulation(),n.returnValue=!1)};n.cancel=function(t){n.stop(t);n.prevent(t)};n.getEventSupport=function(n,t){if(typeof n=="string"&&(t=n,n=window),t="on"+t,t in n)return!0;if(n.setAttribute||(n=document.createElement("div")),n.setAttribute&&n.removeAttribute){n.setAttribute(t,"");var i=typeof n[t]=="function";return typeof n[t]!="undefined"&&(n[t]=null),n.removeAttribute(t),i}};var r=function(n){var i,t;if(!n||typeof n!="object")return n;i=new n.constructor;for(t in n)i[t]=n[t]&&typeof n[t]=="object"?r(n[t]):n[t];return i},i=function(s,h,c,v,y,p){var k,d,nt,tt,ot,it,st,b,ut,w,ht,rt,ft,g;if(v=v||{},String(s)==="[object Object]"){k=s;s=k.target;h=k.type;c=k.listener;delete k.target;delete k.type;delete k.listener;for(b in k)v[b]=k[b]}if(s&&h&&c){if(typeof s=="string"&&h==="ready"){var ct=(new Date).getTime(),lt=v.timeout,at=v.interval||1e3/60,et=window.setInterval(function(){(new Date).getTime()-ct>lt&&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<ot;tt++)d=i(s[tt],h,c,r(v),y),d&&(nt[tt]=d);return f(nt)}if(h.indexOf&&h.indexOf(" ")!==-1&&(h=h.split(" ")),h.indexOf&&h.indexOf(",")!==-1&&(h=h.split(",")),typeof h!="string"){if(typeof h.length=="number")for(it=0,st=h.length;it<st;it++)d=i(s,h[it],c,r(v),y),d&&(nt[h[it]]=d);else for(b in h)d=typeof h[b]=="function"?i(s,b,h[b],r(v),y):i(s,b,h[b].listener,r(h[b]),y),d&&(nt[b]=d);return f(nt)}if(typeof s!="object")return u("Target is not defined!",arguments);if(typeof c!="function")return u("Listener is not a function!",arguments);if(ut=v.useCapture||!1,w=o(s)+"."+o(c)+"."+(ut?1:0),n.Gesture&&n.Gesture._gestureHandlers[h]){if(w=h+w,y==="remove"){if(!t[w])return;t[w].remove();delete t[w]}else if(y==="add"){if(t[w])return t[w].add(),t[w];v.useCall&&!n.modifyEventListener&&(ht=c,c=function(n,t){for(var i in t)n[i]=t[i];return ht.call(s,n)});v.gesture=h;v.target=s;v.listener=c;v.fromOverwrite=p;t[w]=n.proxy[h](v)}return t[w]}for(rt=e(h),ft=0;ft<rt.length;ft++)if(h=rt[ft],g=h+"."+w,y==="remove"){if(!t[g])continue;s[a](h,c,ut);delete t[g]}else if(y==="add"){if(t[g])return t[g];s[l](h,c,ut);t[g]={id:g,type:h,target:s,listener:c,remove:function(){for(var t=0;t<rt.length;t++)n.remove(s,rt[t],c,v)}}}return t[g]}},f=function(n){return{remove:function(){for(var t in n)n[t].remove()},add:function(){for(var t in n)n[t].add()}}},u=function(n,t){typeof console!="undefined"&&typeof console.error!="undefined"&&console.error(n,t)},s={msPointer:["MSPointerDown","MSPointerMove","MSPointerUp"],touch:["touchstart","touchmove","touchend"],mouse:["mousedown","mousemove","mouseup"]},h={MSPointerDown:0,MSPointerMove:1,MSPointerUp:2,touchstart:0,touchmove:1,touchend:2,mousedown:0,mousemove:1,mouseup:2},v=function(){n.supports={};window.navigator.msPointerEnabled&&(n.supports.msPointer=!0);n.getEventSupport("touchstart")&&(n.supports.touch=!0);n.getEventSupport("mousedown")&&(n.supports.mouse=!0)}(),e=function(){return function(t){var r=document.addEventListener?"":"on",u=h[t],i,f;if(isFinite(u)){i=[];for(f in n.supports)i.push(r+s[f][u]);return i}return[r+t]}}(),t={},c=0,o=function(n){return n===window?"#window":n===document?"#document":(n.uniqueID||(n.uniqueID="e"+c++),n.uniqueID)},l=document.addEventListener?"addEventListener":"attachEvent",a=document.removeEventListener?"removeEventListener":"detachEvent";return n.createPointerEvent=function(t,i,r){var h=i.gesture,c=i.target,e=t.changedTouches||n.proxy.getCoords(t),o,u,f,s;e.length&&(o=e[0],i.pointers=r?[]:e,i.pageX=o.pageX,i.pageY=o.pageY,i.x=i.pageX,i.y=i.pageY);u=document.createEvent("Event");u.initEvent(h,!0,!0);u.originalEvent=t;for(f in i)f!=="target"&&(u[f]=i[f]);s=u.type;n.Gesture&&n.Gesture._gestureHandlers[s]&&i.oldListener.call(c,u,i,!1)},n.modifyEventListener&&window.HTMLElement&&function(){var t=function(t){var r=function(r){var u=r+"EventListener",f=t[u];t[u]=function(t,u,o){var s,c,h;if(n.Gesture&&n.Gesture._gestureHandlers[t])s=o,typeof o=="object"?s.useCall=!0:s={useCall:!0,useCapture:o},i(this,t,u,s,r,!0);else for(c=e(t),h=0;h<c.length;h++)f.call(this,c[h],u,o)}};r("add");r("remove")};navigator.userAgent.match(/Firefox/)?(t(HTMLDivElement.prototype),t(HTMLCanvasElement.prototype)):t(HTMLElement.prototype);t(document);t(window)}(),n.modifySelectors&&function(){var n=NodeList.prototype;n.removeEventListener=function(n,t,i){for(var r=0,u=this.length;r<u;r++)this[r].removeEventListener(n,t,i)};n.addEventListener=function(n,t,i){for(var r=0,u=this.length;r<u;r++)this[r].addEventListener(n,t,i)}}(),n}(Event);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";n.pointerSetup=function(n,t){n.doc=n.target.ownerDocument||n.target;n.minFingers=n.minFingers||n.fingers||1;n.maxFingers=n.maxFingers||n.fingers||Infinity;n.position=n.position||"relative";delete n.fingers;t=t||{};t.enabled=!0;t.gesture=n.gesture;t.target=n.target;t.env=n.env;Event.modifyEventListener&&n.fromOverwrite&&(n.oldListener=n.listener,n.listener=Event.createPointerEvent);var r=0,i=t.gesture.indexOf("pointer")===0&&Event.modifyEventListener?"pointer":"mouse";return n.oldListener&&(t.oldListener=n.oldListener),t.listener=n.listener,t.proxy=function(i){t.defaultListener=n.listener;n.listener=i;i(n.event,t)},t.add=function(){t.enabled!==!0&&(n.onPointerDown&&Event.add(n.target,i+"down",n.onPointerDown),n.onPointerMove&&Event.add(n.doc,i+"move",n.onPointerMove),n.onPointerUp&&Event.add(n.doc,i+"up",n.onPointerUp),t.enabled=!0)},t.remove=function(){t.enabled!==!1&&(n.onPointerDown&&Event.remove(n.target,i+"down",n.onPointerDown),n.onPointerMove&&Event.remove(n.doc,i+"move",n.onPointerMove),n.onPointerUp&&Event.remove(n.doc,i+"up",n.onPointerUp),t.reset(),t.enabled=!1)},t.pause=function(t){n.onPointerMove&&(!t||t.move)&&Event.remove(n.doc,i+"move",n.onPointerMove);n.onPointerUp&&(!t||t.up)&&Event.remove(n.doc,i+"up",n.onPointerUp);r=n.fingers;n.fingers=0},t.resume=function(t){n.onPointerMove&&(!t||t.move)&&Event.add(n.doc,i+"move",n.onPointerMove);n.onPointerUp&&(!t||t.up)&&Event.add(n.doc,i+"up",n.onPointerUp);n.fingers=r},t.reset=function(){n.tracker={};n.fingers=0},t};var t=Event.supports;return Event.pointerType=t.mouse?"mouse":t.touch?"touch":"mspointer",n.pointerStart=function(t,i,r){var c=(t.type||"mousedown").toUpperCase(),s,h,o,y,l,e,u;c.indexOf("MOUSE")===0?Event.pointerType="mouse":c.indexOf("TOUCH")===0?Event.pointerType="touch":c.indexOf("MSPOINTER")===0&&(Event.pointerType="mspointer");s=function(n,t){var u=r.bbox,i=f[t]={},e,o;switch(r.position){case"absolute":i.offsetX=0;i.offsetY=0;break;case"differenceFromLast":i.offsetX=n.pageX;i.offsetY=n.pageY;break;case"difference":i.offsetX=n.pageX;i.offsetY=n.pageY;break;case"move":i.offsetX=n.pageX-u.x1;i.offsetY=n.pageY-u.y1;break;default:i.offsetX=u.x1;i.offsetY=u.y1}r.position==="relative"?(e=n.pageX+u.scrollLeft-i.offsetX,o=n.pageY+u.scrollTop-i.offsetY):(e=n.pageX-i.offsetX,o=n.pageY-i.offsetY);i.rotation=0;i.scale=1;i.startTime=i.moveTime=(new Date).getTime();i.move={x:e,y:o};i.start={x:e,y:o};r.fingers++};r.event=t;i.defaultListener&&(r.listener=i.defaultListener,delete i.defaultListener);var a=!r.fingers,f=r.tracker,v=t.changedTouches||n.getCoords(t),p=v.length;for(h=0;h<p;h++)if(o=v[h],u=o.identifier||Infinity,r.fingers){if(r.fingers>=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;e<l;e++)c=s[e],u=c.identifier,h[u||Infinity]=!0;for(u in i.tracker)(f=i.tracker[u],h[u]||f.up)||(r&&r({pageX:f.pageX,pageY:f.pageY,changedTouches:[{pageX:f.pageX,pageY:f.pageY,identifier:u==="Infinity"?Infinity:u}]},"up"),f.up=!0,i.fingers--);if(i.fingers!==0)return!1;o=[];i.gestureFingers=0;for(u in i.tracker)i.gestureFingers++,o.push(u);return t.identifier=o.join(","),!0},n.getCoords=function(t){return n.getCoords=typeof t.pageX!="undefined"?function(n){return Array({type:"mouse",x:n.pageX,y:n.pageY,pageX:n.pageX,pageY:n.pageY,identifier:n.pointerId||Infinity})}:function(n){return n=n||window.event,Array({type:"mouse",x:n.clientX+document.documentElement.scrollLeft,y:n.clientY+document.documentElement.scrollTop,pageX:n.clientX+document.documentElement.scrollLeft,pageY:n.clientY+document.documentElement.scrollTop,identifier:Infinity})},n.getCoords(t)},n.getCoord=function(t){if("ontouchstart"in window){var i=0,r=0;n.getCoord=function(n){var t=n.changedTouches;return t&&t.length?{x:i=t[0].pageX,y:r=t[0].pageY}:{x:i,y:r}}}else n.getCoord=typeof t.pageX!="undefined"&&typeof t.pageY!="undefined"?function(n){return{x:n.pageX,y:n.pageY}}:function(n){return n=n||window.event,{x:n.clientX+document.documentElement.scrollLeft,y:n.clientY+document.documentElement.scrollTop}};return n.getCoord(t)},n.getBoundingBox=function(n){var t,r,i,f,u;for((n===window||n===document)&&(n=document.body),t={},r=n.getBoundingClientRect(),t.width=r.width,t.height=r.height,t.x1=r.left,t.y1=r.top,t.x2=t.x1+t.width,t.y2=t.y1+t.height,t.scaleX=r.width/n.offsetWidth||1,t.scaleY=r.height/n.offsetHeight||1,t.scrollLeft=0,t.scrollTop=0,i=n.parentNode;i!==null;){if(i===document.body)break;if(i.scrollTop===undefined)break;if(f=window.getComputedStyle(i),u=f.getPropertyValue("position"),u==="absolute")break;else if(u==="fixed"){t.scrollTop-=i.parentNode.scrollTop;break}else t.scrollLeft+=i.scrollLeft,t.scrollTop+=i.scrollTop;i=i.parentNode}return t},function(){var t=navigator.userAgent.toLowerCase(),i=t.indexOf("macintosh")!==-1,r;r=i&&t.indexOf("khtml")!==-1?{91:!0,93:!0}:i&&t.indexOf("firefox")!==-1?{224:!0}:{17:!0};n.metaTrackerReset=function(){n.metaKey=!1;n.ctrlKey=!1;n.shiftKey=!1;n.altKey=!1};n.metaTracker=function(t){var i=!!r[t.keyCode];return i&&(n.metaKey=t.type==="keydown"),n.ctrlKey=t.ctrlKey,n.shiftKey=t.shiftKey,n.altKey=t.altKey,i}}(),n}(Event.proxy);typeof Event=="undefined"&&(Event={});Event.MutationObserver=function(){var n=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,t=function(){var n=document.createElement("p"),t=!1,i=function(){t=!0};if(n.addEventListener)n.addEventListener("DOMAttrModified",i,!1);else if(n.attachEvent)n.attachEvent("onDOMAttrModified",i);else return!1;return n.setAttribute("id","target"),t}();return function(i,r){if(n){var u=new n(function(n){n.forEach(function(n){r.call(n.target,n.attributeName)})});u.observe(i,{subtree:!1,attributes:!0})}else t?Event.add(i,"DOMAttrModified",function(n){r.call(i,n.attrName)}):"onpropertychange"in document.body&&Event.add(i,"propertychange",function(){r.call(i,window.event.propertyName)})}}();typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.click=n.click,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.dbltap=n.dblclick=function(t){var o,r,u,e,s,f,i;return t.gesture=t.gesture||"dbltap",t.maxFingers=t.maxFingers||t.fingers||1,o=700,t.onPointerDown=function(h){var c=h.changedTouches||n.getCoords(h);r&&!u?(f=c[0],u=(new Date).getTime()-r):(s=c[0],r=(new Date).getTime(),u=0,clearTimeout(e),e=setTimeout(function(){r=0},o));n.pointerStart(h,i,t)&&(Event.add(t.doc,"mousemove",t.onPointerMove).listener(h),Event.add(t.doc,"mouseup",t.onPointerUp))},t.onPointerMove=function(i){var l,o,h,c;r&&!u&&(l=i.changedTouches||n.getCoords(i),f=l[0]);o=t.bbox;t.position==="relative"?(h=f.pageX+o.scrollLeft-o.x1,c=f.pageY+o.scrollTop-o.y1):(h=f.pageX-o.x1,c=f.pageY-o.y1);h>0&&h<o.width&&c>0&&c<o.height&&Math.abs(f.pageX-s.pageX)<=25&&Math.abs(f.pageY-s.pageY)<=25||(Event.remove(t.doc,"mousemove",t.onPointerMove),clearTimeout(e),r=u=0)},t.onPointerUp=function(f){var h,s;if(n.pointerEnd(f,i,t)&&(Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp)),r&&u){if(u<=o&&!(f.cancelBubble&&++f.bubble>1)){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;e<l;e++){var o=h[e],c=o.identifier||Infinity,f=t.tracker[c];f&&(f.pageX=o.pageX,f.pageY=o.pageY,i.state=u||"move",i.identifier=c,i.start=f.start,i.fingers=t.fingers,t.position==="differenceFromLast"?(i.x=f.pageX-f.offsetX,i.y=f.pageY-f.offsetY,f.offsetX=f.pageX,f.offsetY=f.pageY):t.position==="relative"?(i.x=f.pageX+s.scrollLeft-f.offsetX,i.y=f.pageY+s.scrollTop-f.offsetY):(i.x=f.pageX-f.offsetX,i.y=f.pageY-f.offsetY),t.listener(r,i))}};t.onPointerUp=function(r){n.pointerEnd(r,i,t,t.onPointerMove)&&(t.monitor||(Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp)))};var i=n.pointerSetup(t);if(t.event)t.onPointerDown(t.event);else Event.add(t.target,"mousedown",t.onPointerDown),t.monitor&&(Event.add(t.doc,"mousemove",t.onPointerMove),Event.add(t.doc,"mouseup",t.onPointerUp));return i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.drag=n.drag,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.pointerdown=n.pointerdown,Event.Gesture._gestureHandlers.pointermove=n.pointermove,Event.Gesture._gestureHandlers.pointerup=n.pointerup,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";return n.shake=function(n){var i={gesture:"devicemotion",acceleration:{},accelerationIncludingGravity:{},target:n.target,listener:n.listener,remove:function(){window.removeEventListener("devicemotion",u,!1)}},f=4,e=1e3,o=200,s=3,r=(new Date).getTime(),t={x:0,y:0,z:0},h={x:{count:0,value:0},y:{count:0,value:0},z:{count:0,value:0}},u=function(u){var l=.8,a=u.accelerationIncludingGravity,w,v,y,b,p,nt;if(t.x=l*t.x+(1-l)*a.x,t.y=l*t.y+(1-l)*a.y,t.z=l*t.z+(1-l)*a.z,i.accelerationIncludingGravity=t,i.acceleration.x=a.x-t.x,i.acceleration.y=a.y-t.y,i.acceleration.z=a.z-t.z,n.gesture==="devicemotion"){n.listener(u,i);return}for(w="xyz",v=(new Date).getTime(),y=0,b=w.length;y<b;y++){var k=w[y],d=i.acceleration[k],c=h[k],g=Math.abs(d);v-r<e||g>f&&(p=v*d/g,nt=Math.abs(p+c.value),c.value&&nt<o?(c.value=p,c.count++,c.count===s&&(n.listener(u,i),r=v,c.value=0,c.count=0)):(c.value=p,c.count=1))}};if(window.addEventListener)return window.addEventListener("devicemotion",u,!1),i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.shake=n.shake,n}(Event.proxy);typeof Event=="undefined"&&(Event={});typeof Event.proxy=="undefined"&&(Event.proxy={});Event.proxy=function(n){"use strict";var t=Math.PI/180;return n.swipe=function(i){i.snap=i.snap||90;i.threshold=i.threshold||1;i.gesture=i.gesture||"swipe";i.onPointerDown=function(t){n.pointerStart(t,r,i)&&(Event.add(i.doc,"mousemove",i.onPointerMove).listener(t),Event.add(i.doc,"mouseup",i.onPointerUp))};i.onPointerMove=function(t){for(var e=t.changedTouches||n.getCoords(t),o=e.length,u=0;u<o;u++){var f=e[u],s=f.identifier||Infinity,r=i.tracker[s];r&&(r.move.x=f.pageX,r.move.y=f.pageY,r.moveTime=(new Date).getTime())}};i.onPointerUp=function(u){var b,c;if(n.pointerEnd(u,r,i)){Event.remove(i.doc,"mousemove",i.onPointerMove);Event.remove(i.doc,"mouseup",i.onPointerUp);var o,y,e,l,s={x:0,y:0},p=0,w=0,h=0;for(b in i.tracker){var f=i.tracker[b],a=f.move.x-f.start.x,v=f.move.y-f.start.y;p+=f.move.x;w+=f.move.y;s.x+=f.start.x;s.y+=f.start.y;h++;var d=Math.sqrt(a*a+v*v),k=f.moveTime-f.startTime,l=Math.atan2(a,v)/t+180,y=k?d/k:0;if(typeof e=="undefined")e=l,o=y;else if(Math.abs(l-e)<=20)e=(e+l)/2,o=(o+y)/2;else return}c=i.gestureFingers;i.minFingers<=c&&i.maxFingers>=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;o<a;o++){var u=h[o],v=u.identifier||Infinity,s=t.tracker[v];if(s){t.position==="relative"?(f=u.pageX+r.scrollLeft-r.x1,e=u.pageY+r.scrollTop-r.y1):(f=u.pageX-r.x1,e=u.pageY-r.y1);var c=f-s.start.x,l=e-s.start.y,y=Math.sqrt(c*c+l*l);if(!(f>0&&f<r.width&&e>0&&e<r.height&&y<=t.driftDeviance)){Event.remove(t.doc,"mousemove",t.onPointerMove);t.cancel=!0;return}}}},t.onPointerUp=function(f){if(n.pointerEnd(f,i,t)){if(clearTimeout(u),Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp),f.cancelBubble&&++f.bubble>1)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<u;r++)i[r].call(this,t||{});return this}}fabric.Observable={observe:t,stopObserving:i,fire:r,on:t,off:i,trigger:r}}();fabric.Collection={add:function(){this._objects.push.apply(this._objects,arguments);for(var n=arguments.length;n--;)this._onObjectAdded(arguments[n]);return this.renderOnAddRemove&&this.renderAll(),this},insertAt:function(n,t,i){var r=this.getObjects();return i?r[t]=n:r.splice(t,0,n),this._onObjectAdded(n),this.renderOnAddRemove&&this.renderAll(),this},remove:function(n){var t=this.getObjects(),i=t.indexOf(n);return i!==-1&&(t.splice(i,1),this._onObjectRemoved(n)),this.renderOnAddRemove&&this.renderAll(),n},forEachObject:function(n,t){for(var i=this.getObjects(),r=i.length;r--;)n.call(t,i[r],r,i);return this},getObjects:function(n){return typeof n=="undefined"?this._objects:this._objects.filter(function(t){return t.type===n})},item:function(n){return this.getObjects()[n]},isEmpty:function(){return this.getObjects().length===0},size:function(){return this.getObjects().length},contains:function(n){return this.getObjects().indexOf(n)>-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;i<f;++i)r=r[u[i]];return r},loadImage:function(n,t,i,r){if(!n){t&&t.call(i,n);return}var u=fabric.util.createImage();u.onload=function(){t&&t.call(i,u);u=u.onload=u.onerror=null};u.onerror=function(){fabric.log("Error loading "+u.src);t&&t.call(i,null,!0);u=u.onload=u.onerror=null};n.indexOf("data")!==0&&typeof r!="undefined"&&(u.crossOrigin=r);u.src=n},enlivenObjects:function(n,t,i,r){function f(){++o===e&&t&&t(u)}n=n||[];var u=[],o=0,e=n.length;if(!e){t&&t(u);return}n.forEach(function(n,t){if(!n||!n.type){f();return}var e=fabric.util.getKlass(n.type,i);e.async?e.fromObject(n,function(i,e){e||(u[t]=i,r&&r(n,u[t]));f()}):(u[t]=e.fromObject(n),r&&r(n,u[t]),f())})},groupSVGElements:function(n,t,i){var r;return r=n.length>1?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;r<u;r++)i[r]in n&&(t[i[r]]=n[i[r]])},drawDashedLine:function(n,t,u,f,e,o){var s=f-t,h=e-u,c=i(s*s+h*h),a=r(h,s),v=o.length,y=0,l=!0;for(n.save(),n.translate(t,u),n.moveTo(0,0),n.rotate(a),t=0;c>t;)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;r<f;r++)n[r].x-=t.width/2+i||0,n[r].y-=t.height/2+u||0},isTransparent:function(n,t,i,r){var u,f,e,o,s;for(r>0&&(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;e<o;e+=4)if(s=f.data[e],u=s<=0,u===!1)break;return f=null,u}}}(typeof exports!="undefined"?exports:this),function(){function u(t,u,e,o,s,h,c,l,a){var w,b,k,p,it,rt;if(n=r.call(arguments),i[n])return i[n];var v=f(c,e,o,l,a,t,u),ut=(v.x1-v.x0)*(v.x1-v.x0)+(v.y1-v.y0)*(v.y1-v.y0),d=1/ut-.25;d<0&&(d=0);w=Math.sqrt(d);h===s&&(w=-w);var g=.5*(v.x0+v.x1)-w*(v.y1-v.y0),nt=.5*(v.y0+v.y1)+w*(v.x1-v.x0),tt=Math.atan2(v.y0-nt,v.x0-g),ft=Math.atan2(v.y1-nt,v.x1-g),y=ft-tt;for(y<0&&h===1?y+=2*Math.PI:y>0&&h===0&&(y-=2*Math.PI),b=Math.ceil(Math.abs(y/(Math.PI*.5+.001))),k=[],p=0;p<b;p++)it=tt+p*y/b,rt=tt+(p+1)*y/b,k[p]=[g,nt,it,rt,e,o,v.sin_th,v.cos_th];return i[n]=k,k}function f(n,t,i,r,u,f,e){var c=n*(Math.PI/180),o=Math.sin(c),s=Math.cos(c);t=Math.abs(t);i=Math.abs(i);var l=s*(r-f)*.5+o*(u-e)*.5,a=s*(u-e)*.5-o*(r-f)*.5,h=l*l/(t*t)+a*a/(i*i);h>1&&(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<o.length;f++)s=e.apply(this,o[f]),n.bezierCurveTo.apply(n,s)}}(),function(){function i(n,i){for(var u=t.call(arguments,2),f=[],r=0,e=n.length;r<e;r++)f[r]=u.length?n[r][i].apply(n[r],u):n[r][i].call(n[r]);return f}function r(t,i){return n(t,i,function(n,t){return n>=t})}function u(t,i){return n(t,i,function(n,t){return n<t})}function n(n,t,i){if(!n||n.length===0)return undefined;var r=n.length-1,u=t?n[r][t]:n[r];if(t)while(r--)i(n[r][t],u)&&(u=n[r][t]);else while(r--)i(n[r],u)&&(u=n[r]);return u}var t=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(n){var u,r,t,i;if(this===void 0||this===null)throw new TypeError;if((u=Object(this),r=u.length>>>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<r;i++)if(i in u&&u[i]===n)return i;return-1});Array.prototype.forEach||(Array.prototype.forEach=function(n,t){for(var i=0,r=this.length>>>0;i<r;i++)i in this&&n.call(t,this[i],i,this)});Array.prototype.map||(Array.prototype.map=function(n,t){for(var r=[],i=0,u=this.length>>>0;i<u;i++)i in this&&(r[i]=n.call(t,this[i],i,this));return r});Array.prototype.every||(Array.prototype.every=function(n,t){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&!n.call(t,this[i],i,this))return!1;return!0});Array.prototype.some||(Array.prototype.some=function(n,t){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&n.call(t,this[i],i,this))return!0;return!1});Array.prototype.filter||(Array.prototype.filter=function(n,t){for(var u=[],r,i=0,f=this.length>>>0;i<f;i++)i in this&&(r=this[i],n.call(t,r,i,this)&&u.push(r));return u});Array.prototype.reduce||(Array.prototype.reduce=function(n){var r=this.length>>>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<r;t++)t in this&&(i=n.call(null,i,this[t],t,this));return i});fabric.util.array={invoke:i,min:u,max:r}}(),function(){function n(n,t){for(var i in t)n[i]=t[i];return n}function t(t){return n({},t)}fabric.util.object={extend:n,clone:t}}(),function(){function n(n){return n.replace(/-+(.)?/g,function(n,t){return t?t.toUpperCase():""})}function t(n,t){return n.charAt(0).toUpperCase()+(t?n.slice(1):n.slice(1).toLowerCase())}function i(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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<h;s++)u(r,o[s],e);return r.prototype.initialize||(r.prototype.initialize=i),r.prototype.constructor=r,r.prototype.callSuper=f,r}var n=Array.prototype.slice,i=function(){},r=function(){for(var n in{toString:1})if(n==="toString")return!1;return!0}(),u=function(n,t,i){for(var u in t)n.prototype[u]=u in n.prototype&&typeof n.prototype[u]=="function"&&(t[u]+"").indexOf("callSuper")>-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<u;t++)if(r=typeof n[i[t]],!/^(?:function|object|unknown)$/.test(r))return!1;return!0}function a(n,t){return{handler:t,wrappedHandler:v(n,t)}}function v(n,t){return function(i){t.call(h(n),i||fabric.window.event)}}function y(t,i){return function(r){var f,u,e;if(n[t]&&n[t][i])for(f=n[t][i],u=0,e=f.length;u<e;u++)f[u].call(this,r||fabric.window.event)}}function b(n,t){n||(n=fabric.window.event);var r=n.target||(typeof n.srcElement!==e?n.srcElement:null),i=fabric.util.getScrollLeftTop(r,t);return{x:o(n)+i.left,y:s(n)+i.top}}function l(n,t,i){var r=n.type==="touchend"?"changedTouches":"touches";return n[r]&&n[r][0]?n[r][0][t]-(n[r][0][t]-n[r][0][i])||n[i]:n[i]}var e="unknown",r=function(){var n=0;return function(t){return t.__uniqueID||(t.__uniqueID="uniqueID__"+n++)}}(),h,c,o,s;(function(){var n={};h=function(t){return n[t]};c=function(t,i){n[t]=i}})();var p=i(fabric.document.documentElement,"addEventListener","removeEventListener")&&i(fabric.window,"addEventListener","removeEventListener"),w=i(fabric.document.documentElement,"attachEvent","detachEvent")&&i(fabric.window,"attachEvent","detachEvent"),t={},n={},u,f;p?(u=function(n,t,i){n.addEventListener(t,i,!1)},f=function(n,t,i){n.removeEventListener(t,i,!1)}):w?(u=function(n,i,u){var f=r(n),e;c(f,n);t[f]||(t[f]={});t[f][i]||(t[f][i]=[]);e=a(f,u);t[f][i].push(e);n.attachEvent("on"+i,e.wrappedHandler)},f=function(n,i,u){var f=r(n),o,e,s;if(t[f]&&t[f][i])for(e=0,s=t[f][i].length;e<s;e++)o=t[f][i][e],o&&o.handler===u&&(n.detachEvent("on"+i,o.wrappedHandler),t[f][i][e]=null)}):(u=function(t,i,u){var f=r(t),e;n[f]||(n[f]={});n[f][i]||(n[f][i]=[],e=t["on"+i],e&&n[f][i].push(e),t["on"+i]=y(f,i));n[f][i].push(u)},f=function(t,i,u){var o=r(t),e,f,s;if(n[o]&&n[o][i])for(e=n[o][i],f=0,s=e.length;f<s;f++)e[f]===u&&e.splice(f,1)});fabric.util.addListener=u;fabric.util.removeListener=f;o=function(n){return typeof n.clientX!==e?n.clientX:0};s=function(n){return typeof n.clientY!==e?n.clientY:0};fabric.isTouchSupported&&(o=function(n){return l(n,"pageX","clientX")},s=function(n){return l(n,"pageY","clientY")});fabric.util.getPointer=b;fabric.util.object.extend(fabric.util,fabric.Observable)}(),function(){function r(t,i){var u=t.style,r,f;if(!u)return t;if(typeof i=="string")return t.style.cssText+=";"+i,i.indexOf("opacity")>-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<Math.abs(t)?(n=t,r=i/4):r=i/(2*Math.PI)*Math.asin(t/n),{a:n,c:t,p:i,s:r}}function i(n,t,i){return n.a*Math.pow(2,10*(t-=1))*Math.sin((t*i-n.s)*2*Math.PI/n.p)}function u(n,t,i,r){return i*((n=n/r-1)*n*n+1)+t}function f(n,t,i,r){return(n/=r/2,n<1)?i/2*n*n*n+t:i/2*((n-=2)*n*n+2)+t}function e(n,t,i,r){return i*(n/=r)*n*n*n+t}function o(n,t,i,r){return-i*((n=n/r-1)*n*n*n-1)+t}function s(n,t,i,r){return(n/=r/2,n<1)?i/2*n*n*n*n+t:-i/2*((n-=2)*n*n*n-2)+t}function h(n,t,i,r){return i*(n/=r)*n*n*n*n+t}function c(n,t,i,r){return i*((n=n/r-1)*n*n*n*n+1)+t}function l(n,t,i,r){return(n/=r/2,n<1)?i/2*n*n*n*n*n+t:i/2*((n-=2)*n*n*n*n+2)+t}function a(n,t,i,r){return-i*Math.cos(n/r*(Math.PI/2))+i+t}function v(n,t,i,r){return i*Math.sin(n/r*(Math.PI/2))+t}function y(n,t,i,r){return-i/2*(Math.cos(Math.PI*n/r)-1)+t}function p(n,t,i,r){return n===0?t:i*Math.pow(2,10*(n/r-1))+t}function w(n,t,i,r){return n===r?t+i:i*(-Math.pow(2,-10*n/r)+1)+t}function b(n,t,i,r){return n===0?t:n===r?t+i:(n/=r/2,n<1)?i/2*Math.pow(2,10*(n-1))+t:i/2*(-Math.pow(2,-10*--n)+2)+t}function k(n,t,i,r){return-i*(Math.sqrt(1-(n/=r)*n)-1)+t}function d(n,t,i,r){return i*Math.sqrt(1-(n=n/r-1)*n)+t}function g(n,t,i,r){return(n/=r/2,n<1)?-i/2*(Math.sqrt(1-n*n)-1)+t:i/2*(Math.sqrt(1-(n-=2)*n)+1)+t}function nt(t,r,u,f){var e=0,s=u,o;return t===0?r:(t/=f,t===1)?r+u:(e||(e=f*.3),o=n(s,u,e,1.70158),-i(o,t,f)+r)}function tt(t,i,r,u){var e=0,o=r,f;return t===0?i:(t/=u,t===1)?i+r:(e||(e=u*.3),f=n(o,r,e,1.70158),f.a*Math.pow(2,-10*t)*Math.sin((t*u-f.s)*2*Math.PI/f.p)+f.c+i)}function it(t,r,u,f){var o=0,s=u,e;return t===0?r:(t/=f/2,t===2)?r+u:(o||(o=f*.3*1.5),e=n(s,u,o,1.70158),t<1)?-.5*i(e,t,f)+r:e.a*Math.pow(2,-10*(t-=1))*Math.sin((t*f-e.s)*2*Math.PI/e.p)*.5+e.c+r}function rt(n,t,i,r,u){return u===undefined&&(u=1.70158),i*(n/=r)*n*((u+1)*n-u)+t}function ut(n,t,i,r,u){return u===undefined&&(u=1.70158),i*((n=n/r-1)*n*((u+1)*n+u)+1)+t}function ft(n,t,i,r,u){return(u===undefined&&(u=1.70158),n/=r/2,n<1)?i/2*n*n*(((u*=1.525)+1)*n-u)+t:i/2*((n-=2)*n*(((u*=1.525)+1)*n+u)+2)+t}function r(n,i,r,u){return r-t(u-n,0,r,u)+i}function t(n,t,i,r){return(n/=r)<1/2.75?i*7.5625*n*n+t:n<2/2.75?i*(7.5625*(n-=1.5/2.75)*n+.75)+t:n<2.5/2.75?i*(7.5625*(n-=2.25/2.75)*n+.9375)+t:i*(7.5625*(n-=2.625/2.75)*n+.984375)+t}function et(n,i,u,f){return n<f/2?r(n*2,0,u,f)*.5+i:t(n*2-f,0,u,f)*.5+u*.5+i}fabric.util.ease={easeInQuad:function(n,t,i,r){return i*(n/=r)*n+t},easeOutQuad:function(n,t,i,r){return-i*(n/=r)*(n-2)+t},easeInOutQuad:function(n,t,i,r){return(n/=r/2,n<1)?i/2*n*n+t:-i/2*(--n*(n-2)-1)+t},easeInCubic:function(n,t,i,r){return i*(n/=r)*n*n+t},easeOutCubic:u,easeInOutCubic:f,easeInQuart:e,easeOutQuart:o,easeInOutQuart:s,easeInQuint:h,easeOutQuint:c,easeInOutQuint:l,easeInSine:a,easeOutSine:v,easeInOutSine:y,easeInExpo:p,easeOutExpo:w,easeInOutExpo:b,easeInCirc:k,easeOutCirc:d,easeInOutCirc:g,easeInElastic:nt,easeOutElastic:tt,easeInOutElastic:it,easeInBack:rt,easeOutBack:ut,easeInOutBack:ft,easeInBounce:r,easeOutBounce:t,easeInOutBounce:et}}(),function(n){"use strict";function f(n){return n in o?o[n]:n}function e(n,i,r){var u,f;return(n==="fill"||n==="stroke")&&i==="none"?i="":n==="fillRule"?i=i==="evenodd"?"destination-over":i:n==="strokeDashArray"?i=i.replace(/,/g," ").split(/\s+/):n==="transformMatrix"&&(i=r&&r.transformMatrix?v(r.transformMatrix,t.parseTransformAttribute(i)):t.parseTransformAttribute(i)),u=Object.prototype.toString.call(i)==="[object Array]",f=u?i.map(parseFloat):parseFloat(i),!u&&isNaN(f)?i:f}function y(n){var i,u;for(i in r)n[i]&&typeof n[r[i]]!="undefined"&&n[i].indexOf("url(")!==0&&(u=new t.Color(n[i]),n[i]=u.setAlpha(a(u.getAlpha()*n[r[i]],2)).toRgba(),delete n[r[i]]);return n}function s(n,t){var i=n.match(/(normal|italic)?\s*(normal|small-caps)?\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\s*(\d+)px(?:\/(normal|[\d\.]+))?\s+(.*)/);if(i){var f=i[1],r=i[3],e=i[4],u=i[5],o=i[6];f&&(t.fontStyle=f);r&&(t.fontSize=isNaN(parseFloat(r))?r:parseFloat(r));e&&(t.fontSize=parseFloat(e));o&&(t.fontFamily=o);u&&(t.lineHeight=u==="normal"?1:u)}}function p(n,t){var i,r;n.replace(/;$/,"").split(";").forEach(function(n){var u=n.split(":");i=f(u[0].trim().toLowerCase());r=e(i,u[1].trim());i==="font"?s(r,t):t[i]=r})}function w(n,t){var i,r;for(var u in n)typeof n[u]!="undefined"&&(i=f(u.toLowerCase()),r=e(i,n[u]),i==="font"?s(r,t):t[i]=r)}function b(n){var s=n.nodeName,u=n.getAttribute("class"),f=n.getAttribute("id"),e={},i,o,r;for(i in t.cssRules)if(o=u&&new RegExp("^\\."+u).test(i)||f&&new RegExp("^#"+f).test(i)||new RegExp("^"+s).test(i),o)for(r in t.cssRules[i])e[r]=t.cssRules[i][r];return e}function k(n){var i=n.objects,r=n.options;return i=i.map(function(n){return t[c(n.type)].fromObject(n)}),{objects:i,options:r}}function h(n,t,i){t[i]&&t[i].toSVG&&n.push('<pattern x="0" y="0" id="',i,'Pattern" ','width="',t[i].source.width,'" height="',t[i].source.height,'" patternUnits="userSpaceOnUse">','<image x="0" y="0" ','width="',t[i].source.width,'" height="',t[i].source.height,'" xlink:href="',t[i].source.src,'"><\/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<b;h++)y[h]=o[h];o=y}if(c=o.filter(function(n){return i.test(n.tagName)&&!u(n,/^(?:pattern|defs)$/)}),c&&(!c||c.length)){var s=n.getAttribute("viewBox"),k=n.getAttribute("width"),d=n.getAttribute("height"),a=null,v=null,g,nt;s&&(s=s.match(r))&&(g=parseInt(s[1],10),nt=parseInt(s[2],10),a=parseInt(s[3],10),v=parseInt(s[4],10));a=k?parseFloat(k):a;v=d?parseFloat(d):v;p={width:a,height:v};t.gradientDefs=t.getGradientDefs(n);t.cssRules=t.getCSSRules(n);t.parseElements(c,function(n){t.documentParsingTime=new Date-w;f&&f(n,p)},l(p),e)}}}}();u={has:function(n,t){t(!1)},get:function(){},set:function(){}};i(t,{resolveGradients:function(n){for(var r,u,i=n.length;i--;)(r=n[i].get("fill"),/^url\(/.test(r))&&(u=r.slice(5,r.length-1),t.gradientDefs[u]&&n[i].set("fill",t.Gradient.fromElement(t.gradientDefs[u],n[i])))},getGradientDefs:function(n){for(var u=n.getElementsByTagName("linearGradient"),f=n.getElementsByTagName("radialGradient"),t,r={},i=u.length;i--;)t=u[i],r[t.getAttribute("id")]=t;for(i=f.length;i--;)t=f[i],r[t.getAttribute("id")]=t;return r},parseAttributes:function(n,r){var u,o,s;if(n)return o={},n.parentNode&&/^g$/i.test(n.parentNode.nodeName)&&(o=t.parseAttributes(n.parentNode,r)),s=r.reduce(function(t,i){return u=n.getAttribute(i),u&&(i=f(i),u=e(i,u,o),t[i]=u),t},{}),s=i(s,i(b(n),t.parseStyleAttribute(n))),y(i(o,s))},parseElements:function(n,i,r,u){t.ElementsParser.parse(n,i,r,u)},parseStyleAttribute:function(n){var t={},i=n.getAttribute("style");return i?(typeof i=="string"?p(i,t):w(i,t),t):t},parsePointsAttribute:function(n){var f,i,t,r,u;if(!n)return null;if(n=n.trim(),f=n.indexOf(",")>-1,n=n.split(/\s+/),i=[],f)for(t=0,r=n.length;t<r;t++)u=n[t].split(","),i.push({x:parseFloat(u[0]),y:parseFloat(u[1])});else for(t=0,r=n.length;t<r;t+=2)i.push({x:parseFloat(n[t]),y:parseFloat(n[t+1])});return i.length%2!=0,i},getCSSRules:function(n){for(var r,u=n.getElementsByTagName("style"),t={},i,f=0,e=u.length;f<e;f++)r=u[0].textContent,r=r.replace(/\/\*[\s\S]*?\*\//g,""),i=r.match(/[^{]*\{[\s\S]*?\}/g),i=i.map(function(n){return n.trim()}),i.forEach(function(n){var u=n.match(/([\s\S]*?)\s*\{([^}]*)\}/),f,r,i,e;for(n=u[1],f=u[2].trim(),r=f.replace(/;$/,"").split(/\s*;\s*/),t[n]||(t[n]={}),i=0,e=r.length;i<e;i++){var o=r[i].split(/\s*:\s*/),s=o[0],h=o[1];t[n][s]=h}});return t},loadSVGFromURL:function(n,i,r){function f(f){var e=f.responseXML;(!e.documentElement&&t.window.ActiveXObject&&f.responseText&&(e=new ActiveXObject("Microsoft.XMLDOM"),e.async="false",e.loadXML(f.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/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(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));t.parseSVGDocument(u.documentElement,function(n,t){i(n,t)},r)},createSVGFontFacesMarkup:function(n){for(var i="",t=0,r=n.length;t<r;t++)n[t].type==="text"&&n[t].path&&(i+=["@font-face {","font-family: ",n[t].fontFamily,"; ","src: url('",n[t].path,"')","}"].join(""));return i&&(i=['<style type="text/css">',"<![CDATA[",i,"]\]>","<\/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;n<t;n++)this.createObject(this.elements[n],n)},createObject:function(n,t){var i=fabric[fabric.util.string.capitalize(n.tagName)];if(i&&i.fromElement)try{this._createObject(i,n,t)}catch(r){fabric.log(r)}else this.checkIfDone()},_createObject:function(n,t,i){if(n.async)n.fromElement(t,this.createCallback(i,t),this.options);else{var r=n.fromElement(t,this.options);this.reviver&&this.reviver(t,r);this.instances.splice(i,0,r);this.checkIfDone()}},createCallback:function(n,t){var i=this;return function(r){i.reviver&&i.reviver(t,r);i.instances.splice(n,0,r);i.checkIfDone()}},checkIfDone:function(){--this.numElements==0&&(this.instances=this.instances.filter(function(n){return n!=null}),fabric.resolveGradients(this.instances),this.callback(this.instances))}},function(n){"use strict";function t(n,t){this.x=n;this.y=t}var i=n.fabric||(n.fabric={});if(i.Point){i.warn("fabric.Point is already defined");return}i.Point=t;t.prototype={constructor:t,add:function(n){return new t(this.x+n.x,this.y+n.y)},addEquals:function(n){return this.x+=n.x,this.y+=n.y,this},scalarAdd:function(n){return new t(this.x+n,this.y+n)},scalarAddEquals:function(n){return this.x+=n,this.y+=n,this},subtract:function(n){return new t(this.x-n.x,this.y-n.y)},subtractEquals:function(n){return this.x-=n.x,this.y-=n.y,this},scalarSubtract:function(n){return new t(this.x-n,this.y-n)},scalarSubtractEquals:function(n){return this.x-=n,this.y-=n,this},multiply:function(n){return new t(this.x*n,this.y*n)},multiplyEquals:function(n){return this.x*=n,this.y*=n,this},divide:function(n){return new t(this.x/n,this.y/n)},divideEquals:function(n){return this.x/=n,this.y/=n,this},eq:function(n){return this.x===n.x&&this.y===n.y},lt:function(n){return this.x<n.x&&this.y<n.y},lte:function(n){return this.x<=n.x&&this.y<=n.y},gt:function(n){return this.x>n.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;f<e;f++){var o=r[f],s=r[(f+1)%e],h=t.intersectLineLine(n,i,o,s);u.appendPoints(h.points)}return u.points.length>0&&(u.status="Intersection"),u};i.Intersection.intersectPolygonPolygon=function(n,i){for(var r=new t,f=n.length,u=0;u<f;u++){var e=n[u],o=n[(u+1)%f],s=t.intersectLinePolygon(e,o,i);r.appendPoints(s.points)}return r.points.length>0&&(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<r?6:0);break;case t:f=(r-n)/o+2;break;case r:f=(n-t)/o+4}f/=6}return[Math.round(f*360),Math.round(s*100),Math.round(h*100)]},getSource:function(){return this._source},setSource:function(n){this._source=n},toRgb:function(){var n=this.getSource();return"rgb("+n[0]+","+n[1]+","+n[2]+")"},toRgba:function(){var n=this.getSource();return"rgba("+n[0]+","+n[1]+","+n[2]+","+n[3]+")"},toHsl:function(){var n=this.getSource(),t=this._rgbToHsl(n[0],n[1],n[2]);return"hsl("+t[0]+","+t[1]+"%,"+t[2]+"%)"},toHsla:function(){var n=this.getSource(),t=this._rgbToHsl(n[0],n[1],n[2]);return"hsla("+t[0]+","+t[1]+"%,"+t[2]+"%,"+n[3]+")"},toHex:function(){var r=this.getSource(),i=r[0].toString(16),n,t;return i=i.length===1?"0"+i:i,n=r[1].toString(16),n=n.length===1?"0"+n:n,t=r[2].toString(16),t=t.length===1?"0"+t:t,i.toUpperCase()+n.toUpperCase()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(n){var t=this.getSource();return t[3]=n,this.setSource(t),this},toGrayscale:function(){var n=this.getSource(),t=parseInt((n[0]*.3+n[1]*.59+n[2]*.11).toFixed(0),10),i=n[3];return this.setSource([t,t,t,i]),this},toBlackWhite:function(n){var i=this.getSource(),t=(i[0]*.3+i[1]*.59+i[2]*.11).toFixed(0),r=i[3];return n=n||127,t=Number(t)<Number(n)?0:255,this.setSource([t,t,t,r]),this},overlayWith:function(n){var i;n instanceof t||(n=new t(n));var r=[],f=this.getAlpha(),u=.5,e=this.getSource(),o=n.getSource();for(i=0;i<3;i++)r.push(Math.round(e[i]*(1-u)+o[i]*u));return r[3]=f,this.setSource(r),this}};i.Color.reRGBa=/^rgba?\(\s*(\d{1,3}\%?)\s*,\s*(\d{1,3}\%?)\s*,\s*(\d{1,3}\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;i.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;i.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;i.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"};i.Color.fromRgb=function(n){return t.fromSource(t.sourceFromRgb(n))};i.Color.sourceFromRgb=function(n){var i=n.match(t.reRGBa);if(i){var r=parseInt(i[1],10)/(/%$/.test(i[1])?100:1)*(/%$/.test(i[1])?255:1),u=parseInt(i[2],10)/(/%$/.test(i[2])?100:1)*(/%$/.test(i[2])?255:1),f=parseInt(i[3],10)/(/%$/.test(i[3])?100:1)*(/%$/.test(i[3])?255:1);return[parseInt(r,10),parseInt(u,10),parseInt(f,10),i[4]?parseFloat(i[4]):1]}};i.Color.fromRgba=t.fromRgb;i.Color.fromHsl=function(n){return t.fromSource(t.sourceFromHsl(n))};i.Color.sourceFromHsl=function(n){var i=n.match(t.reHSLa),f,o;if(i){var s=(parseFloat(i[1])%360+360)%360/360,e=parseFloat(i[2])/(/%$/.test(i[2])?100:1),u=parseFloat(i[3])/(/%$/.test(i[3])?100:1),h,c,l;return e===0?h=c=l=u:(f=u<=.5?u*(e+1):u+e-u*e,o=u*2-f,h=r(o,f,s+1/3),c=r(o,f,s),l=r(o,f,s-1/3)),[Math.round(h*255),Math.round(c*255),Math.round(l*255),i[4]?parseFloat(i[4]):1]}};i.Color.fromHsla=t.fromHsl;i.Color.fromHex=function(n){return t.fromSource(t.sourceFromHex(n))};i.Color.sourceFromHex=function(n){if(n.match(t.reHex)){var i=n.slice(n.indexOf("#")+1),r=i.length===3,u=r?i.charAt(0)+i.charAt(0):i.substring(0,2),f=r?i.charAt(1)+i.charAt(1):i.substring(2,4),e=r?i.charAt(2)+i.charAt(2):i.substring(4,6);return[parseInt(u,16),parseInt(f,16),parseInt(e,16),1]}};i.Color.fromSource=function(n){var i=new t;return i.setSource(n),i}}(typeof exports!="undefined"?exports:this),function(){function i(n){var e=n.getAttribute("style"),u=n.getAttribute("offset"),t,r,i,f;if(u=parseFloat(u)/(/%$/.test(u)?100:1),e)for(i=e.split(/\s*;\s*/),i[i.length-1]===""&&i.pop(),f=i.length;f--;){var o=i[f].split(/\s*:\s*/),s=o[0].trim(),h=o[1].trim();s==="stop-color"?t=h:s==="stop-opacity"&&(r=h)}return t||(t=n.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=n.getAttribute("stop-opacity")),t=new fabric.Color(t).toRgb(),{offset:u,color:t,opacity:isNaN(parseFloat(r))?1:parseFloat(r)}}function r(n){return{x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0}}function u(n){return{x1:n.getAttribute("fx")||n.getAttribute("cx")||"50%",y1:n.getAttribute("fy")||n.getAttribute("cy")||"50%",r1:0,x2:n.getAttribute("cx")||"50%",y2:n.getAttribute("cy")||"50%",r2:n.getAttribute("r")||"50%"}}function n(n,i){var r,u;for(r in i)typeof i[r]=="string"&&/^\d+%$/.test(i[r])&&(u=parseFloat(i[r],10),r==="x1"||r==="x2"||r==="r2"?i[r]=fabric.util.toFixed(n.width*u/100,2):(r==="y1"||r==="y2")&&(i[r]=fabric.util.toFixed(n.height*u/100,2))),t(i,r,n)}function t(n,t,i){t==="x1"||t==="x2"?n[t]-=fabric.util.toFixed(i.width/2,2):(t==="y1"||t==="y2")&&(n[t]-=fabric.util.toFixed(i.height/2,2))}function f(n,i){for(var r in i)t(i,r,n),r==="x1"||r==="x2"||r==="r2"?i[r]=fabric.util.toFixed(i[r]/n.width*100,2)+"%":(r==="y1"||r==="y2")&&(i[r]=fabric.util.toFixed(i[r]/n.height*100,2)+"%")}fabric.Gradient=fabric.util.createClass({initialize:function(n){n||(n={});var t={};this.id=fabric.Object.__uid++;this.type=n.type||"linear";t={x1:n.coords.x1||0,y1:n.coords.y1||0,x2:n.coords.x2||0,y2:n.coords.y2||0};this.type==="radial"&&(t.r1=n.coords.r1||0,t.r2=n.coords.r2||0);this.coords=t;this.gradientUnits=n.gradientUnits||"objectBoundingBox";this.colorStops=n.colorStops.slice()},addColorStop:function(n){var t,i;for(t in n)i=new fabric.Color(n[t]),this.colorStops.push({offset:t,color:i.toRgb(),opacity:i.getAlpha()});return this},toObject:function(){return{type:this.type,coords:this.coords,gradientUnits:this.gradientUnits,colorStops:this.colorStops}},toSVG:function(n,t){var i=fabric.util.object.clone(this.coords),u,r;for(this.colorStops.sort(function(n,t){return n.offset-t.offset}),t&&this.gradientUnits==="userSpaceOnUse"?(i.x1+=n.width/2,i.y1+=n.height/2,i.x2+=n.width/2,i.y2+=n.height/2):this.gradientUnits==="objectBoundingBox"&&f(n,i),this.type==="linear"?u=["<linearGradient ",'id="SVGID_',this.id,'" gradientUnits="',this.gradientUnits,'" x1="',i.x1,'" y1="',i.y1,'" x2="',i.x2,'" y2="',i.y2,'">']:this.type==="radial"&&(u=["<radialGradient ",'id="SVGID_',this.id,'" gradientUnits="',this.gradientUnits,'" cx="',i.x2,'" cy="',i.y2,'" r="',i.r2,'" fx="',i.x1,'" fy="',i.y1,'">']),r=0;r<this.colorStops.length;r++)u.push("<stop ",'offset="',this.colorStops[r].offset*100+"%",'" style="stop-color:',this.colorStops[r].color,this.colorStops[r].opacity?";stop-opacity: "+this.colorStops[r].opacity:";",'"/>');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<u;t++){var r=this.colorStops[t].color,f=this.colorStops[t].opacity,e=this.colorStops[t].offset;typeof f!="undefined"&&(r=new fabric.Color(r).setAlpha(f).toRgba());i.addColorStop(parseFloat(e),r)}return i}}});fabric.util.object.extend(fabric.Gradient,{fromElement:function(t,f){var h=t.getElementsByTagName("stop"),o=t.nodeName==="linearGradient"?"linear":"radial",l=t.getAttribute("gradientUnits")||"objectBoundingBox",c=[],e={},s;for(o==="linear"?e=r(t):o==="radial"&&(e=u(t)),s=h.length;s--;)c.push(i(h[s]));return n(f,e),new fabric.Gradient({type:o,coords:e,gradientUnits:l,colorStops:c})},forObject:function(t,i){return i||(i={}),n(t,i),new fabric.Gradient(i)}})}();fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(n){if(n||(n={}),this.id=fabric.Object.__uid++,n.source)if(typeof n.source=="string")if(typeof fabric.util.getFunctionBody(n.source)!="undefined")this.source=new Function(fabric.util.getFunctionBody(n.source));else{var t=this;this.source=fabric.util.createImage();fabric.util.loadImage(n.source,function(n){t.source=n})}else this.source=n.source;n.repeat&&(this.repeat=n.repeat);n.offsetX&&(this.offsetX=n.offsetX);n.offsetY&&(this.offsetY=n.offsetY)},toObject:function(){var n;return typeof this.source=="function"?n=String(this.source):typeof this.source.src=="string"&&(n=this.source.src),{source:n,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(n){var t=typeof this.source=="function"?this.source():this.source,r=t.width/n.getWidth(),u=t.height/n.getHeight(),i="";return t.src?i=t.src:t.toDataURL&&(i=t.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+this.offsetX+'" y="'+this.offsetY+'" width="'+r+'" height="'+u+'"><image x="0" y="0" width="'+t.width+'" height="'+t.height+'" xlink:href="'+i+'"><\/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"),'<filter id="SVGID_'+this.id+'" y="-40%" height="180%"><feGaussianBlur in="'+t+'" stdDeviation="'+(this.blur?this.blur/3:0)+'"><\/feGaussianBlur><feOffset dx="'+this.offsetX+'" dy="'+this.offsetY+'"><\/feOffset><feMerge><feMergeNode><\/feMergeNode><feMergeNode in="SourceGraphic"><\/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<r;++i)(!t||t&&this._objects[i]&&!t.contains(this._objects[i]))&&this._draw(n,this._objects[i])},_renderActiveGroup:function(n,t){if(t){var i=[];this.forEachObject(function(n){t.contains(n)&&i.push(n)});t._set("objects",i);this._draw(n,t)}},_renderBackground:function(n){this.backgroundColor&&(n.fillStyle=this.backgroundColor.toLive?this.backgroundColor.toLive(n):this.backgroundColor,n.fillRect(this.backgroundColor.offsetX||0,this.backgroundColor.offsetY||0,this.width,this.height));this.backgroundImage&&this.backgroundImage.render(n)},_renderOverlay:function(n){this.overlayColor&&(n.fillStyle=this.overlayColor.toLive?this.overlayColor.toLive(n):this.overlayColor,n.fillRect(this.overlayColor.offsetX||0,this.overlayColor.offsetY||0,this.width,this.height));this.overlayImage&&this.overlayImage.render(n)},renderTop:function(){var n=this.contextTop||this.contextContainer,t;return this.clearContext(n),this.selection&&this._groupSelector&&this._drawSelection(),t=this.getActiveGroup(),t&&t.render(n),this.overlayImage&&n.drawImage(this.overlayImage,this.overlayImageLeft,this.overlayImageTop),this.fire("after:render"),this},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(n){return this._centerObject(n,new fabric.Point(this.getCenter().left,n.getCenterPoint().y)),this.renderAll(),this},centerObjectV:function(n){return this._centerObject(n,new fabric.Point(n.getCenterPoint().x,this.getCenter().top)),this.renderAll(),this},centerObject:function(n){var t=this.getCenter();return this._centerObject(n,new fabric.Point(t.left,t.top)),this.renderAll(),this},_centerObject:function(n,t){return n.setPositionByOrigin(t,"center","center"),this},toDatalessJSON:function(n){return this.toDatalessObject(n)},toObject:function(n){return this._toObjectMethod("toObject",n)},toDatalessObject:function(n){return this._toObjectMethod("toDatalessObject",n)},_toObjectMethod:function(t,i){var r=this.getActiveGroup(),u;return r&&this.discardActiveGroup(),u={objects:this._toObjects(t,i)},n(u,this.__serializeBgOverlay()),fabric.util.populateWithProperties(this,u,i),r&&(this.setActiveGroup(new fabric.Group(r.getObjects())),r.forEachObject(function(n){n.set("active",!0)})),u},_toObjects:function(n,t){return this.getObjects().map(function(i){return this._toObject(i,n,t)},this)},_toObject:function(n,t,i){var r,u;return this.includeDefaultValues||(r=n.includeDefaultValues,n.includeDefaultValues=!1),u=n[t](i),this.includeDefaultValues||(n.includeDefaultValues=r),u},__serializeBgOverlay:function(){var n={background:this.backgroundColor&&this.backgroundColor.toObject?this.backgroundColor.toObject():this.backgroundColor};return this.overlayColor&&(n.overlay=this.overlayColor.toObject?this.overlayColor.toObject():this.overlayColor),this.backgroundImage&&(n.backgroundImage=this.backgroundImage.toObject()),this.overlayImage&&(n.overlayImage=this.overlayImage.toObject()),n},toSVG:function(n,t){n||(n={});var i=[];return this._setSVGPreamble(i,n),this._setSVGHeader(i,n),this._setSVGBgOverlayColor(i,"backgroundColor"),this._setSVGBgOverlayImage(i,"backgroundImage"),this._setSVGObjects(i,t),this._setSVGBgOverlayColor(i,"overlayColor"),this._setSVGBgOverlayImage(i,"overlayImage"),i.push("<\/svg>"),i.join("")},_setSVGPreamble:function(n,t){t.suppressPreamble||n.push('<?xml version="1.0" encoding="',t.encoding||"UTF-8",'" standalone="no" ?>','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(n,t){n.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',t.viewBox?t.viewBox.width:this.width,'" ','height="',t.viewBox?t.viewBox.height:this.height,'" ',this.backgroundColor&&!this.backgroundColor.toLive?'style="background-color: '+this.backgroundColor+'" ':null,t.viewBox?'viewBox="'+t.viewBox.x+" "+t.viewBox.y+" "+t.viewBox.width+" "+t.viewBox.height+'" ':null,'xml:space="preserve">',"<desc>Created with Fabric.js ",fabric.version,"<\/desc>","<defs>",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<f;r++)n.push(u[r].toSVG(t));i&&(this.setActiveGroup(new fabric.Group(i.getObjects())),i.forEachObject(function(n){n.set("active",!0)}))},_setSVGBgOverlayImage:function(n,t){this[t]&&this[t].toSVG&&n.push(this[t].toSVG())},_setSVGBgOverlayColor:function(n,t){this[t]&&this[t].source?n.push('<rect x="',this[t].offsetX,'" y="',this[t].offsetY,'" ','width="',this[t].repeat==="repeat-y"||this[t].repeat==="no-repeat"?this[t].source.width:this.width,'" height="',this[t].repeat==="repeat-x"||this[t].repeat==="no-repeat"?this[t].source.height:this.height,'" fill="url(#'+t+'Pattern)"',"><\/rect>"):this[t]&&t==="overlayColor"&&n.push('<rect x="0" y="0" ','width="',this.width,'" height="',this.height,'" fill="',this[t],'"',"><\/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<this._objects.length;++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},moveTo:function(n,i){return t(this._objects,n),this._objects.splice(i,0,n),this.renderAll&&this.renderAll()},dispose:function(){return this.clear(),this.interactive&&this.removeListeners(),this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"}});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;r<f;r++)u=n.midPointFrom(t),i.quadraticCurveTo(n.x,n.y,u.x,u.y),n=this._points[r],t=this._points[r+1];i.lineTo(n.x,n.y);i.stroke()},_getSVGPathData:function(){return this.box=this.getPathBoundingBox(this._points),this.convertPointsToSVGPath(this._points,this.box.minx,this.box.maxx,this.box.miny,this.box.maxy)},getPathBoundingBox:function(i){for(var o,r=[],u=[],f=i[0],h=i[1],s=f,e=1,c=i.length;e<c;e++)o=f.midPointFrom(h),r.push(s.x),r.push(o.x),u.push(s.y),u.push(o.y),f=i[e],h=i[e+1],s=o;return r.push(f.x),u.push(f.y),{minx:n(r),miny:n(u),maxx:t(r),maxy:t(u)}},convertPointsToSVGPath:function(n,t,i,r){var e=[],f=new fabric.Point(n[0].x-t,n[0].y-r),s=new fabric.Point(n[1].x-t,n[1].y-r),u,h,o;for(e.push("M ",n[0].x-t," ",n[0].y-r," "),u=1,h=n.length;u<h;u++)o=f.midPointFrom(s),e.push("Q ",f.x," ",f.y," ",o.x," ",o.y," "),f=new fabric.Point(n[u].x-t,n[u].y-r),u+1<n.length&&(s=new fabric.Point(n[u+1].x-t,n[u+1].y-r));return e.push("L ",f.x," ",f.y," "),e},createPath:function(n){var t=new fabric.Path(n);return t.fill=null,t.stroke=this.color,t.strokeWidth=this.width,t.strokeLineCap=this.strokeLineCap,t.strokeLineJoin=this.strokeLineJoin,this.shadow&&(this.shadow.affectStroke=!0,t.setShadow(this.shadow)),t},_finalizeAndAddPath:function(){var u=this.canvas.contextTop,t,i,r,n;if(u.closePath(),t=this._getSVGPathData().join(""),t==="M 0 0 Q 0 0 0 0 L 0 0"){this.canvas.renderAll();return}i=this.box.minx+(this.box.maxx-this.box.minx)/2;r=this.box.miny+(this.box.maxy-this.box.miny)/2;this.canvas.contextTop.arc(i,r,3,0,Math.PI*2,!1);n=this.createPath(t);n.set({left:i,top:r,originX:"center",originY:"center"});this.canvas.add(n);n.setCoords();this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderAll();this.canvas.fire("path:created",{path:n})}})}();fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(n){this.canvas=n;this.points=[]},drawDot:function(n){var i=this.addPoint(n),t=this.canvas.contextTop;t.fillStyle=i.fill;t.beginPath();t.arc(i.x,i.y,i.radius,0,Math.PI*2,!1);t.closePath();t.fill()},onMouseDown:function(n){this.points.length=0;this.canvas.clearContext(this.canvas.contextTop);this._setShadow();this.drawDot(n)},onMouseMove:function(n){this.drawDot(n)},onMouseUp:function(){var e=this.canvas.renderOnAddRemove,i,t,f,n,r,u;for(this.canvas.renderOnAddRemove=!1,i=[],t=0,f=this.points.length;t<f;t++)n=this.points[t],r=new fabric.Circle({radius:n.radius,left:n.x,top:n.y,originX:"center",originY:"center",fill:n.fill}),this.shadow&&r.setShadow(this.shadow),i.push(r);u=new fabric.Group(i,{originX:"center",originY:"center"});this.canvas.add(u);this.canvas.fire("path:created",{path:u});this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderOnAddRemove=e;this.canvas.renderAll()},addPoint:function(n){var t=new fabric.Point(n.x,n.y),i=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=new fabric.Color(this.color).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();return t.radius=i,t.fill=r,this.points.push(t),t}});fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(n){this.canvas=n;this.sprayChunks=[]},onMouseDown:function(n){this.sprayChunks.length=0;this.canvas.clearContext(this.canvas.contextTop);this._setShadow();this.addSprayChunk(n);this.render()},onMouseMove:function(n){this.addSprayChunk(n);this.render()},onMouseUp:function(){var s=this.canvas.renderOnAddRemove,i,r,e,t,n,o,u,f;for(this.canvas.renderOnAddRemove=!1,i=[],r=0,e=this.sprayChunks.length;r<e;r++)for(t=this.sprayChunks[r],n=0,o=t.length;n<o;n++)u=new fabric.Rect({width:t[n].width,height:t[n].width,left:t[n].x+1,top:t[n].y+1,originX:"center",originY:"center",fill:this.color}),this.shadow&&u.setShadow(this.shadow),i.push(u);this.optimizeOverlapping&&(i=this._getOptimizedRects(i));f=new fabric.Group(i,{originX:"center",originY:"center"});this.canvas.add(f);this.canvas.fire("path:created",{path:f});this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderOnAddRemove=s;this.canvas.renderAll()},_getOptimizedRects:function(n){for(var u,r={},t,i=0,f=n.length;i<f;i++)t=n[i].left+""+n[i].top,r[t]||(r[t]=n[i]);u=[];for(t in r)u.push(r[t]);return u},render:function(){var t=this.canvas.contextTop,i,r,n;for(t.fillStyle=this.color,t.save(),i=0,r=this.sprayChunkPoints.length;i<r;i++)n=this.sprayChunkPoints[i],typeof n.opacity!="undefined"&&(t.globalAlpha=n.opacity),t.fillRect(n.x,n.y,n.width,n.width);t.restore()},addSprayChunk:function(n){var u,f,e,t,i,r;for(this.sprayChunkPoints=[],t=this.width/2,i=0;i<this.density;i++)u=fabric.util.getRandomInt(n.x-t,n.x+t),f=fabric.util.getRandomInt(n.y-t,n.y+t),e=this.dotWidthVariance?fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth,r={x:u,y:f,width:e},this.randomOpacity&&(r.opacity=fabric.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(r);this.sprayChunks.push(this.sprayChunkPoints)}});fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var t=20,i=fabric.document.createElement("canvas"),n=i.getContext("2d");return i.width=i.height=t+5,n.fillStyle=this.color,n.beginPath(),n.arc(t/2,t/2,t/2,0,Math.PI*2,!1),n.closePath(),n.fill(),i},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles");this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(n){var t=this.callSuper("createPath",n);return t.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction()}),t}}),function(){var r=fabric.util.getPointer,f=fabric.util.degreesToRadians,e=fabric.util.radiansToDegrees,u=Math.atan2,n=Math.abs,t=.5,i;fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(n,t){t||(t={});this._initStatic(n,t);this._initInteractive();this._createCacheCanvas();fabric.Canvas.activeInstance=this},uniScaleTransform:!1,centeredScaling:!1,centeredRotation:!1,interactive:!0,selection:!0,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,_initInteractive:function(){this._currentTransform=null;this._groupSelector=null;this._initWrapperElement();this._createUpperCanvas();this._initEventListeners();this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this);this.calcOffset()},_resetCurrentTransform:function(n){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,left:t.original.left,top:t.original.top});this._shouldCenterTransform(n,t.target)?t.action==="rotate"?this._setOriginToCenter(t.target):(t.originX!=="center"&&(t.mouseXSign=t.originX==="right"?-1:1),t.originY!=="center"&&(t.mouseYSign=t.originY==="bottom"?-1:1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(n,t){var i=this.getPointer(n),r=this._normalizePointer(t,i);return t.containsPoint(r)||t._findTargetCorner(n,this._offset)},_normalizePointer:function(n,t){var i=this.getActiveGroup(),r=t.x,u=t.y,f=i&&n.type!=="group"&&i.contains(n);return f&&(r-=i.left,u-=i.top),{x:r,y:u}},isTargetTransparent:function(n,t,i){var u=n.hasBorders,f=n.transparentCorners,r;return n.hasBorders=n.transparentCorners=!1,this._draw(this.contextCache,n),n.hasBorders=u,n.transparentCorners=f,r=fabric.util.isTransparent(this.contextCache,t,i,this.targetFindTolerance),this.clearContext(this.contextCache),r},_shouldClearSelection:function(n,t){var i=this.getActiveGroup(),r=this.getActiveObject();return!t||t&&i&&!i.contains(t)&&i!==t&&!n.shiftKey||t&&!t.evented||t&&!t.selectable&&r&&r!==t},_shouldCenterTransform:function(n,t){if(t){var i=this._currentTransform,r;return i.action==="scale"||i.action==="scaleX"||i.action==="scaleY"?r=this.centeredScaling||t.centeredScaling:i.action==="rotate"&&(r=this.centeredRotation||t.centeredRotation),r?!n.altKey:n.altKey}},_getOriginFromCorner:function(n,t){var i={x:n.originX,y:n.originY};return t==="ml"||t==="tl"||t==="bl"?i.x="right":(t==="mr"||t==="tr"||t==="br")&&(i.x="left"),t==="tl"||t==="mt"||t==="tr"?i.y="bottom":(t==="bl"||t==="mb"||t==="br")&&(i.y="top"),i},_getActionFromCorner_default:function(n,t){var i="drag";return t&&(i=t==="ml"||t==="mr"?"scaleX":t==="mt"||t==="mb"?"scaleY":t==="mtr"?"rotate":"scale"),i},_getActionFromCorner:function(n,t){var i="drag";if(t)switch(t){case"ml":case"mr":i="scaleX";break;case"mt":case"mb":i="scaleY";break;case"mtr":case"br":i="rotate";break;case"DeleteControl":i="delete";break;case"InfoControl":i="info";break;default:i="scale"}return i},_setupCurrentTransform:function(n,t){if(t){var e=t._findTargetCorner(n,this._offset),i=r(n,t.canvas.upperCanvasEl),o=this._getActionFromCorner(t,e),u=this._getOriginFromCorner(t,e);this._currentTransform={target:t,action:o,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:i.x-t.left,offsetY:i.y-t.top,originX:u.x,originY:u.y,ex:i.x,ey:i.y,left:t.left,top:t.top,theta:f(t.angle),width:t.width*t.scaleX,mouseXSign:1,mouseYSign:1};this._currentTransform.original={left:t.left,top:t.top,scaleX:t.scaleX,scaleY:t.scaleY,originX:u.x,originY:u.y};this._resetCurrentTransform(n)}},_translateObject:function(n,t){var i=this._currentTransform.target;i.get("lockMovementX")||i.set("left",n-this._currentTransform.offsetX);i.get("lockMovementY")||i.set("top",t-this._currentTransform.offsetY)},_scaleObject:function(n,t,i){var r=this._currentTransform,e=this._offset,u=r.target,o=u.get("lockScalingX"),s=u.get("lockScalingY"),h,f;o&&s||(h=u.translateToOriginPoint(u.getCenterPoint(),r.originX,r.originY),f=u.toLocalPoint(new fabric.Point(n-e.left,t-e.top),r.originX,r.originY),this._setLocalMouse(f,r),this._setObjectScale(f,r,o,s,i),u.setPositionByOrigin(h,r.originX,r.originY))},_setObjectScale:function(n,t,i,r,u){var f=t.target;t.newScaleX=f.scaleX;t.newScaleY=f.scaleY;u!=="equally"||i||r?u?u!=="x"||f.get("lockUniScaling")?u!=="y"||f.get("lockUniScaling")||(t.newScaleY=n.y/(f.height+f.strokeWidth),r||f.set("scaleY",t.newScaleY)):(t.newScaleX=n.x/(f.width+f.strokeWidth),i||f.set("scaleX",t.newScaleX)):(t.newScaleX=n.x/(f.width+f.strokeWidth),t.newScaleY=n.y/(f.height+f.strokeWidth),i||f.set("scaleX",t.newScaleX),r||f.set("scaleY",t.newScaleY)):this._scaleObjectEqually(n,f,t);this._flipObject(t)},_scaleObjectEqually:function(n,t,i){var r=n.y+n.x,u=(t.height+t.strokeWidth)*i.original.scaleY+(t.width+t.strokeWidth)*i.original.scaleX;i.newScaleX=i.original.scaleX*r/u;i.newScaleY=i.original.scaleY*r/u;t.set("scaleX",i.newScaleX);t.set("scaleY",i.newScaleY)},_flipObject:function(n){n.newScaleX<0&&(n.originX==="left"?n.originX="right":n.originX==="right"&&(n.originX="left"));n.newScaleY<0&&(n.originY==="top"?n.originY="bottom":n.originY==="bottom"&&(n.originY="top"))},_setLocalMouse:function(t,i){var r=i.target;i.originX==="right"?t.x*=-1:i.originX==="center"&&(t.x*=i.mouseXSign*2,t.x<0&&(i.mouseXSign=-i.mouseXSign));i.originY==="bottom"?t.y*=-1:i.originY==="center"&&(t.y*=i.mouseYSign*2,t.y<0&&(i.mouseYSign=-i.mouseYSign));n(t.x)>r.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;u<e;u++)if(f=this.getPointer(n),o=this.isTargetTransparent(i[u],f.x,f.y),!o){r=i[u];this.relatedTarget=r;break}return r},getPointer:function(n){var t=r(n,this.upperCanvasEl);return{x:t.x-this._offset.left,y:t.y-this._offset.top}},_createUpperCanvas:function(){var n=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,"");this.upperCanvasEl=this._createCanvasElement();fabric.util.addClass(this.upperCanvasEl,"upper-canvas "+n);this.wrapperEl.appendChild(this.upperCanvasEl);this._copyCanvasStyle(this.lowerCanvasEl,this.upperCanvasEl);this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement();this.cacheCanvasEl.setAttribute("width",this.width);this.cacheCanvasEl.setAttribute("height",this.height);this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(n){var t=this.getWidth()||n.width,i=this.getHeight()||n.height;fabric.util.setStyle(n,{position:"absolute",width:t+"px",height:i+"px",left:0,top:0});n.width=t;n.height=i;fabric.util.makeElementUnselectable(n)},_copyCanvasStyle:function(n,t){t.style.cssText=n.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},_setActiveObject:function(n){this._activeObject&&this._activeObject.set("active",!1);this._activeObject=n;n.set("active",!0)},setActiveObject:function(n,t){return this._setActiveObject(n),this.renderAll(),this.fire("object:selected",{target:n,e:t}),n.fire("selected",{e:t}),this},getActiveObject:function(){return this._activeObject},_discardActiveObject:function(){this._activeObject&&this._activeObject.set("active",!1);this._activeObject=null},discardActiveObject:function(n){return this._discardActiveObject(),this.renderAll(),this.fire("selection:cleared",{e:n}),this},_setActiveGroup:function(n){this._activeGroup=n;n&&(n.canvas=this,n.set("active",!0))},setActiveGroup:function(n,t){return this._setActiveGroup(n),n&&(this.fire("object:selected",{target:n,e:t}),n.fire("selected",{e:t})),this},getActiveGroup:function(){return this._activeGroup},_discardActiveGroup:function(){var n=this.getActiveGroup();n&&n.destroy();this.setActiveGroup(null)},discardActiveGroup:function(n){return this._discardActiveGroup(),this.fire("selection:cleared",{e:n}),this},deactivateAll:function(){for(var t=this.getObjects(),n=0,i=t.length;n<i;n++)t[n].set("active",!1);return this._discardActiveGroup(),this._discardActiveObject(),this},deactivateAllWithDispatch:function(n){var t=this.getActiveGroup()||this.getActiveObject();return t&&this.fire("before:selection:cleared",{target:t,e:n}),this.deactivateAll(),t&&this.fire("selection:cleared",{e:n}),this},drawControls:function(n){var t=this.getActiveGroup();t?this._drawGroupControls(n,t):this._drawObjectsControls(n)},_drawGroupControls:function(n,t){this._drawControls(n,t,"Group")},_drawObjectsControls:function(n){for(var t=0,i=this._objects.length;t<i;++t)this._objects[t]&&this._objects[t].active&&(this._drawControls(n,this._objects[t],"Object"),this.lastRenderedObjectWithControlsAboveOverlay=this._objects[t])},_drawControls:function(n,t,i){n.save();fabric[i].prototype.transform.call(t,n);t.drawBorders(n).drawControls(n);n.restore()}});for(i in fabric.StaticCanvas)i!=="prototype"&&(fabric.Canvas[i]=fabric.StaticCanvas[i]);fabric.isTouchSupported&&(fabric.Canvas.prototype._setCursorFromEvent=function(){});fabric.Element=fabric.Canvas}(),function(){var u=["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],i={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},n=fabric.util.addListener,t=fabric.util.removeListener,r=fabric.util.getPointer;fabric.util.object.extend(fabric.Canvas.prototype,{_initEventListeners:function(){this._bindEvents();n(fabric.window,"resize",this._onResize);n(this.upperCanvasEl,"mousedown",this._onMouseDown);n(this.upperCanvasEl,"mousemove",this._onMouseMove);n(this.upperCanvasEl,"mousewheel",this._onMouseWheel);n(this.upperCanvasEl,"touchstart",this._onMouseDown);n(this.upperCanvasEl,"touchmove",this._onMouseMove);typeof Event!="undefined"&&"add"in Event&&(Event.add(this.upperCanvasEl,"gesture",this._onGesture),Event.add(this.upperCanvasEl,"drag",this._onDrag),Event.add(this.upperCanvasEl,"orientation",this._onOrientationChange),Event.add(this.upperCanvasEl,"shake",this._onShake))},_bindEvents:function(){this._onMouseDown=this._onMouseDown.bind(this);this._onMouseMove=this._onMouseMove.bind(this);this._onMouseUp=this._onMouseUp.bind(this);this._onResize=this._onResize.bind(this);this._onGesture=this._onGesture.bind(this);this._onDrag=this._onDrag.bind(this);this._onShake=this._onShake.bind(this);this._onOrientationChange=this._onOrientationChange.bind(this);this._onMouseWheel=this._onMouseWheel.bind(this)},removeListeners:function(){t(fabric.window,"resize",this._onResize);t(this.upperCanvasEl,"mousedown",this._onMouseDown);t(this.upperCanvasEl,"mousemove",this._onMouseMove);t(this.upperCanvasEl,"mousewheel",this._onMouseWheel);t(this.upperCanvasEl,"touchstart",this._onMouseDown);t(this.upperCanvasEl,"touchmove",this._onMouseMove);typeof Event!="undefined"&&"remove"in Event&&(Event.remove(this.upperCanvasEl,"gesture",this._onGesture),Event.remove(this.upperCanvasEl,"drag",this._onDrag),Event.remove(this.upperCanvasEl,"orientation",this._onOrientationChange),Event.remove(this.upperCanvasEl,"shake",this._onShake))},_onGesture:function(n,t){this.__onTransformGesture&&this.__onTransformGesture(n,t)},_onDrag:function(n,t){this.__onDrag&&this.__onDrag(n,t)},_onMouseWheel:function(n,t){this.__onMouseWheel&&this.__onMouseWheel(n,t)},_onOrientationChange:function(n,t){this.__onOrientationChange&&this.__onOrientationChange(n,t)},_onShake:function(n,t){this.__onShake&&this.__onShake(n,t)},_onMouseDown:function(i){this.__onMouseDown(i);n(fabric.document,"mouseup",this._onMouseUp);n(fabric.document,"touchend",this._onMouseUp);n(fabric.document,"mousemove",this._onMouseMove);n(fabric.document,"touchmove",this._onMouseMove);t(this.upperCanvasEl,"mousemove",this._onMouseMove);t(this.upperCanvasEl,"touchmove",this._onMouseMove)},_onMouseUp:function(i){this.__onMouseUp(i);t(fabric.document,"mouseup",this._onMouseUp);t(fabric.document,"touchend",this._onMouseUp);t(fabric.document,"mousemove",this._onMouseMove);t(fabric.document,"touchmove",this._onMouseMove);n(this.upperCanvasEl,"mousemove",this._onMouseMove);n(this.upperCanvasEl,"touchmove",this._onMouseMove)},_onMouseMove:function(n){!this.allowTouchScrolling&&n.preventDefault&&n.preventDefault();this.__onMouseMove(n)},_onResize:function(){this.calcOffset()},_shouldRender:function(n,t){var i=this.getActiveGroup()||this.getActiveObject();return!!(n&&(n.isMoving||n!==i)||!n&&!!i||!n&&!i&&!this._groupSelector||t&&this._previousPointer&&this.selection&&(t.x!==this._previousPointer.x||t.y!==this._previousPointer.y))},__onMouseUp:function(n){var t,i;if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(n);return}this._currentTransform?(this._finalizeCurrentTransform(),t=this._currentTransform.target):t=this.findTarget(n,!0);i=this._shouldRender(t,this.getPointer(n));this._maybeGroupObjects(n);t&&(t.isMoving=!1);i&&this.renderAll();this._handleCursorAndEvent(n,t)},_handleCursorAndEvent:function(n,t){this._setCursorFromEvent(n,t);var i=this;setTimeout(function(){i._setCursorFromEvent(n,t)},50);this.fire("mouse:up",{target:t,e:n});t&&t.fire("mouseup",{e:n})},_finalizeCurrentTransform:function(){var t=this._currentTransform,n=t.target;n._scaling&&(n._scaling=!1);n.setCoords();this.stateful&&n.hasStateChanged()&&(this.fire("object:modified",{target:n}),n.fire("modified"));this._restoreOriginXY(n)},_restoreOriginXY:function(n){if(this._previousOriginX&&this._previousOriginY){var t=n.translateToOriginPoint(n.getCenterPoint(),this._previousOriginX,this._previousOriginY);n.originX=this._previousOriginX;n.originY=this._previousOriginY;n.left=t.x;n.top=t.y;this._previousOriginX=null;this._previousOriginY=null}},_onMouseDownInDrawingMode:function(n){this._isCurrentlyDrawing=!0;this.discardActiveObject(n).renderAll();this.clipTo&&fabric.util.clipContext(this,this.contextTop);this.freeDrawingBrush.onMouseDown(this.getPointer(n));this.fire("mouse:down",{e:n})},_onMouseMoveInDrawingMode:function(n){if(this._isCurrentlyDrawing){var t=this.getPointer(n);this.freeDrawingBrush.onMouseMove(t)}this.upperCanvasEl.style.cursor=this.freeDrawingCursor;this.fire("mouse:move",{e:n})},_onMouseUpInDrawingMode:function(n){this._isCurrentlyDrawing=!1;this.clipTo&&this.contextTop.restore();this.freeDrawingBrush.onMouseUp();this.fire("mouse:up",{e:n})},__onMouseDown:function(n){var o="which"in n?n.which===1:n.button===1,t,i,f,r,e,u;if(o||fabric.isTouchSupported){if(this.isDrawingMode){this._onMouseDownInDrawingMode(n);return}this._currentTransform||(t=this.findTarget(n),i=this.getPointer(n),this._previousPointer=i,f=this._shouldRender(t,i),r=this._shouldGroup(n,t),this._shouldClearSelection(n,t)?this._clearSelection(n,t,i):r&&(this._handleGrouping(n,t),t=this.getActiveGroup()),t&&t.selectable&&!r&&(e=t._findTargetCorner(n,this._offset),u=this._getActionFromCorner(t,e),u=="info"?RoomPlannerV2.infoPopup():u=="delete"?RoomPlannerV2.deleteThis():(this._beforeTransform(n,t),this._setupCurrentTransform(n,t))),f&&this.renderAll(),this.fire("mouse:down",{target:t,e:n}),t&&t.fire("mousedown",{e:n}))}},_beforeTransform:function(n,t){var i;if(this.stateful&&t.saveState(),i=t._findTargetCorner(n,this._offset))this.onBeforeScaleRotate(t);t!==this.getActiveGroup()&&t!==this.getActiveObject()&&(this.deactivateAll(),this.setActiveObject(t,n))},_clearSelection:function(n,t,i){this.deactivateAllWithDispatch(n);t&&t.selectable?this.setActiveObject(t,n):this.selection&&(this._groupSelector={ex:i.x,ey:i.y,top:0,left:0})},_setOriginToCenter:function(n){this._previousOriginX=this._currentTransform.target.originX;this._previousOriginY=this._currentTransform.target.originY;var t=n.getCenterPoint();n.originX="center";n.originY="center";n.left=t.x;n.top=t.y;this._currentTransform.left=n.left;this._currentTransform.top=n.top},_setCenterToOrigin:function(n){var t=n.translateToOriginPoint(n.getCenterPoint(),this._previousOriginX,this._previousOriginY);n.originX=this._previousOriginX;n.originY=this._previousOriginY;n.left=t.x;n.top=t.y;this._previousOriginX=null;this._previousOriginY=null},__onMouseMove:function(n){var t,u,i;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(n);return}i=this._groupSelector;i?(u=r(n,this.upperCanvasEl),i.left=u.x-this._offset.left-i.ex,i.top=u.y-this._offset.top-i.ey,this.renderTop()):this._currentTransform?this._transformObject(n):(t=this.findTarget(n),t&&(!t||t.selectable)?this._setCursorFromEvent(n,t):this.upperCanvasEl.style.cursor=this.defaultCursor);this.fire("mouse:move",{target:t,e:n});t&&t.fire("mousemove",{e:n})},_transformObject:function(n){var i=r(n,this.upperCanvasEl),t=this._currentTransform;t.reset=!1;t.target.isMoving=!0;this._beforeScaleTransform(n,t);this._performTransformAction(n,t,i);this.renderAll()},_performTransformAction:function(n,t,i){var r=i.x,u=i.y,f=t.target,e=t.action;e==="rotate"?(this._rotateObject(r,u),this._fire("rotating",f,n)):e==="scale"?(this._onScale(n,t,r,u),this._fire("scaling",f,n)):e==="scaleX"?(this._scaleObject(r,u,"x"),this._fire("scaling",f,n)):e==="scaleY"?(this._scaleObject(r,u,"y"),this._fire("scaling",f,n)):(this._translateObject(r,u),this._fire("moving",f,n),this._setCursor(this.moveCursor))},_fire:function(n,t,i){this.fire("object:"+n,{target:t,e:i});t.fire(n,{e:i})},_beforeScaleTransform:function(n,t){if(t.action==="scale"||t.action==="scaleX"||t.action==="scaleY"){var i=this._shouldCenterTransform(n,t.target);(i&&(t.originX!=="center"||t.originY!=="center")||!i&&t.originX==="center"&&t.originY==="center")&&(this._resetCurrentTransform(n),t.reset=!0)}},_onScale:function(n,t,i,r){(n.shiftKey||this.uniScaleTransform)&&!t.target.get("lockUniScaling")?(t.currentAction="scale",this._scaleObject(i,r)):(t.reset||t.currentAction!=="scale"||this._resetCurrentTransform(n,t.target),t.currentAction="scaleEqually",this._scaleObject(i,r,"equally"))},_setCursorFromEvent:function(n,t){var r=this.upperCanvasEl.style,u,i;if(t&&t.selectable)if(u=this.getActiveGroup(),i=t._findTargetCorner&&(!u||!u.contains(t))&&t._findTargetCorner(n,this._offset),i)switch(i){case"br":case"DeleteControl":case"InfoControl":r.cursor="pointer";break;default:this._setCornerCursor(i,t)}else r.cursor=t.hoverCursor||this.hoverCursor;else return r.cursor=this.defaultCursor,!1;return!0},_setCornerCursor:function(n,t){var r=this.upperCanvasEl.style;if(n in i)r.cursor=this._getRotatedCornerCursor(n,t);else if(n==="mtr"&&t.hasRotatingPoint)r.cursor=this.rotationCursor;else return r.cursor=this.defaultCursor,!1},_getRotatedCornerCursor:function(n,t){var r=Math.round(t.getAngle()%360/45);return r<0&&(r+=8),r+=i[n],r%=8,u[r]}})}(),function(){var n=Math.min,t=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(n,t){var i=this.getActiveObject();return n.shiftKey&&(this.getActiveGroup()||i&&i!==t)&&this.selection},_handleGrouping:function(n,t){(t!==this.getActiveGroup()||(t=this.findTarget(n,!0),t&&!t.isType("group")))&&(this.getActiveGroup()?this._updateActiveGroup(t,n):this._createActiveGroup(t,n),this._activeGroup&&this._activeGroup.saveCoords())},_updateActiveGroup:function(n,t){var i=this.getActiveGroup();if(i.contains(n)){if(i.removeWithUpdate(n),this._resetObjectTransform(i),n.set("active",!1),i.size()===1){this.discardActiveGroup(t);this.setActiveObject(i.item(0));return}}else i.addWithUpdate(n),this._resetObjectTransform(i);this.fire("selection:created",{target:i,e:t});i.set("active",!0)},_createActiveGroup:function(n,t){if(this._activeObject&&n!==this._activeObject){var i=this._createGroup(n);this.setActiveGroup(i);this._activeObject=null;this.fire("selection:created",{target:i,e:t})}n.set("active",!0)},_createGroup:function(n){var t=this.getObjects(),i=t.indexOf(this._activeObject)<t.indexOf(n),r=i?[this._activeObject,n]:[n,this._activeObject];return new fabric.Group(r,{originX:"center",originY:"center"})},_groupSelectedObjects:function(n){var t=this._collectObjects();t.length===1?this.setActiveObject(t[0],n):t.length>1&&(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:"https://images.furnituredealer.net/img/roomplanner/uparrow.png",mbImageSrc:"https://images.furnituredealer.net/img/roomplanner/downarrow.png",mlImageSrc:"https://images.furnituredealer.net/img/roomplanner/leftarrow.png",mrImageSrc:"https://images.furnituredealer.net/img/roomplanner/rightarrow.png",brImageSrc:"https://images.furnituredealer.net/img/roomplanner/rotate.png",DeleteImageSrc:"https://images.furnituredealer.net/img/roomplanner/close.png",InfoImageSrc:"https://images.furnituredealer.net/img/roomplanner/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"#<fabric."+u(this.type)+">"},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.width<t.x&&i.top>n.y&&i.top+i.height<t.y},containsPoint:function(n){var i=this._getImageLines(this.oCoords),t=this._findCrossPoints(n,i);return t!==0&&t%2==1},_getImageLines:function(n){return{topline:{o:n.tl,d:n.tr},rightline:{o:n.tr,d:n.br},bottomline:{o:n.br,d:n.bl},leftline:{o:n.bl,d:n.tl}}},_findCrossPoints:function(n,t){var r,f,e,s,u,h,o=0,i;for(var c in t)if((i=t[c],!(i.o.y<n.y)||!(i.d.y<n.y))&&(!(i.o.y>=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)<this.minScaleLimit?n<0?-this.minScaleLimit:this.minScaleLimit:n},scale:function(n){return n=this._constrainScale(n),n<0&&(this.flipX=!this.flipX,this.flipY=!this.flipY,n*=-1),this.scaleX=n,this.scaleY=n,this.setCoords(),this},scaleToWidth:function(n){var t=this.getBoundingRectWidth()/this.getWidth();return this.scale(n/this.width/t)},scaleToHeight:function(n){var t=this.getBoundingRectHeight()/this.getHeight();return this.scale(n/this.height/t)},setCoords:function(){var s=this.strokeWidth>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("<line ",'x1="',this.get("x1"),'" y1="',this.get("y1"),'" x2="',this.get("x2"),'" y2="',this.get("y2"),'" style="',this.getSvgStyles(),'"/>'),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("<circle ",'cx="0" cy="0" ','r="',this.radius,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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("<polygon ",'points="',u,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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("<ellipse ",'rx="',this.get("rx"),'" ry="',this.get("ry"),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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("<rect ",'x="',this.width/-2,'" y="',this.height/-2,'" rx="',this.get("rx"),'" ry="',this.get("ry"),'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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<f;t++)u.push(i(this.points[t].x,2),",",i(this.points[t].y,2)," ");return r.push("<polyline ",'points="',u.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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<r;t++)i=this.points[t],n.lineTo(i.x,i.y);this._renderFill(n);this._renderStroke(n)},_renderDashedStroke:function(n){var r,u,i,f;for(n.beginPath(),i=0,f=this.points.length;i<f;i++)r=this.points[i],u=this.points[i+1]||r,t.util.drawDashedLine(n,r.x,r.y,u.x,u.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}});t.Polyline.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat();t.Polyline.fromElement=function(n,i){if(!n)return null;i||(i={});var r=t.parsePointsAttribute(n.getAttribute("points")),u=t.parseAttributes(n,t.Polyline.ATTRIBUTE_NAMES);return t.util.normalizePoints(r,i),new t.Polyline(r,t.util.object.extend(u,i),!0)};t.Polyline.fromObject=function(n){var i=n.points;return new t.Polyline(i,n,!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,f=t.util.toFixed;if(t.Polygon){t.warn("fabric.Polygon is already defined");return}t.Polygon=t.util.createClass(t.Object,{type:"polygon",initialize:function(n,t,i){t=t||{};this.points=n;this.callSuper("initialize",t);this._calcDimensions(i)},_calcDimensions:function(n){var t=this.points,i=r(t,"x"),f=r(t,"y"),s=u(t,"x"),h=u(t,"y"),e,o;(this.width=s-i||1,this.height=h-f||1,this.minX=i,this.minY=f,n)||(e=this.width/2+this.minX,o=this.height/2+this.minY,this.points.forEach(function(n){n.x-=e;n.y-=o},this))},toObject:function(n){return i(this.callSuper("toObject",n),{points:this.points.concat()})},toSVG:function(n){for(var r=[],i=this._createBaseSVGMarkup(),t=0,u=this.points.length;t<u;t++)r.push(f(this.points[t].x,2),",",f(this.points[t].y,2)," ");return i.push("<polygon ",'points="',r.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>'),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<r;t++)i=this.points[t],n.lineTo(i.x,i.y);this._renderFill(n);(this.stroke||this.strokeDashArray)&&(n.closePath(),this._renderStroke(n))},_renderDashedStroke:function(n){var r,u,i,f;for(n.beginPath(),i=0,f=this.points.length;i<f;i++)r=this.points[i],u=this.points[i+1]||this.points[0],t.util.drawDashedLine(n,r.x,r.y,u.x,u.y,this.strokeDashArray);n.closePath()},complexity:function(){return this.points.length}});t.Polygon.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat();t.Polygon.fromElement=function(n,r){if(!n)return null;r||(r={});var u=t.parsePointsAttribute(n.getAttribute("points")),f=t.parseAttributes(n,t.Polygon.ATTRIBUTE_NAMES);return t.util.normalizePoints(u,r),new t.Polygon(u,i(f,r),!0)};t.Polygon.fromObject=function(n){return new t.Polygon(n.points,n,!0)}}(typeof exports!="undefined"?exports:this),function(n){function i(n){return n[0]==="H"?n[1]:n[n.length-2]}function r(n){return n[0]==="V"?n[1]:n[n.length-1]}var s={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7};"use strict";var t=n.fabric||(n.fabric={}),f=t.util.array.min,e=t.util.array.max,u=t.util.object.extend,h=Object.prototype.toString,o=t.util.drawArc;if(t.Path){t.warn("fabric.Path is already defined");return}t.Path=t.util.createClass(t.Object,{type:"path",initialize:function(n,t){if(t=t||{},this.setOptions(t),!n)throw new Error("`path` argument is required");var i=h.call(n)==="[object Array]";(this.path=i?n:n.match&&n.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi),this.path)&&(i||(this.path=this._parsePath()),this._initializePath(t),t.sourcePath&&this.setSourcePath(t.sourcePath))},_initializePath:function(n){var t="width"in n&&n.width!=null,i="height"in n&&n.width!=null,r="left"in n,f="top"in n,e=r?this.left:0,o=f?this.top:0;t&&i?(f||(this.top=this.height/2),r||(this.left=this.width/2)):(u(this,this._parseDimensions()),t&&(this.width=n.width),i&&(this.height=n.height));this.pathOffset=this.pathOffset||this._calculatePathOffset(e,o)},_calculatePathOffset:function(n,t){return{x:this.left-n-this.width/2,y:this.top-t-this.height/2}},_render:function(n){for(var t,l=null,i=0,r=0,e=0,s=0,h,c,y,p,u=-(this.width/2+this.pathOffset.x),f=-(this.height/2+this.pathOffset.y),a,v=0,w=this.path.length;v<w;++v){t=this.path[v];switch(t[0]){case"l":i+=t[1];r+=t[2];n.lineTo(i+u,r+f);break;case"L":i=t[1];r=t[2];n.lineTo(i+u,r+f);break;case"h":i+=t[1];n.lineTo(i+u,r+f);break;case"H":i=t[1];n.lineTo(i+u,r+f);break;case"v":r+=t[1];n.lineTo(i+u,r+f);break;case"V":r=t[1];n.lineTo(i+u,r+f);break;case"m":i+=t[1];r+=t[2];a=l&&(l[0]==="m"||l[0]==="M")?"lineTo":"moveTo";n[a](i+u,r+f);break;case"M":i=t[1];r=t[2];a=l&&(l[0]==="m"||l[0]==="M")?"lineTo":"moveTo";n[a](i+u,r+f);break;case"c":h=i+t[5];c=r+t[6];e=i+t[3];s=r+t[4];n.bezierCurveTo(i+t[1]+u,r+t[2]+f,e+u,s+f,h+u,c+f);i=h;r=c;break;case"C":i=t[5];r=t[6];e=t[3];s=t[4];n.bezierCurveTo(t[1]+u,t[2]+f,e+u,s+f,i+u,r+f);break;case"s":h=i+t[3];c=r+t[4];e=e?2*i-e:i;s=s?2*r-s:r;n.bezierCurveTo(e+u,s+f,i+t[1]+u,r+t[2]+f,h+u,c+f);e=i+t[1];s=r+t[2];i=h;r=c;break;case"S":h=t[3];c=t[4];e=2*i-e;s=2*r-s;n.bezierCurveTo(e+u,s+f,t[1]+u,t[2]+f,h+u,c+f);i=h;r=c;e=t[1];s=t[2];break;case"q":h=i+t[3];c=r+t[4];e=i+t[1];s=r+t[2];n.quadraticCurveTo(e+u,s+f,h+u,c+f);i=h;r=c;break;case"Q":h=t[3];c=t[4];n.quadraticCurveTo(t[1]+u,t[2]+f,h+u,c+f);i=h;r=c;e=t[1];s=t[2];break;case"t":h=i+t[1];c=r+t[2];l[0].match(/[QqTt]/)===null?(e=i,s=r):l[0]==="t"?(e=2*i-y,s=2*r-p):l[0]==="q"&&(e=2*i-e,s=2*r-s);y=e;p=s;n.quadraticCurveTo(e+u,s+f,h+u,c+f);i=h;r=c;e=i+t[1];s=r+t[2];break;case"T":h=t[1];c=t[2];e=2*i-e;s=2*r-s;n.quadraticCurveTo(e+u,s+f,h+u,c+f);i=h;r=c;break;case"a":o(n,i+u,r+f,[t[1],t[2],t[3],t[4],t[5],t[6]+i+u,t[7]+r+f]);i+=t[6];r+=t[7];break;case"A":o(n,i+u,r+f,[t[1],t[2],t[3],t[4],t[5],t[6]+u,t[7]+f]);i=t[6];r=t[7];break;case"z":case"Z":n.closePath()}l=t}},render:function(n,i){if(this.visible){n.save();var r=this.transformMatrix;r&&n.transform(r[0],r[1],r[2],r[3],r[4],r[5]);i||this.transform(n);this._setStrokeStyles(n);this._setFillStyles(n);this._setShadow(n);this.clipTo&&t.util.clipContext(this,n);n.beginPath();this._render(n);this._renderFill(n);this._renderStroke(n);this.clipTo&&n.restore();this._removeShadow(n);!i&&this.active&&(this.drawBorders(n),this.drawControls(n));n.restore()}},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},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<f;i++)r.push(this.path[i].join(" "));return u=r.join(" "),t.push('<g transform="',this.group?"":this.getSvgTransform(),'">',"<path ",'d="',u,'" style="',this.getSvgStyles(),'" transform="translate(',-this.width/2," ",-this.height/2,")",'" stroke-linecap="round" ',"/>","<\/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;h<w;h++){for(e=this.path[h],l=e.slice(1).trim(),i.length=0;c=p.exec(l);)i.push(c[0]);for(n=[e.charAt(0)],r=0,a=i.length;r<a;r++)o=parseFloat(i[r]),isNaN(o)||n.push(o);if(v=n[0].toLowerCase(),u=s[v],n.length-1>u)for(t=1,y=n.length;t<y;t+=u)f.push([n[0]].concat(n.slice(t,t+u)));else f.push(n)}return f},_parseDimensions:function(){var n=[],t=[],s={};this.path.forEach(function(i,r){this._getCoordsFromCommand(i,r,n,t,s)},this);var i=f(n),r=f(t),h=e(n),c=e(t),u=h-i,o=c-r;return{left:this.left+(i+u/2),top:this.top+(r+o/2),width:u,height:o}},_getCoordsFromCommand:function(n,t,u,f,e){var h=!1,s,o;n[0]!=="H"&&(e.x=t===0?i(n):i(this.path[t-1]));n[0]!=="V"&&(e.y=t===0?r(n):r(this.path[t-1]));n[0]===n[0].toLowerCase()&&(h=!0);s=this._getXY(n,h,e);o=parseInt(s.x,10);isNaN(o)||u.push(o);o=parseInt(s.y,10);isNaN(o)||f.push(o)},_getXY:function(n,t,u){var f=t?u.x+i(n):n[0]==="V"?u.x:i(n),e=t?u.y+r(n):n[0]==="H"?u.y:r(n);return{x:f,y:e}}});t.Path.fromObject=function(n,i){typeof n.path=="string"?t.loadSVGFromURL(n.path,function(r){var u=r[0],f=n.path;delete n.path;t.util.object.extend(u,n);u.setSourcePath(f);i(u)}):i(new t.Path(n.path,n))};t.Path.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(["d"]);t.Path.fromElement=function(n,i,r){var f=t.parseAttributes(n,t.Path.ATTRIBUTE_NAMES);i&&i(new t.Path(f.d,u(f,r)))};t.Path.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.invoke,u=t.Object.prototype.toObject;if(t.PathGroup){t.warn("fabric.PathGroup is already defined");return}t.PathGroup=t.util.createClass(t.Path,{type:"path-group",fill:"",initialize:function(n,t){t=t||{};this.paths=n||[];for(var i=this.paths.length;i--;)this.paths[i].group=this;this.setOptions(t);this.setCoords();t.sourcePath&&this.setSourcePath(t.sourcePath)},render:function(n){var i,r,u;if(this.visible){for(n.save(),i=this.transformMatrix,i&&n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(n),this._setShadow(n),this.clipTo&&t.util.clipContext(this,n),r=0,u=this.paths.length;r<u;++r)this.paths[r].render(n,!0);this.clipTo&&n.restore();this._removeShadow(n);this.active&&(this.drawBorders(n),this.drawControls(n));n.restore()}},_set:function(n,t){if(n==="fill"&&t&&this.isSameColor())for(var i=this.paths.length;i--;)this.paths[i]._set(n,t);return this.callSuper("_set",n,t)},toObject:function(n){var t=i(u.call(this,n),{paths:r(this.getObjects(),"toObject",n)});return this.sourcePath&&(t.sourcePath=this.sourcePath),t},toDatalessObject:function(n){var t=this.toObject(n);return this.sourcePath&&(t.paths=this.sourcePath),t},toSVG:function(n){for(var r=this.getObjects(),t=["<g ",'style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransform(),'" ',">"],i=0,u=r.length;i<u;i++)t.push(r[i].toSVG(n));return t.push("<\/g>"),n?n(t.join("")):t.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},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"#<fabric.Group: ("+this.complexity()+")>"},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<u;r++)this._renderObject(this._objects[r],n);this.clipTo&&n.restore();!i&&this.active&&(this.drawBorders(n),this.drawControls(n));n.restore()}},_renderObject:function(n,t){var i=n.borderScaleFactor,r=n.hasRotatingPoint,u=Math.max(this.scaleX,this.scaleY);n.visible&&(n.borderScaleFactor=u,n.hasRotatingPoint=!1,n.render(t),n.borderScaleFactor=i,n.hasRotatingPoint=r)},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},_moveFlippedObject:function(n){var i=n.get("originX"),r=n.get("originY"),u=n.getCenterPoint(),t;return n.set({originX:"center",originY:"center",left:u.x,top:u.y}),this._toggleFlipping(n),t=n.getPointByOrigin(i,r),n.set({originX:i,originY:r,left:t.x,top:t.y}),this},_toggleFlipping:function(n){this.flipX&&(n.toggle("flipX"),n.set("left",-n.get("left")),n.setAngle(-n.getAngle()));this.flipY&&(n.toggle("flipY"),n.set("top",-n.get("top")),n.setAngle(-n.getAngle()))},_restoreObjectState:function(n){return this._setObjectPosition(n),n.setCoords(),n.hasControls=n.__origHasControls,delete n.__origHasControls,n.set("active",!1),n.setCoords(),delete n.group,this},_setObjectPosition:function(n){var i=this.getLeft(),r=this.getTop(),t=this._getRotatedLeftTop(n);n.set({angle:n.getAngle()+this.getAngle(),left:i+t.left,top:r+t.top,scaleX:n.get("scaleX")*this.get("scaleX"),scaleY:n.get("scaleY")*this.get("scaleY")})},_getRotatedLeftTop:function(n){var t=this.getAngle()*(Math.PI/180);return{left:-Math.sin(t)*n.getTop()*this.get("scaleY")+Math.cos(t)*n.getLeft()*this.get("scaleX"),top:Math.cos(t)*n.getTop()*this.get("scaleY")+Math.sin(t)*n.getLeft()*this.get("scaleX")}},destroy:function(){return this._objects.forEach(this._moveFlippedObject,this),this._restoreObjectsState()},saveCoords:function(){return this._originalLeft=this.get("left"),this._originalTop=this.get("top"),this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){return this.forEachObject(function(n){n.setCoords()}),this},_setOpacityIfSame:function(){var n=this.getObjects(),t=n[0]?n[0].get("opacity"):1,i=n.every(function(n){return n.get("opacity")===t});i&&(this.opacity=t)},_calcBounds:function(){for(var i,r=[],u=[],n,t=0,f=this._objects.length;t<f;++t){n=this._objects[t];n.setCoords();for(i in n.oCoords)r.push(n.oCoords[i].x),u.push(n.oCoords[i].y)}this.set(this._getBounds(r,u))},_getBounds:function(n,t){var i=r(n),s=u(n),f=r(t),h=u(t),e=s-i||0,o=h-f||0;return{width:e,height:o,left:i+e/2||0,top:f+o/2||0}},toSVG:function(n){for(var t=["<g ",'transform="',this.getSvgTransform(),'">'],i=0,r=this._objects.length;i<r;i++)t.push(this._objects[i].toSVG(n));return t.push("<\/g>"),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<i;t++)if(this._objects[t][n])return!0;return!1}return n in this.delegatedProperties?this._objects[0]&&this._objects[0].get(n):this[n]}}),t.Group.fromObject=function(n,i){t.util.enlivenObjects(n.objects,function(r){delete n.objects;i&&i(new t.Group(r,n))})},t.Group.async=!0)}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=fabric.util.object.extend;if(n.fabric||(n.fabric={}),n.fabric.Image){fabric.warn("fabric.Image is already defined.");return}fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",crossOrigin:"",initialize:function(n,t){t||(t={});this.filters=[];this.callSuper("initialize",t);this._initElement(n,t);this._initConfig(t);t.filters&&(this.filters=t.filters,this.applyFilters())},getElement:function(){return this._element},setElement:function(n,t){return this._element=n,this._originalElement=n,this._initConfig(),this.filters.length!==0&&this.applyFilters(t),this},setCrossOrigin:function(n){return this.crossOrigin=n,this._element.crossOrigin=n,this},getOriginalSize:function(){var n=this.getElement();return{width:n.width,height:n.height}},render:function(n,t){if(this.visible){n.save();var i=this.transformMatrix,r=this.group&&this.group.type==="path-group";r&&n.translate(-this.group.width/2+this.width/2,-this.group.height/2+this.height/2);i&&n.transform(i[0],i[1],i[2],i[3],i[4],i[5]);t||this.transform(n);n.save();this._setShadow(n);this.clipTo&&fabric.util.clipContext(this,n);this._render(n);this.shadow&&!this.shadow.affectStroke&&this._removeShadow(n);this._renderStroke(n);this.clipTo&&n.restore();n.restore();this.active&&!t&&(this.drawBorders(n),this.drawControls(n),this.drawDimensionInfo(n));n.restore()}},_stroke:function(n){n.save();this._setStrokeStyles(n);n.beginPath();n.strokeRect(-this.width/2,-this.height/2,this.width,this.height);n.closePath();n.restore()},_renderDashedStroke:function(n){var t=-this.width/2,i=-this.height/2,r=this.width,u=this.height;n.save();this._setStrokeStyles(n);n.beginPath();fabric.util.drawDashedLine(n,t,i,t+r,i,this.strokeDashArray);fabric.util.drawDashedLine(n,t+r,i,t+r,i+u,this.strokeDashArray);fabric.util.drawDashedLine(n,t+r,i+u,t,i+u,this.strokeDashArray);fabric.util.drawDashedLine(n,t,i+u,t,i,this.strokeDashArray);n.closePath();n.restore()},toObject:function(n){return t(this.callSuper("toObject",n),{src:this._originalElement.src||this._originalElement._src,filters:this.filters.map(function(n){return n&&n.toObject()}),crossOrigin:this.crossOrigin})},toSVG:function(n){var t=[],i;return t.push('<g transform="',this.getSvgTransform(),'">','<image xlink:href="',this.getSvgSrc(),'" style="',this.getSvgStyles(),'" transform="translate('+-this.width/2+" "+-this.height/2+")",'" width="',this.width,'" height="',this.height,'" preserveAspectRatio="none"',"><\/image>"),(this.stroke||this.strokeDashArray)&&(i=this.fill,this.fill=null,t.push("<rect ",'x="',this.width/-2,'" y="',this.height/-2,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>'),this.fill=i),t.push("<\/g>"),n?n(t.join("")):t.join("")},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},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;t<e;t+=4)i[t]+=r,i[t+1]+=r,i[t+2]+=r;u.putImageData(f,0,0)},toObject:function(){return i(this.callSuper("toObject"),{brightness:this.brightness})}});t.Image.filters.Brightness.fromObject=function(n){return new t.Image.filters.Brightness(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Convolute=t.util.createClass(t.Image.filters.BaseFilter,{type:"Convolute",initialize:function(n){n=n||{};this.opaque=n.opaque;this.matrix=n.matrix||[0,0,0,0,1,0,0,0,0];var i=t.util.createCanvasElement();this.tmpCtx=i.getContext("2d")},_createImageData:function(n,t){return this.tmpCtx.createImageData(n,t)},applyTo:function(n){for(var t,i,r,l,a,u,f,b=this.matrix,k=n.getContext("2d"),v=k.getImageData(0,0,n.width,n.height),e=Math.round(Math.sqrt(b.length)),d=Math.floor(e/2),o=v.data,y=v.width,g=v.height,p=y,nt=g,tt=this._createImageData(p,nt),s=tt.data,ft=this.opaque?1:0,h=0;h<nt;h++)for(t=0;t<p;t++){var et=h,ot=t,c=(h*p+t)*4,it=0,rt=0,ut=0,w=0;for(i=0;i<e;i++)for(r=0;r<e;r++)(l=et+i-d,a=ot+r-d,l<0||l>g||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<o;t+=4)i[t+3]=e+255*(f-t)/f;r.putImageData(u,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold})}});t.Image.filters.GradientTransparency.fromObject=function(n){return new t.Image.filters.GradientTransparency(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={});t.Image.filters.Grayscale=t.util.createClass(t.Image.filters.BaseFilter,{type:"Grayscale",applyTo:function(n){for(var f=n.getContext("2d"),r=f.getImageData(0,0,n.width,n.height),i=r.data,e=r.width*r.height*4,t=0,u;t<e;)u=(i[t]+i[t+1]+i[t+2])/3,i[t]=u,i[t+1]=u,i[t+2]=u,t+=4;f.putImageData(r,0,0)}});t.Image.filters.Grayscale.fromObject=function(){return new t.Image.filters.Grayscale}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={});t.Image.filters.Invert=t.util.createClass(t.Image.filters.BaseFilter,{type:"Invert",applyTo:function(n){for(var r=n.getContext("2d"),u=r.getImageData(0,0,n.width,n.height),i=u.data,f=i.length,t=0;t<f;t+=4)i[t]=255-i[t],i[t+1]=255-i[t+1],i[t+2]=255-i[t+2];r.putImageData(u,0,0)}});t.Image.filters.Invert.fromObject=function(){return new t.Image.filters.Invert}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Mask=t.util.createClass(t.Image.filters.BaseFilter,{type:"Mask",initialize:function(n){n=n||{};this.mask=n.mask;this.channel=[0,1,2,3].indexOf(n.channel)>-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;r<l;r+=4)h[r+3]=s[r+c];e.putImageData(u,0,0)}},toObject:function(){return i(this.callSuper("toObject"),{mask:this.mask.toObject(),channel:this.channel})}});t.Image.filters.Mask.fromObject=function(n,i){t.util.loadImage(n.mask.src,function(r){n.mask=new t.Image(r,n.mask);i&&i(new t.Image.filters.Mask(n))})};t.Image.filters.Mask.async=!0}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Noise=t.util.createClass(t.Image.filters.BaseFilter,{type:"Noise",initialize:function(n){n=n||{};this.noise=n.noise||100},applyTo:function(n){for(var u=n.getContext("2d"),f=u.getImageData(0,0,n.width,n.height),i=f.data,e=this.noise,r,t=0,o=i.length;t<o;t+=4)r=(.5-Math.random())*e,i[t]+=r,i[t+1]+=r,i[t+2]+=r;u.putImageData(f,0,0)},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}});t.Image.filters.Noise.fromObject=function(n){return new t.Image.filters.Noise(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Pixelate=t.util.createClass(t.Image.filters.BaseFilter,{type:"Pixelate",initialize:function(n){n=n||{};this.blocksize=n.blocksize||4},applyTo:function(n){for(var h=n.getContext("2d"),f=h.getImageData(0,0,n.width,n.height),i=f.data,w=f.height,s=f.width,t,u,c,l,a,v,e,y,o,p,r=0;r<w;r+=this.blocksize)for(u=0;u<s;u+=this.blocksize)for(t=r*4*s+u*4,c=i[t],l=i[t+1],a=i[t+2],v=i[t+3],e=r,y=r+this.blocksize;e<y;e++)for(o=u,p=u+this.blocksize;o<p;o++)t=e*4*s+o*4,i[t]=c,i[t+1]=l,i[t+2]=a,i[t+3]=v;h.putImageData(f,0,0)},toObject:function(){return i(this.callSuper("toObject"),{blocksize:this.blocksize})}});t.Image.filters.Pixelate.fromObject=function(n){return new t.Image.filters.Pixelate(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.RemoveWhite=t.util.createClass(t.Image.filters.BaseFilter,{type:"RemoveWhite",initialize:function(n){n=n||{};this.threshold=n.threshold||30;this.distance=n.distance||20},applyTo:function(n){for(var h=n.getContext("2d"),c=h.getImageData(0,0,n.width,n.height),i=c.data,l=this.threshold,e=this.distance,o=255-l,s=Math.abs,r,u,f,t=0,a=i.length;t<a;t+=4)r=i[t],u=i[t+1],f=i[t+2],r>o&&u>o&&f>o&&s(r-u)<e&&s(r-f)<e&&s(u-f)<e&&(i[t+3]=1);h.putImageData(c,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold,distance:this.distance})}});t.Image.filters.RemoveWhite.fromObject=function(n){return new t.Image.filters.RemoveWhite(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={});t.Image.filters.Sepia=t.util.createClass(t.Image.filters.BaseFilter,{type:"Sepia",applyTo:function(n){for(var u=n.getContext("2d"),f=u.getImageData(0,0,n.width,n.height),i=f.data,e=i.length,r,t=0;t<e;t+=4)r=.3*i[t]+.59*i[t+1]+.11*i[t+2],i[t]=r+100,i[t+1]=r+50,i[t+2]=r+255;u.putImageData(f,0,0)}});t.Image.filters.Sepia.fromObject=function(){return new t.Image.filters.Sepia}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={});t.Image.filters.Sepia2=t.util.createClass(t.Image.filters.BaseFilter,{type:"Sepia2",applyTo:function(n){for(var e=n.getContext("2d"),o=e.getImageData(0,0,n.width,n.height),i=o.data,s=i.length,r,u,f,t=0;t<s;t+=4)r=i[t],u=i[t+1],f=i[t+2],i[t]=(r*.393+u*.769+f*.189)/1.351,i[t+1]=(r*.349+u*.686+f*.168)/1.203,i[t+2]=(r*.272+u*.534+f*.131)/2.14;e.putImageData(o,0,0)}});t.Image.filters.Sepia2.fromObject=function(){return new t.Image.filters.Sepia2}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),i=t.util.object.extend;t.Image.filters.Tint=t.util.createClass(t.Image.filters.BaseFilter,{type:"Tint",initialize:function(n){n=n||{};this.color=n.color||"#000000";this.opacity=typeof n.opacity!="undefined"?n.opacity:new t.Color(this.color).getAlpha()},applyTo:function(n){var e=n.getContext("2d"),o=e.getImageData(0,0,n.width,n.height),r=o.data,y=r.length,i,s,h,c,l,a,v,u,f;for(f=new t.Color(this.color).getSource(),s=f[0]*this.opacity,h=f[1]*this.opacity,c=f[2]*this.opacity,u=1-this.opacity,i=0;i<y;i+=4)l=r[i],a=r[i+1],v=r[i+2],r[i]=s+l*u,r[i+1]=h+a*u,r[i+2]=c+v*u;e.putImageData(o,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,opacity:this.opacity})}});t.Image.filters.Tint.fromObject=function(n){return new t.Image.filters.Tint(n)}}(typeof exports!="undefined"?exports:this),function(n){"use strict";var t=n.fabric||(n.fabric={}),u=t.util.object.extend,f=t.util.object.clone,i=t.util.toFixed,e=t.StaticCanvas.supports("setLineDash"),r;if(t.Text){t.warn("fabric.Text is already defined");return}r=t.Object.prototype.stateProperties.concat();r.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor","useNative","path");t.Text=t.util.createClass(t.Object,{_dimensionAffectingProps:{fontSize:!0,fontWeight:!0,fontFamily:!0,textDecoration:!0,fontStyle:!0,lineHeight:!0,stroke:!0,strokeWidth:!0,text:!0},_reNewline:/\r?\n/,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",textDecoration:"",textAlign:"left",fontStyle:"",lineHeight:1.3,textBackgroundColor:"",path:null,useNative:!0,stateProperties:r,stroke:null,shadow:null,initialize:function(n,t){t=t||{};this.text=n;this.__skipDimension=!0;this.setOptions(t);this.__skipDimension=!1;this._initDimensions();this.setCoords()},_initDimensions:function(){if(!this.__skipDimension){var n=t.util.createCanvasElement();this._render(n.getContext("2d"))}},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_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;i<u;i++)r=this._getLineWidth(n,t[i]),f=this._getLineLeftOffset(r),this._boundaries.push({height:this.fontSize*this.lineHeight,width:r,left:f})},_setTextStyles:function(n){this._setFillStyles(n);this._setStrokeStyles(n);n.textBaseline="alphabetic";this.skipTextAlign||(n.textAlign=this.textAlign);n.font=this._getFontDeclaration()},_getTextHeight:function(n,t){return this.fontSize*t.length*this.lineHeight},_getTextWidth:function(n,t){for(var u,i=n.measureText(t[0]||"|").width,r=1,f=t.length;r<f;r++)u=n.measureText(t[r]).width,u>i&&(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<l;e++)this._renderChars(n,t,o[e],r+c,u,f),c+=t.measureText(o[e]).width+p}else this._renderChars(n,t,i,r,u,f)},_getLeftOffset:function(){return t.isLikelyNode?0:-this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextFill:function(n,t){var r,i,u,f;if(this.fill||this._skipFillStrokeCheck)for(this._boundaries=[],r=0,i=0,u=t.length;i<u;i++)f=this._getHeightOfLine(n,i,t),r+=f,this._renderTextLine("fillText",n,t[i],this._getLeftOffset(),this._getTopOffset()+r,i)},_renderTextStroke:function(n,t){var r,i,u,f;if(this.stroke||this._skipFillStrokeCheck){for(r=0,n.save(),this.strokeDashArray&&(1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray),e&&n.setLineDash(this.strokeDashArray)),n.beginPath(),i=0,u=t.length;i<u;i++)f=this._getHeightOfLine(n,i,t),r+=f,this._renderTextLine("strokeText",n,t[i],this._getLeftOffset(),this._getTopOffset()+r,i);n.closePath();n.restore()}},_getHeightOfLine:function(){return this.fontSize*this.lineHeight},_renderTextBackground:function(n,t){this._renderTextBoxBackground(n);this._renderTextLinesBackground(n,t)},_renderTextBoxBackground:function(n){this.backgroundColor&&(n.save(),n.fillStyle=this.backgroundColor,n.fillRect(this._getLeftOffset(),this._getTopOffset(),this.width,this.height),n.restore())},_renderTextLinesBackground:function(n,t){var i,u,r,f;if(this.textBackgroundColor){for(n.save(),n.fillStyle=this.textBackgroundColor,i=0,u=t.length;i<u;i++)t[i]!==""&&(r=this._getLineWidth(n,t[i]),f=this._getLineLeftOffset(r),n.fillRect(this._getLeftOffset()+f,this._getTopOffset()+i*this.fontSize*this.lineHeight,r,this.fontSize*this.lineHeight));n.restore()}},_getLineLeftOffset:function(n){return this.textAlign==="center"?(this.width-n)/2:this.textAlign==="right"?this.width-n:0},_getLineWidth:function(n,t){return this.textAlign==="justify"?this.width:n.measureText(t).width},_renderTextDecoration:function(n,t){function r(r){for(var e,s,f=0,o=t.length;f<o;f++)e=i._getLineWidth(n,t[f]),s=i._getLineLeftOffset(e),n.fillRect(i._getLeftOffset()+s,~~(r+f*i._getHeightOfLine(n,f,t)-u),e,1)}if(this.textDecoration){var u=this._getTextHeight(n,t)/2,i=this;this.textDecoration.indexOf("underline")>-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('<g transform="',this.getSvgTransform(),'">',t.textBgRects.join(""),"<text ",this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(),'" ','transform="translate(',i(u.textLeft,2)," ",i(u.textTop,2),')">',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<o;u++)r[u]!==""?(s=this._boundaries&&this._boundaries[u]?this._boundaries[u].left:0,f.push('<tspan x="',i(s+e+this.shadow.offsetX,2),u===0||this.useNative?'" y':'" dy','="',i(this.useNative?n*u-this.height/2+this.shadow.offsetY:n+(u===0?this.shadow.offsetY:0),2),'" ',this._getFillAttributes(this.shadow.color),">",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<o;r++)(i[r]!==""?(this._setSVGTextLineText(i[r],r,e,n,f,u),f=1):f++,this.textBackgroundColor&&this._boundaries)&&this._setSVGTextLineBg(u,r,t,n);return{textSpans:e,textBgRects:u}},_setSVGTextLineText:function(n,r,u,f,e){var o=this._boundaries&&this._boundaries[r]?i(this._boundaries[r].left,2):0;u.push('<tspan x="',o,'" ',r===0||this.useNative?"y":"dy",'="',i(this.useNative?f*r-this.height/2:f*e,2),'" ',this._getFillAttributes(this.fill),">",t.util.string.escapeXml(n),"<\/tspan>")},_setSVGTextLineBg:function(n,t,r,u){n.push("<rect ",this._getFillAttributes(this.textBackgroundColor),' x="',i(r+this._boundaries[t].left,2),'" y="',i(u*t-this.height/2,2),'" width="',i(this._boundaries[t].width,2),'" height="',i(this._boundaries[t].height,2),'"><\/rect>')},_setSVGBg:function(n){this.backgroundColor&&this._boundaries&&n.push("<rect ",this._getFillAttributes(this.backgroundColor),' x="',i(-this.width/2,2),'" y="',i(-this.height/2,2),'" width="',i(this.width,2),'" height="',i(this.height,2),'"><\/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)}}();RoomPlannerV2=function(){function er(n){var r=$("#room-planner-help-template").html(),f=$("#room-planner-help-tip-template").html(),u="",i,t;for(i in helpOpen)t=f,t=i==0?t.replace(/{Active}/g," __active"):t.replace(/{Active}/g,""),t=t.replace(/{Title}/g,helpOpen[i].title),t=t.replace(/{Image}/g,helpOpen[i].image),t=t.replace(/{Text}/g,helpOpen[i].text),u+=t;r=r.replace(/{Tips}/g,u);n(r)}function pt(){$(p).addClass("__open");$("body").css("overflow","hidden");wt()}function or(){ai();$(p).removeClass("__open");$("body").css("overflow","");$(".quickList").removeClass("quickList_roomPlannerOpen");et.stop();TrackEvent("Room Planner","Close","",!0,parseFloat(et.getSeconds()))}function si(n){$.ajax({type:"GET",url:nt+"/RoomPlannerV1.svc/GetGenericProductTypes",dataType:"jsonp",success:function(t){var u=t.Icons,h=$("#room-planner-side-icon-header-template").html(),c=$("#room-planner-side-icon-group-item-template").html(),s=!0,i="",e="",f,r,o;for(f in u)r=c,e!=u[f].RoomName&&(o=h,s||(i+="<\/div>"),e=u[f].RoomName,o=e==null||e==""?o.replace(/{RoomName}/g,"Miscellaneous"):o.replace(/{RoomName}/g,e),i+=o,i+='<div class="room-planner-side__icon-group">'),r=r.replace(/{ImageUrl}/g,u[f].ImageUrl),r=r.replace(/{Width}/g,u[f].Width),r=r.replace(/{Depth}/g,u[f].Depth),r=r.replace(/{IconId}/g,u[f].IconId),r=r.replace(/{ProductTypeId}/g,u[f].ProductTypeId),r=r.replace(/{ProductType}/g,u[f].ProductType),i+=r,s&&(s=!1),e=="Living Room"&&u[f].ProductTypeId=="-1089650625"&&(i+=sr());i+="<\/div>";i+='<div class="room-planner-side__icon-header">Structural<\/div>';i+='<div class="room-planner-side__icon-group">';i+="<div class='canvasObjectContainer'><img class='canvasObject generic structural' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Door_OpensRight.png' rp-width='36' rp-depth='36' id='icon_a' rp-iconid='a' producttype='a' ptn='Door (Opens Right)' /><span>Door (Opens Right)<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic structural' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Door_OpensLeft.png' rp-width='36' rp-depth='36' id='icon_b' rp-iconid='b' producttype='b' ptn='Door (Opens Left)' /><span>Door (Opens Left)<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic structural' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Window.png' rp-width='55' rp-depth='5' id='icon_c' rp-iconid='c' producttype='c' ptn='Window' /><span>Window<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Structural_Fireplace.png' rp-width='52' rp-depth='9' id='icon_d' rp-iconid='d' producttype='d' ptn='Fireplace' /><span>Fireplace<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Structural_FrenchDoors.png' rp-width='80' rp-depth='36' id='icon_e' rp-iconid='e' producttype='e' ptn='French Doors' /><span>French Doors<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Structural_SlidingDoors.png' rp-width='80' rp-depth='5' id='icon_f' rp-iconid='f' producttype='f' ptn='Sliding Doors' /><span>Sliding Doors<\/span><\/div>";i+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Structural_Stairs.png' rp-width='42' rp-depth='66' id='icon_g' rp-iconid='g' producttype='g' ptn='Stairs' /><span>Stairs<\/span><\/div>";i+="<\/div>";$(".room-planner-side__icons").height($(".room-planner-v2.__open").height()-$(".room-planner-header").height()-$(".room-planner-side__header").height());$(".room-planner-side__icons").html(i);n&&n()},error:function(){}})}function sr(){var n="";return n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_ChairRAF.png' rp-width='36' rp-depth='40' id='icon_sec_chair_raf' rp-iconid='sec_chair_raf' producttype='sec_chair_raf' ptn='Sectional - RAF Chair' /><span>Sectional - RAF Chair<\/span><\/div>",n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_ChairLAF.png' rp-width='36' rp-depth='40' id='icon_sec_chair_laf' rp-iconid='sec_chair_laf' producttype='sec_chair_laf' ptn='Sectional - LAF Chair' /><span>Sectional - LAF Chair<\/span><\/div>",n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_ChairArmless.png' rp-width='36' rp-depth='40' id='icon_sec_chair_armless' rp-iconid='sec_chair_armless' producttype='sec_chair_armless' ptn='Sectional - Armless Chair' /><span style='line-height:1em;'>Sectional - Armless Chair<\/span><\/div>",n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_Wedge.png' rp-width='45' rp-depth='45' id='icon_sec_wedge' rp-iconid='sec_wedge' producttype='sec_wedge' ptn='Sectional - Wedge' /><span>Sectional - Wedge<\/span><\/div>",n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_Corner.png' rp-width='40' rp-depth='40' id='icon_sec_corner' rp-iconid='sec_corner' producttype='sec_corner' ptn='Sectional - Corner' /><span>Sectional - Corner<\/span><\/div>",n+="<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_ChaiseRAF.png' rp-width='40' rp-depth='64' id='icon_sec_chaise_raf' rp-iconid='sec_chaise_raf' producttype='sec_chaise_raf' ptn='Sectional - RAF Chaise' /><span>Sectional - RAF Chaise<\/span><\/div>",n+"<div class='canvasObjectContainer'><img class='canvasObject generic' src='https://images.furnituredealer.net/img/RoomPlanner/ObjectIcons/Livingroom_Sectional_ChaiseLAF.png' rp-width='40' rp-depth='64' id='icon_sec_chaise_laf' rp-iconid='sec_chaise_laf' producttype='sec_chaise_laf' ptn='Sectional - LAF Chaise' /><span>Sectional - LAF Chaise<\/span><\/div>"}function ot(){var t=!0;$(".canvasObject").each(function(){return t=t&&this.complete});t?(udata.RoomPlannerId>0&&(!i.SharedId||i.SharedId!=udata.RoomPlannerId)?bt(udata.RoomPlannerId):su(),vi("canvasObjectContainer"),fu(),settings.addToRoomPlanItemData&&(gt(200,200,settings.addToRoomPlanItemData.width*settings.ppi,settings.addToRoomPlanItemData.depth*settings.ppi,0,"icon_"+settings.addToRoomPlanItemData.iconid,settings.addToRoomPlanItemData.gpid,settings.addToRoomPlanItemData.iconid),n.renderAll(),settings.addToRoomPlanItemData=""),lt=$(".room-planner-side__icons").height()-$(".room-planner-side__icon-header").outerHeight()*$(".room-planner-side__icon-header").length,ci($(".room-planner-side__header-tab.__load")),$(".fdn-spinner").remove(),setTimeout(function(){n.renderAll()},500)):setTimeout(ot,100)}function hr(){$(p).hasClass("__side-closed")?$(p).removeClass("__side-closed"):$(p).addClass("__side-closed");setTimeout(function(){n.calcOffset();n.renderAll()},1e3)}function hi(n){nr?$(n).hasClass("__active")?$(n).hasClass("__active")&&($(".room-planner-side__icon-group.__active").slideUp(function(n){$(n).height("")}),$(".room-planner-side__icon-group.__active").removeClass("__active"),$(".room-planner-side__icons .__active").removeClass("__active")):($(n).addClass("__active"),$(n).next().addClass("__active"),$(n).next().height(lt).slideDown()):($(n).hasClass("__active")||($(".room-planner-side__icon-group.__active").slideUp(function(n){$(n).height("")}),$(".room-planner-side__icons .__active").removeClass("__active"),$(n).addClass("__active"),$(n).next().addClass("__active")),$(n).next().height(lt).slideDown());eu()}function ci(n){$(".room-planner-side__header-tab.__load").removeClass("__load");$(n).hasClass("__active")||($(".room-planner-side__header-tab.__active").removeClass("__active"),$(".room-planner-side__nav > div.__active").removeClass("__active"),$(n).addClass("__active"),$(".room-planner-side__nav > div").eq($(n).index()).addClass("__active"),$(".room-planner-side__nav > div.__active").hasClass("room-planner-side__icons")?$(".room-planner-side__icon-header.__active").length==0&&hi($(".room-planner-side__icons > div:first-child")):$(".room-planner-side__quicklist__items").height((window.innerHeight?window.innerHeight:$(window).height())-$(".room-planner-header").height()-$(".room-planner-side__header").height()-$(".room-planner-side__quicklist__header").outerHeight()))}function wt(n){var t="";t=n!=undefined?Utils.BaseURL+"Quicklist/QuickListRoomPlannerPanel/"+n:Utils.BaseURL+"Quicklist/QuickListRoomPlannerPanel";$.get(t,function(t){$(".room-planner-side__quicklist__items").html(t);cr(n)})}function cr(n){var t="";t=n!=undefined?Utils.BaseURL+"Quicklist/QuickListRoomPlannerItems/"+n:Utils.BaseURL+"Quicklist/QuickListRoomPlannerItems";$.ajax({type:"GET",url:t,cache:!1,success:function(n){$(".room-planner-side__quicklist__items .quicklist-room-planner-items").html(n);$(".room-planner-side__quicklist__item").length>0?($(".room-planner-side__header-tab:first-child").addClass("__load"),$(".room-planner-side__quicklist__header").html("Drag LIST items to add them to your room plan")):($(".room-planner-side__header-tab:last-child").addClass("__load"),$(".room-planner-side__quicklist__header").html('<b>No List Items<\/b><p class="no-mar-bottom">To get started, add items to your List or click the ICONS tab for generic products.<\/p>'));vi("room-planner-side__quicklist__item:not(.__noicon)")},error:function(){}})}function lr(n,t){t==!0?$.ajax({type:"POST",url:Utils.BaseURL+"Quicklist/SetPrimaryQuickList",contentType:"application/json; charset=utf-8",data:JSON.stringify({quickListId:n}),success:function(n){var t=JSON.parse(n);t.Status>0&&wt()},error:function(){}}):wt(n)}function ar(){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;hu(n,t,i,r);k()}function li(n){if(CurrentUser.IsAuthenticated)switch(n){case"open":b(br);break;case"save":b(dr)}else b(wr)}function vr(){var t,o,r,u,e,f;d();t="<table cellpadding='10'>";for(o in i.Objects)r=i.Objects[o],r.ObjectType==2&&(r.Gpid!==undefined?(u=$(".roomPlanner_quickListItems img[itemgpid="+r.Gpid+"]"),t+="<tr>",t+="<td><img style='max-width:200px;max-height:200px' src='"+u.attr("src")+"' /><\/td>",t+="<td><span style='font-size:25px;'>"+u.attr("alt")+"<\/span><br/> Width: "+u.attr("width")+'"<br/> Depth: '+u.attr("depth")+'"<\/td>',t+="<\/tr>"):(e=$(".canvasObject.generic[producttype="+r.GenericObjectType+"]"),t+="<tr>",t+="<td><img style='max-width:200px;max-height:100px' src='"+e.attr("src")+"' /><\/td>",t+="<td><span style='font-size:25px;'>"+e.attr("ptn")+"<\/span><br/> Width: "+Math.round(r.Width)+'"<br/> Depth: '+Math.round(r.Depth)+'"<\/td>',t+="<\/tr>"));t+="<\/table>";f=n.toSVG();f+='<div style="page-break-after:always;"><\/div>';f+=t;f+="";c=window.open();c.document.write(f);c.document.title="Print your plan";c.document.close();setTimeout(function(){c.print()},500)}function b(n){n(function(n){var t=ft;t=t.replace(/{Content}/g,n);$("body").append(yt).append(t)})}function k(){$(".room-planner-modal--mask").remove();$(".room-planner-modal").remove()}function yr(n){var t=$("#room-planner-new-template").html();n(t)}function pr(n){var r=$("#room-planner-help-template").html(),f=$("#room-planner-help-tip-template").html(),u="",i,t;for(i in help)t=f,t=i==0?t.replace(/{Active}/g," __active"):t.replace(/{Active}/g,""),console.log(t),t=t.replace(/{Title}/g,help[i].title),t=t.replace(/{Image}/g,help[i].image),t=t.replace(/{Text}/g,help[i].text),u+=t;r=r.replace(/{Tips}/g,u);n(r)}function wr(n){var t,i,r;d();t=$("#room-planner-not-logged-in-template").html();i=window.location.href.replace(Utils.BaseURL,"").replace("?rp=1","").replace("&rp=1","");i+=(i.includes("?")?"&":"?")+"rp=1";r='<a class="room-planner-modal__btn" href="'+Utils.BaseURL+"login.aspx?ReturnUrl="+encodeURIComponent(i)+'">Login<\/a>';t=t.replace(/{LoginBtn}/g,r);n(t)}function br(n){var i=$("#room-planner-open-plan-template").html(),t="";$.ajax({dataType:"jsonp",url:nt+"/RoomPlannerV1.svc/GetSavedPlansList",jsonpCallback:"plans_data_function",data:{uId:udata.UserId,uSess:udata.UserSession},success:function(r){if(r.RoomPlans!="")for(var u in r.RoomPlans)t+='<div class="room-planner-open-plan__plan" data-id="'+r.RoomPlans[u].Id+'">',t+='<span class="room-planner-open-plan__plan-title">'+r.RoomPlans[u].Title+"<\/span>",t+='<span class="room-planner-open-plan__plan-date">Last Updated: '+r.RoomPlans[u].ModifiedDate+"<\/span>",t+="<\/div>";else t="<div>You have no saved plans<\/div>";i=i.replace(/{Plans}/g,t);n(i)}})}function kr(t){bt(t);k();setTimeout(function(){n.renderAll()},500)}function dr(n){var t=$("#room-planner-save-plan-template").html();t=t.replace(/{Title}/g,i.Title);n(t);$(".room-planner-modal").addClass("room-planner-modal--sm")}function gr(){i.Title=document.getElementById("SaveRoom_Title").value;i.Title.match(/^[A-Za-z0-9 _.-]+$/)?(ai(),k()):$(".room-planner-save-plan__error").html('<span style="text-align:center;color:#db4453;">Please enter only alphanumeric characters (letters A-Z, numbers 0-9, hyphens, underscores, and periods)<\/span>')}function nu(n){if(n>0)var t=$.ajax({url:nt+"/RoomPlannerV1.svc/GetProduct",type:"GET",cache:"true",jsonpCallback:"product_data_function",data:{gpid:n,dealerid:CurrentDealer.Id},dataType:"jsonp",success:function(n){var t=$("#room-planner-item-info-template").html(),i="",u="",r;i+="<span>Width: "+n.Width+'"<\/span>';i+="<span>Depth: "+n.Depth+'"<\/span>';i+="<span>Height: "+n.Height+'"<\/span>';u+='<a target="_blank" rel="noopener" class="btn btn-white l-col-xl-6 l-grid-sm-12" href="'+Utils.BaseURL+"item.aspx?itemid="+n.ItemId+"&itemnum="+n.ItemNum+'">View Item Page<\/a>';u+='<div class="btn btn-white l-col-xl-6 l-grid-sm-12 room-planner-clone-item">Clone Item<\/div>';t=t.replace(/{Image}/g,n.Image);t=t.replace(/{Alt}/g,n.MDesc);t=t.replace(/{Title}/g,n.MDesc);t=t.replace(/{Desc}/g,n.SDesc);t=t.replace(/{Dimensions}/g,i);t=t.replace(/{Buttons}/g,u);r=ft;r=r.replace(/{Content}/g,t);$("body").append(yt).append(r)}})}function tu(n,t,i){var r=$("#room-planner-item-info-generic-template").html(),u;r=r.replace(/{Title}/g,n);r=r.replace(/{Width}/g,Math.round(t));r=r.replace(/{Depth}/g,Math.round(i));u=ft;u=u.replace(/{Content}/g,r);$("body").append(yt).append(u);$(".room-planner-modal").addClass("room-planner-modal--sm")}function iu(){au({width:document.getElementById("roomPlanner_iteminfoGeneric_Width").value,height:document.getElementById("roomPlanner_iteminfoGeneric_Depth").value})}function it(n){n&&($(".canvas-container").prepend('<div class="room-planner-status"><span class="fdnicon-checkmark"><\/span> Saved!<\/div>'),setTimeout(function(){$(".room-planner-status").fadeOut()},3e3));ur=n}function ru(){$(".room-planner-help-tip.__active").removeClass("__active").next().addClass("__active");$(".room-planner-help-nav__prev").addClass("__active");$(".room-planner-help-tip.__active").next().length==0&&$(".room-planner-help-nav__next").removeClass("__active")}function uu(){$(".room-planner-help-tip.__active").removeClass("__active").prev().addClass("__active");$(".room-planner-help-nav__next").addClass("__active");$(".room-planner-help-tip.__active").prev().length==0&&$(".room-planner-help-nav__prev").removeClass("__active")}function fu(){$(".room-planner-main").bind("DOMMouseScroll",function(n){n.originalEvent.detail>0?ii():ti()});$(".room-planner-main").bind("mousewheel",function(n){n.originalEvent.wheelDelta<0?ii():ti()})}function eu(){$(".room-planner-side__icon-group.__active .canvasObjectContainer").each(function(){$(this).children(".canvasObject").css("margin-top",($(this).height()-$(this).children(".canvasObject").height())/2-$(this).children("span").height()/2)})}function ou(){c=window.innerWidth?window.innerWidth:$(window).width();rt=window.innerHeight?window.innerHeight:$(window).height();n=new fabric.Canvas("container",{stateful:!1});n.setWidth(c);n.setHeight(rt);n.calcOffset();n.on("object:added",function(n){dt(n.target)});n.on("selection:created",function(n){dt(n.target)});if(window.devicePixelRatio&&window.devicePixelRatio!==1){var t=n.getElement(),i=t.width,r=t.height;t.setAttribute("width",i*window.devicePixelRatio);t.setAttribute("height",r*window.devicePixelRatio);t.getContext("2d").scale(window.devicePixelRatio,window.devicePixelRatio)}gi&&(settings.CURSCALE=.3,$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%"));hf();sf();du();ku();yu();ct();cf();y();n.renderAll()}function su(){var n=1;di()?localStorage.open_plan&&(localStorage.open_plan,i=JSON.parse(localStorage.open_plan),kt(i),n=0):ki("open_plan")&&(bt(ki("open_plan")),n=0);n&&(b(er),i={UserId:udata.UserId,SessionId:udata.UserSession,Title:"Untitled RoomPlan",DealerId:udata.DealerId,CookieId:udata.UserCookie,SharedId:0,Objects:[{ObjectType:1,Corners:JSON.stringify(pi())}]});$(".room-planner-working-on__title").html(i.Title)}function hu(t,r,u,f){t=parseFloat(t);r=parseFloat(r);u=parseFloat(u);f=parseFloat(f);var o=u*12+f,s=t*12+r,h=n.getWidth()-$("#RoomPlanner1_RoomPlannerSideMenu").width(),l=n.getHeight()-$("#RoomPlanner1_RoomPlannerHeader").height(),e=s*settings.ppi,c=o*settings.ppi;(h<e||l<c)&&(settings.CURSCALE=e-h>c-e?Math.round((h/e-.1)*10)/10:Math.round((l/c-.1)*10)/10);kt({Objects:[{ObjectType:1,Corners:JSON.stringify([[a,v],[a+s*settings.ppi*settings.CURSCALE,v],[a+s*settings.ppi*settings.CURSCALE,v+o*settings.ppi*settings.CURSCALE],[a,v+o*settings.ppi*settings.CURSCALE]])}],scale:settings.CURSCALE});delete i.Id;i.Title="Untitled RoomPlan"}function d(){it(!1);i.UserId=udata.UserId;i.SessionId=udata.UserSession;i.DealerId=udata.DealerId;i.CookieId=udata.UserCookie;i.Objects=[{ObjectType:1,Corners:JSON.stringify(pi())}];var t;i.scale=settings.CURSCALE;n.forEachObject(function(n){n==r||n.isLine||n.isTooltip||n.isSnapLine||n==s||n.isPoint||n.isOnWall?n.isOnWall&&(t={ObjectType:n.Type,XCord:n.getLeft(),YCord:n.getTop(),Width:n.getWidth()/settings.ppi/settings.CURSCALE,Depth:n.getHeight()/settings.ppi/settings.CURSCALE,Rotation:n.get("angle")},i.Objects.push(t)):(t={ObjectType:2,XCord:n.getLeft(),YCord:n.getTop(),Width:n.getWidth()/settings.ppi/settings.CURSCALE,Depth:n.getHeight()/settings.ppi/settings.CURSCALE,Rotation:n.get("angle")},n.itemid?(t.Gpid=n.itemid,t.IconId=n.iconid):t.GenericObjectType=n.producttype,i.Objects.push(t))});di()?localStorage.open_plan=JSON.stringify(i):i.Id&&bi("open_plan",i.Id,365)}function ai(){d();$.ajax({type:"POST",url:nt+"/RoomPlannerV1.svc/SavePlanData",dataType:"json",data:JSON.stringify(i),success:function(n){i.Id=n.Id;d();it(!0);$(".room-planner-working-on__title").html(i.Title)}})}function bt(n){$.ajax({dataType:"jsonp",url:nt+"/RoomPlannerV1.svc/GetPlanData",data:{planid:n},success:function(n){kt(n);i=n;udata.RoomPlannerId>0&&(!i.SharedId||i.SharedId!=udata.RoomPlannerId)&&(delete i.Id,i.SharedId=udata.RoomPlannerId);$("#roomPlanner_saveStatus_Title").html(i.Title);$(".room-planner-working-on__title").html(i.Title)}})}function kt(i){var f,u,e;if(i){i.scale&&(settings.CURSCALE=Number(i.scale));$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%");n.forEachObject(function(t){t==r||t.isSnapLine||t==s||n.remove(t)});n.renderAll();i.Objects=yf(i.Objects);i.Objects.unshift(i.Objects.pop());for(f in i.Objects)u=i.Objects[f],u.ObjectType==1?t=wi(JSON.parse(u.Corners)):u.ObjectType==2?(u.GenericObjectType&&(e='[producttype="'+u.GenericObjectType+'"]',u.IconId=$(e).attr("rp-iconid"),u.Gpid=0),u.GenericObjectType=u.GenericObjectType||0,gt(u.XCord,u.YCord,u.Width*settings.ppi,u.Depth*settings.ppi,u.Rotation,"icon_"+u.IconId,u.Gpid,u.IconId,u.GenericObjectType)):u.ObjectType==3?(u.IconId="c",g(st(u.XCord,u.YCord,u.Width*settings.ppi,3,"icon_"+u.IconId))):u.ObjectType==4?(u.IconId="b",g(st(u.XCord,u.YCord,u.Width*settings.ppi*settings.CURSCALE,4,"icon_"+u.IconId))):u.ObjectType==5&&(u.IconId="a",g(st(u.XCord,u.YCord,u.Width*settings.ppi*settings.CURSCALE,5,"icon_"+u.IconId)));y();n.renderAll();d()}}function vi(t){t=t||"canvasObject";var i;$("."+t).draggable({revert:"true",helper:"clone",appendTo:"body",cursor:"move",scroll:!1,zIndex:999,opacity:.3,drag:function(r,u){var f,h,c;if(u.position.left>200-$("."+t).width()){f=u.helper.children("img");u.helper.children("span").hide();var e=f.width(),o=f.height(),y=e/o,a,v=0,s,l;f.hasClass("generic")?(s=f.attr("rp-iconid"),e=parseInt(f.attr("rp-width"),10),o=parseInt(f.attr("rp-depth"),10),a=f.hasClass("structural"),l=f.attr("producttype")):(v=f.attr("itemgpid"),s=f.attr("rp-iconid"),e=parseInt(f.attr("rp-width"),10),o=parseInt(f.attr("rp-depth"),10),f.attr("src",$("#icon_"+s).attr("src")),l=0);f.attr("id","current_image");h=$(n.wrapperEl).offset();i?(i.setLeft(u.position.left+e/2-h.left),i.setTop(u.position.top+o/2-h.top),n.renderAll()):(a?(s==="c"?c=3:s==="b"?c=4:s==="a"&&(c=5),i=st(u.position.left+e/2-h.left,u.position.top+o/2-h.top,e*settings.ppi,c,"current_image")):i=gt(u.position.left+e/2-h.left,u.position.top+o/2-h.top,e*settings.ppi,o*settings.ppi,"0","current_image",v,s,l),i.setCoords(),n.calcOffset(),n.renderAll())}else i&&(n.remove(i),n.renderAll(),i=undefined)},stop:function(){i&&(i.isOnWall&&g(i),i.setCoords(),i=undefined,y())}})}function dt(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 st(t,i,r,u,f){var s,h,o,e;return it(!1),s=r,h="bottom",u==3&&(s=settings.style.walls.width,h="center"),o=new Image,o.src=document.getElementById(f).src+"?"+performance.now().toString(),o.crossOrigin="Anonymous",e=new fabric.Image(o,{left:t,top:i,width:r,height:s,scaleX:settings.CURSCALE,scaleY:settings.CURSCALE,padding:10,originX:"center",originY:h,centeredRotation:!1}),e.isOnWall=1,e.hasBorders=!1,e.Type=u,e.setControlsVisibility({tl:!1,bl:!0,tr:!1,mtr:!1,mb:!1,mt:!1,br:!0,InfoControl:!1,DepthMeasurement:!1}),(u==4||u==5)&&e.setControlsVisibility({tl:!1,bl:!0,tr:!1,mtr:!1,mb:!1,mt:!1,br:!0,mr:!1,ml:!1,InfoControl:!1,DepthMeasurement:!1}),n.add(e),e}function gt(t,i,r,u,f,e,o,s,h){var l,c;return it(!1),l=new Image,l.src=document.getElementById(e).src+"?"+performance.now().toString(),l.crossOrigin="Anonymous",c=new fabric.Image(l,{left:t,top:i,width:r,height:u,angle:f,scaleX:settings.CURSCALE,scaleY:settings.CURSCALE,originX:"center",originY:"center",producttype:h}),c.itemid=o,c.iconid=s,o?c.setControlsVisibility(ir):c.setControlsVisibility(tr),c.padding=10,c.cornerSize=20,c.hasBorders=!1,n.add(c),c}function cu(){var n=o.itemid||0;if(h=o,n)setTimeout(function(){nu(n,ut)},100);else{var t=o.iconid,i=o.producttype,r=$('[producttype="'+i+'"]').attr("ptn"),u=$("#icon_"+t).attr("src"),f=o.getWidth()/settings.ppi/settings.CURSCALE,e=o.getHeight()/settings.ppi/settings.CURSCALE,s=o.getAngle();setTimeout(function(){tu(r,f,e,s,u,ut)},100)}}function lu(){if(it(!1),!h)return"no current popup";n.discardActiveObject();var t=fabric.util.object.clone(h);t.setLeft(t.getLeft()+10);t.setTop(t.getTop()+10);n.add(t);n.setActiveObject(t);n.renderAll()}function au(t){if(!h)return"no current popup";t.width&&h.setWidth(t.width*settings.ppi);t.height&&h.setHeight(t.height*settings.ppi);t.top&&h.setTop(t.top);t.left&&h.setLeft(t.left);t.angle&&h.setAngle(t.angle);h.setCoords();n.renderAll()}function vu(){if(!o){alert("no object selected");return}o.isPoint?bu(o):n.remove(o);n.renderAll();o=undefined;return}function yu(){t=wi([[a,v+ui*settings.ppi*settings.CURSCALE],[a,v],[ri*settings.ppi*settings.CURSCALE+a,v],[ri*settings.ppi*settings.CURSCALE+a,v+ui*settings.ppi*settings.CURSCALE]])}function y(){var u=[],h,t,i,e,f,o;for(h in settings.indexes)u.push([]);t=n.getObjects();for(i in t)t[i]==r?u[settings.indexes.background-1].push(t[i]):t[i].isLine?u[settings.indexes.walls-1].push(t[i]):t[i].isPoint?u[settings.indexes.corners-1].push(t[i]):t[i]==s?u[settings.indexes.background-1].push(t[i]):t[i].isOnWall?u[settings.indexes.doorswindows-1].push(t[i]):u[settings.indexes.objects-1].push(t[i]);e=2;for(f in u)for(o in u[f])u[f][o].bringToFront(),e++;n.renderAll()}function yi(n,t){var i=vf(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 ht(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 pu(n,i,r){var f,u,s,h;for(u in t)s=ht(t[u].line1.x1,t[u].line1.y1,t[u].line1.x2,t[u].line1.y2,n,i),h=ht(t[u].line2.x1,t[u].line2.y1,t[u].line2.x2,t[u].line2.y2,n,i),u==0&&(f=s),f.dist>s.dist&&(f=s),f.dist>h.dist&&(f=h);for(var c=r/360,e=f.angle/360,o=e+.5;o>1;)o--;while(o<0)o++;while(e>1)e--;while(e<0)e++;return Math.abs(e-c)>Math.abs(o-c)&&(f.angle=o*360),f}function wu(i){var r,u;for(var f in t)t[f].line1==i&&(r=t[f]),t[f].line2==i&&(u=t[f]);r.setLeft(i.x1);r.setTop(i.y1);u.setLeft(i.x2);u.setTop(i.y2);r.setCoords();u.setCoords();n.fire("object:moving",{target:r});n.fire("object:moving",{target:u});e(r);e(u)}function e(t){var e=t.left,o=t.top,s,i,r;t.group&&(s=t.group,e+=s.left,o+=s.top);t.line1.set({x1:e,y1:o});t.line1.setCoords();i=ht(t.line1.x1,t.line1.y1,t.line1.x2,t.line1.y2,t.line1.left,t.line1.top);(i.angle>90&&i.angle<=180||i.angle>=-180&&i.angle<-90)&&(i.angle+=180);var u=i.angle-90,f=20*settings.CURSCALE,h=Math.cos(u*(Math.PI/180))*f,c=Math.sin(u*(Math.PI/180))*f;t.line1.tooltip.setLeft(i.x+h);t.line1.tooltip.setTop(i.y+c);t.line1.tooltip.setAngle(i.angle);t.line1.tooltip.setCoords();t.line1.tooltip.setText(yi(t.line1,settings.unitSystem));t.line2.set({x2:e,y2:o});t.line2.setCoords();r=ht(t.line2.x1,t.line2.y1,t.line2.x2,t.line2.y2,t.line2.left,t.line2.top);(r.angle>90&&r.angle<=180||r.angle>=-180&&r.angle<-90)&&(r.angle+=180);u=r.angle-90;h=Math.cos(u*(Math.PI/180))*f;c=Math.sin(u*(Math.PI/180))*f;t.line2.tooltip.setLeft(r.x+h);t.line2.tooltip.setTop(r.y+c);t.line2.tooltip.setAngle(r.angle);t.line2.tooltip.setCoords();t.line2.tooltip.setText(yi(t.line2,settings.unitSystem));n.forEachObject(function(n){n.isOnWall&&g(n)})}function pi(){for(var r=[],f=t.length,n=t[0],u,i;n;){r.push([n.getLeft(),n.getTop()]);u=n.line1;for(i in t)t[i].line2==u&&(n=t[i]);n==t[0]&&(n=undefined)}return r}function wi(n){var u=n.length,i=[],f,r,t,o;for(t in n)f=t+2<=u?l(n[t][0],n[t][1],n[parseFloat(t)+1][0],n[parseFloat(t)+1][1]):l(n[t][0],n[t][1],n[0][0],n[0][1]),i.push(f);r=[];for(t in n)o=parseFloat(t)+2<=u?w(n[t][0],n[t][1],i[t],i[parseFloat(t)+1]):w(n[t][0],n[t][1],i[t],i[0]),r.push(o);for(t in r)e(r[t]);return r}function l(t,i,r,u){var f=new fabric.Line([t,i,r,u],{stroke:settings.style.walls.color,strokeWidth:settings.style.walls.width*settings.CURSCALE,selectable:!0,originX:"center",originY:"center"});return f.isLine=1,f.clicked=0,f.hasControls=f.hasBorders=!1,n.add(f),f.tooltip=new fabric.Text("10'5\"",{originX:"center",originY:"center",fontSize:settings.style.walls.tooltip.fontsize,fontFamily:"Arial",left:100,top:100}),n.add(f.tooltip),f.tooltip.hasControls=f.tooltip.hasBorders=f.tooltip.selectable=!1,f.tooltip.isTooltip=!0,f}function bu(i){var r,s;if(!(t.length<3)){var u=i.line1,f=i.line2,o=l(100,100,200,200),h,c;for(r in t)(t[r].line1==u||t[r].line1==f)&&(t[r].line1=o,h=t[r]),(t[r].line2==u||t[r].line2==f)&&(t[r].line2=o,c=t[r]);t.splice(t.indexOf(i),1);n.remove(u);n.remove(u.tooltip);n.remove(f);n.remove(f.tooltip);n.remove(i);o.setCoords();n.renderAll();for(s in t)e(t[s]);y()}}function w(t,i,r,u){var f=new fabric.Circle({left:t,top:i,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 f.isPoint=1,f.line1=r,f.line2=u,f.hasBorders=!1,f.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}),n.add(f),f}function ku(){u=[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"})];f=[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"})];u[0].isSnapLine=u[1].isSnapLine=u[2].isSnapLine=f[0].isSnapLine=f[1].isSnapLine=f[2].isSnapLine=!0;n.add(u[0]);n.add(u[1]);n.add(u[2]);n.add(f[0]);n.add(f[1]);n.add(f[2])}function du(){n.on({"mouse:down":rf,"object:rotating":ff,"object:moving":ef,"mouse:up":uf,"object:scaling":of,"object:modified":tf,"selection:created":nf,"object:selected":gu});window.onresize=function(n){af(n)}}function gu(t){if(o=t.target,t.target.isLine&&(t.target.oldx=t.target.left,t.target.oldy=t.target.top),t.target==r||t.target.isLine){n.renderAll();o=undefined;return}y();t.target.bringToFront()}function nf(t){n.discardActiveObject();n.discardActiveGroup();n.remove(t.target);n.renderAll();return}function tf(n){n.target.isOnWall&&g(n.target);d()}function g(n){var t=pu(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 rf(t){ut.x=t.e.clientX;ut.y=t.e.clientY;obj=t.target;obj==r&&(n.renderAll(),o=undefined,t.target.hasControls=t.target.hasBorders=!1,at=obj.getLeft(),vt=obj.getTop());n.renderAll()}function uf(i){var h=n.getPointer(i.e).x,c=n.getPointer(i.e).y,r,a,p,b,o,s,v;if(i.target){if(i.target.isLine&&(r=i.target,r.clicked)){a=[l(h,c,h,c),l(h,c,h,c)];for(o in t)t[o].line1==r&&(s=a.shift(),t[o].line1=s,b=s,e(t[o])),t[o].line2==r&&(s=a.shift(),t[o].line2=s,p=s,e(t[o]));v=w(h,c,p,b);t.push(v);r.tooltip.sendToBack();r.sendToBack();n.remove(r.tooltip);n.remove(r);n.fire("object:moving",{target:v});y();n.renderAll()}i.target.clicked=1;setTimeout(function(){i.target.clicked=0},1e3);f[0].visible=!1;f[1].visible=!1;f[2].visible=!1;u[0].visible=!1;u[1].visible=!1;u[2].visible=!1;n.renderAll()}}function ff(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)<t?obj.angle=90:Math.abs(obj.angle-0)<t?obj.angle=0:Math.abs(obj.angle-180)<t?obj.angle=180:Math.abs(obj.angle-270)<t?obj.angle=270:Math.abs(obj.angle-360)<t&&(obj.angle=360)}}function ef(t){var h,c,i;if(obj=t.target,!obj.isOnWall){if(obj.isPoint&&e(obj),obj.isLine&&(h=obj.left-obj.oldx,c=obj.top-obj.oldy,obj.set({x1:obj.x1+h,y1:obj.y1+c,x2:obj.x2+h,y2:obj.y2+c}),obj.setCoords(),obj.oldx=obj.left,obj.oldy=obj.top,wu(obj)),obj==r){var v=obj.getLeft(),y=obj.getTop(),l=v-at,a=y-vt;at=v;vt=y;n.forEachObject(function(n){n.isLine?(n.x1+=l,n.x2+=l,n.y1+=a,n.y2+=a,n.set({x1:n.x1}),n.setCoords()):n!=r&&(n.setLeft(n.getLeft()+l),n.setTop(n.getTop()+a),n.setCoords())})}else if(settings.snapping.moving.enabled){if(obj.isOnWall)return;if(obj.setCoords(),i=obj.getBoundingRect(),obj.isPoint)i.x=[i.left+i.width/2],i.y=[i.top+i.height/2];else{if(obj.isLine){i.x=[];i.y=[];return}i.x=[i.left,i.left+i.width/2,i.left+i.width];i.y=[i.top,i.top+i.height/2,i.top+i.height]}snappedx=[];snappedy=[];var o=0,s=0,p=settings.snapping.moving.sensitivity;n.forEachObject(function(n){var t,h,v,c,l,w,y,a,b,k,d;if(n.name!="grid"&&n!=r&&n!=obj&&n.name!="snap"){if(t=n.getBoundingRect(),n.isTooltip)return;if(obj.isPoint){if(!n.isPoint)return}else if(n.isPoint)return;if(n.isPoint)t.x=[t.left+t.width/2],t.y=[t.top+t.height/2];else{if(n.isLine)return;t.x=[t.left,t.left+t.width/2,t.left+t.width];t.y=[t.top,t.top+t.height/2,t.top+t.height]}for(h in i.x){v=i.x[h];for(c in t.x)if((c==1||h!=1)&&(c!=1||h==1)&&(l=t.x[c],Math.abs(v-l)<=p)){if(o>2)return;w=l-v;obj.setLeft(i.left+i.width/2+w);obj.setCoords();obj.isPoint&&e(obj);f[o].set({x1:l,x2:l});f[o].moveTo(1e3);snappedx.push(o);o++}}for(h in i.y){y=i.y[h];for(c in t.y)if((c==1||h!=1)&&(c!=1||h==1)&&(a=t.y[c],Math.abs(y-a)<=p)){if(s>2)return;b=a-y;obj.setTop(i.top+i.height/2+b);obj.setCoords();obj.isPoint&&e(obj);u[s].set({y1:a,y2:a});u[s].moveTo(1e3);snappedy.push(s);s++}}f[0].visible=!1;f[1].visible=!1;f[2].visible=!1;u[0].visible=!1;u[1].visible=!1;u[2].visible=!1;for(k in snappedx)f[snappedx[k]].visible=!0;for(d in snappedy)u[snappedy[d]].visible=!0;obj.snappedx=0;obj.snappedy=0;obj.setCoords()}})}n.renderAll()}}function of(){settings.snapping.moving.enabled}function sf(){r=new fabric.Rect({width:4e3,height:4e3,left:1e3,top:1e3,originX:"center",originY:"center",fill:settings.style.general.background});n.add(r);r.selectable=!0;r.hasControls=r.hasBorders=!1;r.sendToBack()}function hf(){fi=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 cf(){n.forEachObject(function(n){dt(n);n.isLine?(n.strokeWidth=settings.style.walls.width*settings.CURSCALE,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)});r.fill=settings.style.general.background;n.renderAll()}function ct(){settings.grid.enabled?lf(settings.grid.spacing,settings.grid.width,settings.grid.color):s&&(n.remove(s),s=undefined,n.renderAll())}function lf(t,i,u){var f,e,o;if(r){for(settings.CURSCALE&&(t*=settings.CURSCALE),f=[],x=-2e3;x<=r.width/2;x+=t)e=[[x,-2e3],[x,2e3]],o=[[-2e3,x],[2e3,x]],f.push(e),f.push(o);s&&(n.remove(s),s=undefined);s=new fi(f,i,u);s.name="grid";n.add(s);y();n.renderAll()}}function ni(t,i){var e=n.width*t,o=n.width*i,u=(e-o)/2,s=n.height*t,h=n.height*i,f=(s-h)/2;n.forEachObject(function(n){n.isLine?(n.x1+=u,n.x2+=u,n.y1+=f,n.y2+=f,n.set({x1:n.x1}),n.setCoords()):n!=r&&(n.setLeft(n.getLeft()+u),n.setTop(n.getTop()+f),n.setCoords())})}function ti(){var i,r,u;if(!(settings.CURSCALE>3)){i=n.getObjects();for(r in i)if(i[r].isLine||i[r].isTooltip)i[r].isLine&&(i[r].strokeWidth=i[r].strokeWidth/settings.CURSCALE*(settings.CURSCALE+.1));else{var f=i[r].scaleX,o=i[r].scaleY,s=i[r].left,h=i[r].top,c=f/settings.CURSCALE*(settings.CURSCALE+.1),l=o/settings.CURSCALE*(settings.CURSCALE+.1),a=s/settings.CURSCALE*(settings.CURSCALE+.1),v=h/settings.CURSCALE*(settings.CURSCALE+.1);i[r].scaleX=c;i[r].scaleY=l;i[r].left=a;i[r].top=v;i[r].setCoords()}settings.CURSCALE+=.1;for(u in t)e(t[u]);ct();ni(settings.CURSCALE-.1,settings.CURSCALE);n.renderAll();$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%")}}function ii(){var i,r,u;if(!(settings.CURSCALE<.2)){i=n.getObjects();for(r in i)if(i[r].isLine||i[r].isTooltip)i[r].isLine&&(i[r].strokeWidth=i[r].strokeWidth/settings.CURSCALE*(settings.CURSCALE-.1));else{var f=i[r].scaleX,o=i[r].scaleY,s=i[r].left,h=i[r].top,c=f/settings.CURSCALE*(settings.CURSCALE-.1),l=o/settings.CURSCALE*(settings.CURSCALE-.1),a=s/settings.CURSCALE*(settings.CURSCALE-.1),v=h/settings.CURSCALE*(settings.CURSCALE-.1);i[r].scaleX=c;i[r].scaleY=l;i[r].left=a;i[r].top=v;i[r].setCoords()}settings.CURSCALE-=.1;for(u in t)e(t[u]);ct();ni(settings.CURSCALE+.1,settings.CURSCALE);n.renderAll();$("#roomPlanner_zoomCurscale").text(Math.round(settings.CURSCALE*10)*10+"%")}}function af(){if(c=$(window).width(),rt=$(window).height(),n.setWidth(c),n.setHeight(rt),window.devicePixelRatio&&window.devicePixelRatio!==1){var t=n.getElement(),i=t.width,r=t.height;t.setAttribute("width",i*window.devicePixelRatio);t.setAttribute("height",r*window.devicePixelRatio);t.getContext("2d").scale(window.devicePixelRatio,window.devicePixelRatio)}n.calcOffset();n.renderAll()}function vf(n,t,i,r){return Math.sqrt((n-i)*(n-i)+(t-r)*(t-r))}function bi(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 ki(n){for(var t,r=n+"=",u=document.cookie.split(";"),i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1,t.length);if(t.indexOf(r)===0)return t.substring(r.length,t.length)}return null}function di(){try{return"localStorage"in window&&window.localStorage!==null}catch(n){return!1}}function yf(n){for(var t=null,i=null,u=n.length,r,t=0,i=u-1;t<i;t+=1,i-=1)r=n[t],n[t]=n[i],n[i]=r;return n}var gi=Modernizr.mq("only screen and (max-width: 47.9375em)")?!0:!1,nr=Modernizr.mq("only screen and (min-width: 47.9375em) and (max-width: 63.9375em)")?!0:!1,fr,et,tt,oi;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}}},addToRoomPlanItemData:""};help=[{title:"Adding Items to Room Plan",text:"Drag & drop any product icon from the left side menu",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help1.gif"},{title:"Resizing & Rotating",text:"Click & drag the resize and rotate icons to manipulate an item",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help2.gif"},{title:"Item Info",text:'Click the "i" icon for more information about an item',image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help3.gif"},{title:"Zooming In & Out",text:"Click the + and - in the lower right corner to zoom in & out",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help4.gif"}];helpOpen=[{title:"Welcome to the Room Planner!",text:"Browse our tips on how to best use the tool or close this to get started designing",image:"https://images.furnituredealer.net/img/RoomPlanner/screenshot.png"},{title:"Adding Items to Room Plan",text:"Drag & drop any product icon from the left side menu",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help1.gif"},{title:"Resizing & Rotating",text:"Click & drag the resize and rotate icons to manipulate an item",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help2.gif"},{title:"Item Info",text:'Click the "i" icon for more information about an item',image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help3.gif"},{title:"Zooming In & Out",text:"Click the + and - in the lower right corner to zoom in & out",image:"https://images.furnituredealer.net/img/roomplanner/roomplanner_help4.gif"}];var c=window.innerWidth?window.innerWidth:$(window).width(),rt=window.innerHeight?window.innerHeight:$(window).height(),tr={tl:!1,bl:!1,tr:!1,mtr:!1,leftWall:!1,rightWall:!1},ir={tl:!1,bl:!1,tr:!1,mtr:!1,mb:!1,mt:!1,mr:!1,ml:!1,leftWall:!1,rightWall:!1},a=50,v=50,ri=204,ui=180,lt=0,s,n,h,u,f,r,at,vt,rr,o,fi,t,ut={},i={},ur=!0,ei=!0,p=$(".room-planner-v2"),yt='<div class="room-planner-modal--mask" />',ft="",nt="https://api.furnituredealer.net";Modernizr.mq("only screen and (max-width: 47.9375em)")&&$(p).addClass("__side-closed");fr=0;et=new StopWatch;$(".room-planner--trigger").on("click",function(){$(".room-planner-main .canvas-container").length==0?tt():pt();et.start();TrackEvent("Room Planner","Open","",!0)});$("body").on("click",".js-add-to-room-plan",function(){settings.addToRoomPlanItemData=$(this).data("room-plan-item");tt();typeof laurentideTracker!="undefined"&&Laurentide_AddToRoomplan(settings.addToRoomPlanItemData)});$("body").on("click",".room-planner-close--trigger",function(){or()});$("body").on("click",".room-planner-modal-close",function(){k()});$("body").on("click",".room-planner-modal--mask",function(){k()});$("body").on("click",".room-planner-header__new",function(){b(yr)});$("body").on("click",".room-planner-header__open",function(){li("open")});$("body").on("click",".room-planner-header__save",function(){li("save")});$("body").on("click",".room-planner-header__help",function(){b(pr)});$("body").on("click",".room-planner-header__print",function(){vr()});$("body").on("click",".room-planner-new__btn",function(){ar()});$("body").on("click",".room-planner-clone-item",function(){lu();k()});$("body").on("focus",".room-planner-item-info-generic__input",function(){$(this).select()});$("body").on("change",".room-planner-item-info-generic__input",function(){iu()});$("body").on("click",".room-planner-open-plan__plan",function(){kr($(this).data("id"))});$("body").on("click",".room-planner-save-plan__btn",function(){gr()});$("body").on("click",".room-planner-side--trigger",function(){hr()});$("body").on("click",".room-planner-side__icon-header",function(){hi(this)});$("body").on("click",".room-planner-side__header-tab",function(){ci(this)});$("body").on("change",".quicklist-room-planner-lists__ddl",function(){lr(this.value,$(this).find(":selected").data("owner"))});$("body").on("click","#roomPlanner_zoomIn",function(){ti()});$("body").on("click","#roomPlanner_zoomOut",function(){ii()});$("body").on("click",".room-planner-help-nav__prev.__active",function(){uu()});$("body").on("click",".room-planner-help-nav__next.__active",function(){ru()});return tt=function(){ei?$("#room-planner-templates").load(Utils.BaseURL+"room-planner-templates.html",function(n,t){t=="error"?alert("The Room Planner failed to load"):($(p).html($("#room-planner-template").html()),ft=$("#room-planner-modal-template").html(),pt(),setTimeout(function(){ou();si(function(){ot()})},2e3),ei=!1)}):(pt(),ot())},oi=function(data){settings.addToRoomPlanItemData=eval("("+$(data).attr("rel")+")");tt();laurentideTracker&&Laurentide_AddToRoomplan($(data).data("room-plan-item"))},window.addEventListener("orientationchange",function(){si(function(){ot()})},!1),{settings:settings,init:tt,deleteThis:vu,infoPopup:cu,AddToRoomPlan:oi}}()