"use strict";

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function EventRegistrationCtrlDeferred(n, t, i, r, u, f, e, o, s, h, c, l, a, v) {
    var y = this,
        w = $("#errorWarningPopup"),
        p = angular.extend;n.loaded = !1;u.then(function (u) {
        function k(i) {
            var r = i.filter(function (n) {
                return n.ShowDetails;
            })[0],
                f = r.Name + "-edit",
                u = i.map(function (n) {
                return n.Name + "-editable";
            });n.stepClasses = u.concat(f);t.$broadcast("descriptionSummary:update");u.length != 1 && g(r.Name);
        }function g(n) {
            var t = document.getElementsByClassName(n);setTimeout(function () {
                t[0].scrollIntoView({ behavior: "smooth" });
            }, 100);
        }function nt() {
            var n = l.resetSteps(y.model.IsRegistrationUpdate).filter(function (n) {
                return n.Editable;
            });k(n);
        }function d(n, t) {
            return function (i) {
                if (i.ContactId) {
                    for (var r = 0; r < y.PossibleAttendees.length; r++) {
                        if (y.PossibleAttendees[r][n] == i.ContactId) {
                            i.ContactInfo = y.PossibleAttendees[r];i.resetAdditionalPurchaseItems(y);break;
                        }
                    }t && h.reApplyAllValidDiscounts(y);
                }
            };
        }function tt() {
            return y.EventInfo.IsRegistrationUpdate ? p(new Contact(null, !0), { IsMe: !0 }, y.EventInfo.RegistrationInfo.RegisteredBy) : p(new Contact(), { IsMe: !0 });
        }p(y, u);p(n, { registrationService: f, userService: e, discountService: h, helpers: s, registrationSteps: l });y.INITIALCONTACTID = a.InitialContactId;y.PLACEHOLDERCONTACTID = a.PlaceholderContactId;y.billingSearchTerm = "";y.serverResponse = {};y.fileUploads = [];y.contactsSearchResults = [];y.orgSearchResults = [];y.sponsorSearchResults = [];y.SendEmailNotification = !0;y.validationMessages = [];y.insuranceLoading = !1;y.insuranceReady = !0;y.paymentSubmitted = !1;y.InsuranceErrorMessage = null;n.$on("EventInsuranceService:LoadingStatus", function (n, t) {
            r(function () {
                y.insuranceLoading = t.loading;
            });
        });n.$on("EventInsuranceService:ReadyStatus", function (n, t) {
            r(function () {
                y.insuranceReady = !y.IsEventInsuranceVisible(y) || t.ready;y.paymentSubmitted = y.PaymentSubmitted();
            });
        });n.$on("EventInsuranceService:ErrorClear", function () {
            r(function () {
                y.InsuranceErrorMessage = null;
            });
        });n.$on("EventInsuranceService:Error", function (n, t) {
            r(function () {
                y.InsuranceErrorMessage = t.message;
            });
        });y.billingTrackOptions = { Individual: 1, Organization: 2, ParentOrganization: 3 };y.model.CreatedByUser = _loginInfo.createdBy = tt();y.billing = { ContactInfo: y.model.CreatedByUser, PaymentMethod: 0, InvoiceLocked: !1, TotalPrice: null, PaymentInfo: null };y.model.CreatedByUser.Address = y.model.CreatedByUser.Address || {};p(y.model.CreatedByUser.Address, { CountryId: y.model.TenantCountryId, CountryCode: y.model.TenantCountryCode });y.model.PromoCodeDiscounts = [{ isValid: !1, promoCode: "", EventDiscountId: 0 }];n.$watch("form.$invalid", function (n) {
            y.status.isFormOk = !n;
        });n.$watch("vm.model.CreatedByUser.ContactId", function (n) {
            y.model.CreatedByUser.isEmpty || (y.selectedBillingContactId = n, e.updatePaymentWidgetValues(y, y.model.CreatedByUser), e.updateInsurance(y.model.CreatedByUser));
        });n.$watch("vm.model.CreatedByUser.isEmpty", function () {
            y.PossibleAttendees.addPossibleAttendeeIfNeeded();
        });n.$watch("vm.selectedBillingContactId", function () {
            v.calculateTaxes(y);
        });n.$watch("vm.stats.totalPayment", function () {
            y.recaptcha.updateRequirment();f.setPaymentWidgetAmounts(y);
        });n.getUploader = function (n) {
            var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
            var i = s.getCustomFieldUploader(n, t);return y.fileUploads.push(i), i;
        };var b = y.recaptcha = {};b.widgetId = null;b.updateRequirment = function () {
            b.required = f.shouldShowCaptcha(y);
        };n.setWidgetId = function (n) {
            b.widgetId = n;
        };n.onReCaptchaExpiration = function () {
            b.response = null;
        };n.onReCaptchaResponse = function (n) {
            b.response = n;
        };n.vcRecaptchaApiLoaded = function () {};b.updateRequirment();n.stepClasses = [];y.nextStep = function (n) {
            var t = l.goToNextStep(y, n).filter(function (n) {
                return n.Editable;
            });k(t);
        };y.editStep = function (n) {
            var t = l.editStep(n).filter(function (n) {
                return n.Editable;
            });k(t);
        };y.IsEventInsuranceVisible = function (n) {
            return n.EventInfo.IsRegistrationInsuranceEnabledAndConfigured && n.stats.totalDonationAmount === 0 && n.billing.PaymentMethod === 0 && n.stats.totalPayment > 0;
        };y.PaymentSubmitted = function () {
            return v.InsuranceCommitted();
        };y.isStepValid = function (n) {
            return l.isStepValid(y, n);
        };y.isStepAvailable = function (n) {
            return l.isStepAvailable(y, n);
        };y.addPossibleAttendee = function (n) {
            y.EventSettings.NoShowFeesAllowed && n.ContactId > 0 && e.getAttendeeNoShowFees(y, n);y.PossibleAttendees.push(n);
        };y.submitRegistration = function (t) {
            var i = c.showConfirmationPage.bind(null, y);f.submitRegistration(y, n.form, t, i);
        };y.paymentMethodChanged = function (t) {
            y.billing.PaymentMethod = t;y.showBillToEmail = t == 1 && !y.billing.ContactInfo.isEmpty && !y.billing.ContactInfo.EmailAddressText;n.form.$setDirty();y.recaptcha.updateRequirment();
        };y.SetContactOrOrg = d("OrgIdOrContactId", !0);y.ShowSignupAndSetContactOrOrg = function (n) {
            n.ContactId = n.InitialContactId;y.SetContactOrOrg(n);
        };y.SetAttendee = d("ContactId", !0);y.ShowSignupAndSetAttendee = function (n) {
            n.ContactId = n.InitialContactId;y.SetAttendee(n);
        };y.findContactByEmail = function () {
            n.form.billingEmail.$valid && (e.findContactByEmail(y), window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" }));
        };y.clearContactId = function (n) {
            y.model.CreatedByUser.clearContactId(n);h.reApplyAllValidDiscounts(y);
        };y.increaseRegistrations = function (t) {
            f.increaseRegistrations(y, n, t);
        };y.decreaseRegistrations = function (t) {
            f.decreaseRegistrations(y, n, t);
        };y.regAvailable = function () {
            return y.model.ShowAttendees || y.model.IsRegistrationUpdate || y.model.ShowSponsors && y.sponsorTypesHaveIncludedAttendees || y.model.ShowExhibitors && y.exhibitorTypesHaveIncludedAttendees;
        };y.anyRegTypeAvailable = function () {
            return y.regTypes.some(function (n) {
                return n.shouldShowToAttendees(y, e);
            });
        };y.anySponsorTypeAvailable = function () {
            return y.sponsorTypes.some(function (n) {
                return n.ShouldShowToSponsors(y);
            });
        };y.IsIncludedWithASelectedSponsor = function (n) {
            return y.sponsorTypes.filter(function (t) {
                return t.eventRegistrationTypeId == n;
            }).some(function (n) {
                return n.Sponsorships.length > 0;
            });
        };y.IsIncludedWithASelectedExhibitor = function (n) {
            return y.exhibitorTypes.filter(function (t) {
                return (t.AttendeeRegType || {}).eventRegistrationTypeId == n;
            }).some(function (n) {
                return n.Exhibitors.length > 0;
            });
        };y.anyRegTypesBelowLimit = function () {
            return y.regTypes.some(function (n) {
                return n.Remaining < 10;
            });
        };y.hasBothNonMemberAndMemberRegTypes = function () {
            var t = y.regTypes.some(function (n) {
                return n.IsForNonMembers;
            }),
                n = void 0;return n = y.IsSelfIdentifyAsMemberEventSecurityMode() ? y.regTypes.some(function (n) {
                return n.IsMemberOnly;
            }) : y.regTypes.some(function (n) {
                return n.MembershipTypesIds && n.MembershipTypesIds.length > 0;
            }), n && t;
        };y.increaseSponsorships = function (t) {
            var u, i, r;if (f.increaseSponsorships(y, n, t), u = t.Sponsorships.length === 0, !!t.AttendeeRegType) for (i = 0; i < t.Seed; i++) {
                f.increaseRegistrations(y, n, t.AttendeeRegType, null, t.Id);
            }u && (r = y.model.CreatedByUser.OrganizationContactId, r !== undefined && (t.Sponsorships[0].ContactId = r, y.SetContactOrOrg(t.Sponsorships[0])));
        };y.showRegistrationWarningMessage = function () {
            return y.ShowLoginRequiredToViewOptionsMesssages() ? (y.regWarningMessage = "Login to view all available options.", !0) : !1;
        };y.showRegistrationAlertMessage = function () {
            if (y.regAvailable() && y.anyRegTypeAvailable() || y.model.ShowExhibitors && y.EventInfo.IsExhibitorRegistrationOpen || y.model.ShowSponsors && y.EventInfo.IsSponsorshipRegistrationOpen) {
                if (!y.anyRegTypeAvailable() && y.model.CustomRegOptionsErrors != null) return y.regAlertMessage = y.model.CustomRegOptionsErrors, !0;
            } else return y.regAlertMessage = "No registration options are available.", !0;return !1;
        };y.ShowLoginRequiredToViewOptionsMesssages = function () {
            return y.hasBothNonMemberAndMemberRegTypes() && y.model.CreatedByUser.ContactId <= 0 && !y.loginInfo.isLoggedIn;
        };y.decreaseSponsorships = function (t) {
            if (!!t.AttendeeRegType) for (var i = 0; i < t.Seed; i++) {
                f.decreaseRegistrations(y, n, t.AttendeeRegType);
            }f.decreaseSponsorships(y, n, t);
        };y.increaseExhibitors = function (t) {
            var u = t.Exhibitors.length === 0,
                i,
                r;if (f.increaseExhibitors(y, n, t), !!t.AttendeeRegType) for (i = 0; i < t.Seed; i++) {
                f.increaseRegistrations(y, n, t.AttendeeRegType, t.Id), !y.status.PrimaryExhibitorContactAttendee && t.AttendeeRegType.ActiveAttendees[0] && y.togglePrimaryExhibitorContact(t.AttendeeRegType.ActiveAttendees[0]);
            }u && (r = y.model.CreatedByUser.OrganizationContactId, r !== undefined && (t.Exhibitors[0].ContactId = r, y.SetContactOrOrg(t.Exhibitors[0])));
        };y.decreaseExhibitors = function (t) {
            if (!!t.AttendeeRegType) for (var i = 0; i < t.Seed; i++) {
                f.decreaseRegistrations(y, n, t.AttendeeRegType);
            }f.decreaseExhibitors(y, n, t);
        };y.togglePrimaryExhibitorContact = function (n) {
            y.status.PrimaryExhibitorContactAttendee && (y.status.PrimaryExhibitorContactAttendee.PrimaryExhibitorContact = !1);n.PrimaryExhibitorContact = !0;y.status.PrimaryExhibitorContactAttendee = n;
        };y.addToWaitingList = function (t, i, r) {
            t.addToWaitingList(i, r);v.calculateTaxes(y);o.updateViolations(y, n.form);h.reApplyAllValidDiscounts(y);n.form.$setDirty();
        };y.getPaymentStepIndex = function () {
            var n = y.getDonationStepIndex();return n + (y.EventSettings.CollectDonations ? 1 : 0);
        };y.getDonationStepIndex = function () {
            var n = 4;return n += y.EventInfo.HasPromoCodes ? 1 : 0, n + (y.model.ValidOverallExtraPurchaseItems.length ? 1 : 0);
        };y.shouldShowRegistrationConfirmation = function () {
            var n = !y.status.maxEventLimitViolation.isOk + !y.status.maxAllRegistrationLimitViolation.isOk + !y.status.isAdditionalItemsLimitOk;return y.EventInfo.CurrentUserInfo.IsStaffUser && n > 0 && y.validationMessages && y.validationMessages.length && n == y.validationMessages[0].messages.length && y.validationMessages[1].messages.length == 0;
        };y.closeValidationSummaryModal = function (n) {
            if (w.css("display", "none"), y.overrideValidation = n, n) {
                var t = y.stats.totalPayment.toFixed(2);y.billing.PaymentMethod == 0 && t > 0 ? v.Submit() : y.submitRegistration(!0);
            }
        };y.IsSelfIdentifyAsMemberEventSecurityMode = function () {
            return y.EventSettings.MemberSecurityMode == Enums.SystemMemberSecurityModeOption.SelfIdentifyAsMember;
        };y.RemainingOverall = function () {
            return y.HasOverallLimit ? y.EventInfo.VacantSpotsPerEvent - y.stats.totalAttendeesCount : 9999;
        };y.RegTypesOverAmount = function () {
            return (y.regTypes.filter(function (n) {
                return n.RemainingPerType < 0;
            }) || []).map(function (n) {
                return n.RemainingPerType;
            }).reduce(function (n, t) {
                return n + t;
            }, 0);
        };y.OverallOverAmount = function () {
            return Math.min(y.RemainingOverall() > 0 ? 0 : y.RemainingOverall(), y.RegTypesOverAmount()) * -1;
        };$(i).on("click", function (n) {
            n.target == w[0] && y.closeValidationSummaryModal();
        });i.onbeforeunload = function () {
            c.storeUnsubmittedChanges(n.form.$dirty, y);
        };n.getTableCFValues = function (n) {
            return function (t, i) {
                if (n.tableValues = n.tableValues || {}, !n.tableValues[t]) {
                    var r = Array.isArray(i) ? i : JSON.parse(i);n.tableValues[t] = r;
                }return n.tableValues[t];
            };
        };n.AddNewChildRow = function (n) {
            n == null && (n = []);n.push({});
        };n.DeleteChildRow = function (n, t) {
            var i = 0,
                r = t.length;if (n) for (; i < r; i++) {
                if (n.$$hashKey === t[i].$$hashKey) {
                    t.splice(i, 1);return;
                }
            }
        };n.$on("$stateChangeStart", function () {
            c.storeUnsubmittedChanges(n.form.$dirty, y);
        });y.addPossibleAttendee(y.model.CreatedByUser);c.initializeData(y, n);nt(y.model.IsRegistrationUpdate);n.loaded = !0;
    });
}function formatPhoneNumberToAFormat(n, t) {
    if (n = n.trim(), n[0] == "+") return n;var f = n.toUpperCase(),
        i = "",
        r = -1,
        e = "";for (var _n = 0; _n < f.length; _n++) {
        var _t = f[_n];if (_t == "X") {
            r = _n;break;
        }if (_t == "E" && f.indexOf("EXT", _n) == _n) {
            r = _n;break;
        }i += _t;
    }e = i[i.length - 1] == " " ? " " : "";var h = r > -1 ? n.substring(r) : "";i = i.replace(/\D/g, "");var u = void 0,
        o = i,
        s = !1;return i.length == 10 && (u = i.match(/^(\d{3})(\d{3})(\d{4})$/)), i.length == 7 && (u = i.match(/^(\d{3})(\d{4})$/)), u && (s = !0, o = t(i, u)), s ? o + e + h : n;
}function formatToParanthessisWithDashes(n, t) {
    return n.length == 10 ? "(" + t[1] + ") " + t[2] + "-" + t[3] : n.length == 7 ? t[1] + "-" + t[2] : n;
}function formatPhoneToDotted(n, t) {
    return n.length == 10 ? t[1] + "." + t[2] + "." + t[3] : n.length == 7 ? t[1] + "." + t[2] : n;
}function formatPhoneToDashses(n, t) {
    return n.length == 10 ? t[1] + "-" + t[2] + "-" + t[3] : n.length == 7 ? t[1] + "-" + t[2] : n;
}var _possibleContacts, _defaultCountryId, INITIAL_CONTACT_ID, PLACEHOLDER_CONTACT_ID, app;Array.prototype.find || Object.defineProperty(Array.prototype, "find", { value: function value(n) {
        var i, u, f, t, r;if (this == null) throw new TypeError("this is null or not defined");if (i = Object(this), u = i.length >>> 0, typeof n != "function") throw new TypeError("predicate must be a function");for (f = arguments[1], t = 0; t < u;) {
            if (r = i[t], n.call(f, r, t, i)) return r;t++;
        }return undefined;
    } }), function (n) {
    n(function () {
        var t = n(".RegistrationHeader"),
            r = t.find(".see-more-toggle"),
            i = t.find(".teaser"),
            u = i.height();i.height() > 500 && (t.addClass("teaser-required").addClass("teaser-applied"), r.show().click(function () {
            t.toggleClass("teaser-applied");
        }));
    });
}(jQuery), function () {
    function n() {
        return { require: "ngModel", link: function link(n, t, i, r) {
                r.$parsers.push(function (n) {
                    return n ? parseInt(n, 10) : null;
                });r.$formatters.push(function (n) {
                    return n || n == 0 ? "" + n : null;
                });
            } };
    }window.app.directive("selectOptionsToNumber", [n]);
}(), function () {
    window.app.directive("decimalMask", [function () {
        var n = function n(_n2, t, i, r) {
            var u = function u(n) {
                var i = parseFloat(n);return i > 0 && i < 1 && (n = i.toString(), t.val(n)), r.$setValidity("decimalMask", !0), n;
            };r.$parsers.unshift(u);r.$formatters.push(function (n) {
                return parseFloat(n);
            });
        };return { require: "ngModel", link: n };
    }]);
}(), function () {
    window.app.directive("includeReplace", function () {
        return { require: "ngInclude", restrict: "A", link: function link(n, t) {
                t.replaceWith(t.children());
            } };
    });
}();app.directive("additionalItems", function () {
    return { restrict: "E", template: "<table class=\"table table-condensed\">\n                    <thead>\n                        <tr>\n                            <th>Name</th>\n                            <th>Description</th>\n                            <th style=\"width: 20%\">Price</th>\n                            <th style=\"width: 20%\">         <span class=\"visible-xs visible-sm\"><abbr title=\"Include\">Inc</abbr></span><span class=\"hidden-xs hidden-sm\">Include</span></th>\n                        </tr>\n                    </thead>\n                    <tbody>\n                        <tr ng-repeat=\"item in items | orderBy: Name\">\n                            <td>\n                                {{item.Name + (item.IsMemberOnly ? \" \" + memberOnlyMsg : \"\") }}\n                                <span style=\"font-style: italic\" ng-if=\"!isStaffUser && item.ShowRemainingInventory\">\n                                 (Remaining: {{item.InventoryRemaining}})\n                                </span>\n                            </td>\n                            <td>\n                                {{item.Description}}\n                            </td>\n                            <td class=\"currency\">\n                                {{item.Price | currency }}\n                            </td>\n                            <td class=\"td-center\" ng-if=\"!item.IsSoldOut || isStaffUser\">\n                                <span ng-if=\"item.IsYesNo\"><button type=\"button\" ng-disabled=\"!item.Enabled\" class=\"btn btn-default btn-xs checkbox\" ng-class=\"{ 'checked': item.PurchaseCount == 1 }\" ng-click=\"item.PurchaseCount = !item.PurchaseCount ? 1 : 0; onQuantityChange({item: item});\"><i class=\"glyphicon glyphicon-ok\"></i></button></span>\n                                <span ng-if=\"!item.IsYesNo\"><input aria-label=\"{{item.Name}} quantity\" type=\"number\" style=\"width: 50px\" ng-model=\"item.PurchaseCount\" min=\"0\" ng-min=\"0\" ng-disabled=\"!item.Enabled\" ng-change=\"onQuantityChange({item: item})\" /></span>\n                                <span class=\"alert alert-danger col-sm-12\" style=\"padding: 5px;margin-bottom: 0;\" ng-show=\"item.ShouldShowLimitError\">\n                                    Maximum additional item has been reached. Please remove {{item.InventoryRemaining * -1 }} to continue.\n                                </span>\n                            </td>\n                            <td class=\"td-center\" ng-if=\"item.IsSoldOut && !isStaffUser\">\n                                <span class=\"alert alert-danger col-sm-12\" style=\"padding: 5px;margin-bottom: 0;width: 50%\">\n                                    Sold out\n                                </span>\n                            </td>\n                        </tr>\n                    </tbody>\n                </table>\n                ", replace: !0, scope: { isStaffUser: "=isStaffUser", items: "=items", memberOnlyMsg: "=memberOnlyMsg", onQuantityChange: "&" }, transclude: !0, controller: ["$scope", function () {}], link: function link() {} };
});app.directive("descriptionSummary", ["$timeout", function (n) {
    function t(t, i) {
        n(function () {
            var n = i.find(".regtype-description").height();n > 20 && (t.allowExpand = !0, t.show = !1);
        });
    }return { restrict: "A", scope: { alwaysShow: "=show", description: "=description" }, template: '<div ng-if="description" class="regtype-description-container"><span ng-show="allowExpand" class="fa regtype-description-btn" ng-class="{\'fa-chevron-down\': !show, \'fa-chevron-up\': !!show }" ng-click="show = !show" title="Expand/Collapse Description"><\/span><div class="regtype-description" ng-class="{\'show-full\': !!description && show, \'truncate\': !show, }" ng-bind-html="description"><\/div><\/div>', link: function link(n, i) {
            n.allowExpand = !1;n.show = !0;n.alwaysShow || (n.$watch("description", function () {
                t(n, i);
            }), n.$on("descriptionSummary:update", function () {
                t(n, i);
            }));
        } };
}]), function (n) {
    n.filter("isNotEmptyOrCurrent", ["ContactSelectionService", function (n) {
        return function (t, i, r) {
            return (t || []).filter(function (u) {
                return !!r && u.ContactId == n.InitialContactId ? !0 : u.ContactId > 0 ? !0 : u.isEmpty ? u.ContactId == i.ContactId ? !0 : !i.ContactInfo.isEmpty && u.ContactId == t.filter(function (t) {
                    return !n.ReservedContactIds.includes(t.ContactId);
                }).filter(function (n) {
                    return !n.isAttachedToAttendee;
                }).min("contactId") ? !0 : !1 : !0;
            });
        };
    }]);n.filter("removePlaceholder", ["ContactSelectionService", function (n) {
        return function (t, i, r) {
            return (t || []).filter(function (t) {
                return t.ContactId != n.PlaceholderContactId || !!(i || {}).IsRequired && !i.IsRequired(r || 0);
            });
        };
    }]);n.filter("localizeAs", ["$filter", function (n) {
        return function (t, i) {
            var r = t.replace("[[Attendee]]", i);return n("localizeString")(r, "[");
        };
    }]);n.filter("isMeOrNew", function () {
        return function (n, t) {
            function i(n) {
                var i = (t || {}).ContactId;return n.ContactId == i;
            }function r(n) {
                return n.ContactId < 0;
            }return (n || []).filter(function (n) {
                return r(n) || i(n);
            });
        };
    });n.filter("isNotArchived", function () {
        return function (n) {
            return n.filter(function (n) {
                return !n.IsArchived;
            });
        };
    });n.filter("hasAnyNotArchived", function () {
        return function (n) {
            return !!n.filter(function (n) {
                return !n.IsArchived;
            }).length;
        };
    });
}(window.app), function (n) {
    n.filter("unique", function () {
        return function (n, t) {
            if (t === !1) return n;if ((t || angular.isUndefined(t)) && angular.isArray(n)) {
                var i = [],
                    r = function r(n) {
                    return angular.isObject(n) && angular.isString(t) ? n[t] : n;
                };angular.forEach(n, function (n) {
                    for (var u = !1, t = 0; t < i.length; t++) {
                        if (angular.equals(r(i[t]), r(n))) {
                            u = !0;break;
                        }
                    }u || i.push(n);
                });n = i;
            }return n;
        };
    });
}(window.app);_possibleContacts = [];_defaultCountryId = null;
var Stats = function () {
    function Stats() {
        _classCallCheck(this, Stats);

        this.nextContactId = -1;this.totalPrice = 0;this.totalTaxes = 0;this.totalInsurance = 0;this.totalInsuranceInCents = 0;this.totalDiscount = 0;this.hiddenDiscount = 0;this.totalPayment = 0;this.totalDonationAmount = 0;this.existingAttendeesCount = 0;this.waitingCount = 0;this.totalAttendeesCount = 0;this.totalSponsorsCount = 0;this.totalExhibitorsCount = 0;this.sessionsAttendeesCount = {};this.additionalItemsUsageCount = {};
    }

    _createClass(Stats, [{
        key: "subtractDecimals",
        value: function subtractDecimals(n, t) {
            return Math.round(n * 100 - t * 100) / 100;
        }
    }, {
        key: "addDecimals",
        value: function addDecimals(n, t) {
            return Math.round(n * 100 + t * 100) / 100;
        }
    }, {
        key: "UpdateInsurance",
        value: function UpdateInsurance(n) {
            this.totalInsuranceInCents = n;this.totalInsurance = n ? n / 100 : n;
        }
    }, {
        key: "AddToPrice",
        value: function AddToPrice(n) {
            this.totalPrice = this.addDecimals(this.totalPrice, n);this.totalPayment = this.addDecimals(this.totalPayment, n);
        }
    }, {
        key: "RemoveFromPrice",
        value: function RemoveFromPrice(n) {
            this.totalPrice = this.subtractDecimals(this.totalPrice, n);this.totalPayment = this.subtractDecimals(this.totalPayment, n);
        }
    }, {
        key: "SetTaxesValue",
        value: function SetTaxesValue(n) {
            n = n || 0;this.totalTaxes > 0 && (this.totalPayment = this.subtractDecimals(this.totalPayment, this.totalTaxes));this.totalTaxes = n;this.totalPayment = this.addDecimals(this.totalPayment, n);
        }
    }, {
        key: "AddToHiddenDiscounts",
        value: function AddToHiddenDiscounts(n) {
            this.hiddenDiscount = this.addDecimals(this.hiddenDiscount, n);this.totalPayment = this.subtractDecimals(this.totalPayment, n);
        }
    }, {
        key: "AddToDiscounts",
        value: function AddToDiscounts(n) {
            this.totalDiscount = this.addDecimals(this.totalDiscount, n);this.totalPayment = this.subtractDecimals(this.totalPayment, n);
        }
    }, {
        key: "RemoveFromHiddenDiscounts",
        value: function RemoveFromHiddenDiscounts(n) {
            this.hiddenDiscount = this.subtractDecimals(this.hiddenDiscount, n);this.totalPayment = this.addDecimals(this.totalPayment, n);
        }
    }, {
        key: "RemoveFromDiscounts",
        value: function RemoveFromDiscounts(n) {
            this.totalDiscount = this.subtractDecimals(this.totalDiscount, n);this.totalPayment = this.addDecimals(this.totalPayment, n);
        }
    }, {
        key: "ResetDiscounts",
        value: function ResetDiscounts() {
            this.totalPayment = this.addDecimals(this.totalPayment, this.totalDiscount);this.totalPayment = this.addDecimals(this.totalPayment, this.hiddenDiscount);this.totalDiscount = 0;this.hiddenDiscount = 0;
        }
    }, {
        key: "DisplayTotal",
        get: function get() {
            return this.subtractDecimals(this.totalPrice, this.hiddenDiscount).toFixed(2);
        }
    }, {
        key: "DisplayPaymentWithInsuranceTotal",
        get: function get() {
            return this.addDecimals(this.totalPayment, this.totalInsurance).toFixed(2);
        }
    }, {
        key: "DisplayPaymentTotal",
        get: function get() {
            return this.totalPayment.toFixed(2);
        }
    }, {
        key: "DisplayInsuranceTotal",
        get: function get() {
            return this.totalInsurance.toFixed(2);
        }
    }]);

    return Stats;
}();

var RegistrationType = function () {
    function RegistrationType(n) {
        _classCallCheck(this, RegistrationType);

        this.eventRegistrationTypeId = n;this.RegistrationsCount = 0;this.AttendeesCount = 0;this.Enabled = !0;this.Attendees = [];this.WaitlistEnabled = !1;
    }

    _createClass(RegistrationType, [{
        key: "increase",
        value: function increase(n, t, i, r) {
            this.AttendeesCount = this.AttendeesCount + this.AttendeesCountPerOneRegistration;this.RegistrationsCount = this.RegistrationsCount + 1;this.addAttendees(n, t, i, r);this.updateStats(!0);
        }
    }, {
        key: "decrease",
        value: function decrease() {
            this.RegistrationsCount > 0 && (this.AttendeesCount = this.AttendeesCount - this.AttendeesCountPerOneRegistration, this.RegistrationsCount = this.RegistrationsCount - 1, this.updateStats());
        }
    }, {
        key: "addAttendees",
        value: function addAttendees(n, t, i, r) {
            var f;if (this.Attendees.length < this.AttendeesCount) for (f = this.Attendees.length; f < this.AttendeesCount; f++) {
                var e = t && this.Attendees.length == 0 && !n,
                    o = !e,
                    u = new Attendee(this, o, i, r);u.IsBulkAttendee = this.AttendeesCountPerOneRegistration > 1 && !!(f % this.AttendeesCountPerOneRegistration);e && (u.ContactInfo = _possibleContacts[0], u.setAttendeeNoShowFees());u.IsBulkAttendee && (u.Price = 0);this.Remaining < 0 && this.WaitlistEnabled && !this.HasOverallLimit && this.AttendeesCountPerOneRegistration == 1 && this.addToWaitingList(u, f);this.Attendees.push(u);
            }
        }
    }, {
        key: "updateStats",
        value: function updateStats(n) {
            n ? (_stats.totalAttendeesCount += this.AttendeesCountPerOneRegistration || 1, this.RegistrationsCount - this.PurchasedSlots > 0 && _stats.AddToPrice(this.Price)) : (this.InActiveAttendees.forEach(function (n) {
                n.clearAdditionalItem(), n.clearSessionFees();
            }), _stats.totalAttendeesCount -= this.AttendeesCountPerOneRegistration || 1, this.RegistrationsCount - this.PurchasedSlots >= 0 && _stats.RemoveFromPrice(this.Price));
        }
    }, {
        key: "AllowIncrease",
        value: function AllowIncrease(n) {
            return this.Enabled ? !n.EventInfo.CurrentUserInfo.IsStaffUser && (this.AttendeeCountAtLimit || (this.Remaining <= 0 || this.RemainingOverall < this.AttendeesCountPerOneRegistration) && !n.EventInfo.AllowWaitingList) ? !1 : !0 : !1;
        }
    }, {
        key: "addToWaitingList",
        value: function addToWaitingList(n, t) {
            var f = n.AddToWaitingList !== !0,
                i = this.AttendeesCountPerOneRegistration,
                u,
                r;if (i > 1) for (u = t % i == 0 ? t : parseInt(t / i) * i, r = u; r < u + i; r++) {
                this.updateAttendeeWaitingListStatus(this.Attendees[r], f, r == u, t);
            } else this.updateAttendeeWaitingListStatus(n, f, !0, t);
        }
    }, {
        key: "updateAttendeeWaitingListStatus",
        value: function updateAttendeeWaitingListStatus(n, t, i, r) {
            n.AddToWaitingList = t;t ? (n.Price = 0, _stats.waitingCount += 1, i && _stats.RemoveFromPrice(this.Price)) : (n.Price = this.getAttendeePrice(r), _stats.waitingCount -= 1, i && _stats.AddToPrice(this.Price));
        }
    }, {
        key: "isDiscountValid",
        value: function isDiscountValid(n) {
            var t = n.LimitPerPurchase;return t && t <= n.LocalUsedQuantity ? !1 : n.TotalAvailable && n.TotalAvailable - (n.UsedQuantity + n.LocalUsedQuantity) <= 0 ? !1 : (n.MembershipTypesIds || []).length ? !1 : n.IsVoucher ? !1 : this.IsBulkRegistration && !!this.RegistrationsCount && (!n.ExhibitorAddedRegistrationTypeId || n.ExhibitorAddedRegistrationTypeId == this.EventRegistrationTypeId) && (!n.SponsorAddedRegistrationTypeId || n.SponsorAddedRegistrationTypeId == this.EventRegistrationTypeId) && (!n.EventRegistrationTypeId || n.EventRegistrationTypeId == this.EventRegistrationTypeId);
        }
    }, {
        key: "shouldShowToAttendees",
        value: function shouldShowToAttendees(n, t) {
            if (n.loginInfo.isStaff || n.IsIncludedWithASelectedSponsor(this.eventRegistrationTypeId) || n.IsIncludedWithASelectedExhibitor(this.eventRegistrationTypeId)) return !0;if (!n.model.ShowAttendees || this.IsForIncludedRegistrationsOnly) return !1;var i = !n.IsSelfIdentifyAsMemberEventSecurityMode() || n.loginInfo.isLoggedIn,
                r = this.MembershipTypesIds || [];if (r.length && i) {
                var _i = n.model.CreatedByUser.MembershipIds.concat(n.EventInfo.CurrentUserInfo.MembershipIds || []).map(function (n) {
                    return n.MembershipTypeId;
                }),
                    _t2 = r.some(function (n) {
                    return _i.includes(n);
                });return !_t2 && (n.model.CreatedByUser.ContactId > 0 || n.loginInfo.isLoggedIn) && (n.model.CustomRegOptionsErrors = "No attendee registration options are available for this " + n.EventInfo.MembershipTerm + "." + (n.EventInfo.OrganizationName ? " Please contact " + n.EventInfo.OrganizationName + " for additional information." : "")), _t2;
            }if (n.loginInfo.isMember) {
                var _t3 = this.IsForMembers && i || this.ActiveAttendees.length > 0;return !_t3 && this.IsForMembers && (n.model.CustomRegOptionsErrors = "Login to view all available options."), _t3;
            }return this.IsDisplayedForNonMembers || this.IsForNonMembers || this.ActiveAttendees.length > 0 || t.hasAccessToMemberOnlyFeature(n);
        }
    }, {
        key: "getAttendeePrice",
        value: function getAttendeePrice(n) {
            return this.AttendeesCountPerOneRegistration > 1 && n % this.AttendeesCountPerOneRegistration > 0 ? 0 : this.Price;
        }
    }, {
        key: "applyDiscount",
        value: function applyDiscount(n) {
            var t = this.AttendeesCountPerOneRegistration;return this.Attendees.filter(function (n, i) {
                return !(i % t);
            }).reduce(function (t, i) {
                var r = i.DiscountsApplied.some(function (t) {
                    return n.EventDiscountId == t.EventDiscountId;
                });return t + (r ? 0 : i.applyDiscount(n));
            }, 0);
        }
    }, {
        key: "removeDiscount",
        value: function removeDiscount(n) {
            var t = this.AttendeesCountPerOneRegistration;return this.Attendees.filter(function (n, i) {
                return !(i % t);
            }).reduce(function (t, i) {
                return t + i.removeDiscount(n);
            }, 0);
        }
    }, {
        key: "getSpecificDiscountAmount",
        value: function getSpecificDiscountAmount(n) {
            var t = this.Price;if (!t || !n) return 0;var i = n.DiscountAmount || 0;return n.DiscountPercent && (i += t * n.DiscountPercent / 100), (n.DiscountNewPrice || n.DiscountNewPrice == 0) && (i += t > n.DiscountNewPrice ? t - n.DiscountNewPrice : 0), t > i ? i : t;
        }
    }, {
        key: "IsBulkRegistration",
        get: function get() {
            return this.AttendeesCountPerOneRegistration > 1;
        }
    }, {
        key: "RegistrationsCount",
        get: function get() {
            return this.registrationsCount;
        },
        set: function set(n) {
            this.registrationsCount = n;
        }
    }, {
        key: "PurchasedSlots",
        get: function get() {
            return this.purchasedSlots;
        },
        set: function set(n) {
            this.purchasedSlots = n;
        }
    }, {
        key: "AttendeesCount",
        get: function get() {
            return this.attendeesCount;
        },
        set: function set(n) {
            this.attendeesCount = n;
        }
    }, {
        key: "Enabled",
        get: function get() {
            return this.enabled;
        },
        set: function set(n) {
            this.enabled = n;
        }
    }, {
        key: "Name",
        get: function get() {
            return this.name;
        },
        set: function set(n) {
            this.name = n;
        }
    }, {
        key: "Price",
        get: function get() {
            return this.price;
        },
        set: function set(n) {
            this.price = n;
        }
    }, {
        key: "TotalItemTax",
        get: function get() {
            return this.price * this.TotalTaxRate + this.TotalTaxFlatAmount;
        }
    }, {
        key: "PossibleContacts",
        get: function get() {
            return this.possibleContacts;
        },
        set: function set(n) {
            this.possibleContacts = n;
        }
    }, {
        key: "EventRegistrationTypeId",
        get: function get() {
            return this.eventRegistrationTypeId;
        },
        set: function set(n) {
            this.eventRegistrationTypeId = n;
        }
    }, {
        key: "EventRegistrationId",
        get: function get() {
            return this.eventRegistrationId;
        },
        set: function set(n) {
            this.eventRegistrationId = n;
        }
    }, {
        key: "ActiveAttendees",
        get: function get() {
            return this.Attendees.slice(0, this.AttendeesCount);
        }
    }, {
        key: "InActiveAttendees",
        get: function get() {
            return this.Attendees.slice(this.AttendeesCount);
        }
    }, {
        key: "WaitlistEnabled",
        get: function get() {
            return this.waitlistEnabled;
        },
        set: function set(n) {
            this.waitlistEnabled = n;
        }
    }, {
        key: "VacantSpotsPerEvent",
        get: function get() {
            return this.vacantSpotsPerEvent;
        },
        set: function set(n) {
            this.vacantSpotsPerEvent = n;
        }
    }, {
        key: "MaximumAttendeesPerEvent",
        get: function get() {
            return this.maximumAttendeesPerEvent;
        },
        set: function set(n) {
            this.maximumAttendeesPerEvent = n;
        }
    }, {
        key: "RemainingOverall",
        get: function get() {
            return this.HasOverallLimit ? this.VacantSpotsPerEvent - _stats.totalAttendeesCount : 9999;
        }
    }, {
        key: "Remaining",
        get: function get() {
            return this.HasOverallLimit ? Math.min(this.RemainingOverall, this.RemainingPerType * this.AttendeesCountPerOneRegistration) : this.HasLimit ? this.RemainingPerType * this.AttendeesCountPerOneRegistration : 255;
        }
    }, {
        key: "RemainingPerType",
        get: function get() {
            return this.HasLimit ? this.VacantSpots - this.AttendeesCount / this.AttendeesCountPerOneRegistration : 255;
        }
    }, {
        key: "RemainingLimit",
        get: function get() {
            return this.LimitPerPurchase - this.AttendeesCount / this.AttendeesCountPerOneRegistration;
        }
    }, {
        key: "HasLimit",
        get: function get() {
            return this.Max > 0;
        }
    }, {
        key: "HasOverallLimit",
        get: function get() {
            return this.MaximumAttendeesPerEvent > 0;
        }
    }, {
        key: "CurrentUsedCount",
        get: function get() {
            return this.AttendeesCountPerOneRegistration > 1 ? this.RegistrationsCount - this.PurchasedSlots - this.WaitingListAttendeesCount : this.AttendeesCount - this.PurchasedSlots - this.WaitingListAttendeesCount;
        }
    }, {
        key: "AttendeeCountOverTheLimit",
        get: function get() {
            return this.VacantSpots > 0 || this.Max > 0 ? Math.max(0, this.CurrentUsedCount - this.VacantSpots) : 0;
        }
    }, {
        key: "AttendeeCountAtLimit",
        get: function get() {
            return this.ReachedLimitPerPurchase ? !0 : this.Remaining == 0 && !this.WaitlistEnabled ? !0 : !1;
        }
    }, {
        key: "ReachedLimitPerPurchase",
        get: function get() {
            return this.LimitPerPurchase > 0 && this.CurrentUsedCount >= this.LimitPerPurchase;
        }
    }, {
        key: "WaitingListAttendeesCount",
        get: function get() {
            return this.ActiveAttendees.filter(function (n) {
                return n.AddToWaitingList;
            }).length;
        }
    }]);

    return RegistrationType;
}();

var LimitedType = function () {
    function LimitedType(n, t, i, r, u) {
        _classCallCheck(this, LimitedType);

        this.AttendeeRegType = n.filter(function (n) {
            return n.eventRegistrationTypeId === t;
        })[0];this.AttendeesIncluded = r;this.HasLimit = u != 9999;this.UnlimitedAttendeesIncluded = i;this.AttendeesCountPerOneRegistration = (this.AttendeeRegType || {}).AttendeesCountPerOneRegistration || 0;this.IncludedAttendeesCount = (this.AttendeesIncluded || 0) * this.AttendeesCountPerOneRegistration;this.Seed = this.UnlimitedAttendeesIncluded ? 1 : (this.AttendeesIncluded || 0) > 10 ? 10 : this.AttendeesIncluded || 0;
    }

    _createClass(LimitedType, [{
        key: "AllowIncrease",
        value: function AllowIncrease(n) {
            return !!this.AttendeeRegType && !n.EventInfo.CurrentUserInfo.IsStaffUser && (this.AttendeeRegType.LimitPerPurchase > 0 && this.AttendeeRegType.RemainingLimit < this.Seed || !n.EventInfo.AllowWaitingList && this.AttendeeRegType.Remaining < this.Seed * this.AttendeesCountPerOneRegistration || !this.AttendeeRegType.AllowIncrease(n)) ? !1 : !0;
        }
    }]);

    return LimitedType;
}();

var ExhibitorTypeModel = function (_LimitedType) {
    _inherits(ExhibitorTypeModel, _LimitedType);

    function ExhibitorTypeModel(n, t, i, r, u, f, e, o) {
        _classCallCheck(this, ExhibitorTypeModel);

        var _this = _possibleConstructorReturn(this, (ExhibitorTypeModel.__proto__ || Object.getPrototypeOf(ExhibitorTypeModel)).call(this, r, t, o, i, e));

        _this.exhibitorTypeId = n;_this.showDescription = !1;_this.Exhibitors = [];_this.DirectoryId = u;_this.EventDetailId = f;return _this;
    }

    _createClass(ExhibitorTypeModel, [{
        key: "AllowExhibitorIncrease",
        value: function AllowExhibitorIncrease(n) {
            return this.HasLimit && this.Remaining <= 0 ? !1 : this.AllowIncrease(n);
        }
    }, {
        key: "increase",
        value: function increase() {
            this.Exhibitors.push(new Exhibitor(this));
        }
    }, {
        key: "decrease",
        value: function decrease() {
            this.Exhibitors.pop();
        }
    }, {
        key: "Remaining",
        get: function get() {
            return this.HasLimit ? this.VacantSpots - this.Exhibitors.length : 9999;
        }
    }, {
        key: "EventExhibitorTypeId",
        get: function get() {
            return this.exhibitorTypeId;
        }
    }]);

    return ExhibitorTypeModel;
}(LimitedType);

var DiscountableItem = function () {
    function DiscountableItem() {
        _classCallCheck(this, DiscountableItem);

        this.discountsApplied = [];this.UsedMembershipDiscounts = {};
    }

    _createClass(DiscountableItem, [{
        key: "resetDiscounts",
        value: function resetDiscounts() {
            var _this2 = this;

            this.DiscountsApplied = [];Object.keys(this.UsedMembershipDiscounts).forEach(function (n) {
                _this2.UsedMembershipDiscounts[n].Available = _this2.UsedMembershipDiscounts[n].Initial;
            });this.UsedMembershipDiscounts = {};
        }
    }, {
        key: "getAllDiscountsTotal",
        value: function getAllDiscountsTotal(n, t) {
            var i = this;return !n || i.EventAttendeeId ? 0 : i.DiscountsApplied.reduce(function (r, u) {
                return r + i.getPriceSpecificDiscountAmount(n, u, t);
            }, 0);
        }
    }, {
        key: "addDiscountUsage",
        value: function addDiscountUsage(n, t) {
            if (!this.isMembershipDiscountAlreadyUsed(n)) {
                var u = this.hasNoUsesRemaining;var i = t.filter(function (t) {
                    return n.MembershipTypesIds.includes(t.MembershipTypeId) && !u(t.MembershipId, n);
                })[0],
                    r = n.AvailableForMembership[i.MembershipId] = n.AvailableForMembership[i.MembershipId] || { MembershipId: i.MembershipId, Available: n.MaxPerMembership, Initial: n.MaxPerMembership };this.UsedMembershipDiscounts[n.DiscountId] = r;r.Available--;
            }
        }
    }, {
        key: "isMembershipDiscountAlreadyUsed",
        value: function isMembershipDiscountAlreadyUsed(n) {
            return !!this.UsedMembershipDiscounts[n.DiscountId];
        }
    }, {
        key: "hasNoUsesRemaining",
        value: function hasNoUsesRemaining(n, t) {
            var i = t.AvailableForMembership[n] ? t.AvailableForMembership[n].Available : t.MaxPerMembership;return i <= 0;
        }
    }, {
        key: "applyDiscount",
        value: function applyDiscount(n) {
            var t = 0;if (this.DiscountsApplied.push(n), n.LocalUsedQuantity += 1, (n.MembershipTypesIds || []).length && n.MaxPerMembership) {
                var _t4 = this.ContactInfo.MembershipIds;this.addDiscountUsage(n, _t4);
            }var i = this.Price - this.AllDiscountsTotal,
                r = this.getSpecificDiscountAmount(n);return t = i < 0 ? i + r : r, t > 0 ? t : 0;
        }
    }, {
        key: "removeDiscount",
        value: function removeDiscount(n) {
            var t = 0;if (this.DiscountsApplied.length) {
                var i = this.DiscountsApplied.map(function (n) {
                    return n ? n.EventDiscountId : null;
                }).indexOf(n.EventDiscountId);if (i >= 0) {
                    var r = this.Price - this.AllDiscountsTotal;this.DiscountsApplied.splice(i, 1);n.LocalUsedQuantity = (n.LocalUsedQuantity || 1) - 1;var u = this.getSpecificDiscountAmount(n);t = r < 0 ? r + u : u;
                }
            }return t > 0 ? t : 0;
        }
    }, {
        key: "getSpecificDiscountAmount",
        value: function getSpecificDiscountAmount(n) {
            return this.getPriceSpecificDiscountAmount(this.Price, n, !1);
        }
    }, {
        key: "getPriceSpecificDiscountAmount",
        value: function getPriceSpecificDiscountAmount(n, t, i) {
            if (!n || !t) return 0;var f = t.DiscountAmount,
                r = t.DiscountNewPrice;i && i === !0 && (f = 0, r && (r = 0));var u = f || 0;return t.DiscountPercent && (u += n * t.DiscountPercent / 100), (r || r == 0) && (u += n > r ? n - r : 0), n > u ? u : n;
        }
    }, {
        key: "_isDiscountValid",
        value: function _isDiscountValid(n) {
            var t = n.LimitPerPurchase,
                i = (this.ContactInfo.MembershipIds || []).filter(function (n) {
                return !!n;
            }),
                r = i.map(function (n) {
                return n.MembershipTypeId;
            }),
                u = i.map(function (n) {
                return n.MembershipLevelId;
            });if (t && t <= n.LocalUsedQuantity) return n.ErrorMessage = "Discount was not applied because the limit per purchase was reached.", !1;if (n.TotalAvailable > 0 && n.TotalAvailable - n.UsedQuantity - n.LocalUsedQuantity <= 0) return n.ErrorMessage = "Discount was not applied because the limit was reached.", !1;if ((n.MembershipTypesIds || []).length) {
                if (!r.some(function (t) {
                    return n.MembershipTypesIds.includes(t);
                })) return n.ErrorMessage = "Discount was not applied because the attendee doesn't have the required membership type.", !1;if (n.MembershipLevelId && !u.some(function (t) {
                    return n.MembershipLevelId == t;
                })) return n.ErrorMessage = "Discount was not applied because the attendee doesn't have the required membership level.", !1;var _t5 = this.hasNoUsesRemaining;if (n.MaxPerMembership && !this.isMembershipDiscountAlreadyUsed(n) && !i.some(function (i) {
                    return n.MembershipTypesIds.includes(i.MembershipTypeId) && !_t5(i.MembershipId, n);
                })) return n.ErrorMessage = "Discount was not applied because the attendee memberhsip has not more usages allowed.", !1;
            }return !!n.PromoCode && !n.CanBeUsedWithOtherDiscounts && !!this.DiscountsApplied.length ? (n.ErrorMessage = "Discount cannot be used with other discounts.", !1) : n.IsVoucher && n.ContactId != this.ContactId ? !1 : t && this.TotalDiscount >= this.Price ? (n.EventDiscountId > 0 && (n.LocalUsedQuantity += 1), !1) : n.DiscountNewPrice > 0 && this.DiscountsApplied.some(function (t) {
                return t.DiscountNewPrice > 0 && t.DiscountNewPrice <= n.DiscountNewPrice;
            }) ? !1 : !0;
        }
    }, {
        key: "DiscountsApplied",
        get: function get() {
            return this.discountsApplied;
        },
        set: function set(n) {
            this.discountsApplied = n;
        }
    }, {
        key: "IsDiscounted",
        get: function get() {
            return !!this.DiscountsApplied.length;
        }
    }, {
        key: "IsExhibitor",
        get: function get() {
            return this.DiscountsApplied.some(function (n) {
                return n.ExhibitorAddedRegistrationTypeId;
            });
        }
    }, {
        key: "IsSponsor",
        get: function get() {
            return this.DiscountsApplied.some(function (n) {
                return n.SponsorAddedRegistrationTypeId;
            });
        }
    }, {
        key: "IsBenefit",
        get: function get() {
            return this.DiscountsApplied.some(function (n) {
                return n.IsBenefit;
            });
        }
    }, {
        key: "DiscountMessage",
        get: function get() {
            return this.IsExhibitor ? "- Price is included with Exhibitor" : this.IsSponsor ? "- Price is included with [[Sponsor]]" : this.IsBenefit ? "- Included as a Benefit" : this.IsDiscounted ? "- Discounts have been applied" : "";
        }
    }, {
        key: "AllDiscountsTotal",
        get: function get() {
            var n = this;return !n.Price || n.EventAttendeeId ? 0 : n.DiscountsApplied.reduce(function (t, i) {
                return t + n.getSpecificDiscountAmount(i);
            }, 0);
        }
    }, {
        key: "TotalDiscount",
        get: function get() {
            var n = this;if (!n.Price || n.EventAttendeeId) return 0;var t = n.AllDiscountsTotal;return n.Price > t ? t : n.Price;
        }
    }]);

    return DiscountableItem;
}();

var Exhibitor = function (_DiscountableItem) {
    _inherits(Exhibitor, _DiscountableItem);

    function Exhibitor(n) {
        _classCallCheck(this, Exhibitor);

        var _this3 = _possibleConstructorReturn(this, (Exhibitor.__proto__ || Object.getPrototypeOf(Exhibitor)).call(this));

        _this3.ExhibitorTypeId = n.Id;_this3.Price = n.Price;_this3.ContactInfo = _this3.getOrAddFirstBlankContact(_possibleContacts, !0);_this3.BoothNumber = null;_this3.BoothConfigurationId = n.BoothConfigurationId;n.DirectoryId && (_this3.DirectoryInfo = { DirectoryId: n.DirectoryId, UseExhibitorInformation: !0, DisplayName: "", Logo: { EventDetailId: n.EventDetailId }, Description: "", ContactInfo: {} });_this3.AdditionalPurchaseItems = n.AdditionalPurchaseItems || [];_this3.CustomFields = JSON.parse(JSON.stringify(n.CustomFields));_this3.InitialContactId = INITIAL_CONTACT_ID;return _this3;
    }

    _createClass(Exhibitor, [{
        key: "getOrAddFirstBlankContact",
        value: function getOrAddFirstBlankContact(n, t) {
            var r = n.find(function (n) {
                return n.isEmpty && !t;
            }),
                i;return r ? r : (i = new Contact(null, !0), n.push(i), i);
        }
    }, {
        key: "isDiscountValid",
        value: function isDiscountValid(n) {
            var t = this;return n.EventExhibitorDiscountId ? this.DiscountsApplied.some(function (t) {
                return n.EventExhibitorDiscountId == t.EventExhibitorDiscountId;
            }) ? (n.ErrorMessage = "Discount already applied.", !1) : t._isDiscountValid(n) ? !0 : !1 : !1;
        }
    }, {
        key: "TotalPrice",
        get: function get() {
            return (this.Price + this.AdditionalPurchaseItems.sumMultiplied("Price", "PurchaseCount") - this.TotalDiscount).toFixed(2);
        }
    }, {
        key: "ContactInfo",
        get: function get() {
            return this.contactInfo;
        },
        set: function set(n) {
            this.contactInfo = n;this.ContactId = (n || {}).OrgIdOrContactId;
        }
    }, {
        key: "AdditionalPurchaseItems",
        get: function get() {
            return this.additionalPurchaseItems;
        },
        set: function set(n) {
            var t = this;t.additionalPurchaseItems = [];n && n.forEach(function (n) {
                t.additionalPurchaseItems.push(angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity), n));
            });
        }
    }]);

    return Exhibitor;
}(DiscountableItem);

