(()=>{var e={53796:(e,t)=>{"use strict";t.Um="X-Caller-Service-ID"},65606:e=>{var t,r,n,o=e.exports={};function i(){throw Error("setTimeout has not been defined")}function a(){throw Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var c=[],u=!1,d=-1;function l(){u&&n&&(u=!1,n.length?c=n.concat(c):d=-1,c.length&&p())}function p(){if(!u){var e=s(l);u=!0;for(var t=c.length;t;){for(n=c,c=[];++d1)for(var r=1;r{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e=r.u,t=r.e,n={},o={};r.u=function(t){return e(t)+(n.hasOwnProperty(t)?"?"+n[t]:"")},r.e=function(i){return t(i).catch(function(t){var a=o.hasOwnProperty(i)?o[i]:3;if(a<1){var s=e(i);throw t.message="Loading chunk "+i+" failed after 3 retries.\n("+s+")",t.request=s,t}return new Promise(function(e){setTimeout(function(){n[i]="",o[i]=a-1,e(r.e(i))},1e3*(3-a+1))})})}})(),(()=>{"use strict";let e,t;var n,o={};function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(o),r.d(o,{LogLevel:()=>n,debug:()=>T,error:()=>I,info:()=>O,log:()=>b,setChatWindowId:()=>y,warn:()=>w});var a=r(53796);let s="dfo-chat",c=(e,t=null,r)=>{try{let n=`${e}?brandId=${encodeURIComponent(t??"")}&program=${s}`,o=JSON.stringify(r);if("function"!=typeof navigator.sendBeacon){fetch(n,{method:"POST",body:o,headers:{"Content-Type":"application/json",[a.Um]:s}});return}navigator.sendBeacon(n,o)}catch(o){let{level:e,message:t,...n}=r;console.error("Unable to send log to the endpoint",o,e,t,n)}},u={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)},d=new Uint8Array(16),l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).slice(1));let p=function(t,r,n){if(u.randomUUID&&!r&&!t)return u.randomUUID();let o=(t=t||{}).random||(t.rng||function(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(d)})();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,r){n=n||0;for(let e=0;e<16;++e)r[n+e]=o[e];return r}return function(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+"-"+l[e[t+4]]+l[e[t+5]]+"-"+l[e[t+6]]+l[e[t+7]]+"-"+l[e[t+8]]+l[e[t+9]]+"-"+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}(o)},f={},g={debug:(...e)=>{f.extendedLogger&&console.debug(...e)},error:console.error,info:console.info,warn:console.warn},h=r(65606).env.REACT_APP_CHAT_WINDOW_VERSION??"4.978.0"??"0",m=(e,t)=>t instanceof Error?{...Object.entries(t).reduce((e,[t,r])=>(e[t]=r,e),{}),message:t.message.replace(/\r?\n|\r/g," ").replace(/\s+/g," ").trim(),stack:t.stack?.replace(/\r?\n|\r/g," ").replace(/\s+/g," ").trim()}:"function"==typeof t?Object.entries(t).reduce((e,[t,r])=>(e[t]=r,e),{}):null==t?String(t):t;function y(e){t=e}!function(e){e[e.ERROR=2]="ERROR",e[e.INFO=0]="INFO",e[e.WARN=1]="WARN"}(n||(n={}));let v="https://app-de-na1.niceincontact.com/logger-public",b=(e,r,...n)=>{let o=r.replace(/\r?\n|\r/g," "),i={chatWindowId:t};n.reduce((e,t,r)=>(e[r]=t,e),i);let a={level:e,message:o,detail:JSON.parse(JSON.stringify(i,m)),url:window.location?.toString(),appVersion:h};if(f?.commClient){f.commClient.sendLog(v,a);return}c(v,f?.brandId,a)},w=(e,...t)=>{b(1,e,...t)},I=(e,...t)=>{b(2,e,...t)},O=(e,...t)=>{b(0,e,...t)},T=(e,...t)=>{f.extendedLogger&&b(0,`[DEBUG]: ${e}`,...t)},U="file:"===window.location.protocol?g:o;"serviceWorker"in navigator&&navigator.serviceWorker.register("https://web-modules-de-na1.niceincontact.com/chat/serviceWorker.js").catch(e=>{U.warn("Service worker registration failed",e)});let L=new URL(document.location.href).hash.slice(1);new class{messageListener(e){var t,r;if(t=this.targetOrigin,r=this.sharedId,"*"!==t&&e.origin!==t||"object"!=typeof e.data||e.data.sharedId!==r)return;let n=e.data.msg;if("string"==typeof n?.type)switch(n.type){case"init":return this.onInit(n,e.origin);case"debug":return this.onDebug(n);case"event":return this.onEvent(n);case"log":return this.onLog(n);default:console.warn("Unsupported message:",n)}}post(e){let t=this.sharedId;parent.postMessage({sharedId:t,msg:e},this.targetOrigin)}ack(e,t){this.post({type:"ack",reqId:e,response:t})}onInit(e,t){this.targetOrigin=t,this.options={brandId:e.brandId,channelId:e.channelId,language:e.language},this.ack(e.reqId)}onDebug(e){console.log("CommServer:debug",e)}onEvent(e){setTimeout(()=>{let t={event:e.event,random:p()};this.post({type:"ack",reqId:e.reqId,response:t})},100)}onLog(e){this.options?.brandId||console.error("CommServer:log: brandId is not set"),c(e.endpointUrl,this.options?.brandId,e.data)}constructor(e){i(this,"sharedId",void 0),i(this,"targetOrigin","*"),i(this,"options",void 0),this.sharedId=e,window.addEventListener("message",this.messageListener.bind(this)),this.post({type:"ready"})}}(L)})()})();