!function(){var e={669:function(e,t,i){e.exports=i(609)},448:function(e,t,i){"use strict";var n=i(867),s=i(26),r=i(372),o=i(327),a=i(97),c=i(109),l=i(985),u=i(61);e.exports=function(e){return new Promise((function(t,i){var d=e.data,p=e.headers;n.isFormData(d)&&delete p["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";p.Authorization="Basic "+btoa(f+":"+m)}var g=a(e.baseURL,e.url);if(h.open(e.method.toUpperCase(),o(g,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,h.onreadystatechange=function(){if(h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in h?c(h.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:n,config:e,request:h};s(t,i,r),h=null}},h.onabort=function(){h&&(i(u("Request aborted",e,"ECONNABORTED",h)),h=null)},h.onerror=function(){i(u("Network Error",e,null,h)),h=null},h.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),i(u(t,e,"ECONNABORTED",h)),h=null},n.isStandardBrowserEnv()){var y=(e.withCredentials||l(g))&&e.xsrfCookieName?r.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in h&&n.forEach(p,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete p[t]:h.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),e.responseType)try{h.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),i(e),h=null)})),d||(d=null),h.send(d)}))}},609:function(e,t,i){"use strict";var n=i(867),s=i(849),r=i(321),o=i(185);function a(e){var t=new r(e),i=s(r.prototype.request,t);return n.extend(i,r.prototype,t),n.extend(i,t),i}var c=a(i(655));c.Axios=r,c.create=function(e){return a(o(c.defaults,e))},c.Cancel=i(263),c.CancelToken=i(972),c.isCancel=i(502),c.all=function(e){return Promise.all(e)},c.spread=i(713),c.isAxiosError=i(268),e.exports=c,e.exports.default=c},263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:function(e,t,i){"use strict";var n=i(263);function s(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var i=this;e((function(e){i.reason||(i.reason=new n(e),t(i.reason))}))}s.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},s.source=function(){var e;return{token:new s((function(t){e=t})),cancel:e}},e.exports=s},502:function(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:function(e,t,i){"use strict";var n=i(867),s=i(327),r=i(782),o=i(572),a=i(185);function c(e){this.defaults=e,this.interceptors={request:new r,response:new r}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[o,void 0],i=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)i=i.then(t.shift(),t.shift());return i},c.prototype.getUri=function(e){return e=a(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,i){return this.request(a(i||{},{method:e,url:t,data:(i||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,i,n){return this.request(a(n||{},{method:e,url:t,data:i}))}})),e.exports=c},782:function(e,t,i){"use strict";var n=i(867);function s(){this.handlers=[]}s.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},s.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},s.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=s},97:function(e,t,i){"use strict";var n=i(793),s=i(303);e.exports=function(e,t){return e&&!n(t)?s(e,t):t}},61:function(e,t,i){"use strict";var n=i(481);e.exports=function(e,t,i,s,r){var o=new Error(e);return n(o,t,i,s,r)}},572:function(e,t,i){"use strict";var n=i(867),s=i(527),r=i(502),o=i(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||o.adapter)(e).then((function(t){return a(e),t.data=s(t.data,t.headers,e.transformResponse),t}),(function(t){return r(t)||(a(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:function(e){"use strict";e.exports=function(e,t,i,n,s){return e.config=t,i&&(e.code=i),e.request=n,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:function(e,t,i){"use strict";var n=i(867);e.exports=function(e,t){t=t||{};var i={},s=["url","method","data"],r=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function l(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(i[s]=c(void 0,e[s])):i[s]=c(e[s],t[s])}n.forEach(s,(function(e){n.isUndefined(t[e])||(i[e]=c(void 0,t[e]))})),n.forEach(r,l),n.forEach(o,(function(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(i[s]=c(void 0,e[s])):i[s]=c(void 0,t[s])})),n.forEach(a,(function(n){n in t?i[n]=c(e[n],t[n]):n in e&&(i[n]=c(void 0,e[n]))}));var u=s.concat(r).concat(o).concat(a),d=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return n.forEach(d,l),i}},26:function(e,t,i){"use strict";var n=i(61);e.exports=function(e,t,i){var s=i.config.validateStatus;i.status&&s&&!s(i.status)?t(n("Request failed with status code "+i.status,i.config,null,i.request,i)):e(i)}},527:function(e,t,i){"use strict";var n=i(867);e.exports=function(e,t,i){return n.forEach(i,(function(i){e=i(e,t)})),e}},655:function(e,t,i){"use strict";var n=i(867),s=i(16),r={"Content-Type":"application/x-www-form-urlencoded"};function o(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,c={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(a=i(448)),a),transformRequest:[function(e,t){return s(t,"Accept"),s(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(o(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(o(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(r)})),e.exports=c},849:function(e){"use strict";e.exports=function(e,t){return function(){for(var i=new Array(arguments.length),n=0;n=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([i]):o[t]?o[t]+", "+i:i}})),o):o}},713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},867:function(e,t,i){"use strict";var n=i(849),s=Object.prototype.toString;function r(e){return"[object Array]"===s.call(e)}function o(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==s.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return"[object Function]"===s.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var i=0,n=e.length;i{t().get(e).then((e=>{i(e.data)})).catch((e=>{n(e)}))}))},s=function(e,i){return new Promise(((n,s)=>{t().get(e,i).then((e=>{n(e.data)})).catch((e=>{s(e)}))}))},r=function(e,i,n){return new Promise(((s,r)=>{try{t().post(e,i,n).then((e=>{s(e.data)})).catch((e=>{r(e)}))}catch(e){r(e)}}))},o=function(e,t,i,n,s,r,o,a,c,l,u){return{licenseKey:e,profileSettings:t,baseUrl:i,languageCode:n,supportedDomains:s,environment:r,region:o,recordUrlDomain:a,identityServiceUrl:c,crossDomainConsent:l,customOptions:u}},a=function(e){function t(e){try{const t=new URL(e).hostname.split("."),i=t.length-1,n=t.length>=3&&(t[i]+t[i-1]).length<=5;return t.splice(n?-3:-2).join(".")}catch(e){return null}}function i(e,t){let i=e||window.location.hostname;const n=t||!1;let s=0;if(i.includes(".co.")||i.includes(".com.")){const e=i.split(".");e[e.length-1].length<=3&&(s=1)}if(i=i.replace(/(https?:\/\/)?(www.)?/i,""),!n){const e=i.split(".");i=e.slice(e.length-(2+s)).join(".")}return-1!==i.indexOf("/")?i.split("/")[0]:i}return e&&(e.environment="production"===e.environment?"":e.environment),{getDomainName:i,getDefaultSubmissionUrl:function(){const t=e.recordUrlDomain;if(t||t?.length>0)return t;const{region:n}=e;let s=e?.environment;return s&&s?.length>0&&(s=`-${s}`),`https://cscript-${n}${s}.${i()}/cookiesapi/submit`},getSubmissionUrl:function(){const t=""===e.environment?"":`-${e.environment}`,i=window?.cassieResourceRootDomain??"cassiecloud.com";return`https://cscript-${e.region}${t}.${i}/cookiesapi/submit`},determineJsonUrl:function(){return`${e.baseUrl}/${e.licenseKey}/V2/${e.profileSettings.WidgetId}_${e.languageCode}.json`},checkDomain:function(e){if("all"===e||"N/A"===e)return!0;const i=e.trim().split(",");for(let e=0;e{const t=e.split("-");if(2!==t.length)return null;const i=t[0].match(/s(\d+)c(\d+)/);return i?{FieldID:`s${i[1]}_c${i[2]}`,IsChecked:parseInt(t[1],10)}:null})).filter((e=>null!==e)):[]}function f(e){try{return JSON.parse(e),!0}catch(e){return!1}}var m=class{constructor(e,t=null){this.accessKey=e,this.cookies=this.getAllCookies(),this.defaultCookieExpiry=t??365,this.maxTimeout=2e3}getAllCookies(){for(var e={},t=document.cookie.split(";"),i=1;i<=t.length;i++){var n=t[i-1].split("="),s=n[0],r=n[1];void 0!==s&&s.length>0&&(s=s.trim()),void 0!==r&&r.length>0&&(r=r.trim()),e[s]=r}return e}getCookieValueByName=function(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift().trim():null};sleep(e){return new Promise((t=>setTimeout(t,e)))}getProtectedCookieByName=function(e,t,i=2e3){return new Promise((async n=>{let s=i/100;for(let i=1;i{let t=e.browserCookieName.trim().toLowerCase(),i=[];return t.includes(",")?i=t.split(",").map((e=>e.trim())):i.push(t),i.includes(r.toLowerCase())}));if(o&&0!=o?.expiry){var s=new Date;s.setDate(s.getDate()+o.expiry),n.push(this.getProtectedCookieByName(r,s.getTime().toString(),this.maxTimeout))}}return n=(await Promise.all(n)).filter((e=>e)),n.filter((e=>e))};recreateProtectedCookies(){try{const e=this.getCookieValueByName("SyrenisCustom_"+this.accessKey);let t=[];t=f(e)?JSON.parse(e):function(e){if(!e||"string"!=typeof e||""===e.trim())return[];let t=null;try{t=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4!=0;)t+="=";return decodeURIComponent(Array.from(atob(t)).map((e=>`%${e.charCodeAt(0).toString(16).padStart(2,"0")}`)).join(""))}(e)}catch(e){return console.error("Error decoding base64 string:",e),[]}return t.split("|$|").map((e=>{const t=e.split("|*|");return{Key:t[0],Value:t[1],Expiry:t[2]}}))}(e);for(let e=0;e0&&t[0].FieldID?(c=t)&&Array.isArray(c)&&0!==c.length?c.map((e=>`${e.FieldID.replace("_","")}-${e.IsChecked}`)).join("."):"":Array.isArray(t)&&t.length>0&&t[0].Key?function(e){return e&&Array.isArray(e)&&0!==e.length?(t=e.map((e=>`${e.Key}|*|${e.Value}|*|${e.Expiry}`)).join("|$|"),btoa(Array.from((new TextEncoder).encode(t)).map((e=>String.fromCharCode(e))).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")):"";var t}(t):e.includes("GtmConsent")?function(e){return e&&Array.isArray(e)&&0!==e.length?e.map((e=>Object.entries(e).map((([e,t])=>`${e}:${t}`)).join("|"))).join("|"):""}(t):JSON.stringify(t):"object"==typeof t&&(a=JSON.stringify(t));let l=e+"="+a+";"+r+o+";path=/";document.cookie=l};storeCookieWithTimeExpiry=function(e,t,i,n){let s=new Date;s.setTime(n);let r=e+"="+t+";expires="+s.toUTCString()+";domain="+(i=i??window.document.domain)+";path=/";document.cookie=r};hasConsent=function(){let e=this.getAllCookies(),t=e["SyrenisCookieFormConsent_"+this.accessKey],i=e["SyrenisGuid_"+this.accessKey];return!(!t||!i)};getVisitGuid=function(){return this.getCookieValueByName("SyrenisGuid_"+this.accessKey)};getConsentDate=function(){let e=this.getCookieValueByName("SyrenisCookieConsentDate_"+this.accessKey);return e||(e=new Date(1970,0,1).getTime()),e};getPrivacyPolicyId=function(){let e=this.getCookieValueByName("SyrenisCookiePrivacyLink_"+this.accessKey);return e&&0!=e.length?e:null};getProtectedCookiesContainer=function(){return this.getCookieValueByName("SyrenisCustom_"+this.accessKey)}};let g,y,C;function S(e){const t=e.split(",").map((e=>e.trim().replace("*","").replace("https://","").replace("http://",""))).filter((e=>(e||e.length>0)&&"all"!==e.trim())).map((e=>e.trim().replace("*","")));return 0===t.length&&t.push(`.${document.domain}`),t}var v=function(e,t){function i(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}function n(e){e.sort(((e,t)=>e.executionOrder-t.executionOrder)),e.sort(((e,t)=>t.isRunFirst-e.isRunFirst)),e.forEach((e=>{e.isStrictlyNecessary||(e.isOptIn?(c(e.bodyOptIn,!1),c(e.headOptIn,!0)):(c(e.bodyOptOut,!1),c(e.headOptOut,!0)))}))}function s(e){for(const[t,i]of Object.entries(e))S(y.supportedDomains).forEach((e=>{g.storeCookie(t.replace("Cassie","Syrenis"),i,e)}))}function o(e,t){e.forEach((e=>{const i=t.find((t=>t.channelId==e.channelId));e.isStrictlyNecessary?(e.hasConsent=!0,e.isOptIn=!0):i&&(e.hasConsent=!0,e.isOptIn=i.isOptIn)})),n(e.filter((e=>e.hasConsent)))}return y=e,C=t,g=new m(y.profileSettings.AccessKey,C),{runStrictlyNecessaryScripts:function(e){e.sort(((e,t)=>e.executionOrder-t.executionOrder)),e.sort(((e,t)=>t.isRunFirst-e.isRunFirst)),e.forEach((e=>{e.isStrictlyNecessary&&(c(e.bodyOptIn,!1),c(e.headOptIn,!0))}))},runOptInScripts:n,placeSyrenisCookies:s,processConsent:async function(e,t,n){const r=y.profileSettings.AccessKey,a=e.map((e=>({FieldID:`s${e.statementId}_c${e.channelId}`,IsChecked:e.isOptIn?1:0})));this.runStrictlyNecessaryScripts(t),o(t,e);const c=await g.getProtectedCookies(n.persistCookies,t);y.identityServiceUrl?s(await l(C,r,JSON.stringify([]),JSON.stringify(a),JSON.stringify([]),JSON.stringify([]),JSON.stringify(c),n.privacyId,y.identityServiceUrl,y.supportedDomains,y.crossDomainConsent,y?.profileSettings?.CookieCollectionId??1)):function(e,t){let n=y.profileSettings.AccessKey,s=S(y.supportedDomains);var r=i(),o=(new Date).getTime();s.forEach((i=>{null===g.getCookieValueByName("SyrenisGuid_"+n)&&g.storeCookie("SyrenisGuid_"+n,r,i),g.storeCookie("SyrenisCookieFormConsent_"+n,e,i),g.storeCookie("SyrenisCookiePrivacyLink_"+n,t,i),g.storeCookie("SyrenisCookieConsentDate_"+n,o,i)}))}(a,n.privacyId)},runConsent:async function(e){let t=y?.profileSettings?.CookieCollectionId??1;if(y.identityServiceUrl&&await async function(e){let t=(!g.hasConsent()||y.crossDomainConsent)&&await u(C,y.profileSettings.AccessKey,y.supportedDomains,y.identityServiceUrl,y.crossDomainConsent,e);if(null!==t){const e=JSON.parse(t.CassieConsent),i=t.Restored,n="boolean"!=typeof e&&e;if(n&&s(n),!1===i&&y.crossDomainConsent){const e=await d(y.profileSettings.AccessKey,y.supportedDomains,y.identityServiceUrl);document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend",e)}}}(t),!g.hasConsent())return;const i=g.getCookieValueByName("SyrenisCookieFormConsent_"+y.profileSettings.AccessKey);let n;try{n=f(i)?JSON.parse(i):h(i)}catch(e){return void console.error("Error parsing cookie consent:",e)}let r=n.map((e=>{let t=e.FieldID.indexOf("c")+1;return{channelId:e.FieldID.substring(t,e.FieldID.length),isOptIn:1==e.IsChecked}}));g.recreateProtectedCookies(),this.runStrictlyNecessaryScripts(e),o(e,r)},getCurrentConsent:function(){let e=g.getFormConsent(),t=[];for(let i=0;i{let c={CookieFormID:y?.profileSettings?.WidgetId??null,LicenseID:y?.licenseKey,DivID:s,Preferences:g.getFormConsent(),appCodeName:navigator.appCodeName,appName:navigator.appName,appVersion:navigator.appVersion,cookieEnabled:navigator.cookieEnabled,geolocation:"",language:navigator.language,platform:navigator.platform,referrer:document.referrer.replace(/&/g,"%26"),submissionSource:t??"undefined_source",visitGUID:g.getVisitGuid()??i(),WebsiteURL:document.URL.replace(/&/g,"%26"),PrivacyPolicyID:n,custom1stPartyData:g.getProtectedCookiesContainer()};try{return o(await r(e,c,{timeout:5e3}))}catch(e){return a(e)}}))},dropStrictlyNecessaryCookies:function(e,t){let n=y.profileSettings.AccessKey,s=S(y.supportedDomains);var r=i(),o=(new Date).getTime();s.forEach((t=>{null===g.getCookieValueByName("SyrenisGuid_"+n)&&g.storeCookie("SyrenisGuid_"+n,r,t),g.storeCookie("SyrenisCookiePrivacyLink_"+n,e,t),g.storeCookie("SyrenisCookieConsentDate_"+n,o,t)})),this.runStrictlyNecessaryScripts(t)},saveGtmConsent:function(e){let t=y.profileSettings.AccessKey,i=S(y.supportedDomains),n=e;i.forEach((e=>{g.storeCookie("SyrenisGtmConsent_"+t,n,e)}))}}},w={emit:function(e,t){!function(e,t){const i=t||{bubbles:!0,cancelable:!1},n=document.createEvent("CustomEvent");n.initCustomEvent(e,i.bubbles,i.cancelable,i.detail),document.dispatchEvent(n)}(e,{detail:t,bubbles:!0,cancelable:!0})}};window.CassieWidgetLoaderModule=class{constructor(e){this.widgetProfileId=e.widgetProfileId??null,this.licenseKey=e.licenseKey??null,this.licenseKey||console.error("licenseKey cannot be null"),this.identityUrl=e.identityUrl??null,this.supportedDomains=e.supportedDomains??null,this.languageCode=e?.languageCode??"en",this.customOptions=e.customOptions??null,this.region=e.region??"use",this.environment=e.environment??"production",this.crossDomainConsent=e.crossDomainConsent??!1,this.widgetProfileUrl=e.widgetProfileUrl??null,this.profileSettings=e.widgetProfileSettings??null,this.widgetLocation=e.widgetLocationUrl??null,this.customServerPath=e.customServerPathUrl??null,this.Widget=null,this.baseUrl=e.baseUrl??this.getBaseUrl(),this.recordUrl=e.recordUrl??null,this.error={isError:!1,errorMessage:""},this.isLoading=!0,this.init()}async init(){if("dev"===this.environment)await this.initWidget();else try{await this.initWidget()}catch(e){this.isLoading=!1,this.error.isError=!0,this.error.errorMessage=e}}async initWidget(){this.profileSettings=this.profileSettings??await n(this.getProfileUrl()),this.widgetLocation=this.widgetLocation??this.getWidgetUrl(this.profileSettings.Version);const[e,t]=await Promise.all([this.getWidget(),this.getProfiler()]);this.loadScriptToDOM(e);const i=o(this.licenseKey,this.profileSettings,this.baseUrl,this.languageCode,this.supportedDomains,this.environment,this.region,this.recordUrl,this.identityUrl,t,this.customOptions);this.Widget=new class{constructor(e){this.eventManager=w,this.datetimestamp=(new Date).getTime(),this.domain=(new a).getDomainName();let t=e.languageCode??"";(e.profileSettings?.SupportedLanguages??[]).includes(t)&&""!==t||(t="Default"),this.cassieSettings=o(e.licenseKey,e.profileSettings,e.baseUrl,t,e.supportedDomains??`*.${this.domain}`,e.environment,e.region,e.recordUrlDomain,e.identityServiceUrl,e.crossDomainConsent,e.customOptions),this.cassieSettings.profileSettings?.TemplateOptions||(this.cassieSettings.profileSettings.TemplateOptions={},this.cassieSettings.profileSettings.TemplateOptions.PreBannerPosition=this.cassieSettings.profileSettings?.TemplateOptions?.PreBannerPosition??1,this.cassieSettings.profileSettings.TemplateOptions.WidgetPosition=this.cassieSettings.profileSettings?.TemplateOptions?.WidgetPosition??2),this.urlHelper=new a(this.cassieSettings),this.cookieWidgetDivId="cassie-widget",this.cassieScripts=[],this.widgetTemplate={},this.cassieWidgetFileSettings=null,this.gpcEnabled=(e.profileSettings.GpcEnabled&&navigator.globalPrivacyControl)??!1,this.bannerIsVisible=!1,this.modalIsVisible=!1,this.handlerUrl=this.urlHelper.getSubmissionUrl(),this.forceReconsent=!1,this.extentions=[{event:"Sample",extentionFunction:function(){}}],this.init()}async init(){this.createWidgetElement(),await this.getWidgetJson(),this.cassieWidgetFileSettings.identityServiceUrl&&!this.cassieSettings?.customOptions?.isPreview&&(this.cassieSettings.identityServiceUrl=this.cassieWidgetFileSettings.identityServiceUrl),this.cassieSettings?.crossDomainConsent&&this.cassieWidgetFileSettings.identityServiceUrlPrefix&&(this.cassieSettings.identityServiceUrl=`https://${this.cassieWidgetFileSettings.identityServiceUrlPrefix}.${this.domain}`),this.syrenisHelper=new v(this.cassieSettings,this.cassieWidgetFileSettings.CassieCookiesExpiry),this.cookieHelper=new m(this.cassieSettings.profileSettings.AccessKey,this.cassieWidgetFileSettings.CassieCookiesExpiry);const e=this.cassieWidgetFileSettings.reconsentDate.toString(),t=e.endsWith("Z")?new Date(e):new Date(`${e}Z`);this.forceReconsent=t.getTime()>this.cookieHelper.getConsentDate()&&this.cookieHelper.hasConsent(),!this.forceReconsent&&await this.syrenisHelper.runConsent(this.cassieScripts),this.widgetTemplate.hasConsent=this.cookieHelper.hasConsent()&&!this.forceReconsent,this.widgetTemplate.useRadioButtons=this.cassieSettings.profileSettings.UseRadioButtons??!1,this.widgetTemplate.hasConsent||this.dropCookiesOnLoad(),await this.getTemplateFiles(),w.emit("CassieTemplateFilesLoaded")}registerExtention(e,t){this.extentions.push({event:e,extentionFunction:t})}runExtentions(e){const t=this.extentions.filter((t=>t.event===e));for(const e of t)e.extentionFunction()}dropCookiesOnLoad(){const e="auto_save",t=this.widgetTemplate.CookieDropBehaviourType??1;if(3===t)this.acceptAll(e);else if(2===t){const e=this.cookieHelper.getPrivacyPolicyId()??this.cassieWidgetFileSettings.privacyId;this.syrenisHelper.dropStrictlyNecessaryCookies(e,this.cassieScripts)}else if(4===t)this.acceptAll({respectGpc:!0,source:e});else if(1===t)return}getCurrentConsent(){return this.syrenisHelper.getCurrentConsent()}getGtmConsent(){const e=this.syrenisHelper.getCurrentConsent(),t=this.cassieScripts.filter((e=>null!==e.gtmConsentType&&""!==e.gtmConsentType)).reduce(((e,t)=>{const i=t.gtmConsentType;return e[i]||(e[i]=[]),e[i].push(t.channelId),e}),{});return Object.keys(t).map((i=>{const n=t[i].every((t=>e.find((e=>e.channelId==t))?.isOptIn))?"granted":"denied",s={};return s[i]=n,s}))}storeGtmConsent(){const e=this.getGtmConsent();e.length>0&&this.syrenisHelper.saveGtmConsent(e)}initializeTemplate(){w.emit("CassieTemplateInitialized")}hideBanner(){this.runExtentions("hideBanner"),this.bannerIsVisible=!1,w.emit("CassieBannerVisibility",!1)}showBanner(){this.runExtentions("showBanner"),this.bannerIsVisible=!0,w.emit("CassieBannerVisibility",!0)}showModal(){this.runExtentions("showModal"),this.modalIsVisible=!0,w.emit("CassieModalVisibility",!0)}hideModal(){this.runExtentions("hideModal"),this.modalIsVisible=!1,w.emit("CassieModalVisibility",!1)}getPreferences(){const e=this.widgetTemplate.Categories,t=[];return e.forEach((e=>{const i=e.Cookies.map((e=>({channelId:e.ChannelID,gpcEnabled:e.GpcEnabled,statementId:e.Statements[0].StatementID,isOptIn:e.DefaultValue})));t.push(...i)})),t}async submitConsent(e,t){if(w.emit("CassieSubmitConsent",e),await this.syrenisHelper.processConsent(e,this.cassieScripts,this.cassieWidgetFileSettings),this.storeGtmConsent(),this.widgetTemplate.hasConsent=!0,w.emit("CassieProcessedConsent",e),this.handlerUrl)try{const i=this.cookieHelper.getPrivacyPolicyId()??this.cassieWidgetFileSettings.privacyId;this.syrenisHelper.postConsentToCassie(this.handlerUrl,t,i,this.cookieWidgetDivId).then((t=>(w.emit("CassieSubmittedConsent",e),t))).catch((async()=>{const n=await this.syrenisHelper.postConsentToCassie(this.defaultSubmissionUrl,t,i,this.cookieWidgetDivId);return w.emit("CassieSubmittedConsent",e),n}))}catch(e){return console.error(e),e}}addConsentListener(e){document.addEventListener("CassieProcessedConsent",e)}hasConsent(){return this.widgetTemplate.hasConsent=this.cookieHelper.hasConsent(),this.widgetTemplate.hasConsent}acceptAll(e){if("string"==typeof e||null==e){var t=e;(e={}).source=t,e.respectGpc=!1}let i=this.getPreferences();i.forEach((t=>{t.isOptIn=!0,e.respectGpc&&this.gpcEnabled&&t.gpcEnabled&&(t.isOptIn=!1)})),this.submitConsent(i,e.source)}rejectAll(e){const t=this.getPreferences();t.forEach((e=>e.isOptIn=!1)),this.submitConsent(t,e)}createWidgetElement(){if(!this.cassieSettings.profileSettings.LoadTemplateHtml)return;const e=this.cookieWidgetDivId;if(null===document.getElementById(e)||0===document.getElementById(e).length){const t=document.createElement("div");t.setAttribute("id",e),t.style.display="none",t.classList.add("syrenis-cookie-widget"),document.body.appendChild(t)}}async getWidgetJson(){const e=this.urlHelper.determineJsonUrl(),t=await n(e);this.populateWidget(t),w.emit("CassieWidgetFileLoaded",null)}async getTemplateFiles(){const e=`${this.cassieSettings.baseUrl}/templates/${this.cassieSettings.profileSettings.Template}/`;if(this.cassieSettings.profileSettings.LoadTemplateCss&&this.AddCssToPage(`${e}template.min.css`),this.cassieSettings.profileSettings.LoadTemplateHtml){const t=await n(`${e}index.min.html`);this.loadHtmlToElement(this.cookieWidgetDivId,t)}if(this.cassieSettings.profileSettings.LoadTemplateJs){const t=await n(`${e}template.min.js`);this.loadScriptToDOM(t)}}AddCssToPage(e){const{head:t}=document,i=document.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=e,t.insertBefore(i,t.childNodes[0])}loadHtmlToElement(e,t){const i=document.getElementById(e);i.innerHTML=t;const n=document.getElementsByTagName("body")[0];n.insertBefore(i,n.firstChild)}loadScriptToDOM(e){const t=document.createElement("script");t.innerHTML=e,document.body.appendChild(t)}populateWidget(e){if(this.cassieWidgetFileSettings=new class{constructor(e){this.persistCookies=e.Custom1stPartyData?.length>0?e.Custom1stPartyData:[],this.privacyId=function(e){if(!e)return 1;const t=e.substring(0,e.length-1).split("|"),i=[];for(let e=0;e!1===e.Default));return n?n.PrivacyId:1}(e.Template.PrivacyPolicies),this.identityServiceUrl=e.IdentityServiceEndpoint??null,this.reconsentDate=e.ReconsentDate??"1970-01-01T00:00:00.000Z",this.cookieCollectionId=e.CookieCollectionId??1,this.identityServiceUrlPrefix=e.IdentityServiceUrlPrefix??null,this.CassieCookiesExpiry=e.CassieCookiesExpiry??365}}(e),e.Scripts.forEach((e=>{const t=new class{constructor(e){this.cookieId=e.CookieID,this.scriptName=e.CookieName,this.scriptDescription=e.CookieDescription??new String(""),this.isStrictlyNecessary=e.IsStrictlyNecessary??!1,this.isRunFirst=e.IsRunFirst??!1,this.executionOrder=e.ExecutionOrder??100,this.bodyOptIn=e.CookieBodyDivID,this.bodyOptOut=e.CookieBodyDivIDOptOut,this.headOptIn=e.CookieScript,this.headOptOut=e.CookieScriptOptOut,this.cookieUrl=e.CookieURL,this.channelId=e.ChannelID,this.expiry=e.Expiry,this.browserCookieName=e.BrowserCookieName,this.gtmConsentType=e.GtmConsentType}CreateScript(e){this.cookieId=e.cookieId,this.scriptName=e.scriptName,this.scriptDescription=e.scriptDescription,this.isStrictlyNecessary=e.isStrictlyNecessary,this.isRunFirst=e.isRunFirst,this.executionOrder=e.executionOrder,this.bodyOptIn=e.bodyOptIn,this.bodyOptOut=e.bodyOptOut,this.headOptIn=e.headOptIn,this.headOptOut=e.headOptOut,this.cookieUrl=e.cookieUrl,this.channelId=e.channelID,this.gtmConsentType=e.gtmConsentType}}(e);this.cassieScripts.push(t)})),!(e.AccessKeys?.split(",").map((e=>e.toLowerCase().trim()))??[]).includes(this.cassieSettings.profileSettings.AccessKey.toLowerCase().trim())&&"n/a"!==this.cassieSettings.profileSettings.AccessKey&&!this.cassieSettings?.customOptions?.isPreview)throw new Error(`Access Key: ${this.cassieSettings.profileSettings.AccessKey}\n can't access widget with id: ${this.cassieSettings.widgetId}`);const t=e.SupportedDomains;if(t&&!this.urlHelper.checkDomain(t)&&!this.cassieSettings?.customOptions?.isPreview)throw new Error(`Not supported domain: ${this.domain} the supported domains are ${t}.\n Please add this domain to your Cassie system`);this.cassieSettings.supportedDomains=t,this.widgetTemplate=e.Template,this.widgetTemplate.strictlyNecessary=e.Scripts.filter((e=>e.IsStrictlyNecessary)).map((e=>({cookieName:e.CookieName,cookieDescription:e.CookieDescription}))),this.widgetTemplate.Services=e.Scripts}}(i),this.isLoading=!1}getProfiler(){return this.crossDomainConsent?new Promise((e=>{try{e(this.crossDomainConsent?"true":null)}catch(t){this.error.isError=!0,this.error.errorMessage=t,e(!1)}})):Promise.resolve(null)}getWidget(){return new Promise((async(e,t)=>{try{e(await n(this.widgetLocation))}catch(e){t(e)}}))}getWidgetUrl(e){return`${this.baseUrl}/versions/${e??"4"}/widget.js`}getBaseUrl(){if(this.customServerPath)return this.customServerPath;const e="production"===this.environment?"":`-${this.environment}`,t=window?.cassieResourceRootDomain??"cassiecloud.com";return`https://cscript-cdn-${this.region}${e}.${t}`}getProfileUrl(){return this.widgetProfileUrl?this.widgetProfileUrl:`${this.getBaseUrl()}/${this.licenseKey}/widgetProfile/widgetProfile_${this.widgetProfileId}.json`}loadScriptToDOM(e){const t=document.createElement("script");t.innerHTML=e,document.body.appendChild(t)}loadExternalScriptToDOM(e){const t=document.createElement("script");t.src=e,document.body.appendChild(t)}compactFormatKeyValueToJson(e){if(!e||"string"!=typeof e||""===e.trim())return[];let t=[],i=e.split("|"),n={};return i.forEach((e=>{let[i,s]=e.split(":");i&&void 0!==s?n[i]=s:(t.push(n),n={})})),Object.keys(n).length>0&&t.push(n),t}getSyrenisGtmConsent(){const e=this.profileSettings.AccessKey;let t="";const i=document.cookie.split(";");for(let n=0;n