var SponsorshipTypeModel = function (_LimitedType2) {
    _inherits(SponsorshipTypeModel, _LimitedType2);

    function SponsorshipTypeModel(n, t, i, r, u, f) {
        _classCallCheck(this, SponsorshipTypeModel);

        var _this4 = _possibleConstructorReturn(this, (SponsorshipTypeModel.__proto__ || Object.getPrototypeOf(SponsorshipTypeModel)).call(this, r, t, f, i, u));

        _this4.sponsorshipTypeId = n;_this4.showDescription = !1;_this4.Sponsorships = [];_this4.eventRegistrationTypeId = t;return _this4;
    }

    _createClass(SponsorshipTypeModel, [{
        key: "increase",
        value: function increase() {
            this.Sponsorships.push(new Sponsorship(this.sponsorshipTypeId, this.Price));
        }
    }, {
        key: "decrease",
        value: function decrease() {
            this.Sponsorships.pop();
        }
    }, {
        key: "AllowSponsorIncrease",
        value: function AllowSponsorIncrease(n) {
            if (this.HasLimit && this.Remaining <= 0) return !1;var t = this.AllowIncrease(n);return this.AllowSponsorIncreaseOrShow(n, t);
        }
    }, {
        key: "ShouldShowToSponsors",
        value: function ShouldShowToSponsors(n) {
            if (this.AllowSponsorIncreaseOrShow(n, !0)) return !0;if (this.EventRegistrationVisibilityTypeId == 2) {
                var t = !n.loginInfo.isMember,
                    i = this.IsDisplayedForNonMembers,
                    r = (this.AllowedMembershipTypeIds || []).length == 0;return t && r && i;
            }return !1;
        }
    }, {
        key: "AllowSponsorIncreaseOrShow",
        value: function AllowSponsorIncreaseOrShow(n, t) {
            var i = n.loginInfo.isStaff,
                r = n.loginInfo.isMember,
                u = !n.loginInfo.isMember,
                f = (this.AllowedMembershipTypeIds || []).length == 0,
                e = n.model.CreatedByUser.MembershipIds.concat(n.EventInfo.CurrentUserInfo.MembershipIds || []).map(function (n) {
                return n.MembershipTypeId;
            }),
                o = (this.AllowedMembershipTypeIds || []).some(function (n) {
                return e.includes(n);
            });return i ? !0 : this.EventRegistrationVisibilityTypeId == 1 ? t : this.EventRegistrationVisibilityTypeId == 3 ? u && t : this.EventRegistrationVisibilityTypeId == 2 ? t && r && (o || f) : !1;
        }
    }, {
        key: "Remaining",
        get: function get() {
            return this.HasLimit ? this.VacantSpots - this.Sponsorships.length : 9999;
        }
    }]);

    return SponsorshipTypeModel;
}(LimitedType);

