import{e as g,g as f}from"./chunk-WWJO3B7F.js";import{P as h,h as d}from"./chunk-LLYDPG5N.js";import{G as l,ca as u,ha as r,p as o,t as c,u as a}from"./chunk-2BMUMDG3.js";import{i as n}from"./chunk-2AVGQ2MQ.js";var R=(()=>{class s{constructor(e,t,i,m,p){this.http=e,this.router=t,this.cookieService=i,this.configService=m,this.PRODUCTS_FACTORY=p,this.envUrl="",this.envDetails={},this.inclusionLicenses=[],this.exclusionLicenses=[],this.envUrl=this.configService.protocol+this.configService.baseFolder+"/paralite/cloud/"+this.configService.cloudName+"/envDetails/"}checkLicense(){let e=this.http.get(this.envUrl,{observe:"response"}).pipe(a(t=>(this.storeHeaders(t.headers),{status:t.status,headers:t.headers,body:t.body})),l(t=>(this.storeHeaders(t.headers),o({status:t.status,headers:t.headers,error:t.error}))));return this.API_promise=e,e}storeHeaders(e){let t={};this.inclusionLicenses=[],this.exclusionLicenses=[],e?.keys().forEach(i=>{t[i.toLowerCase()]=e.get(i)||"",e.get(i)==="true"?this.inclusionLicenses.push(i):e.get(i)==="false"&&this.exclusionLicenses.push(i)}),this.envDetails=t}getEnvDetails(){return this.envDetails}getInclusionLicenses(){return this.inclusionLicenses}getLicensedProductsDetails(){return n(this,null,function*(){let e=yield this.getInclusionLicensesNew();return this.PRODUCTS_FACTORY.filter(t=>e.includes(t.licenceKey))})}getInclusionLicensesNew(){return n(this,null,function*(){if(this.inclusionLicenses.length===0&&this.API_promise==null)try{yield c(this.checkLicense())}catch(e){return console.error("Error fetching license info",e),[]}else this.inclusionLicenses.length===0&&this.API_promise!==void 0&&(yield this.API_promise.toPromise());return this.inclusionLicenses})}getExclusionLicenses(){return this.exclusionLicenses}handleErrorByStatus(e){switch(e.status){case 0:return this.router.navigate(["/503"]),{errorMessage:"A specific error occurred. Please try again later."};case 416:return{licenseExpired:!0};case 434:case 450:return{errorMessage:"A specific error occurred. Please try again later."};case 435:return{clientId:e.error.identityProviderSettingsElement.clientId,tenentId:e.error.identityProviderSettingsElement.tenentId,portalRedirectURI:e.error.identityProviderSettingsElement.portalRedirectURI,loginMode:e.error.identityProviderSettingsElement.loginMode,errorMessage:"A specific error occurred. Please try again later."};case 503:return this.router.navigate(["/503"]),{errorMessage:"A specific error occurred. Please try again later."};default:return{clientId:e.error?.identityProviderSettingsElement?.clientId,tenentId:e.error?.identityProviderSettingsElement?.tenentId,portalRedirectURI:e.error?.identityProviderSettingsElement?.portalRedirectURI,loginMode:e.error?.identityProviderSettingsElement?.loginMode,errorMessage:"An error occurred. Please try again later."}}}static{this.\u0275fac=function(t){return new(t||s)(r(d),r(h),r(f),r(g),r("PRODUCTS_FACTORY"))}}static{this.\u0275prov=u({token:s,factory:s.\u0275fac,providedIn:"root"})}}return s})();export{R as a};
