UNPKG

@usercentrics/cmp-browser-sdk

Version:
2 lines (1 loc) 2.2 kB
import{_ as e,g as s,s as n,v as t,f as r,h as i,E as a,i as u,j as c,m as o,k as l,l as d,n as v,o as f,p as g,q as h}from"./index-c3735125.js";var S=function(l){function h(e,S,I){var p=l.call(this,I)||this;return p.categorySlug=e.categorySlug,p.consent=s(e,S),p.id=e.templateId,p.isEssential=S.isEssential,p.isHidden=!!S.isHidden||e.isHidden,p.processorId="".concat(n(t())),p.subServices=[],p.subServicesLength=e.subConsents?e.subConsents.length:0,p.usesThirdCountry=e.usesThirdCountry,p.version=e.version,p.fetchSubServices=function(){return r(p,void 0,void 0,function(){var s,n,t,r,l,I,p,b,m=this;return i(this,function(i){switch(i.label){case 0:if(s=u.getInstance(),n=c.getInstance(),t=e.subConsents,!(r=o(t)).length)return[2,[]];I=null,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,s.fetchAggregatedServices(r,!1)];case 2:return l=i.sent(),[4,s.fetchTranslations()];case 3:return I=i.sent(),[3,5];case 4:throw i.sent(),new Error(a.FETCH_DATA_PROCESSING_SERVICES);case 5:return l&&t?(p=n.getServicesBaseInfo(),b=p.filter(function(e){return e.id===m.id}),this.subServices=t.reduce(function(e,s){var n=null==l?void 0:l.find(function(e){return s.templateId===e.templateId&&s.version===e.version});if(!n)return d([],v(e),!1);var t=new h(s,S,n);return d(d([],v(e),!1),[t],!1)},[]),[2,this.subServices.reduce(function(e,s){var n=t.find(function(e){return s.id===e.templateId&&s.version===e.version});if(!n)return d([],v(e),!1);var r=new f(n,I,l),i=1===b.length?{legalBasis:b[0].legalBasis}:{},a=g(g(g(g({},r),s),{subServices:[]}),i);return d(d([],v(e),!1),[a],!1)},[])]):[2,[]]}})})},p}return e(h,l),h}(l),I=function(e,s,n){this.isEssential=e.isEssential,this.isHidden=e.isHidden,this.services=p(e,s,n),this.slug=e.categorySlug},p=function(e,s,n){return s.reduce(function(s,t){if(t.categorySlug===e.categorySlug){var r=null==n?void 0:n.find(function(e){return t.templateId===e.templateId&&t.version===e.version}),i=new S(t,e,r);return d(d([],v(s),!1),[i],!1)}return d([],v(s),!1)},[])},b=function(e,s,n){this.categories=e.categories.reduce(function(s,t){var r=new I(t,e.consentTemplates,n);return h(r.services)?d(d([],v(s),!1),[r],!1):d([],v(s),!1)},[]),this.controllerId=s};export{b as default};