var Sponsorship = function () {
    function Sponsorship(n, t) {
        _classCallCheck(this, Sponsorship);

        this.SponsorshipTypeId = n;this.Price = t;this.ContactInfo = this.getOrAddFirstBlankContact(_possibleContacts, !0);this.SponsorshipDisplayBy = "2";this.InitialContactId = INITIAL_CONTACT_ID;
    }

    _createClass(Sponsorship, [{
        key: "getOrAddFirstBlankContact",
        value: function getOrAddFirstBlankContact(n, t) {
            var r = n.find(function (n) {
                return n.isEmpty && !t;
            }),
                i;return r ? r : (i = new Contact(null, !0), n.push(i), i);
        }
    }, {
        key: "ContactInfo",
        get: function get() {
            return this.contactInfo;
        },
        set: function set(n) {
            this.contactInfo = n;this.ContactId = (n || {}).OrgIdOrContactId;
        }
    }]);

    return Sponsorship;
}();

var Attendee = function (_DiscountableItem2) {
    _inherits(Attendee, _DiscountableItem2);

    function Attendee(n, t, i, r) {
        _classCallCheck(this, Attendee);

        var _this5 = _possibleConstructorReturn(this, (Attendee.__proto__ || Object.getPrototypeOf(Attendee)).call(this));

        _this5.defaultAttendeeTerm = "Attendee";_this5.ContactInfo = _this5.getOrAddFirstBlankContact(_possibleContacts, t);_this5.price = n.Price || 0;_this5.customFieldValues = [];_this5.AdditionalPurchaseItems = n.AdditionalPurchaseItems || [];_this5.NoShowFees = [];_this5.EventTimeSlots = _this5.getTimeslots(n.EventSessions);_this5.CustomFields = JSON.parse(JSON.stringify(n.CustomFields));_this5.CustomFieldValuesPopulated = !1;_this5.RegistrationTypeId = n.eventRegistrationTypeId;_this5.reserveAllAttendees = n.ReserveAllAttendees;_this5.attendeesCountPerOneRegistration = n.AttendeesCountPerOneRegistration;_this5.ExhibitorTypeId = i;_this5.SponsorTypeId = r;_this5.PrimaryExhibitorContact = !1;_this5.IncludedWithExhibitor = !!i;_this5.IncludedWithSponsor = !!r;_this5.InitialContactId = INITIAL_CONTACT_ID;return _this5;
    }

    _createClass(Attendee, [{
        key: "getOrAddFirstBlankContact",
        value: function getOrAddFirstBlankContact(n, t) {
            var r = n.find(function (n) {
                return n.isEmpty && !t;
            }),
                i;return r ? r : (i = new Contact(null, !0), n.push(i), i);
        }
    }, {
        key: "populateCustomFieldValues",
        value: function populateCustomFieldValues(n) {
            this.CustomFields.forEach(function (t) {
                if (n[t.CustomFieldId] && (t.Value = n[t.CustomFieldId].Value, t.CustomFieldDataTypeId == 12 && (t.tableValues[t.CustomFieldId] = n[t.CustomFieldId].Value), t.CustomFieldDataTypeId == 4)) {
                    var i = new Date(t.Value);i.setMinutes(i.getMinutes() + i.getTimezoneOffset());t.Value = i;
                }
            });this.CustomFieldValuesPopulated = !0;
        }
    }, {
        key: "IsRequired",
        value: function IsRequired(n) {
            return this.attendeesCountPerOneRegistration > 1 ? n % this.attendeesCountPerOneRegistration == 0 : !0;
        }
    }, {
        key: "resetAdditionalPurchaseItems",
        value: function resetAdditionalPurchaseItems(n) {
            var _this6 = this;

            var t = n.regTypes.filter(function (n) {
                return n.eventRegistrationTypeId == _this6.RegistrationTypeId;
            })[0];this.resetAdditionalPurchaseItemsFromType(t);
        }
    }, {
        key: "resetAdditionalPurchaseItemsFromType",
        value: function resetAdditionalPurchaseItemsFromType(n) {
            this.AdditionalPurchaseItems.forEach(function (n) {
                n.PurchaseCount = 0;
            });this.AdditionalPurchaseItems = n.AdditionalPurchaseItems || [];
        }
    }, {
        key: "clearSessionFees",
        value: function clearSessionFees() {
            this.EventTimeSlots.filter(function (n) {
                return n.HasFees;
            }).forEach(function (n) {
                return n.removeSelectedSession();
            });
        }
    }, {
        key: "getSessionsFees",
        value: function getSessionsFees() {
            return this.EventTimeSlots.map(function (n) {
                return n.SessionFeeItems;
            }).reduce(function (n, t) {
                return n.concat(t);
            }, []);
        }
    }, {
        key: "getAttendeeTerm",
        value: function getAttendeeTerm(n, t) {
            return t == 0 || this.price > 0 || !n ? this.defaultAttendeeTerm : n;
        }
    }, {
        key: "getAttendeeIndexDisplay",
        value: function getAttendeeIndexDisplay(n, t) {
            return this.getAttendeeTerm(n, t) == this.defaultAttendeeTerm ? t + 1 : t;
        }
    }, {
        key: "clearAddressId",
        value: function clearAddressId() {
            this.contactInfo && (this.ContactInfo.Address.AddressId = null);
        }
    }, {
        key: "clearContactOrgId",
        value: function clearContactOrgId(n) {
            this.contactInfo && !n && (this.contactInfo.OrganizationContactId = null);
        }
    }, {
        key: "clearContactId",
        value: function clearContactId(n, t) {
            this.contactInfo && (this.contactInfo.clearContactId(n, t), this.ContactId = this.contactInfo.ContactId);
        }
    }, {
        key: "attendeeInfoChanged",
        value: function attendeeInfoChanged(n, t) {
            this.clearContactId(n, t);_possibleContacts.addPossibleAttendeeIfNeeded();
        }
    }, {
        key: "updateCompanyInfo",
        value: function updateCompanyInfo(n) {
            this.ContactInfo.OrganizationContactId = n.ContactId;this.ContactInfo.OrganizationName = n.OrganizationName;this.ContactInfo.OriginOrgName = n.OrganizationName;
        }
    }, {
        key: "updateOrganizationDataIfNull",
        value: function updateOrganizationDataIfNull(n) {
            !this.ContactInfo.OrganizationName && n.OrganizationName && (this.ContactInfo.OrganizationContactId = n.OrganizationContactId, this.ContactInfo.OrganizationName = n.OrganizationName);
        }
    }, {
        key: "isDiscountValid",
        value: function isDiscountValid(n) {
            var t = this;return n.EventDiscountId ? this.isBulkAttendee ? !1 : this.AddToWaitingList ? (n.ErrorMessage = "Discount not applied to waiting list registrations.", !1) : n.ExhibitorAddedRegistrationTypeId && this.RegistrationTypeId != n.ExhibitorAddedRegistrationTypeId ? !1 : n.SponsorAddedRegistrationTypeId && this.RegistrationTypeId != n.SponsorAddedRegistrationTypeId ? !1 : this.DiscountsApplied.some(function (t) {
                return n.EventDiscountId == t.EventDiscountId;
            }) ? (n.ErrorMessage = "Discount already applied.", !1) : t._isDiscountValid(n) ? !0 : !1 : !1;
        }
    }, {
        key: "getTimeslots",
        value: function getTimeslots(n) {
            return n.map(function (t) {
                return angular.extend(new EventTimeSlot(), { Id: t.TimeslotId, EventTimeslotId: t.TimeslotId, Name: t.TimeslotName, StartTime: t.StartTime, EndTime: t.EndTime, EventSessions: n.filter(function (n) {
                        return n.TimeslotId == t.TimeslotId;
                    }).map(function (n) {
                        return angular.extend(new EventSession(), JSON.parse(JSON.stringify(n)));
                    }) });
            }).distinct("Id");
        }
    }, {
        key: "setAttendeeNoShowFees",
        value: function setAttendeeNoShowFees() {
            var n = this;n.ContactInfo.NoShowFees && n.ContactInfo.NoShowFees.length > 0 && (n.ContactInfo.NoShowFees.forEach(function (t) {
                n.additionalPurchaseItems.filter(function (n) {
                    return n.SaleableItemId == t.SaleableItemId;
                }).length == 0 && n.additionalPurchaseItems.push(angular.extend(new AdditionalPurchaseItem(null, t.AdditionalItem.InventoryQuantity), t.AdditionalItem));
            }), n.additionalPurchaseItems.filter(function (n) {
                return n.IsNoShowFee;
            }).forEach(function (n) {
                n.PurchaseCount = 1;
            }));
        }
    }, {
        key: "clearAdditionalItem",
        value: function clearAdditionalItem() {
            var n = this;n.additionalPurchaseItems.forEach(function (n) {
                return n.PurchaseCount = n.PaidCount;
            });
        }
    }, {
        key: "ContactInfo",
        get: function get() {
            return this.contactInfo;
        },
        set: function set(n) {
            this.contactInfo = n;this.ContactId = (n || {}).ContactId;
        }
    }, {
        key: "EventAttendeeId",
        get: function get() {
            return this.eventAttendeeId;
        },
        set: function set(n) {
            this.eventAttendeeId = n;
        }
    }, {
        key: "IsReserved",
        get: function get() {
            return this.isReserved;
        },
        set: function set(n) {
            this.isReserved = n;
        }
    }, {
        key: "IsMainAttendee",
        get: function get() {
            return this.isMainAttendee;
        },
        set: function set(n) {
            this.isMainAttendee = n;
        }
    }, {
        key: "IsBulkAttendee",
        get: function get() {
            return this.isBulkAttendee;
        },
        set: function set(n) {
            this.isBulkAttendee = n;
        }
    }, {
        key: "Price",
        get: function get() {
            return this.price;
        },
        set: function set(n) {
            this.price = n;
        }
    }, {
        key: "TotalPrice",
        get: function get() {
            return (this.Price + this.AdditionalPurchaseItems.sumMultiplied("Price", "PurchaseCount") + this.SessionsTotalFees - this.TotalDiscount).toFixed(2);
        }
    }, {
        key: "AddToWaitingList",
        get: function get() {
            return this.addToWaitingList;
        },
        set: function set(n) {
            this.addToWaitingList = n;
        }
    }, {
        key: "CustomFieldValues",
        get: function get() {
            return this.customFieldValues;
        },
        set: function set(n) {
            this.customFieldValues = n;
        }
    }, {
        key: "AdditionalPurchaseItems",
        get: function get() {
            return this.additionalPurchaseItems;
        },
        set: function set(n) {
            var t = this;t.additionalPurchaseItems = [];n && n.forEach(function (n) {
                t.additionalPurchaseItems.push(angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity), n));
            });t.ContactInfo.NoShowFees && t.ContactInfo.NoShowFees.forEach(function (n) {
                var i = angular.extend(new AdditionalPurchaseItem(null, n.AdditionalItem.InventoryQuantity), n.AdditionalItem);i.PurchaseCount = 1;t.additionalPurchaseItems.push(i);
            });
        }
    }, {
        key: "SessionsTotalFees",
        get: function get() {
            return this.EventTimeSlots.sum("FeesTotal");
        }
    }]);

    return Attendee;
}(DiscountableItem);

