text: /*
   * Copyright (c) Microsoft Corporation. All rights reserved.
   * Licensed under the MIT License.
   */
  import { CryptoUtils } from "./utils/CryptoUtils";
  import { StringUtils } from "./utils/StringUtils";
  /**
   * accountIdentifier       combination of idToken.uid and idToken.utid
   * homeAccountIdentifier   combination of clientInfo.uid and clientInfo.utid
   * userName                idToken.preferred_username
   * name                    idToken.name
   * idToken                 idToken
   * sid                     idToken.sid - session identifier
   * environment             idtoken.issuer (the authority that issues the token)
   */
  var Account = /** @class */ (function () {
      /**
       * Creates an Account Object
       * @praram accountIdentifier
       * @param homeAccountIdentifier
       * @param userName
       * @param name
       * @param idToken
       * @param sid
       * @param environment
       */
      function Account(accountIdentifier, homeAccountIdentifier, userName, name, idTokenClaims, sid, environment) {
          this.accountIdentifier = accountIdentifier;
          this.homeAccountIdentifier = homeAccountIdentifier;
          this.userName = userName;
          this.name = name;
          // will be deprecated soon
          this.idToken = idTokenClaims;
          this.idTokenClaims = idTokenClaims;
          this.sid = sid;
          this.environment = environment;
      }
      /**
       * @hidden
       * @param idToken
       * @param clientInfo
       */
      Account.createAccount = function (idToken, clientInfo) {
          // create accountIdentifier
          var accountIdentifier = idToken.objectId || idToken.subject;
          // create homeAccountIdentifier
          var uid = clientInfo ? clientInfo.uid : "";
          var utid = clientInfo ? clientInfo.utid : "";
          var homeAccountIdentifier;
          if (!StringUtils.isEmpty(uid)) {
              homeAccountIdentifier = StringUtils.isEmpty(utid) ? CryptoUtils.base64Encode(uid) : CryptoUtils.base64Encode(uid) + "." + CryptoUtils.base64Encode(utid);
          }
          return new Account(accountIdentifier, homeAccountIdentifier, idToken.preferredName, idToken.name, idToken.claims, idToken.sid, idToken.issuer);
      };
      /**
       * Utils function to compare two Account objects - used to check if the same user account is logged in
       *
       * @param a1: Account object
       * @param a2: Account object
       */
      Account.compareAccounts = function (a1, a2) {
          if (!a1 || !a2) {
              return false;
          }
          if (a1.homeAccountIdentifier && a2.homeAccountIdentifier) {
              if (a1.homeAccountIdentifier === a2.homeAccountIdentifier) {
                  return true;
              }
          }
          return false;
      };
      return Account;
  }());
  export { Account };
  //# sourceMappingURL=Account.js.map