const configBase={apiBase:"https://client.10-x.eu/api",bookingformVersion:"1",containerId:"10x-Bookingform",wrapperId:"10x-Wrapper",encryptionKey:"7196168e3b076be2ad3fe7cd687aeed4",production:!0,};class FormTitle{text='';tailwindClasses='';textDark=!0;constructor(text='',tailwindClasses='',textDark=!0){this.text=text;this.tailwindClasses=tailwindClasses;this.textDark=textDark} setText(text){this.text=text} setTextLight(){this.textDark=!1} setTailwindClasses(tailwindClasses){this.tailwindClasses=tailwindClasses} getJsonString(){const obj={text:this.text,tailwindClasses:this.tailwindClasses,textDark:this.textDark,} return JSON.stringify(obj)}} class FormImage{url='';alt='';tailwindClasses='';constructor(url='',alt='',tailwindClasses=''){this.url=url;this.alt=alt;this.tailwindClasses=tailwindClasses} setUrl(url){this.url=url} setAlt(alt){this.alt=alt} setTailwindClasses(tailwindClasses){this.tailwindClasses=tailwindClasses} getJsonString(){const obj={url:this.url,alt:this.alt,tailwindClasses:this.tailwindClasses,} return JSON.stringify(obj)}} class TenXBookingformInit{#image=null;#title=null;#config=null;#openByDefault=!1;constructor(){this.#config=configBase} setImage(image){if(image instanceof FormImage){this.#image=image}else{console.error('Image must be instance of FormImage like this: '+new FormImage())} return this} setTitle(title){if(title instanceof FormTitle){this.#title=title}else{console.error('Title must be instance of FormTitle like this: '+new FormTitle())} return this} setOpenByDefault(bool=!0){this.#openByDefault=bool;return this} loadForm(){const wrapper=document.createElement("div");const loaderUrl=this.#config.apiBase+"/utils/loader";document.getElementById(this.#config.containerId).appendChild(wrapper);wrapper.id=this.#config.wrapperId;wrapper.style.position="relative";fetch(loaderUrl,{method:"GET",priority:"high"}).then(response=>{if(!response.ok){throw new Error(`HTTP error! ${response}`)} return response.text()}).then(responseData=>{document.getElementById(this.#config.wrapperId).innerHTML+=responseData;setTimeout(()=>{document.getElementById("10x-Loader-Wrapper").style.display="none"},5000)}) const domain=window.location.hostname;const url=new URL(this.#config.apiBase+"/forms/html/custom");url.searchParams.append('encrypt',this.#config.encryptionKey);url.searchParams.append('domain',domain);url.searchParams.append('version',this.#config.bookingformVersion);url.searchParams.append('openByDefault',this.#openByDefault);if(this.#title!==null){url.searchParams.append('title',this.#title.getJsonString())} if(this.#image!==null){url.searchParams.append('image',this.#image.getJsonString())} const iframe=document.createElement("iframe");document.getElementById(this.#config.wrapperId).appendChild(iframe);iframe.src=url;iframe.name="10x-BookingformFrame";iframe.title="10x-BookingformFrame";iframe.id="10x-BookingformFrame";iframe.width="100%";iframe.height="700px";iframe.style.border="none";iframe.style.overflow="hidden";iframe.scrolling="no";const iframeBuild=document.getElementById("10x-BookingformFrame");window.addEventListener("message",function(e){var iframe=document.getElementById("10x-BookingformFrame");var eventName=e.data[0];var data=e.data[1];switch(eventName){case "setHeight":iframe.height=data;break;case "loaded":document.getElementById("10x-Loader-Wrapper").style.display="none";break}},!1)}}