{"version":3,"sources":["nps-survey.js"],"names":["updateQuestionVisibilityBasedOnScore","score","npsSurveyViewModel","ActiveNpsScore","ShowPromoterFollowUpQuestion","ShowPassiveFollowUpQuestion","ShowDetractorFollowUpQuestion","isModal","isNpsSurveyPage","IsModal","ko","observable","NpsSurveyId","npsSurveyId","npsScoreIdForSurveyPage","NpsUniqueId","MainQuestion","PromoterFollowUpQuestion","PassiveFollowUpQuestion","DetractorFollowUpQuestion","UseSecondaryLogo","EmailUrl","emailUrl","UserAgent","userAgent","PromoterThankYouMessage","PassiveThankYouMessage","DetractorThankYouMessage","npsScoreForSurveyPage","Feedback","ShowSurvey","ShowMainQuestion","ShowFeedback","ShowThankYou","ShowError","ErrorMessage","IsLoadingNpsSurvey","GetNpsSurveyFormData","$","ajax","url","getNpsSurveyFormDataUrl","type","data","npsScoreId","success","nps","UniqueID","PromoterPostSurveyMessage","PassivePostSurveyMessage","DetractorPostSurveyMessage","error","jqXHR","textStatus","errorThrown","errorMessage","status","responseText","includes","always","AnswerNpsSurvey","newNpsScore","SubmitNpsSurvey","answerNpsSurveyUrl","uniqueID","feedback","SkipNpsSurvey","skipNpsSurveyUrl","ShowCustomAlert","modal","SnoozeNpsSurvey","snoozeNpsSurveyUrl","id","ThankYouCloseNpsSurvey","ThankYouMessage","computed","this","document","ready","elementToBind","getElementById","cleanNode","applyBindings"],"mappings":"AA8MA,SAAAA,uCACA,IAAAC,EAAAC,mBAAAC,iBACAD,mBAAAE,6BAAAH,GAAA,GACAC,mBAAAG,4BAAAJ,GAAA,GAAAA,EAAA,GACAC,mBAAAI,8BAAAL,EAAA,EACA,EAnNA,WAEA,IAAAM,EAAA,oBAAAC,iBAAA,OAAAA,gBAEAN,mBAAA,CAEAO,QAAAC,GAAAC,WAAAJ,GAEAK,YAAAF,GAAAC,WAAAJ,EAAAM,YAAAC,yBACAC,YAAAL,GAAAC,WAAA,MACAK,aAAAN,GAAAC,WAAA,IACAM,yBAAAP,GAAAC,WAAA,IACAO,wBAAA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AA+B,mBACA7B,KAAA,OACAC,KAAA,CACA6B,GAAAtE,mBAAAU,gBAIA,EAEA6D,uBAAA,WACAnC,EAAA,gBAAA+B,MAAA,OACA,GAGAnE,mBAAAwE,gBAAAhE,GAAAiE,UAAA,WACA,MAAA1E,EAAA2E,KAAAzE,iBACA,OAAAF,GAAA,GAAA,MAAA2E,KAAAjD,4BAAA,KAAAiD,KAAAjD,2BACAiD,KAAAjD,2BACA1B,GAAA,GAAA,MAAA2E,KAAAlD,0BAAA,KAAAkD,KAAAlD,yBACAkD,KAAAlD,yBACAzB,GAAA,IAAA,MAAA2E,KAAAnD,2BAAA,KAAAmD,KAAAnD,0BACAmD,KAAAnD,0BAEA,YACA,GAAAvB,mBAGA,CA1LA,GA4LAoC,EAAAuC,UAAAC,OAAA,WACA,IAAAC,EAAAF,SAAAG,eAAA,cAEAD,IACArE,GAAAuE,UAAAF,GACArE,GAAAwE,cAAAhF,mBAAA6E,GAEA7E,mBAAAmC,uBAEA,MAAAnC,mBAAAC,kBAAAD,mBAAAO,YACAP,mBAAA6B,kBAAA,GACA/B,uCACAE,mBAAA8B,cAAA,IAIA","file":"nps-survey-bundle.js","sourcesContent":["(function () {\r\n\r\n    var isModal = (typeof isNpsSurveyPage === 'undefined' || isNpsSurveyPage === null);\r\n\r\n    npsSurveyViewModel = {\r\n\r\n        IsModal: ko.observable(isModal),\r\n\r\n        NpsSurveyId: ko.observable(isModal ? npsSurveyId : npsScoreIdForSurveyPage),\r\n        NpsUniqueId: ko.observable(null),\r\n        MainQuestion: ko.observable(''),\r\n        PromoterFollowUpQuestion: ko.observable(''),\r\n        PassiveFollowUpQuestion: ko.observable(''),\r\n        DetractorFollowUpQuestion: ko.observable(''),\r\n        UseSecondaryLogo: ko.observable(false),\r\n        EmailUrl: ko.observable(isModal ? null : emailUrl),\r\n        UserAgent: ko.observable(isModal ? null : userAgent),\r\n\r\n        PromoterThankYouMessage: ko.observable(''),\r\n        PassiveThankYouMessage: ko.observable(''),\r\n        DetractorThankYouMessage: ko.observable(''),\r\n\r\n        ActiveNpsScore: ko.observable(isModal ? null : npsScoreForSurveyPage),\r\n        Feedback: ko.observable(null),\r\n\r\n        ShowSurvey: ko.observable(true),\r\n        ShowMainQuestion: ko.observable(true),\r\n        ShowPromoterFollowUpQuestion: ko.observable(false),\r\n        ShowPassiveFollowUpQuestion: ko.observable(false),\r\n        ShowDetractorFollowUpQuestion: ko.observable(false),\r\n        ShowFeedback: ko.observable(false),\r\n        ShowThankYou: ko.observable(false),\r\n\r\n        ShowError: ko.observable(false),\r\n        ErrorMessage: ko.observable(''),\r\n\r\n        IsLoadingNpsSurvey: ko.observable(false),\r\n\r\n        GetNpsSurveyFormData: function () {\r\n\r\n            npsSurveyViewModel.IsLoadingNpsSurvey(true);\r\n\r\n            $.ajax({\r\n                url: getNpsSurveyFormDataUrl,\r\n                type: 'GET',\r\n                data: {\r\n                    npsScoreId: npsSurveyViewModel.NpsSurveyId()\r\n                },\r\n                success: function (nps) {\r\n                    if (nps) {\r\n                        npsSurveyViewModel.NpsUniqueId(nps.UniqueID);\r\n                        npsSurveyViewModel.MainQuestion(nps.MainQuestion);\r\n                        npsSurveyViewModel.PromoterFollowUpQuestion(nps.PromoterFollowUpQuestion);\r\n                        npsSurveyViewModel.PassiveFollowUpQuestion(nps.PassiveFollowUpQuestion);\r\n                        npsSurveyViewModel.DetractorFollowUpQuestion(nps.DetractorFollowUpQuestion);\r\n                        npsSurveyViewModel.PromoterThankYouMessage(nps.PromoterPostSurveyMessage);\r\n                        npsSurveyViewModel.PassiveThankYouMessage(nps.PassivePostSurveyMessage);\r\n                        npsSurveyViewModel.DetractorThankYouMessage(nps.DetractorPostSurveyMessage);\r\n                        npsSurveyViewModel.UseSecondaryLogo(nps.UseSecondaryLogo);\r\n                    }\r\n                },\r\n                error: function (jqXHR, textStatus, errorThrown) {\r\n                    npsSurveyViewModel.ShowSurvey(false);\r\n                    npsSurveyViewModel.ShowThankYou(false);\r\n\r\n                    var errorMessage = \"An unexpected error occurred while requesting NPS Survey: \";\r\n\r\n                    if (jqXHR.status == 404 || jqXHR.responseText.includes(\"NPS Survey was not found.\")) {\r\n                        errorMessage += '\\n' + \"NPS Survey was not found.\";\r\n                    }\r\n                    else {\r\n                        if (jqXHR.responseText) {\r\n                            errorMessage += '\\n' + jqXHR.responseText;\r\n                        } else {\r\n                            errorMessage += \"\\nError details could not be parsed.\";\r\n                        }\r\n                    }\r\n\r\n                    npsSurveyViewModel.ErrorMessage(errorMessage);\r\n                    npsSurveyViewModel.ShowError(true);\r\n                }\r\n            }).always(function () {\r\n                npsSurveyViewModel.IsLoadingNpsSurvey(false);\r\n\r\n            });\r\n        },\r\n\r\n        AnswerNpsSurvey: function (newNpsScore) {\r\n\r\n            npsSurveyViewModel.ActiveNpsScore(newNpsScore);\r\n            npsSurveyViewModel.ShowMainQuestion(false);\r\n            npsSurveyViewModel.ShowFeedback(true);\r\n\r\n            updateQuestionVisibilityBasedOnScore();\r\n\r\n            if (npsSurveyViewModel.ActiveNpsScore() >= 9) {\r\n                npsSurveyViewModel.ShowPromoterFollowUpQuestion(true);\r\n                npsSurveyViewModel.ShowPassiveFollowUpQuestion(false);\r\n                npsSurveyViewModel.ShowDetractorFollowUpQuestion(false);\r\n            }\r\n            else if (npsSurveyViewModel.ActiveNpsScore() >= 7 && npsSurveyViewModel.ActiveNpsScore() < 9) {\r\n                npsSurveyViewModel.ShowPromoterFollowUpQuestion(false);\r\n                npsSurveyViewModel.ShowPassiveFollowUpQuestion(true);\r\n                npsSurveyViewModel.ShowDetractorFollowUpQuestion(false);\r\n            }\r\n            else {\r\n                npsSurveyViewModel.ShowPromoterFollowUpQuestion(false);\r\n                npsSurveyViewModel.ShowPassiveFollowUpQuestion(false);\r\n                npsSurveyViewModel.ShowDetractorFollowUpQuestion(true);\r\n            }\r\n        },\r\n\r\n        SubmitNpsSurvey: function () {\r\n\r\n            npsSurveyViewModel.ShowSurvey(false);\r\n            npsSurveyViewModel.ShowThankYou(true);\r\n\r\n            if (npsSurveyViewModel.ActiveNpsScore() != null && npsSurveyViewModel.NpsUniqueId() != null) {\r\n                $.ajax({\r\n                    url: answerNpsSurveyUrl,\r\n                    type: 'POST',\r\n                    data: {\r\n                        uniqueID: npsSurveyViewModel.NpsUniqueId(),\r\n                        score: npsSurveyViewModel.ActiveNpsScore(),\r\n                        feedback: npsSurveyViewModel.Feedback(),\r\n                        emailUrl: npsSurveyViewModel.EmailUrl(),\r\n                        userAgent: npsSurveyViewModel.UserAgent()\r\n                    }\r\n                });\r\n            }\r\n        },\r\n\r\n        SkipNpsSurvey: function () {\r\n\r\n            // If a score has not been set, then truly set the survey to skipped.\r\n            if (npsSurveyViewModel.ActiveNpsScore() == null && npsSurveyViewModel.NpsUniqueId() != null) {\r\n                $.ajax({\r\n                    url: skipNpsSurveyUrl,\r\n                    type: 'POST',\r\n                    data: {\r\n                        uniqueID: npsSurveyViewModel.NpsUniqueId()\r\n                    },\r\n                    error: function (jqXHR, textStatus, errorThrown) {\r\n                        ShowCustomAlert(\"You are impersonating a user.  For security reasons, you cannot perform this action.\");\r\n                    }\r\n                }).always(function () {\r\n                    $(\"#novi-pop-up\").modal('hide');\r\n                });\r\n            }\r\n            else {\r\n                $(\"#novi-pop-up\").modal('hide');\r\n            }\r\n        },\r\n\r\n        SnoozeNpsSurvey: function () {\r\n            $(\"#novi-pop-up\").modal('hide');\r\n            // If a score has not been set, then truly snooze the survey.\r\n            if (npsSurveyViewModel.ActiveNpsScore() == null && npsSurveyViewModel.NpsSurveyId() != null) {\r\n                $.ajax({\r\n                    url: snoozeNpsSurveyUrl,\r\n                    type: 'POST',\r\n                    data: {\r\n                        id: npsSurveyViewModel.NpsSurveyId()\r\n                    }\r\n                });\r\n            }\r\n        },\r\n\r\n        ThankYouCloseNpsSurvey: function () {\r\n            $(\"#novi-pop-up\").modal('hide');\r\n        }\r\n    }\r\n\r\n    npsSurveyViewModel.ThankYouMessage = ko.computed(function () {\r\n        const score = this.ActiveNpsScore();\r\n        if (score <= 6 && this.DetractorThankYouMessage() != null && this.DetractorThankYouMessage() !== '') {\r\n            return this.DetractorThankYouMessage();\r\n        } else if (score <= 8 && this.PassiveThankYouMessage() != null && this.PassiveThankYouMessage() !== '') {\r\n            return this.PassiveThankYouMessage();\r\n        } else if (score <= 10 && this.PromoterThankYouMessage() != null && this.PromoterThankYouMessage() !== '') {\r\n            return this.PromoterThankYouMessage();\r\n        }\r\n        return 'Thank You!';\r\n    }, npsSurveyViewModel);\r\n\r\n\r\n})();\r\n\r\n$(document).ready(function () {\r\n    var elementToBind = document.getElementById('nps-survey');\r\n\r\n    if (elementToBind) {\r\n    ko.cleanNode(elementToBind);\r\n    ko.applyBindings(npsSurveyViewModel, elementToBind);\r\n\r\n    npsSurveyViewModel.GetNpsSurveyFormData();\r\n\r\n        if (npsSurveyViewModel.ActiveNpsScore() != null && !npsSurveyViewModel.IsModal()) {\r\n            npsSurveyViewModel.ShowMainQuestion(false);    // aleady answered\r\n            updateQuestionVisibilityBasedOnScore();\r\n            npsSurveyViewModel.ShowFeedback(true);\r\n        }\r\n    }\r\n\r\n});\r\n\r\nfunction updateQuestionVisibilityBasedOnScore() {\r\n    var score = npsSurveyViewModel.ActiveNpsScore();\r\n    npsSurveyViewModel.ShowPromoterFollowUpQuestion(score >= 9);\r\n    npsSurveyViewModel.ShowPassiveFollowUpQuestion(score >= 7 && score < 9);\r\n    npsSurveyViewModel.ShowDetractorFollowUpQuestion(score < 7);\r\n}"]}