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,OAAOC,EAAAA,EAAAA,gBAAgB,CAAE,gBAAgB,EAAM,eAAe,EAAMvB,OAAQA,EAAOI,SAClF,EACDoB,EAAAA,EAAAA,YAAYb,EAAKc,OAAQ,YACxB,KACNP,EAAAA,EAAAA,OAAO/B,KACH4B,EAAAA,EAAAA,cAAcW,EAAAA,EAAAA,aAAaC,EAAAA,WAAmB,CAC7C1D,IAAK,EACL2D,iBAAkBtB,EAA2BF,MAC7CyB,mBAAmB,GAClB,KAAM,EAAG,CAAC,uBACbC,EAAAA,EAAAA,oBAAoB,IAAI,IAC3B,GAAG,CAER,ICxGA,MAAMC,EAAc,EAEpB,O","sources":["webpack://beliefnet-frontend/./src/stores/OnePageQuiz.ts","webpack://beliefnet-frontend/./src/stores/Quiz.ts","webpack://beliefnet-frontend/./src/components/quiz/OnePage.vue?dde7","webpack://beliefnet-frontend/./src/components/quiz/OnePage.vue"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const useOnePageQuizStore = defineStore('OnePageQuiz', {\n    state: () => {\n        return {\n            finalResults: [] as any[],\n            answeredQuestions: [] as boolean[],\n            correctAnswer: [] as number[],\n            userAnswer: [] as number[],\n            userWeight: [] as number[]\n        };\n    },\n    getters: {\n        getAnswerTotalWeightOrCorrect(state) {\n            let count = 0;\n\n            // count the number of correct answers\n            state.userAnswer.forEach((answer, index) => {\n                if (index + 1 <= state.correctAnswer.length) {\n                    if (state.correctAnswer[index] >= 0 && answer == state.correctAnswer[index]) {\n                        count++;\n                    }\n                }\n            });\n\n            // count the weight if we have it\n            state.userWeight.forEach((weight, index) => {\n                if (index + 1 <= state.correctAnswer.length) {\n                    if (weight >= 0) {\n                        count += weight;\n                    }\n                }\n            });\n\n            return count;\n        },\n        numberOfQuestions: (state) => state.correctAnswer.length,\n        canShowUserResult(state) {\n            // only show if there aren't any -1s in the user answer array\n            return (\n                state.userAnswer.filter((val) => val === -1).length === 0 ||\n                state.userWeight.filter((val) => val === -1).length === 0 ||\n                state.answeredQuestions.filter((val) => val === false).length === 0\n            );\n        },\n        nextQuestion() {\n            return (currentQuestion: number) => {\n                const nextQuestion = ++currentQuestion;\n                if (nextQuestion < this.numberOfQuestions) {\n                    return nextQuestion;\n                }\n\n                return -1;\n            };\n        },\n        getFinalResult(state) {\n            let finalResult = null;\n\n            if (state.finalResults.length > 0) {\n                state.finalResults.sort(function (a, b) {\n                    return b.score - a.score;\n                });\n                finalResult = state.finalResults[0].result;\n            }\n\n            return finalResult;\n        }\n    },\n    actions: {\n        reset(numberOfQuestions: number) {\n            this.correctAnswer = Array(numberOfQuestions).fill(-1);\n            this.userAnswer = Array(numberOfQuestions).fill(-1);\n            this.userWeight = Array(numberOfQuestions).fill(-1);\n            this.answeredQuestions = Array(numberOfQuestions).fill(false);\n        },\n        setCorrectAnswer(question: number, answer: number) {\n            this.correctAnswer[question] = answer;\n        },\n        setUserAnswer(question: number, answer: number, weight: number) {\n            if (this.correctAnswer[question] < 0) {\n                this.userWeight[question] = weight;\n            } else {\n                this.userAnswer[question] = answer;\n            }\n        },\n        setFinalAnswer(result: string, score: number) {\n            const existingKeyIndex = this.searchFinalResultsIndex(result);\n\n            if (existingKeyIndex >= 0) {\n                this.finalResults[existingKeyIndex].score += score;\n            } else {\n                this.finalResults.push({ result: result, score: score });\n            }\n        },\n        searchFinalResultsIndex(key: string) {\n            for (let idx = 0; idx < this.finalResults.length; idx++) {\n                if (this.finalResults[idx].result === key) {\n                    return idx;\n                }\n            }\n\n            return -1;\n        },\n        setQuestionAsAnswered(question: number) {\n            this.answeredQuestions[question] = true;\n        }\n    }\n});\n","import { defineStore } from 'pinia';\n\nexport const useQuizStore = defineStore('QuizStore', {\n    state: () => {\n        return {\n            emailSent: false,\n            emailSent2: false\n        };\n    },\n    getters: {\n        isEmailSent: (state) => state.emailSent,\n        isEmailSent2: (state) => state.emailSent2\n    },\n    actions: {\n        setEmailSent(sent: boolean) {\n            this.emailSent = sent;\n        },\n        setEmailSent2(sent: boolean) {\n            this.emailSent2 = sent;\n        }\n    }\n});\n","import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, resolveComponent as _resolveComponent, createVNode as _createVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, normalizeClass as _normalizeClass, createBlock as _createBlock, Fragment as _Fragment } from \"vue\"\n\nconst _hoisted_1 = { key: 0 }\n\nimport { toRefs, watch, ref, onMounted } from 'vue';\nimport { useOnePageQuizStore } from '../../stores/OnePageQuiz';\nimport { useLogger } from 'vue-logger-plugin';\nimport CoRegInterstitial from '../pathfinder/CoRegInterstitial.vue';\nimport { useQuizStore } from '@/stores/Quiz';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n  __name: 'OnePage',\n  props: {\n    questionsCount: { \n        type: Number\n    },\n    showInterstitialOnComplete: {\n        type: Boolean,\n        default: false\n    },\n    captureEmail: {\n        type: Boolean,\n        default: false\n    },\n    listId: {\n        type: Number\n    },\n    sourceDesc: {\n        type: String\n    },\n    newsletterName: {\n        type: String\n    }\n},\n  setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { questionsCount, showInterstitialOnComplete, captureEmail, listId, sourceDesc, newsletterName } = toRefs(props);\n\n// use the logger\nconst logger = useLogger();\nconst loaded = ref(false);\n\n// get quiz store\nconst quizStore = useQuizStore();\n// get the trivia quiz store\nconst onePageStore = useOnePageQuizStore();\n// we want to reset the number of questions being shown on this page\nif (questionsCount?.value) {\n    logger.debug('Resetting quiz question counter', questionsCount.value);\n    onePageStore.reset(questionsCount.value);\n}\n\n// display interstitial after completing quiz\nconst displayContentInterstitial = ref(false);\nif (props.showInterstitialOnComplete) {\n    logger.debug('Configuring CoReg Interstitial upon quiz completion');\n    const unwatch = watch(() => onePageStore.canShowUserResult, complete => {\n        if (complete) {\n            // quiz is complete, display interstitial\n            displayContentInterstitial.value = true;\n            // disconnect watcher\n            unwatch();\n        }\n    });\n}\n\nonMounted(() => loaded.value = true);\n\nreturn (_ctx: any,_cache: any) => {\n  const _component_rad_quiz_newsletter = _resolveComponent(\"rad-quiz-newsletter\")!\n\n  return (_openBlock(), _createElementBlock(_Fragment, null, [\n    (_unref(captureEmail) && _unref(quizStore).isEmailSent == false)\n      ? (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n          _createVNode(_component_rad_quiz_newsletter, {\n            \"list-id\": _unref(listId),\n            \"source-desc\": _unref(sourceDesc),\n            partners: true,\n            \"newsletter-name\": _unref(newsletterName),\n            header: \"Enter your email address to see your quiz.\",\n            \"button-text\": \"Get quiz\",\n            \"result-sent\": false\n          }, null, 8, [\"list-id\", \"source-desc\", \"newsletter-name\"])\n        ]))\n      : (_openBlock(), _createElementBlock(\"div\", {\n          key: 1,\n          class: _normalizeClass({ 'quiz-wrapper': true, 'trivia-quiz': true, loaded: loaded.value })\n        }, [\n          _renderSlot(_ctx.$slots, \"default\")\n        ], 2)),\n    (_unref(showInterstitialOnComplete))\n      ? (_openBlock(), _createBlock(CoRegInterstitial, {\n          key: 2,\n          showInterstitial: displayContentInterstitial.value,\n          enableCloseButton: false\n        }, null, 8, [\"showInterstitial\"]))\n      : _createCommentVNode(\"\", true)\n  ], 64))\n}\n}\n\n})","import script from \"./OnePage.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./OnePage.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["useOnePageQuizStore","defineStore","state","finalResults","answeredQuestions","correctAnswer","userAnswer","userWeight","getters","getAnswerTotalWeightOrCorrect","count","forEach","answer","index","length","weight","numberOfQuestions","canShowUserResult","filter","val","nextQuestion","currentQuestion","this","getFinalResult","finalResult","sort","a","b","score","result","actions","reset","Array","fill","setCorrectAnswer","question","setUserAnswer","setFinalAnswer","existingKeyIndex","searchFinalResultsIndex","push","key","idx","setQuestionAsAnswered","useQuizStore","emailSent","emailSent2","isEmailSent","isEmailSent2","setEmailSent","sent","setEmailSent2","_hoisted_1","_defineComponent","__name","props","questionsCount","type","Number","showInterstitialOnComplete","Boolean","default","captureEmail","listId","sourceDesc","String","newsletterName","setup","__props","toRefs","logger","useLogger","loaded","ref","quizStore","onePageStore","value","debug","displayContentInterstitial","unwatch","watch","complete","onMounted","_ctx","_cache","_component_rad_quiz_newsletter","_resolveComponent","_openBlock","_createElementBlock","_Fragment","_unref","_createVNode","partners","header","class","_normalizeClass","_renderSlot","$slots","_createBlock","CoRegInterstitial","showInterstitial","enableCloseButton","_createCommentVNode","__exports__"],"sourceRoot":""}