var Omni;
(function (Omni) {
    /*  Add all global module registrations here for dependency injection,
        include external libraries first (such as ngAnimate) and internal libraries second (such as omni.booker)
    */
    var app = angular.module("omni", [
        "ngResource",
        "ngSanitize",
        "ngAnimate",
        "ngTouch",
        "angular-cache",
        "ngAria",
        "duScroll",
        "ui.bootstrap",
        "ui.router",
        "omni.core",
        "omni.booker",
        "omni.resortmap"
    ]);
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Core;
    (function (Core) {
        Core.ngModule = angular.module("omni.core", []);
        var CacheFactoryProvider = (function () {
            function CacheFactoryProvider(cacheFactoryProvider) {
                angular.extend(cacheFactoryProvider.defaults, { maxAge: 15 * 60 * 1000 });
            }
            return CacheFactoryProvider;
        }());
        CacheFactoryProvider.$inject = ["CacheFactoryProvider"];
        var LogProviderConfig = (function () {
            function LogProviderConfig($logProvider, appConfig) {
                $logProvider.debugEnabled(appConfig.DebugMode);
            }
            return LogProviderConfig;
        }());
        LogProviderConfig.$inject = ["$logProvider", "appConfig"];
        var QProviderConfig = (function () {
            function QProviderConfig($qProvider) {
                // This may suppress errors with promises not having error (catch) handlers.
                $qProvider.errorOnUnhandledRejections(false);
            }
            return QProviderConfig;
        }());
        QProviderConfig.$inject = ["$qProvider"];
        var CompileProviderConfig = (function () {
            function CompileProviderConfig($compileProvider, appConfig) {
                // See https://docs.angularjs.org/guide/production for references
                $compileProvider.debugInfoEnabled(appConfig.DebugMode);
                // Disables comment directives ('M'), this speeds up compilation
                $compileProvider.commentDirectivesEnabled(false);
                // Due to resort map legacy code, we cannot disable css class directives ('C'), see https://docs.angularjs.org/guide/directive for references
                $compileProvider.cssClassDirectivesEnabled(true);
            }
            return CompileProviderConfig;
        }());
        CompileProviderConfig.$inject = ["$compileProvider", "appConfig"];
        function momentFactory($window) {
            return $window.moment;
        }
        momentFactory.$inject = ["$window"];
        Core.ngModule.config(QProviderConfig);
        Core.ngModule.config(CacheFactoryProvider);
        Core.ngModule.config(LogProviderConfig);
        Core.ngModule.config(CompileProviderConfig);
        Core.ngModule.factory("moment", momentFactory);
    })(Core = Omni.Core || (Omni.Core = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Core;
    (function (Core) {
        var Constants;
        (function (Constants) {
            var AppConfig = (function () {
                function AppConfig() {
                    this.DebugMode = false;
                }
                return AppConfig;
            }());
            function appConfig() {
                var config = new AppConfig();
                // Usage: Place an <input name='ngDebug' value='True' />
                var debugConfig = angular.element(document.querySelectorAll("input[name='ngDebug']"));
                if (debugConfig && debugConfig.length > 0) {
                    config.DebugMode = debugConfig ? debugConfig.val() === "True" : false;
                }
                return config;
            }
            Core.ngModule.constant("appConfig", appConfig());
        })(Constants = Core.Constants || (Core.Constants = {}));
    })(Core = Omni.Core || (Omni.Core = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Core;
    (function (Core) {
        var ProfileService = (function () {
            function ProfileService($http, $log) {
                this.$http = $http;
                this.$log = $log;
            }
            ProfileService.prototype.GetProfile = function () {
                var _this = this;
                var cfg = {
                    jsonpCallbackParam: "callback"
                };
                return this.$http.jsonp("/profile/profile/myaccount", cfg)
                    .then(function (response) {
                    return response.data.Data;
                })["catch"](function (exception) {
                    _this.$log.debug(exception);
                });
            };
            return ProfileService;
        }());
        ProfileService.$inject = [
            "$http",
            "$log"
        ];
        Core.ngModule.service("omni.core.profileservice", ProfileService);
    })(Core = Omni.Core || (Omni.Core = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule = angular.module("omni.booker", []);
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));



var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("omniBookerBookHeader", {
            bindings: {
                propertyDetail: "=" // Input
            },
            templateUrl: "omni-booker-book-header.html",
            controller: (_a = (function () {
                    function OmniBookerHeaderController($log, bookerConfig, bookingService) {
                        this.$log = $log;
                        this.bookerConfig = bookerConfig;
                        this.bookingService = bookingService;
                        this.opaqueBackground = this.bookerConfig.IsBookerOpaque;
                    }
                    OmniBookerHeaderController.prototype.CloseBooker = function () {
                        this.bookingService.CloseBooker();
                    };
                    return OmniBookerHeaderController;
                }()),
                _a.$inject = [
                    "$log",
                    "bookerConfig",
                    "omni.bookingservice"
                ],
                _a)
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("omniBookerExplore", {
            bindings: {
                propertyDetail: "<"
            },
            controller: (_a = (function () {
                    function OmniBookerExploreController(bookingApiService, $window, bookingService, bookerConfig) {
                        this.bookingApiService = bookingApiService;
                        this.$window = $window;
                        this.bookingService = bookingService;
                        this.bookerConfig = bookerConfig;
                        this.showSpinner = false;
                        this.showExploreList = false;
                        this.showPropertyLink = this.bookerConfig.IsBrandPage();
                    }
                    OmniBookerExploreController.prototype.$onChanges = function () {
                        if (this.propertyDetail) {
                            this.getExploreData();
                        }
                    };
                    OmniBookerExploreController.prototype.exploreProperty = function (propertyUrl) {
                        this.$window.location.href = propertyUrl;
                    };
                    OmniBookerExploreController.prototype.getExploreData = function () {
                        var _this = this;
                        this.showExploreList = false;
                        this.showSpinner = true;
                        this.exploreData = undefined;
                        if (this.propertyDetail.HotelId && this.propertyDetail.HotelId.length > 0) {
                            this.bookingApiService.GetExploreData(this.propertyDetail.HotelId)
                                .then(function (data) {
                                _this.exploreData = data;
                                _this.showExploreList = _this.exploreData.length > 1;
                            })["finally"](function () {
                                _this.showSpinner = false;
                            });
                        }
                    };
                    return OmniBookerExploreController;
                }()),
                _a.$inject = [
                    "omni.bookingapiservice",
                    "$window",
                    "omni.bookingservice",
                    "bookerConfig"
                ],
                _a),
            templateUrl: "omni-booker-explore.html"
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("omniBookerFindHeader", {
            bindings: {
                propertyDetail: "="
            },
            templateUrl: "omni-booker-find-header.html",
            controller: (_a = (function () {
                    function OmniBookerHeaderController(omniBookingService, omPropertyFilter, bookerConfig, $scope, $rootScope, $timeout) {
                        var _this = this;
                        this.omniBookingService = omniBookingService;
                        this.omPropertyFilter = omPropertyFilter;
                        this.bookerConfig = bookerConfig;
                        this.$scope = $scope;
                        this.$rootScope = $rootScope;
                        this.$timeout = $timeout;
                        this.getLocalBookingData = function () {
                            // If we're fetching the data don't try to fetch it again
                            if (_this.findDataPromise) {
                                return _this.findDataPromise;
                            }
                            _this.findDataPromise = _this.omniBookingService.GetFindData(_this.bookerConfig.IncludeGha);
                            _this.findDataPromise.then(function (data) {
                                _this.propertyData = data;
                            });
                            return _this.findDataPromise;
                        };
                        this.opaqueBackground = this.bookerConfig.IsBookerOpaque;
                        this.$scope.$on("bookerStateUpdate", function () { _this.onBookerStateUpdate(); });
                    }
                    OmniBookerHeaderController.prototype.$onInit = function () {
                        this.searchInput = "";
                        this.updateWhereGoingDisplay();
                        // Get the booking data
                        this.getLocalBookingData();
                    };
                    OmniBookerHeaderController.prototype.clearFind = function () {
                        if (this.selectedProperty) {
                            this.selectedProperty.selected = false;
                            this.selectedProperty = undefined;
                        }
                        this.selectedCategory = undefined;
                        this.searchInput = "";
                        this.propertyDetail.HotelId = "";
                        this.propertyDetail.PropertyName = "";
                        this.showResults = false;
                        this.searchResults = [];
                        this.focusSearchInput();
                        this.updateWhereGoingDisplay();
                    };
                    OmniBookerHeaderController.prototype.clearSelected = function () {
                        if (this.selectedProperty) {
                            this.selectedProperty.selected = false;
                            this.selectedProperty = undefined;
                        }
                        this.selectedCategory = undefined;
                        this.propertyDetail.HotelId = "";
                        this.propertyDetail.PropertyName = "";
                        this.propertyDetail.IsComingSoon = false;
                        this.propertyDetail.ComingSoonText = "";
                        this.propertyDetail.HotelLink = "";
                        this.propertyDetail.RedeemFreeNights = false;
                        this.propertyDetail.IsVillas = false;
                        this.updateWhereGoingDisplay();
                    };
                    OmniBookerHeaderController.prototype.focusResult = function (item, itemIndex) {
                        var nthChildVal = itemIndex + 1;
                        var targetResult = document.querySelectorAll(".result-category-list[data-category-name='" + item.category + "'] li:nth-child(" + nthChildVal + ") a")[0];
                        targetResult.focus();
                    };
                    OmniBookerHeaderController.prototype.resultFocused = function (item) {
                        //console.log("focusedItem", item);
                        if (this.selectedProperty) {
                            this.selectedProperty.selected = false;
                        }
                        this.selectedCategory = item.category;
                        this.selectedProperty = item;
                        this.selectedProperty.selected = true;
                    };
                    OmniBookerHeaderController.prototype.selectResult = function (item) {
                        if (item.IsGha) {
                            this.clearFind();
                            return;
                        }
                        if (this.selectedProperty) {
                            this.selectedProperty.selected = false;
                        }
                        this.selectedCategory = item.category;
                        this.selectedProperty = item;
                        this.selectedProperty.selected = true;
                        this.propertyDetail.HotelId = this.selectedProperty.ItemIdGuid;
                        this.propertyDetail.PropertyName = this.selectedProperty.ResultLabel;
                        this.propertyDetail.IsComingSoon = this.selectedProperty.IsComingSoonProperty;
                        this.propertyDetail.ComingSoonText = this.selectedProperty.ComingSoonText;
                        this.propertyDetail.HotelLink = this.selectedProperty.HotelLink;
                        this.propertyDetail.RedeemFreeNights = this.selectedProperty.RedeemFreeNights;
                        this.propertyDetail.IsVillas = this.selectedProperty.IsVillas;
                        this.searchInput = this.propertyDetail.PropertyName;
                        this.showResults = false;
                        this.searchResults = [];
                    };
                    OmniBookerHeaderController.prototype.focusNextResult = function () {
                        if (!this.getSelectedCategory()) {
                            this.selectedCategory = this.getFirstCategory().name;
                        }
                        var category = this.getSelectedCategory();
                        var idx = category.results.indexOf(this.selectedProperty);
                        if (category.results.length - 1 > idx) {
                            this.focusResult(category.results[idx + 1], idx + 1);
                        }
                        else {
                            // Last in category, choose next category
                            this.focusNextCategory();
                        }
                    };
                    OmniBookerHeaderController.prototype.focusPreviousResult = function () {
                        if (!this.getSelectedCategory()) {
                            this.selectedCategory = this.getFirstCategory();
                        }
                        var category = this.getSelectedCategory();
                        var idx = category.results.indexOf(this.selectedProperty);
                        if (idx > 0) {
                            this.focusResult(category.results[idx - 1], idx - 1);
                        }
                        else {
                            // first in category, choose previous category
                            this.focusPreviousCategory();
                        }
                    };
                    OmniBookerHeaderController.prototype.focusNextCategory = function () {
                        if (!this.getSelectedCategory()) {
                            // if no category is selected, choose the first
                            this.selectedCategory = this.getFirstCategory().name;
                        }
                        else {
                            var nextCategory = undefined;
                            for (var i = 0, ct = this.searchResults.length; i < ct; i++) {
                                if (this.searchResults[i].name === this.selectedCategory) {
                                    if (i == ct - 1) {
                                        // This is the last category, we cannot go further
                                        return;
                                    }
                                    else {
                                        nextCategory = this.searchResults[i + 1];
                                    }
                                }
                            }
                            this.selectedCategory = nextCategory.name;
                        }
                        // always select a new property
                        this.focusResult(this.getSelectedCategory().results[0], 0);
                    };
                    OmniBookerHeaderController.prototype.focusPreviousCategory = function () {
                        if (!this.getSelectedCategory()) {
                            // if no category is selected, choose the first
                            this.selectedCategory = this.getFirstCategory().name;
                        }
                        else {
                            var previousCategory = undefined;
                            for (var i = 0, ct = this.searchResults.length; i < ct; i++) {
                                if (this.searchResults[i].name === this.selectedCategory) {
                                    if (i == 0) {
                                        // This is the first category, we cannot go further
                                        return;
                                    }
                                    else {
                                        previousCategory = this.searchResults[i - 1];
                                    }
                                }
                            }
                            this.selectedCategory = previousCategory.name;
                        }
                        // always select a new property
                        var numResults = this.getSelectedCategory().results.length;
                        this.focusResult(this.getSelectedCategory().results[numResults - 1], numResults - 1);
                    };
                    OmniBookerHeaderController.prototype.keyupInSearch = function ($event) {
                        if ($event.key.indexOf("Up") >= 0) {
                            this.focusSearchResults();
                            $event.preventDefault();
                        }
                        else if ($event.key.indexOf("Down") >= 0) {
                            this.focusSearchResults();
                            $event.preventDefault();
                        }
                        else if ($event.key.indexOf("Escape") >= 0) {
                            this.clearFind();
                        }
                    };
                    OmniBookerHeaderController.prototype.keyupInResults = function ($event) {
                        if ($event.key.indexOf("Up") >= 0) {
                            this.focusPreviousResult();
                            $event.preventDefault();
                        }
                        else if ($event.key.indexOf("Down") >= 0) {
                            this.focusNextResult();
                            $event.preventDefault();
                        }
                        else if ($event.key.indexOf("Enter") >= 0) {
                            var selected = this.getSelectedResult();
                            if (selected == undefined) {
                                this.showSelectionMessage = true;
                            }
                            else {
                                this.showSelectionMessage = false;
                                this.selectResult(selected);
                            }
                        }
                        else if ($event.key.indexOf("Escape") >= 0) {
                            this.clearFind();
                        }
                    };
                    OmniBookerHeaderController.prototype.keydown = function ($event) {
                        if ($event.key.indexOf("Up") >= 0 || $event.key.indexOf("Down") >= 0) {
                            $event.preventDefault();
                            $event.view.event.preventDefault();
                        }
                    };
                    OmniBookerHeaderController.prototype.filterAutocompleteData = function () {
                        var _this = this;
                        // We must always re-evaluate whether or not we display the where going label.
                        this.updateWhereGoingDisplay();
                        if (this.selectedProperty) {
                            // If the user has already made a selection and is changing their input, we need to reset the selection
                            this.selectedProperty.selected = false;
                            this.selectedProperty = undefined;
                        }
                        if (this.searchInput.length < 3) {
                            this.searchResults = [];
                            this.showResults = false;
                            return;
                        }
                        this.getLocalBookingData().then(function () {
                            _this.showResults = true;
                            // cleanup previous selected properties and wipe out selections 
                            if (_this.selectedProperty) {
                                _this.selectedProperty.selected = false;
                            }
                            _this.selectedCategory = undefined;
                            _this.selectedProperty = undefined;
                            _this.searchResults = _this.omPropertyFilter(_this.propertyData, _this.searchInput);
                            // Gather all categories from search results and build into a new object
                            var categoriesUnique = _this.searchResults.reduce(function (categories, currentItem) {
                                var foundCategory = undefined;
                                for (var i = 0, ct = categories.length; i < ct; i++) {
                                    if (categories[i].name === currentItem.category) {
                                        foundCategory = categories[i];
                                    }
                                }
                                // Add to categories with special handling for City items.
                                if (foundCategory) {
                                    if (currentItem.category === "City") {
                                        if (currentItem.label.toLowerCase().indexOf(_this.searchInput.toLowerCase()) >= 0) {
                                            if (currentItem.ResultLabel.toLowerCase().indexOf(_this.searchInput.toLowerCase()) >= 0) {
                                                foundCategory.results.push(currentItem);
                                            }
                                        }
                                    }
                                    else {
                                        foundCategory.results.push(currentItem);
                                    }
                                }
                                else {
                                    if (currentItem.category === "City") {
                                        if (currentItem.label.toLowerCase().indexOf(_this.searchInput.toLowerCase()) >= 0) {
                                            if (currentItem.ResultLabel.toLowerCase().indexOf(_this.searchInput.toLowerCase()) >= 0) {
                                                categories.push({ name: currentItem.category, results: [currentItem] });
                                            }
                                        }
                                    }
                                    else {
                                        categories.push({ name: currentItem.category, results: [currentItem] });
                                    }
                                }
                                return categories;
                            }, []);
                            // Reorder results to put Omni ahead of GHA in each category
                            categoriesUnique.forEach(function (category) {
                                category.results.sort(function (a, b) {
                                    if (a.IsGha && !b.IsGha) {
                                        return 1;
                                    }
                                    else {
                                        return 0;
                                    }
                                });
                            });
                            _this.searchResults = categoriesUnique;
                        });
                    };
                    OmniBookerHeaderController.prototype.getSelectedResult = function () {
                        var result = undefined;
                        if (this.getSelectedCategory()) {
                            var category = this.getSelectedCategory();
                            for (var i = 0, ct = category.results.length; i < ct; i++) {
                                if (category.results[i].selected) {
                                    result = category.results[i];
                                }
                            }
                        }
                        return result;
                    };
                    OmniBookerHeaderController.prototype.getSelectedCategory = function () {
                        var selectedCategory = undefined;
                        for (var i = 0, ct = this.searchResults.length; i < ct; i++) {
                            if (this.searchResults[i].name === this.selectedCategory) {
                                selectedCategory = this.searchResults[i];
                            }
                        }
                        return selectedCategory;
                    };
                    OmniBookerHeaderController.prototype.getFirstCategory = function () {
                        var firstCategory = undefined;
                        if (this.searchResults && this.searchResults.length > 0) {
                            firstCategory = this.searchResults[0];
                        }
                        return firstCategory;
                    };
                    OmniBookerHeaderController.prototype.updateWhereGoingDisplay = function () {
                        // Evaluates the search input and shows or hides "where are you going" label accordingly
                        if (this.searchInput.length === 0) {
                            this.showWhereGoingLabel = true;
                        }
                        else {
                            this.showWhereGoingLabel = false;
                        }
                    };
                    OmniBookerHeaderController.prototype.onBookerStateUpdate = function () {
                        this.focusSearchInput();
                    };
                    OmniBookerHeaderController.prototype.focusSearchInput = function () {
                        this.$timeout(function () {
                            angular.element("#where-going").focus();
                        }, 500);
                    };
                    OmniBookerHeaderController.prototype.focusSearchResults = function () {
                        this.$timeout(function () {
                            var firstResult = document.querySelectorAll(".result-category-list:first-of-type li:first-of-type a")[0];
                            firstResult.focus();
                        }, 75);
                    };
                    return OmniBookerHeaderController;
                }()),
                _a.$inject = [
                    "omni.bookingapiservice",
                    "omPropertyFilterFilter",
                    "bookerConfig",
                    "$scope",
                    "$rootScope",
                    "$timeout"
                ],
                _a)
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var templateUrlFn = function ($templateCache) {
            var navigationTemplate = $templateCache.get("omni-booker-navigation.html");
            if (navigationTemplate) {
                return "omni-booker-navigation.html";
            }
            return "omni/assets/booker/booker.defaultnav.html";
        };
        templateUrlFn.$inject = ["$templateCache"];
        Booker.NgModule.component("omniBookerNavigation", {
            controller: (_a = (function () {
                    function OmniBookerNavController($rootScope, $scope, $document, $window, bookingService) {
                        var _this = this;
                        this.$rootScope = $rootScope;
                        this.$scope = $scope;
                        this.$document = $document;
                        this.$window = $window;
                        this.bookingService = bookingService;
                        this.onBookerStateUpdate();
                        this.$scope.$on("bookerStateUpdate", function () { _this.onBookerStateUpdate(); });
                    }
                    OmniBookerNavController.prototype.ToggleNavigation = function () {
                        if (this.isBookerVisible()) {
                            this.bookingService.ToggleBooker();
                        }
                        else {
                            this.bookingService.OpenBooker();
                        }
                    };
                    OmniBookerNavController.prototype.isBookerVisible = function () {
                        var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
                        if (this.$document.scrollTop() < h / 2) {
                            return true;
                        }
                        return false;
                    };
                    OmniBookerNavController.prototype.scrollToTop = function () {
                        var left = 0, top = 0, duration = OmniBookerNavController.scrollDuration;
                        // Scroll to the exact position
                        this.$document.duScrollTo(left, top, duration);
                    };
                    OmniBookerNavController.prototype.onBookerStateUpdate = function () {
                        var bookerState = this.bookingService.GetBookerState();
                        this.ShowBooker = bookerState.IsEnabled;
                        this.Expanded = bookerState.IsExpanded;
                        this.BrandPage = bookerState.IsBrandPage;
                        if (this.Expanded) {
                            this.scrollToTop();
                        }
                    };
                    return OmniBookerNavController;
                }()),
                _a.scrollDuration = 0,
                _a.$inject = [
                    "$rootScope",
                    "$scope",
                    "$document",
                    "$window",
                    "omni.bookingservice"
                ],
                _a),
            templateUrl: templateUrlFn
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var PropertyDetail = (function () {
            function PropertyDetail() {
            }
            return PropertyDetail;
        }());
        Booker.PropertyDetail = PropertyDetail;
        var TravelDates = (function () {
            function TravelDates() {
            }
            return TravelDates;
        }());
        Booker.TravelDates = TravelDates;
        var RoomDetail = (function () {
            function RoomDetail() {
                this.RoomCount = 0;
                this.Rooms = [];
                this.BedRoomCount = null;
                this.VillasView = null;
            }
            return RoomDetail;
        }());
        Booker.RoomDetail = RoomDetail;
        var Room = (function () {
            function Room() {
                var _this = this;
                this.ShowOccupancyAlert = function () {
                    if (_this.AdultCount + _this.ChildCount >= Room.OccupancyAlertNumber) {
                        return true;
                    }
                    return false;
                };
                this.AdultCount = 0;
                this.ChildCount = 0;
                this.ChildAges = [];
            }
            return Room;
        }());
        Room.OccupancyAlertNumber = 5;
        Booker.Room = Room;
        var RateCodes = (function () {
            function RateCodes() {
            }
            return RateCodes;
        }());
        Booker.RateCodes = RateCodes;
        Booker.NgModule.component("omniBooker", {
            bindings: {
                currentPropertyData: "@"
            },
            controller: (_a = (function () {
                    function OmniBookerController($window, $document, moment, BookingApiService, BookingService, $log, $scope, $timeout) {
                        var _this = this;
                        this.$window = $window;
                        this.$document = $document;
                        this.moment = moment;
                        this.BookingApiService = BookingApiService;
                        this.BookingService = BookingService;
                        this.$log = $log;
                        this.$scope = $scope;
                        this.$timeout = $timeout;
                        this.addMarginOnAlert();
                        $window.addEventListener("resize", function () {
                            _this.addMarginOnAlert();
                        });
                        $document.bind("keydown", function (e) {
                            //Keycode for ESC
                            if (e.keyCode === 27) {
                                _this.closeBookerEvent();
                                _this.$scope.$apply();
                            }
                            else if (e.keyCode === 9) {
                                _this.tabBookerEvent(e);
                                _this.$scope.$apply();
                            }
                        });
                    }
                    // ReSharper disable once InconsistentNaming - This is angular's component API
                    OmniBookerController.prototype.$onInit = function () {
                        var _this = this;
                        this.PropertyDetailData = this.BookingService.GetPropertyDetail();
                        this.TravelDatesData = this.BookingService.GetTravelDates();
                        this.RoomDetailData = this.BookingService.GetRoomDetails();
                        this.RateCodesData = this.BookingService.GetRateCodes();
                        this.isArrivalOpen = false;
                        this.isDepartOpen = false;
                        // Sync up data upon initialization of component
                        this.BookingService.PutTravelDates(this.TravelDatesData);
                        this.BookingService.PutRateCodes(this.RateCodesData);
                        var parsedViewModel = JSON.parse(this.currentPropertyData);
                        if (parsedViewModel) {
                            this.findEnabled = false;
                            this.PropertyDetailData.HotelId = parsedViewModel.PropertyId;
                            this.PropertyDetailData.PropertyName = parsedViewModel.PropertyName;
                            this.PropertyDetailData.IsComingSoon = parsedViewModel.IsComingSoon;
                            this.PropertyDetailData.ComingSoonText = parsedViewModel.ComingSoonText;
                            this.PropertyDetailData.HotelLink = parsedViewModel.HotelLink;
                            this.PropertyDetailData.RedeemFreeNights = parsedViewModel.RedeemFreeNights;
                            this.PropertyDetailData.IsVillas = parsedViewModel.IsVillasProperty;
                            this.focusArrivalDate();
                        }
                        else {
                            this.findEnabled = true;
                        }
                        this.$scope.$watch(function () { return _this.findEnabled; }, function (newVal) {
                            _this.$log.debug("FindEnabled flipped");
                            if (newVal === false) {
                                _this.focusArrivalDate();
                            }
                        });
                        this.$log.debug("widget-data=", parsedViewModel);
                        this.$log.debug("propertyData=", this.PropertyDetailData);
                        this.$log.debug("travelData=", this.TravelDatesData);
                        this.$log.debug("roomData=", this.RoomDetailData);
                        this.$log.debug("rateData=", this.RateCodesData);
                    };
                    OmniBookerController.prototype.NavigateToHotel = function () {
                        this.$window.location.href = this.PropertyDetailData.HotelLink;
                    };
                    OmniBookerController.prototype.SubmitBooking = function () {
                        var _this = this;
                        this.BookingApiService.GetBookingLink(this.PropertyDetailData, this.TravelDatesData, this.RoomDetailData, this.RateCodesData)
                            .then(function (link) {
                            _this.$log.debug("setting booking url", link);
                            _this.$window.location.href = link;
                        });
                    };
                    OmniBookerController.prototype.CollapseCalendar = function (mode) {
                        if (mode === "SetArrival") {
                            this.isDepartOpen = false;
                        }
                        if (mode === "SetDeparture") {
                            this.isArrivalOpen = false;
                        }
                    };
                    OmniBookerController.prototype.focusArrivalDate = function () {
                        this.$timeout(function () {
                            var targetResult = document.querySelectorAll(".calendar-arrival .om-bk-date-range")[0];
                            if (targetResult) {
                                targetResult.focus();
                            }
                        }, 200);
                    };
                    OmniBookerController.prototype.focusDepartureDate = function () {
                        this.$timeout(function () {
                            var targetResult = document.querySelectorAll(".calendar-departure .om-bk-date-range")[0];
                            if (targetResult) {
                                targetResult.focus();
                            }
                        }, 200);
                    };
                    OmniBookerController.prototype.addMarginOnAlert = function () {
                        if (angular.element(".security-alert").is(":visible")) {
                            var marginToApply = "0px";
                            if (screen.width > 991) {
                                marginToApply = "40px";
                            }
                            else if (screen.width <= 991 && screen.width >= 768) {
                                marginToApply = "35px";
                            }
                            else if (screen.width <= 767 && screen.width >= 550) {
                                marginToApply = "30px";
                            }
                            else if (screen.width < 550) {
                                marginToApply = "25px";
                            }
                            angular.element("omni-booker").css("margin-top", marginToApply);
                        }
                    };
                    OmniBookerController.prototype.closeBookerEvent = function () {
                        this.BookingService.CloseBooker();
                    };
                    OmniBookerController.prototype.tabBookerEvent = function (event) {
                        this.BookingService.TabBooker(event);
                    };
                    return OmniBookerController;
                }()),
                _a.$inject = ["$window", "$document", "moment", "omni.bookingapiservice", "omni.bookingservice", "$log", "$scope", "$timeout"],
                _a),
            templateUrl: 'omni-booker.html'
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("rateConfirmModal", {
            templateUrl: 'rate-confirm-modal.html',
            bindings: {
                message: "@",
                close: "&",
                dismiss: "&"
            },
            controller: function () {
                var $ctrl = this;
                $ctrl.$onInit = function () {
                };
                $ctrl.ok = function () {
                    $ctrl.close({ $value: 'confirm' });
                };
                $ctrl.cancel = function () {
                    $ctrl.dismiss({ $value: 'cancel' });
                };
            }
        });
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var BedroomOption = (function () {
            function BedroomOption() {
            }
            return BedroomOption;
        }());
        Booker.BedroomOption = BedroomOption;
        var ViewOption = (function () {
            function ViewOption() {
            }
            return ViewOption;
        }());
        Booker.ViewOption = ViewOption;
        Booker.NgModule.component("omniBookerRoomDetails", {
            templateUrl: 'omni-booker-room-details.html',
            bindings: {
                roomDetails: "=",
                propertyDetail: "=" // Two-way
            },
            controller: (_a = (function () {
                    function OmniBookerRoomDetailsController($log) {
                        this.$log = $log;
                        this.RoomCountOptions = [1, 2, 3];
                        this.AdultCountOptions = [1, 2, 3, 4];
                        this.ChildCountOptions = [0, 1, 2, 3, 4];
                        this.ChildAgeOptions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
                        //Properties for Villas
                        this.AdultVillasCountOptions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
                        this.BedroomCountOptions = [];
                        this.VillasViewOptions = [];
                        var bedroomCountString = 'bedroom (per Villa)';
                        this.BedroomCountOptions.push({ Count: 1, Label: "1   " + bedroomCountString });
                        this.BedroomCountOptions.push({ Count: 2, Label: "2   " + bedroomCountString });
                        this.BedroomCountOptions.push({ Count: 3, Label: "3   " + bedroomCountString });
                        this.BedroomCountOptions.push({ Count: 4, Label: "4+ " + bedroomCountString });
                        this.VillasViewOptions.push({ Value: "ocean", Label: "Ocean View" });
                        this.VillasViewOptions.push({ Value: "nature", Label: "Nature View" });
                    }
                    OmniBookerRoomDetailsController.prototype.createDefaultRoom = function () {
                        var room = new Booker.Room();
                        room.AdultCount = 2;
                        room.ChildCount = 0;
                        return room;
                    };
                    OmniBookerRoomDetailsController.prototype.onRoomCountChanged = function () {
                        var currentRoomCount = this.roomDetails.Rooms.length;
                        var roomCount = this.roomDetails.RoomCount;
                        if (currentRoomCount === roomCount) {
                            // Nothing to do here
                            return;
                        }
                        var delta = Math.abs(currentRoomCount - roomCount);
                        var adding = currentRoomCount < roomCount;
                        if (adding) {
                            // Need to add extra rooms
                            for (var i = 0; i < delta; i++) {
                                var newRoom = this.createDefaultRoom();
                                this.roomDetails.Rooms.push(newRoom);
                            }
                        }
                        else {
                            // Need to remove extra rooms
                            this.roomDetails.Rooms.splice(currentRoomCount - delta, delta);
                        }
                        this.$log.debug("change hit", this.roomDetails);
                    };
                    OmniBookerRoomDetailsController.prototype.onChildCountChanged = function (room) {
                        var currentChildrenCount = room.ChildAges.length;
                        var childCount = room.ChildCount;
                        if (currentChildrenCount === childCount) {
                            // Nothing to do here
                            return;
                        }
                        var delta = Math.abs(currentChildrenCount - childCount);
                        var adding = currentChildrenCount < childCount;
                        if (adding) {
                            // Need to add extra age
                            for (var i = 0; i < delta; i++) {
                                room.ChildAges.push(undefined);
                            }
                        }
                        else {
                            // Need to remove extra age
                            room.ChildAges.splice(currentChildrenCount - delta, delta);
                        }
                        this.$log.debug("change hit", this.roomDetails);
                    };
                    return OmniBookerRoomDetailsController;
                }()),
                _a.$inject = ["$log"],
                _a)
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("signInModal", {
            templateUrl: "sign-in-modal",
            bindings: {
                message: "@",
                close: "&",
                dismiss: "&"
            },
            controller: (_a = (function () {
                    function SignInModalController() {
                        var _this = this;
                        //public submit = ($event) => {
                        //    angular.element("[name='navFormSI']").submit();
                        //    //$http.post('http://posttestserver.com/post.php?dir=jsfiddle', JSON.stringify(data)).success(function () {/*success callback*/ });
                        //}
                        this.ok = function () {
                            _this.close({ $value: 'confirm' });
                        };
                        this.cancel = function () {
                            _this.dismiss({ $value: 'cancel' });
                        };
                    }
                    SignInModalController.prototype.$onInit = function () {
                        //TODO: Grab data from service, parse whatever needs to be parsed here and bind data to controller (and hidden fields)
                        //var startDate = new Date(Date.parse($j("form#find-and-book-form #hdnStartDate").val()));
                        //var startDateString = (startDate.getMonth() + 1) + "/" + startDate.getDate() + "/" + startDate.getFullYear();
                        //var endDate = new Date(Date.parse($j("form#find-and-book-form #hdnEndDate").val()));
                        //var endDateString = (endDate.getMonth() + 1) + "/" + endDate.getDate() + "/" + endDate.getFullYear();
                    };
                    return SignInModalController;
                }()),
                _a.$inject = [],
                _a)
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        Booker.NgModule.component("omniBookerSpecialRates", {
            bindings: {
                propertyDetail: "=",
                rateInformation: "="
            },
            controller: (_a = (function () {
                    function SpecialRatesController($log, $uibModal, $q, profileService, bookingService, bookerConfig) {
                        var _this = this;
                        this.$log = $log;
                        this.$uibModal = $uibModal;
                        this.$q = $q;
                        this.profileService = profileService;
                        this.bookingService = bookingService;
                        this.bookerConfig = bookerConfig;
                        this.rateCodeInterpreter = function (value) {
                            if (value) {
                                var old = _this.rateInformation.RateCode;
                                _this.rateInformation.RateCode = value;
                                _this.openComponentModal().then(function (response) {
                                    if (response === "ok") {
                                        _this.rateInformation.GroupCode = "";
                                        _this.rateInformation.PromoCode = "";
                                        _this.rateInformation.RateCode = value;
                                    }
                                    else {
                                        _this.rateInformation.RateCode = old;
                                    }
                                })["finally"](function () {
                                    _this.syncToService();
                                });
                            }
                            else {
                                return _this.rateInformation.RateCode;
                            }
                        };
                        this.groupCodeInterpreter = function (value) {
                            if (typeof value != "undefined") {
                                // If group is already selected, we can continue to receive input
                                if (_this.rateInformation.RateCode === "group_code") {
                                    _this.rateInformation.GroupCode = value;
                                    _this.syncToService();
                                    return _this.rateInformation.GroupCode;
                                }
                                var old = _this.rateInformation.GroupCode;
                                _this.openComponentModal().then(function (response) {
                                    if (response === "ok") {
                                        _this.rateInformation.RateCode = "group_code";
                                        _this.rateInformation.PromoCode = "";
                                        _this.rateInformation.GroupCode = value;
                                    }
                                    else {
                                        _this.rateInformation.GroupCode = old;
                                    }
                                })["finally"](function () {
                                    _this.syncToService();
                                });
                            }
                            else {
                                return _this.rateInformation.GroupCode;
                            }
                        };
                        this.promoCodeInterpreter = function (value) {
                            if (typeof value != "undefined") {
                                // If promo is already selected, we can continue to receive input
                                if (_this.rateInformation.RateCode === "promotional_code") {
                                    _this.rateInformation.PromoCode = value;
                                    _this.syncToService();
                                    return _this.rateInformation.PromoCode;
                                }
                                var old = _this.rateInformation.PromoCode;
                                _this.openComponentModal().then(function (response) {
                                    if (response === "ok") {
                                        _this.rateInformation.RateCode = "promotional_code";
                                        _this.rateInformation.GroupCode = "";
                                        _this.rateInformation.PromoCode = value;
                                    }
                                    else {
                                        _this.rateInformation.PromoCode = old;
                                    }
                                })["finally"](function () {
                                    _this.syncToService();
                                });
                            }
                            else {
                                return _this.rateInformation.PromoCode;
                            }
                        };
                        this.freeNightsInterpreter = function (value) {
                            if (typeof (value) !== "undefined") {
                                // Capture old value, set new value immediately
                                var old = _this.rateInformation.IsRedeemingFreeNights;
                                _this.rateInformation.IsRedeemingFreeNights = value;
                                // Request user profile, ensure user is signed in
                                _this.getUserProfile().then(function () {
                                    if (_this.isUserSignedIn) {
                                        // already signed in
                                        _this.syncToService();
                                    }
                                    else {
                                        _this.openSignInModal().then(function (response) {
                                            if (response === "ok") {
                                                // user will be signed in (and redirected) to SSL site, we will never receive the sign in action here
                                            }
                                            else {
                                                // user cancelled, reset redeeming nights value
                                                _this.rateInformation.IsRedeemingFreeNights = old;
                                                _this.syncToService();
                                            }
                                        });
                                    }
                                });
                            }
                            else {
                                return _this.rateInformation.IsRedeemingFreeNights;
                            }
                        };
                        this.openComponentModal = function () {
                            if (_this.modalInstanceDeferred) {
                                return _this.modalInstanceDeferred;
                            }
                            var deferred = _this.$q.defer();
                            var promoDefined = false, groupDefined = false;
                            if (angular.isDefined(_this.rateInformation.PromoCode) && _this.rateInformation.PromoCode.length > 0) {
                                promoDefined = true;
                            }
                            if (angular.isDefined(_this.rateInformation.GroupCode) && _this.rateInformation.GroupCode.length > 0) {
                                groupDefined = true;
                            }
                            if (!promoDefined && !groupDefined) {
                                deferred.resolve("ok");
                                return deferred.promise;
                            }
                            var modalInstance = _this.$uibModal.open({
                                animation: true,
                                component: 'rateConfirmModal',
                                resolve: {}
                            });
                            modalInstance.result.then(function (selectedItem) {
                                _this.$log.debug('modal-component ok\'ed at: ' + new Date());
                                deferred.resolve("ok");
                            }, function () {
                                _this.$log.debug('modal-component dismissed at: ' + new Date());
                                deferred.resolve("cancel");
                            })["finally"](function () {
                                _this.modalInstanceDeferred = undefined;
                            });
                            _this.modalInstanceDeferred = deferred.promise;
                            return _this.modalInstanceDeferred;
                        };
                        this.openSignInModal = function () {
                            if (_this.signInModalInstanceDeferred) {
                                return _this.signInModalInstanceDeferred;
                            }
                            var deferred = _this.$q.defer();
                            var modalInstance = _this.$uibModal.open({
                                animation: true,
                                component: 'signInModal',
                                ariaLabelledBy: 'sign-in-modal-title',
                                resolve: {}
                            });
                            modalInstance.result.then(function (selectedItem) {
                                _this.$log.debug('signin-component ok\'ed at: ' + new Date());
                                deferred.resolve("ok");
                            }, function () {
                                _this.$log.debug('signin-component dismissed at: ' + new Date());
                                deferred.resolve("cancel");
                            })["finally"](function () {
                                _this.signInModalInstanceDeferred = undefined;
                            });
                            _this.signInModalInstanceDeferred = deferred.promise;
                            return _this.signInModalInstanceDeferred;
                        };
                        this.getUserProfile = function () {
                            if (_this.profileDeferred) {
                                return _this.profileDeferred;
                            }
                            _this.profileDeferred = _this.profileService.GetProfile();
                            _this.profileDeferred.then(function (profileRes) {
                                _this.isUserSignedIn = profileRes.IsUserLoggedIn === "true";
                                _this.userFreeNights = parseInt(profileRes.FreeNights, 10);
                            });
                            return _this.profileDeferred;
                        };
                        this.expandRates = false;
                        this.displayExpedia = this.bookerConfig.ShowExpediaLink;
                    }
                    SpecialRatesController.prototype.$onInit = function () {
                        this.$log.debug("rateInfo=", this.rateInformation);
                    };
                    SpecialRatesController.prototype.syncToService = function () {
                        this.bookingService.PutRateCodes(this.rateInformation);
                    };
                    SpecialRatesController.prototype.onPromoCodeClick = function () {
                        document.getElementById("promoCode").focus();
                    };
                    SpecialRatesController.prototype.onGroupCodeClick = function () {
                        document.getElementById("groupCode").focus();
                    };
                    return SpecialRatesController;
                }()),
                _a.$inject = ["$log", "$uibModal", "$q", "omni.core.profileservice", "omni.bookingservice", "bookerConfig"],
                _a),
            templateUrl: "omni-booker-special-rates.html"
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var TravelDatesState;
        (function (TravelDatesState) {
            TravelDatesState[TravelDatesState["SetArrival"] = 0] = "SetArrival";
            TravelDatesState[TravelDatesState["SetDeparture"] = 1] = "SetDeparture";
        })(TravelDatesState || (TravelDatesState = {}));
        Booker.NgModule.component("omniBookerTravelDate", {
            bindings: {
                controlId: "@",
                travelDates: "=",
                calendarClass: "@",
                calendarMode: "@",
                calchange: "&",
                label: "@",
                isOpened: "="
            },
            controller: (_a = (function () {
                    function OmniBookerTravelDateController($window, $log, moment, bookingService) {
                        this.$window = $window;
                        this.$log = $log;
                        this.moment = moment;
                        this.bookingService = bookingService;
                        this.isOpened = false;
                    }
                    OmniBookerTravelDateController.prototype.$onInit = function () {
                        var typedStateString = this.calendarMode;
                        this.state = TravelDatesState[typedStateString];
                        if (this.state == TravelDatesState.SetArrival) {
                            this.travelDates.ArrivalDate = this.getDefaultStartDate();
                        }
                        if (this.state == TravelDatesState.SetDeparture) {
                            this.travelDates.DepartureDate = this.getDefaultEndDate();
                        }
                    };
                    OmniBookerTravelDateController.prototype.toggleCalendar = function () {
                        this.isOpened = !this.isOpened;
                        if (this.isOpened) {
                            this.syncCalendar();
                        }
                        this.calchange({ mode: this.calendarMode });
                    };
                    OmniBookerTravelDateController.prototype.getDefaultStartDate = function () {
                        if (this.travelDates.ArrivalDate) {
                            return this.travelDates.ArrivalDate;
                        }
                        else {
                            return this.moment.utc(this.bookingService.GetCurrentDate());
                        }
                    };
                    OmniBookerTravelDateController.prototype.getDefaultEndDate = function () {
                        if (this.travelDates.DepartureDate) {
                            return this.travelDates.DepartureDate;
                        }
                        else {
                            return this.moment.utc(this.bookingService.GetCurrentDate()).add('days', 1);
                        }
                    };
                    OmniBookerTravelDateController.prototype.syncCalendar = function () {
                        this.selected = this._removeTime(this.moment.utc());
                        this.$log.debug("syncing calendar=", this.state);
                        if (this.state === TravelDatesState.SetDeparture && this.travelDates.DepartureDate) {
                            this.selected = this._removeTime(this.moment.utc(this.travelDates.DepartureDate));
                        }
                        else if (this.state === TravelDatesState.SetArrival && this.travelDates.ArrivalDate) {
                            this.selected = this._removeTime(this.moment.utc(this.travelDates.ArrivalDate));
                        }
                        this.month = this.selected.clone();
                        var start = this.selected.clone();
                        start.date(1);
                        this._removeTime(start.day(0));
                        this._buildMonth(start, this.month);
                    };
                    OmniBookerTravelDateController.prototype.isSelected = function (date) {
                        // Used for styling the selected dates in calendar
                        var arrival = this.moment.utc(this.travelDates.ArrivalDate);
                        var departure = this.moment.utc(this.travelDates.DepartureDate);
                        if (this.state === TravelDatesState.SetArrival && this.moment.utc(date).isSame(arrival)) {
                            return true;
                        }
                        if (this.state === TravelDatesState.SetDeparture && this.moment.utc(date).isSame(departure)) {
                            return true;
                        }
                        return false;
                    };
                    OmniBookerTravelDateController.prototype.select = function (day) {
                        this.selected = day.date;
                        this.$log.debug("selected=", this.selected);
                        var today = this.moment.utc().startOf("day");
                        if (this.selected.isBefore(today)) {
                            this.$log.debug("cannot set date in past");
                            return;
                        }
                        if (this.state === TravelDatesState.SetArrival) {
                            this.travelDates.ArrivalDate = this.selected;
                            if (this.travelDates.DepartureDate && (this.selected.isAfter(this.travelDates.DepartureDate)
                                || this.selected.isSame(this.travelDates.DepartureDate))) {
                                this.travelDates.DepartureDate = this.moment.utc(this.travelDates.ArrivalDate).add('days', 1);
                                this.syncToService();
                            }
                            if (day.isCurrentMonth === false) {
                                if (day.date.isAfter(this.month)) {
                                    this.nextMonth();
                                }
                            }
                        }
                        if (this.state === TravelDatesState.SetDeparture) {
                            var arrival = this.moment.utc(this.travelDates.ArrivalDate);
                            if (arrival.isAfter(this.selected)) {
                                this.$log.debug("cannot set departure earlier than arrival");
                                return;
                            }
                            else if (this.selected.isSame(arrival)) {
                                this.$log.debug("cannot set same dates");
                                return;
                            }
                            else {
                                this.travelDates.DepartureDate = this.selected;
                                this.syncToService();
                            }
                        }
                        this.toggleCalendar();
                    };
                    OmniBookerTravelDateController.prototype.previousMonth = function () {
                        var prevMonth = this.month.clone().subtract("1", "months");
                        var lastDay = prevMonth.endOf("month");
                        // Disable previous month if its completely in the past
                        if (this.moment.utc(lastDay).isBefore()) {
                            return;
                        }
                        // Select the previous month
                        var previous = this.month.clone();
                        this._removeTime(previous.month(previous.month() - 1).date(1));
                        this.month.month(this.month.month() - 1);
                        this._buildMonth(previous, this.month);
                    };
                    OmniBookerTravelDateController.prototype.nextMonth = function (keycode) {
                        if (keycode && keycode === 9) {
                            this.$window.document.getElementById("prevMonth" + this.state).focus();
                        }
                        if (keycode && keycode === 13 || !keycode) {
                            var next = this.month.clone();
                            this._removeTime(next.month(next.month() + 1).date(1));
                            this.month.month(this.month.month() + 1);
                            this._buildMonth(next, this.month);
                        }
                    };
                    OmniBookerTravelDateController.prototype.setTravelDateLabelFormat = function (date) {
                        return this.moment.utc(date).format(OmniBookerTravelDateController.ShortDateFormat);
                    };
                    OmniBookerTravelDateController.prototype.syncToService = function () {
                        this.bookingService.PutTravelDates(this.travelDates);
                    };
                    OmniBookerTravelDateController.prototype._removeTime = function (date) {
                        return date.day(0).hour(0).minute(0).second(0).millisecond(0);
                    };
                    OmniBookerTravelDateController.prototype._buildMonth = function (start, month) {
                        this.weeks = [];
                        var done = false, date = start.clone(), monthIndex = date.month(), count = 0;
                        while (!done) {
                            this.weeks.push({ days: this._buildWeek(date.clone(), month) });
                            date.add(1, "w");
                            done = count++ > 2 && monthIndex !== date.month();
                            monthIndex = date.month();
                        }
                    };
                    OmniBookerTravelDateController.prototype._buildWeek = function (date, month) {
                        var days = [];
                        for (var i = 0; i < 7; i++) {
                            days.push({
                                name: date.format("dd").substring(0, 1),
                                arialabel: date.format("MMMM Do YYYY"),
                                number: date.date(),
                                isCurrentMonth: date.month() === month.month(),
                                isToday: date.isSame(this.moment.utc(this.bookingService.GetCurrentDate()), "day"),
                                isPast: this.isIllegalSelectionDate(date),
                                date: date
                            });
                            date = date.clone();
                            date.add(1, "d");
                        }
                        return days;
                    };
                    OmniBookerTravelDateController.prototype.isIllegalSelectionDate = function (date) {
                        if (date.isBefore(this.moment.utc(this.bookingService.GetCurrentDate()), "day")) {
                            return true;
                        }
                        return false;
                    };
                    return OmniBookerTravelDateController;
                }()),
                // For formatting, see https://momentjs.com/docs/#/displaying/format/ 
                _a.ShortDateFormat = "MM/DD/YYYY",
                _a.$inject = ["$window", "$log", "moment", "omni.bookingservice"],
                _a),
            templateUrl: 'omni-booker-travel-date.html'
        });
        var _a;
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var Constants;
        (function (Constants) {
            var BookerConfiguration = (function () {
                function BookerConfiguration() {
                    this.ShowBookingWidget = false;
                    this.IsBookerAlwaysOpen = false;
                    this.IsBookerOpaque = false;
                    this.IsBookerExpanded = false;
                    this.PageType = "";
                    this.CurrentDate = new Date();
                    this.ShowExpediaLink = false;
                    this.IncludeGha = false;
                }
                BookerConfiguration.prototype.IsBrandPage = function () {
                    if (this.PageType === "Brand") {
                        return true;
                    }
                    return false;
                };
                BookerConfiguration.prototype.IsResortPage = function () {
                    if (this.PageType === "Resort") {
                        return true;
                    }
                    return false;
                };
                BookerConfiguration.prototype.IsHotelPage = function () {
                    if (this.PageType === "Hotel") {
                        return true;
                    }
                    return false;
                };
                return BookerConfiguration;
            }());
            function bookerConfig() {
                var config = new BookerConfiguration();
                var showBookingWidget = angular.element("[name='om-booking-showbookingwidget']");
                config.ShowBookingWidget = showBookingWidget ? showBookingWidget.val() === "True" : false;
                var isBookerOpaque = angular.element("[name='om-booking-isbookeropaque']");
                config.IsBookerOpaque = isBookerOpaque ? isBookerOpaque.val() === "True" : false;
                var isBookerAlwaysOpen = angular.element("[name='om-booking-isbookeralwaysopen']");
                config.IsBookerAlwaysOpen = isBookerAlwaysOpen ? isBookerAlwaysOpen.val() === "True" : false;
                var isBookerExpanded = angular.element("[name='om-booking-isbookerexpanded']");
                config.IsBookerExpanded = isBookerExpanded ? isBookerExpanded.val() === "True" : false;
                var pageType = angular.element("[name='om-booking-pagetype']");
                config.PageType = pageType ? pageType.val() : "";
                var showExpediaLink = angular.element("[name='om-booking-showexpedialink']");
                config.ShowExpediaLink = showExpediaLink ? showExpediaLink.val() === "True" : false;
                var includeGha = angular.element("[name='om-booking-includegha']");
                config.IncludeGha = includeGha ? includeGha.val() === "True" : false;
                var currentDate = angular.element("[name='om-booking-currentdate']");
                var date;
                if (currentDate) {
                    date = new Date(parseInt(currentDate.val()));
                }
                else {
                    date = new Date();
                }
                config.CurrentDate = this.moment.utc(date).toDate();
                return config;
            }
            Booker.NgModule.constant("bookerConfig", bookerConfig());
            var DateConfiguration = (function () {
                function DateConfiguration() {
                    this.MonthsLong = [];
                    this.MonthsShort = [];
                    this.WeekdaysLong = [];
                    this.WeekdaysShort = [];
                }
                return DateConfiguration;
            }());
            function dateConfig() {
                var config = new DateConfiguration();
                var momentConfig = angular.element("input[name='dateConfig']");
                if (momentConfig && momentConfig.length > 0) {
                    var parsedViewModel = JSON.parse(momentConfig.val());
                    config.MonthsLong = parsedViewModel.LongMonthList.split(",");
                    config.MonthsShort = parsedViewModel.ShortMonthList.split(",");
                    config.WeekdaysLong = parsedViewModel.LongWeekdayList.split(",");
                    config.WeekdaysShort = parsedViewModel.ShortWeekdayList.split(",");
                }
                return config;
            }
            Booker.NgModule.constant("dateConfig", dateConfig());
        })(Constants = Booker.Constants || (Booker.Constants = {}));
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        function changeCategoryTitle() {
            return function (category) {
                if (category === "City") {
                    category = "City / State";
                }
                return category;
            };
        }
        changeCategoryTitle.$inject = [];
        Booker.NgModule.filter("changeCategoryTitle", changeCategoryTitle);
        function searchHighlight($sce) {
            return function (text, phrase, category, city, state, isGha) {
                if (phrase) {
                    text = text.replace(new RegExp('(' + phrase + ')', 'gi'), '<span class="search-highlight">$1</span>');
                    if (category === "Hotel") {
                        var cityHighlighted = city.replace(new RegExp('(' + phrase + ')', 'gi'), '<span class="search-highlight" >$1</span>');
                        if (isGha) {
                            text = text.concat('<span class="gha-line-break"></span>');
                        }
                        text = text.concat('<span class="search-highlight-small">' + cityHighlighted + ', ' + state + '</span>');
                        if (isGha) {
                            text = text.concat(' <span class="search-highlight-small gha-search-badge">(DISCOVERY Partner)</span>');
                        }
                    }
                }
                return $sce.trustAsHtml(text);
            };
        }
        searchHighlight.$inject = ["$sce"];
        Booker.NgModule.filter("searchHighlight", searchHighlight);
        function propertyLabelFilter() {
            return function (input, search) {
                input = input || [];
                var filtered = [];
                for (var i = 0, ct = input.length; i < ct; i++) {
                    var item = input[i];
                    if (item.label.search(new RegExp(search, 'i')) >= 0) {
                        filtered.push(item);
                    }
                }
                return filtered;
            };
        }
        propertyLabelFilter.$inject = [];
        Booker.NgModule.filter("omPropertyFilter", propertyLabelFilter);
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var GlobalBookerDetails = (function () {
            function GlobalBookerDetails() {
                this.Country = "-1";
                this.City = "-1";
                this.Brand = "-1";
                this.Hotel = "-1";
            }
            return GlobalBookerDetails;
        }());
        Booker.GlobalBookerDetails = GlobalBookerDetails;
        var BookingDetail = (function () {
            function BookingDetail() {
                this.BookingStartDate = "";
                this.BookingEndDate = "";
                this.RoomQuantity = "";
                this.Room1AdultQuantity = "";
                this.Room1ChildQuantity = "";
                this.Room1ChildAge1 = "";
                this.Room1ChildAge2 = "";
                this.Room1ChildAge3 = "";
                this.Room1ChildAge4 = "";
                this.Room2AdultQuantity = "";
                this.Room2ChildQuantity = "";
                this.Room2ChildAge1 = "";
                this.Room2ChildAge2 = "";
                this.Room2ChildAge3 = "";
                this.Room2ChildAge4 = "";
                this.Room3AdultQuantity = "";
                this.Room3ChildQuantity = "";
                this.Room3ChildAge1 = "";
                this.Room3ChildAge2 = "";
                this.Room3ChildAge3 = "";
                this.Room3ChildAge4 = "";
                this.AccountCode = "";
                this.GroupCode = "";
                this.AdaAccessible = "";
                this.HotelId = "";
                this.Rates = "";
                this.TravelAgentNumber = "";
                this.IsRedeemingFreeNights = false;
                this.VillasBedRoomQuantity = "";
                this.VillasView = "";
            }
            return BookingDetail;
        }());
        var BookingDetailGha = (function () {
            function BookingDetailGha() {
                this.StartDate = "";
                this.EndDate = "";
                this.Country = "";
                this.City = "";
                this.HotelBrand = "";
                this.Hotel = "";
            }
            return BookingDetailGha;
        }());
        var BookingApiService = (function () {
            function BookingApiService($http, $log, $q, moment) {
                this.$http = $http;
                this.$log = $log;
                this.$q = $q;
                this.moment = moment;
            }
            BookingApiService.prototype.GetBookingLink = function (propertyDetail, travelDates, roomDetails, rateCodes) {
                var _this = this;
                var model = this.generateBookingDetailModel(propertyDetail, travelDates, roomDetails, rateCodes);
                return this.$http.post("/find/bookings/checkratesandavailability", model).then(function (response) {
                    _this.$log.debug("resolved checkrates=", response);
                    return response.data;
                })["catch"](function (response) {
                    _this.$log.debug("failed checkrates=", response);
                });
            };
            BookingApiService.prototype.GetGhaLink = function (searchDetail, travelDates) {
                var _this = this;
                var model = this.generateGhaBookingDetailModel(searchDetail, travelDates);
                return this.$http.post("/find/bookings/checkgharatesandavailablity", model).then(function (response) {
                    _this.$log.debug("resolved checkrates=", response);
                    return response.data;
                })["catch"](function (response) {
                    _this.$log.debug("failed checkrates=", response);
                });
            };
            BookingApiService.prototype.GetFindData = function (includeGha) {
                var _this = this;
                if (includeGha === void 0) { includeGha = false; }
                return this.$http.get("/find/findandbook/autocomplete", { cache: true, params: { includeGha: includeGha } }).then(function (response) {
                    _this.$log.debug("resolved autocomplete=", response);
                    var mapped = response.data.map(function (currentValue) {
                        var newOne = new Booker.BookingDataResult();
                        newOne.category = currentValue.category;
                        newOne.City = currentValue.City;
                        newOne.label = currentValue.label;
                        newOne.State = currentValue.State;
                        newOne.ItemIdGuid = currentValue.ItemIdGuid;
                        newOne.ResultLabel = currentValue.ResultLabel;
                        newOne.SubCategory = currentValue.SubCategory;
                        newOne.IsComingSoonProperty = currentValue.IsComingSoonProperty;
                        newOne.ComingSoonText = currentValue.ComingSoonText;
                        newOne.HotelLink = currentValue.HotelLink;
                        newOne.RedeemFreeNights = currentValue.RedeemFreeNights;
                        newOne.HotelCode = currentValue.HotelCode;
                        newOne.IsVillas = currentValue.IsVillasProperty;
                        newOne.IsGha = currentValue.IsGha;
                        return newOne;
                    });
                    return mapped;
                })["catch"](function (response) {
                    _this.$log.debug("failed autocomplete=", response);
                    return [];
                });
            };
            BookingApiService.prototype.GetGlobalData = function (country, city, brand, hotel) {
                var _this = this;
                var formatted = country + "/" + city + "/" + brand + "/" + hotel;
                return this.$http.get("/find/bookings/getgharesponsedata/" + formatted).then(function (response) {
                    _this.$log.debug("resolved GHA=", response);
                    return response.data;
                })["catch"](function (response) {
                    _this.$log.debug("failed GHA=", response);
                    return response;
                });
            };
            BookingApiService.prototype.GetExploreData = function (guid) {
                var _this = this;
                return this.$http.get("/find/findandbook/getexploreoptions/" + guid, { cache: true })
                    .then(function (response) {
                    _this.$log.debug("resolved exploreOptions=", response);
                    return response.data;
                })["catch"](function (response) {
                    _this.$log.debug("failed exploreOptions=", response);
                    return [];
                });
            };
            BookingApiService.prototype.generateBookingDetailModel = function (propertyDetail, travelDates, roomDetails, rateCodes) {
                var bookingDetailModel = new BookingDetail();
                bookingDetailModel.HotelId = propertyDetail.HotelId;
                // Travel dates
                if (travelDates.ArrivalDate) {
                    // format to ISO 8601, this needs to be understood by .NET
                    var formattedStart = this.moment.utc(travelDates.ArrivalDate).hour(0).minute(0).second(0).millisecond(0).format('MM-DD-YYYY');
                    bookingDetailModel.BookingStartDate = formattedStart;
                    if (travelDates.DepartureDate) {
                        // format to ISO 8601, this needs to be understood by .NET
                        var formattedEnd = this.moment.utc(travelDates.DepartureDate).hour(0).minute(0).second(0).millisecond(0).format('MM-DD-YYYY');
                        bookingDetailModel.BookingEndDate = formattedEnd;
                    }
                }
                else {
                    // If we've cleared dates and have no start or end date, select the start date to today and nothing for end date.
                    // format to ISO 8601, this needs to be understood by .NET
                    var formattedStart = this.moment.utc().hour(0).minute(0).second(0).millisecond(0).format('MM-DD-YYYY');
                    bookingDetailModel.BookingStartDate = formattedStart;
                    bookingDetailModel.BookingEndDate = "";
                }
                // Rate codes
                bookingDetailModel.TravelAgentNumber = rateCodes.TravelAgentNumber;
                bookingDetailModel.AccountCode = rateCodes.PromoCode;
                bookingDetailModel.IsRedeemingFreeNights = rateCodes.IsRedeemingFreeNights;
                bookingDetailModel.GroupCode = rateCodes.GroupCode;
                bookingDetailModel.Rates = rateCodes.RateCode;
                // Room details
                bookingDetailModel.RoomQuantity = roomDetails.RoomCount.toString(10);
                bookingDetailModel.AdaAccessible = roomDetails.Accessible ? "true" : "false";
                //Villas Features
                if (propertyDetail.IsVillas) {
                    bookingDetailModel.VillasBedRoomQuantity = roomDetails.BedRoomCount.Count.toString(10);
                    bookingDetailModel.VillasView = roomDetails.VillasView.Value;
                }
                for (var i = 0; i < roomDetails.Rooms.length; i++) {
                    var currentRoom = roomDetails.Rooms[i];
                    switch (i) {
                        case 0:
                            bookingDetailModel.Room1AdultQuantity = currentRoom.AdultCount.toString(10);
                            bookingDetailModel.Room1ChildQuantity = currentRoom.ChildCount.toString(10);
                            var childrenRm1 = mapChildren(currentRoom);
                            bookingDetailModel.Room1ChildAge1 = childrenRm1[0];
                            bookingDetailModel.Room1ChildAge2 = childrenRm1[1];
                            bookingDetailModel.Room1ChildAge3 = childrenRm1[2];
                            bookingDetailModel.Room1ChildAge4 = childrenRm1[3];
                            break;
                        case 1:
                            bookingDetailModel.Room2AdultQuantity = currentRoom.AdultCount.toString(10);
                            bookingDetailModel.Room2ChildQuantity = currentRoom.ChildCount.toString(10);
                            var childrenRm2 = mapChildren(currentRoom);
                            bookingDetailModel.Room2ChildAge1 = childrenRm2[0];
                            bookingDetailModel.Room2ChildAge2 = childrenRm2[1];
                            bookingDetailModel.Room2ChildAge3 = childrenRm2[2];
                            bookingDetailModel.Room2ChildAge4 = childrenRm2[3];
                            break;
                        case 2:
                            bookingDetailModel.Room3AdultQuantity = currentRoom.AdultCount.toString(10);
                            bookingDetailModel.Room3ChildQuantity = currentRoom.ChildCount.toString(10);
                            var childrenRm3 = mapChildren(currentRoom);
                            bookingDetailModel.Room3ChildAge1 = childrenRm3[0];
                            bookingDetailModel.Room3ChildAge2 = childrenRm3[1];
                            bookingDetailModel.Room3ChildAge3 = childrenRm3[2];
                            bookingDetailModel.Room3ChildAge4 = childrenRm3[3];
                            break;
                        default:
                            break;
                    }
                }
                function mapChildren(room) {
                    var childrenMapped = [];
                    for (var i = 0; i < 4; i++) {
                        var childAge = room.ChildAges[i] ? room.ChildAges[i].toString(10) : "";
                        childrenMapped.push(childAge);
                    }
                    return childrenMapped;
                }
                return bookingDetailModel;
            };
            BookingApiService.prototype.generateGhaBookingDetailModel = function (searchDetail, travelDates) {
                var bookingDetail = new BookingDetailGha();
                bookingDetail.Country = searchDetail.Country;
                bookingDetail.City = searchDetail.City;
                bookingDetail.HotelBrand = searchDetail.Brand;
                bookingDetail.Hotel = searchDetail.Hotel;
                // format to ISO 8601, this needs to be understood by .NET
                var formattedStart = this.moment.utc(travelDates.ArrivalDate).hour(0).minute(0).second(0).millisecond(0).format('MM-DD-YYYY');
                var formattedEnd = this.moment.utc(travelDates.DepartureDate).hour(0).minute(0).second(0).millisecond(0).format('MM-DD-YYYY');
                bookingDetail.StartDate = formattedStart;
                bookingDetail.EndDate = formattedEnd;
                return bookingDetail;
            };
            return BookingApiService;
        }());
        BookingApiService.$inject = [
            "$http",
            "$log",
            "$q",
            "moment"
        ];
        Booker.NgModule.service("omni.bookingapiservice", BookingApiService);
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var Booker;
    (function (Booker) {
        var BookingDataResult = (function () {
            function BookingDataResult() {
                this.City = "";
                this.ItemIdGuid = "";
                this.ResultLabel = "";
                this.State = "";
                this.SubCategory = "";
                this.category = "";
                this.label = "";
                this.selected = false;
                this.IsComingSoonProperty = false;
                this.ComingSoonText = "";
                this.HotelLink = "";
                this.RedeemFreeNights = true;
                this.HotelCode = "";
                this.Region_City = "";
                this.IsVillas = false;
                this.IsGha = false;
            }
            return BookingDataResult;
        }());
        Booker.BookingDataResult = BookingDataResult;
        var ExplorePropertyNavigation = (function () {
            function ExplorePropertyNavigation() {
            }
            return ExplorePropertyNavigation;
        }());
        Booker.ExplorePropertyNavigation = ExplorePropertyNavigation;
        var ExplorePropertyResult = (function () {
            function ExplorePropertyResult() {
            }
            return ExplorePropertyResult;
        }());
        Booker.ExplorePropertyResult = ExplorePropertyResult;
        var BookerState = (function () {
            function BookerState(copy) {
                this.IsExpanded = copy ? copy.IsExpanded : false;
                this.IsEnabled = copy ? copy.IsEnabled : false;
                this.IsBrandPage = copy ? copy.IsBrandPage : false;
                this.IsPropertyPage = copy ? copy.IsPropertyPage : false;
                this.IsResortPage = copy ? copy.IsResortPage : false;
            }
            return BookerState;
        }());
        Booker.BookerState = BookerState;
        var BookingService = (function () {
            function BookingService($rootScope, $log, cacheFactory, moment, bookerConfig, dateConfig, $timeout) {
                this.$rootScope = $rootScope;
                this.$log = $log;
                this.cacheFactory = cacheFactory;
                this.moment = moment;
                this.bookerConfig = bookerConfig;
                this.dateConfig = dateConfig;
                this.$timeout = $timeout;
                this.initBookerDateConfig();
                this.initBookerState();
                this.initPageState();
                this.initBookerCache();
            }
            BookingService.prototype.GetCurrentDate = function () {
                return this.bookerConfig.CurrentDate;
            };
            BookingService.prototype.GetPropertyDetail = function () {
                var propertyDetail = new Booker.PropertyDetail();
                propertyDetail.HotelId = "";
                return propertyDetail;
            };
            BookingService.prototype.GetTravelDates = function () {
                var travelDates = new Booker.TravelDates();
                travelDates.ArrivalDate = this.moment.utc(this.bookerConfig.CurrentDate).hour(0).minute(0).second(0).millisecond(0);
                travelDates.DepartureDate = this.moment.utc(this.bookerConfig.CurrentDate).add(1, "days").hour(0).minute(0).second(0).millisecond(0);
                var cachedDates = this.bookingCache.get("travelDates");
                if (cachedDates) {
                    this.$log.debug("Using cached travel dates", cachedDates);
                    travelDates = cachedDates;
                }
                return travelDates;
            };
            BookingService.prototype.PutTravelDates = function (travelDates) {
                this.bookingCache.put("travelDates", travelDates);
            };
            BookingService.prototype.GetRoomDetails = function () {
                var defaultRoomDetail = new Booker.RoomDetail();
                defaultRoomDetail.RoomCount = 1;
                defaultRoomDetail.BedRoomCount = new Booker.BedroomOption();
                defaultRoomDetail.BedRoomCount.Count = 0;
                defaultRoomDetail.VillasView = new Booker.ViewOption();
                defaultRoomDetail.VillasView.Value = '';
                var defaultRoom = new Booker.Room();
                defaultRoom.AdultCount = 2;
                defaultRoom.ChildCount = 0;
                defaultRoomDetail.Rooms.push(defaultRoom);
                return defaultRoomDetail;
            };
            BookingService.prototype.GetRateCodes = function () {
                var rateCode = new Booker.RateCodes();
                rateCode.RateCode = "rpc_NONE";
                var cachedRates = this.bookingCache.get("rateCodes");
                if (cachedRates) {
                    this.$log.debug("Using cached rates", cachedRates);
                    rateCode = cachedRates;
                }
                return rateCode;
            };
            BookingService.prototype.PutRateCodes = function (rateCodes) {
                this.bookingCache.put("rateCodes", rateCodes);
            };
            BookingService.prototype.GetGlobalDetail = function () {
                var globalDetails = new Booker.GlobalBookerDetails();
                globalDetails.Brand = "-1";
                globalDetails.City = "-1";
                globalDetails.Hotel = "-1";
                globalDetails.Country = "-1";
                var cachedDetails = this.bookingCache.get("globalBookerDetails");
                if (cachedDetails) {
                    this.$log.debug("Using cached global details", cachedDetails);
                }
                return globalDetails;
            };
            BookingService.prototype.PutGlobalDetail = function (globalDetail) {
                this.bookingCache.put("globalBookerDetails", globalDetail);
            };
            BookingService.prototype.OpenBooker = function () {
                if (this.bookerConfig.ShowBookingWidget) {
                    this.bookerState.IsExpanded = true;
                    this.onUpdatedBookerState();
                    this.$timeout(function () {
                        var closeButton = angular.element("#closeButton");
                        closeButton.focus();
                    }, 0);
                    angular.element("#omni-booker #bookNowButton").attr("aria-expanded", "true");
                    angular.element("#findAndBookLineItem").attr("aria-expanded", "true");
                    angular.element("#bookNowLineItem").attr("aria-expanded", "true");
                }
            };
            BookingService.prototype.CloseBooker = function () {
                var bookerHasFocus = this.CheckBookerFocus();
                if (this.bookerConfig.ShowBookingWidget && bookerHasFocus) {
                    if (!this.bookerConfig.IsBookerAlwaysOpen) {
                        // configuration maintains booker can't be closed
                        if (this.bookerState.IsExpanded) {
                            this.bookerState.IsExpanded = false;
                            this.$timeout(function () {
                                var bookNowButton = angular.element("#omni-booker #bookNowButton");
                                bookNowButton.focus();
                            }, 0);
                            angular.element("#omni-booker #bookNowButton").attr("aria-expanded", "false");
                            angular.element("#findAndBookLineItem").attr("aria-expanded", "false");
                            angular.element("#bookNowLineItem").attr("aria-expanded", "false");
                        }
                        this.onUpdatedBookerState();
                    }
                }
            };
            BookingService.prototype.ToggleBooker = function () {
                if (this.bookerConfig.ShowBookingWidget) {
                    if (!this.bookerConfig.IsBookerAlwaysOpen) {
                        // configuration maintains booker can't be closed
                        this.bookerState.IsExpanded = !this.bookerState.IsExpanded;
                        if (this.bookerState.IsExpanded) {
                            this.$timeout(function () {
                                var closeButton = angular.element("#closeButton");
                                closeButton.focus();
                            }, 0);
                            angular.element("#bookNowButton").attr("aria-expanded", "true");
                        }
                        else {
                            angular.element("#bookNowButton").attr("aria-expanded", "false");
                        }
                        this.onUpdatedBookerState();
                    }
                }
            };
            BookingService.prototype.TabBooker = function (event) {
                var parentModal = angular.element('.om-booking-container');
                var focusableElementsInModal = parentModal.find(".bookerTabElement");
                var numberOfElements = focusableElementsInModal.length;
                var firstTabElement = focusableElementsInModal[0];
                var lastTabElement = focusableElementsInModal[numberOfElements - 1];
                if (event.keyCode === 9) {
                    if (document.activeElement === lastTabElement) {
                        event.preventDefault();
                        firstTabElement.focus();
                    }
                }
            };
            BookingService.prototype.CheckBookerFocus = function () {
                // if the item that has focus does not have the id of the input field, AND does not have a tabbookeritem class, then we can say that the booker does not have focus.
                var currentFocusedItem = angular.element(document.activeElement);
                var bookerHasFocus = false;
                if (currentFocusedItem.hasClass("bookerTabElement") ||
                    currentFocusedItem.attr("id") === "where-going" ||
                    currentFocusedItem.is('body')) {
                    bookerHasFocus = true;
                }
                else {
                    bookerHasFocus = false;
                }
                return bookerHasFocus;
            };
            BookingService.prototype.GetBookerState = function () {
                // Make a copy, do not allow access to modify the internal state
                return new BookerState(this.bookerState);
            };
            BookingService.prototype.initPageState = function () {
                // TODO: Move this outside of booker, it can be applied to any page (will require changes in input field renderings).
                this.$rootScope["isbrand"] = this.bookerConfig.IsBrandPage();
                this.$rootScope["ishotel"] = this.bookerConfig.IsHotelPage();
                this.$rootScope["isresort"] = this.bookerConfig.IsResortPage();
            };
            BookingService.prototype.initBookerState = function () {
                // Setup booker state from configurations from sitecore / backend
                this.bookerState = new BookerState();
                this.bookerState.IsExpanded = this.bookerConfig.ShowBookingWidget && (this.bookerConfig.IsBookerExpanded || this.bookerConfig.IsBookerAlwaysOpen);
                this.bookerState.IsEnabled = this.bookerConfig.ShowBookingWidget;
                this.bookerState.IsBrandPage = this.bookerConfig.IsBrandPage();
                this.bookerState.IsPropertyPage = this.bookerConfig.IsHotelPage() || this.bookerConfig.IsResortPage();
                this.bookerState.IsResortPage = this.bookerConfig.IsResortPage();
                this.onUpdatedBookerState();
            };
            BookingService.prototype.initBookerDateConfig = function () {
                if (this.dateConfig.MonthsLong.length > 0 &&
                    this.dateConfig.MonthsShort.length > 0 &&
                    this.dateConfig.WeekdaysLong.length > 0 &&
                    this.dateConfig.WeekdaysShort.length > 0) {
                    this.moment.defineLocale("en-foo", {
                        parentLocale: "en"
                    });
                    this.moment.updateLocale("en-foo", {
                        months: this.dateConfig.MonthsLong,
                        monthsShort: this.dateConfig.MonthsShort,
                        weekdays: this.dateConfig.WeekdaysLong,
                        weekdaysShort: this.dateConfig.WeekdaysShort
                    });
                }
            };
            BookingService.prototype.initBookerCache = function () {
                this.bookingCache = this.cacheFactory.get("bookingCache");
                // Create cache if it doesn't exist
                if (!this.bookingCache) {
                    this.bookingCache = this.cacheFactory("bookingCache", {
                        storageMode: "sessionStorage"
                    });
                }
            };
            BookingService.prototype.onUpdatedBookerState = function () {
                this.$rootScope["IsBookerEnabled"] = this.bookerState.IsEnabled;
                this.$rootScope["IsBookerExpanded"] = this.bookerState.IsExpanded;
                this.$rootScope.$broadcast("bookerStateUpdate");
            };
            return BookingService;
        }());
        BookingService.$inject = [
            "$rootScope",
            "$log",
            "CacheFactory",
            "moment",
            "bookerConfig",
            "dateConfig",
            "$timeout"
        ];
        Booker.NgModule.service("omni.bookingservice", BookingService);
    })(Booker = Omni.Booker || (Omni.Booker = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule = angular.module("omni.resortmap", [
            "omniViews"
        ]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.controller('MainController', ['DataService', 'ResortProvider', '$scope', '$state', '$stateParams',
            function (DataService, ResortProvider, $scope, $state, $stateParams) {
                $scope.resort = null;
                DataService.get({}, function (data) {
                    $scope.resort = data;
                    $scope.isResort = data.is_resort;
                    ResortProvider.setResort(data);
                    if ($scope.isResort) {
                        $state.go('resort');
                    }
                    else {
                        $state.go('floor', { id: 0 });
                    }
                });
            }
        ]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.controller('ResortController', ['$scope', '$state', '$stateParams', 'ResortProvider',
            function ($scope, $state, $stateParams, ResortProvider) {
                $scope.showPopover = false;
                $scope.popover = {};
                $scope.resort = ResortProvider.getResort();
                $scope.zoomButton = false;
                $scope.filterResortData = function () {
                    angular.forEach($scope.resort.location, function (value, key) {
                        value.posn = key + 1;
                        value.e = key;
                    });
                };
                $scope.closePopover = function () {
                    $scope.$emit("closePopover");
                };
                $scope.changeState = function (st, num) {
                    $state.go(st, { id: num });
                };
                $scope.filterResortData();
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.controller('RoomController', ['ResortProvider', '$scope', '$state', '$stateParams', '$timeout',
            function (ResortProvider, $scope, $state, $stateParams, $timeout) {
                $scope.location = ResortProvider.getLocation($stateParams.id);
                $scope.showBackButton = true;
                $scope.floor = $scope.location.floor[$stateParams.floorId];
                $scope.room = null;
                angular.forEach($scope.floor.room, function (value, index) {
                    if (index == $stateParams.roomId) {
                        $scope.room = value;
                    }
                });
                $scope.partialIndex = 0;
                $scope.partials = $scope.room.partial;
                $scope.partial = $scope.partials[$scope.partialIndex];
                $scope.layouts = $scope.partial.layout;
                $scope.showPartialSelector = function () {
                    return $scope.partials.length > 1;
                };
                $scope.roomVideoToggle = function () {
                    if ($state.current.name !== 'room.video') {
                        $state.go('room.video');
                    }
                    else {
                        $state.go('room');
                    }
                };
            }
        ]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
            function ($stateProvider, $urlRouterProvider, $locationProvider) {
                $stateProvider
                    .state('resort', {
                    templateUrl: "omni/assets/resortmap/views/resort.tpl.html",
                    controller: "ResortController"
                })
                    .state('location', {
                    abstract: true,
                    params: {
                        "id": ""
                    },
                    resolve: {
                        "location": ["ResortProvider", "$stateParams", function (ResortProvider, $stateParams) {
                                return ResortProvider.getLocation($stateParams.id);
                            }]
                    },
                    templateUrl: "omni/assets/resortmap/views/location.tpl.html",
                    //controller: function() {},
                    controller: ["$rootScope", "$state", "$scope", "$stateParams", "location", function ($rootScope, $state, $scope, $stateParams, location) {
                            $scope.location = location;
                            $scope.baseState = (location.type !== 'undefined' && location.type == 'leisure') ? 'leisure' : 'floor';
                            if ($scope.$parent.isResort) {
                                $scope.showBackButton = true;
                                $scope.h1Class = "withBackButton";
                            }
                            else {
                                $scope.showBackButton = false;
                                $scope.h1Class = "";
                            }
                            $scope.backButton = function () {
                                if ($scope.baseState == 'floor') {
                                    $rootScope["activeTab"] = 'meeting';
                                }
                                else {
                                    $rootScope["activeTab"] = 'leisure';
                                }
                                $state.go('resort');
                            };
                            $scope.videoToggle = function () {
                                if ($state.current.name !== 'video') {
                                    $state.go('video');
                                }
                                else {
                                    $state.go($scope.baseState);
                                }
                            };
                            $scope.showFloorRoomSelector = function () {
                                return $state.current.name === 'floor.detail';
                            };
                        }]
                })
                    .state('video', {
                    parent: "location",
                    views: {
                        "main": {
                            templateUrl: "omni/assets/resortmap/views/video.tpl.html",
                            controller: ["$scope", "$sce", function ($scope, $sce) {
                                    $scope.video_url = null;
                                }]
                        }
                    }
                })
                    .state('leisure', {
                    parent: "location",
                    views: {
                        "main": {
                            templateUrl: 'omni/assets/resortmap/views/slideshow.tpl.html',
                            controller: ["$scope", "$stateParams", function ($scope, $stateParams) {
                                    $scope.slides = $scope.location.gallery;
                                    $scope.showSlideNav = function () {
                                        return $scope.slides.length > 1;
                                    };
                                }]
                        }
                    }
                })
                    .state('meeting', {
                    parent: "location",
                    views: {
                        "main": {
                            templateUrl: "omni/assets/resortmap/views/meeting.tpl.html"
                        }
                    }
                })
                    .state('gallery', {
                    parent: "meeting",
                    views: {
                        "meetingMain": {
                            templateUrl: "omni/assets/resortmap/views/slideshow.tpl.html",
                            controller: ["$scope", function ($scope) {
                                    $scope.slides = $scope.location.gallery;
                                    $scope.showSlideNav = function () {
                                        return $scope.slides.length > 1;
                                    };
                                }]
                        }
                    }
                })
                    .state('floor', {
                    parent: "meeting",
                    params: {
                        "id": ""
                    },
                    resolve: {
                        "location": ["ResortProvider", "$stateParams", function (ResortProvider, $stateParams) {
                                return ResortProvider.getLocation($stateParams.id);
                            }]
                    },
                    views: {
                        'meetingMain': {
                            templateUrl: "omni/assets/resortmap/views/floor.tpl.html",
                            controller: ["$scope", "$state", "$stateParams", "location", function ($scope, $state, $stateParams, location) {
                                    $scope.floors = location.floor;
                                    $scope.showBackButton = true;
                                    if (location.floor.length > 1) {
                                        $scope.showFloorSelector = true;
                                    }
                                    else {
                                        $scope.showFloorSelector = false;
                                    }
                                    $state.go('floor.detail', { id: $stateParams.id, floorId: 0 });
                                }]
                        }
                    }
                })
                    .state("floor.detail", {
                    params: {
                        "id": "",
                        "floorId": ""
                    },
                    parent: "floor",
                    resolve: {
                        "location": ["ResortProvider", "$stateParams", function (ResortProvider, $stateParams) {
                                return ResortProvider.getLocation($stateParams.id);
                            }]
                    },
                    views: {
                        'floorContainer': {
                            templateUrl: "omni/assets/resortmap/views/floorContainer.tpl.html",
                            controller: ["$scope", "$state", "$stateParams", "$timeout", "location", function ($scope, $state, $stateParams, $timeout, location) {
                                    var id = $stateParams.floorId || 0;
                                    $scope.showBackButton = true;
                                    $scope.location = location;
                                    $scope.floor = location.floor[id];
                                    $scope.rooms = $scope.floor.room;
                                    $scope.showPopover = false;
                                    $scope.popover = null;
                                    $scope.floorIndex = $stateParams.floorId;
                                    $scope.closePopover = function () {
                                        $scope.$emit("closePopover");
                                    };
                                }]
                        }
                    }
                })
                    .state('room', {
                    params: {
                        'id': "",
                        'floorId': "",
                        'roomId': ""
                    },
                    parent: 'floor.detail',
                    views: {
                        "@": {
                            templateUrl: "omni/assets/resortmap/views/room.tpl.html",
                            controller: "RoomController"
                        }
                    }
                })
                    .state('room.video', {
                    parent: "room",
                    views: {
                        "roomMain": {
                            templateUrl: "omni/assets/resortmap/views/video.tpl.html",
                            controller: ["$scope", function ($scope) {
                                    $scope.showBackButton = true;
                                }]
                        }
                    }
                });
                $locationProvider.html5Mode({
                    enabled: false,
                    requireBase: false
                });
                $locationProvider.hashPrefix('');
            }])
            .run(['$rootScope', '$state', '$stateParams',
            function ($rootScope, $state, $stateParams) {
                $rootScope["$state"] = $state;
                $rootScope["$stateParams"] = $stateParams;
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('floorCanvas', (['$rootScope', '$stateParams', '$state', "Kinetic",
            function ($rootScope, $stateParams, $state, Kinetic) {
                function createShape(x, y, shape, id) {
                    var r = 10;
                    var el;
                    var name = 'Marker ' + (id + 1);
                    var shapeId = "shape" + id;
                    el = new Kinetic.Circle({
                        x: x,
                        y: y,
                        radius: r,
                        name: name,
                        id: shapeId,
                        fill: '#d55628',
                        stroke: '#b14822',
                        strokeWidth: 1
                    });
                    return el;
                }
                function createMarkerGroup(point, i, xRatio, yRatio) {
                    var x = (point.x_coord / 2) * xRatio;
                    var y = (point.y_coord / 2) * yRatio;
                    var shape = "default";
                    var kids = new Kinetic.Group({
                        id: "group" + i,
                        index: i
                    });
                    var floorMapMarker = createShape(x, y, shape, i);
                    kids.add(floorMapMarker);
                    return kids;
                }
                function buildPopover(loc, x, y, el) {
                    var width = jQuery("#mapContainer").width();
                    var height = jQuery("#mapContainer").height();
                    var popover = {};
                    var v, h;
                    if (y > height / 2) {
                        popover.top = y - 168;
                        v = "top";
                    }
                    else {
                        popover.top = y + 10;
                        v = "bottom";
                    }
                    if (x > width / 2) {
                        h = "l";
                        popover.left = x - 212;
                    }
                    else {
                        h = "r";
                        popover.left = x - 20;
                    }
                    jQuery("#popoverElement").css({
                        top: popover.top,
                        left: popover.left
                    });
                    popover.placement = v + ' ' + h;
                    popover.type = 'floor';
                    popover.title = loc.title;
                    popover.area = loc.area;
                    popover.capacity = loc.capacity;
                    popover.l = loc.length;
                    popover.w = loc.width;
                    if ((loc.length != null && loc.length != 0) && (loc.width != null && loc.width != 0)) {
                        popover.dimensions = loc.length + "' x " + loc.width + "'";
                    }
                    else {
                        popover.dimensions = "NA";
                    }
                    popover.ceiling = loc.ceiling;
                    popover.el = el;
                    return popover;
                }
                return {
                    restrict: "E",
                    priority: 1001,
                    template: '<div id="floorMapCanvas" style="background: url(\'{{ floor_img }}\') no-repeat top left;background-size:contain;"></div>',
                    replace: true,
                    link: function (scope, element, attrs) {
                        var imageObj = new Image();
                        imageObj.src = attrs.src;
                        scope.floor_img = attrs.src;
                        // jQuery("#floorMapCanvas").css("background", "no-repeat top left").css("backgroundImage", scope.floor_img);
                        var mainContainer = jQuery("#mainMapContainer");
                        var containerWidth = mainContainer.width() * (3 / 4);
                        jQuery("#floorMapCanvas").width(containerWidth);
                        var containerHeight = containerWidth * 430 / 692;
                        jQuery("#floorMapCanvas").height(containerHeight);
                        jQuery("#mainMapContainer").height((containerHeight + 2));
                        var xRatio = containerWidth / 692;
                        var yRatio = containerHeight / 430;
                        var floorMap = {
                            canvasId: element.attr('id'),
                            stage: null,
                            layer: null,
                            points: null,
                            popover: null,
                            initialize: function () {
                                floorMap.points = scope.floor.room;
                                floorMap.stage = new Kinetic.Stage({
                                    container: floorMap.canvasId,
                                    width: containerWidth,
                                    height: containerHeight
                                });
                                var floor = new Kinetic.Image({
                                    x: 0,
                                    y: 0,
                                    image: imageObj,
                                    width: containerWidth,
                                    height: containerHeight
                                });
                                floorMap.layer = new Kinetic.Layer();
                                // floorMap.layer.add(floor);
                                for (var i = 0; i < floorMap.points.length; i++) {
                                    var kids = createMarkerGroup(floorMap.points[i], i, xRatio, yRatio);
                                    // add handler to fire tweening function
                                    kids.on("tap", function (e) {
                                        var target = (angular.isUndefined(e.target.parent)) ?
                                            e.target : e.target.parent.attrs.index;
                                        floorMap.showPopover(target);
                                    });
                                    kids.on("click", function (e) {
                                        var target = (angular.isUndefined(e.target.parent)) ?
                                            e.target : e.target.parent.attrs.index;
                                        floorMap.showPopover(target);
                                    });
                                    floorMap.layer.add(kids);
                                }
                                floorMap.stage.add(floorMap.layer);
                                floorMap.stage.on("click", function (evt) {
                                    // console.log(evt);
                                });
                                jQuery("#roomPopoverSelect").empty().append('<option value="-1">Select Room</option>');
                                angular.forEach(scope.floor.room, function (el, index) {
                                    var option = '<option value="' + index + '">' + el.name + '</option>';
                                    jQuery("#roomPopoverSelect").append(option);
                                    option = "";
                                });
                                jQuery("#roomPopoverSelect").off();
                                jQuery("#roomPopoverSelect").on("change", function (e) {
                                    var i = this.value;
                                    floorMap.showPopover(i);
                                });
                            },
                            showPopover: function (target, i) {
                                var floor = scope.location.floor[$stateParams["floorId"]];
                                if (target == -1) {
                                    scope.showPopover = false;
                                    scope.$apply();
                                    return;
                                }
                                var groupName = "#group" + (target);
                                var shape = floorMap.stage.find(groupName);
                                var coordx = shape[0].children[0].attrs.x;
                                var coordy = shape[0].children[0].attrs.y;
                                var loc = null;
                                loc = floor.room[target];
                                scope.showPopover = false;
                                scope.popover = buildPopover(loc, (coordx), (coordy), target);
                                scope.showPopover = true;
                                loc = null;
                                scope.$apply();
                            }
                        };
                        imageObj.onload = function () {
                            scope.$apply(floorMap.initialize());
                            $rootScope.$on("closePopover", function () {
                                scope.showPopover = false;
                            });
                        };
                    }
                };
            }]));
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('floorSelect', (['$document', '$state',
            function ($document, $state) {
                return {
                    restrict: 'C',
                    link: function (scope, element, attrs) {
                        var floor;
                        element.on("change", function (e) {
                            floor = e.target.value;
                            $state.go("floor.detail", { floorId: floor });
                        });
                    }
                };
            }]));
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        (function (window, $j) {
            ResortMap.ngModule.directive('resortMapCanvas', (['$rootScope', '$timeout', '$window', '$location', '$state', "Kinetic",
                function ($rootScope, $timeout, $window, $location, $state, Kinetic) {
                    function scaleImage(source, scaleFactor) {
                        var canvas = document.createElement("canvas");
                        var ctx = canvas.getContext("2d");
                        canvas.width = source.width * scaleFactor;
                        canvas.height = source.height * scaleFactor;
                        ctx.drawImage(source, 0, 0, source.width * scaleFactor, source.height * scaleFactor);
                        sharpen(ctx, canvas.width, canvas.height, 0.35);
                        return (canvas);
                    }
                    function sharpen(ctx, w, h, mix) {
                        var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0], katet = Math.round(Math.sqrt(weights.length)), half = (katet * 0.5) | 0, dstData = ctx.createImageData(w, h), dstBuff = dstData.data, srcBuff = ctx.getImageData(0, 0, w, h).data, y = h;
                        var x;
                        while (y--) {
                            x = w;
                            while (x--) {
                                var sy = y, sx = x, dstOff = (y * w + x) * 4, r = 0, g = 0, b = 0, a = 0;
                                for (var cy = 0; cy < katet; cy++) {
                                    for (var cx = 0; cx < katet; cx++) {
                                        var scy = sy + cy - half;
                                        var scx = sx + cx - half;
                                        if (scy >= 0 && scy < h && scx >= 0 && scx < w) {
                                            var srcOff = (scy * w + scx) * 4;
                                            var wt = weights[cy * katet + cx];
                                            r += srcBuff[srcOff] * wt;
                                            g += srcBuff[srcOff + 1] * wt;
                                            b += srcBuff[srcOff + 2] * wt;
                                            a += srcBuff[srcOff + 3] * wt;
                                        }
                                    }
                                }
                                dstBuff[dstOff] = r * mix + srcBuff[dstOff] * (1 - mix);
                                dstBuff[dstOff + 1] = g * mix + srcBuff[dstOff + 1] * (1 - mix);
                                dstBuff[dstOff + 2] = b * mix + srcBuff[dstOff + 2] * (1 - mix);
                                dstBuff[dstOff + 3] = srcBuff[dstOff + 3];
                            }
                        }
                        ctx.putImageData(dstData, 0, 0);
                    }
                    function createShape(x, y, shape, id) {
                        var r = 10;
                        var el;
                        var name = 'Marker ' + id;
                        var shapeId = "shape" + id;
                        switch (shape) {
                            case "top-left":
                                var sx = x;
                                var sy = y - r;
                                var ex = x - r;
                                var ey = y;
                                var ax = x - r;
                                var ay = y - r;
                                var startPoint = "M" + sx + "," + sy;
                                var curve = "A" + r + "," + r + ",0,1,1," + ex + "," + ey;
                                var point = "L" + ax + "," + ay + "Z";
                                var path = startPoint + curve + point;
                                el = new Kinetic.Path({
                                    data: path
                                });
                                break;
                            case "top-right":
                                var sx = x;
                                var sy = y - r;
                                var ex = x + r;
                                var ey = y;
                                var ax = x + r;
                                var ay = y - r;
                                var startPoint = "M" + sx + "," + sy;
                                var curve = "A" + r + "," + r + ",0,1,0," + ex + "," + ey;
                                var point = "L" + ax + "," + ay + "Z";
                                var path = startPoint + curve + point;
                                el = new Kinetic.Path({
                                    data: path
                                });
                                break;
                            case "bottom-left":
                                var sx = x - r;
                                var sy = y;
                                var ex = x;
                                var ey = y + r;
                                var ax = x - r;
                                var ay = y + r;
                                var startPoint = "M" + sx + "," + sy;
                                var curve = "A" + r + "," + r + ",0,1,1," + ex + "," + ey;
                                var point = "L" + ax + "," + ay + "Z";
                                var path = startPoint + curve + point;
                                el = new Kinetic.Path({
                                    data: path
                                });
                                break;
                            case "bottom-right":
                                var sx = x + r;
                                var sy = y;
                                var ex = x;
                                var ey = y + r;
                                var ax = x + r;
                                var ay = y + r;
                                var startPoint = "M" + sx + "," + sy;
                                var curve = "A" + r + "," + r + ",0,1,0," + ex + "," + ey;
                                var point = "L" + ax + "," + ay + "Z";
                                var path = startPoint + curve + point;
                                el = new Kinetic.Path({
                                    data: path
                                });
                                break;
                            default:
                                el = new Kinetic.Circle({
                                    x: x,
                                    y: y,
                                    radius: r
                                });
                                break;
                        }
                        el.name(name);
                        el.id(shapeId);
                        el.fill('#F07230');
                        el.stroke('#b14822');
                        el.strokeWidth(1);
                        el.opacity(1);
                        return el;
                    }
                    function createTextLabel(x, y, posn) {
                        var simpleText = new Kinetic.Text({
                            x: x,
                            y: y,
                            text: posn,
                            fontSize: 12,
                            fontStyle: 'italic',
                            fontFamily: 'Calibri',
                            fill: '#ffffff',
                            opacity: 1
                        });
                        simpleText.offsetX(simpleText.width() / 2);
                        simpleText.offsetY(simpleText.height() / 2);
                        return simpleText;
                    }
                    function createMarkerGroup(point, z, xRatio, yRatio) {
                        var x = (point.x_coord / 2) * xRatio;
                        var y = (point.y_coord / 2) * yRatio;
                        var shape = point.marker_type;
                        var i = point.id;
                        var kids = new Kinetic.Group({
                            id: "group" + i,
                            index: i
                        });
                        var mapMarker = createShape(x, y, shape, i);
                        var label = createTextLabel(x, y, point.posn);
                        kids.add(mapMarker);
                        kids.add(label);
                        return kids;
                    }
                    function buildPopover(loc, x, y, el) {
                        var width = $j("#mapContainer").width();
                        var height = $j("#mapContainer").height();
                        var popover = {};
                        var v, h;
                        if (y > height / 2) {
                            if (loc.type == "meeting") {
                                var disp = 145;
                            }
                            else {
                                var disp = 100;
                            }
                            if (loc.title.length > 22) {
                                disp = disp + 20;
                            }
                            popover.top = y - disp;
                            v = "top";
                        }
                        else {
                            popover.top = y + 20;
                            v = "bottom";
                        }
                        if (x > width / 2) {
                            h = "l";
                            popover.left = x - 211;
                        }
                        else {
                            h = "r";
                            popover.left = x - 20;
                        }
                        $j("#popoverElement").css({
                            top: popover.top,
                            left: popover.left
                        });
                        popover.placement = v + ' ' + h;
                        popover.title = loc.title;
                        popover.type = loc.type;
                        popover.el = el;
                        return popover;
                    }
                    function setActiveTabItem(el) {
                        // get the type and click the tab
                        var type = el.type;
                        if (type == "leisure") {
                            $j("#tabs a:first").tab("show");
                        }
                        else {
                            $j("#tabs a:last").tab("show");
                        }
                        // then click the item
                        var li = $j(".locationList").find("[data-list-item='" + el.id + "']");
                        li.addClass("active");
                    }
                    function buildTabPane(el) {
                        var html = "";
                        html += "<li class=\"listItem\" data-list-item=\"" + el.id + "\">";
                        html += "<img src=\"" + el.thumbnail + "\" class=\"locationThumb\" />";
                        html += "<span class=\"badge\">" + el.posn + "</span>";
                        html += "<h4>" + el.title + "</h4>";
                        html += "</li>";
                        return html;
                    }
                    function buildSideBar(data) {
                        var html = '';
                        html += "<ul id=\"tabs\" class=\"nav nav-tabs nav-justified\">";
                        html += "<li class=\"active\"><a class=\"tab-toggle\" data-target=\"#leisure\" data-toggle=\"tab\">Leisure</a></li>";
                        html += "<li><a class=\"tab-toggle\" data-target=\"#meeting\" data-toggle=\"tab\">Meeting</a></li>";
                        html += "</ul>";
                        html += "<div class=\"tab-content\">";
                        var leisureHtml = "";
                        var meetingHtml = "";
                        angular.forEach(data, function (el, index) {
                            if (el.type == "leisure") {
                                leisureHtml += buildTabPane(el);
                            }
                            else {
                                meetingHtml += buildTabPane(el);
                            }
                        });
                        html += "<div class=\"tab-pane active\" id=\"leisure\">";
                        html += "<ul class=\"locationList\">" + leisureHtml + "</ul>";
                        html += "</div>";
                        html += "<div class=\"tab-pane\" id=\"meeting\">";
                        html += "<ul class=\"locationList\">" + meetingHtml + "</ul>";
                        html += "</div>";
                        html += "</div>";
                        return html;
                    }
                    function scrollList() {
                        var listContainer = $j(".tab-pane.active");
                        var activeListItem = $j(".tab-pane.active ul.locationList li.listItem.active");
                        var distance = listContainer.scrollTop() +
                            (activeListItem.position().top - listContainer.position().top)
                            - (listContainer.height() / 2) + (activeListItem.height() / 2);
                        listContainer.animate({ scrollTop: distance }, 500, 'swing');
                    }
                    return {
                        restrict: "EA",
                        priority: 1001,
                        replace: true,
                        link: function (scope, element, attrs) {
                            // Build Sidebar List
                            var sidebar = element.find("#mapSidebar");
                            var locations = scope.resort.location;
                            var sideBarHtml = buildSideBar(locations);
                            sidebar.html(sideBarHtml);
                            var regex = new RegExp("[\\?&]m=([^&#]*)"), results = regex.exec(location.search);
                            if ((results !== null && results[1] == 1) || $rootScope["activeTab"] == 'meeting' || $j("#topNavLink").text().trim().toLowerCase() == "meetings") {
                                $j("#tabs a:last").tab("show");
                            }
                            var mainContainer = $j("#mainMapContainer");
                            var containerWidth = mainContainer.width() * (3 / 4);
                            $j("#mapContainer").width(containerWidth);
                            var containerHeight = containerWidth * 430 / 692;
                            $j("#mapContainer").height(containerHeight);
                            $j("#mainMapContainer").height((containerHeight + 1));
                            var xRatio = containerWidth / 692;
                            var yRatio = containerHeight / 430;
                            var map = {
                                parentGroup: null,
                                mapImages: null,
                                canvasId: "mapCanvas",
                                points: locations,
                                fromListClick: false,
                                stage: null,
                                layer: null,
                                popover: null,
                                scale: 1,
                                activeItem: null,
                                targetItem: null,
                                initialize: function (c2) {
                                    map.stage = new Kinetic.Stage({
                                        container: map.canvasId,
                                        width: containerWidth,
                                        height: containerHeight
                                    });
                                    map.layer = new Kinetic.Layer();
                                    map.parentGroup = new Kinetic.Group();
                                    map.mapImages = new Kinetic.Group();
                                    var smResort = new Kinetic.Image({
                                        x: 0,
                                        y: 0,
                                        image: c2,
                                        width: Math.round(containerWidth),
                                        height: Math.round(containerHeight),
                                        listening: true,
                                        name: "smallMap"
                                    });
                                    smResort.on('zoomIn', function (evt) {
                                        smResort.opacity(0);
                                        lgResort.opacity(1);
                                    });
                                    var lgResort = new Kinetic.Image({
                                        x: 0,
                                        y: 0,
                                        image: lgImageObj,
                                        width: Math.round(containerWidth),
                                        height: Math.round(containerHeight),
                                        listening: true,
                                        name: "largeMap"
                                    });
                                    lgResort.on('zoomOut', function (evt) {
                                        lgResort.opacity(0);
                                        smResort.opacity(1);
                                    });
                                    // add the shape to the layer
                                    map.mapImages.add(lgResort);
                                    map.mapImages.add(smResort);
                                    map.parentGroup.add(map.mapImages);
                                    // iterate over points to build marker groups
                                    for (var i = 0; i < map.points.length; i++) {
                                        // build marker layer - shape, shadow, and text
                                        var kids = createMarkerGroup(map.points[i], i, xRatio, yRatio);
                                        // add handler to fire tweening function
                                        kids.on("tap", function (e) {
                                            var target = (angular.isUndefined(e.target.parent)) ?
                                                e.target : e.target.parent.attrs.index;
                                            $j(".listItem").removeClass("active");
                                            scope.showPopover = false;
                                            scope.$apply();
                                            map.playTween(target);
                                        });
                                        kids.on("click", function (e) {
                                            var target = (angular.isUndefined(e.target.parent)) ?
                                                e.target : e.target.parent.attrs.index;
                                            $j(".listItem").removeClass("active");
                                            scope.showPopover = false;
                                            scope.$apply();
                                            map.playTween(target);
                                        });
                                        map.parentGroup.add(kids);
                                    }
                                    map.layer.add(map.parentGroup);
                                    map.stage.add(map.layer);
                                },
                                apply: function () {
                                    try {
                                        scope.$apply();
                                    }
                                    catch (e) { }
                                },
                                playTween: function (target) {
                                    var groupName = "#group" + (target);
                                    var shape = map.stage.find(groupName);
                                    // using the text group for the x/y coords as the shape objects don't have those attrs.
                                    var coordx = shape[0].children[1].attrs.x;
                                    var coordy = shape[0].children[1].attrs.y;
                                    scope.showPopover = false;
                                    if (map.scale == 1) {
                                        map.panZoom(target, coordx, coordy);
                                    }
                                    else if (map.scale == 2 && scope.activeItem !== target) {
                                        map.pan(target, coordx, coordy);
                                    }
                                    else if (map.scale == 2 && scope.activeItem == target) {
                                        map.scale = 1;
                                        map.resetStage();
                                    }
                                },
                                panZoom: function (el, x, y) {
                                    var panZoomDef = {
                                        node: map.parentGroup,
                                        scaleX: 2,
                                        scaleY: 2,
                                        x: -x,
                                        y: -y,
                                        easing: Kinetic.Easings.EaseInOut,
                                        duration: 0.6,
                                        onFinish: function () {
                                            var loc = $j.grep(locations, function (e) { return e.id == el; });
                                            map.popover = buildPopover(loc[0], x, y, el);
                                            map.finishTween(2, el, true);
                                        }
                                    };
                                    var anim = new Kinetic.Tween(panZoomDef);
                                    anim.tween.play();
                                },
                                pan: function (el, x, y) {
                                    var pan = {
                                        node: map.parentGroup,
                                        x: -x,
                                        y: -y,
                                        easing: Kinetic.Easings.EaseInOut,
                                        duration: 0.6,
                                        onFinish: function () {
                                            var loc = $j.grep(locations, function (e) { return e.id == el; });
                                            map.popover = buildPopover(loc[0], x, y, el);
                                            map.finishTween(2, el, true);
                                        }
                                    };
                                    var anim = new Kinetic.Tween(pan);
                                    anim.tween.play();
                                },
                                resetStage: function () {
                                    var reset = {
                                        node: map.parentGroup,
                                        x: 0,
                                        y: 0,
                                        scaleX: 1,
                                        scaleY: 1,
                                        easing: Kinetic.Easings.EaseInOut,
                                        duration: 0.6,
                                        onFinish: function () {
                                            map.finishTween(1, null, false);
                                        }
                                    };
                                    var anim = new Kinetic.Tween(reset);
                                    anim.tween.play();
                                },
                                finishTween: function (scale, activeItem, showPopover) {
                                    if (scale == 2) {
                                        scope.zoomButton = true;
                                        var img = map.stage.find(".smallMap");
                                        img.fire('zoomIn');
                                    }
                                    else {
                                        scope.zoomButton = false;
                                        var img = map.stage.find(".largeMap");
                                        img.fire('zoomOut');
                                    }
                                    map.scale = scale;
                                    map.activeItem = activeItem;
                                    scope.popover = map.popover;
                                    scope.showPopover = showPopover;
                                    if (activeItem !== null) {
                                        var item = $j.grep(locations, function (e) { return e.id == activeItem; });
                                        setActiveTabItem(item[0]);
                                        scrollList();
                                    }
                                    map.apply();
                                }
                            };
                            var lgImageObj = new Image();
                            lgImageObj.src = scope.resort.map_img;
                            var smImageObj = new Image();
                            smImageObj.src = lgImageObj.src;
                            smImageObj.onload = function () {
                                var step1, step2;
                                step1 = (3 / 4);
                                step2 = (2 / 3);
                                // var c1 = scaleImage(smImageObj, step1);
                                var c2 = scaleImage(smImageObj, step2);
                                map.initialize(c2);
                                // Listen for list-item click
                                $j(".listItem").on("click", function (e) {
                                    if ($j(this).hasClass("active")) {
                                        $j(this).toggleClass("active");
                                        scope.showPopover = false;
                                        map.resetStage();
                                        scope.$apply();
                                    }
                                    else {
                                        $j(".listItem").removeClass("active");
                                        scope.showPopover = false;
                                        scope.$apply();
                                        $j(this).addClass("active");
                                        scrollList();
                                        var id = $j(this).data("list-item");
                                        map.playTween(id);
                                    }
                                });
                                $rootScope.$on("closePopover", function () {
                                    scope.showPopover = false;
                                    scope.zoomButton = false;
                                    $j(".listItem").removeClass("active");
                                    map.fromListClick = false;
                                    map.resetStage();
                                });
                                $rootScope.$on("resetStage", function () {
                                    scope.showPopover = false;
                                    map.fromListClick = false;
                                    map.resetStage();
                                });
                            };
                        }
                    };
                }]));
        })(window, window['$j']);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.filter('naFilter', function () {
            return function (input) {
                if (input == 0) {
                    return "NA";
                }
                else {
                    return input;
                }
            };
        })
            .filter('ftFilter', function () {
            return function (input) {
                if (!isNaN(input) && input !== 0) {
                    return input + "'";
                }
                else {
                    return input;
                }
            };
        });
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('partialSlideshow', ['$document',
            function ($document) {
                return {
                    restrict: 'A',
                    priority: 1001,
                    link: function (scope, element, attrs) {
                    }
                };
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('mapPopover', [function () {
                return {
                    restrict: 'EAC',
                    templateUrl: 'omni/assets/resortmap/views/popover.tpl.html'
                };
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('roomLayout', (['$document',
            function ($document) {
                return {
                    restrict: 'EA',
                    link: function (scope, element, attrs) {
                        function getOffset(index, length) {
                            if (length > 5) {
                                var left, right;
                                left = 2;
                                right = length - 3;
                                // index is on the far left
                                if (index <= left) {
                                    return 0;
                                    // index is on the far right
                                }
                                else if (index >= right) {
                                    return (right - 2);
                                    // index is somewhere in the middle
                                }
                                else {
                                    return (index - 2);
                                }
                            }
                        }
                        var partials = scope.partials;
                        var s, a, c, p;
                        var part = 0;
                        var layouts = partials[part];
                        scope._Index = 0;
                        s = $document.find("#partialSelect");
                        a = $document.find("#area");
                        c = $document.find("#ceiling");
                        p = $document.find("#capacity");
                        var body = $document.find("body");
                        var bodyWidth = body.width();
                        var offsetLength = 80;
                        if (bodyWidth >= 1200) {
                            offsetLength = 117;
                        }
                        else if (bodyWidth < 1200 && bodyWidth >= 992) {
                            offsetLength = 92;
                        }
                        else if (bodyWidth < 992 && bodyWidth >= 768) {
                            offsetLength = 83;
                        }
                        s.on("change", function (e) {
                            part = e.target.value;
                            scope.layouts = partials[part].layout;
                            a.html(partials[part].area);
                            c.html(scope.room.ceiling);
                            p.html(partials[part].capacity);
                            scope._Index = 0;
                            scope.length = scope.layouts.length;
                            scope.$digest();
                        });
                        scope.length = scope.layouts.length;
                        scope.$watch('_Index', function () {
                            var offset = getOffset(scope._Index, scope.length);
                            jQuery("#layoutNav").animate({
                                left: -(offset * offsetLength)
                            });
                        });
                        scope.isActive = function (index) {
                            return scope._Index === index;
                        };
                        scope.showPrev = function () {
                            var oldIndex = angular.copy(scope._Index);
                            scope._Index = (scope._Index > 0) ? --scope._Index : scope.length - 1;
                        };
                        scope.showNext = function () {
                            var oldIndex = angular.copy(scope._Index);
                            scope._Index = (scope._Index < scope.length - 1) ? ++scope._Index : 0;
                        };
                        scope.showPhoto = function (index) {
                            var oldIndex = angular.copy(scope._Index);
                            scope._Index = index;
                        };
                        scope.setWidth = function (len) {
                            return len > 5;
                        };
                    }
                };
            }]));
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.factory('DataService', ['$resource', "$window", function ($resource, $window) {
                return $resource($window.endpointUrl);
            }])
            .factory('_', ["$window", function ($window) {
                return $window._;
            }])
            .factory('Kinetic', ["$window", function ($window) {
                return $window.Kinetic;
            }])
            .factory('ResortProvider', ['_', function (_) {
                var resort, location, floor, room;
                var provider = {
                    setResort: function (data) {
                        resort = data;
                    },
                    getResort: function () {
                        return resort;
                    },
                    getLocation: function (i) {
                        if (resort.is_resort) {
                            angular.forEach(resort.location, function (value, index) {
                                if (value.id == i) {
                                    location = value;
                                }
                            });
                        }
                        else {
                            location = resort.location[0];
                        }
                        return location;
                    },
                    getFloor: function (id) {
                        angular.forEach(location.floor, function (value, index) {
                            if (value.id == id) {
                                floor = value;
                            }
                        });
                        return floor;
                    },
                    getRoom: function (id) {
                        angular.forEach(floor.room, function (value, index) {
                            if (value.id == id) {
                                room = value;
                            }
                        });
                        return room;
                    }
                };
                return provider;
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('sidebar', ([
            function () {
                return {
                    restrict: 'C',
                    link: function (scope, element, attrs) {
                        var body = element.find(".body");
                        if (body.height > 290) {
                            body.css({ overflowY: "scroll" });
                        }
                    }
                };
            }
        ]));
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('cycleSlideshow', (['$state', function ($state) {
                return {
                    restrict: 'C',
                    link: function (scope, element, attrs) {
                        var slides = scope.slides;
                        var html = null;
                        var htmlClass;
                        if ($state.current.name == 'gallery') {
                            htmlClass = "cycle-caption meeting";
                        }
                        else {
                            htmlClass = "cycle-caption";
                        }
                        html += "<div class='" + htmlClass + "'></div>";
                        if (slides.length > 1) {
                            html += "<div class='cycle-prev'></div>";
                            html += "<div class='cycle-next'></div>";
                        }
                        angular.forEach(slides, function (slide, key) {
                            html += "<img src='" + slide.img_url + "' data-cycle-title='" + slide.caption + "' />";
                        });
                        element.html(html);
                        element.cycle({
                            fx: "fade",
                            timeout: 5000,
                            captionTemplate: "{{cycleTitle}}",
                            log: false
                        });
                        element.on('$destroy', function () {
                            slides = [];
                        });
                    }
                };
            }]));
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

var Omni;
(function (Omni) {
    var ResortMap;
    (function (ResortMap) {
        ResortMap.ngModule.directive('youtube', ['$sce',
            function ($sce) {
                return {
                    restrict: 'E',
                    template: '<iframe width="692" height="390" src="{{ video_url }}" frameborder="0" allowfullscreen></iframe>',
                    replace: true,
                    link: function (scope, element, attrs) {
                        scope.video_url = $sce.trustAsResourceUrl(scope.location.video_url);
                    }
                };
            }]);
    })(ResortMap = Omni.ResortMap || (Omni.ResortMap = {}));
})(Omni || (Omni = {}));

//# sourceMappingURL=omni-ng.js.map

