!function(e){"use strict";function t(e){return(e=e||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function n(e){const n=e||{};n.src+=(n.src.indexOf("?")>-1?"&":"?")+"uniqueId="+n.uniqueId;const o=n.container||document.body;let i;return{create:function(){if(i)return;i=n.uniqueId||t("iframe-xxxx"),o.insertAdjacentHTML("beforeend",`\n \n `),window.addEventListener("message",r,!0),document.addEventListener("scroll",s(i),!0),s(i)()},element:function(){return o.querySelector("iframe")}};function s(e){return function(e,t){let n;return function(){const o=this,i=arguments;clearTimeout(n),n=setTimeout((()=>{e.apply(o,i)}),t)}}((function(){const t=document.getElementById(e)?.contentWindow;t&&t.postMessage({uniqueId:e,name:"scroll",data:{container:o?.getBoundingClientRect(),window:{width:window.innerWidth,height:window.innerHeight}}},"*")}),100)}function r(e){const t=e.data;if(t.uniqueId!==n.uniqueId||!t.events)return;const o=["resize","close","goToUrl","sendPost","ready"];for(let e=o.length-1;e>-1;e--){const i=o[e];if(t.events[i]){const e=n["on"+i.charAt(0).toUpperCase()+i.substr(1)];if("function"!=typeof e)continue;try{e(t.events[i])}catch(e){}}}}}function o(e,o,i){const s=n({uniqueId:t("xxxxxxxxxx"),src:o,container:e,onResize:e=>{window.setTimeout((function(){const t=s.element();t&&(t.style.height=e.height+"px")}),50)},onClose:()=>{e.remove(),i&&i.remove()},onGoToUrl:e=>{window.location.replace(e.url)},onSendPost:e=>{!function(e,t,n=!1){const o=document.createElement("form");o.setAttribute("action",e),o.setAttribute("method","post"),n&&o.setAttribute("target","_blank");for(const[e,n]of Object.entries(t)){const t=document.createElement("input");t.setAttribute("id",e),t.setAttribute("name",e),t.setAttribute("type","text"),t.setAttribute("value",n),o.appendChild(t)}document.getElementsByTagName("body")[0].appendChild(o),o.submit()}(e.action,e.data)},onReady:()=>{const e=s.element();e&&e.removeAttribute("scrolling")}});return s.create()}function i(e){const t=document.createElement("div");t.setAttribute("class","booksy-widget-overlay"),document.body.appendChild(t);const n=document.createElement("div");var i;n.setAttribute("class","booksy-widget-dialog"),document.body.appendChild(n),o(n,e,t),(i=n)&&window.scroll(0,i.getBoundingClientRect().top)}function s(e){throw new Error(`[Booksy][widget][error] ${e}`)}const r=()=>{const e=function(e){Object.assign(window,{booksy:window.booksy||{}});const t=document.querySelectorAll("script");for(let n=0;ne.split("="))):[]).forEach((([e,n])=>{t[e]=n})),!t.lang){const n=e.match(/https?:\/\/[^/]*\/([a-z][a-z])[_-]([a-zA-Z][a-zA-Z])\/widget/);n&&(t.lang=n[1],t.country=n[2])}return t}(e.src);var n;if((n=t).mode||(n.mode="dialog"),n.theme||(n.theme="default"),n.iframeSrc=`${n.baseUrl}index.html?id=${n.id}&businessId=${n.businessId}&appointmentUid=${n.appointmentUid}&lang=${n.lang}&country=${n.country}&mode=${n.mode}&theme=${n.theme}`,!t.country||!t.lang)return void s(`incomplete configuration: ${JSON.stringify(t)}`);const r=function(e,t){const n="booksy-widget-container",o=[n,n+"-"+t.mode,n+"-"+t.theme,n+"-"+t.lang].join(" "),i=document.createElement("div");return i.setAttribute("class",o),e&&e.parentNode&&e.parentNode.insertBefore(i,e),i}(e,t);var c;if(window.booksy.widgetCss||(window.booksy.widgetCss=(c=t.baseUrl,document.head.insertAdjacentHTML("beforeend",`\n`),!0)),"dialog"===t.mode){const e=function(e){const t=document.createElement("div");return t.setAttribute("class","booksy-widget-button"),e.appendChild(t),t}(r);return function(e,t){const n=document.createElement("a"),{id:o,lang:i,country:s,businessId:r}=t,c=o.split(",")[0]||o||r.split(",")[0]||r,d=t.baseUrl.match(/https?:\/\/[^/]+/);let u=d?d[0]:t.baseUrl;u.match(/\/$/)||(u+="/"),n.setAttribute("class","booksy-business-link"),n.setAttribute("href",`${u}${i}-${s}/dl/show-business/${c}`),n.setAttribute("target","_blank"),e.appendChild(n)}(r,t),void e.addEventListener("click",(()=>{i(t.iframeSrc||"")}))}"inline"!==t.mode?s(`unexpected widget mode ${t.mode}`):o(r,t.iframeSrc)};r(),e.main=r,Object.defineProperty(e,"__esModule",{value:!0})}({});