!function(){"use strict";let e;const t=function(e){return"json"===this.responseType||!0===this.json?e({message:this.statusText},!1):"text"===this.responseType?e(this.statusText):void console.error(this)},i=function(e){if(0===this.status||this.status>=200&&this.status<300||304===this.status){if("json"===this.responseType)return e(this.response.data,this.response.success);if("text"===this.responseType)return e(this.responseText);if(!0===this.json){const t=JSON.parse(this.response);return e(t.data,t.success)}}else t.bind(this,e)},s=e=>{let t=new FormData;const i=Object.prototype.toString.call(e);return"[object FormData]"===i&&(t=e),"[object HTMLFormElement]"===i&&(t=new FormData(e)),"[object Object]"===i&&Object.keys(e).forEach((i=>t.append(i,e[i]))),t.append("action",GLSR.action),t.append("_ajax_request",!0),t},n=s=>{e=new XMLHttpRequest,e.addEventListener("load",i.bind(e,s)),e.addEventListener("error",t.bind(e,s))},r=t=>{(t=t||{})["X-Requested-With"]="XMLHttpRequest";for(let i in t)t.hasOwnProperty(i)&&e.setRequestHeader(i,t[i])};var o={data:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};t._action=e;for(let e of Object.keys(t))i[`${GLSR.nameprefix}[${e}]`]=t[e];return i},get:(t,i,s)=>{n(i),e.open("GET",t,!0),e.responseType="text",r(s),e.send()},post:(t,i,o)=>{n(i),e.open("POST",GLSR.ajaxurl,!0),e.responseType="json",e.json=!0,r(o),e.send(s(t))}};const a={},l=function(e,t){const i=a[e]||[],s=[];t&&[].forEach.call(i,(e=>{t!==e.fn&&t!==e.fn.once&&s.push(e)})),s.length?a[e]=s:delete a[e]},c=function(e,t,i){(a[e]||(a[e]=[])).push({fn:t,context:i})};var d={events:a,off:l,on:c,once:function(e,t,i){const s=function(){l(e,s),t.apply(i,arguments)};s.once=t,c(e,s,i)},trigger:function(e){const t=[].slice.call(arguments,1),i=(a[e]||[]).slice();[].forEach.call(i,(e=>e.fn.apply(e.context,t)))}};const h="function",u="isNode",p=(e,t)=>typeof e===t,f=(e,t)=>{null!==t&&(Array.isArray(t)?t.map((t=>f(e,t))):(v[u](t)||(t=document.createTextNode(t)),e.appendChild(t)))};function v(e,t){let i,s,n=arguments,r=1;if(!v.isElement(e)){let t=~["svg","line","path","rect","mask","radialGradient","stop"].indexOf(e)?"2000/svg":"1999/xhtml";e=document.createElementNS(`http://www.w3.org/${t}`,e)}if("string"==typeof t&&(t={class:t}),p(t,"object")&&!v[u](t)&&!Array.isArray(t))for(i in r++,t)s=t[i],i=v.attrMap[i]||i,p(i,h)?i(e,s):p(s,h)?e[i]=s:e.setAttribute(i,s);for(;re instanceof Element,v[u]=e=>e instanceof Node;const g="glsr-read-more",m=".glsr-hidden-text",w=".glsr-tag-value";class _{constructor(e){this.events={click:this._onClick.bind(this)},(e||document).querySelectorAll(m).forEach((e=>this.init(e)))}init(e){const t=this._insertLink(e);t&&("expand"===e.dataset.trigger&&(t.dataset.text=e.dataset.showLess,t.removeEventListener("click",this.events.click),t.addEventListener("click",this.events.click)),"modal"===e.dataset.trigger&&(t.dataset.glsrTrigger="glsr-modal-review"))}_insertLink(e){let t=e.parentElement.querySelector("."+g);t&&t.parentElement.removeChild(t);const i=v("a",{href:"#"},e.dataset.showMore),s=v("span",{class:g},i);return e.appendChild(s).querySelector("a")}_onClick(e){e.preventDefault();const t=e.currentTarget,i=t.parentElement,s=t.closest(w),n=s.querySelector(m),r=t.dataset.text,o=t.innerText;t.dataset.text=o,t.innerText=r,t.removeEventListener("click",this.events.click),"false"===s.dataset.expanded?(s.querySelector("p:last-of-type").appendChild(i),s.dataset.expanded="true"):(n.appendChild(i),s.dataset.expanded="false"),t.addEventListener("click",this.events.click),"false"===s.dataset.expanded&&t.focus()}}var y=e=>({el:e,loading:()=>{"false"===e.getAttribute("aria-busy")&&(e.setAttribute("aria-busy",!0),e.setAttribute("disabled",""),e.dataset.text=e.innerText,e.innerHTML=''+(e.dataset.loading||e.dataset.text))},loaded:()=>{"true"===e.getAttribute("aria-busy")&&(e.innerHTML=e.dataset.text,e.setAttribute("aria-busy",!1),e.removeAttribute("data-text"),e.removeAttribute("disabled"))}});class b{constructor(e){this.Form=e,this.captcha={friendlycaptcha:"friendlyChallenge",hcaptcha:"hcaptcha",recaptcha_v2_invisible:"grecaptcha",recaptcha_v3:"grecaptcha",turnstile:"turnstile"}[GLSR.captcha.type],this.captchaEl=!1,this.containerEl=this.Form.form.querySelector(".glsr-captcha-holder"),this.loaded=!1,this.token=null,this.widget=-1,this.fixCompatibility()}execute(){if(this.captchaEl&&this.isWidgetLoaded())try{this["execute_"+GLSR.captcha.type]()}catch(e){console.error(e),this.Form.submitForm()}else this.Form.submitForm()}execute_friendlycaptcha(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):this.token?this.Form.submitForm():setTimeout((()=>this.execute_friendlycaptcha()),100)}execute_hcaptcha(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):this.token?this._submitFormWithToken(this.token):window[this.captcha].execute(this.widget,{action:"submit_review",async:!0}).then((e=>{let{response:t}=e;this._submitFormWithToken(t)})).catch((e=>{console.error(e)}))}execute_recaptcha_v2_invisible(){this.execute_recaptcha_v3()}execute_recaptcha_v3(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):window[this.captcha].execute(this.widget,{action:"submit_review"})}execute_turnstile(){let e=window[this.captcha].getResponse(this.widget);1==+this.captchaEl.dataset.error||this.token||void 0===e?this.Form.submitForm():setTimeout((()=>this.execute_turnstile()),100)}fixCompatibility(){"hcaptcha"===GLSR.captcha.type&&void 0!==window.hCaptchaOnLoad&&document.body.click()}isLoaded(e){for(let t=0;t{if(void 0===e||this.isLoaded(e))t();else{const s=document.createElement("script");s.onload=t,s.onerror=i,s.src=e,s.type="text/javascript",GLSR.captcha.urls.length>1&&(-1!==e.indexOf("module")?s.type="module":s.setAttribute("nomodule","")),s.setAttribute("defer",""),document.head.append(s)}}))}render(){if(this.Form.form.onsubmit=null,this.containerEl&&!this.isWidgetLoaded())if(void 0===window[this.captcha])this.loaded?setTimeout((()=>this.render()),50):this.load(GLSR.captcha.urls[0]).then((()=>{this.load(GLSR.captcha.urls[1])})).then((()=>this.loaded=!0)).then((()=>setTimeout((()=>this.render()),100))).catch((e=>console.error(e)));else{this.reset(),this._buildContainer();try{this["render_"+GLSR.captcha.type]()}catch(e){this.captchaEl.dataset.error=1,console.error(e)}}}render_friendlycaptcha(){this.widget=new window[this.captcha].WidgetInstance(this.captchaEl,{doneCallback:e=>this.token=e,errorCallback:e=>{console.error(e),this.captchaEl.dataset.error=1}})}render_hcaptcha(){var e;void 0!==(null===(e=window[this.captcha])||void 0===e?void 0:e.render)?this.widget=window[this.captcha].render(this.captchaEl,{callback:e=>this.token=e,"chalexpired-callback":()=>this.reset(),"close-callback":()=>this.Form.button.loaded(),"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset()}):setTimeout((()=>this.render_hcaptcha()),100)}render_recaptcha_v2_invisible(){this.render_recaptcha_v3()}render_recaptcha_v3(){var e;void 0!==(null===(e=window[this.captcha])||void 0===e?void 0:e.render)?this.widget=window[this.captcha].render(this.captchaEl,{callback:e=>this._submitFormWithToken(e),"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset(),isolated:!0}):setTimeout((()=>this.render_recaptcha_v3()),100)}render_turnstile(){this.widget=window[this.captcha].render(this.captchaEl,{action:"submit_review",callback:e=>this.token=e,"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset(),sitekey:GLSR.captcha.sitekey,theme:GLSR.captcha.theme})}reset(){this.token=null,this.captchaEl&&(this.captchaEl.dataset.error=0),this.isWidgetLoaded()&&("friendlycaptcha"===GLSR.captcha.type?this.widget.reset():window[this.captcha].reset(this.widget))}_buildContainer(){"friendlycaptcha"===GLSR.captcha.type&&this.isWidgetLoaded()&&this.widget.destroy(),Array.from(this.containerEl.getElementsByClassName(GLSR.captcha.class)).forEach((e=>e.remove())),this.captchaEl=v("div",{class:GLSR.captcha.class,"data-badge":GLSR.captcha.badge,"data-lang":GLSR.captcha.language,"data-isolated":!0,"data-sitekey":GLSR.captcha.sitekey,"data-size":GLSR.captcha.size,"data-theme":GLSR.captcha.theme}),this.containerEl.appendChild(this.captchaEl)}_submitFormWithToken(e){["frc-captcha-solution","g-recaptcha-response","h-captcha-response"].forEach((t=>{this.Form.form[t]&&e&&(this.Form.form[t].value=e)})),this.Form.submitForm()}}const E=(e,t,i)=>{e&&t.split(" ").forEach((t=>{e.classList[i?"add":"remove"](t)}))},L=e=>"."+e.trim().split(" ").join("."),S=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,i=null;return function(){clearTimeout(i);for(var s=arguments.length,n=new Array(s),r=0;r{try{return[null,JSON.parse(e)]}catch(t){return[t,e]}},k={contains:(e,t)=>e.includes(t),equals:(e,t)=>{if(Array.isArray(e)){let i=t.split(/\s*(?:,|$)\s*/);return e.sort().toString()===i.sort().toString()}return A(t)?R(e)===+t:e===t},greater:(e,t)=>!!A(t)&&R(e)>+t,less:(e,t)=>!!A(t)&&R(e)<+t,not:(e,t)=>!k.equals(e,t)},T=e=>String(e.getAttribute("type")||e.nodeName).toLowerCase(),R=e=>isNaN(e)?e.length:+e,A=e=>!isNaN(parseInt(e));class F{constructor(e){this.config=GLSR.validationconfig,this.elements=Array.from(e.form.elements),this.event=this.onChange.bind(this),this.Form=e}init(){this.eventListeners("add"),this.elements.forEach((e=>e.conditions={criteria:"always",observes:[],triggers:[]})),this._setConditionObserves(),this._setConditionTriggers()}destroy(){this.eventListeners("remove"),this.elements.forEach((e=>delete e.conditions))}eventListeners(e){this.elements.forEach((t=>t[e+"EventListener"](this.eventName(t),this.event)))}eventName(e){return["radio","checkbox","select"].includes(T(e))?"change":"input"}onChange(e){e.currentTarget.conditions.triggers.forEach((e=>{let t=[];e.conditions.observes.forEach((e=>t.push(this.test(e)))),t=t.filter((e=>e));const i=t.length===e.conditions.observes.length,s=t.length&&"any"===e.conditions.criteria,n=e.closest(L(this.config.field));i||s?(n.classList.remove(this.config.field_hidden),this.Form.validation.initField(e)):(e.validation&&this.Form.validation.destroyField(e.validation),this.resetValue(e),n.classList.add(this.config.field_hidden))}))}resetValue(e){const t=T(e);if("select"===t)Array.from(e.options).forEach((e=>e.selected=e.defaultSelected));else if(["checkbox","radio"].includes(t)){let t=this.Form.form.elements[e.name];Array.from(t.length?t:[t]).forEach((e=>e.checked=e.defaultChecked))}else e.value=e.defaultValue||"";e.dispatchEvent(new Event(this.eventName(e)))}test(e){return!k.hasOwnProperty(e.operator)||k[e.operator](this.value(e.el),e.value)}value(e){const t=e.getAttribute("name"),i=T(e),s=this.Form.form.elements[t];return"radio"===i?s.value:["checkbox","select"].includes(i)?Array.from(s.length?s:[s]).filter((e=>e["checkbox"===i?"checked":"selected"])).map((e=>e.value)):new String(e.value)}_setConditionObserves(){this.elements.filter((e=>e.dataset.conditions)).forEach((e=>{var t;let[i,s]=x(e.dataset.conditions);null===i&&null!=s&&null!==(t=s.conditions)&&void 0!==t&&t.length&&(s.conditions.forEach((t=>{const i=this.elements.filter((e=>e.closest(`[data-field="${t.name}"]`))).shift();i&&e.conditions.observes.push({el:i,...t})})),e.conditions.observes.length&&(e.conditions.criteria=s.criteria))}))}_setConditionTriggers(){this.elements.forEach((e=>{this.elements.filter((e=>e.dataset.conditions)).forEach((t=>{t.conditions.observes.forEach((i=>{i.el.getAttribute("name")===e.getAttribute("name")&&e.conditions.triggers.push(t)}))}))}))}}function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function N(e,t,i){return t&&function(e,t){for(var i=0;i0&&t.push({index:e.index,text:e.text,value:i})})),t.sort((function(e,t){return e.value-t.value}))}(t),this.widgetEl=null,this.el.widget&&this.el.widget.destroy(),s=this.values.length,n=1,r=this.props.maxStars,/^\d+$/.test(s)&&n<=s&&s<=r?this.build():this.destroy()}return N(e,[{key:"build",value:function(){this.destroy(),this.buildWidget(),this.selectValue(this.indexSelected=this.selected(),!1),this.handleEvents("add"),this.el.widget=this}},{key:"buildWidget",value:function(){var e=this,t=null,i=null;this.props.prebuilt&&(t=this.el.parentNode,i=t.querySelector("."+this.props.classNames.base+"--stars")),null===i&&((t=P(this.el,!1,{class:this.props.classNames.base})).appendChild(this.el),i=P(this.el,!0,{class:this.props.classNames.base+"--stars"}),this.values.forEach((function(t,s){var n=M({"data-index":s,"data-value":t.value});"function"==typeof e.props.stars&&e.props.stars.call(e,n,t,s),[].forEach.call(n.children,(function(e){return e.style.pointerEvents="none"})),i.innerHTML+=n.outerHTML}))),t.dataset.starRating="",t.classList.add(this.props.classNames.base+"--"+this.direction),this.props.tooltip&&i.setAttribute("role","tooltip"),this.widgetEl=i}},{key:"changeIndexTo",value:function(e,t){var i=this;if(this.indexActive!==e||t){if([].forEach.call(this.widgetEl.children,(function(t,s){C(t,s<=e,i.props.classNames.active),C(t,s===i.indexSelected,i.props.classNames.selected)})),this.widgetEl.setAttribute("data-rating",e+1),"function"==typeof this.props.stars||this.props.prebuilt||(this.widgetEl.classList.remove("s"+10*(this.indexActive+1)),this.widgetEl.classList.add("s"+10*(e+1))),this.props.tooltip){var s,n=e<0?this.props.tooltip:null===(s=this.values[e])||void 0===s?void 0:s.text;this.widgetEl.setAttribute("aria-label",n)}this.indexActive=e}this.ticking=!1}},{key:"destroy",value:function(){this.indexActive=null,this.indexSelected=this.selected();var e=this.el.parentNode;e.classList.contains(this.props.classNames.base)&&(this.props.prebuilt?(this.widgetEl=e.querySelector("."+this.props.classNames.base+"--stars"),e.classList.remove(this.props.classNames.base+"--"+this.direction),delete e.dataset.starRating):e.parentNode.replaceChild(this.el,e),this.handleEvents("remove")),delete this.el.widget}},{key:"eventListener",value:function(e,t,i,s){var n=this;i.forEach((function(i){return e[t+"EventListener"](i,n.events[i],s||!1)}))}},{key:"handleEvents",value:function(e){var t=this.el.closest("form");t&&"FORM"===t.tagName&&this.eventListener(t,e,["reset"]),this.eventListener(this.el,e,["change"]),"add"===e&&this.el.disabled||(this.eventListener(this.el,e,["keydown"]),this.eventListener(this.widgetEl,e,["mousedown","mouseleave","mousemove","touchend","touchmove"],!1))}},{key:"indexFromEvent",value:function(e){var t,i,s=(null===(t=e.touches)||void 0===t?void 0:t[0])||(null===(i=e.changedTouches)||void 0===i?void 0:i[0])||e,n=document.elementFromPoint(s.clientX,s.clientY);return n.parentNode===this.widgetEl?[].slice.call(n.parentNode.children).indexOf(n):this.indexActive}},{key:"onChange",value:function(){this.changeIndexTo(this.selected(),!0)}},{key:"onKeyDown",value:function(e){var t=e.key.slice(5);if(~["Left","Right"].indexOf(t)){e.preventDefault();var i="Left"===t?-1:1;"rtl"===this.direction&&(i*=-1);var s=this.values.length-1,n=Math.min(Math.max(this.selected()+i,-1),s);this.selectValue(n,!0)}}},{key:"onPointerDown",value:function(e){e.preventDefault();var t=this.indexFromEvent(e);this.props.clearable&&t===this.indexSelected&&(t=-1),this.selectValue(t,!0)}},{key:"onPointerLeave",value:function(e){var t=this;e.preventDefault(),cancelAnimationFrame(this.tick),requestAnimationFrame((function(){return t.changeIndexTo(t.indexSelected)}))}},{key:"onPointerMove",value:function(e){var t=this;e.preventDefault(),this.ticking||(this.tick=requestAnimationFrame((function(){return t.changeIndexTo(t.indexFromEvent(e))})),this.ticking=!0)}},{key:"onReset",value:function(){var e,t=this.valueIndex(null===(e=this.el.querySelector("[selected]"))||void 0===e?void 0:e.value);this.selectValue(t||-1,!1)}},{key:"selected",value:function(){return this.valueIndex(this.el.value)}},{key:"selectValue",value:function(e,t){var i;this.el.value=(null===(i=this.values[e])||void 0===i?void 0:i.value)||"",this.indexSelected=this.selected(),!1===t?this.changeIndexTo(this.selected(),!0):this.el.dispatchEvent(new Event("change"))}},{key:"valueIndex",value:function(e){return this.values.findIndex((function(t){return t.value===+e}))}}]),e}(),D=function(){function e(t,i){G(this,e),this.destroy=this.destroy.bind(this),this.props=i,this.rebuild=this.rebuild.bind(this),this.selector=t,this.widgets=[],this.build()}return N(e,[{key:"build",value:function(){var e=this;this.queryElements(this.selector).forEach((function(t){var i=j(O,e.props,JSON.parse(t.getAttribute("data-options")));"SELECT"!==t.tagName||t.widget||(!i.prebuilt&&t.parentNode.classList.contains(i.classNames.base)&&e.unwrap(t),e.widgets.push(new H(t,i)))}))}},{key:"destroy",value:function(){this.widgets.forEach((function(e){return e.destroy()})),this.widgets=[]}},{key:"queryElements",value:function(e){return"HTMLSelectElement"===q(e)?[e]:"NodeList"===q(e)?[].slice.call(e):"String"===q(e)?[].slice.call(document.querySelectorAll(e)):[]}},{key:"rebuild",value:function(){this.destroy(),this.build()}},{key:"unwrap",value:function(e){var t=e.parentNode,i=t.parentNode;i.insertBefore(e,t),i.removeChild(t)}}]),e}();const V={classNames:{base:"glsr-star-rating"},clearable:!1,tooltip:!1};const I=["required","max","maxlength","min","minlength","pattern"],W=e=>{const t=e.getAttribute("name");return e.validation.form.querySelectorAll(`input[name="${t}"]:checked`).length},$={email:{fn:function(e){return!e||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}},max:{fn:function(e,t){return!e||("checkbox"===this.type?W(this)<=parseInt(t):parseFloat(e)<=parseFloat(t))}},maxlength:{fn:function(e,t){return!e||e.length<=parseInt(t)}},min:{fn:function(e,t){return!e||("checkbox"===this.type?W(this)>=parseInt(t):parseFloat(e)>=parseFloat(t))}},minlength:{fn:function(e,t){return!e||e.length>=parseInt(t)}},number:{fn:function(e){return!e||!isNaN(parseFloat(e))},priority:2},pattern:{fn:function(e,t){let i=t.match(new RegExp("^/(.*?)/([gimy]*)$"));return!e||new RegExp(i[1],i[2]).test(e)}},required:{fn:function(e){return~["checkbox","radio"].indexOf(this.type)?W(this):null!=e&&String(e).replace(/\s/g,"").length>0},priority:99,halt:!0},tel:{fn:function(e){let t=e.replace(/[^0-9]/g,"").length;return!e||4<=t&&15>=t&&new RegExp("^[+]?[\\d\\s()-]*$").test(e)}},url:{fn:function(e){return!e||new RegExp("^(https?)://([\\p{L}\\p{N}\\p{S}\\-_.])+(.?([\\p{L}\\p{N}]|xn--[\\p{L}\\p{N}\\-]+)+.?)(:[0-9]+)?(?:/(?:[\\p{L}\\p{N}\\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*(?:\\?(?:[\\p{L}\\p{N}\\-._~!$&'\\[\\]()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?(?:#(?:[\\p{L}\\p{N}\\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?$","iu").test(e)}}};class B{constructor(e){this.config=GLSR.validationconfig,this.event=this._onChange.bind(this),this.fields=[],this.form=e,this.form.setAttribute("novalidate",""),this.strings=GLSR.validationstrings}destroy(){for(;this.fields.length;)this.destroyField(this.fields[0])}destroyField(e){this.resetField(e),this._eventListener("remove",e.input),delete e.input.validation,this.fields=this.fields.filter((t=>t.input!==e.input))}init(){this.form.querySelectorAll("input:not([type=hidden]):not([type=submit]), select, textarea, [data-glsr-validate]").forEach((e=>this.initField(e)))}initField(e){if(this.fields.find((t=>t.input.name===e.name&&"radio"!==e.type&&!e.name.endsWith("[]"))))return;const t=e.closest(L(this.config.field));null!=t&&t.offsetParent&&this.fields.push(this._initField(e))}reset(){this.fields.forEach((e=>this.resetField(e)))}resetField(e){let t=e.input.closest(L(this.config.field));E(e.input,this.config.input_error,!1),E(e.input,this.config.input_valid,!1),t&&(E(t,this.config.field_error,!1),E(t,this.config.field_valid,!1)),e.errors=[]}setErrors(e,t){e.hasOwnProperty("validation")||this._initField(e),e.validation.errors=t}setInvalid(e){this.toggleError(e,!0)}setValid(e){this.toggleError(e,!1)}toggleError(e,t){let i=e.input.closest(L(this.config.field));if(E(e.input,this.config.input_error,t),E(e.input,this.config.input_valid,!t),i){E(i,this.config.field_error,t),E(i,this.config.field_valid,!t);let s=i.querySelector(L(this.config.field_message));s&&(s.innerHTML=t?e.errors.join("
"):"",s.style.display=t?"":"none")}}validate(e){let t=!0,i=this.fields;return e instanceof HTMLElement&&e.hasOwnProperty("validation")&&(i=[e.validation]),i.forEach((e=>{this._validateField(e)?this.toggleError(e,!1):(this.toggleError(e,!0),t=!1)})),t}_addValidators(e,t,i){[].forEach.call(e,(e=>{let s=e.name.replace("data-","");~I.indexOf(s)?this._addValidatorToField(t,i,s,e.value):"type"===e.name&&this._addValidatorToField(t,i,e.value)}))}_addValidatorToField(e,t,i,s){if($.hasOwnProperty(i)&&($[i].name=i,e.push($[i]),s)){let e="pattern"===i?[s]:s.split(",");e.unshift(null),t[i]=e}}_eventListener(e,t){const i=t.getAttribute("type")||t.nodeName,s=~["radio","checkbox","SELECT"].indexOf(i)?"change":"input";t[e+"EventListener"](s,this.event)}_onChange(e){this.validate(e.currentTarget)}_initField(e){let t={},i=[];return null!==e.offsetParent&&(this._addValidators(e.attributes,i,t),this._sortValidators(i),this._eventListener("add",e)),e.validation={form:this.form,input:e,params:t,validate:()=>this.validate(e),validators:i}}_sortValidators(e){e.sort(((e,t)=>(t.priority||1)-(e.priority||1)))}_validateField(e){let t=[],i=!0;for(let s in e.validators){if(!e.validators.hasOwnProperty(s))continue;let n=e.validators[s],r=e.params[n.name]?e.params[n.name]:[];if(r[0]=e.input.value,!n.fn.apply(e.input,r)){i=!1;let e=this.strings[n.name];if(t.push(e.replace(/(\%s)/g,r[1])),!0===n.halt)break}}return e.errors=t,i}}class Y{constructor(e,t){var i,s;this.button=y(t),this.config=GLSR.validationconfig,this.events={reset:this._onReset.bind(this),submit:this._onSubmit.bind(this)},this.form=e,this.isActive=!1,this.stars=(()=>{let e=null;const t=()=>!!e&&(e.rebuild(),!0);return{init:function(i){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t()||(e=new D(i,Object.assign({},V,s))),e},destroy:()=>!!e&&(e.destroy(),!0),rebuild:t}})(),this.strings=GLSR.validationstrings,this.captcha=new b(this),this.conditions=new F(this),this.validation=new B(e),this.reviewsEl=document.getElementById(null===(i=e.closest(".glsr"))||void 0===i||null===(s=i.dataset)||void 0===s?void 0:s.reviews_id)}destroy(){this._destroyForm(),this.stars.destroy(),this.captcha.reset(),this.isActive=!1}init(){this.isActive||(this._initForm(),this.stars.init(this.form.querySelectorAll(".glsr-field-rating select"),GLSR.starsconfig),this.captcha.render(),this.isActive=!0)}submitForm(){this.button.loading(),GLSR.ajax.post(this._data(),this._handleResponse.bind(this))}_data(){const e=new FormData(this.form);if(this.reviewsEl&&this.reviewsEl.classList.contains("glsr"))try{const t=JSON.parse(JSON.stringify(this.reviewsEl.dataset));for(let i of Object.keys(t)){let s;try{s=JSON.parse(t[i])}catch(e){s=t[i]}e.append(`${GLSR.nameprefix}[_reviews_atts][${i}]`,s)}e.append([`${GLSR.nameprefix}[_pagination_atts][page]`],1),e.append([`${GLSR.nameprefix}[_pagination_atts][url]`],location.href)}catch(e){console.error(e)}return e}_destroyForm(){this.form.removeEventListener("reset",this.events.reset),this.form.removeEventListener("submit",this.events.submit),this._resetErrors(),this.conditions.destroy(),this.validation.destroy()}_handleResponse(e,t){const i=!0===t;if(this.captcha.reset(),i&&this.form.reset(),this._showFieldErrors(e.errors),this._showResults(e.message,i),this.button.loaded(),GLSR.Event.trigger("site-reviews/form/handle",e,this.form),i){if(e.redirect&&""!==e.redirect)return void(window.location=e.redirect);if(this.reviewsEl&&e.reviews){if(this.reviewsEl.innerHTML=e.reviews,GLSR.urlparameter){let e=new URL(location.href);e.searchParams.delete(GLSR.urlparameter),window.history.replaceState({},"",e.toString())}GLSR.Event.trigger("site-reviews/pagination/init")}}}_initForm(){this._destroyForm(),this.form.addEventListener("reset",this.events.reset),this.form.addEventListener("submit",this.events.submit),this.conditions.init(),this.validation.init()}_onReset(e){this.conditions.destroy(),this.conditions.init()}_onSubmit(e){if(!this.validation.validate())return e.preventDefault(),void this._showResults(this.strings.errors,!1);e.preventDefault(),this._resetErrors(),this.button.loading(),this.captcha.execute()}_resetErrors(){E(this.form,this.config.form_error,!1),this._showResults("",null),this.validation.reset()}_showFieldErrors(e){if(e)for(let t in e){if(!e.hasOwnProperty(t))continue;const i=GLSR.nameprefix?GLSR.nameprefix+"["+t+"]":t,s=this.form.querySelector('[name="'+i+'"]');s&&(this.validation.setErrors(s,e[t]),this.validation.toggleError(s.validation,"add"))}}_showResults(e,t){const i=this.form.querySelector(L(this.config.form_message));null!==i&&(E(this.form,this.config.form_error,!1===t),E(i,this.config.form_message_failed,!1===t),E(i,this.config.form_message_success,!0===t),i.innerHTML=e)}}var J=function(){return"undefined"==typeof window},K=function(e){e=e||navigator.userAgent;var t=/(iPad).*OS\s([\d_]+)/.test(e);return{ios:!t&&/(iPhone\sOS)\s([\d_]+)/.test(e)||t,android:/(Android);?[\s/]+([\d.]+)?/.test(e)}};function X(e){return!e&&(null!==e&&("production"!==process.env.NODE_ENV&&("test"!==process.env.NODE_ENV&&console.warn("If scrolling is also required in the floating layer, the target element must be provided."),!0)))}function U(){return"__BSL_PREVENT_DEFAULT__"in window||(window.__BSL_PREVENT_DEFAULT__=function(e){e.cancelable&&e.preventDefault()}),window.__BSL_PREVENT_DEFAULT__}var z={lockedNum:0,lockedElements:[],unLockCallback:null,documentListenerAdded:!1,initialClientPos:{clientX:0,clientY:0}};function Q(e){if(J())return z;if(!(null==e?void 0:e.useGlobalLockState))return Q.lockState;var t="__BSL_LOCK_STATE__"in window?Object.assign(Object.assign({},z),window.__BSL_LOCK_STATE__):z;return window.__BSL_LOCK_STATE__=t,t}Q.lockState=z;var Z=function(e){if(J())return!1;if(!e)throw new Error("options must be provided");var t=!1,i={get passive(){t=!0}},s=function(){},n="__TUA_BSL_TEST_PASSIVE__";window.addEventListener(n,s,i),window.removeEventListener(n,s,i);var r=e.capture;return t?e:void 0!==r&&r}({passive:!1});function ee(e,t){if(!J()){X(e);var i,s,n,r,o,a=Q(t);if(K().ios){if(e)(Array.isArray(e)?e:[e]).forEach((function(e){e&&-1===a.lockedElements.indexOf(e)&&(e.ontouchstart=function(e){var t=e.targetTouches[0],i=t.clientX,s=t.clientY;a.initialClientPos={clientX:i,clientY:s}},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t,i){if(t){var s=t.scrollTop,n=t.scrollLeft,r=t.scrollWidth,o=t.scrollHeight,a=t.clientWidth,l=t.clientHeight,c=e.targetTouches[0].clientX-i.clientX,d=e.targetTouches[0].clientY-i.clientY,h=Math.abs(d)>Math.abs(c);if(h&&(d>0&&0===s||d<0&&s+l+1>=o)||!h&&(c>0&&0===n||c<0&&n+a+1>=r))return U()(e)}e.stopPropagation()}(t,e,a.initialClientPos)},a.lockedElements.push(e))}));a.documentListenerAdded||(document.addEventListener("touchmove",U(),Z),a.documentListenerAdded=!0)}else a.lockedNum<=0&&(a.unLockCallback=K().android?(i=document.documentElement,s=document.body,n=i.scrollTop||s.scrollTop,r=Object.assign({},i.style),o=Object.assign({},s.style),i.style.height="100%",i.style.overflow="hidden",s.style.top="-".concat(n,"px"),s.style.width="100%",s.style.height="auto",s.style.position="fixed",s.style.overflow="hidden",function(){i.style.height=r.height||"",i.style.overflow=r.overflow||"",["top","width","height","overflow","position"].forEach((function(e){s.style[e]=o[e]||""})),"scrollBehavior"in document.documentElement.style?window.scrollTo({top:n,behavior:"instant"}):window.scrollTo(0,n)}):function(){var e=document.documentElement,t=Object.assign({},e.style),i=window.innerWidth-e.clientWidth,s=parseInt(window.getComputedStyle(e).paddingRight,10);return e.style.overflow="hidden",e.style.boxSizing="border-box",e.style.paddingRight="".concat(i+s,"px"),function(){["overflow","boxSizing","paddingRight"].forEach((function(i){e.style[i]=t[i]||""}))}}());a.lockedNum+=1}}const te=["[contenteditable]",'[tabindex]:not([tabindex^="-"])',"a[href]","button:not([disabled]):not([aria-hidden])",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])"],ie={focus:!1,onClose:()=>{},onOpen:()=>{}},se="data-glsr-close",ne="glsr-modal",re="is-open",oe="data-glsr-trigger",ae=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.class=ne+"__"+e,t};class le{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.events={_open:this._openModal.bind(this),mouseup:this._onClick.bind(this),keydown:this._onKeydown.bind(this),touchstart:this._onClick.bind(this)},this.id=e,this.triggers=[],this._config(t),this._reset()}header(e,t){return this._insertHtml(this.dom.header,e,t)}content(e,t){return this._insertHtml(this.dom.content,e,t)}footer(e,t){return this._insertHtml(this.dom.footer,e,t)}_closeModal(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&(e.preventDefault(),e.stopPropagation());const t=()=>{this.root.removeEventListener("animationend",t,!1),this.root.classList.remove(re),ce.open.pop(),this.config.onClose(this,e),GLSR.Event.trigger("site-reviews/modal/close",this,e),S((()=>this._reset()))()};this.root.addEventListener("animationend",t,!1),this.root.setAttribute("aria-hidden","true"),this._eventHandler("remove"),function(e,t){if(!J()){X(e);var i=Q(t);i.lockedNum-=1,i.lockedNum>0||(K().ios||"function"!=typeof i.unLockCallback?(e&&(Array.isArray(e)?e:[e]).forEach((function(e){var t=i.lockedElements.indexOf(e);-1!==t&&(e.ontouchmove=null,e.ontouchstart=null,i.lockedElements.splice(t,1))})),i.documentListenerAdded&&(document.removeEventListener("touchmove",U(),Z),i.documentListenerAdded=!1)):i.unLockCallback())}}(this.dom.content),this.trigger&&this.trigger.focus&&this.trigger.focus()}_config(e){return this.config=Object.assign({},ie,e),this}_eventHandler(e){this._eventListener(this.dom.close,e,["keydown"]),this._eventListener(this.root,e,["mouseup","touchstart"]),this._eventListener(document,e,["keydown"])}_eventListener(e,t,i){e&&i.forEach((i=>e[t+"EventListener"](i,this.events[i])))}_focusableNodes(){return[].slice.call(this.root.querySelectorAll(te))}_insertHtml(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e&&null!==t){if(""!==t){const e=v("div",arguments.length>2&&void 0!==arguments[2]?arguments[2]:{});e.innerHTML=t,t=e.outerHTML}e.innerHTML=t}return e}_insertModal(){var e;const t=v("button",ae("close",{"aria-label":GLSR.text.closemodal,"data-glsr-close":""})),i=v("div",ae("content",{tabindex:-1})),s=v("div",ae("header")),n=v("div",ae("footer")),r=v("div",ae("dialog",{"aria-modal":!0,role:"dialog"}),t,s,i,n),o=v("div",{class:ne,id:this.id,"aria-hidden":!0},v("div",ae("overlay",{tabindex:-1,"data-glsr-close":""}),r));this.dom={...this.dom,close:t,content:i,dialog:r,footer:n,header:s};const a=null!==(e=document.querySelector("body > #page.site"))&&void 0!==e?e:document.body;this.root=a.appendChild(o)}_onClick(e){e.target.hasAttribute(se)&&this._closeModal(e)}_onKeydown(e){~[13,32].indexOf(e.keyCode)&&e.target===this.dom.close&&this._closeModal(e),27===e.keyCode&&ce.open.slice(-1)[0]===this.id&&this._closeModal(e),9===e.keyCode&&this._retainFocus(e)}_openModal(e){ce.open.push(this.id),this.trigger=document.activeElement,e&&(e.preventDefault(),this.trigger=e.currentTarget),this._insertModal(),ee(this.dom.content),this.config.onOpen(this,e),GLSR.Event.trigger("site-reviews/modal/open",this,e),this.root.setAttribute("aria-hidden","false"),this.root.classList.add(re),this._eventHandler("add");const t=()=>{this.root.removeEventListener("animationend",t,!1),this._setFocusToFirstNode()};this.root.addEventListener("animationend",t,!1)}_registerTrigger(e){this._removeTrigger(e),e.addEventListener("click",this.events._open),this.triggers.push(e)}_removeTrigger(e){this.triggers.filter((t=>t!==e)),e.removeEventListener("click",this.events._open)}_removeTriggers(){this.triggers.forEach((e=>this._removeTrigger(e))),this.triggers=[]}_reset(){this.dom={close:null,content:null,footer:null,header:null},this.root&&this.root.remove(),this.root=null,this.trigger=null}_retainFocus(e){let t=this._focusableNodes();if(0!==t.length)if(t=t.filter((e=>null!==e.offsetParent)),this.root.contains(document.activeElement)){const i=t.indexOf(document.activeElement);e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&t.length>0&&i===t.length-1&&(t[0].focus(),e.preventDefault())}else t[0].focus()}_setFocusToFirstNode(){if(!this.config.focus)return;const e=this._focusableNodes();if(0===e.length)return;const t=e.filter((e=>!e.hasAttribute(se)));t.length>0?t[0].focus():0===t.length&&e[0].focus()}}const ce={active:{},open:[]};var de={close:e=>{if(e)ce.active[e]&&ce.active[e]._closeModal();else for(let e in ce.active)ce.active[e]._closeModal()},init:(e,t)=>{let i;return ce.active[e]?(i=ce.active[e],i._removeTriggers(),t&&i._config(t)):i=new le(e,t),document.querySelectorAll("["+oe+"]").forEach((t=>{e===t.attributes[oe].value&&i._registerTrigger(t)})),ce.active[e]=i,ce.active},modals:ce,modify:(e,t)=>{e&&ce.active[e]&&t(ce.active[e])},open:(e,t)=>{let i;ce.active[e]?(i=ce.active[e],i.root&&i._eventHandler("remove"),t&&i._config(t)):i=new le(e,t),ce.active[e]=i,i._openModal()}};const he="glsr-hide",ue=16,pe=468,fe="button.glsr-button-loadmore",ve=".glsr-pagination a[data-page]",ge=".glsr-reviews, [data-reviews]";class me{constructor(e,t){this.events={button:{click:this._onLoadMore.bind(this)},link:{click:this._onPaginate.bind(this)},window:{popstate:this._onPopstate.bind(this)}},this.paginationEl=t,this.reviewsEl=e.querySelector(ge),this.wrapperEl=e}destroy(){this._eventHandler("remove")}init(){this._eventHandler("add");const e=this.paginationEl.querySelector(".current");if(e){const t=this._data(e),i=e.nextElementSibling;t&&i&&2==+i.dataset.page&&GLSR.urlparameter&&window.history.replaceState(t,"",window.location)}}_data(e){try{const i=JSON.parse(JSON.stringify(this.paginationEl.dataset)),s={page:e.dataset.page||1,schema:!1,url:e.href||location.href};for(var t of Object.keys(i)){let e;try{e=JSON.parse(i[t])}catch(s){e=i[t]}s[`atts][${t}`]=e}return GLSR.ajax.data("fetch-paged-reviews",s)}catch(e){return console.error("Invalid pagination config."),!1}}_eventHandler(e){this._eventListener(window,e,this.events.window),this.wrapperEl.querySelectorAll(fe).forEach((t=>{this._eventListener(t,e,this.events.button)})),this.wrapperEl.querySelectorAll(ve).forEach((t=>{this._eventListener(t,e,this.events.link)}))}_eventListener(e,t,i){Object.keys(i).forEach((s=>e[t+"EventListener"](s,i[s])))}_handleLoadMore(e,t,i,s){s?(e.loaded(),this.destroy(),this.paginationEl.innerHTML=i.pagination,this.reviewsEl.insertAdjacentHTML("beforeend",i.reviews),this.init(),GLSR.Event.trigger("site-reviews/pagination/handle",i,this)):window.location=location}_handlePagination(e,t,i,s){s?(this._paginate(i),GLSR.urlparameter&&window.history.pushState(t,"",e.href)):window.location=e.href}_handlePopstate(e,t,i){i?this._paginate(t):console.error(t)}_loaded(){const e=this.paginationEl.querySelector(".glsr-spinner");e&&this.paginationEl.removeChild(e),this.wrapperEl.classList.remove(he)}_loading(){this.wrapperEl.classList.add(he),this.paginationEl.insertAdjacentHTML("beforeend",'
')}_onLoadMore(e){const t=e.currentTarget,i=this._data(t);if(i){const s=y(t);s.loading(),e.preventDefault(),GLSR.ajax.post(i,this._handleLoadMore.bind(this,s,i))}}_onPaginate(e){const t=e.currentTarget,i=this._data(t);i&&(this._loading(),e.preventDefault(),GLSR.ajax.post(i,this._handlePagination.bind(this,t,i)))}_onPopstate(e){GLSR.Event.trigger("site-reviews/pagination/popstate",e,this),e.state&&e.state[`${GLSR.nameprefix}[_action]`]&&(this._loading(),GLSR.ajax.post(e.state,this._handlePopstate.bind(this,e.state)))}_paginate(e){this.destroy(),this.paginationEl.innerHTML=e.pagination,this.reviewsEl.innerHTML=e.reviews,this.init(),this._scrollToTop(),this._loaded(),GLSR.Event.trigger("site-reviews/pagination/handle",e,this)}_scrollStep(e){const t=Math.min(1,(window.performance.now()-e.startTime)/pe),i=.5*(1-Math.cos(Math.PI*t)),s=e.startY+(e.endY-e.startY)*i;window.scroll(0,e.offset+s),s!==e.endY&&window.requestAnimationFrame(this._scrollStep.bind(this,e))}_scrollToTop(){let e=ue;[].forEach.call(GLSR.ajaxpagination,(t=>{const i=document.querySelector(t);i&&"fixed"===window.getComputedStyle(i).getPropertyValue("position")&&(e+=i.clientHeight)}));const t=this.reviewsEl.getBoundingClientRect().top-e;t>0||this._scrollStep({endY:t,offset:window.pageYOffset,startTime:window.performance.now(),startY:this.reviewsEl.scrollTop})}}const we="site-reviews/excerpts/init",_e="site-reviews/forms/init",ye="site-reviews/init",be="site-reviews/loaded",Ee="site-reviews/modal/init",Le="site-reviews/pagination/init";window.hasOwnProperty("GLSR")||(window.GLSR={}),window.GLSR.ajax=o,window.GLSR.forms=[],window.GLSR.pagination=[],window.GLSR.Event=d,window.GLSR.Modal=de,window.GLSR.Utils={debounce:S,dom:v,isEmpty:e=>[Object,Array].includes((e||{}).constructor)&&!Object.entries(e||{}).length,parseJson:x},d.on(we,(e=>{new _(e),d.trigger(Ee)})),d.on(_e,(()=>{GLSR.forms=GLSR.forms.filter((e=>!!e.form.closest("body"))),document.querySelectorAll("form.glsr-review-form").forEach((e=>{const t=e.querySelector("[type=submit]");if(t){let i,s=GLSR.forms.findIndex((t=>t.form===e));-1!==s?(i=GLSR.forms[s],i.destroy()):(i=new Y(e,t),GLSR.forms.push(i)),i.init()}}))})),d.on(Ee,(()=>{GLSR.Modal.init("glsr-modal-review",{onOpen:e=>{const t=e.trigger.closest(".glsr").cloneNode(!0),i=e.trigger.closest(".glsr-review").cloneNode(!0);i.querySelectorAll('[data-expanded="false"]').forEach((e=>{e.dataset.expanded="true"})),i.removeAttribute("id"),t.innerHTML="",t.appendChild(i),e.dom.content.appendChild(t)}})})),d.on(Le,(()=>{GLSR.pagination.forEach((e=>e.destroy())),GLSR.pagination=[],document.querySelectorAll(".glsr").forEach((e=>{const t=e.querySelector(".glsr-pagination");if(t&&(t.classList.contains("glsr-ajax-loadmore")||t.classList.contains("glsr-ajax-pagination"))){const i=new me(e,t);i.init(),GLSR.pagination.push(i)}}))})),d.on(ye,(()=>{document.querySelectorAll(".glsr").forEach((e=>{const t="glsr-"+window.getComputedStyle(e,null).getPropertyValue("direction");e.classList.add(t)})),d.trigger(we),d.trigger(_e),d.trigger(Le),d.trigger(be)})),d.on("site-reviews/pagination/handle",((e,t)=>{d.trigger(we,t.wrapperEl)})),document.addEventListener("DOMContentLoaded",(()=>{setTimeout((()=>d.trigger(ye)),5),setTimeout((()=>(()=>{let e=new URL(location.href);if(!e.searchParams.has("review_id")||!e.searchParams.has("verified"))return;let t=["form","review_id","theme","verified"],i={};t.forEach((t=>{e.searchParams.has(t)&&(i[t]=e.searchParams.get(t))})),GLSR.ajax.post(GLSR.ajax.data("verified-review",i),((s,n)=>{n?GLSR.Modal.open("glsr-modal-verified",{onClose:i=>{t.forEach((t=>e.searchParams.delete(t))),history.pushState({},"",e.href)},onOpen:e=>{const t=v("p");t.innerHTML=s.message,e.footer(t.outerHTML),e.content(s.review,s.attributes),e.dom.content.querySelectorAll('[data-expanded="false"]').forEach((e=>{e.dataset.expanded="true"}))}}):console.error({request:i,response:s})}))})()),10)}))}();