function getDyeSubName(e){switch(e){case"13104":case"13110":case"13115":case"13120":case"13125":case"13130":case"13135":case"13140":case"13145":case"13150":case"13155":case"13160":case"13165":case"13170":return"Canopy Only";case"13105":case"13111":case"13116":case"13121":case"13126":case"13131":case"13136":case"13141":case"13146":case"13151":case"13156":case"13161":case"13166":case"13171":case"13175":case"13180":case"13185":case"13190":case"13195":return"Canopy + Half Wall";case"13106":case"13112":case"13117":case"13122":case"13127":case"13132":case"13137":case"13142":case"13147":case"13152":case"13157":case"13162":case"13167":case"13172":case"13176":case"13181":case"13186":case"13191":case"13196":return"Canopy + Printed Back Wall";case"13108":case"11341":case"11347":case"11876":case"11337":case"11343":case"11349":case"11339":case"11345":case"11351":case"13089":case"13091":case"13093":case"13095":case"13179":case"13184":case"13189":case"13194":case"13199":return"Canopy + 3 printed walls (Popular Choice)";case"13109":case"13114":case"13119":case"13124":case"13129":case"13134":case"13139":case"13144":case"13149":case"13154":case"13159":case"13164":case"13169":case"13174":case"13178":case"13183":case"13188":case"13193":case"13198":return"Canopy + 4 printed walls";case"13107":case"13113":case"13118":case"13123":case"13128":case"13133":case"13138":case"13143":case"13148":case"13153":case"13158":case"13163":case"13168":case"13173":case"13177":case"13182":case"13187":case"13192":case"13197":return"Canopy + Double-Sided Walls";default:return null}}function getDyeSubDesc(e){switch(e){case"13104":case"13110":case"13115":case"13120":case"13125":case"13130":case"13135":case"13140":case"13145":case"13150":case"13155":case"13160":case"13165":case"13170":return"This is an unlimited print canopy with the frame of your choice. ";case"13105":case"13111":case"13116":case"13121":case"13126":case"13131":case"13136":case"13141":case"13146":case"13151":case"13156":case"13161":case"13166":case"13171":case"13175":case"13180":case"13185":case"13195":return"Create a serving hatch by adding a custom-printed gazebo half wall. This also includes strengthening bar for hanging the wall. ";case"13190":return"Create a serving hatch by adding a custom-printed gazebo half wall. You may require a strengthening bar to hang the half wall if you do not have one.";case"13106":case"13112":case"13117":case"13122":case"13127":case"13132":case"13137":case"13142":case"13147":case"13152":case"13157":case"13162":case"13167":case"13172":case"13176":case"13181":case"13186":case"13191":case"13196":return"Enhance your printed gazebo space with a branded back wall (single-sided print).";case"13108":case"11341":case"11347":case"11876":case"11337":case"11343":case"11349":case"11339":case"11345":case"11351":case"13089":case"13091":case"13093":case"13095":case"13179":case"13184":case"13189":case"13194":case"13199":return"Enclose your structure with fully branded walls, including a double-sided back wall for inner and outer brand exposure.";case"13109":case"13114":case"13119":case"13124":case"13129":case"13134":case"13139":case"13144":case"13149":case"13154":case"13159":case"13164":case"13169":case"13174":case"13178":case"13183":case"13188":case"13193":case"13198":return"This is a fully printed gazebo from top-to-bottom. Get Canopy plus 3 walls and a printed gazebo door panel.";case"13107":case"13113":case"13118":case"13123":case"13128":case"13133":case"13138":case"13143":case"13148":case"13153":case"13158":case"13163":case"13168":case"13173":case"13177":case"13182":case"13187":case"13192":case"13197":return"Get your gazebo printed top-to-bottom, plus printed on both sides of your gazebo walls. The only limit is your imagination.";default:return null}}function DyeSubItem(e){var a=this;a.ProductAvailable=e.ProductAvailable,a.ProductCode=e.ProductCode,a.ProductDiscount=e.ProductDiscount,a.ProductLink=e.ProductLink,a.ProductName=e.ProductName,a.ProductPrice=e.ProductPrice,a.ProductShip=e.ProductShip,a.ProdLargeImage=e.ProdLargeImage,a.ShortName=getDyeSubName(a.ProductCode)||a.ProductName,a.ShortDesc=getDyeSubDesc(a.ProductCode)||"x",a.isSelected=ko.observable(!1),a.click_select=function(){for(let e in PrintedGazebo.DyeSub.listing())PrintedGazebo.DyeSub.listing()[e].isSelected(!1);a.isSelected(!0),PrintedGazebo.DyeSub.Product.Selected(a)}}var PrintedGazebo;function PrintJobSheet(){this.PRINTJOBNOTES=null,this.hasArtwork=ko.observable("YES")}function uploadFile(){const e=document.getElementById("fileInput").files[0];if(!e)return void alert("Please select a file.");const a=new FormData;a.append("multfile",e),fetch("/create-printed-gazebo/artwork",{method:"PUT",body:a}).then((e=>e.json())).then((e=>{console.log("Success:",e),alert("File uploaded successfully")})).catch((e=>{console.error("Error:",e),alert("Error uploading file")}))}function deletePhoto(e){if(confirm("Delete artwork "+e)){const a="/create-printed-gazebo/artwork/"+encodeURIComponent(e);fetch(a,{method:"DELETE"}).then((e=>{if(!e.ok)throw new Error("Network response was not ok.");return e.json()})).then((e=>{showAlert("icon-trash","Deleted!","","#FFFFFF",!1),setTimeout(pollUploadedImages,1e3),setTimeout(pollUploadedImages,3e3),setTimeout(pollUploadedImages,5e3)})).catch((e=>{console.error("Error:",e)}))}}function pollUploadedImages(){fetch("/create-printed-gazebo/artwork").then((e=>e.json())).then((e=>{const a=[];for(const s of e)"file"===s[".tag"]&&(s.Id=a.length+1,a.push(s));PrintedGazebo.DyeSub.Product.Artwork(a)})).catch((e=>{console.error("Error:",e)}))}function PrintedGazeboModel(){var e=urlParams.get("method"),a=urlParams.get("size"),s=urlParams.get("frame")||"COVERS",t=(urlParams.get("qty"),this);t.Interface=new InterfaceModel,t.Vinyl=new VinylModel,t.Questions={PrintingMethod:ko.observable(e),CanopySize:ko.observable(a),Frame:ko.observable(s),Qty:ko.observable(),click_next:function(){if(!t.Questions.PrintingMethod()||!t.Questions.CanopySize()||!t.Questions.Frame())return alert("fill everything in!");t.Interface.setInterface("VINYL"==t.Questions.PrintingMethod()?1:2),pushURL()}},t.DyeSub=new DyeSubModel(t),loadURL()}function InterfaceModel(){var e=this;e.InterfaceID=ko.observable(0),e.setInterface=function(a){e.InterfaceID(a);try{scrolltoTop()}catch(e){}}}function VinylModel(){var e=this;e.Interface=new InterfaceModel,e.Questions={CanopyPrinting:ko.observable(),FabricColour:ko.observable(),SidewallPrinting:ko.observable(),SidewallColour:ko.observable()},e.CanopyPrintArea={Front:ko.observable(),Back:ko.observable(),Left:ko.observable(),Right:ko.observable()},e.click_design=function(){PrintedGazebo.DyeSub.Interface.setInterface(1)}}function DyeSubModel(e){var a=this;a.Interface=new InterfaceModel;let s=[];for(var t in window.__data.dyesub)s.push(new DyeSubItem(window.__data.dyesub[t]));a.listing=ko.observableArray(s),a.filteredListing=ko.computed((function(){return ko.utils.arrayFilter(a.listing(),(function(a){try{return a.ProductName.toUpperCase().includes(e.Questions.CanopySize())&&a.ProductName.toUpperCase().includes(e.Questions.Frame().toUpperCase())}catch(e){return console.log(e),!1}}))})),a.Product={Selected:ko.observable(),PJS:new PrintJobSheet,Artwork:ko.observableArray(),add_to_basket:function(){const e=document.getElementById("artworkinstructions");a.Product.PJS.PRINTJOBNOTES=e?e.value:"";const s=[{sku:a.Product.Selected().ProductCode,qty:PrintedGazebo.Questions.Qty(),extras:{pjs:JSON.parse(ko.toJSON(a.Product.PJS))}}];console.log(s),fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:s})}).then((e=>e.json())).then((e=>{setBasket({Qty:e.totalQty,Cost:e.totalPrice}),showAlert("fa-check","Added!","Added item(s) to your basket!","#FFFFFF",!1)})).catch((e=>{console.error("Error:",e)}))}}}function scrolltoTop(){setTimeout((function(){document.body.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}),100)}document.addEventListener("DOMContentLoaded",(function(){PrintedGazebo=new PrintedGazeboModel,ko.applyBindings(PrintedGazebo)})),document.addEventListener("DOMContentLoaded",(function(){pollUploadedImages(),setInterval(pollUploadedImages,15e3)}));const urlParams=new URLSearchParams(window.location.search);function buildURL(){let e=`${window.location.origin}${window.location.pathname}?`,a=PrintedGazebo;return a&&(e+=`method=${a.Questions.PrintingMethod()}&`,a.Questions&&a.Questions.CanopySize()&&(e+=`size=${a.Questions.CanopySize()}&`),a.Questions&&a.Questions.Frame()&&(e+=`frame=${a.Questions.Frame()}&`),a.Questions&&a.Questions.Qty()&&(e+=`qty=${a.Questions.Qty()}&`)),e}function pushURL(){const e=buildURL();window.history.pushState({path:e},"",e)}function loadURL(){var e=urlParams.get("steps");e&&e>0&&setTimeout((function(){PrintedGazebo.Questions.click_next()}),0)}window.addEventListener("popstate",(function(e){e.state?loadURL():console.log("Initial page load or no state data.")}));