!function(d){"use strict";window.bhfb={init:function(){this.builderGridContentFlag=!1,this.updateGridDelay=200,this.currentDevice="desktop",this.currentArea="header",this.currentRowInput="",this.currentRow="",this.currentColumn="",this.currentColumnPos="",this.currentComponent="",this.currentBuilder="",this.currentBuilderType="",this.componentsOrder="",this.customizeNavigation(),this.elementsPopup(),this.elementsButton(),this.storeGlobals(),this.devicesSwitcher(),this.elementsPopupContent(),this.builderGridContent(),this.elementsSortable(),this.builderCustomColumns(),this.builderColumnsLayout(),this.footerCustomizerOptions(),this.headerPresets(),this.showHideBuilder(),this.showHideBuilderTop()},jsonDecode:function(e){return JSON.parse(e.replace(/'/g,'"').replace(";",""))},customizeNavigation:function(){const o=["sub-accordion-section-botiga_section_hb_presets","sub-accordion-section-botiga_section_hb_above_header_row","sub-accordion-section-botiga_section_hb_main_header_row","sub-accordion-section-botiga_section_hb_below_header_row","sub-accordion-section-botiga_section_hb_mobile_offcanvas","sub-accordion-section-botiga_section_hb_component__logo","sub-accordion-section-botiga_section_hb_component__search","sub-accordion-section-botiga_section_hb_component__social","sub-accordion-section-botiga_section_hb_component__menu","sub-accordion-section-botiga_section_hb_component__secondary_menu","sub-accordion-section-botiga_section_hb_component__contact_info","sub-accordion-section-botiga_section_hb_component__button","sub-accordion-section-botiga_section_hb_component__button2","sub-accordion-section-botiga_section_hb_component__html","sub-accordion-section-botiga_section_hb_component__html2","sub-accordion-section-botiga_section_hb_component__shortcode","sub-accordion-section-botiga_section_hb_component__login_register","sub-accordion-section-botiga_section_hb_component__woo_icons","sub-accordion-section-botiga_section_hb_component__pll_switcher","sub-accordion-section-botiga_section_hb_component__wpml_switcher","sub-accordion-section-botiga_section_hb_component__mobile_offcanvas_menu","sub-accordion-section-botiga_section_hb_component__mobile_hamburger","sub-accordion-section-botiga_section_fb_above_footer_row","sub-accordion-section-botiga_section_fb_main_footer_row","sub-accordion-section-botiga_section_fb_below_footer_row","sub-accordion-section-botiga_section_fb_component__footer_menu","sub-accordion-section-botiga_section_fb_component__copyright","sub-accordion-section-botiga_section_fb_component__social","sub-accordion-section-botiga_section_fb_component__button","sub-accordion-section-botiga_section_fb_component__button2","sub-accordion-section-botiga_section_fb_component__html","sub-accordion-section-botiga_section_fb_component__html2","sub-accordion-section-botiga_section_fb_component__shortcode","sub-accordion-section-botiga_section_fb_component__widget1","sub-accordion-section-botiga_section_fb_component__widget2","sub-accordion-section-botiga_section_fb_component__widget3","sub-accordion-section-botiga_section_fb_component__widget4"];for(const i of["above","main","below"])for(let e=1;e<=6;e++)o.push("sub-accordion-section-botiga_header_row__"+i+"_header_row_column"+e),o.push("sub-accordion-section-botiga_footer_row__"+i+"_footer_row_column"+e);let t="";d(document).on("mouseover focus",".customize-section-back",function(e){t=d(".control-section.open").attr("id")}),d(document).on("click keydown",".customize-section-back",function(e){if(o.includes(t))return-1!==t.indexOf("above_header_row_column")?(wp.customize.section("botiga_section_hb_above_header_row").focus(),!1):-1!==t.indexOf("main_header_row_column")?(wp.customize.section("botiga_section_hb_main_header_row").focus(),!1):-1!==t.indexOf("below_header_row_column")?(wp.customize.section("botiga_section_hb_below_header_row").focus(),!1):-1!==t.indexOf("above_footer_row_column")?(wp.customize.section("botiga_section_fb_above_footer_row").focus(),!1):-1!==t.indexOf("main_footer_row_column")?(wp.customize.section("botiga_section_fb_main_footer_row").focus(),!1):-1!==t.indexOf("below_footer_row_column")?(wp.customize.section("botiga_section_fb_below_footer_row").focus(),!1):void(-1!==t.indexOf("_hb_")||-1!==t.indexOf("_header_")?wp.customize.section("botiga_section_hb_wrapper"):wp.customize.section("botiga_section_fb_wrapper")).focus()})},storeGlobals:function(){const o=this;d(" .wp-full-overlay-footer .devices button, .botiga-devices-preview button").on("click",function(){let e=d(this).attr("data-device");"tablet"===e&&(e="mobile"),"footer"===o.currentBuilderType&&(e="desktop"),o.currentDevice=e,o.builderGridContent()}),d(document).on("click mouseover",".botiga-bhfb-area:not(.bhfb-available-components)",function(e){return!d("#botiga-bhfb-elements").hasClass("show")&&(o.currentRowInput=d("#_customize-input-botiga_"+o.currentBuilderType+"_row__"+d(this).data("bhfb-row")),o.currentRow=d(this).closest(".botiga-bhfb-row"),o.currentColumnPos=d(this).index()-1,o.currentColumn=d(this),void(!o.currentRow.length&&d(this).hasClass("botiga-bhfb-area-offcanvas")&&(o.currentRowInput=d("#_customize-input-botiga_header_row__mobile_offcanvas"),o.currentRow=d(".botiga-bhfb-area-offcanvas"),o.currentColumnPos=d(this).index())))}),d(document).on("click mouseover",".bhfb-button",function(e){o.currentComponent=d(this).data("bhfb-id")})},devicesSwitcher:function(){d(" .wp-full-overlay-footer .devices button, .botiga-devices-preview button").on("click",function(){var e=d(this).attr("data-device");"mobile"===e&&(e="tablet"),d(".botiga-bhfb-devices .botiga-bhfb-device-link").removeClass("active"),d('.botiga-bhfb-devices .botiga-bhfb-device-link[data-device="'+e+'"]').addClass("active")}),d(".botiga-bhfb-devices .botiga-bhfb-device-link").on("click",function(e){e.preventDefault();e=d(this).attr("data-device");d(' .wp-full-overlay-footer .devices button[data-device="'+e+'"]').trigger("click")})},getElementsUnused:function(){var e;let o=botiga_hfb.components.desktop,t=botiga_hfb.components.mobile,i=["#_customize-input-botiga_header_row__above_header_row","#_customize-input-botiga_header_row__main_header_row","#_customize-input-botiga_header_row__below_header_row","#_customize-input-botiga_header_row__mobile_offcanvas"];"footer"===this.currentBuilderType&&(o=botiga_hfb.components.footer,i=["#_customize-input-botiga_footer_row__above_footer_row","#_customize-input-botiga_footer_row__main_footer_row","#_customize-input-botiga_footer_row__below_footer_row"]);for(e of i){for(var n of o){var _=this.jsonDecode(d(e).val());if(_.desktop.length)for(const a of _.desktop)o=o.filter(e=>!a.includes(e.id))}for(var n of t){var r=this.jsonDecode(d(e).val());if(r.mobile.length)for(const s of r.mobile)t=t.filter(e=>!s.includes(e.id));if(-1!==e.indexOf("row__mobile_offcanvas")&&r.mobile_offcanvas.length)for(const c of r.mobile_offcanvas)t=t.filter(e=>!c.includes(e.id))}}return{desktop:o,mobile:t}},elementsPopup:function(){const n=this;d(document).on("click",".botiga-bhfb-area:not(.bhfb-available-components)",function(e){const o=n.currentBuilder.find("#botiga-bhfb-elements"),t=d(this)[0].getBoundingClientRect(),i=d(this).data("bhfb-row");setTimeout(function(){return o.css("top",0),o.css("left",t.left),o.css("top",t.top-(o.height()+50)),n.isElementInViewport(o)?(o.css("left",t.left),o.css("right","auto")):(o.css("left","auto"),o.css("right",25)),!e.target.classList.contains("bhfb-remove-element")&&!e.target.classList.contains("bhfb-button")&&void o.addClass("show")},200),n.elementsPopupContent(i),n.builderGridContent()}),d("#customize-preview iframe").on("mouseup",function(e){n.closeElementsPopup(e)}),d(document).on("mouseup",function(e){return!!n.currentBuilder&&void n.closeElementsPopup(e)})},closeElementsPopup:function(e){const o=this.currentBuilder.find("#botiga-bhfb-elements");null===e.target.closest("#botiga-bhfb-elements")&&o.removeClass("show")},isElementInViewport:function(e){e=(e="function"==typeof jQuery&&e instanceof jQuery?e[0]:e).getBoundingClientRect();return 0<=e.top&&0<=e.left&&e.bottom<=(window.innerHeight||d(window).height())&&e.right<=(window.innerWidth||d(window).width())},elementsPopupContent:function(e=""){const o=this.getElementsUnused(),t=d(".botiga-bhfb-elements-desktop"),i=d(".botiga-bhfb-elements-mobile");t.html(""),i.html("");let n="hb";if(this.currentBuilderType&&"footer"===this.currentBuilderType&&(n="fb"),o.desktop.length)for(const _ of o.desktop)t.append('
");else t.append(''+botiga_hfb.i18n.elementsMessage+"
");if(o.mobile="mobile_offcanvas"!==e?o.mobile.filter(e=>"mobile_offcanvas_menu"!==e.id):o.mobile.filter(e=>"secondary_menu"!==e.id&&"mobile_hamburger"!==e.id),o.mobile.length)for(const r of o.mobile)i.append('");else i.append(''+botiga_hfb.i18n.elementsMessage+"
");this.addUpsellComponents()},updateAvailableComponents:function(){"header"===this.currentBuilderType&&(d(".botiga-header-builder-available-components").html(""),d(".botiga-header-builder-available-components").html(d(".botiga-bhfb-header .botiga-bhfb-elements-desktop").html()),d(".botiga-header-builder-available-mobile-components").html(""),d(".botiga-header-builder-available-mobile-components").html(d(".botiga-bhfb-header .botiga-bhfb-elements-mobile").html())),"footer"===this.currentBuilderType&&(d(".botiga-footer-builder-available-footer-components").html(""),d(".botiga-footer-builder-available-footer-components").html(d(".botiga-bhfb-footer .botiga-bhfb-elements-desktop").html()))},addUpsellComponents:function(){if(!botiga_hfb.upsell_components.enable)return!1;let e="",o="header"===this.currentBuilderType?botiga_hfb.upsell_components.header:botiga_hfb.upsell_components.footer;for(const i of o)e+=`
`;var t=`
`;d("#botiga-bhfb-elements .botiga-bhfb-elements-wrapper .botiga-bhfb-upsell-components-wrapper").remove(),d("#botiga-bhfb-elements .botiga-bhfb-elements-wrapper").append(t)},elementsButton:function(){const i=this;d(document).on("click",".botiga-bhfb-element > a",function(e){e.preventDefault();const o=d(this).data("bhfb-id"),t=d(this).data("bhfb-focus-section");if(d(this).closest("#botiga-bhfb-elements").length)i.elementsButtonAdd(o),i.currentBuilder.find("#botiga-bhfb-elements").removeClass("show");else if(e.target.classList.contains("bhfb-remove-element"))return i.elementsButtonRemove(o),!1;setTimeout(function(){wp.customize.section(t).focus()},i.updateGridDelay)})},elementsButtonAdd:function(e,o=!1){var t=this;let i=t.jsonDecode(t.currentRowInput.val()),n=t.currentDevice;return"mobile"===t.currentDevice&&t.currentRow.hasClass("botiga-bhfb-area-offcanvas")&&(n="mobile_offcanvas"),o?i[n][t.currentColumnPos]=t.componentsOrder:i[n][t.currentColumnPos].push(e),!("mobile_offcanvas_menu"===t.currentComponent&&!t.currentRow.hasClass("botiga-bhfb-area-offcanvas"))&&(("mobile_hamburger"!==t.currentComponent||!t.currentRow.hasClass("botiga-bhfb-area-offcanvas"))&&(t.currentRowInput.val(JSON.stringify(i)),t.currentRowInput.trigger("change"),"header"===t.currentBuilderType&&t.currentRowInput.closest(".customize-control").next().find("input").val(Math.random()).trigger("change"),t.elementsPopupContent(),t.builderGridContent(),void d("#botiga-bhfb-elements").removeClass("show")))},elementsButtonRemove:function(o,e=!0){var t=this;let i=t.jsonDecode(t.currentRowInput.val()),n=t.currentDevice;"mobile"===t.currentDevice&&t.currentRow.hasClass("botiga-bhfb-area-offcanvas")&&(n="mobile_offcanvas"),i[n][t.currentColumnPos]=i[n][t.currentColumnPos].filter(e=>e!==o),t.currentRowInput.val(JSON.stringify(i)),e&&(t.currentRowInput.trigger("change"),t.currentRowInput.closest(".customize-control").next().find("input").val(Math.random()).trigger("change")),t.elementsPopupContent(),t.builderGridContent()},elementsSortable:function(){const a=this;d(".botiga-bhfb-area").each(function(){d(this).sortable({placeholder:"botiga-bhfb-element bhfb-ui-state-highlight",connectWith:".botiga-bhfb-area",scroll:!1,cancel:".bhfb-edit-column",change:function(e,o){a.currentComponent=d(o.item[0]).find(".bhfb-button").data("bhfb-id"),a.currentRow=d(o.placeholder[0]).closest(".botiga-bhfb-row").length?d(o.placeholder[0]).closest(".botiga-bhfb-row"):d(o.placeholder[0]).closest(".botiga-bhfb-area-offcanvas"),a.currentRowInput=d("#_customize-input-botiga_"+a.currentBuilderType+"_row__"+o.placeholder.closest(".botiga-bhfb-area").data("bhfb-row"));let t=[];o.placeholder.closest(".botiga-bhfb-area").find(".ui-sortable-placeholder").attr("data-bhfb-id",a.currentComponent),o.placeholder.closest(".botiga-bhfb-area").find(".botiga-bhfb-element").each(function(){var e=(void 0!==d(this).find(".bhfb-button").data("bhfb-id")?d(this).find(".bhfb-button"):d(this)).data("bhfb-id");d(this).hasClass("ui-sortable-helper")||t.push(e)}),a.componentsOrder=t},update:function(e,o){if(this===o.item.parent()[0]){var t=o.item.find("> .bhfb-button").data("bhfb-id"),i=o.item.closest(".botiga-bhfb-area").data("bhfb-row"),n=o.item.closest(".botiga-bhfb-area").index()-1,_=null!==o.sender?o.sender.data("bhfb-row"):null,r=null!==o.sender?o.sender.index()-1:null;if(null===o.sender)return a.elementsButtonAdd("",!0),!1;o.sender.hasClass("bhfb-available-components")||(a.currentRowInput=d("#_customize-input-botiga_"+a.currentBuilderType+"_row__"+_)),a.currentColumnPos=r,a.elementsButtonRemove(t,!0),o.sender.hasClass("bhfb-available-components")||(a.currentRowInput=d("#_customize-input-botiga_"+a.currentBuilderType+"_row__"+i)),a.currentColumnPos=n,a.elementsButtonAdd(t,!0)}}}),d(this).disableSelection()})},builderGridContent:function(){let l=this,e=["#_customize-input-botiga_header_row__above_header_row","#_customize-input-botiga_header_row__main_header_row","#_customize-input-botiga_header_row__below_header_row","#_customize-input-botiga_header_row__mobile_offcanvas"],u="hb";if(l.currentBuilderType&&"footer"===l.currentBuilderType&&(e=["#_customize-input-botiga_footer_row__above_footer_row","#_customize-input-botiga_footer_row__main_footer_row","#_customize-input-botiga_footer_row__below_footer_row"],u="fb"),l.builderGridContentFlag)return!1;l.builderGridContentFlag=!0,setTimeout(function(){for(var t of e){var i,n=l.jsonDecode(d(t).val());let o="";if(-1!==t.indexOf("above_"+l.currentBuilderType+"_row")&&(o="above"),-1!==t.indexOf("main_"+l.currentBuilderType+"_row")&&(o="main"),-1!==t.indexOf("below_"+l.currentBuilderType+"_row")&&(o="below"),-1!==t.indexOf("row__mobile_offcanvas")&&(o="mobile_offcanvas"),d('.botiga-bhfb-area[data-bhfb-row="'+o+"_"+l.currentBuilderType+'_row"]').each(function(){d(this).remove()}),"desktop"===l.currentDevice){let e=1;for(const a of n.desktop){d(".botiga-bhfb-"+l.currentBuilderType+" .botiga-bhfb-"+o+"-row").append('');const s=d(".botiga-bhfb-"+o+"-row").find(".botiga-bhfb-area:last-child");if(a.length)for(var _ of a)_=l.getElementData(_),s.append('
');e++}}if("mobile"===l.currentDevice){let e=1;for(const c of n.mobile){d(".botiga-bhfb-"+o+"-row").append('
');const b=d(".botiga-bhfb-"+o+"-row").find(".botiga-bhfb-area:last-child");if(c.length)for(var r of c)r=l.getElementData(r),b.append('
');e++}if(-1!==t.indexOf("mobile_offcanvas"))if(d(".botiga-bhfb-area-offcanvas").html(""),n.mobile_offcanvas.length)for(i of n.mobile_offcanvas[0])i=l.getElementData(i),d(".botiga-bhfb-area-offcanvas").append('
')}}if(!l.currentBuilder)return l.builderGridContentFlag=!1;l.currentBuilder.hasClass("show")&&!l.currentBuilder.hasClass("show-bottom")?(d(".botiga-bhfb").css("height",0),l.currentBuilder.css("height",l.currentBuilder.find(".botiga-bhfb-top").outerHeight()+47)):l.currentBuilder.css("height",0),l.updateAvailableComponents(),l.elementsSortable(),d(window).trigger("bhfb.grid.ready"),l.builderGridContentFlag=!1},l.updateGridDelay)},getElementData:function(e){var o;let t=[...botiga_hfb.components.desktop,...botiga_hfb.components.mobile];"footer"===this.currentBuilderType&&(t=botiga_hfb.components.footer);for(o of t)if(o.id===e)return o;return""},showHideBuilder:function(){const t=this,o=["botiga_section_hb_wrapper","botiga_section_hb_presets","botiga_section_hb_above_header_row","botiga_section_hb_main_header_row","botiga_section_hb_below_header_row","botiga_section_hb_mobile_offcanvas","botiga_section_hb_component__logo","botiga_section_hb_component__search","botiga_section_hb_component__social","botiga_section_hb_component__menu","botiga_section_hb_component__secondary_menu","botiga_section_hb_component__contact_info","botiga_section_hb_component__button","botiga_section_hb_component__button2","botiga_section_hb_component__html","botiga_section_hb_component__html2","botiga_section_hb_component__shortcode","botiga_section_hb_component__login_register","botiga_section_hb_component__woo_icons","botiga_section_hb_component__pll_switcher","botiga_section_hb_component__wpml_switcher","botiga_section_hb_component__mobile_offcanvas_menu","botiga_section_hb_component__mobile_hamburger","botiga_section_fb_wrapper","botiga_section_fb_above_footer_row","botiga_section_fb_main_footer_row","botiga_section_fb_below_footer_row","botiga_section_fb_component__social","botiga_section_fb_component__footer_menu","botiga_section_fb_component__copyright","botiga_section_fb_component__button","botiga_section_fb_component__button2","botiga_section_fb_component__html","botiga_section_fb_component__html2","botiga_section_fb_component__shortcode","botiga_section_fb_component__widget1","botiga_section_fb_component__widget2","botiga_section_fb_component__widget3","botiga_section_fb_component__widget4"];for(const i of["above","main","below"])for(let e=1;e<=6;e++)o.push("botiga_header_row__"+i+"_header_row_column"+e),o.push("botiga_footer_row__"+i+"_footer_row_column"+e);o.forEach(function(o){void 0!==wp.customize.section(o)&&wp.customize.section(o).expanded.bind(function(e){t.currentBuilder=t.getCurrentBuilderByComponent(o),t.currentBuilderType=t.currentBuilder.hasClass("botiga-bhfb-header")?"header":"footer",e?(d("body").addClass("bhfb-active"),t.currentBuilder.addClass("show"),t.scrollToRespectiveBuilderArea()):(d("body").removeClass("bhfb-active"),t.currentBuilder.removeClass("show")),setTimeout(function(){t.builderGridContent(),"botiga_section_hb_wrapper"!==o&&"botiga_section_fb_wrapper"!==o||(d(".botiga-bhfb-"+t.currentBuilderType).find(".botiga-bhfb-above-row .botiga-bhfb-area").trigger("click"),d(".botiga-bhfb-elements").removeClass("show"))},100)})})},scrollToRespectiveBuilderArea:function(){var e=document.querySelector("#customize-preview > iframe").contentWindow.document.getElementsByTagName("html")[0],o="header"===this.currentBuilderType?0:99999;d(e).animate({scrollTop:o},"fast")},getCurrentBuilderByComponent:function(e){return-1!==e.indexOf("_hb_")||-1!==e.indexOf("_header_")?d(".botiga-bhfb-header"):(-1!==e.indexOf("_fb_")||-1!==e.indexOf("_footer_"))&&d(".botiga-bhfb-footer")},showHideBuilderTop:function(){const o=this;d(".botiga-bhfb-bottom-display").on("click",function(e){e.preventDefault(),d("body").toggleClass("bhfb-active-bottom"),d(this).toggleClass("show"),d(".botiga-bhfb-top").toggleClass("show"),d(".botiga-bhfb").toggleClass("show-bottom"),o.builderGridContent()})},builderCustomColumns:function(){const c=this;["botiga_header_row__above_header_row_columns","botiga_header_row__main_header_row_columns","botiga_header_row__below_header_row_columns","botiga_footer_row__above_footer_row_columns_desktop","botiga_footer_row__main_footer_row_columns_desktop","botiga_footer_row__below_footer_row_columns_desktop"].forEach(function(a){if(void 0!==wp.customize.control(a))for(const s of-1!==a.indexOf("header")?["desktop","tablet"]:["desktop"]){var e=-1!==a.indexOf("header")?"_"+s:"";wp.customize(a+e,function(e){e.bind(function(e){let o="",t="";for(const r of["above","main","below"]){var i="botiga_"+c.currentBuilderType+"_row__"+r+"_"+c.currentBuilderType,n="#_customize-input-botiga_"+c.currentBuilderType+"_row__"+r+"_"+c.currentBuilderType+"_row";-1!==a.indexOf(i)&&(o="botiga-bhfb-"+r+"-row",t=d(n),c.currentRow=r)}if(""===o||""===t)return!1;c.addBuilderRowColumnsClass(s,o,e);let _=c.jsonDecode(t.val());if(e<_[c.currentDevice].length)for(;_[c.currentDevice].length>e;)_[c.currentDevice].pop();else if(e>_[c.currentDevice].length)for(;_[c.currentDevice].length