Socket
Socket
Sign inDemoInstall

vanilla-cookieconsent

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-cookieconsent - npm Package Compare versions

Comparing version 2.9.1 to 2.9.2

4

dist/cookieconsent.js
/*!
* CookieConsent v2.9.0
* CookieConsent v2.9.2
* https://www.github.com/orestbida/cookieconsent

@@ -7,2 +7,2 @@ * Author Orest Bida

*/
!function(){'use strict';var n='initCookieConsent';'undefined'!=typeof window&&'function'!=typeof window[n]&&(window[n]=function(n){var t,e,o,i,r,a,c,f,u,d,v,l,s,p,b,m,y,g,h,_,w,k,x,S,J,O,j,N,T,D,C,U,z,E,I,L={mode:'opt-in',current_lang:'en',auto_language:null,autorun:!0,page_scripts:!0,hide_from_bots:!0,cookie_name:'cc_cookie',cookie_expiration:182,cookie_domain:location.hostname,cookie_path:'/',cookie_same_site:'Lax',use_rfc_cookie:!1,autoclear_cookies:!0,revision:0,script_selector:'data-cookiecategory'},M={},R={},A=null,G=!0,H=!1,P=!1,q=!1,B=!1,F=!0,K=[],Q=!1,V=[],W=[],X=[],Y=!1,Z=[],$=[],nn=[],tn=[],en=[],on=document.documentElement,rn=function(n){'number'==typeof(t=n).cookie_expiration&&(L.cookie_expiration=t.cookie_expiration),'number'==typeof t.cookie_necessary_only_expiration&&(L.cookie_necessary_only_expiration=t.cookie_necessary_only_expiration),'boolean'==typeof t.autorun&&(L.autorun=t.autorun),'string'==typeof t.cookie_domain&&(L.cookie_domain=t.cookie_domain),'string'==typeof t.cookie_same_site&&(L.cookie_same_site=t.cookie_same_site),'string'==typeof t.cookie_path&&(L.cookie_path=t.cookie_path),'string'==typeof t.cookie_name&&(L.cookie_name=t.cookie_name),'function'==typeof t.onAccept&&(v=t.onAccept),'function'==typeof t.onFirstAction&&(s=t.onFirstAction),'function'==typeof t.onChange&&(l=t.onChange),'opt-out'===t.mode&&(L.mode='opt-out'),'number'==typeof t.revision&&(t.revision>-1&&(L.revision=t.revision),B=!0),'boolean'==typeof t.autoclear_cookies&&(L.autoclear_cookies=t.autoclear_cookies),!0===t.use_rfc_cookie&&(L.use_rfc_cookie=!0),'boolean'==typeof t.hide_from_bots&&(L.hide_from_bots=t.hide_from_bots),L.hide_from_bots&&(Y=navigator&&(navigator.userAgent&&/bot|crawl|spider|slurp|teoma/i.test(navigator.userAgent)||navigator.webdriver)),L.page_scripts=!0===t.page_scripts,'browser'===t.auto_language||!0===t.auto_language?L.auto_language='browser':'document'===t.auto_language&&(L.auto_language='document'),L.auto_language,L.current_lang=sn(t.languages,t.current_lang)},an=function(n){for(var t='accept-',e=c('c-settings'),o=c(t+'all'),i=c(t+'necessary'),r=c(t+'custom'),a=0;a<e.length;a++)e[a].setAttribute('aria-haspopup','dialog'),wn(e[a],'click',(function(n){n.preventDefault(),M.showSettings(0)}));for(a=0;a<o.length;a++)wn(o[a],'click',(function(n){f(n,'all')}));for(a=0;a<r.length;a++)wn(r[a],'click',(function(n){f(n)}));for(a=0;a<i.length;a++)wn(i[a],'click',(function(n){f(n,[])}));function c(t){return(n||document).querySelectorAll('[data-cc="'+t+'"]')}function f(n,t){n.preventDefault(),M.accept(t),M.hideSettings(),M.hide()}},cn=function(n,t){return t.hasOwnProperty(n)?n:kn(t).length>0?t.hasOwnProperty(L.current_lang)?L.current_lang:kn(t)[0]:void 0},fn=function(n){if(!0===t.force_consent&&xn(on,'force--consent'),!h){h=ln('div');var e=ln('div'),o=ln('div');h.id='cm',e.id='c-inr-i',o.id='cm-ov',h.tabIndex=-1,h.setAttribute('role','dialog'),h.setAttribute('aria-modal','true'),h.setAttribute('aria-hidden','false'),h.setAttribute('aria-labelledby','c-ttl'),h.setAttribute('aria-describedby','c-txt'),g.appendChild(h),g.appendChild(o),h.style.visibility=o.style.visibility='hidden',o.style.opacity=0}var i=t.languages[n].consent_modal.title;i&&(_||((_=ln('div')).id='c-ttl',_.setAttribute('role','heading'),_.setAttribute('aria-level','2'),e.appendChild(_)),_.innerHTML=i);var r=t.languages[n].consent_modal.description;B&&(r=F?r.replace('{{revision_message}}',''):r.replace('{{revision_message}}',t.languages[n].consent_modal.revision_message||'')),w||((w=ln('div')).id='c-txt',e.appendChild(w)),w.innerHTML=r;var a,c=t.languages[n].consent_modal.primary_btn,f=t.languages[n].consent_modal.secondary_btn;c&&(k||((k=ln('button')).id='c-p-bn',k.className='c-bn',k.appendChild(On(1)),'accept_all'===c.role&&(a='all'),wn(k,'click',(function(){M.hide(),M.accept(a)}))),k.firstElementChild.innerHTML=t.languages[n].consent_modal.primary_btn.text),f&&(x||((x=ln('button')).id='c-s-bn',x.className='c-bn c_link',x.appendChild(On(1)),'accept_necessary'===f.role?wn(x,'click',(function(){M.hide(),M.accept([])})):wn(x,'click',(function(){M.showSettings(0)}))),x.firstElementChild.innerHTML=t.languages[n].consent_modal.secondary_btn.text);var u=t.gui_options;J||((J=ln('div')).id='c-inr',J.appendChild(e)),S||((S=ln('div')).id='c-bns',u&&u.consent_modal&&!0===u.consent_modal.swap_buttons?(f&&S.appendChild(x),c&&S.appendChild(k),S.className='swap'):(c&&S.appendChild(k),f&&S.appendChild(x)),(c||f)&&J.appendChild(S),h.appendChild(J)),H=!0,an(J)},un=function(n){if(O)(C=ln('div')).id='s-bl';else{(O=ln('div')).tabIndex=-1;var e=ln('div'),o=ln('div'),i=ln('div');j=ln('div'),N=ln('div');var r=ln('div');(T=ln('button')).appendChild(On(2));var a=ln('div');D=ln('div');var c=ln('div');wn(i,'click',(function(n){q&&!j.contains(n.target)&&M.hideSettings()}),!0),O.id='s-cnt',e.id='c-vln',i.id='c-s-in',o.id='cs',N.id='s-ttl',j.id='s-inr',r.id='s-hdr',D.id='s-bl',T.id='s-c-bn',c.id='cs-ov',a.id='s-c-bnc',T.className='c-bn',O.setAttribute('role','dialog'),O.setAttribute('aria-modal','true'),O.setAttribute('aria-hidden','true'),O.setAttribute('aria-labelledby','s-ttl'),N.setAttribute('role','heading'),O.style.visibility=c.style.visibility='hidden',c.style.opacity=0,a.appendChild(T),wn(document,'keydown',(function(n){27===n.keyCode&&q&&M.hideSettings()}),!0),wn(T,'click',(function(){M.hideSettings()}))}var f=t.languages[n].settings_modal;T.setAttribute('aria-label',f.close_btn_label||'Close'),d=f.blocks,u=f.cookie_table_headers;var v=f.cookie_table_caption,l=d.length;N.innerHTML=f.title;for(var s=0;s<l;++s){var p=d[s].title,b=d[s].description,m=d[s].toggle,y=d[s].cookie_table,h=!0===t.remove_cookie_tables,_=!!b||!h&&!!y,w=ln('div'),k=ln('div');if(b){var x=ln('div');x.className='p',x.insertAdjacentHTML('beforeend',b)}var S=ln('div');if(S.className='title',w.className='c-bl',k.className='desc',void 0!==m){var J='c-ac-'+s,L=ln(_?'button':'div'),A=ln('label'),H=ln('input'),P=ln('span'),B=ln('span'),F=ln('span'),K=ln('span');L.className=_?'b-tl exp':'b-tl',A.className='b-tg',H.className='c-tgl',F.className='on-i',K.className='off-i',P.className='c-tg',B.className='t-lb',_&&(L.setAttribute('aria-expanded','false'),L.setAttribute('aria-controls',J)),H.type='checkbox',P.setAttribute('aria-hidden','true');var Q=m.value;H.value=Q,B.textContent=p,L.insertAdjacentHTML('beforeend',p),S.appendChild(L),P.appendChild(F),P.appendChild(K),G?m.enabled?(H.checked=!0,!C&&nn.push(!0),m.enabled&&!C&&X.push(Q)):!C&&nn.push(!1):vn(R.categories,Q)>-1?(H.checked=!0,!C&&nn.push(!0)):!C&&nn.push(!1),!C&&tn.push(Q),m.readonly&&(H.disabled=!0,xn(P,'c-ro'),!C&&en.push(Q)),xn(k,'b-acc'),xn(S,'b-bn'),xn(w,'b-ex'),k.id=J,k.setAttribute('aria-hidden','true'),A.appendChild(H),A.appendChild(P),A.appendChild(B),S.appendChild(A),_&&function(n,t,e){wn(L,'click',(function(){Jn(t,'act')?(Sn(t,'act'),e.setAttribute('aria-expanded','false'),n.setAttribute('aria-hidden','true')):(xn(t,'act'),e.setAttribute('aria-expanded','true'),n.setAttribute('aria-hidden','false'))}),!1)}(k,w,L)}else if(p){var V=ln('div');V.className='b-tl',V.setAttribute('role','heading'),V.setAttribute('aria-level','3'),V.insertAdjacentHTML('beforeend',p),S.appendChild(V)}if(p&&w.appendChild(S),b&&k.appendChild(x),!h&&void 0!==y){for(var W=document.createDocumentFragment(),Y=0;Y<u.length;++Y){var Z=ln('th'),$=u[Y];if(Z.setAttribute('scope','col'),$){var on=$&&kn($)[0];Z.textContent=u[Y][on],W.appendChild(Z)}}var rn=ln('tr');rn.appendChild(W);var an=ln('thead');an.appendChild(rn);var cn=ln('table');if(v){var fn=ln('caption');fn.innerHTML=v,cn.appendChild(fn)}cn.appendChild(an);for(var un=document.createDocumentFragment(),dn=0;dn<y.length;dn++){for(var sn=ln('tr'),pn=0;pn<u.length;++pn)if($=u[pn]){on=kn($)[0];var bn=ln('td');bn.insertAdjacentHTML('beforeend',y[dn][on]),bn.setAttribute('data-column',$[on]),sn.appendChild(bn)}un.appendChild(sn)}var mn=ln('tbody');mn.appendChild(un),cn.appendChild(mn),k.appendChild(cn)}(m&&p||!m&&(p||b))&&(w.appendChild(k),C?C.appendChild(w):D.appendChild(w))}U||((U=ln('div')).id='s-bns'),E||((E=ln('button')).id='s-all-bn',E.className='c-bn',U.appendChild(E),wn(E,'click',(function(){M.accept('all'),M.hideSettings(),M.hide()}))),E.innerHTML=f.accept_all_btn;var yn=f.reject_all_btn;if(yn&&(I||((I=ln('button')).id='s-rall-bn',I.className='c-bn',wn(I,'click',(function(){M.accept([]),M.hideSettings(),M.hide()})),j.className='bns-t',U.appendChild(I)),I.innerHTML=yn),z||((z=ln('button')).id='s-sv-bn',z.className='c-bn',U.appendChild(z),wn(z,'click',(function(){M.accept(),M.hideSettings(),M.hide()}))),z.innerHTML=f.save_settings_btn,C)return j.replaceChild(C,D),void(D=C);r.appendChild(N),r.appendChild(a),j.appendChild(r),j.appendChild(D),j.appendChild(U),i.appendChild(j),o.appendChild(i),e.appendChild(o),O.appendChild(e),g.appendChild(O),g.appendChild(c)};M.updateLanguage=function(n,e){if('string'==typeof n){var o=cn(n,t.languages);return(o!==L.current_lang||!0===e)&&(L.current_lang=o,H&&fn(o),un(o),!0)}};var dn=function(n){var t=d.length,e=-1;Q=!1;var o=hn('','all'),i=[L.cookie_domain,'.'+L.cookie_domain];if('www.'===L.cookie_domain.slice(0,4)){var r=L.cookie_domain.substr(4);i.push(r),i.push('.'+r)}for(var a=0;a<t;a++){var c=d[a];if(c.hasOwnProperty('toggle')){var f=vn(K,c.toggle.value)>-1;if(!nn[++e]&&c.hasOwnProperty('cookie_table')&&(n||f)){var v=c.cookie_table,l=kn(u[0])[0],s=v.length;'on_disable'===c.toggle.reload&&f&&(Q=!0);for(var p=0;p<s;p++){var b=i,m=v[p],y=[],g=m[l],h=m.is_regex||!1,_=m.domain||null,w=m.path||!1;if(_&&(b=[_,'.'+_]),h)for(var k=0;k<o.length;k++)o[k].match(g)&&y.push(o[k]);else{var x=vn(o,g);x>-1&&y.push(o[x])}y.length>0&&(_n(y,w,b),'on_clear'===c.toggle.reload&&(Q=!0))}}}}},vn=function(n,t){return n.indexOf(t)},ln=function(n){var t=document.createElement(n);return'button'===n&&t.setAttribute('type',n),t},sn=function(n,t){return'browser'===L.auto_language?cn(pn(),n):'document'===L.auto_language?cn(document.documentElement.lang,n):'string'==typeof t?L.current_lang=cn(t,n):(L.current_lang,L.current_lang)},pn=function(){var n=navigator.language||navigator.browserLanguage;return n.length>2&&(n=n[0]+n[1]),n.toLowerCase()};M.allowedCategory=function(n){if(G&&'opt-in'!==L.mode)t=X;else var t=JSON.parse(hn(L.cookie_name,'one',!0)||'{}').categories||[];return vn(t,n)>-1},M.run=function(t){if(!document.getElementById('cc_div')){if(rn(t),Y)return;R=JSON.parse(hn(L.cookie_name,'one',!0)||'{}');var c=void 0!==(i=R.consent_uuid);if((e=R.consent_date)&&(e=new Date(e)),(o=R.last_consent_update)&&(o=new Date(o)),A=void 0!==R.data?R.data:null,B&&R.revision!==L.revision&&(F=!1),H=G=!(c&&F&&e&&o&&i),function(){(y=ln('div')).id='cc--main',y.style.position='fixed',y.innerHTML='<div id="cc_div" class="cc_div"></div>',g=y.children[0];var t=L.current_lang;H&&fn(t),un(t),(n||document.body).appendChild(y)}(),function(){var n=['[href]','button','input','details','[tabindex="0"]'];function t(t,e){var o=!1,i=!1;try{for(var r,a=t.querySelectorAll(n.join(':not([tabindex="-1"]), ')),c=a.length,f=0;f<c;)r=a[f].getAttribute('data-focus'),i||'1'!==r?'0'===r&&(o=a[f],i||'0'===a[f+1].getAttribute('data-focus')||(i=a[f+1])):i=a[f],f++}catch(e){return t.querySelectorAll(n.join(', '))}e[0]=a[0],e[1]=a[a.length-1],e[2]=o,e[3]=i}t(j,$),H&&t(h,Z)}(),function(n,t){if('object'==typeof n){var e=n.consent_modal,o=n.settings_modal;H&&e&&i(h,['box','bar','cloud'],['top','middle','bottom'],['zoom','slide'],e.layout,e.position,e.transition),o&&i(O,['bar'],['left','right'],['zoom','slide'],o.layout,o.position,o.transition)}function i(n,t,e,o,i,r,a){if(r=r&&r.split(' ')||[],vn(t,i)>-1&&(xn(n,i),('bar'!==i||'middle'!==r[0])&&vn(e,r[0])>-1))for(var c=0;c<r.length;c++)xn(n,r[c]);vn(o,a)>-1&&xn(n,a)}}(t.gui_options),an(),L.autorun&&H&&M.show(t.delay||0),setTimeout((function(){xn(y,'c--anim')}),30),setTimeout((function(){wn(document,'keydown',(function(n){if('Tab'===n.key&&(P||q)&&r){var t=Tn();n.shiftKey?t!==r[0]&&a.contains(t)||(n.preventDefault(),jn(r[1])):t!==r[1]&&a.contains(t)||(n.preventDefault(),jn(r[0]))}}))}),100),G)'opt-out'===L.mode&&(L.mode,bn(X));else{var f='boolean'==typeof R.rfc_cookie;(!f||f&&R.rfc_cookie!==L.use_rfc_cookie)&&(R.rfc_cookie=L.use_rfc_cookie,gn(L.cookie_name,JSON.stringify(R))),p=yn(mn()),bn(),'function'==typeof v&&v(R)}}};var bn=function(n){if(L.page_scripts){var t=document.querySelectorAll('script['+L.script_selector+']'),e=n||R.categories||[],o=function(n,t){if(t<n.length){var i=n[t],r=i.getAttribute(L.script_selector);if(vn(e,r)>-1){i.type=i.getAttribute('data-type')||'text/javascript',i.removeAttribute(L.script_selector);var a=i.getAttribute('data-src');a&&i.removeAttribute('data-src');var c=ln('script');if(c.textContent=i.innerHTML,function(n,t){for(var e=t.attributes,o=e.length,i=0;i<o;i++){var r=e[i].nodeName;n.setAttribute(r,t[r]||t.getAttribute(r))}}(c,i),a?c.src=a:a=i.src,a&&(c.readyState?c.onreadystatechange=function(){'loaded'!==c.readyState&&'complete'!==c.readyState||(c.onreadystatechange=null,o(n,++t))}:c.onload=function(){c.onload=null,o(n,++t)}),i.parentNode.replaceChild(c,i),a)return}o(n,++t)}};o(t,0)}};M.set=function(n,t){return'data'===n&&function(n,t){var e=!1;if('update'===t){var o=typeof(A=M.get('data'))==typeof n;if(o&&'object'==typeof A)for(var i in!A&&(A={}),n)A[i]!==n[i]&&(A[i]=n[i],e=!0);else!o&&A||A===n||(A=n,e=!0)}else A=n,e=!0;return e&&(R.data=A,gn(L.cookie_name,JSON.stringify(R))),e}(t.value,t.mode)},M.get=function(n,t){return JSON.parse(hn(t||L.cookie_name,'one',!0)||'{}')[n]},M.getConfig=function(n){return L[n]||t[n]};var mn=function(){return V=R.categories||[],W=tn.filter((function(n){return-1===vn(V,n)})),{accepted:V,rejected:W}},yn=function(n){var t='custom',e=en.length;return n.accepted.length===tn.length?t='all':n.accepted.length===e&&(t='necessary'),t};M.getUserPreferences=function(){var n=mn();return{accept_type:yn(n),accepted_categories:n.accepted,rejected_categories:n.rejected}},M.loadScript=function(n,t,e){var o='function'==typeof t;if(document.querySelector('script[src="'+n+'"]'))o&&t();else{var i=ln('script');if(e&&e.length>0)for(var r=0;r<e.length;++r)e[r]&&i.setAttribute(e[r].name,e[r].value);o&&(i.onload=t),i.src=n,document.head.appendChild(i)}},M.updateScripts=function(){bn()},M.show=function(n,t){!0===t&&fn(L.current_lang),H&&(b=Tn(),r=Z,a=h,P=!0,h.removeAttribute('aria-hidden'),setTimeout((function(){xn(on,'show--consent')}),n>0?n:t?30:0))},M.hide=function(){H&&(P=!1,jn(c),h.setAttribute('aria-hidden','true'),Sn(on,'show--consent'),jn(b),b=null)},M.showSettings=function(n){q=!0,O.removeAttribute('aria-hidden'),P?m=Tn():b=Tn(),a=O,r=$,setTimeout((function(){xn(on,'show--settings')}),n>0?n:0)},M.hideSettings=function(){q=!1,Nn(),jn(f),O.setAttribute('aria-hidden','true'),Sn(on,'show--settings'),P?(jn(m),m=null,a=h,r=Z):(jn(b),b=null)},M.accept=function(n,t){var r=n||void 0,a=t||[],c=[];if(r)if('object'==typeof r&&'number'==typeof r.length)for(var f=0;f<r.length;f++)-1!==vn(tn,r[f])&&c.push(r[f]);else'string'==typeof r&&('all'===r?c=tn.slice():-1!==vn(tn,r)&&c.push(r));else c=function(){for(var n=document.querySelectorAll('.c-tgl')||[],t=[],e=0;e<n.length;e++)n[e].checked&&t.push(n[e].value);return t}();if(a.length>=1)for(f=0;f<a.length;f++)c=c.filter((function(n){return n!==a[f]}));for(f=0;f<tn.length;f++)!0===en.includes(tn[f])&&-1===vn(c,tn[f])&&c.push(tn[f]);!function(n){K=[];var t=O.querySelectorAll('.c-tgl')||[];if(t.length>0)for(var r=0;r<t.length;r++)-1!==vn(n,tn[r])?(t[r].checked=!0,nn[r]||(K.push(tn[r]),nn[r]=!0)):(t[r].checked=!1,nn[r]&&(K.push(tn[r]),nn[r]=!1));!G&&L.autoclear_cookies&&K.length>0&&dn(),e||(e=new Date),i||(i=([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(n){try{return(n^(window.crypto||window.msCrypto).getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}catch(n){return''}}))),R={categories:n,level:n,revision:L.revision,data:A,rfc_cookie:L.use_rfc_cookie,consent_date:e.toISOString(),consent_uuid:i},(G||K.length>0)&&(F=!0,o=o?new Date:e,R.last_consent_update=o.toISOString(),p=yn(mn()),gn(L.cookie_name,JSON.stringify(R)),bn()),G&&(L.autoclear_cookies&&dn(!0),'function'==typeof s&&s(M.getUserPreferences(),R),'function'==typeof v&&v(R),G=!1,'opt-in'===L.mode)||('function'==typeof l&&K.length>0&&l(R,K),Q&&location.reload())}(c)},M.eraseCookies=function(n,t,e){var o=[],i=e?[e,'.'+e]:[L.cookie_domain,'.'+L.cookie_domain];if('object'==typeof n&&n.length>0)for(var r=0;r<n.length;r++)this.validCookie(n[r])&&o.push(n[r]);else this.validCookie(n)&&o.push(n);_n(o,t,i)};var gn=function(n,t){var e=L.cookie_expiration;'number'==typeof L.cookie_necessary_only_expiration&&'necessary'===p&&(e=L.cookie_necessary_only_expiration),t=L.use_rfc_cookie?encodeURIComponent(t):t;var o=new Date;o.setTime(o.getTime()+24*e*60*60*1e3);var i=n+'='+(t||'')+'; expires='+o.toUTCString()+'; Path='+L.cookie_path+';';i+=' SameSite='+L.cookie_same_site+';',location.hostname.indexOf('.')>-1&&L.cookie_domain&&(i+=' Domain='+L.cookie_domain+';'),'https:'===location.protocol&&(i+=' Secure;'),document.cookie=i},hn=function(n,t,e){var o;if('one'===t){if((o=(o=document.cookie.match('(^|;)\\s*'+n+'\\s*=\\s*([^;]+)'))?e?o.pop():n:'')&&n===L.cookie_name){try{o=JSON.parse(o)}catch(n){try{o=JSON.parse(decodeURIComponent(o))}catch(n){o={}}}o=JSON.stringify(o)}}else if('all'===t){var i=document.cookie.split(/;\s*/);o=[];for(var r=0;r<i.length;r++)o.push(i[r].split('=')[0])}return o},_n=function(n,t,e){for(var o=t||'/',i=0;i<n.length;i++){for(var r=0;r<e.length;r++)document.cookie=n[i]+'=; path='+o+(0==e[r].indexOf('.')?'; domain='+e[r]:'')+'; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';n[i]}};M.validCookie=function(n){return''!==hn(n,'one',!0)};var wn=function(n,t,e,o){n.addEventListener(t,e,!0===o&&{passive:!0})},kn=function(n){if('object'==typeof n)return Object.keys(n)},xn=function(n,t){n.classList.add(t)},Sn=function(n,t){n.classList.remove(t)},Jn=function(n,t){return n.classList.contains(t)},On=function(n){var t=ln('span');return t.tabIndex=-1,1===n?c=t:f=t,t},jn=function(n){n&&n instanceof HTMLElement&&n.focus()},Nn=function(){for(var n=j.querySelectorAll('.c-tgl'),t=0;t<n.length;t++){var e=n[t].value,o=en.includes(e);n[t].checked=o||M.allowedCategory(e)}},Tn=function(){return document.activeElement};return M})}();
!function(){'use strict';var n='initCookieConsent';'undefined'!=typeof window&&'function'!=typeof window[n]&&(window[n]=function(n){var t,o,e,i,r,a,c,u,f,d,v,l,s,p,b,m,y,g,h,_,w,k,x,S,J,O,j,N,T,D,C,U,z,E,I,L={mode:'opt-in',current_lang:'en',auto_language:null,autorun:!0,page_scripts:!0,hide_from_bots:!0,cookie_name:'cc_cookie',cookie_expiration:182,cookie_domain:location.hostname,cookie_path:'/',cookie_same_site:'Lax',use_rfc_cookie:!1,autoclear_cookies:!0,revision:0,script_selector:'data-cookiecategory'},M={},R={},A=null,G=!0,H=!1,P=!1,q=!1,B=!1,F=!0,K=[],Q=!1,V=[],W=[],X=[],Y=!1,Z=[],$=[],nn=[],tn=[],on=[],en=document.documentElement,rn=function(n){'number'==typeof(t=n).cookie_expiration&&(L.cookie_expiration=t.cookie_expiration),'number'==typeof t.cookie_necessary_only_expiration&&(L.cookie_necessary_only_expiration=t.cookie_necessary_only_expiration),'boolean'==typeof t.autorun&&(L.autorun=t.autorun),'string'==typeof t.cookie_domain&&(L.cookie_domain=t.cookie_domain),'string'==typeof t.cookie_same_site&&(L.cookie_same_site=t.cookie_same_site),'string'==typeof t.cookie_path&&(L.cookie_path=t.cookie_path),'string'==typeof t.cookie_name&&(L.cookie_name=t.cookie_name),'function'==typeof t.onAccept&&(v=t.onAccept),'function'==typeof t.onFirstAction&&(s=t.onFirstAction),'function'==typeof t.onChange&&(l=t.onChange),'opt-out'===t.mode&&(L.mode='opt-out'),'number'==typeof t.revision&&(t.revision>-1&&(L.revision=t.revision),B=!0),'boolean'==typeof t.autoclear_cookies&&(L.autoclear_cookies=t.autoclear_cookies),!0===t.use_rfc_cookie&&(L.use_rfc_cookie=!0),'boolean'==typeof t.hide_from_bots&&(L.hide_from_bots=t.hide_from_bots),L.hide_from_bots&&(Y=navigator&&(navigator.userAgent&&/bot|crawl|spider|slurp|teoma/i.test(navigator.userAgent)||navigator.webdriver)),L.page_scripts=!0===t.page_scripts,'browser'===t.auto_language||!0===t.auto_language?L.auto_language='browser':'document'===t.auto_language&&(L.auto_language='document'),L.auto_language,L.current_lang=sn(t.languages,t.current_lang)},an=function(n){for(var t='accept-',o=c('c-settings'),e=c(t+'all'),i=c(t+'necessary'),r=c(t+'custom'),a=0;a<o.length;a++)o[a].setAttribute('aria-haspopup','dialog'),wn(o[a],'click',(function(n){n.preventDefault(),M.showSettings(0)}));for(a=0;a<e.length;a++)wn(e[a],'click',(function(n){u(n,'all')}));for(a=0;a<r.length;a++)wn(r[a],'click',(function(n){u(n)}));for(a=0;a<i.length;a++)wn(i[a],'click',(function(n){u(n,[])}));function c(t){return(n||document).querySelectorAll('[data-cc="'+t+'"]')}function u(n,t){n.preventDefault(),M.accept(t),M.hideSettings(),M.hide()}},cn=function(n,t){return t.hasOwnProperty(n)?n:kn(t).length>0?t.hasOwnProperty(L.current_lang)?L.current_lang:kn(t)[0]:void 0},un=function(n){if(!0===t.force_consent&&xn(en,'force--consent'),!h){h=ln('div');var o=ln('div'),e=ln('div');h.id='cm',o.id='c-inr-i',e.id='cm-ov',h.tabIndex=-1,h.setAttribute('role','dialog'),h.setAttribute('aria-modal','true'),h.setAttribute('aria-hidden','false'),h.setAttribute('aria-labelledby','c-ttl'),h.setAttribute('aria-describedby','c-txt'),g.appendChild(h),g.appendChild(e),h.style.visibility=e.style.visibility='hidden',e.style.opacity=0}var i=t.languages[n].consent_modal.title;i&&(_||((_=ln('h2')).id='c-ttl',o.appendChild(_)),_.innerHTML=i);var r=t.languages[n].consent_modal.description;B&&(r=F?r.replace('{{revision_message}}',''):r.replace('{{revision_message}}',t.languages[n].consent_modal.revision_message||'')),w||((w=ln('div')).id='c-txt',o.appendChild(w)),w.innerHTML=r;var a,c=t.languages[n].consent_modal.primary_btn,u=t.languages[n].consent_modal.secondary_btn;c&&(k||((k=ln('button')).id='c-p-bn',k.className='c-bn',k.appendChild(On(1)),'accept_all'===c.role&&(a='all'),wn(k,'click',(function(){M.hide(),M.accept(a)}))),k.firstElementChild.innerHTML=t.languages[n].consent_modal.primary_btn.text),u&&(x||((x=ln('button')).id='c-s-bn',x.className='c-bn c_link',x.appendChild(On(1)),'accept_necessary'===u.role?wn(x,'click',(function(){M.hide(),M.accept([])})):wn(x,'click',(function(){M.showSettings(0)}))),x.firstElementChild.innerHTML=t.languages[n].consent_modal.secondary_btn.text);var f=t.gui_options;J||((J=ln('div')).id='c-inr',J.appendChild(o)),S||((S=ln('div')).id='c-bns',f&&f.consent_modal&&!0===f.consent_modal.swap_buttons?(u&&S.appendChild(x),c&&S.appendChild(k),S.className='swap'):(c&&S.appendChild(k),u&&S.appendChild(x)),(c||u)&&J.appendChild(S),h.appendChild(J)),H=!0,an(J)},fn=function(n){if(O)(C=ln('div')).id='s-bl';else{(O=ln('div')).tabIndex=-1;var o=ln('div'),e=ln('div'),i=ln('div');j=ln('div'),N=ln('h2');var r=ln('div');(T=ln('button')).appendChild(On(2));var a=ln('div');D=ln('div');var c=ln('div'),u=!1;wn(O,'mouseup',(function(n){!q||u||j.contains(n.target)||M.hideSettings()})),wn(O,'mousedown',(function(n){q&&(u=j.contains(n.target))})),O.id='s-cnt',o.id='c-vln',i.id='c-s-in',e.id='cs',N.id='s-ttl',j.id='s-inr',r.id='s-hdr',D.id='s-bl',T.id='s-c-bn',c.id='cs-ov',a.id='s-c-bnc',T.className='c-bn',O.setAttribute('role','dialog'),O.setAttribute('aria-modal','true'),O.setAttribute('aria-hidden','true'),O.setAttribute('aria-labelledby','s-ttl'),O.style.visibility=c.style.visibility='hidden',c.style.opacity=0,a.appendChild(T),wn(document,'keydown',(function(n){27===n.keyCode&&q&&M.hideSettings()}),!0),wn(T,'click',(function(){M.hideSettings()}))}var v=t.languages[n].settings_modal;T.setAttribute('aria-label',v.close_btn_label||'Close'),d=v.blocks,f=v.cookie_table_headers;var l=v.cookie_table_caption,s=d.length;N.innerHTML=v.title;for(var p=0;p<s;++p){var b=d[p].title,m=d[p].description,y=d[p].toggle,h=d[p].cookie_table,_=!0===t.remove_cookie_tables,w=!!m||!_&&!!h,k=ln('div'),x=ln('div');if(m){var S=ln('div');S.className='p',S.insertAdjacentHTML('beforeend',m)}var J=ln('div');if(J.className='title',k.className='c-bl',x.className='desc',void 0!==y){var L='c-ac-'+p,A=ln(w?'button':'div'),H=ln('label'),P=ln('input'),B=ln('span'),F=ln('span'),K=ln('span'),Q=ln('span');A.className=w?'b-tl exp':'b-tl',H.className='b-tg',P.className='c-tgl',K.className='on-i',Q.className='off-i',B.className='c-tg',F.className='t-lb',w&&(A.setAttribute('aria-expanded','false'),A.setAttribute('aria-controls',L)),P.type='checkbox',B.setAttribute('aria-hidden','true');var V=y.value;P.value=V,F.textContent=b,A.insertAdjacentHTML('beforeend',b),J.appendChild(A),B.appendChild(K),B.appendChild(Q),G?y.enabled?(P.checked=!0,!C&&nn.push(!0),y.enabled&&!C&&X.push(V)):!C&&nn.push(!1):vn(R.categories,V)>-1?(P.checked=!0,!C&&nn.push(!0)):!C&&nn.push(!1),!C&&tn.push(V),y.readonly&&(P.disabled=!0,xn(B,'c-ro'),!C&&on.push(V)),xn(x,'b-acc'),xn(J,'b-bn'),xn(k,'b-ex'),x.id=L,x.setAttribute('aria-hidden','true'),H.appendChild(P),H.appendChild(B),H.appendChild(F),J.appendChild(H),w&&function(n,t,o){wn(A,'click',(function(){Jn(t,'act')?(Sn(t,'act'),o.setAttribute('aria-expanded','false'),n.setAttribute('aria-hidden','true')):(xn(t,'act'),o.setAttribute('aria-expanded','true'),n.setAttribute('aria-hidden','false'))}),!1)}(x,k,A)}else if(b){var W=ln('div');W.className='b-tl',W.setAttribute('role','heading'),W.setAttribute('aria-level','3'),W.insertAdjacentHTML('beforeend',b),J.appendChild(W)}if(b&&k.appendChild(J),m&&x.appendChild(S),!_&&void 0!==h){for(var Y=document.createDocumentFragment(),Z=0;Z<f.length;++Z){var $=ln('th'),en=f[Z];if($.setAttribute('scope','col'),en){var rn=en&&kn(en)[0];$.textContent=f[Z][rn],Y.appendChild($)}}var an=ln('tr');an.appendChild(Y);var cn=ln('thead');cn.appendChild(an);var un=ln('table');if(l){var fn=ln('caption');fn.innerHTML=l,un.appendChild(fn)}un.appendChild(cn);for(var dn=document.createDocumentFragment(),sn=0;sn<h.length;sn++){for(var pn=ln('tr'),bn=0;bn<f.length;++bn)if(en=f[bn]){rn=kn(en)[0];var mn=ln('td');mn.insertAdjacentHTML('beforeend',h[sn][rn]),mn.setAttribute('data-column',en[rn]),pn.appendChild(mn)}dn.appendChild(pn)}var yn=ln('tbody');yn.appendChild(dn),un.appendChild(yn),x.appendChild(un)}(y&&b||!y&&(b||m))&&(k.appendChild(x),C?C.appendChild(k):D.appendChild(k))}U||((U=ln('div')).id='s-bns'),E||((E=ln('button')).id='s-all-bn',E.className='c-bn',U.appendChild(E),wn(E,'click',(function(){M.accept('all'),M.hideSettings(),M.hide()}))),E.innerHTML=v.accept_all_btn;var gn=v.reject_all_btn;if(gn&&(I||((I=ln('button')).id='s-rall-bn',I.className='c-bn',wn(I,'click',(function(){M.accept([]),M.hideSettings(),M.hide()})),j.className='bns-t',U.appendChild(I)),I.innerHTML=gn),z||((z=ln('button')).id='s-sv-bn',z.className='c-bn',U.appendChild(z),wn(z,'click',(function(){M.accept(),M.hideSettings(),M.hide()}))),z.innerHTML=v.save_settings_btn,C)return j.replaceChild(C,D),void(D=C);r.appendChild(N),r.appendChild(a),j.appendChild(r),j.appendChild(D),j.appendChild(U),i.appendChild(j),e.appendChild(i),o.appendChild(e),O.appendChild(o),g.appendChild(O),g.appendChild(c)};M.updateLanguage=function(n,o){if('string'==typeof n){var e=cn(n,t.languages);return(e!==L.current_lang||!0===o)&&(L.current_lang=e,H&&un(e),fn(e),!0)}};var dn=function(n){var t=d.length,o=-1;Q=!1;var e=hn('','all'),i=[L.cookie_domain,'.'+L.cookie_domain];if('www.'===L.cookie_domain.slice(0,4)){var r=L.cookie_domain.substr(4);i.push(r),i.push('.'+r)}for(var a=0;a<t;a++){var c=d[a];if(c.hasOwnProperty('toggle')){var u=vn(K,c.toggle.value)>-1;if(!nn[++o]&&c.hasOwnProperty('cookie_table')&&(n||u)){var v=c.cookie_table,l=kn(f[0])[0],s=v.length;'on_disable'===c.toggle.reload&&u&&(Q=!0);for(var p=0;p<s;p++){var b=i,m=v[p],y=[],g=m[l],h=m.is_regex||!1,_=m.domain||null,w=m.path||!1;if(_&&(b=[_,'.'+_]),h)for(var k=0;k<e.length;k++)e[k].match(g)&&y.push(e[k]);else{var x=vn(e,g);x>-1&&y.push(e[x])}y.length>0&&(_n(y,w,b),'on_clear'===c.toggle.reload&&(Q=!0))}}}}},vn=function(n,t){return n.indexOf(t)},ln=function(n){var t=document.createElement(n);return'button'===n&&t.setAttribute('type',n),t},sn=function(n,t){return'browser'===L.auto_language?cn(pn(),n):'document'===L.auto_language?cn(document.documentElement.lang,n):'string'==typeof t?L.current_lang=cn(t,n):(L.current_lang,L.current_lang)},pn=function(){var n=navigator.language||navigator.browserLanguage;return n.length>2&&(n=n[0]+n[1]),n.toLowerCase()};M.allowedCategory=function(n){if(G&&'opt-in'!==L.mode)t=X;else var t=JSON.parse(hn(L.cookie_name,'one',!0)||'{}').categories||[];return vn(t,n)>-1},M.run=function(t){if(!document.getElementById('cc_div')){if(rn(t),Y)return;R=JSON.parse(hn(L.cookie_name,'one',!0)||'{}');var c=void 0!==(i=R.consent_uuid);if((o=R.consent_date)&&(o=new Date(o)),(e=R.last_consent_update)&&(e=new Date(e)),A=void 0!==R.data?R.data:null,B&&R.revision!==L.revision&&(F=!1),H=G=!(c&&F&&o&&e&&i),function(){(y=ln('div')).id='cc--main',y.style.position='fixed',y.innerHTML='<div id="cc_div" class="cc_div"></div>',g=y.children[0];var t=L.current_lang;H&&un(t),fn(t),(n||document.body).appendChild(y)}(),function(){var n=['[href]','button','input','details','[tabindex="0"]'];function t(t,o){try{var e=t.querySelectorAll(n.join(':not([tabindex="-1"]), '))}catch(o){return t.querySelectorAll(n.join(', '))}o[0]=e[0],o[1]=e[e.length-1]}t(j,$),H&&t(h,Z)}(),function(n,t){if('object'==typeof n){var o=n.consent_modal,e=n.settings_modal;H&&o&&i(h,['box','bar','cloud'],['top','middle','bottom'],['zoom','slide'],o.layout,o.position,o.transition),e&&i(O,['bar'],['left','right'],['zoom','slide'],e.layout,e.position,e.transition)}function i(n,t,o,e,i,r,a){if(r=r&&r.split(' ')||[],vn(t,i)>-1&&(xn(n,i),('bar'!==i||'middle'!==r[0])&&vn(o,r[0])>-1))for(var c=0;c<r.length;c++)xn(n,r[c]);vn(e,a)>-1&&xn(n,a)}}(t.gui_options),an(),L.autorun&&H&&M.show(t.delay||0),setTimeout((function(){xn(y,'c--anim')}),30),setTimeout((function(){wn(document,'keydown',(function(n){if('Tab'===n.key&&(P||q)&&r){var t=Tn();n.shiftKey?t!==r[0]&&a.contains(t)||(n.preventDefault(),jn(r[1])):t!==r[1]&&a.contains(t)||(n.preventDefault(),jn(r[0]))}}))}),100),G)'opt-out'===L.mode&&(L.mode,bn());else{var u='boolean'==typeof R.rfc_cookie;(!u||u&&R.rfc_cookie!==L.use_rfc_cookie)&&(R.rfc_cookie=L.use_rfc_cookie,gn(L.cookie_name,JSON.stringify(R))),p=yn(mn()),bn(),'function'==typeof v&&v(R)}}};var bn=function(){if(L.page_scripts){var n=R.categories||[];G&&'opt-out'===L.mode&&(n=X);var t=document.querySelectorAll('script['+L.script_selector+']'),o=function(t,e){if(e<t.length){var i=t[e],r=i.getAttribute(L.script_selector);if(vn(n,r)>-1){i.type=i.getAttribute('data-type')||'text/javascript',i.removeAttribute(L.script_selector);var a=i.getAttribute('data-src');a&&i.removeAttribute('data-src');var c=ln('script');if(c.textContent=i.innerHTML,function(n,t){for(var o=t.attributes,e=o.length,i=0;i<e;i++){var r=o[i].nodeName;n.setAttribute(r,t[r]||t.getAttribute(r))}}(c,i),a?c.src=a:a=i.src,a&&(c.readyState?c.onreadystatechange=function(){'loaded'!==c.readyState&&'complete'!==c.readyState||(c.onreadystatechange=null,o(t,++e))}:c.onload=function(){c.onload=null,o(t,++e)}),i.parentNode.replaceChild(c,i),a)return}o(t,++e)}};o(t,0)}};M.set=function(n,t){return'data'===n&&function(n,t){var o=!1;if('update'===t){var e=typeof(A=M.get('data'))==typeof n;if(e&&'object'==typeof A)for(var i in!A&&(A={}),n)A[i]!==n[i]&&(A[i]=n[i],o=!0);else!e&&A||A===n||(A=n,o=!0)}else A=n,o=!0;return o&&(R.data=A,gn(L.cookie_name,JSON.stringify(R))),o}(t.value,t.mode)},M.get=function(n,t){return JSON.parse(hn(t||L.cookie_name,'one',!0)||'{}')[n]},M.getConfig=function(n){return L[n]||t[n]};var mn=function(){return V=R.categories||[],W=tn.filter((function(n){return-1===vn(V,n)})),{accepted:V,rejected:W}},yn=function(n){var t='custom',o=on.length;return n.accepted.length===tn.length?t='all':n.accepted.length===o&&(t='necessary'),t};M.getUserPreferences=function(){var n=mn();return{accept_type:yn(n),accepted_categories:n.accepted,rejected_categories:n.rejected}},M.loadScript=function(n,t,o){var e='function'==typeof t;if(document.querySelector('script[src="'+n+'"]'))e&&t();else{var i=ln('script');if(o&&o.length>0)for(var r=0;r<o.length;++r)o[r]&&i.setAttribute(o[r].name,o[r].value);e&&(i.onload=t),i.src=n,document.head.appendChild(i)}},M.updateScripts=function(){bn()},M.show=function(n,t){!0===t&&un(L.current_lang),H&&(b=Tn(),r=Z,a=h,P=!0,h.removeAttribute('aria-hidden'),setTimeout((function(){xn(en,'show--consent')}),n>0?n:t?30:0))},M.hide=function(){H&&(P=!1,jn(c),h.setAttribute('aria-hidden','true'),Sn(en,'show--consent'),jn(b),b=null)},M.showSettings=function(n){q=!0,O.removeAttribute('aria-hidden'),P?m=Tn():b=Tn(),a=O,r=$,setTimeout((function(){xn(en,'show--settings')}),n>0?n:0)},M.hideSettings=function(){q=!1,Nn(),jn(u),O.setAttribute('aria-hidden','true'),Sn(en,'show--settings'),P?(jn(m),m=null,a=h,r=Z):(jn(b),b=null)},M.accept=function(n,t){var r=n||void 0,a=t||[],c=[];if(r)if('object'==typeof r&&'number'==typeof r.length)for(var u=0;u<r.length;u++)-1!==vn(tn,r[u])&&c.push(r[u]);else'string'==typeof r&&('all'===r?c=tn.slice():-1!==vn(tn,r)&&c.push(r));else c=function(){for(var n=document.querySelectorAll('.c-tgl')||[],t=[],o=0;o<n.length;o++)n[o].checked&&t.push(n[o].value);return t}();if(a.length>=1)for(u=0;u<a.length;u++)c=c.filter((function(n){return n!==a[u]}));for(u=0;u<tn.length;u++)!0===on.includes(tn[u])&&-1===vn(c,tn[u])&&c.push(tn[u]);!function(n){K=[];var t=O.querySelectorAll('.c-tgl')||[];if(t.length>0)for(var r=0;r<t.length;r++)-1!==vn(n,tn[r])?(t[r].checked=!0,nn[r]||(K.push(tn[r]),nn[r]=!0)):(t[r].checked=!1,nn[r]&&(K.push(tn[r]),nn[r]=!1));!G&&L.autoclear_cookies&&K.length>0&&dn(),o||(o=new Date),i||(i=([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(n){try{return(n^(window.crypto||window.msCrypto).getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}catch(n){return''}}))),R={categories:n,level:n,revision:L.revision,data:A,rfc_cookie:L.use_rfc_cookie,consent_date:o.toISOString(),consent_uuid:i},(G||K.length>0)&&(F=!0,e=e?new Date:o,R.last_consent_update=e.toISOString(),p=yn(mn()),gn(L.cookie_name,JSON.stringify(R)),bn()),G&&(L.autoclear_cookies&&dn(!0),'function'==typeof s&&s(M.getUserPreferences(),R),'function'==typeof v&&v(R),G=!1,'opt-in'===L.mode)||('function'==typeof l&&K.length>0&&l(R,K),Q&&location.reload())}(c)},M.eraseCookies=function(n,t,o){var e=[],i=o?[o,'.'+o]:[L.cookie_domain,'.'+L.cookie_domain];if('object'==typeof n&&n.length>0)for(var r=0;r<n.length;r++)this.validCookie(n[r])&&e.push(n[r]);else this.validCookie(n)&&e.push(n);_n(e,t,i)};var gn=function(n,t){var o=L.cookie_expiration;'number'==typeof L.cookie_necessary_only_expiration&&'necessary'===p&&(o=L.cookie_necessary_only_expiration),t=L.use_rfc_cookie?encodeURIComponent(t):t;var e=new Date;e.setTime(e.getTime()+24*o*60*60*1e3);var i=n+'='+(t||'')+'; expires='+e.toUTCString()+'; Path='+L.cookie_path+';';i+=' SameSite='+L.cookie_same_site+';',location.hostname.indexOf('.')>-1&&L.cookie_domain&&(i+=' Domain='+L.cookie_domain+';'),'https:'===location.protocol&&(i+=' Secure;'),document.cookie=i},hn=function(n,t,o){var e;if('one'===t){if((e=(e=document.cookie.match('(^|;)\\s*'+n+'\\s*=\\s*([^;]+)'))?o?e.pop():n:'')&&n===L.cookie_name){try{e=JSON.parse(e)}catch(n){try{e=JSON.parse(decodeURIComponent(e))}catch(n){e={}}}e=JSON.stringify(e)}}else if('all'===t){var i=document.cookie.split(/;\s*/);e=[];for(var r=0;r<i.length;r++)e.push(i[r].split('=')[0])}return e},_n=function(n,t,o){for(var e=t||'/',i=0;i<n.length;i++){for(var r=0;r<o.length;r++)document.cookie=n[i]+'=; path='+e+(0==o[r].indexOf('.')?'; domain='+o[r]:'')+'; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';n[i]}};M.validCookie=function(n){return''!==hn(n,'one',!0)},M.validConsent=function(){return!G};var wn=function(n,t,o,e){n.addEventListener(t,o,!0===e&&{passive:!0})},kn=function(n){if('object'==typeof n)return Object.keys(n)},xn=function(n,t){n.classList.add(t)},Sn=function(n,t){n.classList.remove(t)},Jn=function(n,t){return n.classList.contains(t)},On=function(n){var t=ln('span');return t.tabIndex=-1,1===n?c=t:u=t,t},jn=function(n){n&&n instanceof HTMLElement&&n.focus()},Nn=function(){for(var n=j.querySelectorAll('.c-tgl'),t=0;t<n.length;t++){var o=n[t].value,e=on.includes(o);n[t].checked=e||M.allowedCategory(o)}},Tn=function(){return document.activeElement};return M})}();
{
"name": "vanilla-cookieconsent",
"version": "v2.9.1",
"version": "v2.9.2",
"description": "🍪 Simple cross-browser cookie-consent plugin written in vanilla js.",

@@ -36,7 +36,7 @@ "main": "dist/cookieconsent.js",

"cssnano": "^6.0.1",
"postcss": "^8.4.23",
"postcss": "^8.4.27",
"postcss-cli": "^10.1.0",
"postcss-custom-properties": "^13.1.5",
"terser": "^5.17.3"
"postcss-custom-properties": "^13.3.0",
"terser": "^5.19.2"
}
}

@@ -20,14 +20,14 @@ <h1 align="center" style="text-align: center;">Cookie Consent</h1>

## Table of contents
- [Table of contents](#table-of-contents)
- [Key features](#key-features)
- [Installation & Usage](#installation--usage)
- [Layout options & customization](#layout-options--customization)
- [How to block/manage scripts](#how-to-blockmanage-scripts)
- [API methods](#api-methods)
- [Available `data-cc` actions](#available-data-cc-actions)
- [Available callbacks](#available-callbacks)
- [All configuration options](#all-configuration-options)
- [Full example configurations](#full-example-configurations)
- [How to configure languages & cookie settings](#how-to-configure-languages--cookie-settings)
- [How to enable/manage revisions](#how-to-enablemanage-revisions)
- [Installation & usage](#installation--usage)
- [How to block scripts](#how-to-blockmanage-scripts)
- [How to clear cookies](#how-to-clear-cookies)
- [Layout & customization](#layout-options--customization)
- [API](#api)
- [Callbacks](#available-callbacks)
- [Custom `data-cc` attribute](#custom-data-cc-attribute)
- [Configuration options](#configuration-options)
- [How to manage revisions](#how-to-manage-revisions)
- [How to share consent across subdomains](#how-to-share-consent-across-subdomains)
- [How to block iframes](#how-to-block-iframes)
- [FAQ](#faq)

@@ -38,3 +38,3 @@ - [License](#license)

- __Lightweight__
- __Cross-browser__ support (IE10+ [*](#note-css-variables-are-not-supported-on-ie))
- __Cross-browser__ support
- __Standalone__ (no external dependencies needed)

@@ -45,40 +45,44 @@ - __GDPR compliant__

- __[WAI-ARIA](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/WAI-ARIA_basics) compliant__
- Allows you to __define different cookie categories with opt in/out toggle__
- Allows you to __define custom cookie tables__ to specify the cookies you use
<br>
## Installation & Usage
1. Download the [latest release](https://github.com/orestbida/cookieconsent/releases/latest) or use via CDN or [NPM](https://www.npmjs.com/package/vanilla-cookieconsent)
1. Download the [latest release](https://github.com/orestbida/cookieconsent/releases/latest) or use via CDN/[NPM](https://www.npmjs.com/package/vanilla-cookieconsent)
```bash
# CDN links
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.9.1/dist/cookieconsent.js
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.9.1/dist/cookieconsent.css
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.9.2/dist/cookieconsent.js
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.9.2/dist/cookieconsent.css
```
Thanks to [Till Sanders](https://github.com/tillsanders) for bringing the plugin on npm.
Thanks to [Till Sanders](https://github.com/tillsanders) for bringing the plugin on npm!
```bash
npm i vanilla-cookieconsent
yarn add vanilla-cookieconsent
```
1. Import the plugin: add a `script` tag pointing to `cookieconsent.js`
1. Import the production version of the plugin (`dist` folder):
```html
<html>
<head>
<!-- head content -->
<!-- Deferred CSS loading (recommended) -->
<link rel="stylesheet" href="<path-to-cookieconsent.css>" media="print" onload="this.media='all'">
<!-- Load stylesheet -->
<link rel="stylesheet" href="cookieconsent.css">
</head>
<body>
<!-- body content -->
<script defer src="<path-to-cookieconsent.js>"></script>
<!-- Load script with the "defer" keyword -->
<script defer src="cookieconsent.js"></script>
</body>
</html>
```
<span>Note: replace `<path-to-cookieconsent.js>` and `<path-to-cookieconsent.css>` with valid paths!</span>
<br>
3. Configure and run
- <details><summary>As external script</summary>
If you're on React, check out the [FAQ](#faq) for more details or this live [Stackblitz](https://stackblitz.com/edit/nextjs-euxk9k?file=components%2FCookieConsentComponent.js) demo.
If you're using VUE/Nuxt, check out this [example setup](https://github.com/orestbida/cookieconsent/issues/42#issuecomment-899387614).
3. Configure the plugin:
Since there are no default settings, you must configure the (cookie) categories and at least one language! Example configurations:
- <details><summary>using an external script</summary>
<p>

@@ -90,5 +94,5 @@

<body>
<!-- body content ... -->
<script defer src="<path-to-cookieconsent.js>"></script>
<script defer src="<path-to-cookieconsent-init.js>"></script>
<!-- Load script with the "defer" keyword -->
<script defer src="cookieconsent.js"></script>
<script defer src="cookieconsent-init.js"></script>
<body>

@@ -218,3 +222,3 @@ ```

</details>
- <details><summary>As inline script</summary>
- <details><summary>using an inline script</summary>
<p>

@@ -224,4 +228,4 @@

<body>
<!-- body content ... -->
<script defer src="<path-to-cookieconsent.js>"></script>
<!-- Load script with the "defer" keyword -->
<script defer src="cookieconsent.js"></script>

@@ -354,9 +358,174 @@ <!-- Inline script -->

</details>
<br>
4. Add a button/link to show the settings modal:
```html
<button type="button" data-cc="c-settings">Manage cookie settings</button>
```
5. Now you must configure the scripts and cookies.
* [How to block/manage script tags](#how-to-blockmanage-scripts)
* [How to autoclear cookies](#how-to-clear-cookies)
<br>
## How to block/manage scripts
You can manage any script tag (inline or external).
1. Enable `page_scripts` option:
```javascript
cc.run({
// ...
page_scripts: true
// ...
});
```
2. Set `type="text/plain"` and `data-cookiecategory="<category>"` to any `script` tag you want to manage:
```html
<!-- External script -->
<script
type="text/plain"
data-cookiecategory="analytics"
src="analytics.js">
</script>
<!-- Inline script -->
<script
type="text/plain"
data-cookiecategory="ads">
console.log('"ads" category accepted');
</script>
```
You can also specify a custom type via the `data-type` attribute:
```html
<script
type="text/plain"
data-type="module"
data-cookiecategory="analytics"
src="test.js">
</script>
```
Note: the `type="text/plain"` disables the script tag (required attribute)!
<br>
## How to clear cookies
You can configure the plugin so that it automatically clears existing cookies when a category is rejected/disabled.
Cookies must be listed manually as the plugin is not aware of them.
1. Enable the `autoclear_cookies` option:
```js
cc.run({
// ...
autoclear_cookies: true,
// ...
});
```
2. Add the `settings_modal.cookie_table_headers` field:
```js
cc.run({
// ...
autoclear_cookies: true,
languages: {
en: {
// ...
settings_modal: {
// ...
cookie_table_headers: [
{col1: 'Name'},
{col2: 'Service'},
{col3: 'Description'}
]
}
}
}
});
```
3. Add the `cookie_table` field under the desired category block. A category block must contain the `toggle` object with a valid category name (`toggle.value`).
```js
cc.run({
// ...
autoclear_cookies: true,
// ...
languages: {
'en': {
// ...
settings_modal: {
// ...
cookie_table_headers: [
{col1: 'Name'},
{col2: 'Service'},
{col3: 'Description'}
],
blocks: [
// ...
{
// ...
toggle: {
value: 'analytics'
},
cookie_table: [
{
col1: '^_ga',
col2: 'Google Analytics',
col3: 'description ...',
is_regex: true
},
{
col1: '_gid',
col2: 'Google Analytics',
col3: 'description ...',
}
]
}
]
}
}
}
});
```
The `is_regex` option is handy if you want to match multiple cookies without specifying them individually.
This matches all cookies starting with `'_ga'`
```javascript
{
col1: '^_ga',
col2: '...',
col3: '...',
is_regex: true
}
```
This only matches the specific `'_ga'` cookie:
```javascript
{
col1: '_ga',
col2: '...',
col3: '...'
}
```
You can also customize the table (add/remove columns).
**For the autoclear cookies function to work, the _first_ column must contain the name of the cookie!**
[Full example](https://github.com/orestbida/cookieconsent/blob/9ad310e7edcac7bf23600ff0e23d42254d3fced2/demo/demo_iframemanager/cookieconsent-init.js#L139).
<br>
## Layout options & customization
You can change the color scheme with css variables inside cookieconsent.css. You can also change some basic layout options via the `gui_options` inside the config. object; example:
You can choose a few layout options via `gui_options`.
```javascript
cookieconsent.run({
cc.run({
// ...

@@ -372,3 +541,3 @@ gui_options: {

layout: 'box', // box/bar
// position: 'left', // left/right
position: 'left', // left/right
transition: 'slide' // zoom/slide

@@ -380,50 +549,18 @@ }

```
<i>Default layout is `box` and default transition is `zoom`.</i>
You can alter the color scheme by overriding the available css variables which you can find [here](src/cookieconsent.css).
### How to customize the color scheme
### Note: css variables are not supported on IE
You can customize the color scheme using css variables, which you can find at the top of [cookieconsent.css](src/cookieconsent.css) file.
How to build an ad-hoc stylesheet with your color scheme:
0. make sure you have [nodejs](https://nodejs.org/en/download/) installed
1. download/clone this repo.
2. run `npm install`
3. modify `src/cookieconsent.css` (css variables that will apply to IE are under the `:root` css selector)
4. run `npm run build`
5. use the newly generated `dist/cookieconsent.css` stylesheet
Alternatively, you could load a css variables polyfill.
<br>
## How to block/manage scripts
You can manage any script (inline or external) via the `page_scripts` option:
## API
Once you configure and run the plugin:
1. Enable page scripts management:
```javascript
const cc = initCookieConsent();
```javascript
cookieconsent.run({
// ...
page_scripts: true
// ...
});
```
2. Set `type="text/plain"` and `data-cookiecategory="<category>"` to any `script` tag you want to manage:
```html
<script type="text/plain" data-cookiecategory="analytics" src="analytics.js" defer></script>
<script type="text/plain" data-cookiecategory="ads">
console.log('"ads" category accepted');
</script>
```
<i>Note: `data-cookiecategory` must be a valid category defined inside the configuration object</i>
## API methods
After getting the plugin like so:
```javascript
var cookieconsent = initCookieConsent();
cc.run({
// required config.
});
```

@@ -433,10 +570,10 @@

- cookieconsent`.run(<config_object>)`
- cookieconsent`.show(<optional_delay>, <create_modal>)`
- cookieconsent`.hide()`
- cookieconsent`.showSettings(<optional_delay>)`
- cookieconsent`.hideSettings()`
* cc`.show(delay?: number, createModal?: boolean)`
* cc`.hide()`
* cc`.showSettings(delay?: number)`
* cc`.hideSettings()`
Additional methods for an easier management of your scripts and cookie settings (expand them to see usage example):
- <details><summary>cookieconsent<code>.accept(&lt;accepted_categories&gt;, &lt;optional_rejected_categories&gt;)</code> [v2.5.0+]</summary>
<br>
- <details><summary>cc<code>.accept(&lt;accepted_categories&gt;, &lt;optional_rejected_categories&gt;)</code> [v2.5.0+]</summary>
<p>

@@ -454,10 +591,10 @@

```javascript
cookieconsent.accept('all'); // accept all categories
cookieconsent.accept([]); // accept none (reject all)
cookieconsent.accept('analytics'); // accept only analytics category
cookieconsent.accept(['cat_1', 'cat_2']); // accept only these 2 categories
cookieconsent.accept(); // accept all currently selected categories inside modal
cc.accept('all'); // accept all categories
cc.accept([]); // accept none (reject all)
cc.accept('analytics'); // accept only analytics category
cc.accept(['cat_1', 'cat_2']); // accept only these 2 categories
cc.accept(); // accept all currently selected categories inside modal
cookieconsent.accept('all', ['analytics']); // accept all except "analytics" category
cookieconsent.accept('all', ['cat_1', 'cat_2']); // accept all except these 2 categories
cc.accept('all', ['analytics']); // accept all except "analytics" category
cc.accept('all', ['cat_1', 'cat_2']); // accept all except these 2 categories
```

@@ -468,7 +605,7 @@

```javascript
cookieconsent.accept('all', ['targeting']); // opt out of targeting category
cc.accept('all', ['targeting']); // opt out of targeting category
```
</p>
</details>
- <details><summary>cookieconsent<code>.allowedCategory(&lt;category_name&gt;)</code></summary>
- <details><summary>cc<code>.allowedCategory(&lt;category_name&gt;)</code></summary>
<p>

@@ -484,6 +621,6 @@

toggle: {
value: 'analytics', // cookie category
enabled: false, // default status
readonly: false // allow to enable/disable
// reload: 'on_disable', // allows to reload page when the current cookie category is deselected
value: 'analytics', // cookie category
enabled?: false, // default status
readonly?: false // allow to enable/disable
reload?: 'on_disable', // allows to reload page when the current cookie category is deselected
}

@@ -496,3 +633,3 @@ // ...

// Check if user accepts cookie consent with analytics category enabled
if (cookieconsent.allowedCategory('analytics')) {
if (cc.allowedCategory('analytics')) {
// yoo, you might want to load analytics.js ...

@@ -503,3 +640,3 @@ };

</details>
- <details><summary>cookieconsent<code>.validCookie(&lt;cookie_name&gt;)</code></summary>
- <details><summary>cc<code>.validCookie(&lt;cookie_name&gt;)</code></summary>
<p>

@@ -511,3 +648,3 @@

// Example: check if '_gid' cookie is set
if (!cookieconsent.validCookie('_gid')) {
if (!cc.validCookie('_gid')) {
// yoo, _gid cookie is not set, do something ...

@@ -518,5 +655,18 @@ };

</details>
- <details><summary>cookieconsent<code>.eraseCookies(&lt;cookie_names&gt;, &lt;optional_path&gt;, &lt;optional_domains&gt;)</code> [v2.5.0+]</summary>
- <details><summary>cc<code>.validConsent()</code></summary>
<p>
If consent is valid return <code>true</code>, otherwise <code>false</code>.
```javascript
// Example: show modal if consent is not valid
if (!cc.validConsent()) {
cc.show();
}
```
</p>
</details>
- <details><summary>cc<code>.eraseCookies(&lt;cookie_names&gt;, &lt;optional_path&gt;, &lt;optional_domains&gt;)</code> [v2.5.0+]</summary>
<p>
- cookie_names: `string[]`

@@ -531,11 +681,11 @@ - path: `string` - optional

```javascript
cookieconsent.eraseCookies(['cc_cookies']); // erase "cc_cookie" if it exists
cookieconsent.eraseCookies(['cookie1', 'cookie2']); // erase these 2 cookies
cc.eraseCookies(['cc_cookies']); // erase "cc_cookie" if it exists
cc.eraseCookies(['cookie1', 'cookie2']); // erase these 2 cookies
cookieconsent.eraseCookies(['cc_cookie'], "/demo");
cookieconsent.eraseCookies(['cc_cookie'], "/demo", [location.hostname]);
cc.eraseCookies(['cc_cookie'], "/demo");
cc.eraseCookies(['cc_cookie'], "/demo", [location.hostname]);
```
</p>
</details>
- <details><summary>cookieconsent<code>.loadScript(&lt;path&gt;, &lt;callback_function&gt;, &lt;optional_custom_attributes&gt;)</code></summary>
- <details><summary>cc<code>.loadScript(&lt;path&gt;, &lt;callback_function&gt;, &lt;optional_custom_attributes&gt;)</code></summary>
<p>

@@ -546,3 +696,3 @@

```javascript
cookieconsent.loadScript('https://www.google-analytics.com/analytics.js', function(){
cc.loadScript('https://www.google-analytics.com/analytics.js', function(){
// Script loaded, do something

@@ -553,3 +703,3 @@ });

```javascript
cookieconsent.loadScript('https://www.google-analytics.com/analytics.js', function(){
cc.loadScript('https://www.google-analytics.com/analytics.js', function(){
// Script loaded, do something

@@ -563,3 +713,3 @@ }, [

</details>
- <details><summary>cookieconsent<code>.set(&lt;field&gt;, &lt;object&gt;)</code> [v2.6.0+]</summary>
- <details><summary>cc<code>.set(&lt;field&gt;, &lt;object&gt;)</code> [v2.6.0+]</summary>
<p>

@@ -576,10 +726,10 @@

// Set cookie's "data" field to whatever the value of the `value` prop. is
cookieconsent.set('data', {value: {id: 21, country: "italy"}});
cc.set('data', {value: {id: 21, country: "italy"}});
// Only add/update the specified props.
cookieconsent.set('data', {value: {id: 22, new_prop: 'new prop value'}, mode: 'update'});
cc.set('data', {value: {id: 22, new_prop: 'new prop value'}, mode: 'update'});
```
</p>
</details>
- <details><summary>cookieconsent<code>.get(&lt;field&gt;)</code> [v2.6.0+]</summary>
- <details><summary>cc<code>.get(&lt;field&gt;)</code> [v2.6.0+]</summary>
<p>

@@ -589,9 +739,9 @@

```javascript
cookieconsent.get('level'); // retrieve all accepted categories (if cookie exists)
cookieconsent.get('data'); // retrieve custom data (if cookie exists)
cookieconsent.get('revision'); // retrieve revision number (if cookie exists)
cc.get('level'); // retrieve all accepted categories (if cookie exists)
cc.get('data'); // retrieve custom data (if cookie exists)
cc.get('revision'); // retrieve revision number (if cookie exists)
```
</p>
</details>
- <details><summary>cookieconsent<code>.getConfig(&lt;field&gt;)</code> [v2.7.0+]</summary>
- <details><summary>cc<code>.getConfig(&lt;field&gt;)</code> [v2.7.0+]</summary>
<p>

@@ -601,4 +751,4 @@

```javascript
cookieconsent.getConfig('current_lang'); // get currently used language
cookieconsent.getConfig('cookie_expiration'); // get configured cookie expiration
cc.getConfig('current_lang'); // get currently used language
cc.getConfig('cookie_expiration'); // get configured cookie expiration
// ...

@@ -608,3 +758,3 @@ ```

</details>
- <details><summary>cookieconsent<code>.getUserPreferences()</code> [v2.7.0+]</summary>
- <details><summary>cc<code>.getUserPreferences()</code> [v2.7.0+]</summary>
<p>

@@ -622,3 +772,3 @@

</details>
- <details><summary>cookieconsent<code>.updateScripts()</code> [v2.7.0+]</summary>
- <details><summary>cc<code>.updateScripts()</code> [v2.7.0+]</summary>
<p>

@@ -631,3 +781,3 @@

</details>
- <details><summary>cookieconsent<code>.updateLanguage(&lt;language&gt;, &lt;force_update&gt;)</code> [v2.8.0+]</summary>
- <details><summary>cc<code>.updateLanguage(&lt;language&gt;, &lt;force_update&gt;)</code> [v2.8.0+]</summary>
<p>

@@ -644,3 +794,3 @@

```javascript
cookieconsent.updateLanguage('it');
cc.updateLanguage('it');
```

@@ -655,6 +805,6 @@

// Change content: e.g. modify modal title
cookieconsent.getConfig('languages').en.consent_modal.title = 'New title';
cc.getConfig('languages').en.consent_modal.title = 'New title';
// Update changes
cookieconsent.updateLanguage('en', true);
cc.updateLanguage('en', true);
```

@@ -667,20 +817,3 @@

## Available `data-cc` actions
Any button (or link) can use the custom `data-cc` attribute to perform a few actions without manually invoking the api methods.
Valid values:
- `c-settings`: show settings modal
- `accept-all`: accept all categories
- `accept-necessary`: accept only categories marked as necessary/readonly (reject all)
- `accept-custom`: accept currently selected categories inside the settings modal
Examples:
```html
<button type="button" data-cc="c-settings">Show cookie settings</button>
<button type="button" data-cc="accept-all">Accept all cookies</button>
```
<br>
## Available callbacks
The following functions have to be defined inside the configuration object passed to the `.run()` method.

@@ -707,3 +840,3 @@ - <details><summary><code>onAccept</code></summary>

onAccept: function(cookie){
// load somescript, google analytics ...
// load script, e.g. google analytics ...
},

@@ -771,4 +904,19 @@ // ...

### All configuration options
## Custom `data-cc` attribute
You can add the `data-cc` attribute to any element (typically a button) to perform a few actions without having to use code.
Valid values:
- `c-settings`: show settings modal
- `accept-all`: accept all categories
- `accept-necessary`: accept only categories marked as necessary/readonly (reject all)
- `accept-custom`: accept currently selected categories inside the settings modal
Example:
```html
<button type="button" data-cc="c-settings">Show cookie settings</button>
```
<br>
## Configuration options
Below a table which sums up all of the available options (must be passed to the .run() method).

@@ -786,3 +934,3 @@ | Option | Type | Default | Description |

| `use_rfc_cookie` | boolean | false | Enable if you want the value of the cookie to be rfc compliant |
| `force_consent` | boolean | false | Enable if you want to block page navigation until user action (check [faq](#faq) for a proper implementation) |
| `force_consent` | boolean | false | Enable if you want to block page navigation until user action (Check out the [FAQ > Make consent required item](#faq) for a proper implementation) |
| `revision` | number | 0 | Specify this option to enable revisions. [Check below](#how-to-enablemanage-revisions) for a proper usage |

@@ -796,251 +944,16 @@ | `current_lang` | string | - | Specify one of the languages you have defined (can also be dynamic): `'en'`, `'de'` ... |

| `gui_options` | object | - | Customization option which allows to choose layout, position and transition. Check [layout options & customization](#layout-options--customization) |
| __`onAccept`__ | function | - | Method run on: <br> 1. the moment the cookie consent is accepted <br> 2. after each page load (if cookie consent has already been accepted) |
| __`onChange`__ | function | - | Method run `whenever preferences are modified` (and only if cookie consent has already been accepted) |
| __`onFirstAction`__ | function | - | Method run only `once` when the user makes the initial choice (accept/reject) |
| `languages` | object | - | [Check below](#how-to-configure-languages--cookie-settings) for configuration
| __`onAccept`__ | function | - | Callback run on: <br> 1. the moment the cookie consent is accepted <br> 2. after each page load (if cookie consent has already been accepted) |
| __`onChange`__ | function | - | Callback run **whenever preferences are modified** (and only if cookie consent has already been accepted) |
| __`onFirstAction`__ | function | - | Callback executed **once**, on the users first consent action. |
| `languages` | object | - | Defined in [types.d.ts](https://github.com/orestbida/cookieconsent/blob/f83cacea7d3dfba22eb96910f03af0fea290f5a2/types/types.d.ts#L91-L94)
## Full example configurations
- <details><summary>Configuration with gtag.js - Google Analytics</summary>
<p>
<br>
1. enable `page_scripts`
2. set `type="text/plain"` and `data-cookiecategory="<your-category>"` to each script:
## How to manage revisions
Revisions can be enabled by setting a value different from `0` (default). If the saved revision number (stored in the cookie) is different from the current one, the consent modal will be shown.
<br>
1. Enable revisions by setting a `revision` number > 0:
```html
<!-- Global site tag (gtag.js) - Google Analytics -->
<script type="text/plain" data-cookiecategory="analytics" async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script type="text/plain" data-cookiecategory="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_MEASUREMENT_ID');
</script>
<script defer src="<path-to-cookieconsent.js>"></script>
<script>
window.addEventListener('load', function () {
// obtain cookieconsent plugin
var cookieconsent = initCookieConsent();
// run plugin with config object
cookieconsent.run({
autorun: true,
current_lang: 'en',
autoclear_cookies: true,
page_scripts: true,
onFirstAction: function(user_preferences, cookie){
// callback triggered only once
},
onAccept: function (cookie) {
// ... cookieconsent accepted
},
onChange: function (cookie, changed_preferences) {
// ... cookieconsent preferences were changed
},
languages: {
en: {
consent_modal: {
title: 'I use cookies',
description: 'Hi, this website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only upon approval. <a aria-label="Cookie policy" class="cc-link" href="#">Read more</a>',
primary_btn: {
text: 'Accept',
role: 'accept_all' // 'accept_selected' or 'accept_all'
},
secondary_btn: {
text: 'Settings',
role: 'settings' // 'settings' or 'accept_necessary'
}
},
settings_modal: {
title: 'Cookie preferences',
save_settings_btn: 'Save settings',
accept_all_btn: 'Accept all',
reject_all_btn: 'Reject all', // optional, [v.2.5.0 +]
cookie_table_headers: [
{col1: 'Name'},
{col2: 'Domain'},
{col3: 'Expiration'},
{col4: 'Description'},
{col5: 'Type'}
],
blocks: [
{
title: 'Cookie usage',
description: 'I use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want.'
}, {
title: 'Strictly necessary cookies',
description: 'These cookies are essential for the proper functioning of my website. Without these cookies, the website would not work properly.',
toggle: {
value: 'necessary',
enabled: true,
readonly: true
}
}, {
title: 'Analytics cookies',
description: 'These cookies collect information about how you use the website, which pages you visited and which links you clicked on. All of the data is anonymized and cannot be used to identify you.',
toggle: {
value: 'analytics',
enabled: false,
readonly: false
},
cookie_table: [
{
col1: '^_ga',
col2: 'google.com',
col3: '2 years',
col4: 'description ...',
col5: 'Permanent cookie',
is_regex: true
},
{
col1: '_gid',
col2: 'google.com',
col3: '1 day',
col4: 'description ...',
col5: 'Permanent cookie'
}
]
}, {
title: 'More information',
description: 'For any queries in relation to my policy on cookies and your choices, please <a class="cc-link" href="#yourwebsite">contact me</a>.',
}
]
}
}
}
});
});
</script>
```
</p>
</details>
### How to configure languages & cookie settings
Languages is an object which basically holds all of the text/html of your cookie modals in different languages. In here you can define `cookie categories`, `cookie tables`, `opt-in/out toggle` for each category and more. For each language, a `consent_modal` object and a `settings_modal` object must be configured.
<details><summary>Example with <b>multiple languages</b> ('en' and 'it')</summary>
<p>
```javascript
cookieconsent.run({
// ...,
languages: {
'en': {
consent_modal: {
title: 'Title here ...',
description: 'Description here ...',
primary_btn: {
text: 'Accept',
role: 'accept_all' // 'accept_selected' or 'accept_all'
},
secondary_btn: {
text: 'Settings',
role: 'settings' // 'settings' or 'accept_necessary'
}
},
settings_modal: {
title: 'Cookie preferences ...',
save_settings_btn: 'Save settings',
accept_all_btn: 'Accept all',
blocks: [
{
title: 'First block title ...',
description: 'First block description ...'
}, {
title: 'Second block title ...',
description: 'Second block description ...',
toggle: {
value: 'my_category1',
enabled: true,
readonly: true
}
}, {
title: 'Third block title ...',
description: 'Third block description ...',
toggle: {
value: 'my_category2',
enabled: false,
readonly: false
}
}
]
}
},
'it': {
consent_modal: {
title: 'Title in italian here ...',
description: 'Description in italian here ...',
primary_btn: {
text: 'Accept in italian',
role: 'accept_all' //'accept_selected' or 'accept_all'
},
secondary_btn: {
text: 'Settings',
role: 'settings' //'settings' or 'accept_necessary'
}
},
settings_modal: {
title: 'Cookie preferences ...',
save_settings_btn: 'Save settings in italian',
accept_all_btn: "Accept all",
blocks: [
{
title: 'First block title in italian ...',
description: 'First block description in italian ...'
}, {
title: 'Second block title in italian ...',
description: 'Second block description in italian...',
toggle: {
value: 'my_category1',
enabled: true,
readonly: true
}
}, {
title: 'Third block title in italian ...',
description: 'Third block description in italian...',
toggle: {
value: 'my_category2',
enabled: false,
readonly: false
}
}
]
}
}
}
});
```
</p>
</details>
<details><summary>Example with <b>custom cookie table</b></summary>
<p>
You can create tables with a custom number of columns to explain what each cookie does.
**NOTE**: If you want to also use `autoclear_cookie`, make sure the first column of the cookie table contains the name of the cookie.
[Check demo app.js](demo/app.js) which has a full example with cookie table.
</p>
</details>
## How to enable/manage revisions
Note:
- default revision number is 0
- if existing revision number is different from the one you just specified => show consent modal
1. Enable revisions by specifying a valid `revision` parameter:
```javascript
cookieconsent.run({
cc.run({
// ...,

@@ -1052,6 +965,6 @@ revision: 1,

2. Set a valid `revision_message` parameter (optional) inside `consent_modal`, and add the following placeholder `{{revision_message}}` inside `description`:
2. You can optionally set a revision message. To do this, add the `revision_message` parameter inside `consent_modal`, and also place the following placeholder `{{revision_message}}` inside the `description` field:
```javascript
cookieconsent.run({
cc.run({
// ...,

@@ -1075,4 +988,31 @@ revision: 1,

<br>
## How to share consent across subdomains
If your main domain and subdomain share the same cookieconsent configuration, you can also share the consent by pointing all configurations to the same cookie (using the main domain).
In the plugin's config. simply specify the main domain in the `cookie_domain` option:
```js
var cc = initCookieConsent();
cc.run({
// ...
cookie_domain: 'domain.com'
});
```
E.g. if your main domain is `"loremipsum.com"` or `"www.loremipsum.com"`, you have to put `"loremipsum.com"`.
<br>
## How to block iframes
CookieConsent does not have any built-in functionality to block iframes. You can however use [iframemanager](https://github.com/orestbida/iframemanager) which was specifically designed for this task.
<br>
## FAQ
- <details><summary>How to enable dark-mode</summary>
- <details><summary>How to enable dark mode</summary>
<p>

@@ -1092,3 +1032,3 @@

```javascript
<button type="button" aria-label="View cookie settings" data-cc="c-settings">Cookie Settings</button>
<button type="button" data-cc="c-settings">Cookie Settings</button>
```

@@ -1098,3 +1038,3 @@

</details>
- <details><summary>How to integrate with my multi-language website</summary>
- <details><summary>How to integrate with a multi-language website</summary>
<p>

@@ -1111,3 +1051,3 @@

```javascript
cookieconsent.run({
cc.run({
// ...

@@ -1134,3 +1074,3 @@ current_lang: document.documentElement.getAttribute('lang'),

```javascript
cookieconsent.run({
cc.run({
// ...

@@ -1155,7 +1095,7 @@ page_scripts: true,

```javascript
cookieconsent.run({
cc.run({
// ...
onAccept: function () {
if (cookieconsent.allowedCategory('analytics')) {
cookieconsent.loadScript('<path-to-analytics.js', function () {
if (cc.allowedCategory('analytics')) {
cc.loadScript('analytics.js', function () {
// script loaded ...

@@ -1167,2 +1107,3 @@ });

```
</p>

@@ -1180,3 +1121,3 @@ </details>

```javascript
cookieconsent.run({
cc.run({
// ...

@@ -1261,5 +1202,5 @@ force_consent: true,

if (!document.getElementById('cc--main')) {
window.CookieConsentApi = window.initCookieConsent();
window.CookieConsentApi.run({
// your config
window.CC = window.initCookieConsent();
window.CC.run({
// your config (required)
});

@@ -1274,3 +1215,3 @@ }

2. Import the component only once (generally in your main/root component like `App.js` or `index.js`)
2. Import the component in your main/root file (e.g. `App.js`):

@@ -1293,3 +1234,5 @@ ```javascript

<br>
## License
Distributed under the MIT License. See [LICENSE](https://github.com/orestbida/cookieconsent/blob/master/LICENSE) for more information.

@@ -140,2 +140,3 @@ export {}

validCookie(cookie_name: string): boolean
validConsent(): boolean
allowedCategory(cookie_category: string): boolean

@@ -142,0 +143,0 @@ set(field: string, data: Record<string, any>): boolean

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc