"use strict";
/*
@licstart  The following is the entire license notice for the
JavaScript code in this page.

Copyright (C) 2018  Access42

The JavaScript code in this page is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version.  The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend  The above is the entire license notice
for the JavaScript code in this page.
*/const AccessConfig=function(){const e={Setup:{id:"accessconfig"},Setting:{useExtendContrast:!0},BodyActive:{classSetting:"active"},Overlay:{classSetting:"overlay"},ModalButton:{id:"button"},ModalContainer:{classSetting:"modal",titleLang:{en:"Accessibility setting",fr:"Paramètres d’accessibilité"},titleId:"title",titleClass:"title"},CloseButton:{id:"close",classSetting:"close",lang:{en:"close",fr:"fermer"},hiddenTextClass:"sr-only"},InlineContentContainer:{id:"inline-c"},FormFieldsetContent:{classSetting:"content"},FormFieldset:{classSetting:"fieldset"},LegendFieldset:{classSetting:"legend"},FormRadio:{classSetting:"radio"},ContrastFieldset:{id:"contrast"},ContrastLegend:{lang:{en:"Contrast",fr:"Contrastes"}},DefaultContrastCheckbox:{id:"default-contrast",value:"default-contrast",groupName:"contrast",lang:{en:"Default",fr:"Défaut"}},HighContrastCheckbox:{id:"high-contrast",value:"high-contrast",groupName:"contrast",lang:{en:"Reinforce",fr:"Renforcer"}},InvertContrastCheckbox:{id:"inv-contrast",value:"inv-contrast",groupName:"contrast",lang:{en:"Reverse",fr:"Inverser"}},DyslexiaFieldset:{id:"font"},DyslexiaLegend:{lang:{en:"Font (dyslexia)",fr:"Police (dyslexie)"}},DefaultFontCheckbox:{id:"default-font",value:"default-font",groupName:"font",lang:{en:"Default",fr:"Défaut"}},DyslexiaFontCheckbox:{id:"dys-font",value:"dys-font",groupName:"font",lang:{en:"Adapt",fr:"Adapter"}},LineSpacingFieldset:{id:"line-spacing"},LineSpacingLegend:{lang:{en:"Line spacing",fr:"Interlignage"}},DefaultLineSpacingCheckbox:{id:"default-spacing",value:"default-spacing",groupName:"line-spacing",lang:{en:"Default",fr:"Défaut"}},DyslexiaLineSpacingCheckbox:{id:"dys-spacing",value:"dys-spacing",groupName:"line-spacing",lang:{en:"Increase",fr:"Augmenter"}},JustificationFieldset:{id:"justification"},JustificationLegend:{lang:{en:"Justification",fr:"Justification"}},DefaultJustificationCheckbox:{id:"default-justification",value:"default-justification",groupName:"justification",lang:{en:"Default",fr:"Défaut"}},DyslexiaJustificationCheckbox:{id:"cancel-justification",value:"cancel-justification",groupName:"justification",lang:{en:"Remove",fr:"Supprimer"}},ImageReplacementFieldset:{id:"image"},ImageReplacementCSS:{replacementCss:"replace-img",replacementStyle:"replace-style"},ImageReplacementLegend:{lang:{en:"Images",fr:"Images"}},DefaultImageReplacementCheckbox:{id:"default-img",value:"default-img",groupName:"image",lang:{en:"Default",fr:"Défaut"}},ImageReplacementCheckbox:{id:"text-img",value:"text-img",groupName:"image",lang:{en:"Replace with text",fr:"Remplacer par du texte"}}},t={mode:null,cookieName:null,openObj:null,imgTab:null,imgSpan:null};let a;function n(){const n=document.querySelector("body"),c=document.getElementById(t.mode).querySelectorAll("input");for(let e=0,t=c.length;e<t;e++)c[e].addEventListener("click",(function(){i(this)}),!1);const l=function(e){const t=`${a}-${e}=`,n=document.cookie.split(";");for(let e of n){for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(t))return e.substring(t.length,e.length)}return null}(t.cookieName);if(l){n.classList.add(l);for(let e=0,t=c.length;e<t;e++)c[e].removeAttribute("checked");document.getElementById(l).setAttribute("checked","checked")}n.classList.contains(`${a}-${e.DefaultImageReplacementCheckbox.value}`)&&o(),n.classList.contains(`${a}-${e.ImageReplacementCheckbox.value}`)&&s()}function i(n){t.mode=n.getAttribute("name"),t.cookieName=n.getAttribute("name");const i=document.getElementById(t.mode).querySelectorAll("input"),c=document.querySelector("body");for(let t=0,n=i.length;t<n;t++){var l=i[t].getAttribute("value");i[t].removeAttribute("checked"),l===`${a}-${e.DefaultImageReplacementCheckbox.value}`&&o(),c.classList.remove(l)}const d=n.getAttribute("value");n.setAttribute("checked","checked"),(l=n.getAttribute("value"))===`${a}-${e.ImageReplacementCheckbox.value}`&&s(),c.classList.add(d),function(e,t,a){if(a){const e=new Date;e.setTime(e.getTime()+24*a*60*60*1e3);var n=`; expires=${e.toGMTString()}`}else n="";document.cookie=`${e}=${t}${n}; path=/`}(t.cookieName,d,"180")}function s(){for(let a=0,n=t.imgTab.length;a<n;a++)if(t.imgTab[a].parentNode){var e=t.imgTab[a].parentNode;t.imgTab[a]=e.replaceChild(t.imgSpan[a],t.imgTab[a])}}function o(){for(let a=0,n=t.imgSpan.length;a<n;a++)if(t.imgSpan[a].parentNode){var e=t.imgSpan[a].parentNode;t.imgSpan[a]=e.replaceChild(t.imgTab[a],t.imgSpan[a])}}function c(n){document.body.classList.add(`${a}-${e.BodyActive.classSetting}`);const i=document.createElement("div");i.classList.add(`${a}-${e.Overlay.classSetting}`),document.body.appendChild(i),t.openObj=document.getElementById(a),t.openObj.style.display="block",document.getElementById(`${a}-${e.CloseButton.id}`).focus(),document.addEventListener("keydown",(function i(s){if(27===s.keyCode){t.openObj.style.display="none",n.focus(),document.removeEventListener("keydown",i,!1),document.body.classList.remove(`${a}-${e.BodyActive.classSetting}`);const s=document.querySelector(`.${a}-${e.Overlay.classSetting}`);s&&s.remove()}}),!1);const s=document.getElementById(`${a}-${e.CloseButton.id}`);s.addEventListener("click",(function i(){t.openObj.style.display="none",n.focus(),s.removeEventListener("click",i,!1),document.body.classList.remove(`${a}-${e.BodyActive.classSetting}`);const o=document.querySelector(`.${a}-${e.Overlay.classSetting}`);o&&o.remove()}),!1),document.addEventListener("focus",l,!0)}function l(e){t.openObj&&!t.openObj.contains(e.target)&&(e.stopPropagation(),t.openObj.focus())}window.onload=()=>{if(!document.querySelector("[data-accessconfig-params]"))return void console.log("AccessConfig warning : HTML missing");const i=document.querySelector("[data-accessconfig-params]");if(t.userParams=JSON.parse(i.getAttribute("data-accessconfig-params")),a=t.userParams.Prefix??"a42-ac",function(){function n(e){const t=e.tagName,a=document.createElement(t);for(const t in e)"tagName"!=t&&"function"!=typeof e[t]&&a.setAttribute(t,e[t]);return a}const i=function(){const e=document.querySelector("html").getAttribute("lang");if(e){const t=e.indexOf("-")>0?e.indexOf("-"):3;return e.substring(0,t)}return"en"}(),s=n({tagName:"div",id:a,class:a}),o=n({tagName:"div",class:`${a}-${e.FormFieldsetContent.classSetting}`});if(1==t.userParams.Modal||void 0===t.userParams.Modal){s.setAttribute("role","dialog"),s.setAttribute("aria-labelledby",`${a}-${e.ModalContainer.titleId}`),s.setAttribute("tabindex","-1"),t.userParams.ContainerClass?s.classList.add(`${a}-${t.userParams.ContainerClass}`):s.classList.add(`${a}-${e.ModalContainer.classSetting}`);const o=n({tagName:"h1",id:`${a}-${e.ModalContainer.titleId}`});t.userParams.ModalTitle?o.classList.add(a+t.userParams.ModalTitle):o.classList.add(`${a}-${e.ModalContainer.titleClass}`);const c=document.createTextNode(e.ModalContainer.titleLang[i]);o.appendChild(c),s.appendChild(o);const l=n({tagName:"button",type:"button",id:`${a}-${e.CloseButton.id}`});t.userParams.ModalCloseButton?l.classList.add(a+t.userParams.ModalCloseButton):l.classList.add(`${a}-${e.CloseButton.classSetting}`);const d=n({tagName:"span",class:e.CloseButton.hiddenTextClass}),r=document.createTextNode(e.CloseButton.lang[i]);d.appendChild(r),l.appendChild(d),s.appendChild(l)}else{document.getElementById(e.Setup.id).appendChild(s),s.classList.add(`${a}accessconfig-inline`)}s.appendChild(o);const c=e=>{const t=n({tagName:"fieldset",id:`${a}-${e.fieldset_id}`}),s=document.createElement("legend");s.appendChild(document.createTextNode(e.legend_text)),t.appendChild(s);let c=0;for(const s of e.checkboxes)if(s[0]){const e={tagName:"input",type:"radio",id:`${a}-${s[1].id}`,value:`${a}-${s[1].value}`,name:`${a}-${s[1].groupName}`};0===c&&(e.checked="checked"),t.appendChild(n(e));const o=n({tagName:"label",for:`${a}-${s[1].id}`});o.appendChild(document.createTextNode(s[1].lang[i])),t.appendChild(o),c++}o.appendChild(t)};0!=t.userParams.Contrast&&c({fieldset_id:e.ContrastFieldset.id,legend_text:e.ContrastLegend.lang[i],checkboxes:[[!0,e.DefaultContrastCheckbox],[e.Setting.useExtendContrast,e.HighContrastCheckbox],[!0,e.InvertContrastCheckbox]]});0!=t.userParams.Font&&c({fieldset_id:e.DyslexiaFieldset.id,legend_text:e.DyslexiaLegend.lang[i],checkboxes:[[!0,e.DefaultFontCheckbox],[!0,e.DyslexiaFontCheckbox]]});0!=t.userParams.LineSpacing&&c({fieldset_id:e.LineSpacingFieldset.id,legend_text:e.LineSpacingLegend.lang[i],checkboxes:[[!0,e.DefaultLineSpacingCheckbox],[!0,e.DyslexiaLineSpacingCheckbox]]});0!=t.userParams.Justification&&c({fieldset_id:e.JustificationFieldset.id,legend_text:e.JustificationLegend.lang[i],checkboxes:[[!0,e.DefaultJustificationCheckbox],[!0,e.DyslexiaJustificationCheckbox]]});0!=t.userParams.ImageReplacement&&c({fieldset_id:e.ImageReplacementFieldset.id,legend_text:e.ImageReplacementLegend.lang[i],checkboxes:[[!0,e.DefaultImageReplacementCheckbox],[!0,e.ImageReplacementCheckbox]]});const l=s.querySelectorAll("fieldset");for(let n=0,i=l.length;n<i;n++)t.userParams.FormFieldset?l[n].classList.add(a+t.userParams.FormFieldset):l[n].classList.add(`${a}-${e.FormFieldset.classSetting}`);const d=s.querySelectorAll("legend");for(let n=0,i=d.length;n<i;n++)t.userParams.FormFieldsetLegend?d[n].classList.add(a+t.userParams.FormFieldsetLegend):d[n].classList.add(`${a}-${e.LegendFieldset.classSetting}`);const r=s.querySelectorAll('input[type="radio"]');for(let n=0,i=r.length;n<i;n++)t.userParams.FormRadio?r[n].classList.add(a+t.userParams.FormRadio):r[n].classList.add(`${a}-${e.FormRadio.classSetting}`);const u=document.querySelector("body"),m=u.firstChild;1!=t.userParams.Modal&&void 0!==t.userParams.Modal||u.insertBefore(s,m)}(),1==t.userParams.Modal||void 0===t.userParams.Modal){const t=document.createElement("button");if(t.setAttribute("id",`${a}-${e.ModalButton.id}`),t.setAttribute("data-accessconfig-button","true"),document.querySelector("[data-accessconfig-buttonname]")&&!document.querySelector('[id="accessconfig-buttonname-extension"]')){const e=document.querySelector("[data-accessconfig-buttonname]"),a=document.createTextNode(e.getAttribute("data-accessconfig-buttonname")),n=document.createElement("span");n.appendChild(a),t.appendChild(n)}else document.querySelector('[id="accessconfig-buttonname-extension"]')&&""!=document.querySelector('[id="accessconfig-buttonname-extension"]').innerHTML&&t.appendChild(document.querySelector('[id="accessconfig-buttonname-extension"]'));document.querySelector("[data-accessconfig-buttontitle]")&&""!=document.querySelector("[data-accessconfig-buttontitle]").getAttribute("data-accessconfig-buttontitle")&&t.setAttribute("title",document.querySelector("[data-accessconfig-buttontitle]").getAttribute("data-accessconfig-buttontitle"));document.getElementById(e.Setup.id).appendChild(t);const n=document.querySelectorAll('[data-accessconfig-button="true"]');for(let e=0,t=n.length;e<t;e++)n[e].addEventListener("click",(function(){c(this)}),!1)}0!=t.userParams.Contrast&&(t.mode=`${a}-${e.ContrastFieldset.id}`,t.cookieName="contrast",n()),0!=t.userParams.Font&&(t.mode=`${a}-${e.DyslexiaFieldset.id}`,t.cookieName="font",n()),0!=t.userParams.LineSpacing&&(t.mode=`${a}-${e.LineSpacingFieldset.id}`,t.cookieName="line-spacing",n()),0!=t.userParams.Justification&&(t.mode=`${a}-${e.JustificationFieldset.id}`,t.cookieName="justification",n()),0!=t.userParams.ImageReplacement&&(t.mode=`${a}-${e.ImageReplacementFieldset.id}`,t.cookieName="image",function(){t.imgSpan=new Array;const n=`.${a}-${e.ImageReplacementCSS.replacementCss}`;t.imgTab=document.querySelectorAll(n);for(let n=0,i=t.imgTab.length;n<i;n++){const i=document.createElement("span"),s=t.imgTab[n].getAttribute("alt"),o=document.createTextNode(s);i.appendChild(o),i.classList.add(`${a}-${e.ImageReplacementCSS.replacementCss}`),i.classList.add(`${a}-${e.ImageReplacementCSS.replacementStyle}`),t.imgSpan[n]=i}}(),n())}}();
