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,KAAM,EAAGV,IACZD,EAAAA,EAAAA,oBAAoB,KAAM,CACxB8C,UAAWZ,oBAAmBD,EAAAA,EAAAA,OAAOrB,KACpC,KAAM,EAAGV,IACZ6C,EAAAA,EAAAA,YAAYlB,EAAKmB,OAAQ,iBAG7BH,EAAAA,EAAAA,oBAAoB,IAAI,EAAK,CAErC,ICzGA,MAAMI,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/Result.vue?0229","webpack://beliefnet-frontend/./src/components/quiz/onepage/Result.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, createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, renderSlot as _renderSlot } from \"vue\"\n\nconst _hoisted_1 = { key: 0 }\nconst _hoisted_2 = { key: 1 }\nconst _hoisted_3 = {\n  key: 0,\n  class: \"image-container\"\n}\nconst _hoisted_4 = [\"src\", \"alt\"]\nconst _hoisted_5 = { class: \"img-attribution\" }\nconst _hoisted_6 = { class: \"text-center\" }\nconst _hoisted_7 = /*#__PURE__*/_createElementVNode(\"div\", { class: \"result-title\" }, \"Your result is:\", -1)\nconst _hoisted_8 = [\"innerHTML\"]\nconst _hoisted_9 = [\"innerHTML\"]\n\nimport { useQuizStore } from '@/stores/Quiz';\nimport { toRefs } from 'vue';\nimport { useLogger } from 'vue-logger-plugin';\nimport { useOnePageQuizStore } from '../../../stores/OnePageQuiz';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n  __name: 'Result',\n  props: {\n    minScore: Number,\n    maxScore: Number,\n    resultId: String,\n    title: String,\n    message: String,\n    imageUrl: String,\n    imageAlt: String,\n    captureEmail: Boolean,\n    listId: Number,\n    sourceDesc: String,\n    newsletterName: String\n},\n  setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { minScore, maxScore, resultId, title, message, imageUrl, imageAlt, captureEmail, listId, sourceDesc, newsletterName } = toRefs(props);\n\n// user logger\nconst logger = useLogger();\n// get the quiz store\nconst quizStore = useQuizStore();\n// get the trivia quiz store\nconst onePageStore = useOnePageQuizStore();\nlogger.debug('result id has min and max scores set', resultId?.value, minScore?.value, maxScore?.value);\n\nreturn (_ctx: any,_cache: any) => {\n  const _component_rad_quiz_newsletter = _resolveComponent(\"rad-quiz-newsletter\")!\n\n  return (\n            _unref(captureEmail) && _unref(quizStore).isEmailSent2 == false && ((_unref(onePageStore).canShowUserResult &&\n            _unref(onePageStore).getAnswerTotalWeightOrCorrect >= _unref(minScore) &&\n            _unref(onePageStore).getAnswerTotalWeightOrCorrect <= _unref(maxScore)) ||\n            (_unref(onePageStore).canShowUserResult && \n            _unref(onePageStore).getFinalResult == decodeURIComponent(_unref(title))))\n        )\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 result.\",\n          \"button-text\": \"Get results\",\n          \"result-sent\": true\n        }, null, 8, [\"list-id\", \"source-desc\", \"newsletter-name\"])\n      ]))\n    : (\n            (_unref(onePageStore).canShowUserResult &&\n            _unref(onePageStore).getAnswerTotalWeightOrCorrect >= _unref(minScore) &&\n            _unref(onePageStore).getAnswerTotalWeightOrCorrect <= _unref(maxScore)) ||\n            (_unref(onePageStore).canShowUserResult && \n            _unref(onePageStore).getFinalResult == decodeURIComponent(_unref(title)))\n        )\n      ? (_openBlock(), _createElementBlock(\"div\", _hoisted_2, [\n          (_unref(imageUrl)?.value?.length > 0)\n            ? (_openBlock(), _createElementBlock(\"figure\", _hoisted_3, [\n                _createElementVNode(\"img\", {\n                  src: _unref(imageUrl),\n                  alt: _unref(imageAlt),\n                  class: \"img-responsive image-decoration center-block\"\n                }, null, 8, _hoisted_4),\n                _createElementVNode(\"div\", _hoisted_5, _toDisplayString(_unref(imageAlt)), 1)\n              ]))\n            : _createCommentVNode(\"\", true),\n          _createElementVNode(\"div\", _hoisted_6, [\n            _hoisted_7,\n            _createElementVNode(\"span\", {\n              class: \"h2\",\n              innerHTML: decodeURIComponent(_unref(title))\n            }, null, 8, _hoisted_8),\n            _createElementVNode(\"h5\", {\n              innerHTML: decodeURIComponent(_unref(message))\n            }, null, 8, _hoisted_9),\n            _renderSlot(_ctx.$slots, \"default\")\n          ])\n        ]))\n      : _createCommentVNode(\"\", true)\n}\n}\n\n})","import script from \"./Result.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./Result.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","_hoisted_2","_hoisted_3","class","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_createElementVNode","_hoisted_8","_hoisted_9","_defineComponent","__name","props","minScore","Number","maxScore","resultId","String","title","message","imageUrl","imageAlt","captureEmail","Boolean","listId","sourceDesc","newsletterName","setup","__props","toRefs","logger","useLogger","quizStore","onePageStore","debug","value","_ctx","_cache","_component_rad_quiz_newsletter","_resolveComponent","_unref","decodeURIComponent","_openBlock","_createElementBlock","_createVNode","partners","header","_b","_a","src","alt","_toDisplayString","_createCommentVNode","innerHTML","_renderSlot","$slots","__exports__"],"sourceRoot":""}