"use strict";
(self["webpackChunkafterlogic_aurora_platform"] = self["webpackChunkafterlogic_aurora_platform"] || []).push([[11],{

/***/ "0O7n":
/*!*******************************************************!*\
  !*** ./modules/InvitationLinkWebclient/js/manager.js ***!
  \*******************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {



module.exports = function (oAppData) {
  __webpack_require__(/*! modules/CoreWebclient/js/vendors/jquery.cookie.js */ "GUFh");
  var $ = __webpack_require__(/*! jquery */ "M4cL"),
    TextUtils = __webpack_require__(/*! modules/CoreWebclient/js/utils/Text.js */ "LKDt"),
    Ajax = __webpack_require__(/*! modules/CoreWebclient/js/Ajax.js */ "8QQh"),
    App = __webpack_require__(/*! modules/CoreWebclient/js/App.js */ "yU9o"),
    Routing = __webpack_require__(/*! modules/CoreWebclient/js/Routing.js */ "ioSH"),
    Screens = __webpack_require__(/*! modules/CoreWebclient/js/Screens.js */ "D2Gh"),
    UserSettings = __webpack_require__(/*! modules/CoreWebclient/js/Settings.js */ "KIwC"),
    Settings = __webpack_require__(/*! modules/InvitationLinkWebclient/js/Settings.js */ "qFnw"),
    bAnonimUser = App.getUserRole() === Enums.UserRole.Anonymous,
    fGetInvitationLinkHash = function fGetInvitationLinkHash() {
      var aHashArray = Routing.getCurrentHashArray();
      if (aHashArray.length >= 2 && aHashArray[0] === Settings.RegisterModuleHash) {
        return aHashArray[1];
      }
      return '';
    },
    sInvitationLinkHash = fGetInvitationLinkHash();
  Settings.init(oAppData);
  if (!App.isPublic() && bAnonimUser) {
    return {
      start: function start(ModulesManager) {
        App.subscribeEvent('StandardRegisterFormWebclient::ShowView::after', function (oParams) {
          if ('CRegisterView' === oParams.Name) {
            sInvitationLinkHash = fGetInvitationLinkHash();
            if (sInvitationLinkHash !== '') {
              $.cookie('InvitationLinkHash', sInvitationLinkHash, {
                expires: 30
              });
            } else {
              $.removeCookie('InvitationLinkHash');
            }
            Ajax.send(Settings.ServerModuleName, 'GetUserPublicId', {
              'InvitationLinkHash': sInvitationLinkHash
            }, function (oResponse) {
              if (oResponse.Result) {
                App.broadcastEvent('ShowWelcomeRegisterText', {
                  'UserName': oResponse.Result,
                  'WelcomeText': TextUtils.i18n('INVITATIONLINKWEBCLIENT/INFO_WELCOME', {
                    'USERNAME': oResponse.Result,
                    'SITE_NAME': UserSettings.SiteName
                  })
                });
              } else {
                Screens.showError(TextUtils.i18n('INVITATIONLINKWEBCLIENT/REPORT_INVITATION_LINK_INCORRECT'), true);
                Routing.setHash([Settings.LoginModuleHash]);
              }
            });
          }
        });
        App.subscribeEvent('SendAjaxRequest::before', function (oParams) {
          if (oParams.Module === Settings.RegisterModuleName && oParams.Method === 'Register') {
            oParams.Parameters.InvitationLinkHash = sInvitationLinkHash;
          }
        });
      }
    };
  }
  $.removeCookie('InvitationLinkHash');
  if (sInvitationLinkHash !== '') {
    Ajax.send(Settings.ServerModuleName, 'GetUserPublicId', {
      'InvitationLinkHash': sInvitationLinkHash
    }, function (oResponse) {
      if (oResponse.Result) {
        Screens.showError(TextUtils.i18n('INVITATIONLINKWEBCLIENT/REPORT_LOGGED_IN'), true);
      }
    });
    App.subscribeEvent('clearAndReloadLocation::before', function (oParams) {
      oParams.OnlyReload = true;
    });
  }
  return null;
};

/***/ }),

/***/ "qFnw":
/*!********************************************************!*\
  !*** ./modules/InvitationLinkWebclient/js/Settings.js ***!
  \********************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {



var _ = __webpack_require__(/*! underscore */ "C3HO"),
  Types = __webpack_require__(/*! modules/CoreWebclient/js/utils/Types.js */ "ERH9");
module.exports = {
  ServerModuleName: 'InvitationLinkWebclient',
  RegisterModuleName: 'StandardRegisterFormWebclient',
  RegisterModuleHash: 'register',
  LoginModuleHash: 'login',
  /**
   * Initializes settings from AppData object sections.
   * 
   * @param {Object} oAppData Object contained modules settings.
   */
  init: function init(oAppData) {
    var oAppDataSection = oAppData['InvitationLinkWebclient'];
    if (!_.isEmpty(oAppDataSection)) {
      this.RegisterModuleName = Types.pString(oAppDataSection.RegisterModuleName, this.RegisterModuleName);
      this.RegisterModuleHash = Types.pString(oAppDataSection.RegisterModuleHash, this.RegisterModuleHash);
      this.LoginModuleHash = Types.pString(oAppDataSection.LoginModuleHash, this.LoginModuleHash);
    }
  }
};

/***/ })

}]);