/*! js-cookie v3.0.5 | MIT */
function t(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)t[n]=i[n];}return t}var e=function e(i,n){function s(e,s,o){if("undefined"!=typeof document){"number"==typeof(o=t({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var h in o)o[h]&&(r+="; "+h,!0!==o[h]&&(r+="="+o[h].split(";")[0]));return document.cookie=e+"="+i.write(s,e)+r}}return Object.create({set:s,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split("; "):[],n={},s=0;s<e.length;s++){var o=e[s].split("="),r=o.slice(1).join("=");try{var h=decodeURIComponent(o[0]);if(n[h]=i.read(r,h),t===h)break}catch(t){}}return t?n[t]:n}},remove:function(e,i){s(e,"",t({},i,{expires:-1}));},withAttributes:function(i){return e(this.converter,t({},this.attributes,i))},withConverter:function(i){return e(t({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(i)}})}({read:function(t){return '"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});window.UniGrazCmpLibrary=new class{constructor(){this.reset(),this.update();}reset(){this.htmlElement=document.querySelector("html"),this.webservice=this.htmlElement.dataset.unigrazCmpWebservice||"https://webcmp.uni-graz.at",this.siteId=parseInt(this.htmlElement.dataset.unigrazCmpSiteId),this.config={id:0,name:"",cookieDomain:".uni-graz.at",bannerHtml:"",btnAllowAll:"",btnDenyAll:"",btnSettings:"",btnSave:"",settingsHtml:"",groups:[]},this.configFetched=!1,this.updateCallbacks=[],this.cookieName="unigraz-cmp-consent-"+this.siteId,this.cookiePath="/",this.cookieDuration=365,this.consents=[];}update(){this.fetchConfig().then((()=>{this.readCookie(),this.configFetched=!0,this.executeUpdateCallbacks();}));}persist(){this.saveCookie(),this.executeUpdateCallbacks();}async fetchConfig(){if(this.webservice.length&&this.siteId){const t=await fetch(this.webservice+"/sites/"+this.siteId,{headers:{Accept:"application/json"}});if(t.ok){const e=await t.json(),i=await e;this.config=i;}}}getConfig(){return this.config}getAllServiceIds(){let t=[];return this.config.groups.forEach((e=>{e.services.forEach((e=>{t.includes(e.id)||t.push(e.id);}));})),t}getRequiredServiceIds(){let t=[];return this.config.groups.forEach((e=>{"required"===e.type&&e.services.forEach((e=>{t.includes(e.id)||t.push(e.id);}));})),t}readCookie(){const t=e.get(this.cookieName);"string"==typeof t&&(this.consents=JSON.parse(t));}saveCookie(){const t=JSON.stringify(this.consents.sort());let i={path:this.cookiePath,domain:this.config.cookieDomain,expires:this.cookieDuration};e.set(this.cookieName,t,i);}getConsentsGiven(){return this.consents}hasConsentGiven(t){return this.consents.includes(t)}giveConsents(t){t.forEach((t=>{this.consents.includes(t)||this.consents.push(t);}));}giveConsent(t){this.giveConsents([t]);}giveAllConsents(){const t=this.getAllServiceIds();this.giveConsents(t);}giveSelectedConsentsIncludeRequired(t){t=t.concat(this.getRequiredServiceIds()),this.giveConsents(t);}giveRequiredConsents(){const t=this.getRequiredServiceIds();this.giveConsents(t);}revokeConsents(t){t.forEach((t=>{const e=this.consents.indexOf(t);e>=0&&this.consents.splice(e,1);}));}revokeConsent(t){this.revokeConsents([t]);}registerUpdateCallback(t){this.updateCallbacks.push(t),this.configFetched&&t();}executeUpdateCallbacks(){this.updateCallbacks.forEach((t=>{t();}));}};
