@usercentrics/cmp-browser-sdk
Version:
Usercentrics CMP Browser SDK
2 lines (1 loc) • 3.22 kB
JavaScript
import{F as t,S as e,C as a,a as i,D as n,b as o,W as s,c as r,A as c,_ as u,L as l,G as p,d as C,e as d}from"./index-c3735125.js";import g from"./DefaultData-982e0079.js";var A=function(t){return!(!t||!t.length||t[2]!==e.ACCEPT)},f=function(t){var e=t&&t.data&&t.data.__uspapiCall;e&&window[s](e.command,e.version,function(a,i){!t.source||t.source instanceof MessagePort||t.source instanceof ServiceWorker||t.source.postMessage({__uspapiReturn:{callId:e.callId,returnValue:a,success:i}},"*")})},m=function(g){function m(i,u,C,d){var m,v,O,w,P,S,h,D,N=this;return(N=g.call(this,u,C)||this).explicitDeny=!1,N.iabAgreementExists=(null===(m=i.ccpa)||void 0===m?void 0:m.iabAgreementExists)||!1,N.isActive=i.framework?["CCPA","UCPA","CTDPA","VCDPA","CPRA","CPA"].includes(i.framework):null!==(O=null===(v=i.ccpa)||void 0===v?void 0:v.isActive)&&void 0!==O&&O,N.region=(null===(w=i.ccpa)||void 0===w?void 0:w.region)||l.US_CA_ONLY,N.reshowAfterDays=(null===(P=i.ccpa)||void 0===P?void 0:P.reshowAfterDays)||365,N.showOnPageLoad=(null===(S=i.ccpa)||void 0===S?void 0:S.showOnPageLoad)||!1,N.isOptedOut=!!navigator.globalPrivacyControl,N.isExplicitConsented=d,N.framework=i.framework||"ccpa",N.legalFramework=N.getLegalFramework(N.framework),o.getCcpaString()!==n?(N.explicitNotice=!(!(D=o.getCcpaString())||!D.length||D[1]!==e.ACCEPT),!d&&N.isOptedOut?(N.explicitDeny=!0,N.setCcpaStorage(N.isOptedOut,N.explicitNotice?e.ACCEPT:e.UNKNOWN)):(N.isOptedOut=A(o.getCcpaString()),null===(h=p.getInstance())||void 0===h||h.setSectionString(o.getCcpaString(),N.legalFramework))):(N.setCcpaStorage(N.isOptedOut,e.UNKNOWN),N.explicitNotice=!1),function(){if(!Object.prototype.hasOwnProperty.call(window.frames,t)){var e=document.createElement("iframe");e.style.display="none",e.name=t,document.body.appendChild(e)}}(),window[s]=function(t,e,i){switch("function"!=typeof i&&console.warn(r.API_INVALID_CALLBACK),e!==a&&i({uspString:null,version:null},!1),t){case c.GET_USP_DATA:i({uspString:o.getCcpaString(),version:a},!0);break;case s:i(null,!0);break;default:console.warn(r.API_INVALID_COMMAND,t),i(null,!1)}},window.addEventListener("message",f,!1),N}return u(m,g),m.prototype.getIsOptedOut=function(){return this.isOptedOut},m.prototype.getLegalFramework=function(t){switch(t){case"UCPA":return"usut";case"CTDPA":return"usct";case"VCDPA":return"usva";case"CPRA":return"usca";case"CPA":return"usco";default:return"uspv1"}},m.prototype.getExplicitNotice=function(){return this.explicitNotice},m.prototype.setCcpaStorage=function(t,s){var r;void 0===s&&(s=e.ACCEPT),this.setIsOptedOut(t),t?o.setCcpaTimeStamp():o.clearCcpaData(),s===e.ACCEPT?this.explicitNotice=!0:this.explicitNotice=!1;var c=function(t,o,s){var r="".concat(a).concat(o).concat(t?e.ACCEPT:e.DENY).concat(s?e.ACCEPT:e.UNKNOWN);return i.test(r)||(r=n),r}(t,s,this.iabAgreementExists);null===(r=p.getInstance())||void 0===r||r.setSectionString(c,this.legalFramework),C.isCrossDomainAvailable()&&C.setCrossDomainCcpaData({ccpaString:c,timestamp:o.getCcpaTimeStamp()}).catch(function(){console.warn(d.CROSS_DOMAIN_SET_DATA_FAILURE)}),o.setCcpaString(c)},m.prototype.setIsOptedOut=function(t){var e="boolean"==typeof t?t:A(t);this.isOptedOut=e},m}(g);export{m as default};