{"version":3,"file":"Qualtrics.js","names":["Qualtrics","a","setters","ThirdPartyLoader","default","deepMerge","cookie","execute","constructor","element","options","arguments","length","url","params","Q_ZID","thirdPartyE","thirdPartyH","expireInDays","initLoad","document","readyState","checkCookie","loadScript","loaded","cookieValue","getCookie","qsi","e","h","split","Math","random","setCookie","join","percentage","parseInt","remainder","floor"],"sources":["components/integration/Qualtrics.js"],"sourcesContent":["import ThirdPartyLoader from 'components/global/ThirdPartyLoader';\nimport { deepMerge } from 'toolbox/deepMerge';\nimport { cookie } from 'toolbox/cookie';\n\n/**\n * This is a description of the Qualtrics constructor function.\n * @class\n * @classdesc Qualtrics will create script tag and third-party script will inject it's content.\n * @extends Component\n */\nexport default class Qualtrics extends ThirdPartyLoader {\n /**\n * Constructor of the class that mainly merge the options of the components\n * @param {HTMLElement} element HTMLElement of the component\n * @param {object} options options that belongs to the component\n */\n constructor(element, options = {}) {\n super(element, deepMerge({\n // The default value 100, 'r' and 7 are taken from third-party script\n url: null,\n params: {\n Q_ZID: null,\n },\n thirdPartyE: 100,\n thirdPartyH: 'r',\n expireInDays: 7,\n }, options));\n }\n\n /**\n * Executed when load event is triggered or triggered directly when component is initialized if window.onload has been\n * triggered before the initialization of the component. Is called after all the other hooks\n */\n initLoad() {\n if (document.readyState === 'complete') {\n if (this.checkCookie()) {\n this.loadScript();\n }\n } else {\n this.loaded = false;\n }\n }\n\n /**\n * checkCookie method checking cookie\n * @returns {Boolean} true - will inject the third-party script else no need to call third-party\n */\n checkCookie() {\n let cookieValue = cookie.getCookie(this.options.qsi);\n let e = this.options.thirdPartyE;\n const h = this.options.thirdPartyH;\n if (cookieValue) {\n cookieValue = cookieValue.split(':');\n } else if (e !== 100) {\n if (h === 'v') {\n e = Math.random() >= e / 100 ? 0 : 100;\n }\n cookieValue = [h, e, 0];\n cookie.setCookie(this.options.qsi, cookieValue.join(':'), this.options.expireInDays);\n } else {\n return true;\n }\n const percentage = parseInt(cookieValue[1], 10);\n let remainder;\n if (percentage === 100) {\n return true;\n }\n switch (cookieValue[0]) {\n case 'v':\n return false;\n case 'r':\n remainder = cookieValue[2] % Math.floor(100 / percentage);\n cookieValue[2] += 1;\n this.setCookie(this.options.qsi, cookieValue.join(':'), this.options.expireInDays);\n return !remainder;\n default:\n return true;\n }\n }\n}\n"],"mappings":"4IAUqBA,CAAS,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAVvBE,CAAgB,CAAAF,CAAA,CAAAG,OAAA,WAAAH,CAAA,EACdI,CAAS,CAAAJ,CAAA,CAATI,SAAS,WAAAJ,CAAA,EACTK,CAAM,CAAAL,CAAA,CAANK,MAAM,GAAAC,OAAA,SAAAA,CAAA,EAAAN,CAAA,WAQMD,CAAS,CAAf,aAAwB,CAAAG,CAAiB,CAMpDK,WAAWA,CAACC,CAAO,CAAgB,IAAd,CAAAC,CAAO,GAAAC,SAAA,CAAAC,MAAA,WAAAD,SAAA,IAAAA,SAAA,IAAG,CAAC,CAAC,CAC7B,KAAK,CAACF,CAAO,CAAEJ,CAAS,CAAC,CAErBQ,GAAG,CAAE,IAAI,CACTC,MAAM,CAAE,CACJC,KAAK,CAAE,IACX,CAAC,CACDC,WAAW,CAAE,GAAG,CAChBC,WAAW,CAAE,GAAG,CAChBC,YAAY,CAAE,CAClB,CAAC,CAAER,CAAO,CAAC,CACf,CAMAS,QAAQA,CAAA,CAAG,CACqB,UAAU,GAAlCC,QAAQ,CAACC,UAAyB,CAC9B,IAAI,CAACC,WAAW,CAAC,CAAC,EAClB,IAAI,CAACC,UAAU,CAAC,CAAC,CAGrB,IAAI,CAACC,MAAM,GAEnB,CAMAF,WAAWA,CAAA,CAAG,IACN,CAAAG,CAAW,CAAGnB,CAAM,CAACoB,SAAS,CAAC,IAAI,CAAChB,OAAO,CAACiB,GAAG,CAAC,CAChDC,CAAC,CAAG,IAAI,CAAClB,OAAO,CAACM,WAAW,CAChC,KAAM,CAAAa,CAAC,CAAG,IAAI,CAACnB,OAAO,CAACO,WAAW,CAClC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