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B,EAF3D,uBAAgB,MAAM,oBAAqB,iBAAiB,GAKnCS,IAC9Bb,EAAA,YAAY,SAAUG,CAAQ,EACpBC,EAAA,GACd,CACF","names":["LOCAL_STORAGE_KEY","responsivevoice","_el","$el","opts","customiseResponsiveVoice","isActive","isFirstTime","localStorageValue","loadResponsiveVoiceScript","resolve","script","voiceScriptTag","_a","checkIfExist","initResponsiveVoiceScript","toggleLocalStorageResponsiveVoice","enabled","willRemoveItem"],"sources":["../../../FE_DEV/src/modules/responsivevoice.ts"],"sourcesContent":["const LOCAL_STORAGE_KEY = 'enabled_responsivevoice'\n\nexport default async (_el: HTMLElement, $el: JQuery, opts: { apiKey: string }) => {\n\tlet customiseResponsiveVoice: unknown = null\n\tlet isActive = false\n\tlet isFirstTime = true\n\tconst localStorageValue = localStorage.getItem(LOCAL_STORAGE_KEY)\n\n\tconst loadResponsiveVoiceScript = async () => {\n\t\treturn new Promise(resolve => {\n\t\t\tif (!window.responsiveVoice) {\n\t\t\t\tconst script = document.createElement('script')\n\t\t\t\tscript.src = `https://code.responsivevoice.org/responsivevoice.js?key=${opts.apiKey}`\n\t\t\t\tscript.async = true\n\t\t\t\tconst voiceScriptTag = document.getElementsByTagName('script')[0]\n\t\t\t\tvoiceScriptTag?.parentNode?.insertBefore(script, voiceScriptTag)\n\n\t\t\t\tconst checkIfExist = () => {\n\t\t\t\t\tif (!window.responsiveVoice) {\n\t\t\t\t\t\trequestAnimationFrame(checkIfExist)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tresolve(undefined)\n\t\t\t\t}\n\t\t\t\trequestAnimationFrame(checkIfExist)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresolve(undefined)\n\t\t})\n\t}\n\n\tconst initResponsiveVoiceScript = async (opts: object) => {\n\t\tawait loadResponsiveVoiceScript()\n\t\tconst { default: customiseResponsiveVoice } = await import('../custom_vendors/responsivevoice')\n\t\tcustomiseResponsiveVoice(opts)\n\t\twindow.responsiveVoice.init()\n\t\treturn customiseResponsiveVoice\n\t}\n\n\tconst toggleLocalStorageResponsiveVoice = (enabled?: boolean) => {\n\t\tconst isEnabledUndefined = typeof enabled === 'undefined'\n\n\t\tconst willRemoveItem = !isEnabledUndefined ? !enabled : !!(localStorage.getItem(LOCAL_STORAGE_KEY))\n\n\t\twindow.localStorage[willRemoveItem ? 'removeItem' : 'setItem'](LOCAL_STORAGE_KEY, '1')\n\t}\n\n\tif (localStorageValue) {\n\t\tcustomiseResponsiveVoice = await initResponsiveVoiceScript({\n\t\t\t...opts,\n\t\t\twelcomeMessage: false,\n\t\t})\n\t\tisActive = true\n\t\t$el.toggleClass('active', isActive)\n\t\tisFirstTime = false\n\t}\n\n\n\t$el.on('click', async () => {\n\t\tif(!customiseResponsiveVoice) {\n\t\t\tcustomiseResponsiveVoice = await initResponsiveVoiceScript(opts)\n\t\t}\n\t\tisActive = !isActive\n\t\tif(window.responsiveVoice) {\n\t\t\tif(!isActive) {\n\t\t\t\twindow.responsiveVoice.speak('Text to Audio off', 'UK English Male')\n\t\t\t} else if(!isFirstTime) {\n\t\t\t\twindow.responsiveVoice.speak('Text to Audio on', 'UK English Male')\n\t\t\t}\n\t\t}\n\t\ttoggleLocalStorageResponsiveVoice()\n\t\t$el.toggleClass('active', isActive)\n\t\tisFirstTime = false\n\t})\n}\n"],"file":"assets/responsivevoice-79ca8745.js"}