var EventSession = function () {
    function EventSession() {
        _classCallCheck(this, EventSession);
    }

    _createClass(EventSession, [{
        key: "isSessionFull",
        value: function isSessionFull(n) {
            return !this.IsSessionAvailable && (!n.SelectedSession || n.SelectedSession.SessionId != this.SessionId);
        }
    }, {
        key: "SessionId",
        get: function get() {
            return this.sessionId;
        },
        set: function set(n) {
            this.sessionId = n;
        }
    }, {
        key: "AttendeesCount",
        get: function get() {
            return _stats.sessionsAttendeesCount[this.sessionId] || 0;
        },
        set: function set(n) {
            _stats.sessionsAttendeesCount[this.sessionId] = n;
        }
    }, {
        key: "IsSessionAvailable",
        get: function get() {
            return this.AttendeeLimit == 0 || this.AttendeeLimit - this.AttendeesCount > 0;
        }
    }, {
        key: "FeesTotal",
        get: function get() {
            return this.HasFees ? this.FeeItems.map(function (n) {
                return (n.PurchaseCount - n.PaidCount) * n.Price;
            }).reduce(function (n, t) {
                return n + t;
            }, 0) : 0;
        }
    }, {
        key: "PriceTotal",
        get: function get() {
            return this.HasFees ? this.FeeItems.sum("Price") : 0;
        }
    }, {
        key: "HasFees",
        get: function get() {
            return this.FeeItems && this.FeeItems.length;
        }
    }]);

    return EventSession;
}();

var EventTimeSlot = function () {
    function EventTimeSlot() {
        _classCallCheck(this, EventTimeSlot);

        this.SelectedSessionId = 0;this.oldSelectedSessionTotal = 0;
    }

    _createClass(EventTimeSlot, [{
        key: "updateSelectedSession",
        value: function updateSelectedSession(n) {
            _stats.RemoveFromPrice(this.oldSelectedSessionTotal);_stats.sessionsAttendeesCount[this.SelectedSessionId] -= 1;n && n.IsSessionAvailable ? (n.AttendeesCount += 1, this.SelectedSessionId = n.SessionId, _stats.AddToPrice(this.FeesTotal), this.oldSelectedSessionTotal = this.FeesTotal) : (this.oldSelectedSessionTotal = 0, this.SelectedSession = undefined);
        }
    }, {
        key: "removeSelectedSession",
        value: function removeSelectedSession() {
            this.SelectedSession.AttendeesCount -= 1;_stats.RemoveFromPrice(this.oldSelectedSessionTotal);this.oldSelectedSessionTotal = 0;this.SelectedSession = undefined;this.SelectedSessionId = 0;
        }
    }, {
        key: "SelectedSession",
        get: function get() {
            return this.selectedSession;
        },
        set: function set(n) {
            this.selectedSession = n;
        }
    }, {
        key: "SessionFeeItems",
        get: function get() {
            return this.SelectedSession ? this.SelectedSession.FeeItems : [];
        }
    }, {
        key: "FeesTotal",
        get: function get() {
            return this.HasFees ? this.SelectedSession.FeesTotal : 0;
        }
    }, {
        key: "PriceTotal",
        get: function get() {
            return this.HasFees ? this.SelectedSession.PriceTotal : 0;
        }
    }, {
        key: "HasFees",
        get: function get() {
            return this.SelectedSession && this.SelectedSession.HasFees;
        }
    }]);

    return EventTimeSlot;
}();

var AdditionalPurchaseItem = function () {
    function AdditionalPurchaseItem(n, t, i) {
        _classCallCheck(this, AdditionalPurchaseItem);

        this.Parent = n || null;this.inventoryQuantity = t;this.updateStats = i != undefined ? i : !0;
    }

    _createClass(AdditionalPurchaseItem, [{
        key: "PurchaseCount",
        get: function get() {
            return this.purchaseCount;
        },
        set: function set(n) {
            var t = Math.abs(n - this.purchaseCount);n > this.purchaseCount && n - this.PaidCount > 0 ? (this.InventoryRemaining -= t, this.updateStats && _stats.AddToPrice(this.Price * t)) : n < this.purchaseCount && this.purchaseCount - this.PaidCount > 0 && (this.InventoryRemaining += t, this.updateStats && _stats.RemoveFromPrice(this.Price * t));this.purchaseCount = n;
        }
    }, {
        key: "PaidCount",
        get: function get() {
            return this.paidCount;
        },
        set: function set(n) {
            this.paidCount = n;
        }
    }, {
        key: "TotalTaxRate",
        get: function get() {
            return this.totalTaxRate;
        },
        set: function set(n) {
            this.totalTaxRate = n;
        }
    }, {
        key: "TotalTaxFlatAmount",
        get: function get() {
            return this.totalTaxFlatAmount;
        },
        set: function set(n) {
            this.totalTaxFlatAmount = n;
        }
    }, {
        key: "EventSaleableItemId",
        get: function get() {
            return this.eventSaleableItemId;
        },
        set: function set(n) {
            this.eventSaleableItemId = n;
        }
    }, {
        key: "EventSessionSaleableItemId",
        get: function get() {
            return this.eventSessionSaleableItemId;
        },
        set: function set(n) {
            this.eventSessionSaleableItemId = n;
        }
    }, {
        key: "Price",
        get: function get() {
            return this.price;
        },
        set: function set(n) {
            this.price = n;
        }
    }, {
        key: "Parent",
        get: function get() {
            return this.parent;
        },
        set: function set(n) {
            this.parent = n;
        }
    }, {
        key: "InventoryQuantity",
        get: function get() {
            return this.inventoryQuantity;
        },
        set: function set(n) {
            this.inventoryQuantity = n;
        }
    }, {
        key: "InventoryRemaining",
        get: function get() {
            return this.updateStats ? _stats.additionalItemsUsageCount[this.EventSaleableItemId] || 0 : 1;
        },
        set: function set(n) {
            this.InventoryQuantity > 0 && this.updateStats && (_stats.additionalItemsUsageCount[this.EventSaleableItemId] = n);
        }
    }, {
        key: "TotalItemTax",
        get: function get() {
            return this.Price * this.TotalTaxRate + this.TotalTaxFlatAmount;
        }
    }, {
        key: "Enabled",
        get: function get() {
            var n = function n() {
                return _loginInfo.isMember || (_loginInfo.createdBy || {}).IsMember;
            };return !this.IsNoShowFee && (this.IsForNonMembers || this.IsForMembers && n() || this.IsForStaff && _loginInfo.isStaff);
        }
    }, {
        key: "ShouldShowLimitError",
        get: function get() {
            return this.InventoryQuantity > 0 && this.InventoryRemaining < 0 && this.PurchaseCount - this.PaidCount > 0;
        }
    }, {
        key: "ShowRemainingInventory",
        get: function get() {
            return this.InventoryQuantity > 0 && this.InventoryRemaining < 10 && this.InventoryRemaining > 0;
        }
    }]);

    return AdditionalPurchaseItem;
}();

var Contact = function () {
    function Contact(n, t, i) {
        _classCallCheck(this, Contact);

        this.typeOfItem = i || "Attendee";this.ContactId = n ? n : this.NextContactId;this.isMe = !1;this.placeholder = "< Someone else >";this.isAttachedToAttendee = !!t;this.emailAddress = new EmailAddress();this.defaultCountryId = _defaultCountryId;this.Address = {};this.RelatedAttendees = [];this.MembershipIds = [];
    }

    _createClass(Contact, [{
        key: "clearContactId",
        value: function clearContactId(n, t) {
            !n && this.ContactId > 0 && !t && (this.ContactId = this.NextContactId, this.MembershipIds = [], this.ContactRoles = [], this.IsMember = !1, this.RelatedAttendees = []);n && this.EmailAddress && (this.EmailAddress.EmailAddressId = null);
        }
    }, {
        key: "IsMe",
        get: function get() {
            return this.isMe;
        },
        set: function set(n) {
            this.isMe = n;
        }
    }, {
        key: "Placeholder",
        get: function get() {
            return this.placeholder;
        },
        set: function set(n) {
            this.placeholder = n;
        }
    }, {
        key: "Prefix",
        get: function get() {
            return this.prefix;
        },
        set: function set(n) {
            this.prefix = n;
        }
    }, {
        key: "FirstName",
        get: function get() {
            return this.firstName;
        },
        set: function set(n) {
            this.firstName = n;
        }
    }, {
        key: "CommonName",
        get: function get() {
            return this.commonName;
        },
        set: function set(n) {
            this.commonName = n;
        }
    }, {
        key: "MiddleName",
        get: function get() {
            return this.middleName;
        },
        set: function set(n) {
            this.middleName = n;
        }
    }, {
        key: "LastName",
        get: function get() {
            return this.lastName;
        },
        set: function set(n) {
            this.lastName = n;
        }
    }, {
        key: "Suffix",
        get: function get() {
            return this.suffix;
        },
        set: function set(n) {
            this.suffix = n;
        }
    }, {
        key: "ContactId",
        get: function get() {
            return this.contactId;
        },
        set: function set(n) {
            this.contactId = n || this.NextContactId;
        }
    }, {
        key: "EmailAddress",
        get: function get() {
            return this.emailAddress;
        },
        set: function set(n) {
            this.emailAddress = n || {};
        }
    }, {
        key: "Phone",
        get: function get() {
            return this.phone = this.phone || {}, this.phone;
        },
        set: function set(n) {
            this.phone = n || {};
        }
    }, {
        key: "Address",
        get: function get() {
            return this.address;
        },
        set: function set(n) {
            var t = n || {};!t.CountryId && this.defaultCountryId && (t.CountryId = this.defaultCountryId);this.address = t;
        }
    }, {
        key: "isEmpty",
        get: function get() {
            return !this.FirstName && !this.LastName && !this.EmailAddressText && this.ContactId < 0;
        }
    }, {
        key: "OrganizationContactId",
        get: function get() {
            return this.organizationContactId;
        },
        set: function set(n) {
            this.organizationContactId = n;
        }
    }, {
        key: "Title",
        get: function get() {
            return this.title;
        },
        set: function set(n) {
            this.title = n;
        }
    }, {
        key: "OrganizationName",
        get: function get() {
            return this.organizationName;
        },
        set: function set(n) {
            this.organizationName = n;
        }
    }, {
        key: "RelatedAttendees",
        get: function get() {
            return this.relatedAttendees;
        },
        set: function set(n) {
            this.relatedAttendees = n;
        }
    }, {
        key: "NextContactId",
        get: function get() {
            var n = _stats.nextContactId || -1;return _stats.nextContactId = _stats.nextContactId - 1, n;
        }
    }, {
        key: "EmailAddressText",
        get: function get() {
            return (this.EmailAddress || {}).EmailAddress || "";
        }
    }, {
        key: "DisplayName",
        get: function get() {
            if (this.isEmpty) return this.placeholder;var n = this.EmailAddressText;return (this.FirstName || "") + " " + (this.LastName || "") + (n ? " (" + n + ")" : "");
        }
    }, {
        key: "Name",
        get: function get() {
            return !this.FirstName && !this.LastName ? this.placeholder : (this.FirstName || "") + (this.LastName ? " " + this.LastName : "") + (this.isMe ? " (Me)" : "");
        }
    }, {
        key: "OrgNameOrFullName",
        get: function get() {
            return this.OrganizationName || this.Name;
        }
    }, {
        key: "OrgIdOrContactId",
        get: function get() {
            return this.OrganizationContactId || this.ContactId;
        }
    }]);

    return Contact;
}();

INITIAL_CONTACT_ID = -9999;
var InitialContact = function (_Contact) {
    _inherits(InitialContact, _Contact);

    function InitialContact() {
        _classCallCheck(this, InitialContact);

        return _possibleConstructorReturn(this, (InitialContact.__proto__ || Object.getPrototypeOf(InitialContact)).call(this, INITIAL_CONTACT_ID, !0));
    }

    _createClass(InitialContact, [{
        key: "Name",
        get: function get() {
            return "< Who is the [[Attendee]]? >";
        }
    }, {
        key: "isEmpty",
        get: function get() {
            return !0;
        }
    }]);

    return InitialContact;
}(Contact);

PLACEHOLDER_CONTACT_ID = -9998;
var PlaceholderContact = function (_Contact2) {
    _inherits(PlaceholderContact, _Contact2);

    function PlaceholderContact() {
        _classCallCheck(this, PlaceholderContact);

        return _possibleConstructorReturn(this, (PlaceholderContact.__proto__ || Object.getPrototypeOf(PlaceholderContact)).call(this, PLACEHOLDER_CONTACT_ID, !0));
    }

    _createClass(PlaceholderContact, [{
        key: "Name",
        get: function get() {
            return "< I don't know yet >";
        }
    }, {
        key: "isEmpty",
        get: function get() {
            return !1;
        }
    }]);

    return PlaceholderContact;
}(Contact);

var EmailAddress = function () {
    function EmailAddress(n, t, i) {
        _classCallCheck(this, EmailAddress);

        this.emailAddress = n || "";this.emailAddressId = t || 0;this.emailAddressTypeId = i || "";
    }

    _createClass(EmailAddress, [{
        key: "EmailAddressId",
        get: function get() {
            return this.emailAddressId;
        },
        set: function set(n) {
            this.emailAddressId = n;
        }
    }, {
        key: "EmailAddress",
        get: function get() {
            return this.emailAddress;
        },
        set: function set(n) {
            this.emailAddress = n;
        }
    }, {
        key: "IsModified",
        get: function get() {
            return this.isModified;
        },
        set: function set(n) {
            this.isModified = n;
        }
    }, {
        key: "EmailAddressTypeId",
        get: function get() {
            return this.emailAddressTypeId;
        },
        set: function set(n) {
            this.emailAddressTypeId = n;
        }
    }]);

    return EmailAddress;
}();

