@m00rl0ck/a11y-widget 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var b=Object.defineProperty;var g=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>g(o,typeof t!="symbol"?t+"":t,e);var n={uk:{panelTitle:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",panelSubtitle:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.",closeLabel:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",fontSizeLabel:"\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:",themeLabel:"\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:",extraLabel:"\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:",readableFont:"\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442",letterSpacing:"\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438",reset:"\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443",toggleLabel:"\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",toggleText:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443"},en:{panelTitle:"Vision Accessibility",panelSubtitle:"Adjust text size, contrast, and readability of the site.",closeLabel:"Close panel",fontSizeLabel:"Font size:",themeLabel:"Color scheme:",extraLabel:"Additional:",readableFont:"Readable font",letterSpacing:"Letter spacing",reset:"Default view",toggleLabel:"Open vision accessibility settings",toggleText:"Vision accessibility"},de:{panelTitle:"Barrierefreiheit",panelSubtitle:"Passen Sie Schriftgr\xF6\xDFe, Kontrast und Lesbarkeit der Seite an.",closeLabel:"Schlie\xDFen",fontSizeLabel:"Schriftgr\xF6\xDFe:",themeLabel:"Farbschema:",extraLabel:"Zus\xE4tzlich:",readableFont:"Lesbare Schrift",letterSpacing:"Buchstabenabstand",reset:"Standardansicht",toggleLabel:"Barrierefreiheit-Einstellungen \xF6ffnen",toggleText:"Barrierefreiheit"}};function h(){let t=(document.documentElement.lang||navigator.language||"en").slice(0,2).toLowerCase();return t in n?t:"en"}var r="vision-a11y-settings",p="vision-a11y-global-styles",c={fontSize:"normal",theme:"default",letterSpacing:!1,readableFont:!1},l=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._state={...c,open:!1}}get lang(){return this.getAttribute("lang")||h()}t(t){let e=n[this.lang]||n.en;return this._getLabelOverrides()[t]||e[t]||t}_getLabelOverrides(){let t={"label-title":"panelTitle","label-subtitle":"panelSubtitle","label-reset":"reset"},e={};for(let[a,s]of Object.entries(t)){let i=this.getAttribute(a);i&&(e[s]=i)}return e}connectedCallback(){this._loadState(),this._render(),this._applySettings()}attributeChangedCallback(){this.shadowRoot.innerHTML&&this._render()}_loadState(){try{let t=JSON.parse(localStorage.getItem(r));t&&(this._state={...c,...t,open:!1})}catch{}}_saveState(){let{open:t,...e}=this._state;localStorage.setItem(r,JSON.stringify(e))}_setState(t){this._state={...this._state,...t},this._saveState(),this._render(),this._applySettings()}_reset(){localStorage.removeItem(r),this._state={...c,open:!1},this._render(),this._applySettings()}_applySettings(){let t=document.documentElement;t.classList.remove("va-font-normal","va-font-large","va-font-xlarge","va-theme-default","va-theme-contrast","va-theme-light","va-readable-font","va-letter-spacing"),t.classList.add(`va-font-${this._state.fontSize}`),t.classList.add(`va-theme-${this._state.theme}`),this._state.readableFont&&t.classList.add("va-readable-font"),this._state.letterSpacing&&t.classList.add("va-letter-spacing"),this._ensureGlobalStyles()}_ensureGlobalStyles(){if(document.getElementById(p))return;let t=document.createElement("style");t.id=p,t.textContent=`
1
+ var L=Object.defineProperty;var k=(o,t,e)=>t in o?L(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>k(o,typeof t!="symbol"?t+"":t,e);var p={uk:{panelTitle:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",panelSubtitle:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0440\u043E\u0437\u043C\u0456\u0440 \u0442\u0435\u043A\u0441\u0442\u0443, \u043A\u043E\u043D\u0442\u0440\u0430\u0441\u0442 \u0456 \u0447\u0438\u0442\u0430\u0431\u0435\u043B\u044C\u043D\u0456\u0441\u0442\u044C \u0441\u0430\u0439\u0442\u0443.",closeLabel:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",fontSizeLabel:"\u0420\u043E\u0437\u043C\u0456\u0440 \u0448\u0440\u0438\u0444\u0442\u0443:",themeLabel:"\u041A\u043E\u043B\u0456\u0440 \u0441\u0430\u0439\u0442\u0443:",extraLabel:"\u0414\u043E\u0434\u0430\u0442\u043A\u043E\u0432\u043E:",readableFont:"\u041F\u0440\u043E\u0441\u0442\u0438\u0439 \u0448\u0440\u0438\u0444\u0442",letterSpacing:"\u0411\u0456\u043B\u044C\u0448\u0456 \u0456\u043D\u0442\u0435\u0440\u0432\u0430\u043B\u0438",reset:"\u0417\u0432\u0438\u0447\u0430\u0439\u043D\u0430 \u0432\u0435\u0440\u0441\u0456\u044F \u0441\u0430\u0439\u0442\u0443",toggleLabel:"\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443",toggleText:"\u041B\u044E\u0434\u044F\u043C \u0456\u0437 \u043F\u043E\u0440\u0443\u0448\u0435\u043D\u043D\u044F\u043C \u0437\u043E\u0440\u0443"},en:{panelTitle:"Vision Accessibility",panelSubtitle:"Adjust text size, contrast, and readability of the site.",closeLabel:"Close panel",fontSizeLabel:"Font size:",themeLabel:"Color scheme:",extraLabel:"Additional:",readableFont:"Readable font",letterSpacing:"Letter spacing",reset:"Default view",toggleLabel:"Open vision accessibility settings",toggleText:"Vision accessibility"},de:{panelTitle:"Barrierefreiheit",panelSubtitle:"Passen Sie Schriftgr\xF6\xDFe, Kontrast und Lesbarkeit der Seite an.",closeLabel:"Schlie\xDFen",fontSizeLabel:"Schriftgr\xF6\xDFe:",themeLabel:"Farbschema:",extraLabel:"Zus\xE4tzlich:",readableFont:"Lesbare Schrift",letterSpacing:"Buchstabenabstand",reset:"Standardansicht",toggleLabel:"Barrierefreiheit-Einstellungen \xF6ffnen",toggleText:"Barrierefreiheit"}};function x(){let t=(document.documentElement.lang||navigator.language||"en").slice(0,2).toLowerCase();return t in p?t:"en"}var f="vision-a11y-settings",y="vision-a11y-global-styles",g={fontSize:"normal",theme:"default",letterSpacing:!1,readableFont:!1},r=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._state={...g,open:!1}}get lang(){return this.getAttribute("lang")||x()}t(t){let e=p[this.lang]||p.en;return this._getLabelOverrides()[t]||e[t]||t}_getLabelOverrides(){let t={"label-title":"panelTitle","label-subtitle":"panelSubtitle","label-reset":"reset"},e={};for(let[a,i]of Object.entries(t)){let s=this.getAttribute(a);s&&(e[i]=s)}return e}connectedCallback(){this._loadState(),this._render(),this._applySettings()}attributeChangedCallback(){this.shadowRoot.innerHTML&&this._render()}_loadState(){try{let t=JSON.parse(localStorage.getItem(f));t&&(this._state={...g,...t,open:!1})}catch{}}_saveState(){let{open:t,...e}=this._state;localStorage.setItem(f,JSON.stringify(e))}_setState(t){this._state={...this._state,...t},this._saveState(),this._render(),this._applySettings()}_reset(){localStorage.removeItem(f),this._state={...g,open:!1},this._render(),this._applySettings()}_applySettings(){let t=document.documentElement;t.classList.remove("va-font-normal","va-font-large","va-font-xlarge","va-theme-default","va-theme-contrast","va-theme-light","va-readable-font","va-letter-spacing"),t.classList.add(`va-font-${this._state.fontSize}`),t.classList.add(`va-theme-${this._state.theme}`),this._state.readableFont&&t.classList.add("va-readable-font"),this._state.letterSpacing&&t.classList.add("va-letter-spacing"),this._ensureGlobalStyles()}_ensureGlobalStyles(){if(document.getElementById(y))return;let t=document.createElement("style");t.id=y,t.textContent=`
2
2
  html.va-font-large { font-size: 112.5%; }
3
3
  html.va-font-xlarge { font-size: 125%; }
4
4
 
@@ -243,5 +243,477 @@ var b=Object.defineProperty;var g=(o,t,e)=>t in o?b(o,t,{enumerable:!0,configura
243
243
  <span>${this.t("toggleText")}</span>
244
244
  </button>
245
245
  </div>
246
- `,this.shadowRoot.querySelector(".toggle").addEventListener("click",()=>{this._setState({open:!this._state.open})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>{this._setState({open:!1})}),this.shadowRoot.querySelectorAll("[data-font]").forEach(a=>{a.addEventListener("click",()=>this._setState({fontSize:a.dataset.font}))}),this.shadowRoot.querySelectorAll("[data-theme]").forEach(a=>{a.addEventListener("click",()=>this._setState({theme:a.dataset.theme}))}),this.shadowRoot.querySelectorAll("[data-toggle]").forEach(a=>{a.addEventListener("click",()=>this._setState({[a.dataset.toggle]:!this._state[a.dataset.toggle]}))}),this.shadowRoot.querySelector(".reset").addEventListener("click",()=>this._reset())}_getPositionStyles(){let t=this.getAttribute("position")||"right-bottom",[e,a]=t.split("-"),s={};return e==="right"?s.right="20px":s.left="20px",a==="bottom"?s.bottom="20px":s.top="20px",Object.entries(s).map(([i,f])=>`${i}: ${f};`).join(" ")}};d(l,"observedAttributes",["lang","position","label-title","label-subtitle","label-reset"]);var m=l;customElements.get("vision-accessibility-widget")||customElements.define("vision-accessibility-widget",l);export{m as VisionA11y,l as VisionAccessibilityWidget};
246
+ `,this.shadowRoot.querySelector(".toggle").addEventListener("click",()=>{this._setState({open:!this._state.open})}),this.shadowRoot.querySelector(".close").addEventListener("click",()=>{this._setState({open:!1})}),this.shadowRoot.querySelectorAll("[data-font]").forEach(a=>{a.addEventListener("click",()=>this._setState({fontSize:a.dataset.font}))}),this.shadowRoot.querySelectorAll("[data-theme]").forEach(a=>{a.addEventListener("click",()=>this._setState({theme:a.dataset.theme}))}),this.shadowRoot.querySelectorAll("[data-toggle]").forEach(a=>{a.addEventListener("click",()=>this._setState({[a.dataset.toggle]:!this._state[a.dataset.toggle]}))}),this.shadowRoot.querySelector(".reset").addEventListener("click",()=>this._reset())}_getPositionStyles(){let t=this.getAttribute("position")||"right-bottom",[e,a]=t.split("-"),i={};return e==="right"?i.right="20px":i.left="20px",a==="bottom"?i.bottom="20px":i.top="20px",Object.entries(i).map(([s,n])=>`${s}: ${n};`).join(" ")}};d(r,"observedAttributes",["lang","position","label-title","label-subtitle","label-reset"]);var q=r;customElements.get("vision-accessibility-widget")||customElements.define("vision-accessibility-widget",r);var h={uk:{toggleText:"\u0414\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C",toggleLabel:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0441\u0430\u0439\u0442 \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439 \u0456\u0437 \u0434\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C\u043E\u043C",closeLabel:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u043F\u0430\u043D\u0435\u043B\u044C",panelTitle:"\u041D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0434\u043B\u044F \u0434\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C\u0443",panelSubtitle:"\u041F\u0440\u043E\u0439\u0434\u0456\u0442\u044C \u0448\u0432\u0438\u0434\u043A\u0438\u0439 \u0442\u0435\u0441\u0442 \u0430\u0431\u043E \u043E\u0431\u0435\u0440\u0456\u0442\u044C \u0441\u0432\u0456\u0439 \u0442\u0438\u043F \u0437\u043E\u0440\u0443.",testTab:"\u0422\u0435\u0441\u0442",manualTab:"\u0412\u0440\u0443\u0447\u043D\u0443",startTest:"\u0420\u043E\u0437\u043F\u043E\u0447\u0430\u0442\u0438 \u0442\u0435\u0441\u0442",nextQuestion:"\u0414\u0430\u043B\u0456",question1:"\u042F\u043A\u0438\u0439 \u043A\u043E\u043B\u0456\u0440 \u0432\u0438 \u0431\u0430\u0447\u0438\u0442\u0435 \u0432 \u0446\u0435\u043D\u0442\u0440\u0456?",question2:"\u042F\u043A\u0435 \u0447\u0438\u0441\u043B\u043E \u0431\u0430\u0447\u0438\u0442\u0435?",question3:"\u042F\u043A\u0438\u0439 \u043A\u0432\u0430\u0434\u0440\u0430\u0442 \u044F\u0441\u043A\u0440\u0430\u0432\u0456\u0448\u0438\u0439?",optRedGreen:"\u0427\u0435\u0440\u0432\u043E\u043D\u0438\u0439 / \u0417\u0435\u043B\u0435\u043D\u0438\u0439",optBlueYellow:"\u0421\u0438\u043D\u0456\u0439 / \u0416\u043E\u0432\u0442\u0438\u0439",optNone:"\u041D\u0435 \u0431\u0430\u0447\u0443 \u0440\u0456\u0437\u043D\u0438\u0446\u0456",optNumber74:"74",optNumber21:"21",optNoNumber:"\u041D\u0435 \u0431\u0430\u0447\u0443 \u0447\u0438\u0441\u043B\u0430",optLeft:"\u041B\u0456\u0432\u0438\u0439",optRight:"\u041F\u0440\u0430\u0432\u0438\u0439",optSame:"\u041E\u0434\u043D\u0430\u043A\u043E\u0432\u0456",resultTitle:"\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u0442\u0435\u0441\u0442\u0443",resultDesc:"\u0421\u0445\u043E\u0436\u0435, \u0443 \u0432\u0430\u0441 {type}. \u0421\u0430\u0439\u0442 \u043F\u0456\u0434\u043B\u0430\u0448\u0442\u043E\u0432\u0430\u043D\u043E.",typeNormal:"\u043D\u043E\u0440\u043C\u0430\u043B\u044C\u043D\u0438\u0439 \u0437\u0456\u0440",typeDeuteranopia:"\u0434\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C \u043D\u0430 \u0437\u0435\u043B\u0435\u043D\u0438\u0439 (deuteranopia)",typeProtanopia:"\u0434\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C \u043D\u0430 \u0447\u0435\u0440\u0432\u043E\u043D\u0438\u0439 (protanopia)",typeTritanopia:"\u0434\u0430\u043B\u044C\u0442\u043E\u043D\u0456\u0437\u043C \u043D\u0430 \u0441\u0438\u043D\u0456\u0439 (tritanopia)",typeMonochromacy:"\u043F\u043E\u0432\u043D\u0430 \u0432\u0456\u0434\u0441\u0443\u0442\u043D\u0456\u0441\u0442\u044C \u043A\u043E\u043B\u044C\u043E\u0440\u043E\u0432\u043E\u0433\u043E \u0437\u043E\u0440\u0443 (monochromacy)",selectType:"\u041E\u0431\u0435\u0440\u0456\u0442\u044C \u0432\u0430\u0448 \u0442\u0438\u043F \u0437\u043E\u0440\u0443:",deuteranopia:"\u041D\u0435 \u0440\u043E\u0437\u0440\u0456\u0437\u043D\u044F\u044E \u0437\u0435\u043B\u0435\u043D\u0438\u0439",protanopia:"\u041D\u0435 \u0440\u043E\u0437\u0440\u0456\u0437\u043D\u044F\u044E \u0447\u0435\u0440\u0432\u043E\u043D\u0438\u0439",tritanopia:"\u041D\u0435 \u0440\u043E\u0437\u0440\u0456\u0437\u043D\u044F\u044E \u0441\u0438\u043D\u0456\u0439",monochromacy:"\u0427\u043E\u0440\u043D\u043E-\u0431\u0456\u043B\u0438\u0439 \u0437\u0456\u0440",apply:"\u0417\u0430\u0441\u0442\u043E\u0441\u0443\u0432\u0430\u0442\u0438",reset:"\u0421\u043A\u0438\u043D\u0443\u0442\u0438 \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F",severity:"\u0421\u0442\u0443\u043F\u0456\u043D\u044C:",mild:"\u041B\u0435\u0433\u043A\u0430",moderate:"\u041F\u043E\u043C\u0456\u0440\u043D\u0430",severe:"\u0421\u0438\u043B\u044C\u043D\u0430"},en:{toggleText:"Colorblind",toggleLabel:"Adapt website for colorblind users",closeLabel:"Close panel",panelTitle:"Colorblind Settings",panelSubtitle:"Take a quick test or select your vision type.",testTab:"Test",manualTab:"Manual",startTest:"Start test",nextQuestion:"Next",question1:"What color do you see in the center?",question2:"What number do you see?",question3:"Which square is brighter?",optRedGreen:"Red / Green",optBlueYellow:"Blue / Yellow",optNone:"No difference",optNumber74:"74",optNumber21:"21",optNoNumber:"No number",optLeft:"Left",optRight:"Right",optSame:"Same",resultTitle:"Test result",resultDesc:"It appears you have {type}. The site has been adapted.",typeNormal:"normal vision",typeDeuteranopia:"green-blindness (deuteranopia)",typeProtanopia:"red-blindness (protanopia)",typeTritanopia:"blue-blindness (tritanopia)",typeMonochromacy:"complete color blindness (monochromacy)",selectType:"Select your vision type:",deuteranopia:"Cannot distinguish green",protanopia:"Cannot distinguish red",tritanopia:"Cannot distinguish blue",monochromacy:"Black and white vision",apply:"Apply",reset:"Reset settings",severity:"Severity:",mild:"Mild",moderate:"Moderate",severe:"Severe"},de:{toggleText:"Farbenblindheit",toggleLabel:"Website f\xFCr Farbenblinde anpassen",closeLabel:"Schlie\xDFen",panelTitle:"Farbenblind-Einstellungen",panelSubtitle:"Machen Sie einen schnellen Test oder w\xE4hlen Sie Ihren Sehtyp.",testTab:"Test",manualTab:"Manuell",startTest:"Test starten",nextQuestion:"Weiter",question1:"Welche Farbe sehen Sie in der Mitte?",question2:"Welche Zahl sehen Sie?",question3:"Welches Quadrat ist heller?",optRedGreen:"Rot / Gr\xFCn",optBlueYellow:"Blau / Gelb",optNone:"Kein Unterschied",optNumber74:"74",optNumber21:"21",optNoNumber:"Keine Zahl",optLeft:"Links",optRight:"Rechts",optSame:"Gleich",resultTitle:"Testergebnis",resultDesc:"Sie haben wahrscheinlich {type}. Die Website wurde angepasst.",typeNormal:"normales Sehen",typeDeuteranopia:"Gr\xFCnblindheit (Deuteranopie)",typeProtanopia:"Rotblindheit (Protanopie)",typeTritanopia:"Blaublindheit (Tritanopie)",typeMonochromacy:"vollst\xE4ndige Farbenblindheit (Monochromasie)",selectType:"W\xE4hlen Sie Ihren Sehtyp:",deuteranopia:"Kann Gr\xFCn nicht unterscheiden",protanopia:"Kann Rot nicht unterscheiden",tritanopia:"Kann Blau nicht unterscheiden",monochromacy:"Schwarz-Wei\xDF-Sehen",apply:"Anwenden",reset:"Zur\xFCcksetzen",severity:"St\xE4rke:",mild:"Leicht",moderate:"M\xE4\xDFig",severe:"Stark"}};function _(){let t=(document.documentElement.lang||navigator.language||"en").slice(0,2).toLowerCase();return t in h?t:"en"}var c=[{id:"q1",promptKey:"question1",options:[{labelKey:"optRedGreen",value:"red-green"},{labelKey:"optBlueYellow",value:"blue-yellow"},{labelKey:"optNone",value:"none"}]},{id:"q2",promptKey:"question2",options:[{labelKey:"optNumber74",value:"number"},{labelKey:"optNumber21",value:"number"},{labelKey:"optNoNumber",value:"none"}]},{id:"q3",promptKey:"question3",options:[{labelKey:"optLeft",value:"left"},{labelKey:"optRight",value:"right"},{labelKey:"optSame",value:"same"}]}];function S(o){let t=0,e=0,a=0,i=0;o.q1==="red-green"?(e+=3,t+=3):o.q1==="none"&&(i+=2),o.q2==="none"&&(t+=3,e+=2,i+=2),o.q3==="same"&&(i+=3,t+=1,e+=1);let s=[{type:"monochromacy",score:i},{type:"deuteranopia",score:t},{type:"protanopia",score:e},{type:"tritanopia",score:a}];if(s.sort(($,z)=>z.score-$.score),s[0].score===0)return{type:"normal",severity:"none"};let n=s[0].score,v=s[1].score,M=v>0?n/v:99,m="mild";return n>=7?m="severe":n>=4&&(m="moderate"),{type:s[0].type,severity:m}}var w="colorblind-adapt-styles";function T(o,t){if(b(),o==="normal"||!o)return;let e=document.createElement("style");e.id=w,e.textContent=R(o,t||"moderate"),document.head.appendChild(e)}function b(){document.getElementById(w)?.remove()}function R(o,t){return[A(o,t==="severe"?1:t==="moderate"?.6:.3)].join(`
247
+ `)}function A(o,t){switch(o){case"deuteranopia":return E(t);case"protanopia":return C(t);case"tritanopia":return N(t);case"monochromacy":return K(t);default:return""}}function E(o){return`
248
+ html[data-cba-active] * {
249
+ --cba-green: hsl(140, ${30*o}%, 50%);
250
+ --cba-red: hsl(0, 100%, 40%);
251
+ --cba-bg: hsl(220, ${5*o}%, 97%);
252
+ }
253
+ html[data-cba-active] a,
254
+ html[data-cba-active] a:visited {
255
+ text-decoration: underline;
256
+ text-decoration-thickness: 2px;
257
+ }
258
+ html[data-cba-active] .success,
259
+ html[data-cba-active] [class*="success"],
260
+ html[data-cba-active] [class*="valid"],
261
+ html[data-cba-active] [class*="positive"] {
262
+ color: #0055aa !important;
263
+ border-color: #0055aa !important;
264
+ }
265
+ html[data-cba-active] .error,
266
+ html[data-cba-active] [class*="error"],
267
+ html[data-cba-active] [class*="invalid"],
268
+ html[data-cba-active] [class*="danger"],
269
+ html[data-cba-active] [class*="negative"] {
270
+ color: #cc4400 !important;
271
+ border-color: #cc4400 !important;
272
+ }
273
+ html[data-cba-active] button:not([class*="active"]):not([class*="selected"]):not([class*="primary"]) {
274
+ border: 2px solid currentColor;
275
+ }
276
+ `}function C(o){return`
277
+ html[data-cba-active] * {
278
+ --cba-red: hsl(10, ${80*o}%, 40%);
279
+ --cba-green: hsl(140, ${60*o}%, 40%);
280
+ --cba-bg: hsl(220, ${5*o}%, 97%);
281
+ }
282
+ html[data-cba-active] a,
283
+ html[data-cba-active] a:visited {
284
+ text-decoration: underline;
285
+ text-decoration-thickness: 2px;
286
+ }
287
+ html[data-cba-active] .success,
288
+ html[data-cba-active] [class*="success"],
289
+ html[data-cba-active] [class*="valid"],
290
+ html[data-cba-active] [class*="positive"] {
291
+ color: #007744 !important;
292
+ border-color: #007744 !important;
293
+ }
294
+ html[data-cba-active] .error,
295
+ html[data-cba-active] [class*="error"],
296
+ html[data-cba-active] [class*="invalid"],
297
+ html[data-cba-active] [class*="danger"],
298
+ html[data-cba-active] [class*="negative"] {
299
+ color: #cc0033 !important;
300
+ border-color: #cc0033 !important;
301
+ }
302
+ html[data-cba-active] button:not([class*="active"]):not([class*="selected"]):not([class*="primary"]) {
303
+ border: 2px solid currentColor;
304
+ }
305
+ `}function N(o){return`
306
+ html[data-cba-active] * {
307
+ --cba-blue: hsl(200, ${80*o}%, 45%);
308
+ --cba-yellow: hsl(40, ${80*o}%, 50%);
309
+ --cba-bg: hsl(220, ${5*o}%, 97%);
310
+ }
311
+ html[data-cba-active] a,
312
+ html[data-cba-active] a:visited {
313
+ text-decoration: underline;
314
+ text-decoration-style: dotted;
315
+ text-decoration-thickness: 2px;
316
+ }
317
+ html[data-cba-active] [class*="blue"],
318
+ html[data-cba-active] [class*="info"],
319
+ html[data-cba-active] [class*="primary"] {
320
+ color: #0066aa !important;
321
+ border-color: #0066aa !important;
322
+ }
323
+ html[data-cba-active] [class*="yellow"],
324
+ html[data-cba-active] [class*="warning"] {
325
+ color: #885500 !important;
326
+ border-color: #885500 !important;
327
+ }
328
+ html[data-cba-active] button:not([class*="active"]):not([class*="selected"]):not([class*="primary"]) {
329
+ border: 2px solid currentColor;
330
+ }
331
+ `}function K(o){return`
332
+ html[data-cba-active] {
333
+ filter: grayscale(${o});
334
+ }
335
+ html[data-cba-active] img,
336
+ html[data-cba-active] video,
337
+ html[data-cba-active] canvas {
338
+ filter: grayscale(${o});
339
+ }
340
+ html[data-cba-active] a {
341
+ text-decoration: underline;
342
+ text-decoration-thickness: 2px;
343
+ font-weight: 700;
344
+ }
345
+ html[data-cba-active] [class*="error"],
346
+ html[data-cba-active] [class*="danger"],
347
+ html[data-cba-active] [class*="negative"],
348
+ html[data-cba-active] [class*="invalid"] {
349
+ border-left: 4px solid #666 !important;
350
+ padding-left: 8px !important;
351
+ }
352
+ html[data-cba-active] [class*="success"],
353
+ html[data-cba-active] [class*="valid"],
354
+ html[data-cba-active] [class*="positive"] {
355
+ border-left: 4px solid #999 !important;
356
+ padding-left: 8px !important;
357
+ }
358
+ html[data-cba-active] button,
359
+ html[data-cba-active] .btn,
360
+ html[data-cba-active] [role="button"] {
361
+ border: 2px solid currentColor;
362
+ }
363
+ html[data-cba-active] button:hover,
364
+ html[data-cba-active] .btn:hover {
365
+ outline: 3px solid #ffcc00;
366
+ outline-offset: 2px;
367
+ }
368
+ `}var u="colorblind-adapt-settings",l=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._open=!1,this._tab="test",this._quizAnswers={},this._quizStep=0,this._quizDone=!1,this._quizResult=null,this._activeType=null,this._activeSeverity="moderate"}get lang(){return this.getAttribute("lang")||_()}t(t){return(h[this.lang]||h.en)[t]||t}connectedCallback(){this._loadState(),this._render(),this._applyAdaptation()}attributeChangedCallback(){this.shadowRoot.innerHTML&&this._render()}_loadState(){try{let t=JSON.parse(localStorage.getItem(u));t&&t.type&&(this._activeType=t.type,this._activeSeverity=t.severity||"moderate")}catch{}}_saveState(){this._activeType?localStorage.setItem(u,JSON.stringify({type:this._activeType,severity:this._activeSeverity})):localStorage.removeItem(u)}_setOpen(t){this._open=t,this._render()}_switchTab(t){this._tab=t,t==="test"&&(this._quizAnswers={},this._quizStep=0,this._quizDone=!1,this._quizResult=null),this._render()}_answerQuestion(t){let e=c[this._quizStep];e&&(this._quizAnswers[e.id]=t,this._quizStep<c.length-1?(this._quizStep++,this._render()):(this._quizResult=S(this._quizAnswers),this._quizDone=!0,this._activeType=this._quizResult.type,this._activeSeverity=this._quizResult.severity,this._saveState(),this._applyAdaptation(),this._render()))}_selectType(t){this._activeType=t,this._saveState(),this._applyAdaptation(),this._render()}_setSeverity(t){this._activeSeverity=t,this._activeType&&(this._saveState(),this._applyAdaptation()),this._render()}_reset(){this._activeType=null,this._activeSeverity="moderate",this._quizAnswers={},this._quizStep=0,this._quizDone=!1,this._quizResult=null,this._tab="test",localStorage.removeItem(u),b(),document.documentElement.removeAttribute("data-cba-active"),this._render()}_applyAdaptation(){document.documentElement.removeAttribute("data-cba-active"),b(),this._activeType&&this._activeType!=="normal"&&(document.documentElement.setAttribute("data-cba-active",this._activeType),T(this._activeType,this._activeSeverity))}_render(){let t=a=>this.t(a);this.shadowRoot.innerHTML=`
369
+ <style>
370
+ :host {
371
+ position: fixed;
372
+ right: 20px;
373
+ bottom: 80px;
374
+ z-index: 99999;
375
+ font-family: Arial, Helvetica, sans-serif;
376
+ }
377
+ * { box-sizing: border-box; }
378
+ .widget {
379
+ display: flex;
380
+ flex-direction: column;
381
+ align-items: flex-end;
382
+ gap: 10px;
383
+ }
384
+ .toggle {
385
+ display: inline-flex;
386
+ align-items: center;
387
+ gap: 8px;
388
+ border: 2px solid #111;
389
+ border-radius: 999px;
390
+ padding: 12px 16px;
391
+ background: #fff;
392
+ color: #111;
393
+ font-size: 15px;
394
+ font-weight: 700;
395
+ cursor: pointer;
396
+ box-shadow: 0 10px 30px rgba(0,0,0,.18);
397
+ transition: transform 160ms ease, box-shadow 160ms ease;
398
+ }
399
+ .toggle:hover {
400
+ transform: translateY(-1px);
401
+ box-shadow: 0 14px 34px rgba(0,0,0,.22);
402
+ }
403
+ .toggle:focus-visible,
404
+ .control:focus-visible,
405
+ .tab:focus-visible {
406
+ outline: 3px solid #ffcc00;
407
+ outline-offset: 3px;
408
+ }
409
+ .panel {
410
+ width: min(360px, calc(100vw - 32px));
411
+ padding: 18px;
412
+ border: 2px solid #111;
413
+ border-radius: 18px;
414
+ background: #fff;
415
+ color: #111;
416
+ box-shadow: 0 18px 50px rgba(0,0,0,.25);
417
+ }
418
+ .panel[hidden] { display: none; }
419
+ .header {
420
+ display: flex;
421
+ align-items: flex-start;
422
+ justify-content: space-between;
423
+ gap: 12px;
424
+ margin-bottom: 14px;
425
+ }
426
+ .title {
427
+ margin: 0;
428
+ font-size: 18px;
429
+ line-height: 1.25;
430
+ font-weight: 800;
431
+ }
432
+ .subtitle {
433
+ margin: 4px 0 0;
434
+ font-size: 13px;
435
+ line-height: 1.4;
436
+ color: #555;
437
+ }
438
+ .close {
439
+ width: 32px; height: 32px;
440
+ border: 1px solid #ddd;
441
+ border-radius: 50%;
442
+ background: #f7f7f7;
443
+ cursor: pointer;
444
+ font-size: 20px;
445
+ line-height: 1;
446
+ }
447
+ .tabs {
448
+ display: flex;
449
+ gap: 4px;
450
+ margin-bottom: 14px;
451
+ background: #f0f0f0;
452
+ border-radius: 10px;
453
+ padding: 3px;
454
+ }
455
+ .tab {
456
+ flex: 1;
457
+ padding: 8px;
458
+ border: none;
459
+ border-radius: 8px;
460
+ background: transparent;
461
+ color: #555;
462
+ font-size: 13px;
463
+ font-weight: 700;
464
+ cursor: pointer;
465
+ transition: background 140ms, color 140ms;
466
+ }
467
+ .tab.active {
468
+ background: #fff;
469
+ color: #111;
470
+ box-shadow: 0 1px 3px rgba(0,0,0,.1);
471
+ }
472
+ .option-grid {
473
+ display: flex;
474
+ flex-direction: column;
475
+ gap: 8px;
476
+ }
477
+ .option {
478
+ display: block;
479
+ width: 100%;
480
+ padding: 12px 14px;
481
+ border: 2px solid #d6d6d6;
482
+ border-radius: 12px;
483
+ background: #fafafa;
484
+ color: #111;
485
+ font-size: 14px;
486
+ font-weight: 700;
487
+ cursor: pointer;
488
+ text-align: left;
489
+ transition: border-color 140ms ease, background 140ms ease;
490
+ }
491
+ .option:hover {
492
+ border-color: #111;
493
+ background: #f0f0f0;
494
+ }
495
+ .option.active {
496
+ border-color: #111;
497
+ background: #111;
498
+ color: #fff;
499
+ }
500
+ .step-indicator {
501
+ font-size: 12px;
502
+ color: #888;
503
+ margin-bottom: 12px;
504
+ }
505
+ .result-card {
506
+ padding: 16px;
507
+ border: 2px solid #111;
508
+ border-radius: 12px;
509
+ background: #fafafa;
510
+ margin-bottom: 12px;
511
+ }
512
+ .result-title {
513
+ font-weight: 800;
514
+ font-size: 16px;
515
+ margin-bottom: 6px;
516
+ }
517
+ .result-desc {
518
+ font-size: 13px;
519
+ line-height: 1.5;
520
+ color: #333;
521
+ }
522
+ .result-type {
523
+ display: inline-block;
524
+ padding: 3px 10px;
525
+ border-radius: 999px;
526
+ background: #111;
527
+ color: #fff;
528
+ font-size: 12px;
529
+ font-weight: 700;
530
+ margin-top: 8px;
531
+ }
532
+ .select-group {
533
+ margin-bottom: 12px;
534
+ }
535
+ .select-label {
536
+ display: block;
537
+ font-weight: 700;
538
+ font-size: 13px;
539
+ margin-bottom: 6px;
540
+ color: #333;
541
+ }
542
+ .select-input {
543
+ width: 100%;
544
+ padding: 10px 12px;
545
+ border: 2px solid #d6d6d6;
546
+ border-radius: 10px;
547
+ font-size: 14px;
548
+ font-weight: 600;
549
+ background: #fafafa;
550
+ color: #111;
551
+ cursor: pointer;
552
+ }
553
+ .select-input:focus {
554
+ border-color: #111;
555
+ outline: none;
556
+ }
557
+ .severity-group {
558
+ display: flex;
559
+ gap: 6px;
560
+ margin-top: 8px;
561
+ }
562
+ .severity-btn {
563
+ flex: 1;
564
+ padding: 8px;
565
+ border: 2px solid #d6d6d6;
566
+ border-radius: 8px;
567
+ background: #fafafa;
568
+ color: #555;
569
+ font-size: 12px;
570
+ font-weight: 700;
571
+ cursor: pointer;
572
+ text-align: center;
573
+ transition: all 140ms;
574
+ }
575
+ .severity-btn.active {
576
+ border-color: #111;
577
+ background: #111;
578
+ color: #fff;
579
+ }
580
+ .action-row {
581
+ display: flex;
582
+ gap: 8px;
583
+ margin-top: 14px;
584
+ }
585
+ .btn-primary {
586
+ flex: 1;
587
+ padding: 10px;
588
+ border: 2px solid #111;
589
+ border-radius: 10px;
590
+ background: #111;
591
+ color: #fff;
592
+ font-weight: 700;
593
+ font-size: 13px;
594
+ cursor: pointer;
595
+ }
596
+ .btn-reset {
597
+ flex: 1;
598
+ padding: 10px;
599
+ border: 2px solid #f0b4b4;
600
+ border-radius: 10px;
601
+ background: #fff4f4;
602
+ color: #8a0000;
603
+ font-weight: 700;
604
+ font-size: 13px;
605
+ cursor: pointer;
606
+ }
607
+ .btn-reset:hover {
608
+ background: #ffe0e0;
609
+ }
610
+ .tag {
611
+ display: inline-block;
612
+ padding: 2px 8px;
613
+ border-radius: 6px;
614
+ font-size: 11px;
615
+ font-weight: 700;
616
+ margin-left: 8px;
617
+ }
618
+ .tag-active {
619
+ background: #111;
620
+ color: #fff;
621
+ }
622
+ @media (max-width: 520px) {
623
+ :host {
624
+ right: 12px !important;
625
+ bottom: 70px !important;
626
+ }
627
+ .toggle { padding: 11px 14px; font-size: 14px; }
628
+ }
629
+ </style>
630
+
631
+ <div class="widget">
632
+ <section class="panel" ${this._open?"":"hidden"} aria-label="${t("panelTitle")}">
633
+ <div class="header">
634
+ <div>
635
+ <h2 class="title">
636
+ ${t("panelTitle")}
637
+ ${this._activeType&&this._activeType!=="normal"?`<span class="tag tag-active">${this._activeType}</span>`:""}
638
+ </h2>
639
+ <p class="subtitle">${t("panelSubtitle")}</p>
640
+ </div>
641
+ <button class="close" type="button" aria-label="${t("closeLabel")}">\xD7</button>
642
+ </div>
643
+
644
+ ${this._renderBody()}
645
+
646
+ ${this._activeType&&this._activeType!=="normal"?`
647
+ <div class="action-row">
648
+ <button class="btn-reset" type="button">${t("reset")}</button>
649
+ </div>
650
+ `:""}
651
+ </section>
652
+
653
+ <button
654
+ class="toggle"
655
+ type="button"
656
+ aria-expanded="${this._open?"true":"false"}"
657
+ aria-label="${t("toggleLabel")}"
658
+ >
659
+ <span class="icon" aria-hidden="true">\u{1F535}</span>
660
+ <span>${t("toggleText")}</span>
661
+ ${this._activeType&&this._activeType!=="normal"?" \u2713":""}
662
+ </button>
663
+ </div>
664
+ `,this.shadowRoot.querySelector(".toggle").addEventListener("click",()=>this._setOpen(!this._open)),this.shadowRoot.querySelector(".close").addEventListener("click",()=>this._setOpen(!1));let e=this.shadowRoot.querySelector(".panel");if(e&&e.querySelectorAll("button[data-answer]").forEach(a=>{a.addEventListener("click",()=>this._answerQuestion(a.dataset.answer))}),this._open&&this._tab==="test"&&!this._quizDone&&this.shadowRoot.querySelectorAll(".tab").forEach(a=>{a.addEventListener("click",()=>this._switchTab(a.dataset.tab))}),this._open&&this._tab==="manual"){let a=this.shadowRoot.querySelector("#cba-type-select");a&&(a.addEventListener("change",()=>this._selectType(a.value)),this.shadowRoot.querySelectorAll("[data-severity]").forEach(n=>{n.addEventListener("click",()=>this._setSeverity(n.dataset.severity))}));let i=this.shadowRoot.querySelector(".btn-reset");i&&i.addEventListener("click",()=>this._reset())}if(this._open&&this._quizDone){let a=this.shadowRoot.querySelector(".btn-reset");a&&a.addEventListener("click",()=>this._reset())}}_renderBody(){let t=e=>this.t(e);return this._activeType&&this._activeType!=="normal"?this._renderActiveState(t):this._quizDone?this._renderResult(t):`
665
+ <div class="tabs">
666
+ <button class="tab ${this._tab==="test"?"active":""}" data-tab="test" type="button">${t("testTab")}</button>
667
+ <button class="tab ${this._tab==="manual"?"active":""}" data-tab="manual" type="button">${t("manualTab")}</button>
668
+ </div>
669
+ ${this._tab==="test"?this._renderQuiz(t):this._renderManual(t)}
670
+ `}_renderQuiz(t){let e=c[this._quizStep];return e?`
671
+ <div class="step-indicator">${t("question"+(this._quizStep+1))} (${this._quizStep+1}/${c.length})</div>
672
+ <p style="font-weight:700;font-size:15px;margin:0 0 12px">${t(e.promptKey)}</p>
673
+ <div class="option-grid">
674
+ ${e.options.map((a,i)=>`
675
+ <button class="option" data-answer="${a.value}" type="button">
676
+ ${t(a.labelKey)}
677
+ </button>
678
+ `).join("")}
679
+ </div>
680
+ `:""}_renderManual(t){let e=["deuteranopia","protanopia","tritanopia","monochromacy"],a=["mild","moderate","severe"];return`
681
+ <div class="select-group">
682
+ <label class="select-label" for="cba-type-select">${t("selectType")}</label>
683
+ <select class="select-input" id="cba-type-select">
684
+ <option value="">\u2014 ${t("selectType")} \u2014</option>
685
+ ${e.map(i=>`
686
+ <option value="${i}" ${this._activeType===i?"selected":""}>
687
+ ${t(i)}
688
+ </option>
689
+ `).join("")}
690
+ </select>
691
+ </div>
692
+ ${this._activeType?`
693
+ <div class="select-group">
694
+ <label class="select-label">${t("severity")}</label>
695
+ <div class="severity-group">
696
+ ${a.map(i=>`
697
+ <button class="severity-btn ${this._activeSeverity===i?"active":""}" data-severity="${i}" type="button">
698
+ ${t(i)}
699
+ </button>
700
+ `).join("")}
701
+ </div>
702
+ </div>
703
+ `:""}
704
+ `}_renderResult(t){let e=this._quizResult;if(!e)return"";let a="type"+e.type.charAt(0).toUpperCase()+e.type.slice(1);return`
705
+ <div class="result-card">
706
+ <div class="result-title">${t("resultTitle")}</div>
707
+ <div class="result-desc">
708
+ ${t("resultDesc").replace("{type}",t(a))}
709
+ </div>
710
+ <span class="result-type">${t(e.severity)} \xB7 ${t(a)}</span>
711
+ </div>
712
+ <button class="btn-reset" type="button">${t("reset")}</button>
713
+ `}_renderActiveState(t){let e=this._quizResult;return`
714
+ <div class="result-card">
715
+ <div class="result-title">${t("resultTitle")}</div>
716
+ <span class="result-type">${this._activeType} \xB7 ${t(this._activeSeverity)}</span>
717
+ </div>
718
+ `}};d(l,"observedAttributes",["lang"]);var B=l;customElements.get("colorblind-adapt-widget")||customElements.define("colorblind-adapt-widget",l);export{B as ColorblindAdapt,l as ColorblindAdaptWidget,q as VisionA11y,r as VisionAccessibilityWidget};
247
719
  //# sourceMappingURL=index.js.map