"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.License = void 0; const Entity_1 = require("../../../../shared/domain/Entity"); const UniqueId_1 = require("../../../../shared/domain/UniqueId"); const LicensePlan_1 = require("../value-objects/LicensePlan"); const FeatureEntitlement_1 = require("../value-objects/FeatureEntitlement"); class License extends Entity_1.Entity { static createFree() { return new License({ plan: LicensePlan_1.LicensePlan.free(), organizationName: 'Community', email: '', expiresAt: null, issuedAt: new Date(), signature: 'free', rawKey: 'free', }, UniqueId_1.UniqueId.create()); } static reconstitute(props, id) { return new License(props, id); } get plan() { return this.props.plan; } get organizationName() { return this.props.organizationName; } get email() { return this.props.email; } get expiresAt() { return this.props.expiresAt; } get issuedAt() { return this.props.issuedAt; } get signature() { return this.props.signature; } get rawKey() { return this.props.rawKey; } get isExpired() { if (!this.props.expiresAt) return false; return this.props.expiresAt < new Date(); } get isValid() { return !this.isExpired; } getEntitlements() { if (!this.isValid) return FeatureEntitlement_1.FeatureEntitlement.forFeatures(FeatureEntitlement_1.FREE_FEATURES); if (this.props.plan.isEnterprise) return FeatureEntitlement_1.FeatureEntitlement.forFeatures(FeatureEntitlement_1.ENTERPRISE_FEATURES); if (this.props.plan.isPro) return FeatureEntitlement_1.FeatureEntitlement.forFeatures(FeatureEntitlement_1.PRO_FEATURES); return FeatureEntitlement_1.FeatureEntitlement.forFeatures(FeatureEntitlement_1.FREE_FEATURES); } hasFeature(feature) { return this.getEntitlements().has(feature); } } exports.License = License;