"use strict";(self.webpackChunk_roots_bud_sage_ootheme_v2=self.webpackChunk_roots_bud_sage_ootheme_v2||[]).push([[143],{"./styles/app.scss":function(){},"./scripts/app.js":function(){var e=e=>{window.requestAnimationFrame((async function t(){document.body?await e():window.requestAnimationFrame(t)}))};class t{constructor(){this._utmCookies()}_utmCookies(){this._getQueryVariable("utm_source")&&(this._createCookie(app.cookie_prefix+"utmz",this._getQueryVariable("utm_source")+"|"+this._getQueryVariable("utm_medium")+"|"+this._getQueryVariable("utm_term")+"|"+this._getQueryVariable("utm_campaign")+"|"+this._getQueryVariable("utm_content"),60),this._createCookie(app.cookie_prefix+"utm_url",window.location.href.split("?")[0],60)),0===document.referrer.indexOf(location.protocol+"//"+location.host)&&this._createCookie(app.cookie_prefix+"utm_referrer",document.referrer,60);let e=this._readCookie(app.cookie_prefix+"utmz");if(e){e=e.replaceAll("false","");const t=e.split("|")[0],r=e.split("|")[1],o=e.split("|")[2],n=e.split("|")[3],i=e.split("|")[4],a=this._readCookie(app.cookie_prefix+"utm_url"),s=this._readCookie(app.cookie_prefix+"utm_referrer");document.addEventListener("DOMContentLoaded",(function(){const e=document.querySelectorAll("input[name='utm_source']");for(let c=0;c<e.length;c++)document.querySelectorAll("input[name='utm_source']")[c].value=t,document.querySelectorAll("input[name='utm_medium']")[c].value=r,document.querySelectorAll("input[name='utm_term']")[c].value=o,document.querySelectorAll("input[name='utm_campaign']")[c].value=n,document.querySelectorAll("input[name='utm_content']")[c].value=i,document.querySelectorAll("input[name='utm_url']")[c].value=a,document.querySelectorAll("input[name='referrer']")[c].value=s}))}}_getQueryVariable(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var o=t[r].split("=");if(o[0]===e)return o[1]}return!1}_createCookie(e,t,r){var o="";if(r){var n=new Date;n.setTime(n.getTime()+24*r*60*60*1e3),o="; expires="+n.toGMTString()}document.cookie=e+"="+t+o+"; path=/"}_readCookie(e){for(var t=e+"=",r=document.cookie.split(";"),o=0;o<r.length;o++){for(var n=r[o];" "===n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return n.substring(t.length,n.length)}return null}_eraseCookie(e){this._createCookie(e,"",-1)}}class r{constructor(){this._header()}_header(){const e=document.querySelector("header.main-header"),t=e?.querySelector(".burger"),r=e?.querySelector(".site-header__main");if(t&&t.addEventListener("click",(function(e){e.preventDefault(),document.body.classList.toggle("menu-open")})),!r)return;const o=e.querySelector(".site-header__top");let n=0,i=!1;const a=()=>{const t=window.scrollY>n;e.classList.toggle("has-sticky-main",t),r.classList.toggle("is-sticky",t)},s=()=>{const t=(()=>{const e=document.querySelector("#wpadminbar");return e&&"fixed"===window.getComputedStyle(e).position?e.offsetHeight:0})(),i=e.getBoundingClientRect().top+window.scrollY;n=Math.max(0,i+(o?.offsetHeight||0)-t),e.style.setProperty("--site-header-main-height",`${r.offsetHeight}px`),r.style.setProperty("--site-header-sticky-top",`${t}px`),a()};s(),window.addEventListener("scroll",(()=>{i||(i=!0,window.requestAnimationFrame((()=>{a(),i=!1})))}),{passive:!0}),window.addEventListener("resize",s)}}function o(){document.querySelectorAll(".wp-block-testimonios").forEach((e=>{const t=e.querySelector("[data-testimonios-track]"),r=e.querySelector("[data-testimonios-prev]"),o=e.querySelector("[data-testimonios-next]");if(!t)return;const n=e=>{const r=t.querySelector(".testimonios__card"),o=r?r.getBoundingClientRect().width+24:t.clientWidth;t.scrollBy({left:e*o,behavior:"smooth"})};r?.addEventListener("click",(()=>n(-1))),o?.addEventListener("click",(()=>n(1)))})),document.addEventListener("click",(e=>{const t=e.target.closest("[data-video-modal]");if(!t)return;const r=t.getAttribute("href");r&&"#"!==r&&(e.preventDefault(),function(e){let t=document.querySelector(".video-modal");t||(t=document.createElement("div"),t.className="video-modal",t.innerHTML='\n\t\t\t<div class="video-modal__content">\n\t\t\t\t<button class="video-modal__close" aria-label="Cerrar video">&times;</button>\n\t\t\t\t<div class="video-modal__ratio"></div>\n\t\t\t</div>\n\t\t',document.body.appendChild(t),t.querySelector(".video-modal__close").addEventListener("click",n),t.addEventListener("click",(e=>{e.target===t&&n()})),document.addEventListener("keydown",(e=>{"Escape"===e.key&&t.classList.contains("is-open")&&n()})));const r=t.querySelector(".video-modal__ratio"),o=function(e){if(!e)return"";const t=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,r=e.match(t);if(r&&11===r[2].length)return`https://www.youtube-nocookie.com/embed/${r[2]}?autoplay=1&rel=0`;const o=/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/,n=e.match(o);return n&&n[1]?`https://player.vimeo.com/video/${n[1]}?autoplay=1`:e}(e);o.match(/\.(mp4|webm|ogg)($|\?)/i)?r.innerHTML=`<video src="${o}" controls autoplay></video>`:r.innerHTML=`<iframe src="${o}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`,requestAnimationFrame((()=>{t.classList.add("is-open"),document.body.style.overflow="hidden"}))}(r))}))}function n(){const e=document.querySelector(".video-modal");e&&(e.classList.remove("is-open"),document.body.style.overflow="",setTimeout((()=>{const t=e.querySelector(".video-modal__ratio");t&&(t.innerHTML="")}),300))}document.addEventListener("wpcf7invalid",(function(e){e.target.querySelector(".wpcf7-response-output").classList.add("alert","alert-danger")}),!1),document.addEventListener("wpcf7spam",(function(e){var t=e.target.querySelector(".wpcf7-response-output");t.classList.remove("alert-danger"),t.classList.add("alert","alert-warning")}),!1),document.addEventListener("wpcf7mailfailed",(function(e){var t=e.target.querySelector(".wpcf7-response-output");t.classList.remove("alert-danger"),t.classList.add("alert","alert-warning")}),!1),document.addEventListener("wpcf7mailsent",(function(e){var t=e.target,r=t.querySelector(".wpcf7-response-output");r.classList.remove("alert-danger","alert-warning"),r.classList.add("alert","alert-success"),t.querySelector("button.wpcf7-submit").disabled=!0}),!1),document.querySelectorAll(".wpcf7-submit").forEach((function(e){var t=document.createElement("div");t.classList.add("ajax-loader");var r=document.createElement("div");r.classList.add("spinner-border","spinner-border-sm"),r.setAttribute("role","status"),r.setAttribute("aria-hidden","true"),t.appendChild(r),e.insertBefore(t,e.firstChild)})),e((async()=>{new t,new r,document.querySelectorAll(".wp-block-faq").forEach((e=>{e.querySelectorAll(".faq__question").forEach((e=>{e.addEventListener("click",(()=>{const t=document.getElementById(e.getAttribute("aria-controls")),r="true"===e.getAttribute("aria-expanded");e.setAttribute("aria-expanded",String(!r)),t&&(t.hidden=r)}))}))})),o(),function(){const e=document.querySelector("#site-footer-newsletter-form");if(!e)return;const t=document.querySelector(".site-footer__newsletter-message"),r=e.querySelector('button[type="submit"]'),o=r?r.textContent:"";e.addEventListener("submit",(async n=>{n.preventDefault();const i=e.querySelector('input[name="newsletter_name"]')||e.querySelector('input[name="name"]'),a=e.querySelector('input[name="email"]'),s=e.querySelector('input[name="_newsletter_nonce"]'),c=i?i.value.trim():"",l=a?a.value.trim():"",u=s?s.value:"";if(c&&l){t&&(t.style.display="none",t.className="site-footer__newsletter-message",t.textContent=""),r&&(r.disabled=!0,r.textContent="Enviando...");try{const r=new FormData;r.append("action","subscribe_newsletter"),r.append("nonce",u),r.append("name",c),r.append("email",l);const o=window.app?.admin_ajax||"/wp-admin/admin-ajax.php",n=await fetch(o,{method:"POST",body:r}),i=await n.json();t&&(t.style.display="block",i.success?(t.classList.add("is-success"),t.textContent=i.data?.message||"\xa1Gracias por suscribirte!",e.reset()):(t.classList.add("is-error"),t.textContent=i.data?.message||"Ocurri\xf3 un error. Int\xe9ntalo de nuevo."))}catch(e){t&&(t.style.display="block",t.classList.add("is-error"),t.textContent="Error de conexi\xf3n. Por favor, int\xe9ntalo m\xe1s tarde.")}finally{r&&(r.disabled=!1,r.textContent=o)}}}))}()}))}},function(e){var t=function(t){return e(e.s=t)};t("./scripts/app.js"),t("./styles/app.scss")}])