function ProductModel(t){this.ProductCode=t.ProductCode,this.ProductName=t.ProductName,this.ProductDiscount=t.ProductDiscount,this.ProductPrice=t.ProductPrice,this.ProductShip=t.ProductShip,this.Qty=t.Qty||1,this.images=t.images,this.videos=t.videos,this.Material=this.extractMaterialFromName(this.ProductName),this.Size=this.extractDimensionFromName(this.ProductName)}function ProductMultipleModel(t,e,o){this.name=t,this.list=[];for(const t of o){let o=transformedData.find((t=>t.name==e)).products.find((e=>e.ProductCode==t.ProductCode));o.Qty=t.Qty,this.list.push(new ProductModel(o))}this.calcCosts=()=>{let t=0,e=0;return this.list.forEach((function(o){if(o.ProductPrice){var r=o.ProductPrice,n=o.Qty,i=o.ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}})),e=Number(parseFloat(e).toFixed(2)),{totalCost:t,totalSaving:e}}}function customtrackEvent(t,e){try{gtag("event",t,{event_category:"engagement",event_label:e,value:1}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:t})}catch(t){console.log(t)}}ProductModel.prototype.extractMaterialFromName=function(t){for(var e=["PE","PVC"],o=0;o{if(t&&t.marquee_details_fragmentHTML){const e=document.getElementById("marquee_details_fragmentHTML");if(e){e.innerHTML=t.marquee_details_fragmentHTML;try{observeAnimations()}catch(t){}try{pjslider_init()}catch(t){}}else console.error('Element with ID "marquee_details_fragmentHTML" not found.');if(t.featuredVideo){const e=document.getElementById("featuredVideo");if(e&&"IFRAME"===e.tagName){const o=`https://www.youtube.com/embed/${t.featuredVideo}`;e.src!==o&&(e.src=o)}else console.error('Element with ID "featuredVideo" not found or is not an iframe.')}t.meta&&(document.title=t.meta.title||document.title,document.querySelector('meta[name="description"]').content=t.meta.description||"",document.querySelector('meta[name="keywords"]').content=t.meta.keywords||"")}else console.error("Invalid data or marquee_details_fragmentHTML not found.")};var Marquee,MarqueeModel=function(){this.Standing=ko.observable(),this.Seated=ko.observable(),this.Packing=ko.observableArray(),this.getPackingTotalWeight=()=>{let t=0;return this.Packing().forEach((e=>{let o=0,r=1,n=e.Value.match(/WT\s*([\d\.]+)\s*kg/);if(n||(n=e.Value.match(/Weight:\s*([\d\.]+)\s*kg\s*(each)?/)),n&&(o=parseFloat(n[1]),n[2])){const t=e.Value.match(/(\d+)\s*x/);r=t?parseInt(t[1]):1}t+=o*r})),parseFloat(t).toFixed(2)},this.Dimensions=ko.observableArray(),this.formattedProductShip=ko.observable(),this.InstructionVideo=ko.observable(),this.imageOne=()=>{switch(this.Canopy.Product().ProductCode){case"06073":case"00700":case"06205":case"00702":case"07161":case"07162":case"07827":case"00701":case"00703":case"00704":case"00705":case"00706":case"00707":case"00708":case"00709":case"10080":case"10081":case"10082":case"10083":case"10084":case"10085":return"https://cdn.galatent.co.uk/cdn/galatent_co_uk/images/marquee-land/3m-wide-pe-marquee--GB.png";case"09080":case"09073":case"09081":case"09082":case"09083":case"09084":case"09085":return"https://cdn.galatent.co.uk/cdn/galatent_co_uk/images/marquee-land/3m-wide-pvc-marquess---GB.jpg";case"09086":case"09087":case"09088":case"09089":case"09090":return"https://cdn.galatent.co.uk/cdn/galatent_co_uk/images/marquee-land/4m-wide-pvc-marquess---GB.jpg";default:return"https://cdn.galatent.co.uk/cdn/galatent_co_uk/images/marquee-land/6m-wide-pvc-marquess---GB.jpg"}},this.Qty=ko.observable(1);var t=window.__marquee.material,e=window.__marquee.size;this.SizeDims=ko.observableArray(e.split(" x ")),this.Frame={Size:ko.observable(e),Frame:ko.observable(),Product:ko.observable()},this.Canopy={Material:ko.observable(t),Product:ko.observable()},this.Anchorage={ConcreteWeights:{Option:ko.observable(),previewOption:ko.observable(),generateOptions:function(){const[t,e]=Marquee.SizeDims(),o=4+parseInt(e.replace("m"))/3*2;let r=[],n=o;const i=Math.floor(n/10);n-=10*i;const a=Math.floor(n/8);n-=8*a;const c=Math.floor(n/6);n-=6*c;const s=Math.floor(n/4);n-=4*s,n>0?42===o?r=[{ProductCode:"12598",Qty:3},{ProductCode:"12597",Qty:1},{ProductCode:"12595",Qty:1}]:32===o?r=[{ProductCode:"12598",Qty:2},{ProductCode:"12597",Qty:1},{ProductCode:"12595",Qty:1}]:22===o?r=[{ProductCode:"12598",Qty:1},{ProductCode:"12597",Qty:1},{ProductCode:"12595",Qty:1}]:12===o?r=[{ProductCode:"12597",Qty:1},{ProductCode:"12595",Qty:1}]:console.warn(`Unaccounted quantity: ${n}`):(i>0&&r.push({ProductCode:"12598",Qty:i}),a>0&&r.push({ProductCode:"12597",Qty:a}),c>0&&r.push({ProductCode:"12596",Qty:c}),s>0&&r.push({ProductCode:"12595",Qty:s}));const u=new ProductMultipleModel(`x${o} Concrete Weights 40kg`,"Anchorage",r);this.previewOption(u)},toggle:function(){this.Option("Yes"===this.Option()?"No":"Yes")}},WaterBagWeights:{Option:ko.observable(),previewOption:ko.observable(),generateOptions:function(){const[t,e]=Marquee.SizeDims(),o=4+parseInt(e.replace("m"))/3*2;let r=new ProductMultipleModel(`x${o} Water Bag Weights 50kg`,"Anchorage",[{ProductCode:"11087",Qty:o}]);this.previewOption(r)},toggle:function(){this.Option("Yes"===this.Option()?"No":"Yes")}},HeavyDutyGroundAnchor:{Option:ko.observable(),previewOption:ko.observable(),generateOptions:function(){const[t,e]=Marquee.SizeDims(),o=4+parseInt(e.replace("m"))/3*2;let r=new ProductMultipleModel(`x${o} Heavy Duty Ground Anchor Peg`,"Anchorage",[{ProductCode:"07531",Qty:o}]);this.previewOption(r)},toggle:function(){this.Option("Yes"===this.Option()?"No":"Yes")}}},this.Anchors={Empty:new ProductModel({ProductCode:"Select",ProductName:"Select"}),Option:ko.observable(),Product:ko.observable(),Options:ko.observableArray(),toggle:function(){setTimeout((function(){Marquee.Anchors.Option(Marquee.Anchors.Option()===Marquee.Anchors.Empty?Marquee.Anchors.tiedownkit():Marquee.Anchors.Empty)}),0)},generateOptions:function(){var t=function(t,e){var o=new ProductModel(t=transformedData.find((t=>"Anchorage"==t.name)).products.find((e=>e.ProductCode==t)));return o.Selected=ko.observable(),e>1&&(o.Qty=e,o.ProductName="(x"+o.Qty+") "+o.ProductName+" +"+localizeCost(o.ProductPrice*o.Qty)),o},e=[];const o=extractDimensions(Marquee.Frame.Size());o?6==o.width?e.push(t("07531",o.height)):4==o.width?12==o.height?e.push(t("07531",8)):10==o.height?e.push(t("07531",6)):8==o.height||6==o.height?e.push(t("07531",4)):e.push(t("07531",3)):3==o.width&&(12==o.height?e.push(t("07531",8)):10==o.height?e.push(t("07531",5)):8==o.height?e.push(t("07531",4)):6==o.height?e.push(t("07531",3)):e.push(t("07531",2))):e.push(t("07531",2)),e.push(t("12595",2)),this.Options(e)},previewOption:function(){return transformedData.find((t=>"Anchorage"==t.name)).products.find((t=>"07531"===t.ProductCode))}},this.Extras={Option:ko.observable()},this.Lining={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Marquee.Lining.Option("Select"===Marquee.Lining.Option()?"Yes":"Select")}),0)},previewOption:function(){return transformedData.find((t=>"Lining"==t.name)).products.find((t=>-1!==t.ProductName.indexOf(Marquee.Frame.Size())))}},this.calculateMarquee=function(){var t=transformedData.find((t=>"Marquees"==t.name)).products.find((t=>(t.Size||"")==this.Frame.Size()));this.Canopy.Product(t)},this.calculateMarqueeProducts=function(){try{if("Yes"==this.Lining.Option()){var t=transformedData.find((t=>"Lining"==t.name)).products.find((t=>-1!==t.ProductName.indexOf(this.Frame.Size())));t?this.Lining.Product(t):(showAlert("icon-cancel-circled","Error","Lining option not available for this size!","#FFFFFF",!1),this.Lining.Option("Select"))}else this.Lining.Product(void 0)}catch(t){console.log(t)}},this.calcCosts=()=>{let t=0,e=0;return[this.Frame,this.Canopy,this.Anchors,this.Lining,this.Anchorage.ConcreteWeights,this.Anchorage.HeavyDutyGroundAnchor,this.Anchorage.WaterBagWeights].forEach((function(o){if(void 0!==o.Product&&o.Product()&&o.Product().ProductPrice){var r=o.Product().ProductPrice,n=o.Product().Qty,i=o.Product().ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}else if(void 0!==o.Option&&"Yes"===o.Option()){const r=o.previewOption().calcCosts();t+=r.totalCost,e+=r.totalSaving}})),e=Number(parseFloat(e).toFixed(2)),t*=this.Qty(),e*=this.Qty(),{totalCost:t,totalSaving:e}},this.calcBundleCosts=()=>{let t=0,e=0;return[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){var r=o.Product().ProductPrice,n=o.Product().Qty,i=o.Product().ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}})),e=Number(parseFloat(e).toFixed(2)),t*=this.Qty(),e*=this.Qty(),{totalCost:t,totalSaving:e}},this.calculateGazeboCost=function(){const{totalCost:t}=this.calcCosts();return t},this.getSaving=function(){const{totalSaving:t}=this.calcCosts();return t},this.getBundleProducts=()=>{const t=[];var e=1;return[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){let r={sku:o.Product().ProductCode,qty:o.Product().Qty};o.Product().ProductShip>e&&(e=o.Product().ProductShip),r.qty>0&&t.push(r)}})),{skusToAdd:t,productShipping:e}},this.click_addbuilderproducts_bundle=function(){const t=this.getBundleProducts();this.add(t)},this.getShipping=function(){const t=Marquee.getBuilderProducts(),{productShipping:e}=t;return parseInt(e)},this.getBreakDown=function(){let t=[];return[this.Frame,this.Canopy,this.Lining,this.Anchorage.ConcreteWeights,this.Anchorage.HeavyDutyGroundAnchor,this.Anchorage.WaterBagWeights].forEach((function(e){if(void 0!==e.Product&&e.Product()&&e.Product().ProductPrice)e.Product().Qty>0&&t.push(e.Product());else if(void 0!==e.Option&&"Yes"===e.Option())for(const o of e.previewOption().list)t.push(o)})),t},this.getBuilderProducts=function(){const t=[];var e=1;return[this.Frame,this.Canopy,this.Anchors,this.Lining,this.Anchorage.ConcreteWeights,this.Anchorage.HeavyDutyGroundAnchor,this.Anchorage.WaterBagWeights].forEach((function(o){if(void 0!==o.Product&&o.Product()&&o.Product().ProductPrice){let r={sku:o.Product().ProductCode,qty:o.Product().Qty*Marquee.Qty()};o.Product().ProductShip>e&&(e=o.Product().ProductShip),r.qty>0&&t.push(r)}else if(void 0!==o.Option&&"Yes"===o.Option())for(const r of o.previewOption().list){let o={sku:r.ProductCode,qty:r.Qty*Marquee.Qty()};r.ProductShip>e&&(e=r.ProductShip),o.qty>0&&t.push(o)}})),{skusToAdd:t,productShipping:e}},this.click_addbuilderproducts=function(){const t=this.getBuilderProducts();this.add(t)},this.add=t=>{const{skusToAdd:e,productShipping:o}=t;o>1&&modalOpen(document.getElementById("help-oos")),fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e})}).then((t=>t.json())).then((t=>{setBasket({Qty:t.totalQty,Cost:t.totalPrice}),showAlert("icon-ok-circled",CONST_PRODUCT_ADD_TITLE,CONST_PRODUCT_ADDED+" "+CONST_PRODUCT_ADDED_APPEND,"#FFFFFF",!1)})).catch((t=>{console.error("Error:",t)}))},this.Frame.Size.subscribe((function(t){Marquee.calculateMarquee(),Marquee.calculateMarqueeProducts(),Marquee.Anchors.generateOptions();const e=t.split(" x ");Marquee.SizeDims(e),Marquee.Anchorage.ConcreteWeights.generateOptions(),Marquee.Anchorage.WaterBagWeights.generateOptions(),Marquee.Anchorage.HeavyDutyGroundAnchor.generateOptions()})),this.Canopy.Material.subscribe((function(t){Marquee.calculateMarquee()})),this.Canopy.Product.subscribe((function(t){t&&t.images&&setTimeout((function(){var e=[],o=t.images;for(var r in o)e.push(new galleryModel(o[r]));var n=t.videos;for(var r in n)e.push(new galleryModel(n[r]));gallery=e,"undefined"!=typeof createGallery&&createGallery()}),0),fetch("/modular-marquees/fragment?code="+Marquee.Canopy.Product().ProductCode).then((t=>{if(!t.ok)throw new Error("Network response was not ok "+t.statusText);return t.json()})).then((t=>{setDetailsFragmentHTML(t),Marquee.formattedProductShip(t.formattedProductShip),updateUrlAndReload(`/modular-marquees${t.URL}`)})).catch((t=>{console.error("Fetch error:",t)}))})),this.Anchors.Option.subscribe((function(t){Marquee.Anchors.Product(t),Marquee.calculateMarqueeProducts()})),this.Lining.Option.subscribe((function(t){Marquee.calculateMarqueeProducts()}))};function qty_increase(t){var e=t();e=isNaN(e)?0:e,t(qty_check(++e))}function qty_decrease(t){var e=t();e=isNaN(e)?0:e,t(qty_check(--e))}function qty_check(t){var e=isNaN(t)?0:t;return e>999?e=999:e<0&&(e=0),e}function extractDimensions(t){const e=t.match(/(\d+)m\s*x\s*(\d+)m/);if(e&&e.length>=3){return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}return null}function updateUrlAndReload(t){try{t.startsWith("/")&&(t=t.substring(1));const e=window.location.origin,o=new URL(t,e),r=e+o.pathname+o.search;window.history.pushState({path:r},"",r);document.querySelector('link[rel="canonical"]').href=r}catch(t){console.error("Error updating URL:",t)}}function transformInputToProductModels(){var t=[];return window.__input.forEach((function(e){var o={};o.name=e.name,o.products=e.data.map((function(t){return new ProductModel(t)})),t.push(o)})),t}document.addEventListener("DOMContentLoaded",(function(){(Marquee=new MarqueeModel).calculateMarquee(),Marquee.Anchors.generateOptions(),Marquee.Anchorage.ConcreteWeights.generateOptions(),Marquee.Anchorage.WaterBagWeights.generateOptions(),Marquee.Anchorage.HeavyDutyGroundAnchor.generateOptions(),ko.applyBindings(Marquee,document.getElementById("content"))})),window.addEventListener("popstate",(function(t){window.location.reload(!1)}));var transformedData=transformInputToProductModels();