File: /var/www/html/wp-content/plugins/wpseo-local/js/dist/wp-seo-local-settings-1580.js
(()=>{"use strict";class e{handleFormToggle(e,t){const s=this;null!==e&&null!==t&&t.addEventListener("change",(function(){if(this.checked)return s.toggleFormElements(e,"enable"),void e.classList.remove("wpseo-local-form-elements-disabled");s.toggleFormElements(e,"disable"),e.classList.add("wpseo-local-form-elements-disabled")}))}toggleFormElements(e,t){e&&e.querySelectorAll("input, select, textarea").forEach((e=>{"enable"===t?e.removeAttribute("disabled"):e.setAttribute("disabled","")}))}}class t{constructor(){this.utils=new e,this.wrapper=document.querySelector("#business-info-settings"),this.addressWrapper=document.querySelector("#non-shared-business-info"),this.sharedInfoToggle=document.querySelector("#multiple_locations_shared_business_info"),this.multipleLocationsToggle=document.querySelector("#use_multiple_locations"),this.handleSharedBusinessInfoToggle()}handleSharedBusinessInfoToggle(){this.utils.handleFormToggle(this.wrapper,this.sharedInfoToggle)}updateSharedBusinessInfo(){const e=this.multipleLocationsToggle.checked?"enable":"disable",t=this.sharedInfoToggle.checked?"enable":"disable";if("disable"===e||"enable"===t)return this.utils.toggleFormElements(this.wrapper,"enable"),this.wrapper.classList.remove("wpseo-local-form-elements-disabled"),void this.addressWrapper.classList.remove("wpseo-local-form-elements-disabled");this.utils.toggleFormElements(this.wrapper,"disable"),this.wrapper.classList.add("wpseo-local-form-elements-disabled"),this.addressWrapper.classList.add("wpseo-local-form-elements-disabled")}}class s{constructor({hideOpeningHours:t,useMultipleLocations:s,locationsAreSameOrganization:o,open247:i,useMultipleHours:n}){this.hideOpeningHours=t,this.useMultipleLocations=s,this.locationsAreSameOrganization=o,this.open247=i,this.useMultipleHours=n,this.updateOpeningHoursState=this.updateOpeningHoursState.bind(this),this.displayMultipleOpeningHours=this.displayMultipleOpeningHours.bind(this),this.handleDaily24hToggles=this.handleDaily24hToggles.bind(this),this.handleOpeningHoursOverride=this.handleOpeningHoursOverride.bind(this),this.utils=new e,this.handleDaily24hToggles(),this.automaticallySetToClosed(),this.handleSharedOpeningHoursToggle(),this.handleOpeningHoursOverride()}updateOpeningHoursState(){const e=document.querySelector("#opening-hours-settings"),t=document.querySelector("#opening-hours-time-settings"),s=document.querySelector("#opening-hours-time-settings-normal"),o=document.querySelector("#opening-hours-time-specification-wrap"),i=document.querySelector("#share-opening-hours-settings"),n=document.querySelector("#multiple_locations_shared_opening_hours");let l=!0,r=!0,a=!0,c=!0;if(this.hideOpeningHours.checked&&(l=!1,r=!1),this.useMultipleLocations.checked&&!this.locationsAreSameOrganization.checked&&(r=!1,c=!1),this.useMultipleLocations.checked||(c=!1),this.open247.checked&&(a=!1),this.displayOpeningHoursSettingsSection(e,l),this.displayOpeningHoursSettingsSection(t,r),this.displayOpeningHoursSettingsSection(o,a),this.displayOpeningHoursSettingsSection(i,c),s&&n){if(!this.useMultipleLocations.checked||n.checked)return this.utils.toggleFormElements(s,"enable"),void s.classList.remove("wpseo-local-form-elements-disabled");this.utils.toggleFormElements(s,"disable"),s.classList.add("wpseo-local-form-elements-disabled")}}displayOpeningHoursSettingsSection(e,t){e&&(e.style.display=t?"block":"none")}displayMultipleOpeningHours(){const e=document.querySelectorAll(".opening-hours-second"),t=document.querySelector(".opening-hours-second-description"),s=this.useMultipleHours.checked,o=e.length;for(let t=0;t<o;t++)s?e[t].classList.remove("hidden"):e[t].classList.add("hidden");this.displayOpeningHoursSettingsSection(t,s)}handleDaily24hToggles(){document.querySelectorAll(".wpseo_open_24h input[type='checkbox']").forEach((e=>{e.addEventListener("click",(()=>{e.closest(".opening-hours").querySelectorAll("select").forEach((t=>{t.disabled=e.checked}))}))}))}handleOpeningHoursOverride(){document.querySelectorAll(".wpseo-local-location-opening-hours-override input[type='checkbox'], #_wpseo_is_overridden_business_timezone").forEach((e=>{e.addEventListener("change",(()=>{let t=e.closest(".wpseo-local-toggle-enabled-state-wrapper"),s=t.querySelectorAll(".wpseo-local-toggleable-enabled-state, .switch-container input[type='checkbox']"),o=!e.checked;o?t.classList.add("wpseo-local-has-disabled-elements"):t.classList.remove("wpseo-local-has-disabled-elements"),s.forEach((e=>{e.disabled=o}))}))}))}replaceHourFormatForElements(e,t){for(const s of e){const e=s.cloneNode(!0);for(const s of e.options)s.hasAttribute("data-time-format-12-hours")&&(s.text="24h"!==t?s.dataset["timeFormat-12Hours"]:s.dataset["timeFormat-24Hours"]);e.selectedIndex=s.selectedIndex,s.replaceWith(e)}this.automaticallySetToClosed()}automaticallySetToClosed(){document.querySelectorAll(".opening-hours select").forEach((e=>{e.addEventListener("change",(()=>{if("closed"===e.value){let t=e.closest(".opening-hours").querySelectorAll("select");e.id.includes("_second_")&&(t=e.closest(".opening-hours").querySelectorAll("[id*='_second_']")),t.forEach((e=>{e.selectedIndex=0}))}}))}))}handleSharedOpeningHoursToggle(){const e=document.querySelector("#opening-hours-time-settings-normal"),t=document.querySelector("#multiple_locations_shared_opening_hours");this.utils.handleFormToggle(e,t)}}(new class{constructor(){this.internalTabLinks=document.querySelectorAll("[data-action='link-to-tab']"),this.useMultipleLocations=document.querySelector("#use_multiple_locations"),this.locationsAreSameOrganization=document.querySelector("#multiple_locations_same_organization"),this.hideOpeningHours=document.querySelector("#hide_opening_hours"),this.open247=document.querySelector("#open_247"),this.multipleOpeningHours=document.querySelector("#multiple_opening_hours"),this.timeFormatToggle=document.querySelector("#opening_hours_24h"),this.navigateToTab=this.navigateToTab.bind(this);const e={open247:this.open247,hideOpeningHours:this.hideOpeningHours,useMultipleHours:this.multipleOpeningHours,useMultipleLocations:this.useMultipleLocations,locationsAreSameOrganization:this.locationsAreSameOrganization};this.businessInfo=new t,this.openingHours=new s(e)}addEventListeners(){this.internalTabLinks.forEach((e=>{e.addEventListener("click",this.navigateToTab)})),this.open247.addEventListener("change",this.openingHours.updateOpeningHoursState),this.hideOpeningHours.addEventListener("change",this.openingHours.updateOpeningHoursState),this.useMultipleLocations.addEventListener("change",(()=>{this.openingHours.updateOpeningHoursState(),this.businessInfo.updateSharedBusinessInfo()})),this.locationsAreSameOrganization.addEventListener("change",(()=>{this.openingHours.updateOpeningHoursState(),this.businessInfo.updateSharedBusinessInfo()})),this.multipleOpeningHours.addEventListener("change",(()=>this.openingHours.displayMultipleOpeningHours())),this.timeFormatToggle.addEventListener("change",(()=>this.openingHours.replaceHourFormatForElements(document.querySelectorAll(".openinghours-wrapper select"),this.detectTimeFormat())))}detectTimeFormat(){const e=document.querySelector("#opening_hours_24h");return e&&e.checked?"24h":"12h"}navigateToTab(e){const t=e.target.dataset.tabId+"-tab",s=document.getElementById(t);null!==s&&s.click()}}).addEventListeners()})();