UNPKG

@usercentrics/cmp-browser-sdk

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