function OCRmanager(e){this.m_Silent=!0,this.m_UsePica=!1,this.m_EncodeAsPNG=!0,this.m_CannyPreProcess=!1,this.m_PreprocessDone=!1,this.id="OCRmanager",e?this.m_url="http://192.168.1.49:7070/images":this.m_EncodeAsPNG?this.m_url="http://ec2-52-211-180-164.eu-west-1.compute.amazonaws.com:3000/images":this.m_url="http://ec2-52-211-180-164.eu-west-1.compute.amazonaws.com:3000/images",this.m_UsingBackupURL=!1,this.m_EncodeAsPNG?this.m_BackupURL="":this.m_BackupURL="",this.m_Callback=null,this.m_ErrorCallback=null,this.m_SceneVPs=[],this.m_Width=0,this.m_Height=0,this.m_ScaledCanvas=null,this.m_ScaleFactorX=1,this.m_ScaleFactorY=1,this.m_Busy=!1,this.m_ForceStop=!1,this.m_PostTryIdx=0,this.POST_MAX_TRIES=3,this.m_TimeBetweenPostTries=2e3,this.m_Markers=[],this.m_MarkerSizeFeet=.5807087,this.m_DetectedMats=[],this.m_SKUS=[],this.m_MinSKUlength=3,this.m_MinWordLength=3,this.m_MaxLeven=2,this.m_Words=[],this.m_UniqueDescriptorWords=[],this.m_UniqueDescriptorPhrases=[],this.m_MatchList=[]}function OCRReader(e,t){function o(e,o,i){r(e,function(e){if(location.href.indexOf("help")!=-1){var o=JSON.stringify(e,void 0,2);alert(vobj(e))}for(var r=0,n=0,a=0;ae.height?o/e.width:o/e.height,i=document.createElement("canvas"),i.width=e.width*r,i.height=e.height*r,pica.resizeCanvas(e,i,{},function(){t(i)})}var i=null;l||($("body").append(''),$("input[type=file].m-hidden-ocr-upload-trigger-button").change(function(r){e();var n=new FileReader;n.onload=function(e){var r=new Image;r.src=n.result,r.onload=function(){var e=Math.max(r.width,r.height);e>s?o(r,s):(i=document.createElement("canvas"),i.width=r.width,i.height=r.height,i.getContext("2d").drawImage(r,0,0),t(i))}},n.readAsDataURL(r.target.files[0]),this.value=null}),l=!0),$("input[type=file].m-hidden-ocr-upload-trigger-button").trigger("click")}function r(e,t){function o(){t(a.getMatchList())}function i(){alert("OCR Error")}function r(){alert("OCR Send")}return null==e?void alert("readOCRText(): No photo"):void a.doOCR(e,o,i,r)}var n=this,e=e,a;const s=5e3;for(var l=!1,a=new OCRmanager(!1),u=new Array,c=0;c1&&(t=",");for(var o="\n",i="",r=0,n=e.charAt(r),a=0,s=0,l=new Array;n!=i;){for(;" "==n||"\t"==n||"\r"==n;)n=e.charAt(++r);var u="";if('"'==n){n=e.charAt(++r);do if('"'!=n&&(u+=n,n=e.charAt(++r)),'"'==n){var c=e.charAt(r+1);'"'==c&&(u+='"',r+=2,n=e.charAt(r))}while(n!=i&&'"'!=n);if(n==i)throw"Unexpected end of data, double-quote expected";n=e.charAt(++r)}else for(;n!=i&&n!=t&&n!=o&&"\t"!=n&&"\r"!=n;)u+=n,n=e.charAt(++r);for(l.length<=a&&l.push(new Array),l[a].push(u);" "==n||"\t"==n||"\r"==n;)n=e.charAt(++r);if(n==t)s++;else if(n==o)s=0,a++;else if(n!=i)throw"Delimiter expected after character "+r+" "+n+" "+n.charCodeAt(0);if(n=e.charAt(++r),n==i&&a>0)for(;s"+n.thumbnailName+"
"),a=a.replace("[[[SKU1]]]",n.sku),a=a.replace("[[[SKU2]]]",n.sku),null!=e){var s=e[n.sku];void 0==s&&alert("setupAllProducts(): SKU not found in thumbnails pack: "+n.sku),s=s.replace("url('","url('mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/"),s=s.replace(".jpg",".jpg?"+mobileVisualizerStopCaching),a=a.replace('style=""','style="'+s+'"'),a=a.replace("HIDE-IMAGE","m-hide")}else a=a.replace('src=""','src="'+n.thumbnail+'"'),a=a.replace("HIDE-BACKGROUND-IMAGE","m-hide");t+=a,++i}}$(".m-product-thumbnails-inject").html(t)}if(mobileVisualizerConfig.enableSimpleUYORooms)return void e();if(!mobileVisualizerConfig.thumbnailsFromPack)return t(null),void e();var o="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/thumbnailpacks-100.json?"+mobileVisualizerStopCaching;"Desktop"==w&&(o="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/thumbnailpacks-200.json?"+mobileVisualizerStopCaching),VUtils.loadTextFromURL(o,function(o){y=JSON.parse(o),t(y),e()})}function h(){for(var e="",t=$(".m-product-filter-template").html(),o=$(".m-product-filter-item-template").html(),i=null,r=0;r',"[DELETE]",'',"[RED+]",'',"[RED-]",'',"[GREEN+]",'',"[GREEN-]",''],r=o;"Desktop"==w&&(r=t),r=r.concat(i);for(var n=0;n0&&0==mobileVisualizer.getNumDecoratedTexturedWalls()||mobileVisualizer.getNumFloors()>0&&0==mobileVisualizer.getNumTexturedWalls()?($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").show(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").hide()):mobileVisualizer.getNumDecoratedTexturedWalls()>0&&0==mobileVisualizer.getNumDecoratedFloors()||mobileVisualizer.getNumTexturedWalls()>0&&0==mobileVisualizer.getNumFloors()?($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").show(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").hide()):($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").show()),!mobileVisualizer.isStairsRoom()&&"UYO"==mobileVisualizer.getCurRoomId()&&mobileVisualizerConfig.enableToolsFloorPatchAndMask?($(".m-tool-button.mm-patch-floor-area").show(),$(".m-tool-button.mm-mask-floor-area").show()):($(".m-tool-button.mm-patch-floor-area").hide(),$(".m-tool-button.mm-mask-floor-area").hide()),"UYO"==mobileVisualizer.getCurRoomId()&&mobileVisualizerConfig.enableToolsEditingTools?$(".m-tool-button.mm-editing-tools").show():$(".m-tool-button.mm-editing-tools").hide(),$(".m-tool-button.mm-edit-stairs").hide(),mobileVisualizer.isStairsRoom()&&($(".m-tool-button.mm-edit-stairs").removeClass("mm-disabled"),mobileVisualizer.isDecoratedFloor()||$(".m-tool-button.mm-edit-stairs").addClass("mm-disabled"),$(".m-tool-button.mm-edit-stairs").show()),$(".m-tool-button.mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide").hide();var r=0;$(".m-tool-button").each(function(){$(this).hasClass(".mm-patch-floor-area")||$(this).hasClass(".mm-mask-floor-area")||"none"!=$(this).css("display")&&($(this).hasClass("mm-wide")?r+=2:++r)}),r%2==1?$(".m-tool-button.mm-rotate-floor").show():$(".m-tool-button.mm-rotate-floor-wide").show(),mobileVisualizer.isStairsRoom()&&($(".m-tool-button.mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide").hide()),mobileVisualizerConfig.enableSimpleUYORooms||$(".m-tools-container").show()},this.toggleRecentlyUsedAndFavourites=function(){x=!x,l()},this.updateRecentyUsedAndFavourites=function(){l()},this.showLanding=function(e){e?($(".m-header .mm-all-buttons").hide(),$(".m-landing-container").show()):($(".m-header .mm-all-buttons").show(),$(".m-landing-container").hide(),mobileVisualizerConfig.enableSimpleUYORooms&&$(".m-header .mm-all-buttons").hide()),mobileVisualizerConfig.panoModeOnly&&$(".m-header .mm-all-buttons").hide(),D=e},this.isLandingVisible=function(){return D},this.showLandingContent=function(e){e?$(".m-landing-content").show():$(".m-landing-content").hide()},this.isQuickSelectorOn=function(){return O},this.setQuickSelectorMode=function(e){e?(v.dontShowHelp(),$(".m-tools-container").css("right","-"+$(".m-tools-container").width()+"px"),_=!1,n(),$(".m-quick-selector").show(),O=!0):($(".m-header .mm-menu-button").show(),$(".m-header .mm-tools-button").show(),v.toggleTools(),$(".m-quick-selector").hide(),O=!1)},this.toggleMenu=function(){if(p(),E)v.closeMenu();else{var e=mobileVisualizer.getLastPlacedFloor();$(".m-menu-selector.mm-view-panoramic-room").removeClass("mm-disabled"),null!=e&&""==e.gotPano&&$(".m-menu-selector.mm-view-panoramic-room").addClass("mm-disabled"),$(".m-menu-selector.mm-choose-saved-room").removeClass("mm-disabled"),0==mobileVisualizer.getSavedRooms().length&&$(".m-menu-selector.mm-choose-saved-room").addClass("mm-disabled"),$(".m-menu-container .mm-editing-tools").hide(),"UYO"==mobileVisualizer.getCurRoomId()&&mobileVisualizerConfig.enableMenuEditingTools&&$(".m-menu-container .mm-editing-tools").show(),I&&v.closeRoomSelector(),k&&v.closeProductSelector(),P&&v.closePaintSelector(),$(".m-menu-container").animate({left:"0px"},200),E=!0}},this.closeMenu=function(){E=!1,$(".m-menu-container").animate({left:"-100%"},200)},this.toggleTools=function(){mobileVisualizerConfig.enableSimpleUYORooms||E||I||k||P||(p(),_?($(".m-tools-container").animate({right:"-"+$(".m-tools-container").width()},200),_=!1):($(".m-tools-container").animate({right:"0px"},200),_=!0))},this.openRoomSelector=function(e){e&&0==mobileVisualizer.getSavedRooms().length||(a(e),p(),E&&v.closeMenu(),$(".m-room-selector-heading").hide(),e?$(".m-room-selector-heading.mm-saved-rooms").show():$(".m-room-selector-heading.mm-stock-rooms").show(),$(".m-room-selector-container").scrollTop(0),$(".m-room-selector-container").animate({top:"0px"},200,function(){I&&$(".m-room-selector-close-container").show()}),I=!0)},this.closeRoomSelector=function(e){$(".m-room-selector-close-container").hide(),$(".m-room-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()}),I=!1},this.openProductSelector=function(e){return $(".m-select-paint-button").hide(),mobileVisualizerConfig.enablePaintButton&&mobileVisualizer.getNumWalls()>0&&("UYO"!=mobileVisualizer.getCurRoomId()?$(".m-select-paint-button").show():mobileVisualizerConfig.noUYOWallPaint||$(".m-select-paint-button").show()),
p(),E&&v.closeMenu(),void 0!=e&&e?($(".m-product-selector-container").scrollTop(0),$(".m-product-selector-container").css({top:"0px"}),$(".m-product-selector-close-container").show(),void(k=!0)):($(".m-product-selector-container").scrollTop(0),$(".m-product-selector-container").animate({top:"0px"},200,function(){$(".m-product-selector-close-container").show()}),void(k=!0))},this.closeProductSelector=function(e){v.closeProductTypesSelector(),v.closeProductFilterSelector(),v.closeFilters(),$(".m-product-selector-close-container").hide(),$(".m-product-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()}),k=!1},this.switchToPaintSelector=function(){$(".m-product-selector-close-container").hide(),$(".m-product-selector-container").css({top:"-100%"}),$(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").css({top:"0px"}),$(".m-paint-selector-close-container").show(),P=!0},this.openPaintSelector=function(){p(),E&&v.closeMenu(),$(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").animate({top:"0px"},200,function(){$(".m-paint-selector-close-container").show()}),P=!0},this.closePaintSelector=function(e){$(".m-paint-selector-close-container").hide(),$(".m-paint-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()}),P=!1},this.updateNewRoomProductTypes=function(){if(!mobileVisualizer.curRoomSupportsProductTypeSubType(V,B))for(var e=0;e=e.canvas.height){s=document.createElement("canvas"),s.width=e.canvas.height,s.height=e.canvas.width;var i=s.getContext("2d");i.save(),i.translate(e.canvas.height,0),i.rotate(90*Math.PI/180),i.drawImage(e.canvas,0,0),i.restore()}var l=document.createElement("canvas");l.width=Math.floor(h*s.width/s.height),l.height=h;var u=l.getContext("2d");if(u.fillStyle=p,u.fillRect(0,0,l.width,l.height),r)n.resize(s,l,{unsharpAmount:30,unsharpRadius:.5,unsharpThreshold:15,quality:3,alpha:!0}).then(function(){var e=document.createElement("canvas");e.width=h,e.height=h;var i=e.getContext("2d");i.fillStyle=p,i.fillRect(0,0,e.width,e.height),i.drawImage(l,(e.width-l.width)/2,0),a(t,m,e,o)});else{w=l.height*e.canvas.width/e.canvas.height,x=(l.width-w)/2,u.drawImage(s,0,0,s.width,s.height,0,0,l.width,l.height);var c=document.createElement("canvas");c.width=h,c.height=h;var f=c.getContext("2d");f.fillStyle=p,f.fillRect(0,0,c.width,c.height),f.drawImage(l,(c.width-l.width)/2,0),a(t,m,c,o)}}else{d(m,e.canvas,k);var l=document.createElement("canvas");l.width=h,l.height=h;var u=l.getContext("2d"),c=document.createElement("canvas");c.width=500,c.height=500,"TapiCarpets"==mobileVisualizerConfigType&&(c.width=200,c.height=200);var f=c.getContext("2d"),g=f.createPattern(e.canvas,"repeat");f.fillStyle=g,f.save(),f.translate(c.height,0),f.rotate(90*Math.PI/180),f.fillRect(0,0,c.width,c.height),f.restore(),r?n.resize(c,l,{unsharpAmount:30,unsharpRadius:.5,unsharpThreshold:15,quality:3,alpha:!1}).then(function(){a(t,m,l,o)}):(u.drawImage(c,0,0,c.width,c.height,0,0,l.width,l.height),a(t,m,l,o))}})}function a(e,t,o,r){var n="../../createdthumbnails/"+mobileVisualizerConfigType+"/",a=n+"/"+t.assetRef+".jpg";c(e,t,o,function(){i(e+1,r)})}function s(e,t){var o=new VTileSet;o.setup(e.sku,!1);var i="mobile/config/"+mobileVisualizerConfigType+"/textures/"+e.assetRef+"_c.png?"+uncache;void 0!=e.assetPath&&""!=e.assetPath&&(i="mobile/config/"+mobileVisualizerConfigType+"/textures/"+e.assetPath+"/"+e.assetRef+"_c.png?"+uncache),""!=e.assetFileExt&&(i=i.replace(".png","."+e.assetFileExt)),o.load(!0,i,"",function(){99999==e.width&&(e.width=o.tiles[0].w),99999==e.height&&(e.height=o.tiles[0].h),m+=e.sku+","+e.width+","+e.height+"\n",t(o)})}function l(e,t,o,i){var r=.9;u(e,t,o,r,function(){void 0!=i&&i()})}function u(e,t,o,i,r){var n={base64Data:e.toDataURL("image/jpeg",i).replace(/^data:image\/(png|jpeg);base64,/,""),folder:t,filename:o};$.post("vsavebase64.php",n,function(e){e.indexOf("ERROR")!=-1&&alert("uploadCanvasAsJPG(): Error: "+e),null!=r&&r()})}function c(t,o,i,r){var n="background-image: url('thumbnailspack"+C+"-"+h+".jpg'); ",a=y/h,s=_/h,u=100/(v-1)*a,c=100/(v-1)*s;if(n+="background-position: "+u+"% "+c+"%; ",g[o.sku]=n,A.drawImage(i,y,_),y+=h+f,y>=b.width&&(y=0,_+=h+f),(t+1)%(v*v)!=0&&t+1!=e.products.length)return void r();var d="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/",m=d+"thumbnailspack"+C+"-"+h+".jpg";l(b,d,m,function(){++C,A.fillStyle="#ffffff",A.fillRect(0,0,b.width,b.height),y=0,_=0,r()})}function d(e,t,o){for(var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=!1,a,s,l,u=0;uNote that walls can only take Hardwood and Laminate",5e3)}))}function l(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline").show(),$(".m-uyo-tools").show(),We.showInstructionFor("Drag the circles to adjust the area and [tap] [OK] when finished, or [DELETE] to delete the area",Jt)}function u(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline").show(),$(".m-uyo-tools").show(),We.showInstructionFor("Drag the circles to adjust the area and [tap] [OK] when finished, or [DELETE] to delete",Jt)}function c(){mo.uyoFinishSurfaceEdit(),nt="",$(".m-uyo-tools").hide(),G(function(){m(),We.updateTools(),We.updateCurrentProduct()})}function d(){return mobileVisualizerConfig.enableSimpleUYORooms?void $(".m-simple-room-selector .mm-button-container").hide():(Ve(!1),$(".m-header .mm-all-buttons").hide(),$(".m-open-products-button").hide(),$(".m-tools-container").hide(),void $(".m-current-product-details").hide())}function m(){return mobileVisualizerConfig.enableSimpleUYORooms?void $(".m-simple-room-selector .mm-button-container").show():(Ve(!0),$(".m-header .mm-all-buttons").show(),$(".m-open-products-button").show(),$(".m-tools-container").show(),void $(".m-current-product-details").show())}function h(){We.showMessage(null),$(".m-floor-or-stairs-popup").show()}function f(){bt=!0,g()}function p(){bt=!1,v();var e="FLOOR-"+pe(),t="AreaRef-"+pe();St=new Object,St[t]=new Object,St[t].id="Stairs",St[t].gridName=e,St[t].type="texture",St[t].isLayer=!1,St[t].decoration=null,St[t].decorationRotate=0,St[t].rugDecoration=null,St[t].sku=null,ne(function(){We.updateNewRoomProductTypes(),We.updateCurrentProduct(),We.updateTools()})}function g(){Ve(!1),$(".m-header .mm-all-buttons").hide(),$(".m-open-products-button").hide(),$(".m-tools-container").hide(),$(".m-current-product-details").hide(),We.hideHelp(),Zt=We.isQuickSelectorOn(),Zt&&We.setQuickSelectorMode(!1)}function v(){We.updateTools(),$(".m-header .mm-all-buttons").show(),$(".m-open-products-button").show(),$(".m-tools-container").show(),Zt&&We.setQuickSelectorMode(!0)}function b(){var e=new Object;if(e.roomId=ft,e.roomData=St,"UYO"==ft){var t=.5;e.uyoData=JSON.parse(mo.getUYOEditData()),e.uyoOriginalRoomImage=JSON.parse(mo.getUYOOriginalRoomImage(t))}e.thumbnail=y(400,266).toDataURL("image/jpeg",.5),uo.save(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef,e)||uo.save(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef,null)}function w(){var e=uo.load(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef);return null!=e&&("Started"==VUtils.loadCookie("AutoLoading")?(VUtils.saveCookie("AutoLoading","Finished"),lo.track("@AutoLoadFailed"),!1):(VUtils.saveCookie("AutoLoading","Started"),"UYO"==e.roomId?M(e.uyoData,e.uyoOriginalRoomImage,function(){We.showLanding(!1),S(),De(null),St=VUtils.clone(e.roomData),ne(function(){k(),We.updateCurrentProduct(),We.updateNewRoomProductTypes(),VUtils.saveCookie("AutoLoading","Finished")})}):N(e.roomId,function(){We.showLanding(!1),De(null),St=VUtils.clone(e.roomData),ne(function(){k(),We.updateCurrentProduct(),We.updateNewRoomProductTypes(),VUtils.saveCookie("AutoLoading","Finished")})}),!0))}function A(){vt||(vt=!0,We.updateQuickSelector())}function C(){pt=uo.load(mobileVisualizerConfigType+"-MobileVisualizer-SavedRooms-"+mobileVisualizerConfig.savedRoomsRef),null==pt&&(pt=new Array,uo.save(mobileVisualizerConfigType+"-MobileVisualizer-SavedRooms-"+mobileVisualizerConfig.savedRoomsRef,pt));for(var e=!1,t=0;t0){i.font="30px Arial",i.textAlign="center";for(var m=0,u=0;u0&&(x+=20+n/2),i.fillStyle="rgba(32,32,32,0.7)",i.fillRect(x-n/2,t,n,a),i.fillStyle="#fff";for(var h=t,u=0;u0){i.font="30px Arial",i.textAlign="center";for(var m=0,u=0;u135&&(St[e].decorationRotate=0)),G(function(){We.updateTools(),We.updateCurrentProduct()})}function q(e){null!=mt&&(clearTimeout(mt),mt=null),We.showInstruction(null),nt="",St[e].rugDecoration.decorationRotate=90-St[e].rugDecoration.decorationRotate,G(function(){We.updateTools(),We.updateCurrentProduct()})}function G(e){function t(){Xt.update(Ct.assetRef,Ct.panoVersion,Rt,function(){We.showMessage(null),We.showHelpOnce(),We.updateCurrentProduct(),null!=e&&e()})}function o(){function t(){mo.renderAreasAndLayers(i,o,function(){We.showMessage(null),Oe(),void 0!=e&&e()})}var o=[],i=[],r=25;mobileVisualizerConfig.UseHalfSizedtextures&&(r=12.5),mobileVisualizerConfig.overrideDPI!=-1&&(r=mobileVisualizerConfig.overrideDPI);for(var n in St){var a=St[n];if(null!=a.decoration)if(a.isLayer){var s=a.decoration,l="";90==a.decorationRotate&&(l="_Rotation=90"),VUtils.GetQueryStringParam("vit-testscale")&&(s="OneFootSquares");var u=mobileVisualizerConfig.layersPath+ft+"/"+ft+"_"+n.replace("Ref","")+"_Texture="+s+l+".png";o.push(u)}else if(a.decoration.indexOf("#")==-1){var c=J(a.sku),d=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=c.assetPath&&""!=c.assetPath&&(d+=c.assetPath+"/");var m="png";void 0!=c.assetFileExt&&""!=c.assetFileExt&&(m=c.assetFileExt);var h=d+a.decoration+"_c."+m;VUtils.GetQueryStringParam("vit-testscale")&&(h=d+"OneFootSquares_c.jpg"),h+="?"+mobileVisualizerStopCaching;var f=null;mobileVisualizerConfig.isTextureNormals&&(f=h.replace("_c.","_n."));var p={colourTexture:h,normalTexture:f,pattern:"Linear",lighting:"matt",rotate:a.decorationRotate,dpi:r};"TileMountain"==mobileVisualizerConfigType&&(p.lighting=c.lighting,p.type="Tile",p.groutColour="#FFFFFF",""==c.addNoEdgeGrout&&(p.addGrout=2)),i.push({id:a.id,data:p})}else{var g={colour:a.decoration};i.push({id:a.id,data:g})}}var v=!1;for(var n in St){var a=St[n],b=a.rugDecoration;if(null!=b){var c=J(b.sku),d=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=c.assetPath&&""!=c.assetPath&&(d+=c.assetPath+"/");var m="png";void 0!=c.assetFileExt&&""!=c.assetFileExt&&(m=c.assetFileExt);var h=d+b.decoration+"_c."+m;h+="undefined"!=typeof vitRugMaker?"?"+(new Date).getTime():"?"+mobileVisualizerStopCaching,v=!0;var w={colourTexture:h,normalTexture:null,lighting:"matt",rotate:b.decorationRotate,x:b.x,y:b.y,dpi:25},A=!0;mo.addRug(a.id,w,A,function(){Oe(),t()})}}v||t()}We.showMessage("Rendering",!0),"Pano"==ft&&setTimeout(t,1),"Pano"!=ft&&setTimeout(o,1)}function Y(e){function t(){var t=[],o=25;mobileVisualizerConfig.UseHalfSizedtextures&&(o=12.5),mobileVisualizerConfig.overrideDPI!=-1&&(o=mobileVisualizerConfig.overrideDPI);for(var i in St){var r=St[i],n=J(r.sku),a=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=n.assetPath&&""!=n.assetPath&&(a+=n.assetPath+"/");var s="png";void 0!=n.assetFileExt&&""!=n.assetFileExt&&(s=n.assetFileExt);var l=a+r.decoration+"_c."+s;l+="?"+mobileVisualizerStopCaching;var u=null;mobileVisualizerConfig.isTextureNormals&&(u=l.replace("_c.","_n."));var c={groutColour:"#Transparent",colourTexture:l,normalTexture:u,pattern:"Linear",lighting:"matt",rotate:r.decorationRotate,dpi:o};t.push({id:r.id,data:c})}var d=[];mo.enableSemiTransparentRendering(!0),mo.renderAreasAndLayers(t,d,function(){mo.enableSemiTransparentRendering(!1),We.showMessage(null),null!=e&&e()})}We.showMessage("Preparing",!0),setTimeout(t,1)}function W(){if(void 0!=Ye.productFilters)for(var e=0;et;)Tt.pop();VUtils.saveCookie(mobileVisualizerConfigType+"-MobileVisualizer-RecentlyUsed-"+mobileVisualizerConfig.savedRecentlyUsedRef,JSON.stringify(Tt))}}function oe(){Pt=VUtils.loadCookie(mobileVisualizerConfigType+"-MobileVisualizer-Favourites-"+mobileVisualizerConfig.savedFavouritesRef),Pt=null!=Pt?JSON.parse(Pt):new Array;for(var e=0;e"," ")),$(".m-editing-tools-popup .mm-title").html(mobileVisualizerConfig.editingToolsName.replace("
"," "))),mobileVisualizerConfig.usLanguage&&($(".m-product-selector-heading").each(function(e){$(this).html($(this).html().replace("favourite","favorite")),$(this).html($(this).html().replace("favourite","favorite"))}),$(".m-tool-button-text").each(function(){$(this).html().indexOf("Favourite")!=-1&&$(this).html($(this).html().replace("Favourite","Favorite")),$(this).html().indexOf("favourite")!=-1&&$(this).html($(this).html().replace("favourite","favorite")),$(this).html().indexOf("Favourites")!=-1&&$(this).html($(this).html().replace("Favourites","Favorites"))}),$(".m-paint-selector-container .m-paint-selector-heading").html($(".m-paint-selector-container .m-paint-selector-heading").html().replace("colour","color"))),mobileVisualizerConfig.includeMetadata?"undefined"==typeof mobileVisualizerConfigMetadata?verror("Need to include Metadata .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigMetadata!=mobileVisualizerConfigType&&verror("Wrong Metadata .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigMetadata+")"):"undefined"!=typeof mobileVisualizerConfigMetadata&&verror("No Metadata .kit file required - is set to "+mobileVisualizerConfigMetadata),mobileVisualizerConfig.includeGoogleAnalytics?"undefined"==typeof mobileVisualizerConfigGoogleAnalytics?verror("Need to include Google Analytics .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigGoogleAnalytics!=mobileVisualizerConfigType&&verror("Wrong Google Analytics .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigGoogleAnalytics+")"):"undefined"!=typeof mobileVisualizerConfigGoogleAnalytics&&verror("No Google Analytics .kit file required - is set to "+mobileVisualizerConfigGoogleAnalytics),mobileVisualizerConfig.includeExtraHTML1?"undefined"==typeof mobileVisualizerConfigExtraHTML1?verror("Need to include extra HTML1 .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigExtraHTML1!=mobileVisualizerConfigType&&verror("Wrong extra HTML2 .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigExtraHTML1+")"):"undefined"!=typeof mobileVisualizerConfigExtraHTML1&&verror("No extra HTML1 .kit file required - is set to "+mobileVisualizerConfigExtraHTML1),mobileVisualizerConfig.includeExtraHTML2?"undefined"==typeof mobileVisualizerConfigExtraHTML2?verror("Need to include extra HTML2 .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigExtraHTML2!=mobileVisualizerConfigType&&verror("Wrong extra HTML2 .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigExtraHTML2+")"):"undefined"!=typeof mobileVisualizerConfigExtraHTML2&&verror("No extra HTML2 .kit file required - is set to "+mobileVisualizerConfigExtraHTML2)}function ve(){function e(){var e=$(".m-scene-render").width(),o=$(".m-scene-render").height(),i=e/o,r=document.getElementById("id-visualizer-plugin-render-canvas"),n=r.width,a=r.height,s=n/a;if($("body").removeClass("disable-horizontal-scrolling"),$("body").removeClass("disable-vertical-scrolling"),$(".visualizer-plugin-render-canvas").removeClass("mm-fill-width"),$(".visualizer-plugin-render-canvas").removeClass("mm-fill-height"),t){if(mobileVisualizerConfig.desktopZoomOut)return $("body").addClass("disable-horizontal-scrolling"),$("body").addClass("disable-vertical-scrolling"),void(s>=i?$(".visualizer-plugin-render-canvas").addClass("mm-fill-width"):$(".visualizer-plugin-render-canvas").addClass("mm-fill-height"));$(document).scrollTop($(document).height())}if(s>=i){if(t||$("body").addClass("disable-vertical-scrolling"),$(".visualizer-plugin-render-canvas").addClass("mm-fill-height"),!t){var l=(n*o/a-e)/2;$(window).scrollLeft(l)}}else if(t||$("body").addClass("disable-horizontal-scrolling"),$(".visualizer-plugin-render-canvas").addClass("mm-fill-width"),!t){var l=1.5*(a*e/n-o)/2;$(window).scrollTop(l)}}if(null!=ft&&"Pano"!=ft){var t=!1;$("body").hasClass("m-desktop")&&(t=!0),et=10,t&&(et=1),e(),null!=Ze&&clearInterval(Ze),Ze=setInterval(function(){--et,0==et&&(clearInterval(Ze),Ze=null),e()},25)}}function be(e){if($(".m-phone-popup-message").is(":visible")){var t=85,o=54,i=!1;switch(window.orientation){case 0:e.beta>=o&&e.beta<=180-t&&(i=!0);break;case 90:(e.gamma>=-89.999&&e.gamma<=-o||e.gamma<=89.999&&e.gamma>=t)&&(i=!0);break;case-90:(e.gamma>=o&&e.gamma<=89.999||e.gamma>=-89.999&&e.gamma<=-t)&&(i=!0);break;case 180:}location.href.indexOf("ignorecameravertical")!=-1&&(i=!0),(Xe||i!=Je)&&($(".m-phone-popup-message .m-phone-popup-message-take-photo-button").removeClass("m-phone-not-close-to-vertical"),i||$(".m-phone-popup-message .m-phone-popup-message-take-photo-button").addClass("m-phone-not-close-to-vertical")),location.href.indexOf("showcameraangle")!=-1&&$(".m-phone-popup-message .m-phone-popup-message-take-photo-button p").html(window.orientation+"
Beta: "+e.beta.toFixed(1)+"
Gamma: "+e.gamma.toFixed(1)),Je=i,Xe=!1}}function we(){function e(o){o&&null!==o.alpha&&null!==o.beta&&null!==o.gamma&&(window.removeEventListener("deviceorientation",e),clearTimeout(t),t=null,tt=!0)}if(window.DeviceOrientationEvent){var t=setTimeout(function(){t=null},1e3);window.addEventListener("deviceorientation",e)}}function Ae(){function e(e){e.changedTouches[0].force>=.1&&e.preventDefault()}$(".visualizer-plugin-render-canvas").bind("mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(e){Ce(e)}),document.getElementById("m-save-photo-disable-3d-touch").addEventListener("touchforcechange",e)}function Ce(e){if("UYOEditingFloor"!=nt&&"UYOEditingWall"!=nt){var t=$(".visualizer-plugin-render-canvas")[0],o=t.getBoundingClientRect(),i=t.width/o.width,r=t.height/o.height,n=0,a=0;switch(e.clientX&&e.clientY?(n=(e.clientX-o.left)*i,a=(e.clientY-o.top)*r):e.originalEvent.targetTouches&&e.originalEvent.targetTouches.length>0&&(n=(e.originalEvent.targetTouches[0].clientX-o.left)*i,a=(e.originalEvent.targetTouches[0].clientY-o.top)*r),nt){case"WaitingForFloorSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=de(n,a);null!=s&&Q(s)}return;case"WaitingForFloorOrWallSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=de(n,a);null!=s&&Q(s)}return;case"WaitingForRotateFloorOrWallSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=de(n,a);if(null!=s){var l=St[s];l.decoration.indexOf("#")==-1&&H(s)}}return;case"WaitingForRugPlacement":if("mousedown"==e.type||"touchstart"==e.type){var s=de(n,a);null!=s&&j(s,n,a)}return;case"WaitingForRotateSelection":if("mousedown"==e.type||"touchstart"==e.type)for(var s in St){var l=St[s];if("texture"==l.type){if(null!=l.rugDecoration&&null!=mo.getRugAtXY(n,a))return void q(s);if(null!=l.decoration&&de(n,a)==s)return void H(s)}}return}switch(e.type){case"mousedown":case"touchstart":mo.checkStartDraggingRug(n,a),lt=n,ut=a;break;case"mousemove":case"touchmove":if(!mo.checkDragRug(n,a))break;ct=n-lt,dt=a-ut,e.preventDefault();break;case"mouseout":case"mouseup":case"touchend":mo.checkStopDraggingRug(function(e){if(null!=e){at+=ct,st+=dt;for(var t in St){var o=St[t];if("texture"==o.type&&null!=o.rugDecoration){St[t].rugDecoration.x=at,St[t].rugDecoration.y=st,St[t].rugDecoration.x=e.x,St[t].rugDecoration.y=e.y;break}}We.showMessage(null)}},function(){We.showMessage("Rendering",!0)})}}}function ye(){$(".visualizer-plugin-render-canvas").css("cursor","pointer")}function _e(){$(".visualizer-plugin-render-canvas").css("cursor","default")}function Ee(e){to=mobileVisualizerConfigType+"-"+VUtils.getGUID().replace(/-/g,"").substr(0,6);var t="https://qr.viziserve.com/?photocode="+to+"&name="+document.title;void 0!=e&&(t+="&type="+e),null==eo?eo=new QRCode(document.getElementById("qr-code-container"),{text:t,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.L}):(eo.clear(),eo.makeCode(t))}function Ie(){if(mobileVisualizerConfig.enableRunVisualizerViaQRCode&&"Desktop"==Ke){$(".m-menu-container .mm-run-visualizer-on-phone").show();var e=location.href;new QRCode(document.getElementById("run-on-phone-qr-code-container"),{text:e,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.L})}}function ke(e,t){$.ajax({type:"GET",url:e,dataType:"text",crossDomain:!0,success:function(e){t(e)},error:function(t,o,i){verror("loadTextFromURL(): "+e+" - ajax error: jqXHR.status=["+t.status+"] textStatus=["+o+"] errorThrown=["+i+"]")},statusCode:{404:function(){verror("loadTextFromURL(): "+e+" - 404 page not found")},405:function(){verror("loadTextFromURL(): "+e+" - 405 page not found")}}})}function Se(){Fe()&&(Vt=-1,null!=zt&&(zt.width=0,zt.height=0),zt=null,Ft=0,Ut=!0,Ve(!1),jt=[])}function Re(){function e(e){e.preventDefault(),"touchstart"==e.type&&(Ot=!0),$(".m-before-after-viewer .mm-slider-help").hide(),r=!0,setTimeout(function(){r=!1,nt=""},300),Ot?(document.ontouchend=o,document.ontouchmove=t):(document.onmouseup=o,document.onmousemove=t),i=Ot?e.touches[0].clientX-document.getElementById("m-before-after-viewer-slider").offsetLeft:e.clientX-document.getElementById("m-before-after-viewer-slider").offsetLeft}function t(e){var t;t=Ot?e.touches[0].clientX:e.clientX,t-=i,Vt=parseInt(t+25);var o=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,r=document.getElementById("id-visualizer-plugin-render-canvas"),n=r.getBoundingClientRect();Vt-o<3?Vt=o+3:Vt>o+n.width-25&&(Vt=o+n.width-25),Bt=!0,Ut=!1,ze()}function o(){document.onmouseup=null,document.onmousemove=null,document.ontouchend=null,document.ontouchmove=null;var e=document.getElementById("id-visualizer-plugin-render-canvas"),t=e.getContext("2d"),o=e.getBoundingClientRect(),i;i="Desktop"==Ke&&mobileVisualizerConfig.desktopZoomOut?o.left+3:-o.left+3,i=parseInt(i),vout("sliderSplitX="+Vt+" viewLeftX="+i);const n=25;return Bt&&Vt>=i-n&&Vt<=i+n&&xe(),r?(Vt=Ut?-2:-1,Ut=!Ut,void ze()):void(Bt=!1)}var i=0,r;document.getElementById("m-before-after-viewer-slider").onmousedown=e,document.getElementById("m-before-after-viewer-slider").ontouchstart=e}function Te(){if(Be()){var e=document.getElementById("id-visualizer-plugin-render-canvas"),t=e.getContext("2d"),o=e.getBoundingClientRect(),i=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,r=Vt;r-=i,r*=zt.width/o.width;var n=r/zt.width*100;n<25?(Vt=-1,Ut=!0):(Vt=-2,Ut=!1),ze()}}function Pe(){return vout("scrollingBeforeAfterSlider()"),null==ft&&vout("No room loaded yet"),"Pano"==ft?void vout("Not pano room"):void(Ut?xe():ze())}function $e(){return vout("delayedResetBeforeAfterSlider()"),null==ft&&vout("No room loaded yet"),"Pano"==ft?void vout("Not pano room"):void setTimeout(function(){xe()},100)}function xe(){vout("resetBeforeAfterSlider()"),Vt=-1,Ut=!0,Be()&&ze()}function De(e,t){if(vout("storeCurrentBeforeAfter()"),Fe()&&(null==e||e.sku!=t.sku)){jt=VUtils.clone(U());var o=mo.getRenderedScene();null==zt&&(zt=document.createElement("canvas"),Lt=zt.getContext("2d"),zt.width=o.width,zt.height=o.height),Lt.drawImage(o,0,0)}}function Oe(){Fe()&&(++Ft,Be()&&ze())}function ze(){var e=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft;Le();var t=document.getElementById("id-visualizer-plugin-render-canvas"),o=t.getContext("2d"),i=t.getBoundingClientRect();if(Ut)o.drawImage(mo.getRenderedScene(),0,0);else{var r=Vt;r-=e,r*=zt.width/i.width,o.drawImage(mo.getRenderedScene(),0,0),o.drawImage(zt,0,0,r,zt.height,0,0,r,zt.height)}Ve(!0)}function Le(){var e=document.getElementById("id-visualizer-plugin-render-canvas").clientHeight;document.getElementById("m-before-after-viewer-divider").style.height=e+"px";var e=10+$(".m-tools-container").outerHeight(!1),t=$(window).scrollTop();t+=e,document.getElementById("m-before-after-viewer-slider").style.top=t+"px",t=e,document.getElementById("m-before-after-viewer-slider-locked").style.top=t+"px",e=40,t=$(window).scrollTop(),t+=e,document.getElementById("id-m-before-product-details").style.top=t+"px",document.getElementById("id-m-after-product-details").style.top=t+"px";var o=document.getElementById("id-visualizer-plugin-render-canvas"),i=o.getContext("2d"),r=o.getBoundingClientRect();Vt==-1?(Vt="Desktop"==Ke&&mobileVisualizerConfig.desktopZoomOut?r.left+3:-r.left+3,Vt=parseInt(Vt)):Vt==-2&&(Vt="Desktop"==Ke&&mobileVisualizerConfig.desktopZoomOut?$(".m-scene-render").width()/2:-r.left+$(".m-scene-render").width()/2,Vt=parseInt(Vt));var n=parseInt(Vt-25);document.getElementById("m-before-after-viewer-slider").style.left=n+"px",n=parseInt(Vt-3),document.getElementById("m-before-after-viewer-divider").style.left=n+"px";var a=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft;n=a,document.getElementById("m-before-after-viewer-slider-locked").style.left=n+"px",document.getElementById("m-before-after-viewer-divider-locked").style.left=n+"px";var a=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,s="auto",l=25-(Vt-a);if(l>0){var s="rect(0px,50px,50px,[LEFT]px)";s=s.replace("[LEFT]",l)}$(".m-before-after-viewer .mm-unlocked .mm-slider").css("clip",s),Ut?($(".m-before-after-viewer .mm-locked .mm-divider").show(),$(".m-before-after-viewer .mm-locked .mm-slider").show(),$(".m-before-after-viewer .mm-unlocked .mm-divider").addClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-unlocked .mm-slider").addClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-before-after-product-details").hide(),$(".m-current-product-details").show()):($(".m-before-after-viewer .mm-locked .mm-divider").hide(),$(".m-before-after-viewer .mm-locked .mm-slider").hide(),$(".m-before-after-viewer .mm-unlocked .mm-divider").removeClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-unlocked .mm-slider").removeClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-before-after-product-details.mm-after").show(),Ge.getBeforeUsedProducts().length>0?$(".m-before-after-viewer .mm-before-after-product-details.mm-before").show():$(".m-before-after-viewer .mm-before-after-product-details.mm-before").hide(),$(".m-current-product-details").hide())}function Ve(e){Fe()&&($(".m-before-after-viewer").hide(),e&&$(".m-before-after-viewer").show())}function Be(){return!!Fe()&&!(Ft<2)}function Fe(){return!!mobileVisualizerConfig.enableBeforeAfterViewer&&("Phone"!=Ke&&"Pano"!=ft)}function Ue(e){ro=e,Me()}function Me(){$(".m-rug-size-popup").show()}function Ne(e,t,o,i){We.showMessage("Creating Rug or Runner");var r="mobile/config/StantonCarpetDemo/textures/jpg90/"+e+"_c.jpg";Qe(r,function(e){var r=e.getContext("2d");ao.width=Math.floor(25*t),ao.height=Math.floor(25*o);var n=ao.getContext("2d");n.fillStyle="#"+qe(e),n.fillRect(0,0,ao.width,ao.height);var a=n.createPattern(e,"repeat");n.fillStyle=a;var s=50;n.fillRect(s,s,ao.width-2*s,ao.height-2*s),je(ao,function(){We.showMessage(null),i()})})}function Qe(e,t){var o=new Image;o.crossOrigin="Anonymous",o.onerror=function(){t(null)},o.onload=function(){no.width=o.width,no.height=o.height,no.getContext("2d").drawImage(o,0,0),t(no)},VUtils.isInternetExplorerBrowser()||(o.src=""),o.src=e}function je(e,t){var o="mobile/config/StantonCarpetDemo/textures/jpg90/",i=o+"UserCreatedRug_c.jpg";He(e,o,i,.8,function(){t()})}function He(e,t,o,i,r){var n={base64Data:e.toDataURL("image/jpeg",i).replace(/^data:image\/(png|jpeg);base64,/,""),folder:t,filename:o};$.post("vsavebase64.php",n,function(e){null!=r&&r()})}function qe(e){function t(e){var t=e.toString(16);return 1==t.length?"0"+t:t}for(var o=30,i=0,r=0,n=0,a=e.width,s=e.height,l=e.getContext("2d"),u=0;u0?Ht<20&&(Ht+=.5):Ht>2&&(Ht-=.5),mo.setUYOAreaDimensionA(Ht)},this.adjustUYODimensionB=function(e){e>0?qt<20&&(qt+=.5):qt>2&&(qt-=.5),mo.setUYOAreaDimensionB(qt)},this.finishedAdjustingDimensions=function(){mo.uyoEditAreaFinished()},this.deleteOutline=function(){null==Gt?(Gt=null,"UYOEditingFloor"==nt?c():mo.uyoEditDeleteOutline()):Ge.abortAdjustingOutlines()},this.finishedAdjustingOutline=function(){mo.uyoEditFinishedAdjustingOutline()},this.finishedAdjustingPerspective=function(){mo.uyoEditFinishedAdjustingPerspective()},this.editOutlines=function(){nt="UYOEditingWall",We.hideHelp(),d(),mo.uyoStartSurfaceEdit(),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline-not-started").show(),$(".m-uyo-tools").show(),We.showInstructionFor("[Tap] a wall area to adjust",Jt)},this.abortAdjustingOutlines=function(){mobileVisualizerGUI.showMessageFor("Updating"),nt="",$(".m-uyo-tools").hide(),We.showInstruction(null),mo.uyoFinishSurfaceEdit(),We.updateCurrentProduct(),We.updateTools(),G(function(){m()})},this.addMaskOutline=function(){nt="UYOEditingWall",We.hideHelp(),d(),mo.uyoStartSurfaceEdit(),mo.uyoAddMask(),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),We.showInstructionFor("[Tap] around the area to exclude from decorating and back on the first point to finish, or [DELETE] to cancel",Jt)},this.patchFloorArea=function(){mobileVisualizerConfig.enableToolsFloorPatchAndMask&&$(".m-tool-button.mm-patch-floor-area").hasClass("mm-disabled")||(nt="UYOEditingFloor",We.hideHelp(),d(),$(".m-uyo-tools .m-uyo-tool-button").hide(),
$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),We.showInstructionFor("[Tap] around the floor area and back on the first point to finish.",5e3),$(".m-current-product-details").hide(),mo.patchFloorArea(function(){nt="",$(".m-uyo-tools").hide(),G(function(){m(),We.updateTools(),We.updateCurrentProduct()})},function(){We.showInstruction(null)}))},this.maskFloorArea=function(){mobileVisualizerConfig.enableToolsFloorPatchAndMask&&$(".m-tool-button.mm-mask-floor-area").hasClass("mm-disabled")||(We.hideHelp(),nt="UYOEditingFloor",d(),$(".m-current-product-details").hide(),Y(function(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),We.showInstructionFor("[Tap] around the area to exclude from decorating and back on the first point to finish",5e3),mo.maskFloorArea(function(){nt="",$(".m-uyo-tools").hide(),G(function(){m(),We.updateTools(),We.updateCurrentProduct()})},function(){We.showInstruction(null)})}))},this.closeFloorOrStairsPopup=function(){$(".m-floor-or-stairs-popup").hide(),Yt&&We.showLandingContent(!0),ve(),re()},this.hideFloorOrStairsPopup=function(){$(".m-floor-or-stairs-popup").hide()},this.setFloorOrStairsSelection=function(e){Ge.closeFloorOrStairsPopup(),$(".m-floor-or-stairs-popup").hide(),We.showMessage("Loading Photo",!0),mo.setFloorOrStairsSelection(e)},this.openEditingToolsPopup=function(){$(".m-editing-tools-popup .mm-add-wall-outline").hide(),mobileVisualizerConfig.enableWallOutlining&&$(".m-editing-tools-popup .mm-add-wall-outline").show(),$(".m-editing-tools-popup .mm-edit-wall-outline").hide(),he()>0&&$(".m-editing-tools-popup .mm-edit-wall-outline").show(),$(".m-editing-tools-popup .mm-mask-floor-area").show(),$(".m-editing-tools-popup .mm-mask-outline").hide(),mobileVisualizerConfig.enableWallOutlining&&he()>0&&($(".m-editing-tools-popup .mm-mask-floor-area").hide(),$(".m-editing-tools-popup .mm-mask-outline").show()),mobileVisualizerConfig.enableFloorPatchAndMask||($(".m-editing-tools-popup .mm-patch-floor-area").hide(),$(".m-editing-tools-popup .mm-mask-floor-area").hide()),$(".m-editing-tools-popup").show()},this.closeEditingToolsPopup=function(){$(".m-editing-tools-popup").hide()},this.saveRoom=function(){if("Pano"!=ft&&(mobileVisualizer.isDecoratedFloor()||mobileVisualizer.isRug())){We.showMessageFor("Saving",2e3);var e=new Object;if(e.roomId=ft,e.roomData=St,"UYO"==ft&&(vt=!1),"UYO"==ft){var t=.5;e.uyoData=JSON.parse(mo.getUYOEditData()),e.uyoOriginalRoomImage=JSON.parse(mo.getUYOOriginalRoomImage(t))}e.thumbnail=y(400,266).toDataURL("image/jpeg",.5),pt.unshift(e);for(var o=0;oe&&--gt[o]:(alert("found "+e),gt.splice(o,1),t=!0,--o);We.updateQuickSelector(),We.updateRoomSelector(!0)},this.getSavedRooms=function(){return pt},this.getThisSessionSavedUYORooms=function(){return gt},this.showQuickSelectorLastSavedUYORoom=function(){return vt},this.getOCRReader=function(){return Kt},this.getLastPlacedProduct=function(){return At},this.getLastPlacedFloor=function(){return Ct},this.getLastPlacedRug=function(){return Et},this.editStairs=function(){Ge.isDecoratedFloor()&&mo.editStairs()},this.isStairsRoom=function(){if("UYO"==ft)return vitStairsRoom},this.isDecoratedFloor=function(){if("Pano"==ft)return!0;for(var e in St){var t=St[e];if("texture"==t.type&&null!=t.decoration)return!0}return!1},this.getNumFloors=function(){return me()},this.getNumWalls=function(){return he()},this.getNumTexturedWalls=function(){return fe()},this.getNumDecoratedFloors=function(){if("Pano"==ft)return 0;var e=0;for(var t in St){var o=St[t];"texture"==o.type&&o.gridName.indexOf("FLOOR")!=-1&&null!=o.decoration&&++e}return e},this.getNumDecoratedTexturedWalls=function(){if("Pano"==ft)return 0;var e=0;for(var t in St){var o=St[t];"texture"==o.type&&o.gridName.indexOf("WALL")!=-1&&null!=o.decoration&&o.decoration.indexOf("#")==-1&&++e}return e},this.isRug=function(){if("Pano"==ft)return!1;for(var e in St){var t=St[e];if("texture"==t.type&&null!=t.rugDecoration)return!0}return!1},this.savePhoto=function(){lo.track("@SavePhotoStart"),R(function(e){$(".m-save-photo-popup-container img").attr("src",e.toDataURL("image/jpeg",1)),$(".m-save-photo-popup").show()})},this.savePhotoClose=function(){$(".m-save-photo-popup").hide()},this.exportOriginal=function(){var e=mo.getOriginalScene();e.toBlob(function(e){saveAs(e,"My Original Room Photo.jpg")})},this.exportJPG=function(){function e(){R(function(e){e.toBlob(function(e){saveAs(e,"My Room Image.jpg")},"image/jpeg",.9)})}return lo.track("@SavedJPG"),We.showMessageFor("Preparing your photo for download so you can share or email it to your friends",4e3,function(){e()}),!0},this.printPDF=function(){return lo.track("@PrintedPDF"),$(".m-export-pdf-frame").attr("src","mobile/exportpdf.html?print&"+mobileVisualizerStopCaching),!0},this.exportPDF=function(){return lo.track("@SavedPDF"),$(".m-export-pdf-frame").attr("src","mobile/exportpdf.html?"+mobileVisualizerStopCaching),!0},this.getExportPDFData=function(e){var t=new Object;R(function(o){t.sceneRender=o.toDataURL("image/jpeg",1),e(t)})},this.getCurRoomId=function(){return ft},this.getProduct=function(e){return J(e)},this.curRoomSupportsProductTypeSubType=function(e,t){if(null==ft)return!0;if("Pano"==ft)return"Carpet"!=e||"Rug"!=t;if(Ge.isStairsRoom()&&("Carpet"!=e||"Carpet"==e&&"Rug"==t))return!1;var o=X(ft);if(null==o)return!0;if(o.productTypesAllowed.indexOf("All")!=-1)return!0;var i=e;return""!=t&&t.indexOf("!")==-1&&(i+="-"+t),o.productTypesAllowed.indexOf(i)!=-1},this.setCameraHeight=function(e,t){lo.track("@SelectedHeight");var o=10,i=VUtils.GetQueryStringParam("height");null!=i&&(e=i,alert("Override person height to "+e+" inches (camera height is "+(e-o)+" inches)"));var r=.0254*(e-o);mo.setAutoFindFloorCameraHeight(r),P(!0)},this.linkToMainVisualizer=function(){"Mannington"==mobileVisualizerConfigType&&so.linkToMainManningtonVD()},this.linkToHomepage=function(){null!=mobileVisualizerConfig.headerLink&&(lo.track("@Link","Homepage"),window.open(mobileVisualizerConfig.headerLink))},this.hideProductDetails=function(){return"HughMackay"==mobileVisualizerConfigType?void so.showProductDetails(null):"VictoriaCarpets"==mobileVisualizerConfigType?void so.showProductDetails(null):void 0},this.showProductDetails=function(){if(!mobileVisualizerConfig.noProductDetailLinks){if("HughMackay"==mobileVisualizerConfigType)return so.showProductDetails(At),void lo.track("@Link","HughMackayProductDetails");if("VictoriaCarpets"==mobileVisualizerConfigType)return so.showProductDetails(At),void lo.track("@Link","VictoriaCarpetsProductDetails");for(var e=U(),t=0;t0&&!e)nt="WaitingForFloorOrWallSelection",We.showInstructionFor("[Tap] floor or wall to decorate",4e3),mt=setTimeout(function(){mt=null,nt=""},5e3);else if(1==me())for(var o in St){var i=St[o];if("texture"==i.type){"Mannington"==mobileVisualizerConfigType&&(nt="WaitingForFloorOrWallSelection"),Q(o);break}}else nt="WaitingForFloorSelection",We.showInstructionFor("[Tap] to select floor or stairs",2e3),mt=setTimeout(function(){mt=null,nt=""},5e3)})}},this.deleteRug=function(){for(var e in St){var t=St[e];if("texture"==t.type&&null!=t.rugDecoration)return t.rugDecoration=null,_t=null,Et=null,void mo.deleteRug(t.id,function(){We.updateTools(),We.updateCurrentProduct()})}},this.selectRotate=function(){if(We.hideHelp(),"Pano"==ft)return Rt=90-Rt,void G(function(){We.updateTools(),We.updateCurrentProduct()});var e=0,t=0,o=null,i=null;for(var r in St){var n=St[r];"texture"==n.type&&(n.gridName.indexOf("FLOOR")!=-1?(null!=n.decoration&&(o=r),null!=n.rugDecoration&&(o=r,++t)):n.gridName.indexOf("WALL")!=-1&&null!=n.decoration&&(i=r))}0==Ge.getNumDecoratedFloors()&&0==t&&0==Ge.getNumDecoratedTexturedWalls()||(Ge.getNumDecoratedFloors()>0&&Ge.getNumDecoratedTexturedWalls()>0?(nt="WaitingForRotateFloorOrWallSelection",We.showInstructionFor("[Tap] to rotate floor or wall",2e3),mt=setTimeout(function(){mt=null,nt=""},5e3)):0==Ge.getNumDecoratedFloors()&&1==Ge.getNumDecoratedTexturedWalls()?H(i):0==Ge.getNumDecoratedFloors()&&Ge.getNumDecoratedTexturedWalls()>1?(nt="WaitingForRotateFloorOrWallSelection",We.showInstructionFor("[Tap] to rotate wall",2e3),mt=setTimeout(function(){mt=null,nt=""},5e3)):Ge.getNumDecoratedFloors()+t==1?null!=St[o].decoration?H(o):q(o):(nt="WaitingForRotateSelection",1==t?We.showInstructionFor("[Tap] to rotate floor or rug",2e3):We.showInstructionFor("[Tap] to rotate floor or stairs",2e3),mt=setTimeout(function(){mt=null,nt=""},5e3)))},this.toggleFilterItem=function(e,t){var o=ht[e].indexOf(t);return o==-1?(ht[e].push(t),vobj(ht),!1):(ht[e].splice(o,1),!0)},this.filterItemIsOn=function(e,t){return ht[e].indexOf(t)!=-1},this.getRecentlyUsed=function(){return Tt},this.addToFavourites=function(){if(null!=At){var e=At.sku;if("undefined"==typeof vitRugMaker||"UserCreatedRug"!=e){Pt.indexOf(e)!=-1&&Pt.splice(Pt.indexOf(e),1),Pt.unshift(e);for(var t=24;Pt.length>t;)Pt.pop();VUtils.saveCookie(mobileVisualizerConfigType+"-MobileVisualizer-Favourites-"+mobileVisualizerConfig.savedFavouritesRef,JSON.stringify(Pt)),We.updateTools(),We.updateRecentyUsedAndFavourites()}}},this.getFavourites=function(){return Pt},this.openPhonePhotoUploadQRCodePopup=function(e){function t(){if(r){if(i)return;$(".m-scan-qr-code-popup .mm-waiting").css("opacity","1.0"),setTimeout(t,800)}else{if(i)return;$(".m-scan-qr-code-popup .mm-waiting").css("opacity","0.0"),setTimeout(t,100)}r=!r}function o(){ke("https://qr.viziserve.com/vphotouploaded.php?photocode="+to,function(e){return"true"==e?($(".m-scan-qr-code-popup .mm-waiting").css("opacity","1.0"),i=!0,$(".m-scan-qr-code-popup .mm-waiting").hide(),$(".m-scan-qr-code-popup .mm-found").show(),void $(".m-scan-qr-code-popup .mm-load-my-photo").show()):void(io&&setTimeout(o,2e3))})}void 0==e&&(e=oo),oo=e,mobileVisualizerConfig.enableStairs?Ee(oo):Ee(),$(".m-landing-content").hide(),$(".m-scan-qr-code-popup .mm-waiting").show(),$(".m-scan-qr-code-popup .mm-found").hide(),$(".m-scan-qr-code-popup .mm-load-my-photo").hide(),$(".m-scan-qr-code-popup .mm-title").hide(),mobileVisualizerConfig.enableStairs?"Floor"==e?$(".m-scan-qr-code-popup .mm-title.mm-floor").show():$(".m-scan-qr-code-popup .mm-title.mm-stairs").show():$(".m-scan-qr-code-popup .mm-title.mm-just-floor").show(),$(".m-scan-qr-code-popup").show(),io=!0,o();var i=!1,r=!0;t()},this.closeQRCodePopup=function(){$(".m-landing-content").show(),$(".m-scan-qr-code-popup").hide(),io=!1},this.loadQRCodeUploadedPhoto=function(){Se();var e="https://qr.viziserve.com/vgetphoto.php?photocode="+to;z(e,oo)},this.getShowCurrentDetails=function(){return!Fe()||!!Ut},this.canUseBeforeAfter=function(){return Be()},this.closeRugSizePopup=function(){$(".m-rug-size-popup").hide()},this.enteredRugSizeOK=function(){const e=18,t=72;var o=$(".m-rug-size-popup .mm-dimension-width").val(),i=$(".m-rug-size-popup .mm-dimension-height").val();if(""==o||""==i)return We.showMessageFor("Please enter dimensions for both the width and length",2e3),!1;var o=parseInt(o),i=parseInt(i);if(ot||it)return We.showMessageFor("Please enter rug dimensions in the range 18 to 72 inches",2e3),!1;var r=J(ro);return Ne(r.assetRef,o,i,function(){sku="UserCreatedRug",r=J(sku),r.width=25*o,r.height=25*i,Ge.selectProduct("UserCreatedRug")}),!0}}var QRCode;!function(){function e(e){this.mode=u.MODE_8BIT_BYTE,this.data=e,this.parsedData=[];for(var t=[],o=0,i=this.data.length;i>o;o++){var r=this.data.charCodeAt(o);r>65536?(t[0]=240|(1835008&r)>>>18,t[1]=128|(258048&r)>>>12,t[2]=128|(4032&r)>>>6,t[3]=128|63&r):r>2048?(t[0]=224|(61440&r)>>>12,t[1]=128|(4032&r)>>>6,t[2]=128|63&r):r>128?(t[0]=192|(1984&r)>>>6,t[1]=128|63&r):t[0]=r,this.parsedData=this.parsedData.concat(t)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function t(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function o(e,t){if(void 0==e.length)throw new Error(e.length+"/"+t);for(var o=0;o=r;r++){var a=0;switch(t){case c.L:a=p[r][0];break;case c.M:a=p[r][1];break;case c.Q:a=p[r][2];break;case c.H:a=p[r][3]}if(a>=i)break;o++}if(o>p.length)throw new Error("Too long data");return o}function l(e){var t=encodeURI(e).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return t.length+(t.length!=e?3:0)}e.prototype={getLength:function(){return this.parsedData.length},write:function(e){for(var t=0,o=this.parsedData.length;o>t;t++)e.put(this.parsedData[t],8)}},t.prototype={addData:function(t){var o=new e(t);this.dataList.push(o),this.dataCache=null},isDark:function(e,t){if(0>e||this.moduleCount<=e||0>t||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,o){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var i=0;i=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=t.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,o)},setupPositionProbePattern:function(e,t){for(var o=-1;7>=o;o++)if(!(-1>=e+o||this.moduleCount<=e+o))for(var i=-1;7>=i;i++)-1>=t+i||this.moduleCount<=t+i||(this.modules[e+o][t+i]=o>=0&&6>=o&&(0==i||6==i)||i>=0&&6>=i&&(0==o||6==o)||o>=2&&4>=o&&i>=2&&4>=i)},getBestMaskPattern:function(){for(var e=0,t=0,o=0;8>o;o++){this.makeImpl(!0,o);var i=m.getLostPoint(this);(0==o||e>i)&&(e=i,t=o)}return t},createMovieClip:function(e,t,o){var i=e.createEmptyMovieClip(t,o),r=1;this.make();for(var n=0;n=n;n++)for(var a=-2;2>=a;a++)this.modules[i+n][r+a]=-2==n||2==n||-2==a||2==a||0==n&&0==a}},setupTypeNumber:function(e){for(var t=m.getBCHTypeNumber(this.typeNumber),o=0;18>o;o++){var i=!e&&1==(1&t>>o);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=i}for(var o=0;18>o;o++){var i=!e&&1==(1&t>>o);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)]=i}},setupTypeInfo:function(e,t){for(var o=this.errorCorrectLevel<<3|t,i=m.getBCHTypeInfo(o),r=0;15>r;r++){var n=!e&&1==(1&i>>r);6>r?this.modules[r][8]=n:8>r?this.modules[r+1][8]=n:this.modules[this.moduleCount-15+r][8]=n}for(var r=0;15>r;r++){var n=!e&&1==(1&i>>r);8>r?this.modules[8][this.moduleCount-r-1]=n:9>r?this.modules[8][15-r-1+1]=n:this.modules[8][15-r-1]=n}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var o=-1,i=this.moduleCount-1,r=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;2>s;s++)if(null==this.modules[i][a-s]){var l=!1;n>>r));var u=m.getMask(t,i,a-s);u&&(l=!l),this.modules[i][a-s]=l,r--,-1==r&&(n++,r=7)}if(i+=o,0>i||this.moduleCount<=i){i-=o,o=-o;break}}}},t.PAD0=236,t.PAD1=17,t.createData=function(e,o,n){for(var a=i.getRSBlocks(e,o),s=new r,l=0;l8*c)throw new Error("code length overflow. ("+s.getLengthInBits()+">"+8*c+")");for(s.getLengthInBits()+4<=8*c&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;!(s.getLengthInBits()>=8*c)&&(s.put(t.PAD0,8),!(s.getLengthInBits()>=8*c));)s.put(t.PAD1,8);return t.createBytes(s,a)},t.createBytes=function(e,t){for(var i=0,r=0,n=0,a=new Array(t.length),s=new Array(t.length),l=0;l=0?p.get(g):0}}for(var v=0,d=0;dd;d++)for(var l=0;ld;d++)for(var l=0;l=0;)t^=m.G15<=0;)t^=m.G18<>>=1;return t},getPatternPosition:function(e){return m.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,o){switch(e){case d.PATTERN000:return 0==(t+o)%2;case d.PATTERN001:return 0==t%2;case d.PATTERN010:return 0==o%3;case d.PATTERN011:return 0==(t+o)%3;case d.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(o/3))%2;case d.PATTERN101:return 0==t*o%2+t*o%3;case d.PATTERN110:return 0==(t*o%2+t*o%3)%2;case d.PATTERN111:return 0==(t*o%3+(t+o)%2)%2;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new o([1],0),i=0;e>i;i++)t=t.multiply(new o([1,h.gexp(i)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case u.MODE_NUMBER:return 10;case u.MODE_ALPHA_NUM:return 9;case u.MODE_8BIT_BYTE:return 8;case u.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(27>t)switch(e){case u.MODE_NUMBER:return 12;case u.MODE_ALPHA_NUM:return 11;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else{if(!(41>t))throw new Error("type:"+t);switch(e){case u.MODE_NUMBER:return 14;case u.MODE_ALPHA_NUM:return 13;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),o=0,i=0;t>i;i++)for(var r=0;t>r;r++){for(var n=0,a=e.isDark(i,r),s=-1;1>=s;s++)if(!(0>i+s||i+s>=t))for(var l=-1;1>=l;l++)0>r+l||r+l>=t||(0!=s||0!=l)&&a==e.isDark(i+s,r+l)&&n++;n>5&&(o+=3+n-5)}for(var i=0;t-1>i;i++)for(var r=0;t-1>r;r++){var u=0;e.isDark(i,r)&&u++,e.isDark(i+1,r)&&u++,e.isDark(i,r+1)&&u++,e.isDark(i+1,r+1)&&u++,(0==u||4==u)&&(o+=3)}for(var i=0;t>i;i++)for(var r=0;t-6>r;r++)e.isDark(i,r)&&!e.isDark(i,r+1)&&e.isDark(i,r+2)&&e.isDark(i,r+3)&&e.isDark(i,r+4)&&!e.isDark(i,r+5)&&e.isDark(i,r+6)&&(o+=40);for(var r=0;t>r;r++)for(var i=0;t-6>i;i++)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(o+=40);for(var c=0,r=0;t>r;r++)for(var i=0;t>i;i++)e.isDark(i,r)&&c++;var d=Math.abs(100*c/t/t-50)/5;return o+=10*d}},h={glog:function(e){if(1>e)throw new Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},f=0;8>f;f++)h.EXP_TABLE[f]=1<f;f++)h.EXP_TABLE[f]=h.EXP_TABLE[f-4]^h.EXP_TABLE[f-5]^h.EXP_TABLE[f-6]^h.EXP_TABLE[f-8];for(var f=0;255>f;f++)h.LOG_TABLE[h.EXP_TABLE[f]]=f;o.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=new Array(this.getLength()+e.getLength()-1),i=0;ia;a++)for(var s=o[3*a+0],l=o[3*a+1],u=o[3*a+2],c=0;s>c;c++)n.push(new i(l,u));return n},i.getRsBlockTable=function(e,t){switch(t){case c.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];
case c.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case c.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case c.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return}},r.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var o=0;t>o;o++)this.putBit(1==(1&e>>>t-o-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var p=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],g=function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){function t(e,t){var o=document.createElementNS("http://www.w3.org/2000/svg",e);for(var i in t)t.hasOwnProperty(i)&&o.setAttribute(i,t[i]);return o}var o=this._htOption,i=this._el,r=e.getModuleCount();Math.floor(o.width/r),Math.floor(o.height/r),this.clear();var n=t("svg",{viewBox:"0 0 "+String(r)+" "+String(r),width:"100%",height:"100%",fill:o.colorLight});n.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),i.appendChild(n),n.appendChild(t("rect",{fill:o.colorDark,width:"1",height:"1",id:"template"}));for(var a=0;r>a;a++)for(var s=0;r>s;s++)if(e.isDark(a,s)){var l=t("use",{x:String(a),y:String(s)});l.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),n.appendChild(l)}},e.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},e}(),v="svg"===document.documentElement.tagName.toLowerCase(),b=v?g:n()?function(){function e(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function t(e,t){var o=this;if(o._fFail=t,o._fSuccess=e,null===o._bSupportDataURI){var i=document.createElement("img"),r=function(){o._bSupportDataURI=!1,o._fFail&&_fFail.call(o)},n=function(){o._bSupportDataURI=!0,o._fSuccess&&o._fSuccess.call(o)};return i.onabort=r,i.onerror=r,i.onload=n,void(i.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")}o._bSupportDataURI===!0&&o._fSuccess?o._fSuccess.call(o):o._bSupportDataURI===!1&&o._fFail&&o._fFail.call(o)}if(this._android&&this._android<=2.1){var o=1/window.devicePixelRatio,i=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(e,t,r,n,a,s,l,u){if("nodeName"in e&&/img/i.test(e.nodeName))for(var c=arguments.length-1;c>=1;c--)arguments[c]=arguments[c]*o;else"undefined"==typeof u&&(arguments[1]*=o,arguments[2]*=o,arguments[3]*=o,arguments[4]*=o);i.apply(this,arguments)}}var r=function(e,t){this._bIsPainted=!1,this._android=a(),this._htOption=t,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=t.width,this._elCanvas.height=t.height,e.appendChild(this._elCanvas),this._el=e,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return r.prototype.draw=function(e){var t=this._elImage,o=this._oContext,i=this._htOption,r=e.getModuleCount(),n=i.width/r,a=i.height/r,s=Math.round(n),l=Math.round(a);t.style.display="none",this.clear();for(var u=0;r>u;u++)for(var c=0;r>c;c++){var d=e.isDark(u,c),m=c*n,h=u*a;o.strokeStyle=d?i.colorDark:i.colorLight,o.lineWidth=1,o.fillStyle=d?i.colorDark:i.colorLight,o.fillRect(m,h,n,a),o.strokeRect(Math.floor(m)+.5,Math.floor(h)+.5,s,l),o.strokeRect(Math.ceil(m)-.5,Math.ceil(h)-.5,s,l)}this._bIsPainted=!0},r.prototype.makeImage=function(){this._bIsPainted&&t.call(this,e)},r.prototype.isPainted=function(){return this._bIsPainted},r.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},r.prototype.round=function(e){return e?Math.floor(1e3*e)/1e3:e},r}():function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){for(var t=this._htOption,o=this._el,i=e.getModuleCount(),r=Math.floor(t.width/i),n=Math.floor(t.height/i),a=[''],s=0;i>s;s++){a.push("");for(var l=0;i>l;l++)a.push(' | ');a.push("
")}a.push("
"),o.innerHTML=a.join("");var u=o.childNodes[0],c=(t.width-u.offsetWidth)/2,d=(t.height-u.offsetHeight)/2;c>0&&d>0&&(u.style.margin=d+"px "+c+"px")},e.prototype.clear=function(){this._el.innerHTML=""},e}();QRCode=function(e,t){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:c.H},"string"==typeof t&&(t={text:t}),t)for(var o in t)this._htOption[o]=t[o];"string"==typeof e&&(e=document.getElementById(e)),this._android=a(),this._el=e,this._oQRCode=null,this._oDrawing=new b(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(e){this._oQRCode=new t(s(e,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(e),this._oQRCode.make(),this._el.title=e,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=c}(),function(e,t){"function"==typeof define&&define.amd?define([],t):"undefined"!=typeof exports?t():(t(),e.FileSaver={exports:{}}.exports)}(this,function(){"use strict";function e(e,t){return"undefined"==typeof t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}function t(e,t,o){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){n(i.response,t,o)},i.onerror=function(){console.error("could not download file")},i.send()}function o(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function i(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(o){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var r="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,n=r.saveAs||("object"!=typeof window||window!==r?function(){}:"download"in HTMLAnchorElement.prototype?function(e,n,a){var s=r.URL||r.webkitURL,l=document.createElement("a");n=n||e.name||"download",l.download=n,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?i(l):o(l.href)?t(e,n,a):i(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout(function(){s.revokeObjectURL(l.href)},4e4),setTimeout(function(){i(l)},0))}:"msSaveOrOpenBlob"in navigator?function(r,n,a){if(n=n||r.name||"download","string"!=typeof r)navigator.msSaveOrOpenBlob(e(r,a),n);else if(o(r))t(r,n,a);else{var s=document.createElement("a");s.href=r,s.target="_blank",setTimeout(function(){i(s)})}}:function(e,o,i,n){if(n=n||open("","_blank"),n&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return t(e,o,i);var a="application/octet-stream"===e.type,s=/constructor/i.test(r.HTMLElement)||r.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||a&&s)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=l?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=e:location=e,n=null},u.readAsDataURL(e)}else{var c=r.URL||r.webkitURL,d=c.createObjectURL(e);n?n.location=d:location.href=d,n=null,setTimeout(function(){c.revokeObjectURL(d)},4e4)}});r.saveAs=n.saveAs=n,"undefined"!=typeof module&&(module.exports=n)}),!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pica=e()}(function(){return function e(t,o,i){function r(a,s){if(!o[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(n)return n(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=o[a]={exports:{}};t[a][0].call(c.exports,function(e){return r(t[a][1][e]||e)},c,c.exports,e,t,o,i)}return o[a].exports}for(var n="function"==typeof require&&require,a=0;a>14),t[w+2]=i(u+8192>>14),t[w+1]=i(l+8192>>14),t[w]=i(s+8192>>14),w=w+4*r|0}w=4*(p+1)|0,b=(p+1)*o*4|0}},convolveVertically:function(e,t,o,r,n,a){var s,l,u,c,d,m,h,f,p,g,v,b=0,w=0;for(p=0;p>14),t[w+2]=i(u+8192>>14),t[w+1]=i(l+8192>>14),t[w]=i(s+8192>>14),w=w+4*r|0}w=4*(p+1)|0,b=(p+1)*o*4|0}}}},{}],3:[function(e,t,o){t.exports="AGFzbQEAAAABFAJgBn9/f39/fwBgB39/f39/f38AAg8BA2VudgZtZW1vcnkCAAEDAwIAAQQEAXAAAAcZAghjb252b2x2ZQAACmNvbnZvbHZlSFYAAQkBAArmAwLBAwEQfwJAIANFDQAgBEUNACAFQQRqIRVBACEMQQAhDQNAIA0hDkEAIRFBACEHA0AgB0ECaiESAn8gBSAHQQF0IgdqIgZBAmouAQAiEwRAQQAhCEEAIBNrIRQgFSAHaiEPIAAgDCAGLgEAakECdGohEEEAIQlBACEKQQAhCwNAIBAoAgAiB0EYdiAPLgEAIgZsIAtqIQsgB0H/AXEgBmwgCGohCCAHQRB2Qf8BcSAGbCAKaiEKIAdBCHZB/wFxIAZsIAlqIQkgD0ECaiEPIBBBBGohECAUQQFqIhQNAAsgEiATagwBC0EAIQtBACEKQQAhCUEAIQggEgshByABIA5BAnRqIApBgMAAakEOdSIGQf8BIAZB/wFIG0EQdEGAgPwHcUEAIAZBAEobIAtBgMAAakEOdSIGQf8BIAZB/wFIG0EYdEEAIAZBAEobciAJQYDAAGpBDnUiBkH/ASAGQf8BSBtBCHRBgP4DcUEAIAZBAEobciAIQYDAAGpBDnUiBkH/ASAGQf8BSBtB/wFxQQAgBkEAShtyNgIAIA4gA2ohDiARQQFqIhEgBEcNAAsgDCACaiEMIA1BAWoiDSADRw0ACwsLIQACQEEAIAIgAyAEIAUgABAAIAJBACAEIAUgBiABEAALCw=="},{}],4:[function(e,t,o){t.exports={name:"resize",fn:e("./resize"),wasm_fn:e("./resize_wasm"),wasm_src:e("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(e,t,o){var i=e("./resize_filter_gen"),r=e("./convolve").convolveHorizontally,n=e("./convolve").convolveVertically;t.exports=function(e){var t=e.src,o=e.width,a=e.height,s=e.toWidth,l=e.toHeight,u=e.scaleX||e.toWidth/e.width,c=e.scaleY||e.toHeight/e.height,d=e.offsetX||0,m=e.offsetY||0,h=e.dest||new Uint8Array(s*l*4),f=void 0===e.quality?3:e.quality,p=e.alpha||!1,g=i(f,o,s,u,d),v=i(f,a,l,c,m),b=new Uint8Array(s*a*4);return r(t,b,o,a,s,g),n(b,h,a,s,l,v),p||function(e,t,o){for(var i=3,r=t*o*4|0;i>1]+=i(1-b),A=0;A>8&255}}var r=e("./resize_filter_gen"),n=!0;try{n=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(e){}t.exports=function(e){var t=e.src,o=e.width,n=e.height,a=e.toWidth,s=e.toHeight,l=e.scaleX||e.toWidth/e.width,u=e.scaleY||e.toHeight/e.height,c=e.offsetX||0,d=e.offsetY||0,m=e.dest||new Uint8Array(a*s*4),h=void 0===e.quality?3:e.quality,f=e.alpha||!1,p=r(h,o,a,l,c),g=r(h,n,s,u,d),v=this.__align(0+Math.max(t.byteLength,m.byteLength)),b=this.__align(v+n*a*4),w=this.__align(b+p.byteLength),A=w+g.byteLength,C=this.__instance("resize",A),y=new Uint8Array(this.__memory.buffer),_=new Uint32Array(this.__memory.buffer),E=new Uint32Array(t.buffer);return _.set(E),i(p,y,b),i(g,y,w),(C.exports.convolveHV||C.exports._convolveHV)(b,w,v,o,n,a,s),new Uint32Array(m.buffer).set(new Uint32Array(this.__memory.buffer,0,s*a)),f||function(e,t,o){for(var i=3,r=t*o*4|0;ie.idle&&(o.destroy(),1))}),0!==this.available.length?this.timeoutId=setTimeout(function(){return e.gc()},100):this.timeoutId=0},t.exports=i},{}],10:[function(e,t,o){t.exports=function(e,t,o,i,r,n){var a=o/e,s=i/t,l=(2*n+2+1)/r;if(.5=e.toWidth&&(s=e.toWidth-t),(o=a-e.destTileBorder)<0&&(o=0),o+(l=a+m+e.destTileBorder-o)>=e.toHeight&&(l=e.toHeight-o),h={toX:t,toY:o,toWidth:s,toHeight:l,toInnerX:n,toInnerY:a,toInnerWidth:d,toInnerHeight:m,offsetX:t/u-i(t/u),offsetY:o/c-i(o/c),scaleX:u,scaleY:c,x:i(t/u),y:i(o/c),width:r(s/u),height:r(l/c)},f.push(h);return f}},{}],12:[function(e,t,o){function i(e){return Object.prototype.toString.call(e)}t.exports.isCanvas=function(e){var t=i(e);return"[object HTMLCanvasElement]"===t||"[object Canvas]"===t},t.exports.isImage=function(e){return"[object HTMLImageElement]"===i(e)},t.exports.limiter=function(e){function t(){o>2),r=0,n=0,a=0;a>16&255,i[n++]=r>>8&255,i[n++]=255&r),r=r<<6|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(t.charAt(a));var s=o%4*6;return 0==s?(i[n++]=r>>16&255,i[n++]=r>>8&255,i[n++]=255&r):18==s?(i[n++]=r>>10&255,i[n++]=r>>2&255):12==s&&(i[n++]=r>>4&255),i}},{}],18:[function(e,t,o){t.exports=function(e,t,o){for(var i,r,n,a,s,l=t*o,u=new Uint16Array(l),c=0;c>1;return u}},{}],19:[function(e,t,o){t.exports={name:"unsharp_mask",fn:e("./unsharp_mask"),wasm_fn:e("./unsharp_mask_wasm"),wasm_src:e("./unsharp_mask_wasm_base64")}},{"./unsharp_mask":20,"./unsharp_mask_wasm":21,"./unsharp_mask_wasm_base64":22}],20:[function(e,t,o){var i=e("glur/mono16"),r=e("./hsl_l16");t.exports=function(e,t,o,n,a,s){var l,u,c,d,m,h,f,p,g,v,b,w,A;if(!(0===n||a<.5)){2=E&&(l=e[A=4*k],u=e[1+A],c=e[2+A],h=257*((p=u<=l&&c<=l?l:l<=u&&c<=u?u:c)+(f=l<=u&&l<=c?l:u<=l&&u<=c?u:c))>>1,d=f===p?m=0:(m=h<=32767?4095*(p-f)/(p+f)|0:4095*(p-f)/(510-p-f)|0,l===p?65535*(u-c)/(6*(p-f))|0:u===p?21845+(65535*(c-l)/(6*(p-f))|0):43690+(65535*(l-u)/(6*(p-f))|0)),65535<(h+=_*w+2048>>12)?h=65535:h<0&&(h=0),0===m?l=u=c=h>>8:(g=2*h-(v=h<=32767?h*(4096+m)+2048>>12:h+((65535-h)*m+2048>>12))>>8,v>>=8,l=43690<=(b=d+21845&65535)?g:32767<=b?g+(6*(v-g)*(43690-b)+32768>>16):10922<=b?v:g+(6*(v-g)*b+32768>>16),u=43690<=(b=65535&d)?g:32767<=b?g+(6*(v-g)*(43690-b)+32768>>16):10922<=b?v:g+(6*(v-g)*b+32768>>16),c=43690<=(b=d-21845&65535)?g:32767<=b?g+(6*(v-g)*(43690-b)+32768>>16):10922<=b?v:g+(6*(v-g)*b+32768>>16)),e[A]=l,e[1+A]=u,e[2+A]=c)}}},{"./hsl_l16":18,"glur/mono16":14}],21:[function(e,t,o){t.exports=function(e,t,o,i,r,n){if(!(0===i||r<.5)){2=this.m_MinWordLength},getUniqueDescriptorWordsAndPhrases:function(){var e=["flooringtype","productcollection","patternseries","colorwayname"];this.m_UniqueDescriptorWords=[],this.m_UniqueDescriptorPhrases=[];for(var t=0;t=2},setSceneSize:function(e,t){this.m_Width=e,this.m_Height=t},forceStop:function(){this.m_Busy&&(this.m_ForceStop=!0),this.m_xmlhttp=null,this.m_Busy=!1},prepScaledCanvasForGoogleOCR:function(e){var t=1024,o=e.width,i=e.height;if(o<=t&&i<=t)this.m_ScaledCanvas=e;else{null==this.m_ScaledCanvas&&(this.m_ScaledCanvas=document.createElement("canvas")),this.m_ScaledCanvas.width=this.m_ScaledCanvas.width,o>i?(this.m_ScaleFactorX=t/e.width,this.m_ScaleFactorY=this.m_ScaleFactorX,this.m_ScaledCanvas.width=t,this.m_ScaledCanvas.height=e.height*this.m_ScaleFactorY):(this.m_ScaleFactorY=t/e.height,this.m_ScaleFactorX=this.m_ScaleFactorY,this.m_ScaledCanvas.height=t,this.m_ScaledCanvas.width=e.width*this.m_ScaleFactorX);var r=this.m_ScaledCanvas.getContext("2d");r.drawImage(e,0,0,e.width,e.height,0,0,this.m_ScaledCanvas.width,this.m_ScaledCanvas.height)}},prepScaledCanvas:function(e){null==this.m_ScaledCanvas&&(this.m_ScaledCanvas=document.createElement("canvas")),this.m_ScaledCanvas.width=this.m_ScaledCanvas.width,this.m_ScaleFactorX=640/e.width,this.m_ScaleFactorY=480/e.height,this.m_ScaledCanvas.width=640,this.m_ScaledCanvas.height=480;var t=this.m_ScaledCanvas.getContext("2d");try{t.drawImage(e,0,0,e.width,e.height,0,0,this.m_ScaledCanvas.width,this.m_ScaledCanvas.height)}catch(e){this.m_Silent||alert("vpmanager, Error drawing scaled image:"+e.message)}try{this.m_EncodeAsPNG?this.m_canvasdata=this.m_ScaledCanvas.toDataURL("image/png"):this.m_canvasdata=this.m_ScaledCanvas.toDataURL("image/jpeg",1)}catch(e){this.m_Silent||alert("vpmanager, Error converting toDataURL:"+e.message)}},prepScaledCanvasPica:function(e,t){null==this.m_ScaledCanvas&&(this.m_ScaledCanvas=document.createElement("canvas")),this.m_ScaledCanvas.width=this.m_ScaledCanvas.width,this.m_ScaleFactorX=640/parseFloat(e.width),this.m_ScaleFactorY=480/parseFloat(e.height),this.m_ScaledCanvas.width=640,this.m_ScaledCanvas.height=480,pica.resizeCanvas(e,this.m_ScaledCanvas,{},t)},imageScaledOK:function(e){if(this.m_CannyPreProcess){var t=this.m_ScaledCanvas.getContext("2d"),o=t.getImageData(0,0,this.m_ScaledCanvas.width,this.m_ScaledCanvas.height),i=new jsfeat.matrix_t(this.m_ScaledCanvas.width,this.m_ScaledCanvas.height,jsfeat.U8C1_t);jsfeat.imgproc.grayscale(o.data,this.m_ScaledCanvas.width,this.m_ScaledCanvas.height,i),jsfeat.imgproc.equalize_histogram(i,i);for(var r=new Uint32Array(o.data.buffer),n=255<<24,a=i.cols*i.rows,s=0;--a>=0;)s=i.data[a],r[a]=n|s<<16|s<<8|s;t.putImageData(o,0,0)}this.m_EncodeAsPNG?this.m_canvasdata=this.m_ScaledCanvas.toDataURL("image/png",1):this.m_canvasdata=this.m_ScaledCanvas.toDataURL("image/jpeg",1),this.m_PostTryIdx=0,this.ajaxTrySendGoogle()},doOCR:function(e,t,o,i,r){this.m_SceneVPs.length=0,this.m_Width=e.width,this.m_Height=e.height,this.m_Markers=[];var n=this;1==this.m_Busy?r&&r():(this.m_Busy=!0,this.m_ForceStop=!1,this.m_Callback=t,this.m_ErrorCallback=o,this.m_SendingCallback=i,this.m_PreprocessDone?this.imageScaledOK():(this.prepScaledCanvasForGoogleOCR(e),this.imageScaledOK()),this.m_PreprocessDone=!1)},preprocessImage:function(e,t){this.m_preprocessCallback=t,this.m_UsePica?this.prepScaledCanvasPica(e,this.preprocessDone.bind(this)):(this.prepScaledCanvas(e),this.preprocessDone())},preprocessDone:function(){this.m_PreprocessDone=!0,this.m_preprocessCallback&&this.m_preprocessCallback()},getLastErrorStatus:function(){return this.m_LastErrorStatus},makeblob:function(e){var t=";base64,";if(e.indexOf(t)==-1){var o=e.split(","),i=o[0].split(":")[1],r=decodeURIComponent(o[1]);return new Blob([r],{type:i})}for(var o=e.split(t),i=o[0].split(":")[1],r=window.atob(o[1]),n=r.length,a=new Uint8Array(n),s=0;s=this.m_MinSKUlength&&t.push(s)}return t},getPotentialSKUSGoogle:function(e){var t=[];this.m_Words=[];for(var o=0;o=this.m_MinSKUlength&&t.push(n)}}return t},getDescriptorsAndPhrasesFromWords:function(){this.m_FoundDescriptors=[];for(var e=0;e0){a=!0;for(var s=0;st.LEVEN?1:0},getMatches:function(e){for(var t=[],o=[],i,r,n,a=this.m_SKUS,s=0;st.length&&(e=t,t=r);var n=e.length,a=t.length;if(0===n)return a;if(0===a)return n;for(;n>0&&e.charCodeAt(~-n)===t.charCodeAt(~-a);)n--,a--;if(0===n)return a;for(var s=0;su?d>u?u+1:d:d>c?c+1:d;return u},ajaxTrySendGoogle:function(){this.m_MatchList=[],cout("sending to Google...");var e={key:"AIzaSyD7ZYZtAyW8ITq5YyCUIIBsIxXnCy3Zj68"},t=this,o=this.m_canvasdata.replace(/^data:image\/\w+;base64,/,""),i="",r={requests:[{image:{content:o},features:[{type:"TEXT_DETECTION"}]}]};this.m_xmlhttp=$.ajax({url:"https://vision.googleapis.com/v1/images:annotate?"+$.param(e),beforeSend:function(e){},type:"POST",contentType:"application/json",data:JSON.stringify(r),processData:!1,cache:!1}).success(function(e){var o=t.getPotentialSKUSGoogle(e),i=t.getMatches(o);t.m_xmlhttp=null,t.m_canvasdata=null,t.m_ScaledCanvas=null,t.m_Busy=!1,t.m_PostTryIdx=0,t.m_UsingBackupURL=!1,t.m_Callback&&t.m_Callback()}).fail(function(e,t,o){var i=""===o?"Error. ":o+" ("+e.status+"): ";i+=""===e.responseText?"":jQuery.parseJSON(e.responseText).message,alert(i)})},ajaxTrySendMS:function(){cout("sending to MS...");var e={language:"en","detectOrientation ":"true"},t=this,o=this.makeblob(this.m_canvasdata),i="";this.m_xmlhttp=$.ajax({url:"https://westcentralus.api.cognitive.microsoft.com/vision/v1.0/ocr?"+$.param(e),beforeSend:function(e){e.setRequestHeader("Content-Type","application/octet-stream"),e.setRequestHeader("Ocp-Apim-Subscription-Key","de68385ab8e9421f8adeb1b4a86c2a15")},type:"POST",processData:!1,cache:!1,data:o}).done(function(e){var o=t.getPotentialSKUSMS(e),i=t.getMatches(o);cout("DONE"),t.m_xmlhttp=null,t.m_canvasdata=null,t.m_ScaledCanvas=null,t.m_Busy=!1,t.m_PostTryIdx=0,t.m_UsingBackupURL=!1,t.m_Callback&&t.m_Callback()}).fail(function(e,t,o){var i=""===o?"Error. ":o+" ("+e.status+"): ";i+=""===e.responseText?"":jQuery.parseJSON(e.responseText).message,alert(i)})}},!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&"undefined"!=typeof exports?module.exports=t():e.Papa=t()}(this,function(){"use strict";function e(e,t){t=t||{};var o=t.dynamicTyping||!1;if(v(o)&&(t.dynamicTypingFunction=o,o={}),t.dynamicTyping=o,t.worker&&I.WORKERS_SUPPORTED){var s=c();return s.userStep=t.step,s.userChunk=t.chunk,s.userComplete=t.complete,s.userError=t.error,t.step=v(t.step),t.chunk=v(t.chunk),t.complete=v(t.complete),t.error=v(t.error),delete t.worker,void s.postMessage({input:e,config:t,workerId:s.id})}var l=null;return"string"==typeof e?l=t.download?new i(t):new n(t):e.readable===!0&&v(e.read)&&v(e.on)?l=new a(t):(w.File&&e instanceof File||e instanceof Object)&&(l=new r(t)),l.stream(e)}function t(e,t){function o(){"object"==typeof t&&("string"==typeof t.delimiter&&1===t.delimiter.length&&I.BAD_DELIMITERS.indexOf(t.delimiter)===-1&&(u=t.delimiter),("boolean"==typeof t.quotes||t.quotes instanceof Array)&&(s=t.quotes),"string"==typeof t.newline&&(c=t.newline),"string"==typeof t.quoteChar&&(d=t.quoteChar),"boolean"==typeof t.header&&(l=t.header))}function i(e){if("object"!=typeof e)return[];var t=[];for(var o in e)t.push(o);return t}function r(e,t){var o="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var i=e instanceof Array&&e.length>0,r=!(t[0]instanceof Array);if(i&&l){for(var a=0;a0&&(o+=u),o+=n(e[a],a);t.length>0&&(o+=c)}for(var s=0;s0&&(o+=u);var h=i&&r?e[m]:m;o+=n(t[s][h],m)}s-1||" "===e.charAt(0)||" "===e.charAt(e.length-1);return o?d+e+d:e}function a(e,t){for(var o=0;o-1)return!0;return!1}var s=!1,l=!0,u=",",c="\r\n",d='"';o();var m=new RegExp(d,"g");if("string"==typeof e&&(e=JSON.parse(e)),e instanceof Array){if(!e.length||e[0]instanceof Array)return r(null,e);if("object"==typeof e[0])return r(i(e[0]),e)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),e.data instanceof Array&&(e.fields||(e.fields=e.meta&&e.meta.fields),e.fields||(e.fields=e.data[0]instanceof Array?e.fields:i(e.data[0])),e.data[0]instanceof Array||"object"==typeof e.data[0]||(e.data=[e.data])),r(e.fields||[],e.data||[]);throw"exception: Unable to serialize unrecognized input"}function o(e){function t(e){var t=p(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null),this._handle=new s(t),this._handle.streamer=this,this._config=t}this._handle=null,this._paused=!1,this._finished=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},t.call(this,e),this.parseChunk=function(e){if(this.isFirstChunk&&v(this._config.beforeFirstChunk)){var t=this._config.beforeFirstChunk(e);void 0!==t&&(e=t)}this.isFirstChunk=!1;var o=this._partialLine+e;this._partialLine="";var i=this._handle.parse(o,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var r=i.meta.cursor;this._finished||(this._partialLine=o.substring(r-this._baseIndex),this._baseIndex=r),i&&i.data&&(this._rowCount+=i.data.length);var n=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(C)w.postMessage({results:i,workerId:I.WORKER_ID,finished:n});else if(v(this._config.chunk)){if(this._config.chunk(i,this._handle),this._paused)return;i=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(i.data),this._completeResults.errors=this._completeResults.errors.concat(i.errors),this._completeResults.meta=i.meta),!n||!v(this._config.complete)||i&&i.meta.aborted||this._config.complete(this._completeResults,this._input),n||i&&i.meta.paused||this._nextChunk(),i}},this._sendError=function(e){v(this._config.error)?this._config.error(e):C&&this._config.error&&w.postMessage({workerId:I.WORKER_ID,error:e,finished:!1})}}function i(e){function t(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substr(t.lastIndexOf("/")+1))}e=e||{},e.chunkSize||(e.chunkSize=I.RemoteChunkSize),o.call(this,e);var i;A?this._nextChunk=function(){this._readChunk(),this._chunkLoaded()}:this._nextChunk=function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)return void this._chunkLoaded();if(i=new XMLHttpRequest,this._config.withCredentials&&(i.withCredentials=this._config.withCredentials),A||(i.onload=g(this._chunkLoaded,this),i.onerror=g(this._chunkError,this)),i.open("GET",this._input,!A),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var t in e)i.setRequestHeader(t,e[t])}if(this._config.chunkSize){var o=this._start+this._config.chunkSize-1;i.setRequestHeader("Range","bytes="+this._start+"-"+o),i.setRequestHeader("If-None-Match","webkit-no-cache")}try{i.send()}catch(e){this._chunkError(e.message)}A&&0===i.status?this._chunkError():this._start+=this._config.chunkSize},this._chunkLoaded=function(){if(4==i.readyState){if(i.status<200||i.status>=400)return void this._chunkError();this._finished=!this._config.chunkSize||this._start>t(i),this.parseChunk(i.responseText)}},this._chunkError=function(e){var t=i.statusText||e;this._sendError(t)}}function r(e){e=e||{},e.chunkSize||(e.chunkSize=I.LocalChunkSize),o.call(this,e);var t,i,r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,i=e.slice||e.webkitSlice||e.mozSlice,r?(t=new FileReader,t.onload=g(this._chunkLoaded,this),t.onerror=g(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function n(e){e=e||{},o.call(this,e);var t,i;this.stream=function(e){return t=e,i=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e=this._config.chunkSize,t=e?i.substr(0,e):i;return i=e?i.substr(e):"",this._finished=!i,this.parseChunk(t)}}}function a(e){e=e||{},o.call(this,e);var t=[],i=!0;this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._nextChunk=function(){t.length?this.parseChunk(t.shift()):i=!0},this._streamData=g(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),i&&(i=!1,this.parseChunk(t.shift()))}catch(e){this._streamError(e)}},this),this._streamError=g(function(e){this._streamCleanUp(),this._sendError(e.message)},this),this._streamEnd=g(function(){this._streamCleanUp(),this._finished=!0,this._streamData("")},this),this._streamCleanUp=g(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function s(e){function t(){if(_&&f&&(d("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+I.DefaultDelimiter+"'"),f=!1),e.skipEmptyLines)for(var t=0;t<_.data.length;t++)1===_.data[t].length&&""===_.data[t][0]&&_.data.splice(t--,1);return o()&&i(),a()}function o(){return e.header&&0===y.length}function i(){if(_){for(var e=0;o()&&e<_.data.length;e++)for(var t=0;t<_.data[e].length;t++)y.push(_.data[e][t]);_.data.splice(0,1)}}function r(t){return e.dynamicTypingFunction&&void 0===e.dynamicTyping[t]&&(e.dynamicTyping[t]=e.dynamicTypingFunction(t)),(e.dynamicTyping[t]||e.dynamicTyping)===!0}function n(e,t){return r(e)?"true"===t||"TRUE"===t||"false"!==t&&"FALSE"!==t&&c(t):t}function a(){if(!_||!e.header&&!e.dynamicTyping)return _;for(var t=0;t<_.data.length;t++){for(var o=e.header?{}:[],i=0;i<_.data[t].length;i++){var r=i,a=_.data[t][i];e.header&&(r=i>=y.length?"__parsed_extra":y[i]),a=n(r,a),"__parsed_extra"===r?(o[r]=o[r]||[],o[r].push(a)):o[r]=a}_.data[t]=o,e.header&&(i>y.length?d("FieldMismatch","TooManyFields","Too many fields: expected "+y.length+" fields but parsed "+i,t):i1&&(c+=Math.abs(f-n),n=f):n=f}m.data.length>0&&(d/=m.data.length),("undefined"==typeof r||c1.99&&(r=c,i=u)}return e.delimiter=i,{successful:!!i,bestDelimiter:i}}function u(e){e=e.substr(0,1048576);var t=e.split("\r"),o=e.split("\n"),i=o.length>1&&o[0].length=t.length/2?"\r\n":"\r"}function c(e){var t=g.test(e);return t?parseFloat(e):e}function d(e,t,o,i){_.errors.push({type:e,code:t,message:o,row:i})}var m,h,f,g=/^\s*-?(\d*\.?\d+|\d+\.?\d*)(e[-+]?\d+)?\s*$/i,b=this,w=0,A=!1,C=!1,y=[],_={data:[],errors:[],meta:{}};if(v(e.step)){var E=e.step;e.step=function(i){if(_=i,o())t();else{if(t(),0===_.data.length)return;w+=i.data.length,e.preview&&w>e.preview?h.abort():E(_,b)}}}this.parse=function(o,i,r){if(e.newline||(e.newline=u(o)),f=!1,e.delimiter)v(e.delimiter)&&(e.delimiter=e.delimiter(o),_.meta.delimiter=e.delimiter);else{var n=s(o,e.newline);n.successful?e.delimiter=n.bestDelimiter:(f=!0,e.delimiter=I.DefaultDelimiter),_.meta.delimiter=e.delimiter}var a=p(e);return e.preview&&e.header&&a.preview++,m=o,h=new l(a),_=h.parse(m,i,r),t(),A?{meta:{paused:!0}}:_||{meta:{paused:!1}}},this.paused=function(){return A},this.pause=function(){A=!0,h.abort(),m=m.substr(h.getCharIndex())},this.resume=function(){A=!1,b.streamer.parseChunk(m)},this.aborted=function(){return C},this.abort=function(){C=!0,h.abort(),_.meta.aborted=!0,v(e.complete)&&e.complete(_),m=""}}function l(e){e=e||{};var t=e.delimiter,o=e.newline,i=e.comments,r=e.step,n=e.preview,a=e.fastMode,s=e.quoteChar||'"';if(("string"!=typeof t||I.BAD_DELIMITERS.indexOf(t)>-1)&&(t=","),i===t)throw"Comment character same as delimiter";i===!0?i="#":("string"!=typeof i||I.BAD_DELIMITERS.indexOf(i)>-1)&&(i=!1),"\n"!=o&&"\r"!=o&&"\r\n"!=o&&(o="\n");var l=0,u=!1;this.parse=function(e,c,d){function m(e){_.push(e),k=l}function h(t){return d?p():("undefined"==typeof t&&(t=e.substr(l)),I.push(t),l=b,m(I),y&&g(),p())}function f(t){l=t,m(I),I=[],P=e.indexOf(o,l)}function p(e){return{data:_,errors:E,meta:{delimiter:t,linebreak:o,aborted:u,truncated:!!e,cursor:k+(c||0)}}}function g(){r(p()),_=[],E=[]}if("string"!=typeof e)throw"Input must be a string";var b=e.length,w=t.length,A=o.length,C=i.length,y=v(r);l=0;var _=[],E=[],I=[],k=0;if(!e)return p();if(a||a!==!1&&e.indexOf(s)===-1){for(var S=e.split(o),R=0;R=n)return _=_.slice(0,n),p(!0)}}return p()}for(var T=e.indexOf(t,l),P=e.indexOf(o,l),x=new RegExp(s+s,"g");;)if(e[l]!==s)if(i&&0===I.length&&e.substr(l,C)===i){if(P===-1)return p();l=P+A,P=e.indexOf(o,l),T=e.indexOf(t,l)}else if(T!==-1&&(T=n)return p(!0)}else{var D=l;for(l++;;){var D=e.indexOf(s,D+1);if(D===-1)return d||E.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:_.length,index:l}),h();if(D===b-1){var O=e.substring(l,D).replace(x,s);return h(O)}if(e[D+1]!==s){if(e[D+1]===t){I.push(e.substring(l,D).replace(x,s)),l=D+1+w,T=e.indexOf(t,l),P=e.indexOf(o,l);break}if(e.substr(D+1,A)===o){if(I.push(e.substring(l,D).replace(x,s)),f(D+1+A),T=e.indexOf(t,l),y&&(g(),u))return p();if(n&&_.length>=n)return p(!0);break}}else D++}}return h()},this.abort=function(){u=!0},this.getCharIndex=function(){return l}}function u(){var e=document.getElementsByTagName("script");return e.length?e[e.length-1].src:""}function c(){if(!I.WORKERS_SUPPORTED)return!1;if(!y&&null===I.SCRIPT_PATH)throw new Error("Script path cannot be determined automatically when Papa Parse is loaded asynchronously. You need to set Papa.SCRIPT_PATH manually.");var e=I.SCRIPT_PATH||b;e+=(e.indexOf("?")!==-1?"&":"?")+"papaworker";var t=new w.Worker(e);return t.onmessage=d,t.id=E++,_[t.id]=t,t}function d(e){var t=e.data,o=_[t.workerId],i=!1;if(t.error)o.userError(t.error,t.file);else if(t.results&&t.results.data){var r=function(){i=!0,m(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},n={abort:r,pause:h,resume:h};if(v(o.userStep)){for(var a=0;a