app.factory("SharedHelpers", ["$window", "FileUploader", function (n, t) {
    var i = this;return i.getFirstRegTypeWithAttendeesInForm = function (n) {
        return n.regTypes ? n.regTypes.find(function (n) {
            return n.ActiveAttendees.length > 0;
        }) : null;
    }, i.getRegistrationTypesHavingAttendees = function (n) {
        return n.regTypes ? n.regTypes.filter(function (n) {
            return n.ActiveAttendees.length > 0;
        }) : [];
    }, i.getExhibitorTypesHavingExhibitors = function (n) {
        return n.exhibitorTypes ? n.exhibitorTypes.filter(function (n) {
            return !!n.Exhibitors.length;
        }) : [];
    }, i.enableAllRegTypes = function (n) {
        n.regTypes.forEach(function (n) {
            return n.Enabled = !0;
        });
    }, i.disableMembersOnlyRegTypes = function (n, t) {
        n.regTypes.forEach(function (i) {
            i.IsMemberOnly && (i.Enabled = t || n.model.IsRegistrationUpdate && i.ActiveAttendees.length > 0);
        });
    }, i.getAttendeesCustomFieldsValues = function (n) {
        return n.regTypes.filter(function (n) {
            return n.ActiveAttendees.length > 0;
        }).map(function (n) {
            return n.ActiveAttendees;
        }).reduce(function (n, t) {
            return n.concat(t);
        }, []).map(function (n) {
            return n.CustomFieldValues;
        }).reduce(function (n, t) {
            return n.concat(t);
        }, []);
    }, i.anyOverallExtraPurchaseItemsExist = function (n) {
        return n.model.ValidOverallExtraPurchaseItems.some(function (n) {
            return n.PurchaseCount > 0;
        });
    }, i.getvalidExtraPurchaseItemsByType = function (n, t) {
        return n.EventInfo.AdditionalPurchaseItems.filter(function (n) {
            return n.EventSaleableItemTypeId == t;
        }).map(function (n) {
            return angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity), n);
        });
    }, i.getvalidPurchaseItemsByRegType = function (n, t) {
        return n.EventInfo.EventRegistrationSaleableItemModels.filter(function (n) {
            return n.EventRegistrationTypeId == t;
        }).map(function (n) {
            return angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity, !1), n);
        });
    }, i.getvalidPurchaseItemsByExhibitorType = function (n, t) {
        return n.EventInfo.EventExhibitorSaleableItems.filter(function (n) {
            return n.EventExhibitorTypeId == t;
        }).map(function (n) {
            return angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity, !1), n);
        });
    }, i.getvalidSponsorPurchaseItemsBySaleableItemIds = function (n, t) {
        return n.EventInfo.EventSponsorSaleableItems.filter(function (n) {
            return t.includes(n.EventSponsorshipId);
        }).map(function (n) {
            return angular.extend(new AdditionalPurchaseItem(null, n.InventoryQuantity, !1), n);
        });
    }, i.showValidationSummary = function () {
        $("#errorWarningPopup").css("display", "block");
    }, i.getRegistrationType = function (n, t) {
        return n.regTypes.find(function (n) {
            return n.EventRegistrationTypeId == t;
        });
    }, i.getExhibitorType = function (n, t) {
        return n.exhibitorTypes.find(function (n) {
            return n.exhibitorTypeId == t;
        });
    }, i.getRegistrationTypeName = function (n, t) {
        var r = i.getRegistrationType(n, t);return r ? r.Name : "";
    }, i.getExhibitorTypeName = function (n, t) {
        var r = i.getExhibitorType(n, t);return r ? r.Name : "";
    }, i.TaxTypes = { FlatAmount: 0, Rate: 1 }, i.getTotalTaxByType = function (n, t, r, u) {
        var e = n.billing.ContactInfo,
            f = e.TaxSet;return e.IsTaxExempt ? 0 : t.SaleableItemTaxExist ? r == i.TaxTypes.FlatAmount ? t.TotalTaxFlatAmount * u : t.TotalTaxRate : t.ProductTaxCategoryId && f && f.Categories.indexOf(t.ProductTaxCategoryId) >= 0 ? r == i.TaxTypes.FlatAmount ? f.TotalTaxFlatAmount * u : f.TotalTaxRate : 0;
    }, i.getPurchaseItemTotalTax = function (n, t) {
        var r = t.PurchaseCount - t.PaidCount;return r <= 0 ? 0 : t.Price * r * i.getTotalTaxByType(n, t, i.TaxTypes.Rate) + i.getTotalTaxByType(n, t, i.TaxTypes.FlatAmount, r);
    }, i.roundAwayFromZero = function (n) {
        return (n = n * 100, n % .5 != 0) ? Math.round(n) / 100 : Math.ceil(n) % 2 == 0 ? Math.ceil(n) / 100 : Math.round(n) / 100;
    }, i.getPurchaseItemsTotalTax = function (n, t) {
        if (t) {
            var r = 0;return t.forEach(function (t) {
                var u = i.roundAwayFromZero(i.getPurchaseItemTotalTax(n, t));r = (r * 100 + u * 100) / 100;
            }), r;
        }return 0;
    }, i.showError = function (n, t) {
        n.validationMessages = [];n.validationMessages.push({ key: "", messages: [t] });i.showValidationSummary();
    }, i.checkPurchaseItemQuantityHandler = function (n) {
        return i.checkPurchaseItemQuantity.bind(this, n);
    }, i.checkPurchaseItemQuantity = function (n, t) {
        t.purchaseCount >= t.paidCount || t.price == 0 ? i.calculateTaxes(n) : n.EventInfo.CurrentUserInfo.IsStaffUser ? t.IsPaid ? (t.purchaseCount = t.paidCount, i.showError(n, "Sorry you cannot reduce the number of additional items that are already paid for.")) : (i.showError(n, "You have decreased the quantity of an item. If this registration is already paid for, you will need to manually issue a refund or partial refund. To do this, simply click on the invoice number from the attendees tab, and use the payment's action button to issue the refund."), i.calculateTaxes(n)) : (t.purchaseCount = t.paidCount, i.showError(n, "Sorry you cannot reduce the number of registrations or additional items. Please contact an administrator."));
    }, i.addTax = function (n, t) {
        return (n * 100 + t * 100) / 100;
    }, i.calculateTaxes = function (n) {
        var r, u;var t = 0;n.regTypes.forEach(function (r) {
            r.ActiveAttendees.forEach(function (u) {
                if (u.Price !== 0) {
                    var f = i.getvalidPurchaseItemsByRegType(n, r.EventRegistrationTypeId);f.length && f.sort(function (n, t) {
                        return n.Price < t.Price ? 1 : -1;
                    }).forEach(function (n, t) {
                        n.price -= u.getAllDiscountsTotal(n.price, t > 0);n.PurchaseCount = 1;
                    });t = i.addTax(t, i.getPurchaseItemsTotalTax(n, f));
                }t = i.addTax(t, i.getPurchaseItemsTotalTax(n, u.AdditionalPurchaseItems));t = i.addTax(t, i.getPurchaseItemsTotalTax(n, u.getSessionsFees()));
            });
        });n.exhibitorTypes.forEach(function (r) {
            r.Exhibitors.forEach(function (u) {
                if (u.Price !== 0) {
                    var f = i.getvalidPurchaseItemsByExhibitorType(n, r.EventExhibitorTypeId);f.length && f.sort(function (n, t) {
                        return n.Price < t.Price ? 1 : -1;
                    }).forEach(function (n, t) {
                        n.price -= u.getAllDiscountsTotal(n.price, t > 0);n.PurchaseCount = 1;
                    });t = i.addTax(t, i.getPurchaseItemsTotalTax(n, f));
                }t = i.addTax(t, i.getPurchaseItemsTotalTax(n, u.AdditionalPurchaseItems));
            });
        });t = i.addTax(t, i.getPurchaseItemsTotalTax(n, n.model.ValidOverallExtraPurchaseItems));r = [];n.sponsorTypes.length && n.sponsorTypes.forEach(function (n) {
            n.Sponsorships.length && (r[r.length] = n.Id);
        });u = i.getvalidSponsorPurchaseItemsBySaleableItemIds(n, r);u.forEach(function (t) {
            t.PurchaseCount = n.sponsorTypes.find(function (n) {
                return n.Id === t.EventSponsorshipId;
            }).Sponsorships.length;
        });t = i.addTax(t, i.getPurchaseItemsTotalTax(n, u));n.stats.SetTaxesValue(t);
    }, i.getRegistrationTypeSessions = function (n, t) {
        return n.EventInfo.EventSessions.filter(function (n) {
            return n.RegistrationTypesIds.length && n.RegistrationTypesIds.indexOf(t) >= 0;
        });
    }, i.isStateRequired = function (t) {
        return [180, 210].indexOf(t) === -1 && !!n.allStatesList.filter(function (n) {
            return n.CountryId == t;
        }).length;
    }, i.getCountryStates = function (t) {
        return t ? n.allStatesList.filter(function (n) {
            return n.CountryId == t;
        }) : [];
    }, i.getCountryCode = function (t) {
        if (t) {
            var i = n.countriesList.filter(function (n) {
                return n.CountryId == t;
            });if (i.length) return i[0].Code;
        }return "";
    }, i.getTextHtmlVersion = function (n) {
        return n.replace(/(?:\r\n)/g, "<br />");
    }, i.getValidExhibitorTypeCustomFields = function (n, t) {
        return n.EventInfo.ExhibitorCustomFields.filter(function (n) {
            return !(n.ExhibitorTypeIds || []).length || (n.ExhibitorTypeIds || []).any(function (n) {
                return n == t;
            });
        });
    }, i.getValidRegistrationTypeCustomFields = function (n, t) {
        return n.EventInfo.CustomFields.filter(function (n) {
            return !(n.RegistrationTypesIds || []).length || (n.RegistrationTypesIds || []).any(function (n) {
                return n == t;
            });
        });
    }, i.fileUploadErrors = { 0: function _() {
            return "An unknown error has occurred";
        }, 404: function _() {
            return "This file was too large to be accepted as an upload";
        }, 500: function _(n) {
            return n.ExceptionMessage;
        } }, i.getCustomFieldUploader = function (n) {
        var r = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
        return new t({ autoUpload: !1, url: "/api/files/eventDetails/" + n.EventDetailId + "/upload/0/" + r, removeAfterUpload: !0, onSuccessItem: function onSuccessItem(t, i) {
                if (n.isUploading = !1, i && i.length) {
                    var r = i[0];n.isValidFile = 1;n.FileModel = { Name: r.Name, Url: r.Url, ContentType: r.ContentType, FileId: r.FileId };n.Value = JSON.stringify(n.FileModel);
                } else n.isValidFile = null;
            }, onAfterAddingFile: function onAfterAddingFile(t) {
                this.autoUpload || !t || (n.Error = null, ["exe", "msi"].some(function (n) {
                    return (t.file.name.split(".").pop() || "").toLowerCase() == n;
                }) && (n.Error = "you cannot upload files of this type."), t.file.size >= 20971520 && (n.Error = Errors[404]()), n.isValidFile = !n.Error);
            }, onBeforeUploadItem: function onBeforeUploadItem() {
                n.Error = null;n.isUploading = !0;
            }, onCompleteItem: function onCompleteItem() {
                n.isUploading = !1;
            }, onErrorItem: function onErrorItem(t, r, u) {
                n.Error = (i.fileUploadErrors[u] || i.fileUploadErrors[0])(r);
            } });
    }, { getCountryCode: i.getCountryCode, calculateTaxes: i.calculateTaxes, isStateRequired: i.isStateRequired, getCountryStates: i.getCountryStates, enableAllRegTypes: i.enableAllRegTypes, getTextHtmlVersion: i.getTextHtmlVersion, getExhibitorTypeName: i.getExhibitorTypeName, showValidationSummary: i.showValidationSummary, getCustomFieldUploader: i.getCustomFieldUploader, getRegistrationTypeName: i.getRegistrationTypeName, checkPurchaseItemQuantity: i.checkPurchaseItemQuantity, disableMembersOnlyRegTypes: i.disableMembersOnlyRegTypes, getRegistrationTypeSessions: i.getRegistrationTypeSessions, getAttendeesCustomFieldsValues: i.getAttendeesCustomFieldsValues, getvalidExtraPurchaseItemsByType: i.getvalidExtraPurchaseItemsByType, anyOverallExtraPurchaseItemsExist: i.anyOverallExtraPurchaseItemsExist, getValidExhibitorTypeCustomFields: i.getValidExhibitorTypeCustomFields, getExhibitorTypesHavingExhibitors: i.getExhibitorTypesHavingExhibitors, getFirstRegTypeWithAttendeesInForm: i.getFirstRegTypeWithAttendeesInForm, getRegistrationTypesHavingAttendees: i.getRegistrationTypesHavingAttendees, getValidRegistrationTypeCustomFields: i.getValidRegistrationTypeCustomFields, checkPurchaseItemQuantityHandler: i.checkPurchaseItemQuantityHandler };
}]);app.factory("UserService", ["ApiService", "SharedHelpers", "DiscountService", "EventInsuranceService", "$cookies", function (n, t, i, r, u) {
    function e(n) {
        var t = ((n || {}).emailAddress || {}).emailAddress || ((n || {}).EmailAddress || {}).EmailAddress;if (t) {
            var _i2 = (n || {}).address || {};r.UpdateContact(t, n.firstName, n.lastName, _i2.StateProvince);
        }
    }var f = this;return f.performOperation = function (t, i, r) {
        var f = i == "login",
            e = f ? n.login(t.loginInfo) : n.logout();t.status.authInProgress = !0;e.then(function (n) {
            f ? u.put("MMP.Auth.AccessToken", n.access_token) : (angular.element("#logout-confirm-Popup").hide(), u.remove("MMP.Auth.AccessToken"));r ? window.location.href = r + "?redirectUrl=" + encodeURIComponent(window.location.href) : window.location.reload();
        }, function (n) {
            t.loginInfo.errorMessage = f ? n.data.error_description : "Error logging out";
        }).finally(function () {
            t.status.authInProgress = !1;
        });
    }, f.login = function (n) {
        if (!n.loginInfo.username || !n.loginInfo.password) {
            n.loginInfo.errorMessage = "Please fill in user name and password.";return;
        }f.performOperation(n, "login");window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });
    }, f.logout = function () {
        angular.element("#logout-confirm-Popup").show();
    }, f.confirmLogout = function (n, t, i) {
        t ? f.performOperation(n, "logout", i) : angular.element("#logout-confirm-Popup").hide();
    }, f.hasAccessToMemberOnlyFeature = function (n) {
        return n.loginInfo.isMember || n.EventSettings.MemberSecurityMode == Enums.SystemMemberSecurityModeOption.FullAuth;
    }, f.getFirstRelatedCompany = function (n) {
        return (n = n || [], n.length > 0) ? n[0].OrganizationId : null;
    }, f.loadUserDataToAttendee = function (n, t, i) {
        var r = i.ContactInfo;angular.extend(r, t);r.OriginFirstName = t.FirstName;r.OriginLastName = t.LastName;r.OriginOrgName = t.OrganizationName;r.Address && (r.Address.CountryId = r.Address.CountryId || n.model.TenantCountryId);r.ContactId > 0 && (i.CustomFields || []).length && n.EventSettings.UseIndividualCustomFieldsForER && f.updateContactCustomFieldValues(i);
    }, f.updateContactCustomFieldValues = function (t) {
        return n.getAttendeeCustomFields(t.ContactInfo.ContactId).then(function (n) {
            t.populateCustomFieldValues(n);
        });
    }, f.setCompanyNameAfterFirstAttendee = function (n) {
        var i = t.getFirstRegTypeWithAttendeesInForm(n);if (i) {
            var _t6 = i.ActiveAttendees[0].ContactInfo;n.regTypes.forEach(function (n) {
                return n.ActiveAttendees.forEach(function (n) {
                    return n.updateOrganizationDataIfNull(_t6);
                });
            });
        }
    }, f.updateSponsorFromSelectedSponsor = function (n, t, r) {
        f.loadUserDataToAttendee(n, t, r);i.reApplyAllValidDiscounts(n);
    }, f.updateContactInfoFromSelectedContact = function (n, t, r) {
        t.OrganizationContactId = t.ContactId;f.loadUserDataToAttendee(n, t, r);i.reApplyAllValidDiscounts(n);
    }, f.updateBillingContactFromSelectedContact = function (n, t) {
        t && (n.selectedBillingContactId = t.ContactId, n.billing.ContactInfo = t, f.updatePaymentWidgetValues(n, t));n.showBillToEmail = n.billing.PaymentMethod == 1 && !n.billing.ContactInfo.isEmpty && !n.billing.ContactInfo.EmailAddressText;
    }, f.updateAttendeeInfoFromSelectedContact = function (n, t, r) {
        f.loadUserDataToAttendee(n, t, r);i.reApplyAllValidDiscounts(n);f.setCompanyNameAfterFirstAttendee(n);var u = n.EventSettings.ShowRelatedContactsUponSearch || n.loginInfo.isLoggedIn;u && f.fetchPossibleAttendeesList(t).then(f.updatePossibleAttendeesList.bind(null, n, !1));
    }, f.updatePaymentWidgetValues = function (n, t) {
        n.payWidget && (n.payWidget.setAddress(t.Address || {}), n.payWidget.setEmail(t.EmailAddress.EmailAddress), n.payWidget.updateFutureSaveMessage(t.Name), n.payWidget.setContactId(t.ContactId > 0 ? t.ContactId : null));
    }, f.fetchPossibleAttendeesList = function (t) {
        return n.getAttendeeRelatedContacts(t.ContactId);
    }, f.updatePossibleAttendeesList = function (n, t, i) {
        t && n.PossibleAttendees.clearRelatedContacts();var r = n.PossibleAttendees.map(function (n) {
            return n.ContactId;
        });i.forEach(function (t) {
            r.indexOf(t.ContactId) < 0 && n.addPossibleAttendee(angular.extend(new Contact(null, !0), t));
        });
    }, f.updateFirstAttendeeContactId = function (n, i) {
        var u = t.getFirstRegTypeWithAttendeesInForm(n),
            r;u && (r = u.ActiveAttendees[0], r.ContactInfo == i && (r.ContactId = i.ContactId, r.NoShowFees = i.NoShowFees));
    }, f.updateBillingPersonFromSelectedContact = function (n, t) {
        var r, u;t.ContactId > 0 && (r = angular.extend(n.model.CreatedByUser, t), n.EventSettings.NoShowFeesAllowed && f.getAttendeeNoShowFees(n, r), f.updateFirstAttendeeContactId(n, r), u = n.EventSettings.ShowRelatedContactsUponSearch || n.loginInfo.isLoggedIn, u && f.fetchPossibleAttendeesList(t).then(f.updatePossibleAttendeesList.bind(null, n, !0)), f.updatePaymentWidgetValues(n, r), n.EventSettings.BenefitEmailMatch && !n.loginInfo.isLoggedIn && r.BenefitDiscounts && r.BenefitDiscounts != null && f.resetBenefitDiscounts(n, r), i.reApplyAllValidDiscounts(n));
    }, f.resetBenefitDiscounts = function (n, t) {
        n.EventInfo.EventDiscounts = n.EventInfo.EventDiscounts.filter(function (n) {
            return !n.IsBenefit;
        });n.EventInfo.EventDiscounts = n.EventInfo.EventDiscounts.concat(t.BenefitDiscounts.filter(function (n) {
            return n.ContactId == t.ContactId;
        }));
    }, f.applyMemberSecurityFeatures = function (n, i, r) {
        var s = [Enums.SystemMemberSecurityModeOption.EmailDomainMatch, Enums.SystemMemberSecurityModeOption.ExactEmailMatch, Enums.SystemMemberSecurityModeOption.FullAuth];if (n.model.AllowEmailDomainActivation && !!i && i.length) {
            var u = i[0],
                e = n.model.CreatedByUser,
                o = u.IsMember;n.billing.IsDomainMember = n.loginInfo.isMember = o;n.loginInfo.showMatchMembershipFoundMessage = !0;n.loginInfo.showMatchFoundMessage = !o;o ? t.enableAllRegTypes(n) : t.disableMembersOnlyRegTypes(n, f.hasAccessToMemberOnlyFeature(n));e.OrganizationName = u.OrganizationName;e.OrganizationContactId = u.OrganizationId;e.Title = u.Title;e.MembershipIds = u.MembershipTypesIds;e.ContactRoles = i;
        } else s.indexOf(n.EventSettings.MemberSecurityMode) >= 0 && r && r.ContactId > 0 && (n.loginInfo.showMatchMembershipFoundMessage = r.IsMember, n.loginInfo.showMatchFoundMessage = !r.IsMember, r.IsMember ? t.enableAllRegTypes(n) : t.disableMembersOnlyRegTypes(n, f.hasAccessToMemberOnlyFeature(n)));n.loginInfo.isMember = n.loginInfo.isMember || r && r.IsMember;
    }, f.selectBillingContact = function (n, t) {
        f.updateBillingPersonFromSelectedContact(n, t);f.applyMemberSecurityFeatures(n, null, t);n.potentialBillingContacts = [];
    }, f.setBillingContact = function (n, t) {
        var i = n.PossibleAttendees.find(function (n) {
            return t == n.ContactId;
        });f.updateBillingContactFromSelectedContact(n, i);e(i);
    }, f.clearMatchResults = function (n) {
        n.loginInfo.showNoMatchFoundMessage = !0;n.loginInfo.isMember = n.EventInfo.CurrentUserInfo.IsStaffUser;n.loginInfo.showMatchMembershipFoundMessage = !1;n.loginInfo.showMatchFoundMessage = !1;var i = new Contact(null, !0);i.EmailAddress.EmailAddress = n.model.CreatedByUser.EmailAddress.EmailAddress;f.updateBillingPersonFromSelectedContact(n, i);n.EventSettings.MemberSecurityMode != Enums.SystemMemberSecurityModeOption.FullAuth && t.disableMembersOnlyRegTypes(n, f.hasAccessToMemberOnlyFeature(n));
    }, f.updateBillingContactOptions = function (n, t) {
        if (t && t.data && t.data.Data) {
            var e = t.data.Data,
                r = e.ContactsInfo,
                u = e.PossibleOrganizations;e.Success ? r ? r.length == 1 ? (f.updateBillingPersonFromSelectedContact(n, r[0]), f.applyMemberSecurityFeatures(n, u, r[0])) : (n.potentialBillingContacts = r, f.applyMemberSecurityFeatures(n, u, null)) : !!u && u.length ? (f.applyMemberSecurityFeatures(n, u, null), i.reApplyAllValidDiscounts(n)) : n.potentialBillingContacts = [] : f.clearMatchResults(n);
        } else f.clearMatchResults(n);
    }, f.getAttendeeOrg = function (n, t) {
        return n.model.CreatedByUser.ContactRoles.find(function (n) {
            return n.OrganizationId == t;
        });
    }, f.updateBillingAttendeeOrg = function (n) {
        var t = n.model.CreatedByUser,
            i = t.OrganizationContactId;i && (t.OrganizationName = f.getAttendeeOrg(n, i).OrganizationName);
    }, f.findContactByEmail = function (t) {
        t.loginInfo.showNoMatchFoundMessage = !1;t.loginInfo.showMatchMembershipFoundMessage = !1;t.loginInfo.showMatchFoundMessage = !1;t.loginInfo.isMember = t.EventInfo.CurrentUserInfo.IsStaffUser;var i = t.model.CreatedByUser.EmailAddress.EmailAddress;t.status.billingSearchInProgress = !0;n.findContactByEmail(i, f.updateBillingContactOptions.bind(null, t), null, function () {
            t.status.billingSearchInProgress = !1;
        });
    }, f.searchSponsorsByNameOnEnter = function (n, t, i, r) {
        return function (u) {
            u.which == 13 && (u.preventDefault(), f.searchSponsorsByName(n, t, i, r));
        };
    }, f.searchSponsorsByName = function (t, i, r, u) {
        return r[u] = !0, n.crud.sponsorTypeAhead({ search: i }, function (n) {
            r[u] = !1;t.sponsorSearchResults = n || [];
        }, function () {
            r[u] = !1;
        });
    }, f.searchOrgsByNameOnEnter = function (n, t, i, r) {
        return function (u) {
            u.which == 13 && (u.preventDefault(), f.searchOrgsByName(n, t, i, r));
        };
    }, f.searchOrgsByName = function (t, i, r, u) {
        return r[u] = !0, n.crud.orgTypeAhead({ search: i }, function (n) {
            r[u] = !1;t.orgSearchResults = n || [];
        }, function () {
            r[u] = !1;
        });
    }, f.searchContactByNameOnEnter = function (n, t, i, r, u) {
        return function (e) {
            e.which == 13 && (e.preventDefault(), f.searchContactByName(n, t, i, r, !!u));
        };
    }, f.searchContactByName = function (t, i, r, u, f) {
        return r[u] = !0, n.crud.contactTypeAhead({ search: i, includeNonCRM: !!f && t.EventInfo.CurrentUserInfo.IsStaffUser }, function (n) {
            r[u] = !1;t.contactsSearchResults = n || [];
        }, function () {
            r[u] = !1;
        });
    }, f.singleSignOn = function (n) {
        window.location.href = n + "&ReturnURL=" + encodeURIComponent(window.location.href);
    }, f.getAttendeeNoShowFees = function (t, i) {
        t && t.EventSettings.NoShowFeesAllowed && i && i.ContactId > 0 && n.getAttendeeNoShowFees(i.ContactId).then(function (n) {
            n && (i.NoShowFees = n, t.regTypes.forEach(function (n) {
                n.Attendees.forEach(function (t) {
                    t.resetAdditionalPurchaseItemsFromType(n);
                });
            }));
        });
    }, { login: f.login, logout: f.logout, singleSignOn: f.singleSignOn, confirmLogout: f.confirmLogout, updateInsurance: e, searchOrgsByName: f.searchOrgsByName, searchOrgsByNameOnEnter: f.searchOrgsByNameOnEnter, searchSponsorsByName: f.searchSponsorsByName, searchSponsorsByNameOnEnter: f.searchSponsorsByNameOnEnter, updateSponsorFromSelectedSponsor: f.updateSponsorFromSelectedSponsor, setBillingContact: f.setBillingContact, findContactByEmail: f.findContactByEmail, searchContactByName: f.searchContactByName, searchContactByNameOnEnter: f.searchContactByNameOnEnter, selectBillingContact: f.selectBillingContact, updateBillingAttendeeOrg: f.updateBillingAttendeeOrg, updatePaymentWidgetValues: f.updatePaymentWidgetValues, hasAccessToMemberOnlyFeature: f.hasAccessToMemberOnlyFeature, updateContactCustomFieldValues: f.updateContactCustomFieldValues, updateContactInfoFromSelectedContact: f.updateContactInfoFromSelectedContact, updateAttendeeInfoFromSelectedContact: f.updateAttendeeInfoFromSelectedContact, updateBillingContactFromSelectedContact: f.updateBillingContactFromSelectedContact, getAttendeeNoShowFees: f.getAttendeeNoShowFees };
}]);app.factory("ContactSelectionService", [function () {
    var n = _possibleContacts,
        t,
        i;return n.addPossibleAttendeeIfNeeded = function () {
        var n = this.some(function (n) {
            return n.isEmpty && !n.isAttachedToAttendee;
        });n || this.push(new Contact());
    }, n.clearRelatedContacts = function () {
        var n = -1;for (var t in this) {
            t.ContactId > 0 ? this.splice(n + 1, 1) : n += 1;
        }
    }, t = new InitialContact(), i = new PlaceholderContact(), n.push(t), n.push(i), { ReservedContactIds: [t.ContactId, i.ContactId], InitialContactId: t.ContactId, PlaceholderContactId: i.ContactId, PossibleContacts: n };
}]);app.factory("ValidationService", ["ApiService", "SharedHelpers", "$sce", "$timeout", function (n, t, i, r) {
    var u = this,
        f = i.trustAsHtml,
        e = [],
        o = [];return u.checkRegistrationValidity = function (n, t) {
        return u.updateViolations(n, t), Promise.resolve(u.isRegistrationValid(n, t));
    }, u.isRegistrationValid = function (n, t) {
        if (!n.status.isAttendeesCountOk && !n.status.isSponsorsCountOk && !n.status.isAdditionalPurchaseItemsOk && !n.status.isExhibitorsCountOk || n.recaptcha.required && !n.recaptcha.response || !n.status.maxEventLimitViolation.isOk) return !1;var i = t.$error;return i.required && i.required.length > 0 ? !1 : n.status.isFormOk ? n.status.maxAllRegistrationLimitViolation.isOk ? n.status.isAdditionalItemsLimitOk ? n.status.isTermsOk ? !0 : !1 : !1 : !1 : !1;
    }, u.getMaxEventAttendeeLimitMessage = function (n, t) {
        if (t <= 0) return "";var i = "The maximum attendee limit for the event has been reached.";return !n.EventInfo.CurrentUserInfo.IsStaffUser && n.EventInfo.AllowWaitingList && (i += " You may add " + t + " attendee(s) to the waiting list, or remove them to continue"), i;
    }, u.hasValueLessThan = function (n, t) {
        var i = !1;for (var r in n) {
            if (n.hasOwnProperty(r) && (i = i || n[r] < t, i)) break;
        }return i;
    }, u.updateViolations = function (n, i) {
        var r = 0,
            f;n.EventInfo.MaximumAttendees > 0 && (r = Math.max(0, n.stats.totalAttendeesCount - n.stats.existingAttendeesCount - n.stats.waitingCount - n.EventInfo.VacantSpotsPerEvent));u.fillRequiredFieldsList(n, i);u.fillMaxLengthFieldsList(n, i);n.status.isTermsOk = n.status.isTermsChecked || !n.stats.totalExhibitorsCount || !n.EventInfo.TermsOfUseId;n.status.isAdditionalPurchaseItemsOk = t.anyOverallExtraPurchaseItemsExist(n);n.status.isAttendeesCountOk = n.stats.totalAttendeesCount > 0;n.status.isSponsorsCountOk = n.stats.totalSponsorsCount > 0;n.status.isExhibitorsCountOk = n.stats.totalExhibitorsCount > 0;n.status.isAdditionalItemsLimitOk = !u.hasValueLessThan(n.stats.additionalItemsUsageCount, 0);n.status.maxEventLimitViolation.AttendeesCountExcess = r;n.status.maxEventLimitViolation.msg = u.getMaxEventAttendeeLimitMessage(n, r);n.status.maxEventLimitViolation.isOk = r == 0;f = n.regTypes.map(function (n) {
            return n.AttendeeCountOverTheLimit;
        }).reduce(function (n, t) {
            return n + t;
        }, 0);n.status.maxAllRegistrationLimitViolation.isOk = f == 0;u.fillValidationErrorMessages(n);
    }, u.fillValidationErrorMessages = function (n) {
        n.validationMessages = [{ key: "", messages: [] }, { key: "Please fill out the following required fields:", messages: [] }, { key: "Please adjust the length of the following fields:", messages: [] }];var t = [],
            i = [],
            s = [];u.myInfoRequiredFields.length && (n.status.isAttendeesCountOk || n.status.isAdditionalPurchaseItemsOk || n.status.isSponsorsCountOk || n.status.isExhibitorsCountOk) && (n.EventInfo.CurrentUserInfo.IsStaffUser ? i.push(f('<span class="requiredField">' + u.myInfoRequiredFields.join(", ") + "<\/span><\/p>")) : i.push(f('In Start Registration: <span class="requiredField">' + u.myInfoRequiredFields.join(", ") + "<\/span><\/p>")));u.attendeeInfoRequiredFields.length && i.push(f('In Registration Information: <span class="requiredField">' + u.attendeeInfoRequiredFields.join(", ") + "<\/span><\/p>"));n.status.isAttendeesCountOk || n.status.isAdditionalPurchaseItemsOk || n.status.isSponsorsCountOk || n.status.isExhibitorsCountOk || t.push(f("Please add attendees"));u.maxlengthErrors.length && s.push(f('In Registration Information: <span class="maxlengthField">' + u.maxlengthErrors.join(", ") + "<\/span><\/p>"));n.status.isFormOk || o.length || e.length || t.push(f("<h2>Please ensure all fields on the form are filled out correctly.<\/h2>"));n.status.maxEventLimitViolation.isOk || t.push(f(n.status.maxEventLimitViolation.msg));n.status.maxAllRegistrationLimitViolation.isOk || t.push(f("Maximum registration limit for one or more registration(s) type has been reached."));n.recaptcha.required && !n.recaptcha.response && t.push(f("Please verify that you have checked the “I'm not a robot” checkbox."));!n.status.serverResponse.isOk && n.saveRegistrationClicked && t.push(f(n.status.serverResponse.msg));n.status.isAdditionalItemsLimitOk || t.push("Maximum purchase limit for one or more additional item(s) type has been reached.");n.status.isTermsOk || t.push("Please agree to the Terms and Conditions");r(function () {
            n.validationMessages[0].messages = t;n.validationMessages[1].messages = i;n.validationMessages[2].messages = s;
        });
    }, u.fillRequiredFieldsList = function (n, t) {
        u.myInfoRequiredFields = [];u.attendeeInfoRequiredFields = [];u.FillInRequiredCustomFieldErrors(n, t);u.FillInRequiredFormFieldErrors(n, t);u.myInfoRequiredFields = [].concat(_toConsumableArray(new Set(u.myInfoRequiredFields)));u.attendeeInfoRequiredFields = [].concat(_toConsumableArray(new Set(u.attendeeInfoRequiredFields)));
    }, u.FillInRequiredFormFieldErrors = function (n, t) {
        var i = t.$error.required || [];i.forEach(function (n) {
            var t = u.pickName(n);n.$name.includes("billing") ? u.myInfoRequiredFields.push(t) : u.attendeeInfoRequiredFields.push(t);
        });
    }, u.FillInRequiredCustomFieldErrors = function (n) {
        t.getAttendeesCustomFieldsValues(n).filter(function (n) {
            return n.IsRequired;
        }).filter(function (n) {
            return !n.Value;
        }).filter(function (n) {
            return !u.attendeeInfoRequiredFields.includes(n.DisplayName);
        }).forEach(function (n) {
            u.attendeeInfoRequiredFields.push(n.DisplayName);
        });
    }, u.fillMaxLengthFieldsList = function (n, t) {
        var i = t.$error.maxlength || [];u.maxlengthErrors = i.map(function (n) {
            return u.pickName(n);
        });
    }, u.pickName = function (n) {
        if (n.$name.includes("attendee")) return n.$name.replace("attendee", "").replace("FirstName", "First name").replace("LastName", "Last name");if (n.$name.includes("billing")) return n.$name.replace("billing", "").replace("BillTo", "Bill To").replace("FirstName", "First name").replace("LastName", "Last name");n.$name == "" && n.$$element && $(n.$$element).each(function (n, t) {
            if (t.innerText != "" && t.innerText.toLowerCase().includes("session")) return "sessions";
        });var t = n.$$element[0];if (t) {
            var _n3 = t.parentElement.querySelector(".control-label");if (_n3 && _n3.innerText) return _n3.innerText.trim();
        }return n.$name;
    }, u.checkRegistrationValidityFromServer = function (t, i) {
        return n.validateEventRegistration(i).then(function (n) {
            var i = !(n.Status === 500 && n.Data.length);return i || n.Data.forEach(function (n) {
                t.validationMessages[0].messages.push(f(n));
            }), i;
        });
    }, { updateViolations: u.updateViolations, checkRegistrationValidity: u.checkRegistrationValidity, checkRegistrationValidityFromServer: u.checkRegistrationValidityFromServer, fillValidationErrorMessages: u.fillValidationErrorMessages };
}]);app.factory("DiscountService", ["$sce", "SharedHelpers", "ApiService", "PaymentWidgetService", function (n, t, i, r) {
    var u = this,
        f = [-1, -5];return u.addNewPromoDiscount = function (n) {
        n.model.PromoCodeDiscounts.push({ IsValid: !1, PromoCode: "", EventDiscountId: 0 });
    }, u.isPromoCodeAppliedToAnyRegistrationType = function (n, t) {
        var i = !0;return t.TypeId && (i = t.EventDiscountType == 0 && n.regTypes.some(function (n) {
            return n.RegistrationsCount > 0 && n.EventRegistrationTypeId == t.TypeId;
        }) || t.EventDiscountType == 1 && n.exhibitorTypes.some(function (n) {
            return (n.Exhibitors || []).length && n.exhibitorTypeId == t.TypeId;
        })), i;
    }, u.getPromoDiscountMessage = function (i, r) {
        var u = "";return r.Applied ? (u = "Discount applied: " + r.Name, r.EventDiscountType == 0 && r.TypeId && (u += " For " + t.getRegistrationTypeName(i, r.TypeId)), r.EventDiscountType == 1 && r.TypeId && (u += " For " + t.getExhibitorTypeName(i, r.TypeId)), r.MinToActivateDiscount && (u += " (Min: " + r.MinToActivateDiscount + " attendees)")) : u = r.ErrorMessage ? "<span style='color: red'>" + r.ErrorMessage + "<\/span>" : "<span style='color: red'>Discount doesn't apply to any of " + (r.EventDiscountType == 0 ? "Registration" : "Exhibitor") + " types selected.<\/span>", n.trustAsHtml(u);
    }, u.handlePromoCodeServerResult = function (n, t, i) {
        t.IsValid = i.some(function (n) {
            return n.IsValid;
        });t.IsValid || (n.status.promoCodeMessage = i.reduce(function (n, t) {
            return n.indexOf(t) < 0 && n.push(t), n;
        }, []).reduce(function (n, t) {
            return n + (t.Message + "<\/br>");
        }, ""));i.filter(function (n) {
            return n.IsValid;
        }).forEach(function (i) {
            angular.extend(t, i.DiscountInfo, { DisplayMessage: "" });t.Applied = t.EventDiscountType == 1 ? u.addDiscountToExhibitors(n, t) : u.addDiscountToAttendees(n, t);t.DisplayMessage = u.getPromoDiscountMessage(n, t);
        });u.reApplyAllValidDiscounts(n);
    }, u.showPromoCodeError = function (n, i) {
        n.status.promoCodeMessage = t.getTextHtmlVersion(i);
    }, u.applyPromoCodeDiscount = function (n, t) {
        i.checkPromoCode({ EventDetailId: n.EventInfo.EventDetailId, NewCode: t.PromoCode, AttendeesCount: n.stats.totalAttendeesCount, CurrentCodes: u.getAllDiscounts(n).filter(function (n) {
                return n.Applied;
            }) }, u.handlePromoCodeServerResult.bind(this, n, t), u.showPromoCodeError.bind(this, n));
    }, u.removePromoDiscount = function (n, t, i) {
        u.removeDiscount(n, t);n.model.PromoCodeDiscounts.splice(i, 1);n.model.PromoCodeDiscounts.length || u.addNewPromoDiscount(n);n.status.promoCodeMessage = "";u.reApplyAllValidDiscounts(n);
    }, u.getValidPromoCodeDiscounts = function (n) {
        return n.model.PromoCodeDiscounts.filter(function (n) {
            return n.IsValid;
        });
    }, u.isValidDiscountForRegType = function (n, t) {
        if (!!n.exhibitorTypeId != !!t.EventExhibitorDiscountId || n.Price == 0) return !1;var i = t.EventDiscountType == 0 ? n.RegistrationsCount : (n.Exhibitors || []).length;return t.MinToActivateDiscount && i < t.MinToActivateDiscount ? !1 : (!t.EventRegistrationTypeId || t.EventRegistrationTypeId == n.EventRegistrationTypeId) && (!t.EventExhibitorTypeId || t.EventExhibitorTypeId == n.EventExhibitorTypeId);
    }, u.addDiscountToAttendees = function (n, i) {
        var f = !1;return t.getRegistrationTypesHavingAttendees(n).forEach(function (t) {
            u.isValidDiscountForRegType(t, i) && t.ActiveAttendees.forEach(function (t) {
                f = u.addDiscountIfValid(n, t, i) || f;
            });f = u.addDiscountIfValid(n, t, i) || f;
        }), r.calculateTaxes(n), f;
    }, u.addDiscountToExhibitors = function (n, i) {
        var f = !1;return t.getExhibitorTypesHavingExhibitors(n).forEach(function (t) {
            u.isValidDiscountForRegType(t, i) && t.Exhibitors.forEach(function (t) {
                f = u.addDiscountIfValid(n, t, i) || f;
            });
        }), r.calculateTaxes(n), f;
    }, u.addDiscountIfValid = function (n, t, i) {
        var r = t.isDiscountValid(i);if (r) {
            var u = t.applyDiscount(i);var _r = f.some(function (n) {
                return n == i.EventDiscountId;
            });_r ? n.stats.AddToHiddenDiscounts(u) : n.stats.AddToDiscounts(u);
        }return r;
    }, u.removeDiscountFrom = function (n, t, i) {
        var r = t.removeDiscount(i);var u = f.some(function (n) {
            return n == i.EventDiscountId;
        });u ? n.stats.RemoveFromHiddenDiscounts(r) : n.stats.RemoveFromDiscounts(r);
    }, u.removeDiscount = function (n, i) {
        t.getRegistrationTypesHavingAttendees(n).forEach(function (t) {
            t.Price > 0 && (t.ActiveAttendees.forEach(function (t) {
                u.removeDiscountFrom(n, t, i);
            }), u.removeDiscountFrom(n, t, i));
        });t.getExhibitorTypesHavingExhibitors(n).forEach(function (t) {
            t.Price > 0 && t.Exhibitors.forEach(function (t) {
                u.removeDiscountFrom(n, t, i);
            });
        });r.calculateTaxes(n);
    }, u.getValidExhibitorAttendeeDiscounts = function (n) {
        return n.exhibitorTypes.filter(function (n) {
            return !!n.ExhibitorAttendeeEventRegistrationTypeId;
        }).filter(function (n) {
            return n.AttendeesIncluded > 0;
        }).reduce(function (n, t) {
            return n.concat(t.Exhibitors.map(function () {
                return { EventDiscountId: -1, ExhibitorAddedRegistrationTypeId: t.ExhibitorAttendeeEventRegistrationTypeId, LimitPerPurchase: t.AttendeesIncluded, DiscountNewPrice: 0 };
            }));
        }, []);
    }, u.getValidSponsorAttendeeDiscounts = function (n) {
        return n.sponsorTypes.filter(function (n) {
            return !!n.EventRegistrationTypeId;
        }).filter(function (n) {
            return n.AttendeesIncluded > 0;
        }).reduce(function (n, t) {
            return n.concat(t.Sponsorships.map(function () {
                return { EventDiscountId: -5, SponsorAddedRegistrationTypeId: t.EventRegistrationTypeId, LimitPerPurchase: t.AttendeesIncluded, DiscountNewPrice: 0 };
            }));
        }, []);
    }, u.reApplyAllValidDiscounts = function (n) {
        var t = u.getAllDiscounts(n);u.removeDiscountsApplied(n, t);u.applyDiscountsToRegistrations(n, t);
    }, u.getAllDiscounts = function (n) {
        var t = n.EventInfo.EventDiscounts,
            i = n.EventInfo.EventExhibitorDiscounts,
            r = u.getValidPromoCodeDiscounts(n),
            f = u.getValidExhibitorAttendeeDiscounts(n),
            e = u.getValidSponsorAttendeeDiscounts(n),
            o = e.concat(f),
            s = t.concat(r).concat(i).sort(function (n, t) {
            return (n.DiscountNewPrice || 0) - (t.DiscountNewPrice || 0) || (t.DiscountPercent || 0) - (n.DiscountPercent || 0) || (t.DiscountAmount || 0) - (n.DiscountAmount || 0);
        });return o.concat(s);
    }, u.applyDiscountsToRegistrations = function (n, t) {
        t.forEach(function (t) {
            t.Applied = t.EventExhibitorDiscountId ? u.addDiscountToExhibitors(n, t) : u.addDiscountToAttendees(n, t);t.PromoCode && (t.Applied = u.isPromoCodeAppliedToAnyRegistrationType(n, t), t.DisplayMessage = u.getPromoDiscountMessage(n, t));
        });
    }, u.removeDiscountsApplied = function (n, t) {
        n.regTypes.forEach(function (n) {
            n.ActiveAttendees.forEach(function (n) {
                return n.resetDiscounts();
            });
        });n.exhibitorTypes.forEach(function (n) {
            n.Exhibitors.forEach(function (n) {
                return n.resetDiscounts();
            });
        });t.forEach(function (n) {
            return n.LocalUsedQuantity = 0;
        });n.stats.ResetDiscounts();r.calculateTaxes(n);
    }, { addNewPromoDiscount: u.addNewPromoDiscount, applyPromoCodeDiscount: u.applyPromoCodeDiscount, removePromoDiscount: u.removePromoDiscount, reApplyAllValidDiscounts: u.reApplyAllValidDiscounts };
}]);app = window.app;app.factory("EventInsuranceService", ["moment", "$window", "$rootScope", function (n, t, i) {
    function l(t, i, u, f) {
        var e = n(i.StartDate),
            o = i.EndDate ? n(i.EndDate) : n(i.StartDate).add(1, "days");r.onChange = f;r.EventState = (i.Address || {}).StateProvince || u.TenantState;r.EventPostalCode = (i.Address || {}).PostalCode || u.TenantPostalCode;r.customer = {};r.policy_attributes = { event_end_date: o.format("YYYY-MM-DD"), event_start_date: e.format("YYYY-MM-DD"), insurable_amount: 0, participant: { first_name: "Event Refund", last_name: "Required" }, organization: { org_name: u.TenantName, org_contact_email: u.TenantPrimaryEmail, org_contact_phone: u.TenantPrimaryPhone, org_city: u.TenantCity, org_state: u.TenantState, org_postal_code: u.TenantPostalCode, org_country: u.TenantCountryCode } };r.metadata = { context_name: u.TenantName, context_event: i.Name, event_id: u.HashedEventId, tenant_key: u.TenantKey };r.config = { "registration-cancellation": [{ customer: r.customer, metadata: r.metadata, policy_attributes: r.policy_attributes }] };r.clientId = t;s();
    }function e() {
        u !== null && (t.clearTimeout(u), u = null);
    }function o(n) {
        if (!f) {
            f = !0;e();try {
                n && n();
            } finally {
                i.$broadcast("EventInsuranceService:LoadingStatus", { loading: !1 });
            }
        }
    }function s() {
        r.currentQoutes = null;r.onChange([]);f = !1;e();i.$broadcast("EventInsuranceService:LoadingStatus", { loading: !0 });i.$broadcast("EventInsuranceService:ReadyStatus", { ready: !1 });i.$broadcast("EventInsuranceService:ErrorClear");var n = t.document.getElementById(c);n.innerHTML = null;u = t.setTimeout(function () {
            o(function () {
                i.$broadcast("EventInsuranceService:ReadyStatus", { ready: !0 });i.$broadcast("EventInsuranceService:Error", { message: "Unable to load insurance offer. Please continue without or refresh to try again." });
            });
        }, 1e4);r.widget = new VerticalInsure("#" + c, { client_id: r.clientId, product_config: r.config }, function (n) {
            t.clearTimeout(u);f = !1;o(function () {
                r.currentQoutes = n.quotes;r.onChange(n.quotes);i.$broadcast("EventInsuranceService:ReadyStatus", { ready: !0 });
            });
        }, function () {
            e();r.widget.validate().then(function (n) {
                o(function () {
                    i.$broadcast("EventInsuranceService:ReadyStatus", { ready: !!n });
                });
            });
        });
    }function h() {
        s();
    }function a(n) {
        if (r.widget) {
            var _t7 = Math.round(n * 100) / 100;r.policy_attributes.insurable_amount = _t7 * 100;h();
        }
    }function v(n, t, i, u, f) {
        r.widget && (r.customer.email_address = n, r.customer.first_name = t, r.customer.last_name = i, r.customer.state = u || r.EventState, r.customer.postal_code = f || r.EventPostalCode, r.policy_attributes.participant.first_name = t || n, r.policy_attributes.participant.last_name = i, h());
    }var r = this,
        c = "event-insurance-widget",
        f = !1,
        u = null;return { Init: l, UpdateAmount: a, UpdateContact: v };
}]);app = window.app;app.factory("PaymentWidgetService", ["EventInsuranceService", "SharedHelpers", "$timeout", function (n, t, i) {
    function u(n, t, i) {
        var u = y(n, t, i);return r.widget = u, r.stats = t.stats, u;
    }function f(n) {
        i(function () {
            r.insuranceId = n.quote_id;r.stats.UpdateInsurance(n.total || 0);
        });
    }function e() {
        r.insuranceQuoteId = r.insuranceId;r.insuranceQuoteTotal = r.stats.totalInsuranceInCents;r.insuranceCommitted = !0;r.widget.setInsurance({ quote_id: r.insuranceQuoteId, total: r.insuranceQuoteTotal });
    }function o() {
        return r.insuranceQuoteId;
    }function s() {
        return r.insuranceQuoteTotal;
    }function h() {
        return r.insuranceCommitted;
    }function c(t, i) {
        r.stats.UpdateInsurance(0);r.widget.setAmount(t, i);n.UpdateAmount(r.stats.totalPayment);
    }function l(n) {
        r.widget.setVoluntaryItems(n);
    }function a() {
        r.widget._submit();
    }function v(n) {
        t.calculateTaxes(n);
    }var r = this,
        y = function y(n, t, i) {
        var r = t.model.CreatedByUser.ContactId,
            e = t.EventInfo.PaymentSettings.PaymentGatewayId,
            u = t.EventInfo.PaymentSettings.DonationPaymentGatewayIds ? t.EventInfo.PaymentSettings.DonationPaymentGatewayIds.slice() : null,
            f = void 0;return u && u.length ? (u.unshift(t.EventInfo.PaymentSettings.PaymentGatewayId), f = u) : f = [], e || f.length || !t.InvoicingOptions.AllowInvoicing ? (t.payWidget && (t.payWidget.destroy(), $("#widget").html(""), t.payWidget = null), r = r <= 0 ? null : r, t.payWidget = new MNI.Widgets.PaymentArea("widget", i(n, t, r, e, f))) : (t.billing.PaymentMethod = 1, t.billing.InvoiceLocked = !0), t.payWidget;
    };return { Init: u, Submit: a, setAmount: c, SetInsurance: f, InsuranceQuoteId: o, InsuranceQuoteTotal: s, InsuranceCommitted: h, CommitInsurance: e, calculateTaxes: v, setVoluntaryItems: l };
}]);app.factory("ApiService", ["$resource", "ServerApis", "RequestSecurity", "$q", "$http", function (n, t, i, r, u) {
    var f = this,
        o = "__RequestVerificationToken",
        e;return f.crud = n("", {}, { login: { url: t.OauthUrl, method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, transformRequest: function transformRequest(n) {
                var i = [];for (var t in n) {
                    n.hasOwnProperty(t) && i.push(encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
                }return i.join("&");
            } }, logout: { url: t.LogoutUrl, method: "GET", transformResponse: function transformResponse(n) {
                return { html: n };
            } }, save: { url: t.SaveEventRegistrationUrl, method: "POST" }, determineBillingContact: { url: t.DetermineBillingContactUrl, method: "POST" }, checkPromoCodes: { url: t.ValidatePromoCodesUrl, method: "POST" }, sponsorTypeAhead: { url: t.FindSponsorByNameUrl, method: "GET", isArray: !0, params: {} }, orgTypeAhead: { url: t.FindOrganizationByNameUrl, method: "GET", isArray: !0, params: {} }, contactTypeAhead: { url: t.FindAttendeesUrl, method: "GET", isArray: !0, params: {} }, getRelatedContacts: { url: t.RelatedContactsUrl, identity: "contactId", method: "GET", isArray: !0, params: { hash: i.Hash } }, getAttendeeCustomFields: { url: t.CustomFieldValuesUrl, identity: "contactId", method: "GET" }, validateEventRegistration: { url: t.ValidateEventRegistrationUrl, method: "POST" }, eventRegistrationSplits: { url: t.EventRegistrationSplitsUrl, method: "POST" }, eventRegistrationNoShowFees: { url: t.EventRegistrationNoShowUrl, identity: "contactId", method: "GET", isArray: !0 } }), f.login = function (n) {
        return f.crud.login({ grant_type: "password", username: n.username, password: n.password, client_id: 1, client_secret: document.getElementsByName(o)[0].value }).$promise;
    }, f.logout = function () {
        return f.crud.logout().$promise;
    }, f.saveRegistration = function (n) {
        return f.crud.save({}, n).$promise;
    }, f.findContactByEmail = function (n, f, o, s) {
        e && e.promise.$$state.status == 0 && e.resolve();e = r.defer();var h = { timeout: e.promise, params: { email: n, hash: i.Hash } },
            c = t.GetContactByEmailApiUrl;u.get(c, h).then(function (n) {
            f && f(n);e.resolve();
        }, function (n) {
            o && o(n);
        }).finally(function () {
            s && s();
        });
    }, f.checkPromoCode = function (n, t, i) {
        f.crud.checkPromoCodes(n, function (n) {
            n.Status == 200 ? t(n.Data) : i(n.StatusMessage);
        }, function (n) {
            i(n.StatusMessage);
        });
    }, f.determineBillingContact = function (n) {
        return f.crud.determineBillingContact(n.billing.ContactInfo).$promise;
    }, f.getAttendeeCustomFields = function (n) {
        var t = r.defer();return f.crud.getAttendeeCustomFields({ contactId: n }, function (n) {
            t.resolve(n);
        }, function () {
            t.resolve({});
        }), t.promise;
    }, f.getAttendeeRelatedContacts = function (n) {
        var t = r.defer();return f.crud.getRelatedContacts({ contactId: n }, function (n) {
            t.resolve(n);
        }, function () {
            t.resolve([]);
        }), t.promise;
    }, f.getAttendeeNoShowFees = function (n) {
        var t = r.defer();return f.crud.eventRegistrationNoShowFees({ contactId: n }, function (n) {
            t.resolve(n);
        }, function () {
            t.resolve([]);
        }), t.promise;
    }, f.validateEventRegistration = function (n) {
        return f.crud.validateEventRegistration({}, n).$promise;
    }, f.eventRegistrationSplits = function (n) {
        return f.crud.eventRegistrationSplits({}, n).$promise;
    }, { crud: f.crud, login: f.login, logout: f.logout, saveRegistration: f.saveRegistration, findContactByEmail: f.findContactByEmail, checkPromoCode: f.checkPromoCode, getAttendeeRelatedContacts: f.getAttendeeRelatedContacts, determineBillingContact: f.determineBillingContact, getAttendeeCustomFields: f.getAttendeeCustomFields, validateEventRegistration: f.validateEventRegistration, eventRegistrationSplits: f.eventRegistrationSplits, getAttendeeNoShowFees: f.getAttendeeNoShowFees };
}]);app.factory("EventRegistrationService", ["ApiService", "UserService", "ValidationService", "DiscountService", "SharedHelpers", "PaymentWidgetService", "EventInsuranceService", "$timeout", function (n, t, i, r, u, f, e, o) {
    function h(n) {
        return function (t, u, e) {
            e.increase();t.stats.AddToPrice(e.Price);f.calculateTaxes(t);t.stats[n]++;i.updateViolations(t, u.form);r.reApplyAllValidDiscounts(t);
        };
    }function c(n) {
        return function (t, u, e) {
            e.decrease();t.stats[n] && (t.stats.RemoveFromPrice(e.Price), f.calculateTaxes(t), t.stats[n]--, i.updateViolations(t, u.form), r.reApplyAllValidDiscounts(t));
        };
    }var s = this,
        l = angular.extend;return s.searchForCompany = function (t) {
        return t ? n.crud.orgTypeAhead({ search: t, ignore: [], ms: null }).$promise : [];
    }, s.increaseRegistrations = function (n, u, e, o, s) {
        var h = n.EventInfo.CurrentUserInfo.IsStaffUser;e.increase(h, !1, o, s);n.EventSettings.UseIndividualCustomFieldsForER && Promise.all(e.Attendees.filter(function (n) {
            return n.ContactInfo.ContactId > 0 && n.CustomFields.length && !n.CustomFieldValuesPopulated;
        }).map(function (n) {
            return t.updateContactCustomFieldValues(n);
        }));f.calculateTaxes(n);i.updateViolations(n, u.form);r.reApplyAllValidDiscounts(n);
    }, s.decreaseRegistrations = function (n, t, u) {
        u.decrease();f.calculateTaxes(n);i.updateViolations(n, t.form);r.reApplyAllValidDiscounts(n);
    }, s.increaseSponsorships = h("totalSponsorsCount"), s.decreaseSponsorships = c("totalSponsorsCount"), s.increaseExhibitors = h("totalExhibitorsCount"), s.decreaseExhibitors = c("totalExhibitorsCount"), s.transformClientRegDataToServerFormat = function (n) {
        return { EventRegistrationTypeId: n.EventRegistrationTypeId, EventRegistrationId: n.EventRegistrationId, Attendees: n.ActiveAttendees, RegistrationsCount: n.RegistrationsCount };
    }, s.getRegistrationsForSubmission = function (n) {
        var t = [];return n.regTypes && (t = n.regTypes.filter(function (n) {
            return n.RegistrationsCount > 0;
        }).map(s.transformClientRegDataToServerFormat)), t.length == 0 && u.anyOverallExtraPurchaseItemsExist(n) > 0 && t.push({ Attendees: [] }), t;
    }, s.redirectToThankYouPage = function (n, t, i, r) {
        n.noLocalRegistrationSave = !0;window.location = "/a/Events/Confirm/" + n.model.HashedEventId + "/" + (t || "0") + "/" + (i || "0") + "/" + (r || "0");
    }, s.shouldShowRegTypesSection = function (n) {
        return (n.regTypes || []).some(function (i) {
            return i.shouldShowToAttendees(n, t);
        });
    }, s.anyRegTypeEnabled = function (n) {
        return (n.regTypes || []).some(function (n) {
            return n.Enabled;
        });
    }, s.shouldShowCaptcha = function (n) {
        return s.shouldShowRegTypesSection(n) && s.anyRegTypeEnabled(n) && !n.loginInfo.isLoggedIn && (n.stats.totalPayment <= 0 || n.billing.PaymentMethod == 1);
    }, s.showServerError = function (n, t, r) {
        n.payWidget && (n.payWidget._hideProgress(), n.payWidget.enablePaymentButton());n.status.serverResponse.isOk = !1;var f = (t.Data || {}).Message || t.StatusMessage;n.status.serverResponse.msg = t.Status === 400 ? u.getTextHtmlVersion(f) : "Error saving data";r && r.reject();o(function () {
            n.recaptcha.required && (n.recaptcha.response = null, grecaptcha.reset(n.recaptcha.widgetId));
        });i.fillValidationErrorMessages(n);u.showValidationSummary();
    }, s.getDonationOptions = function (n, t, i) {
        var r = i.AllowCustomPrice,
            u = i.MinimumPrice;
        return { valueField: "Choice", labelField: "Choice", create: r, placeholder: "-- Select Amount " + (r ? "or type your own" : "") + " --", maxItems: 1, createOnBlur: !0, closeAfterSelect: !0, selectOnTab: !0, addEmptyOption: !1, plugins: ["clear_button"], createFilter: function createFilter(n) {
                return u >= 0 && n && parseInt(n) >= u ? !0 : !1;
            }, onChange: s.updateDonationAmount.bind(null, n, t) };
    }, s.getTotalDonationAmount = function (n) {
        var t = 0;return n.EventInfo.DonationItems.forEach(function (n) {
            return t += parseFloat(n.Price || 0);
        }), t;
    }, s.updateDonationAmount = function (n, t) {
        var i = function i() {
            t.stats.RemoveFromPrice(t.stats.totalDonationAmount);t.stats.totalDonationAmount = s.getTotalDonationAmount(t);t.stats.AddToPrice(t.stats.totalDonationAmount);t.recaptcha.updateRequirment();s.setPaymentWidgetAmounts(t);
        };n.$$phase ? i() : n.$apply(i);
    }, s.setPaymentWidgetAmounts = function (n) {
        var e, i;if (n.payWidget) {
            var t = n.EventInfo.PaymentSettings.PaymentGatewayId,
                r = n.EventInfo.PaymentSettings.DonationPaymentGatewayId,
                o = n.EventInfo.PaymentSettings.DonationPaymentGatewayIds,
                u = +n.stats.totalDonationAmount.toFixed(2),
                s = +(n.stats.totalPayment - n.stats.totalDonationAmount).toFixed(2);if ((r || o) && u > 0 && (e = [], f.setVoluntaryItems(e)), r && r != t) u > 0 && f.setAmount(u, r), f.setAmount(s, t);else if (o) {
                i = [];n.EventInfo.DonationItems.forEach(function (n) {
                    if (n.Price) {
                        var _t8 = i[n.PaymentGatewayId] || 0;i[n.PaymentGatewayId] = _t8 + parseFloat(n.Price);
                    }
                });var _r2 = i[t] || 0;i[t] = _r2 + s;i.forEach(function (n, t) {
                    f.setAmount(n.toFixed(2), t);
                });
            } else t && r && r != t || f.setAmount(+n.stats.totalPayment.toFixed(2), t);
        }
    }, s.getOverallAdditionalItemsSelected = function (n) {
        return n.model.ValidOverallExtraPurchaseItems.filter(function (n) {
            return n.PurchaseCount - n.PaidCount != 0;
        });
    }, s.getRegistrationDataToSubmit = function (n) {
        var t = s.getRegistrationsForSubmission(n),
            i = n.sponsorTypes.reduce(function (n, t) {
            return n.concat(t.Sponsorships || []);
        }, []),
            r = n.exhibitorTypes.reduce(function (n, t) {
            return n.concat(t.Exhibitors || []);
        }, []),
            u = n.webReferralSourceTypeId || Enums.SystemWebReferralSourceOption.Website;return { EventId: n.EventSettings.EventId, TargetContactId: n.model.TargetContactId, TargetMode: n.model.TargetMode, ReCaptchaResponse: n.recaptcha.response, DisableReCaptchaCheck: !n.recaptcha.required, IsMember: n.loginInfo.isMember, WebReferralSourceTypeId: u, SendEmailNotification: n.SendEmailNotification, BillingInfo: n.billing, Creator: n.model.CreatedByUser, Registrations: t, Sponsorships: i, Exhibitors: r, DonationItems: n.EventInfo.DonationItems.filter(function (n) {
                return n.Price > 0;
            }), AdditionalPurchaseItems: s.getOverallAdditionalItemsSelected(n), InsuranceInfo: f.InsuranceQuoteId() ? { Id: f.InsuranceQuoteId(), Amount: f.InsuranceQuoteTotal() } : null };
    }, s.validateRegistrationLocal = function (n, t) {
        return n.saveRegistrationClicked = !0, n.status.inProgress = !0, i.checkRegistrationValidity(n, t);
    }, s.validateRegistrationFromServer = function (n, t) {
        return function (r) {
            return r ? (n.payWidget && (n.payWidget._skipStripeRefresh = !0, n.payWidget._showProgress()), i.checkRegistrationValidityFromServer(n, t)) : !1;
        };
    }, s.handleInvalidForm = function (n) {
        return function (t) {
            return !n.overrideValidation && !t ? (u.showValidationSummary(), n.status.inProgress = !1, n.payWidget && n.payWidget._hideProgress(), !1) : (n.status.serverResponse.isOk = !0, !0);
        };
    }, s.validateRegistration = function (n, t, i) {
        return s.validateRegistrationLocal(n, t).then(s.validateRegistrationFromServer(n, i)).then(s.handleInvalidForm(n));
    }, s.submitRegistration = function (t, i, r, u) {
        t.billing.TotalPrice = t.stats.totalPrice;var f = s.getRegistrationDataToSubmit(t),
            e = r ? Promise.resolve(!0) : s.validateRegistration(t, i, f);return e.then(function (r) {
            if (!r) return Promise.resolve();var e = Promise.resolve();return !t.fileUploads.length || (e = Promise.all(t.fileUploads.map(function (n) {
                return n.uploadAll();
            })).catch(function () {
                return s.validateRegistration(t, i, f);
            })), e.then(function () {
                return n.saveRegistration(f);
            }).then(function (n) {
                n.Data && n.Status == 200 ? u(n.Data) : s.showServerError(t, n);
            }, function () {
                t.payWidget && t.payWidget._hideProgress();s.showServerError(t, {});
            }).finally(function () {
                t.status.inProgress = !1;
            });
        });
    }, s.getAndUpdateBillingContact = function (t) {
        return n.determineBillingContact(t);
    }, s.getRegistrationSplits = function (t, i) {
        return t.payWidget && t.payWidget._paymentGatewayTypeId === 6 ? n.eventRegistrationSplits(i) : Promise.resolve(!0);
    }, { searchForCompany: s.searchForCompany, submitRegistration: s.submitRegistration, shouldShowCaptcha: s.shouldShowCaptcha, redirectToThankYouPage: s.redirectToThankYouPage, validateRegistration: s.validateRegistration, setPaymentWidgetAmounts: s.setPaymentWidgetAmounts, getAndUpdateBillingContact: s.getAndUpdateBillingContact, getDonationOptions: s.getDonationOptions, increaseRegistrations: s.increaseRegistrations, decreaseRegistrations: s.decreaseRegistrations, increaseSponsorships: s.increaseSponsorships, decreaseSponsorships: s.decreaseSponsorships, increaseExhibitors: s.increaseExhibitors, decreaseExhibitors: s.decreaseExhibitors, updateDonationAmount: s.updateDonationAmount, getRegistrationDataToSubmit: s.getRegistrationDataToSubmit, getRegistrationSplits: s.getRegistrationSplits };
}]);app.factory("DataInitializationService", ["SharedHelpers", "localStorageService", "EventRegistrationService", "UserService", "ContactSelectionService", "EventInsuranceService", "PaymentWidgetService", function (n, t, i, r, u, f, e) {
    var o = this,
        s = angular.extend,
        h = function h(n, t, r, u, f) {
        return { buttonClass: "form-control btn-primary", paymentGatewayId: u, paymentGateways: f, contactId: r, capture: !1, allowSavingCard: !0, allowBankPayments: t.EventInfo.EnableAchPayments, allowAddingBankAccounts: t.EventInfo.EnableAchPayments, payOnBehalfOfSomebodyElse: t.EventInfo.IsStaff, stripeConnectPaymentMethodConfigId: t.EventInfo.StripeConnectPaymentMethodConfigId, stripeConnectOnlyAchPaymentMethodConfigId: t.EventInfo.StripeConnectOnlyAchPaymentMethodConfigId, showSaveCard: !0, forceShowSaveCard: !0, trackOn: t.EventInfo.PaymentSettings.TrackPaymentOption, orgTerm: t.EventInfo.Terms.Organization, validateControls: function validateControls() {
                var u = this,
                    r = {};return e.CommitInsurance(), i.getRegistrationDataToSubmit && (r = i.getRegistrationDataToSubmit(t)), i.getRegistrationSplits(t, r).then(function (f) {
                    var e = f.Status !== 500 && f.Data != undefined;return e && u.setSaleableAmounts(f.Data), i.validateRegistration(t, n.form, r);
                });
            }, preSubmitFunction: function preSubmitFunction() {
                var n = this;i.getAndUpdateBillingContact(t).then(function (i) {
                    s(t.billing.ContactInfo, i);i.ContactType == Enums.SystemContactTypeOption.Organization ? (n._contactId = t.billing.ContactInfo.OrganizationContactId, n.updateSaveOnContactId(i.ContactId)) : n._contactId = t.billing.ContactInfo.ContactId;n.continuePayCardPost();
                });
            }, callback: function callback(r) {
                var u = this.getPaymentGateways();t.billing.PaymentInfo = s(r, { PaymentGateways: u });var f = o.showConfirmationPage.bind(null, t);i.submitRegistration(t, n.form, !1, f);
            }, widgetLoaded: function widgetLoaded() {
                this.setAddress(t.model.CreatedByUser.Address || {});
            } };
    };return o.showConfirmationPage = function (n, t) {
        o.clearSavedRegistrationInBrowser(n);i.redirectToThankYouPage(n, t.HashedRegistrationId, t.HashedSponsorId, t.HashedExhibitorId);
    }, o.initializeData = function (t, u) {
        var v, c, l, a;for (t.EventInfo.AdditionalPurchaseItems = t.EventInfo.AdditionalPurchaseItems.map(function (n) {
            return s(new AdditionalPurchaseItem(null, n.InventoryQuantity), n);
        }), t.EventInfo.EventSessions = t.EventInfo.EventSessions.map(function (n) {
            return s(new EventSession(), n);
        }), t.regTypes = [], v = n.getvalidExtraPurchaseItemsByType(t, Enums.SystemEventSaleableItemTypeOption.AttendeeItem), t.HasOverallLimit = t.EventInfo.MaximumAttendees > 0, c = 0; c < t.EventInfo.RegistrationTypes.length; c++) {
            l = t.EventInfo.RegistrationTypes[c], t.regTypes[c] = s(new RegistrationType(), l, { AdditionalPurchaseItems: v, EventSessions: n.getRegistrationTypeSessions(t, l.EventRegistrationTypeId), CustomFields: n.getValidRegistrationTypeCustomFields(t, l.EventRegistrationTypeId), Attendees: [], WaitlistEnabled: t.EventInfo.AllowWaitingList, VacantSpotsPerEvent: t.EventInfo.VacantSpotsPerEvent, MaximumAttendeesPerEvent: t.EventInfo.MaximumAttendees }), a = l.RegisteredAttendees.reduce(function (n, t) {
                return (n[t.Settings.GroupId] = n[t.Settings.GroupId] || []).push(t), n;
            }, {}), t.regTypes[c].PurchasedSlots = t.regTypes[c].RegistrationsCount = Object.keys(a).length, Object.keys(a).forEach(function (n) {
                var i = a[n].sort(function (n, t) {
                    return (n.Settings.GroupOrder || 0) - (t.Settings.GroupOrder || 0);
                });o.addAttendeesToRegType(t, t.regTypes[c], i);
            });
        }t.sponsorTypes = t.EventInfo.SponsorshipTypes.map(function (n) {
            return s(new SponsorshipTypeModel(n.Id, n.EventRegistrationTypeId, n.AttendeesIncluded, t.regTypes, n.VacantSpots || (n.IsSoldOut ? 0 : 9999), n.UnlimitedAttendeesIncluded), n);
        });t.sponsorTypesHaveIncludedAttendees = t.sponsorTypes.some(function (n) {
            return n.AttendeesIncluded > 0;
        });t.exhibitorTypes = t.EventInfo.ExhibitorTypes.map(function (i) {
            return s(new ExhibitorTypeModel(i.Id, i.ExhibitorAttendeeEventRegistrationTypeId, i.IncludedAttendeeQuantity, t.regTypes, t.EventInfo.ExhibitorDirectoryId, t.EventInfo.EventDetailId, i.VacantSpots || (i.IsSoldOut ? 0 : 9999), i.UnlimitedAttendeesIncluded), i, { AdditionalPurchaseItems: n.getvalidExtraPurchaseItemsByType(t, Enums.SystemEventSaleableItemTypeOption.ExhibitorItem), CustomFields: n.getValidExhibitorTypeCustomFields(t, i.Id) });
        });t.exhibitorTypesHaveIncludedAttendees = t.exhibitorTypes.some(function (n) {
            return n.AttendeesIncluded > 0;
        });t.regTypes[0] && (t.regTypes[0].possibleContacts = t.PossibleAttendees);t.EventInfo.RegistrationTypes.Count == 1 && t.increaseRegistrations(t.regTypes[0]);t.donationItemsChoicesOptions = (t.EventInfo.DonationItems || []).reduce(function (n, r) {
            return n[r.FundraisingCampaignSaleableItemId] = i.getDonationOptions(u, t, r), n;
        }, {});var y = (t.EventInfo.EventSponsors || []).filter(function (n) {
            return n.CanBeDisplayedOnRegistrationPage;
        }).sort(function (n, t) {
            return (n.Position || 0) - (t.Position || 0) || (n.DisplayOrder || 0) - (t.DisplayOrder || 0);
        });y.length && (t.currentSponsorships = y.reduce(function (n, t) {
            return n[t.Level] = n[t.Level] || [], n[t.Level].push(t), n;
        }, {}));t.payWidget = e.Init(u, t, h);t.EventInfo.IsRegistrationInsuranceEnabledAndConfigured && f.Init(t.EventInfo.EventInsuranceClientId, t.EventInfo, t.model, function (n) {
            e.SetInsurance(n[0] || {});
        });t.EventInfo.CurrentUserInfo.IsStaffUser || r.selectBillingContact(t, t.EventInfo.CurrentUserInfo);
    }, o.updateSelectedSessions = function (n, t, i) {
        t.EventTimeSlots.forEach(function (t) {
            var r = i.find(function (n) {
                return n.EventTimeslotId == t.EventTimeslotId;
            });r && (t.SelectedSession = t.EventSessions.find(function (n) {
                return n.SessionId == r.SelectedSessionId;
            }), t.SelectedSession && (n.model.IsRegistrationUpdate && (t.SelectedSession.FeeItems || []).forEach(function (n) {
                return n.PaidCount = 1;
            }), t.updateSelectedSession(t.SelectedSession)));
        });
    }, o.addAttendeesToRegType = function (n, t, i) {
        var f, r, u;if (i && (i.forEach(function (i) {
            var u = i.EventTimeSlots,
                r;delete i.EventTimeSlots;r = s(new Attendee(t, !0), i, { ContactInfo: s(new Contact(null, !0), i.ContactInfo) });r.ContactId = i.ContactInfo.ContactId;r.InitialContactId = r.ContactId;o.updateSelectedSessions(n, r, u);t.Attendees.push(r);n.stats.totalAttendeesCount += 1;r.eventAttendeeId > 0 && (n.stats.existingAttendeesCount += 1);n.PossibleAttendees.indexOf(r.ContactInfo) == -1 && n.PossibleAttendees.push(r.ContactInfo);n.status.maxRegistrationLimitViolation[t.EventRegistrationTypeId] = {};
        }), t.Attendees.length && t.Attendees.length % t.AttendeesCountPerOneRegistration)) for (f = t.AttendeesCountPerOneRegistration - t.Attendees.length % t.AttendeesCountPerOneRegistration, r = 0; r < f; r++) {
            u = new Attendee(t, !0), u.price = 0, t.Attendees.push(u), t.AttendeesCount++;
        }
    }, o.clearSavedRegistrationInBrowser = function (n) {
        t.remove(n.EventSettings.EventId);
    }, o.loadContactFromData = function (n) {
        var i = s(new EmailAddress(), n.emailAddress),
            t;return n.contactId < 0 && delete n.contactId, t = s(new Contact(null, !1), n, { emailAddress: i }), vm.EventSettings.NoShowFeesAllowed && r.getAttendeeNoShowFees(vm, t), u.PossibleContacts.push(t), t;
    }, o.updateAdditionalPurchaseItems = function (n, t, i) {
        t.length && (t.forEach(function (n) {
            var t = i.find(function (t) {
                return t.eventSaleableItemId == n.eventSaleableItemId;
            });t && (t.PurchaseCount = n.purchaseCount);
        }), e.calculateTaxes(n));
    }, o.loadRegistrationFromBrowser = function (n, r) {
        var f, u;if (!r.model.IsRegistrationUpdate && (f = t.get(r.EventSettings.EventId), f)) try {
            if (u = JSON.parse(f), !u || !r.billing) return;r.billing.ContactInfo = r.model.CreatedByUser = o.loadContactFromData(u.Creator);r.SendEmailNotification = u.SendEmailNotification;u.DonationItems.length && (u.DonationItems.forEach(function (n) {
                var t = r.EventInfo.DonationItems.find(function (t) {
                    return t.FundraisingCampaignSaleableItemId == n.FundraisingCampaignSaleableItemId;
                });t && (t.Price = n.Price);
            }), i.updateDonationAmount(n, r));o.updateAdditionalPurchaseItems(r, u.AdditionalPurchaseItems, r.model.ValidOverallExtraPurchaseItems);u.Registrations.forEach(function (t) {
                for (var e, u, f = r.regTypes.find(function (n) {
                    return n.EventRegistrationTypeId == t.EventRegistrationTypeId;
                }), s = 0; s < t.RegistrationsCount; s++) {
                    var _loop = function _loop() {
                        var n = t.Attendees[u],
                            i = f.Attendees[u];i.ContactInfo = o.loadContactFromData(n.contactInfo);o.updateSelectedSessions(r, i, n.EventTimeSlots);i.CustomFields.forEach(function (t) {
                            var i = n.CustomFields.find(function (n) {
                                return n.EventRegistrationCustomFieldId == t.EventRegistrationCustomFieldId;
                            });i && (t.Value = i.Value);
                        });o.updateAdditionalPurchaseItems(r, n.additionalPurchaseItems, i.AdditionalPurchaseItems);
                    };

                    for (i.increaseRegistrations(r, n, f), e = s * f.AttendeesCountPerOneRegistration, u = e; u < e + f.AttendeesCountPerOneRegistration; u++) {
                        _loop();
                    }
                }
            });
        } catch (e) {
            console.log(e);o.clearSavedRegistrationInBrowser(r);window.location.reload();
        }
    }, o.storeUnsubmittedChanges = function (n, r) {
        if (n && !r.model.IsRegistrationUpdate && !r.noLocalRegistrationSave) {
            var u = i.getRegistrationDataToSubmit(r);delete u.ReCaptchaResponse;t.set(u.EventId, JSON.stringify(u));
        }
    }, { storeUnsubmittedChanges: o.storeUnsubmittedChanges, loadRegistrationFromBrowser: o.loadRegistrationFromBrowser, clearSavedRegistrationInBrowser: o.clearSavedRegistrationInBrowser, addAttendeesToRegType: o.addAttendeesToRegType, initializeData: o.initializeData, showConfirmationPage: o.showConfirmationPage };
}]);app.controller("EventRegistrationCtrlDeferred", ["$scope", "$rootScope", "$window", "$timeout", "SettingsService", "EventRegistrationService", "UserService", "ValidationService", "SharedHelpers", "DiscountService", "DataInitializationService", "RegistrationStepsService", "ContactSelectionService", "PaymentWidgetService", EventRegistrationCtrlDeferred]);
var Step = function () {
    function Step(n, t) {
        _classCallCheck(this, Step);

        this.name = n;this.editable = !1;this.showDetails = !!t;
    }

    _createClass(Step, [{
        key: "IsAvailable",
        value: function IsAvailable() {
            return !0;
        }
    }, {
        key: "IsValid",
        value: function IsValid() {
            return !0;
        }
    }, {
        key: "Name",
        get: function get() {
            return this.name;
        },
        set: function set(n) {
            this.name = n;
        }
    }, {
        key: "ShowDetails",
        get: function get() {
            return this.showDetails;
        },
        set: function set(n) {
            this.showDetails = n;
        }
    }, {
        key: "Editable",
        get: function get() {
            return this.editable;
        },
        set: function set(n) {
            return this.editable = n;
        }
    }]);

    return Step;
}();

var RegistrationTypeStep = function (_Step) {
    _inherits(RegistrationTypeStep, _Step);

    function RegistrationTypeStep() {
        _classCallCheck(this, RegistrationTypeStep);

        return _possibleConstructorReturn(this, (RegistrationTypeStep.__proto__ || Object.getPrototypeOf(RegistrationTypeStep)).call(this, "registration-type-section"));
    }

    _createClass(RegistrationTypeStep, [{
        key: "IsValid",
        value: function IsValid(n) {
            return n.model.ValidOverallExtraPurchaseItems.length > 0 || n.EventSettings.CollectDonations && !!n.EventInfo.DonationItems.length || n.stats.totalSponsorsCount > 0 || n.stats.totalAttendeesCount > 0 || n.stats.totalExhibitorsCount > 0;
        }
    }]);

    return RegistrationTypeStep;
}(Step);

var RegistrantInfoStep = function (_Step2) {
    _inherits(RegistrantInfoStep, _Step2);

    function RegistrantInfoStep() {
        _classCallCheck(this, RegistrantInfoStep);

        return _possibleConstructorReturn(this, (RegistrantInfoStep.__proto__ || Object.getPrototypeOf(RegistrantInfoStep)).call(this, "registrant-info-section"));
    }

    _createClass(RegistrantInfoStep, [{
        key: "IsAvailable",
        value: function IsAvailable(n) {
            return n.stats.totalSponsorsCount > 0 || n.stats.totalAttendeesCount > 0 || n.stats.totalExhibitorsCount > 0 || !(n.model.ValidOverallExtraPurchaseItems.length > 0 || n.EventSettings.CollectDonations && !!n.EventInfo.DonationItems.length);
        }
    }]);

    return RegistrantInfoStep;
}(Step);

var AdditionalInfoStep = function (_Step3) {
    _inherits(AdditionalInfoStep, _Step3);

    function AdditionalInfoStep() {
        _classCallCheck(this, AdditionalInfoStep);

        return _possibleConstructorReturn(this, (AdditionalInfoStep.__proto__ || Object.getPrototypeOf(AdditionalInfoStep)).call(this, "additional-purchases-section"));
    }

    _createClass(AdditionalInfoStep, [{
        key: "IsAvailable",
        value: function IsAvailable(n) {
            return n.model.ValidOverallExtraPurchaseItems.length > 0 || n.EventSettings.CollectDonations && !!n.EventInfo.DonationItems.length;
        }
    }]);

    return AdditionalInfoStep;
}(Step);

app.factory("RegistrationStepsService", [function () {
    var t = this,
        n = [new Step("login-section", !0), new RegistrationTypeStep(), new RegistrantInfoStep(), new AdditionalInfoStep(), new Step("payment-info-section")];return t.goToNextStep = function (t, i) {
        var f = 0,
            u = null,
            r = null;do {
            if (r = n[f++], !!u && !!r && r.IsAvailable(t)) break;(r || {}).Name == i && (u = r);
        } while (!!r);return !u || (u.ShowDetails = !1, u.Editable = !0), !r || (r.Editable = !0, r.ShowDetails = !0), n;
    }, t.editStep = function (t) {
        n.forEach(function (n) {
            return n.ShowDetails = !1;
        });var i = n.filter(function (n) {
            return n.Name == t;
        })[0];return !i || (i.ShowDetails = !0), n;
    }, t.resetSteps = function (t) {
        return t ? n.forEach(function (n) {
            n.ShowDetails = n.Name == "registrant-info-section";n.Editable = !0;
        }) : (n.forEach(function (n) {
            n.ShowDetails = !1;n.Editable = !1;
        }), n[0].ShowDetails = !0, n[0].Editable = !0), n;
    }, t.isStepValid = function (t, i) {
        var r = n.filter(function (n) {
            return n.Name == i;
        })[0];return r ? r.IsValid(t) : !1;
    }, t.isStepAvailable = function (t, i) {
        var r = n.filter(function (n) {
            return n.Name == i;
        })[0];return r ? r.IsAvailable(t) : !1;
    }, { resetSteps: t.resetSteps, goToNextStep: t.goToNextStep, editStep: t.editStep, isStepValid: t.isStepValid, isStepAvailable: t.isStepAvailable };
}]);var formatPhoneNumber = function formatPhoneNumber(n, t) {
    var i = void 0;switch (t) {case 0:
            return n;case 1:
            i = formatToParanthessisWithDashes;break;case 2:
            i = formatPhoneToDotted;break;case 3:
            i = formatPhoneToDashses;}return formatPhoneNumberToAFormat(n, i);
};window.formatPhoneNumber = formatPhoneNumber;