const b="optin",T="optout",g="allow",C="deny",j="yootheme:consent",N="yootheme_consent",X=30,y="data-category";function x(t,e){var n;(e.debug||e.state.invalidConsent)&&(e.element=(n=document.querySelector(t))==null?void 0:n.content.firstElementChild.cloneNode(!0),e.element&&document.body[e.banner_layout==="section-top"?"prepend":"append"](e.element)),document.addEventListener("click",s=>{let l=s.target.dataset.consentButton;["accept","reject"].includes(l)&&(e.setConsent(Object.fromEntries(e.getCategories().map(p=>[p,l==="accept"||p==="functional"?g:C]))),e.loadScriptTags(),e.saveState())})}function I(t){const e=window.document.cookie.split(";");t=`${t}=`;for(let n of e)if(n=n.trim(),n.startsWith(t))return n.substring(t.length);return""}function $(t,e,n=30){const s=new Date,l=window.location.protocol==="https:"?";secure":"";s.setTime(s.getTime()+n*24*60*60*1e3),document.cookie=`${t}=${e}${l};expires=${s.toGMTString()};path=/`}async function A(t){for(const e of t){const n=document.createRange().createContextualFragment(e.outerHTML).firstElementChild;n.removeAttribute("type"),n.removeAttribute(y);for(const s of["src","type"])e.dataset[s]&&(n[s]=e.dataset[s],delete n.dataset[s]);await P(n,()=>e.replaceWith(n))}}async function P(t,e){const n=t.src&&(!t.type||L(t.type));e(t),n&&await new Promise(s=>{t.onload=s(!0),t.onerror=s(!1)})}function L(t){return["text/javascript","module"].includes(t)}function R(t){const e={type:b,event_prefix:j,cookie_prefix:N,cookie_expiration:30,state:{},cookie:{},element:null,revision:null,categories:{},on:q,emit:W,extend:D,loadState:s,saveState:l,hasConsent:p,setConsent:h,changeConsent:r,getCategories:n,loadScriptTags:a};function n(){const o=[];for(const[i,u]of Object.entries(this.categories)){o.push(i);for(const c of u)o.push(c?`${i}.${c}`:i)}return o}function s(){var v;const{revision:o,categories:i,consentId:u,consentTimestamp:c,lastConsentTimestamp:f}=this.cookie=(v=O(I(this.cookie_prefix)))!=null?v:{},d=u&&typeof u=="string",_=this.revision===null||this.revision===o;return this.state=E({revision:o,categories:i,consentId:u,consentTimestamp:c,lastConsentTimestamp:f,invalidConsent:!d||!_||!i||!c||!f}),this.state.invalidConsent&&(this.state.categories={}),this}function l(){var d;const{consentId:o,categories:i,consentTimestamp:u,invalidConsent:c}=this.state;if(!c&&B(i,(d=this.cookie.categories)!=null?d:{}))return;const f=new Date().toISOString();this.cookie={revision:this.revision,categories:i,consentId:o!=null?o:F(),consentTimestamp:u!=null?u:f,lastConsentTimestamp:f},this.state=E({...this.cookie,invalidConsent:!1}),$(this.cookie_prefix,S(this.cookie))}function p(o){if(!this.type)return!0;const i=this.state.categories[o];return this.type===T&&!i?!0:i===g}function h(o,i){const u=[];typeof o=="string"?c.call(this,o,i):typeof o=="object"&&Object.entries(o).forEach(f=>c.call(this,...f)),u.length>0&&this.changeConsent(u);function c(f,d){d!==g&&d!==C||(this.state.categories[f]!==d&&u.push(f),this.state.categories[f]=d)}}function r(o){const i={},u={};for(const c of this.getCategories())i[c]=this.hasConsent(c);for(const c of o)u[c]=this.hasConsent(c);this.emit("change",{allConsents:i,changedConsents:u,...this})}async function a(){const o=[];for(const i of document.querySelectorAll(`script[${y}]`))i.getAttribute(y).split(/\s+/).some(f=>this.hasConsent(f))&&o.push(i);await A(o)}return e.extend(t).loadState()}function q(t,e){document.addEventListener(`${this.event_prefix}.${t}`,n=>e(n.detail,n))}function W(t,e,n){document.dispatchEvent(new CustomEvent(`${this.event_prefix}.${t}`,{detail:e,...n}))}function D(...t){return Object.assign(this,...t)}function B(t,e){return Object.keys(t).length===Object.keys(e).length&&Object.entries(t).every(([n,s])=>e[n]===s)}function E(t){return O(S(t))}function O(t){try{return JSON.parse(t)}catch{}}function S(t){return JSON.stringify(t)}function F(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function J(t,e){document.addEventListener("click",h=>{const r=h.target.closest("a,button");(r==null?void 0:r.hash)!==t&&(r==null?void 0:r.dataset.consentButton)!=="settings"||(h.preventDefault(),s(),p(),requestAnimationFrame(()=>n.dispatchEvent(new CustomEvent("toggle"))))});let n;function s(){var h;n||(n=document.body.appendChild((h=document.querySelector(t))==null?void 0:h.content.firstElementChild.cloneNode(!0)),n.addEventListener("change",r=>{var f;const{form:a}=r.target;if(!a)return;const{name:o,checked:i}=r.target,u=e.getCategories();if(!u.includes(o))return;const[c]=o.split(".",1);if(o===c)for(const d of u)d.startsWith(`${c}.`)&&a[d]&&(a[d].checked=i);else a[c]&&((f=a[c]).checked||(f.checked=Array.from(a.elements).some(d=>d.name.startsWith(`${c}.`)&&d.checked)))}),n.addEventListener("submit",r=>{const a=r.target;a&&(r.preventDefault(),e.setConsent(Object.fromEntries(e.getCategories().map(o=>{var i;return[o,(i=a[o])!=null&&i.checked?g:C]}))),l())}),n.addEventListener("click",r=>{let a=r.target.dataset.consentButton;["accept","reject"].includes(a)&&(e.setConsent(Object.fromEntries(e.getCategories().map(o=>[o,a==="accept"||o==="functional"?g:C]))),l())}))}function l(){e.loadScriptTags(),e.saveState(),e.element&&(e.element.hidden=!0)}function p(){var h,r;for(const a of(r=(h=n.querySelector("form"))==null?void 0:h.elements)!=null?r:[])e.getCategories().includes(a.name)&&(a.checked=e.hasConsent(a.name))}}function M(t,e){var n;window.wp_consent_type=e.type;for(const[s,l]of Object.entries(e.categories))for(const p of l)(n=t.services)==null||n.push({name:p,category:s});e.on("change",({changedConsents:s})=>{var l,p;for(const[h,r]of Object.entries(s)){const[a,o]=h.split(".");o?(l=window.wp_set_service_consent)==null||l.call(window,o,r):(p=window.wp_set_consent)==null||p.call(window,a,r?"allow":"deny")}})}const{consent_api:k,yootheme:w}=window,m=w.consent=R(w.consent);k&&M(k,m),m.on("init",t=>{x("#consent-banner",t),J("#consent-settings",t),t.loadScriptTags()}),m.type&&m.emit("init",m);