ufc-itapaje-accessibility 1.0.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 ADDED
@@ -0,0 +1,1939 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/accessibility.ts
21
+ var accessibility_exports = {};
22
+ __export(accessibility_exports, {
23
+ Accessibility: () => main_default,
24
+ AccessibilityModulesType: () => AccessibilityModulesType,
25
+ applyTheme: () => applyTheme,
26
+ createModule: () => createModule,
27
+ createModules: () => createModules,
28
+ createThemeCss: () => createThemeCss,
29
+ default: () => accessibility_default,
30
+ ptBRLabels: () => ptBRLabels,
31
+ removeTheme: () => removeTheme
32
+ });
33
+ module.exports = __toCommonJS(accessibility_exports);
34
+
35
+ // src/main.ts
36
+ var import_runtime = require("regenerator-runtime/runtime.js");
37
+
38
+ // src/common.ts
39
+ var _Common = class _Common {
40
+ constructor() {
41
+ this.body = document.body || document.querySelector("body");
42
+ this.deployedMap = /* @__PURE__ */ new Map();
43
+ }
44
+ isIOS() {
45
+ if (typeof this._isIOS === "boolean") return this._isIOS;
46
+ const devices = ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"];
47
+ this._isIOS = !!navigator.platform && devices.some((d) => navigator.platform === d);
48
+ return this._isIOS;
49
+ }
50
+ jsonToHtml(obj) {
51
+ var _a, _b, _c;
52
+ let elm = document.createElement(obj.type);
53
+ for (let i in obj.attrs) {
54
+ elm.setAttribute(i, obj.attrs[i]);
55
+ }
56
+ for (const child of (_a = obj.children) != null ? _a : []) {
57
+ let newElem = null;
58
+ if (child.type === "#text") {
59
+ newElem = document.createTextNode((_b = child.text) != null ? _b : "");
60
+ } else {
61
+ newElem = this.jsonToHtml(child);
62
+ }
63
+ if (((_c = newElem == null ? void 0 : newElem.tagName) == null ? void 0 : _c.toLowerCase()) !== "undefined" || newElem.nodeType === 3)
64
+ elm.appendChild(newElem);
65
+ }
66
+ return elm;
67
+ }
68
+ injectStyle(css, innerOptions = {}) {
69
+ let sheet = document.createElement("style");
70
+ sheet.appendChild(document.createTextNode(css));
71
+ if (innerOptions.className) sheet.classList.add(innerOptions.className);
72
+ this.body.appendChild(sheet);
73
+ return sheet;
74
+ }
75
+ getFormattedDim(value) {
76
+ if (!value) return null;
77
+ value = String(value);
78
+ const by = (val, suffix) => ({
79
+ size: val.substring(0, val.indexOf(suffix)),
80
+ suffix
81
+ });
82
+ if (value.includes("%")) return by(value, "%");
83
+ if (value.includes("rem")) return by(value, "rem");
84
+ if (value.includes("px")) return by(value, "px");
85
+ if (value.includes("em")) return by(value, "em");
86
+ if (value.includes("pt")) return by(value, "pt");
87
+ if (value === "auto") return by(value, "");
88
+ return null;
89
+ }
90
+ extend(src, dest) {
91
+ for (let i in src) {
92
+ if (typeof src[i] === "object") {
93
+ if (dest && dest[i]) {
94
+ if (dest[i] instanceof Array) src[i] = dest[i];
95
+ else src[i] = this.extend(src[i], dest[i]);
96
+ }
97
+ } else if (typeof dest === "object" && typeof dest[i] !== "undefined") {
98
+ src[i] = dest[i];
99
+ }
100
+ }
101
+ return src;
102
+ }
103
+ injectIconsFont(urls, callback) {
104
+ if (!(urls == null ? void 0 : urls.length)) return;
105
+ let head = document.getElementsByTagName("head")[0];
106
+ let counter = 0;
107
+ let hasErrors = false;
108
+ let onload = (e) => {
109
+ if (typeof e === "string" || e.type === "error") hasErrors = true;
110
+ if (!--counter) callback(hasErrors);
111
+ };
112
+ urls.forEach((url) => {
113
+ let link = document.createElement("link");
114
+ link.type = "text/css";
115
+ link.rel = "stylesheet";
116
+ link.href = url;
117
+ link.className = `_access-font-icon-${counter++}`;
118
+ link.onload = onload;
119
+ link.onerror = onload;
120
+ this.deployedObjects.set("." + link.className, true);
121
+ head.appendChild(link);
122
+ });
123
+ }
124
+ getFixedFont(name) {
125
+ if (this.isIOS()) return name.replaceAll(" ", "+");
126
+ return name;
127
+ }
128
+ getFixedPseudoFont(name) {
129
+ if (this.isIOS()) return name.replaceAll("+", " ");
130
+ return name;
131
+ }
132
+ isFontLoaded(fontFamily, callback) {
133
+ try {
134
+ const onReady = () => callback(document.fonts.check(`1em ${fontFamily.replaceAll("+", " ")}`));
135
+ document.fonts.ready.then(onReady, onReady);
136
+ } catch (e) {
137
+ callback(true);
138
+ }
139
+ }
140
+ warn(msg) {
141
+ const prefix = "AccessibilityWidget: ";
142
+ (console.warn || console.log)(prefix + msg);
143
+ }
144
+ get deployedObjects() {
145
+ return {
146
+ get: (key) => this.deployedMap.get(key),
147
+ contains: (key) => this.deployedMap.has(key),
148
+ set: (key, val) => {
149
+ this.deployedMap.set(key, val);
150
+ },
151
+ remove: (key) => {
152
+ this.deployedMap.delete(key);
153
+ },
154
+ getAll: () => this.deployedMap
155
+ };
156
+ }
157
+ createScreenshot(url) {
158
+ return new Promise((resolve) => {
159
+ if (!this._canvas) this._canvas = document.createElement("canvas");
160
+ const img = new Image();
161
+ this._canvas.style.cssText = "position:fixed;top:0;left:0;opacity:0.05;transform:scale(0.05)";
162
+ img.crossOrigin = "anonymous";
163
+ img.onload = () => {
164
+ document.body.appendChild(this._canvas);
165
+ const ctx = this._canvas.getContext("2d");
166
+ this._canvas.width = img.naturalWidth;
167
+ this._canvas.height = img.naturalHeight;
168
+ ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
169
+ ctx.drawImage(img, 0, 0);
170
+ let res = _Common.DEFAULT_PIXEL;
171
+ try {
172
+ res = this._canvas.toDataURL("image/png");
173
+ } catch (e) {
174
+ }
175
+ resolve(res);
176
+ this._canvas.remove();
177
+ };
178
+ img.onerror = () => resolve(_Common.DEFAULT_PIXEL);
179
+ img.src = url;
180
+ });
181
+ }
182
+ getFileExtension(filename) {
183
+ return filename.substring(filename.lastIndexOf(".") + 1) || filename;
184
+ }
185
+ };
186
+ _Common.DEFAULT_PIXEL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";
187
+ var Common = _Common;
188
+
189
+ // src/interfaces/accessibility.interface.ts
190
+ var AccessibilityModulesType = /* @__PURE__ */ ((AccessibilityModulesType2) => {
191
+ AccessibilityModulesType2[AccessibilityModulesType2["increaseText"] = 1] = "increaseText";
192
+ AccessibilityModulesType2[AccessibilityModulesType2["decreaseText"] = 2] = "decreaseText";
193
+ AccessibilityModulesType2[AccessibilityModulesType2["increaseTextSpacing"] = 3] = "increaseTextSpacing";
194
+ AccessibilityModulesType2[AccessibilityModulesType2["decreaseTextSpacing"] = 4] = "decreaseTextSpacing";
195
+ AccessibilityModulesType2[AccessibilityModulesType2["increaseLineHeight"] = 5] = "increaseLineHeight";
196
+ AccessibilityModulesType2[AccessibilityModulesType2["decreaseLineHeight"] = 6] = "decreaseLineHeight";
197
+ AccessibilityModulesType2[AccessibilityModulesType2["invertColors"] = 7] = "invertColors";
198
+ AccessibilityModulesType2[AccessibilityModulesType2["grayHues"] = 8] = "grayHues";
199
+ AccessibilityModulesType2[AccessibilityModulesType2["bigCursor"] = 9] = "bigCursor";
200
+ AccessibilityModulesType2[AccessibilityModulesType2["readingGuide"] = 10] = "readingGuide";
201
+ AccessibilityModulesType2[AccessibilityModulesType2["underlineLinks"] = 11] = "underlineLinks";
202
+ AccessibilityModulesType2[AccessibilityModulesType2["textToSpeech"] = 12] = "textToSpeech";
203
+ AccessibilityModulesType2[AccessibilityModulesType2["speechToText"] = 13] = "speechToText";
204
+ AccessibilityModulesType2[AccessibilityModulesType2["disableAnimations"] = 14] = "disableAnimations";
205
+ AccessibilityModulesType2[AccessibilityModulesType2["iframeModals"] = 15] = "iframeModals";
206
+ AccessibilityModulesType2[AccessibilityModulesType2["customFunctions"] = 16] = "customFunctions";
207
+ AccessibilityModulesType2[AccessibilityModulesType2["dyslexicFont"] = 17] = "dyslexicFont";
208
+ AccessibilityModulesType2[AccessibilityModulesType2["hideImages"] = 18] = "hideImages";
209
+ return AccessibilityModulesType2;
210
+ })(AccessibilityModulesType || {});
211
+
212
+ // src/menu-interface.ts
213
+ var MenuInterface = class {
214
+ constructor(accessibility) {
215
+ this._acc = accessibility;
216
+ this.readBind = this._acc.read.bind(this._acc);
217
+ }
218
+ updateCycleButton(btn, level, max) {
219
+ if (level > 0) btn.classList.add("active");
220
+ else btn.classList.remove("active");
221
+ let indicator = btn.querySelector("._access-cycle-indicator");
222
+ if (!indicator) {
223
+ indicator = document.createElement("div");
224
+ indicator.className = "_access-cycle-indicator";
225
+ for (let i = 0; i < max; i++) indicator.appendChild(document.createElement("span"));
226
+ btn.appendChild(indicator);
227
+ }
228
+ indicator.querySelectorAll("span").forEach((span, i) => span.classList.toggle("filled", i < level));
229
+ }
230
+ refreshCycleButtons() {
231
+ const find = (action) => {
232
+ var _a;
233
+ return (_a = this._acc.menu) == null ? void 0 : _a.querySelector(`[data-access-action="${action}"]`);
234
+ };
235
+ const t = find("increaseText");
236
+ if (t) this.updateCycleButton(t, this._acc.sessionState.textSize, 3);
237
+ const s = find("increaseTextSpacing");
238
+ if (s) this.updateCycleButton(s, this._acc.sessionState.textSpace, 3);
239
+ const l = find("increaseLineHeight");
240
+ if (l) this.updateCycleButton(l, this._acc.sessionState.lineHeight, 3);
241
+ }
242
+ increaseText(_destroy, btn) {
243
+ if (this._acc.sessionState.textSize >= 3) {
244
+ this._acc.resetTextSize();
245
+ } else {
246
+ this._acc.alterTextSize(true);
247
+ }
248
+ if (btn) this.updateCycleButton(btn, this._acc.sessionState.textSize, 3);
249
+ }
250
+ decreaseText() {
251
+ this._acc.alterTextSize(false);
252
+ }
253
+ increaseTextSpacing(_destroy, btn) {
254
+ if (this._acc.sessionState.textSpace >= 3) {
255
+ this._acc.resetTextSpace();
256
+ } else {
257
+ this._acc.alterTextSpace(true);
258
+ }
259
+ if (btn) this.updateCycleButton(btn, this._acc.sessionState.textSpace, 3);
260
+ }
261
+ decreaseTextSpacing() {
262
+ this._acc.alterTextSpace(false);
263
+ }
264
+ increaseLineHeight(_destroy, btn) {
265
+ if (this._acc.sessionState.lineHeight >= 3) {
266
+ this._acc.resetLineHeight();
267
+ } else {
268
+ this._acc.alterLineHeight(true);
269
+ }
270
+ if (btn) this.updateCycleButton(btn, this._acc.sessionState.lineHeight, 3);
271
+ }
272
+ decreaseLineHeight() {
273
+ this._acc.alterLineHeight(false);
274
+ }
275
+ invertColors(destroy) {
276
+ var _a, _b;
277
+ const counterClass = "_access-invert-counter";
278
+ const removeCounter = () => {
279
+ var _a2;
280
+ return (_a2 = document.querySelector("." + counterClass)) == null ? void 0 : _a2.remove();
281
+ };
282
+ if (typeof this._acc.stateValues.html.backgroundColor === "undefined")
283
+ this._acc.stateValues.html.backgroundColor = getComputedStyle(this._acc.html).backgroundColor;
284
+ if (typeof this._acc.stateValues.html.color === "undefined")
285
+ this._acc.stateValues.html.color = getComputedStyle(this._acc.html).color;
286
+ if (destroy) {
287
+ this._acc.resetIfDefined(this._acc.stateValues.html.backgroundColor, this._acc.html.style, "backgroundColor");
288
+ this._acc.resetIfDefined(this._acc.stateValues.html.color, this._acc.html.style, "color");
289
+ if (!this._acc.options.suppressDomInjection)
290
+ (_a = this._acc.menu.querySelector('[data-access-action="invertColors"]')) == null ? void 0 : _a.classList.remove("active");
291
+ this._acc.stateValues.invertColors = false;
292
+ this._acc.sessionState.invertColors = false;
293
+ this._acc.onChange(true);
294
+ this._acc.html.style.filter = "";
295
+ removeCounter();
296
+ return;
297
+ }
298
+ if (!this._acc.options.suppressDomInjection)
299
+ (_b = this._acc.menu.querySelector('[data-access-action="invertColors"]')) == null ? void 0 : _b.classList.toggle("active");
300
+ this._acc.stateValues.invertColors = !this._acc.stateValues.invertColors;
301
+ this._acc.sessionState.invertColors = this._acc.stateValues.invertColors;
302
+ this._acc.onChange(true);
303
+ if (this._acc.stateValues.invertColors) {
304
+ if (this._acc.stateValues.grayHues) this._acc.menuInterface.grayHues(true);
305
+ this._acc.html.style.filter = "invert(1)";
306
+ this._acc.common.injectStyle("._access { filter: invert(1) !important; }", { className: counterClass });
307
+ this._acc.common.deployedObjects.set("." + counterClass, false);
308
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Colors Inverted");
309
+ } else {
310
+ this._acc.html.style.filter = "";
311
+ removeCounter();
312
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Colors Set To Normal");
313
+ }
314
+ }
315
+ grayHues(destroy) {
316
+ var _a, _b;
317
+ const overlayClass = "_access-gray-overlay";
318
+ const removeOverlay = () => {
319
+ var _a2;
320
+ (_a2 = document.querySelector("." + overlayClass)) == null ? void 0 : _a2.remove();
321
+ };
322
+ if (destroy) {
323
+ if (!this._acc.options.suppressDomInjection)
324
+ (_a = this._acc.menu.querySelector('[data-access-action="grayHues"]')) == null ? void 0 : _a.classList.remove("active");
325
+ this._acc.stateValues.grayHues = false;
326
+ this._acc.sessionState.grayHues = false;
327
+ this._acc.onChange(true);
328
+ removeOverlay();
329
+ return;
330
+ }
331
+ if (!this._acc.options.suppressDomInjection)
332
+ (_b = this._acc.menu.querySelector('[data-access-action="grayHues"]')) == null ? void 0 : _b.classList.toggle("active");
333
+ this._acc.stateValues.grayHues = !this._acc.stateValues.grayHues;
334
+ this._acc.sessionState.grayHues = this._acc.stateValues.grayHues;
335
+ this._acc.onChange(true);
336
+ if (this._acc.stateValues.grayHues) {
337
+ if (this._acc.stateValues.invertColors) this.invertColors(true);
338
+ const overlay = document.createElement("div");
339
+ overlay.className = overlayClass;
340
+ overlay.style.cssText = "position:fixed;inset:0;z-index:9998;backdrop-filter:grayscale(1);-webkit-backdrop-filter:grayscale(1);pointer-events:none;";
341
+ document.body.appendChild(overlay);
342
+ this._acc.common.deployedObjects.set("." + overlayClass, false);
343
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Gray Hues Enabled.");
344
+ } else {
345
+ removeOverlay();
346
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Gray Hues Disabled.");
347
+ }
348
+ }
349
+ underlineLinks(destroy) {
350
+ var _a, _b, _c;
351
+ const className = "_access-underline";
352
+ const remove = () => {
353
+ const style = document.querySelector("." + className);
354
+ if (style) {
355
+ style.parentElement.removeChild(style);
356
+ this._acc.common.deployedObjects.remove("." + className);
357
+ }
358
+ };
359
+ if (destroy) {
360
+ this._acc.stateValues.underlineLinks = false;
361
+ this._acc.sessionState.underlineLinks = false;
362
+ this._acc.onChange(true);
363
+ if (!this._acc.options.suppressDomInjection)
364
+ (_a = this._acc.menu.querySelector('[data-access-action="underlineLinks"]')) == null ? void 0 : _a.classList.remove("active");
365
+ return remove();
366
+ }
367
+ if (!this._acc.options.suppressDomInjection)
368
+ (_b = this._acc.menu.querySelector('[data-access-action="underlineLinks"]')) == null ? void 0 : _b.classList.toggle("active");
369
+ this._acc.stateValues.underlineLinks = !this._acc.stateValues.underlineLinks;
370
+ this._acc.sessionState.underlineLinks = this._acc.stateValues.underlineLinks;
371
+ this._acc.onChange(true);
372
+ if (this._acc.stateValues.underlineLinks) {
373
+ const parts = ((_c = this._acc.options.linkSelector) != null ? _c : "a").split(",").map((s) => s.trim());
374
+ const rules = parts.flatMap((s) => [`body ${s}`, `body ${s} *`]).join(", ");
375
+ this._acc.common.injectStyle(`${rules} { text-decoration: underline !important; }`, { className });
376
+ this._acc.common.deployedObjects.set("." + className, true);
377
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Links UnderLined");
378
+ } else {
379
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Links UnderLine Removed");
380
+ remove();
381
+ }
382
+ }
383
+ bigCursor(destroy) {
384
+ var _a, _b;
385
+ if (destroy) {
386
+ this._acc.html.classList.remove("_access_cursor");
387
+ if (!this._acc.options.suppressDomInjection)
388
+ (_a = this._acc.menu.querySelector('[data-access-action="bigCursor"]')) == null ? void 0 : _a.classList.remove("active");
389
+ this._acc.stateValues.bigCursor = false;
390
+ this._acc.sessionState.bigCursor = false;
391
+ this._acc.onChange(true);
392
+ return;
393
+ }
394
+ if (!this._acc.options.suppressDomInjection)
395
+ (_b = this._acc.menu.querySelector('[data-access-action="bigCursor"]')) == null ? void 0 : _b.classList.toggle("active");
396
+ this._acc.stateValues.bigCursor = !this._acc.stateValues.bigCursor;
397
+ this._acc.sessionState.bigCursor = this._acc.stateValues.bigCursor;
398
+ this._acc.onChange(true);
399
+ this._acc.html.classList.toggle("_access_cursor");
400
+ if (this._acc.stateValues.textToSpeech)
401
+ this._acc.textToSpeech(this._acc.stateValues.bigCursor ? "Big Cursor Enabled" : "Big Cursor Disabled");
402
+ }
403
+ readingGuide(destroy) {
404
+ var _a, _b, _c, _d;
405
+ if (destroy) {
406
+ (_a = document.getElementById("access_read_guide_bar")) == null ? void 0 : _a.remove();
407
+ if (!this._acc.options.suppressDomInjection)
408
+ (_b = this._acc.menu.querySelector('[data-access-action="readingGuide"]')) == null ? void 0 : _b.classList.remove("active");
409
+ this._acc.stateValues.readingGuide = false;
410
+ this._acc.sessionState.readingGuide = false;
411
+ this._acc.onChange(true);
412
+ document.body.removeEventListener("touchmove", this._acc.updateReadGuide, false);
413
+ document.body.removeEventListener("mousemove", this._acc.updateReadGuide, false);
414
+ return;
415
+ }
416
+ if (!this._acc.options.suppressDomInjection)
417
+ (_c = this._acc.menu.querySelector('[data-access-action="readingGuide"]')) == null ? void 0 : _c.classList.toggle("active");
418
+ this._acc.stateValues.readingGuide = !this._acc.stateValues.readingGuide;
419
+ this._acc.sessionState.readingGuide = this._acc.stateValues.readingGuide;
420
+ this._acc.onChange(true);
421
+ if (this._acc.stateValues.readingGuide) {
422
+ const read = document.createElement("div");
423
+ read.id = "access_read_guide_bar";
424
+ read.classList.add("access_read_guide_bar");
425
+ document.body.append(read);
426
+ document.body.addEventListener("touchmove", this._acc.updateReadGuide, false);
427
+ document.body.addEventListener("mousemove", this._acc.updateReadGuide, false);
428
+ } else {
429
+ (_d = document.getElementById("access_read_guide_bar")) == null ? void 0 : _d.remove();
430
+ document.body.removeEventListener("touchmove", this._acc.updateReadGuide, false);
431
+ document.body.removeEventListener("mousemove", this._acc.updateReadGuide, false);
432
+ if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Reading Guide Disabled");
433
+ }
434
+ }
435
+ textToSpeech(destroy) {
436
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
437
+ const tSpeechList = this._acc.menu.querySelector('[data-access-action="textToSpeech"]');
438
+ if (!tSpeechList) return;
439
+ const step1 = document.getElementsByClassName("screen-reader-wrapper-step-1");
440
+ const step2 = document.getElementsByClassName("screen-reader-wrapper-step-2");
441
+ const step3 = document.getElementsByClassName("screen-reader-wrapper-step-3");
442
+ this._acc.onChange(false);
443
+ const className = "_access-text-to-speech";
444
+ const remove = () => {
445
+ var _a2;
446
+ const style = document.querySelector("." + className);
447
+ if (style) {
448
+ style.parentElement.removeChild(style);
449
+ document.removeEventListener("click", this.readBind, false);
450
+ document.removeEventListener("keyup", this.readBind, false);
451
+ this._acc.common.deployedObjects.remove("." + className);
452
+ }
453
+ (_a2 = window.speechSynthesis) == null ? void 0 : _a2.cancel();
454
+ this._acc.isReading = false;
455
+ };
456
+ if (destroy) {
457
+ tSpeechList.classList.remove("active");
458
+ (_a = step1[0]) == null ? void 0 : _a.classList.remove("active");
459
+ (_b = step2[0]) == null ? void 0 : _b.classList.remove("active");
460
+ (_c = step3[0]) == null ? void 0 : _c.classList.remove("active");
461
+ this._acc.stateValues.textToSpeech = false;
462
+ (_d = window.speechSynthesis) == null ? void 0 : _d.cancel();
463
+ return remove();
464
+ }
465
+ if (this._acc.stateValues.speechRate === 1 && !tSpeechList.classList.contains("active")) {
466
+ this._acc.stateValues.textToSpeech = true;
467
+ this._acc.textToSpeech("Screen Reader enabled. Reading Pace - Normal");
468
+ tSpeechList.classList.add("active");
469
+ (_e = step1[0]) == null ? void 0 : _e.classList.add("active");
470
+ (_f = step2[0]) == null ? void 0 : _f.classList.add("active");
471
+ (_g = step3[0]) == null ? void 0 : _g.classList.add("active");
472
+ } else if (this._acc.stateValues.speechRate === 1 && tSpeechList.classList.contains("active")) {
473
+ this._acc.stateValues.speechRate = 1.5;
474
+ this._acc.textToSpeech("Reading Pace - Fast");
475
+ (_h = step1[0]) == null ? void 0 : _h.classList.remove("active");
476
+ } else if (this._acc.stateValues.speechRate === 1.5 && tSpeechList.classList.contains("active")) {
477
+ this._acc.stateValues.speechRate = 0.7;
478
+ this._acc.textToSpeech("Reading Pace - Slow");
479
+ (_i = step2[0]) == null ? void 0 : _i.classList.remove("active");
480
+ } else {
481
+ this._acc.stateValues.speechRate = 1;
482
+ this._acc.textToSpeech("Screen Reader - Disabled");
483
+ tSpeechList.classList.remove("active");
484
+ (_j = step3[0]) == null ? void 0 : _j.classList.remove("active");
485
+ const timeout = setInterval(() => {
486
+ if (this._acc.isReading) return;
487
+ this._acc.stateValues.textToSpeech = false;
488
+ remove();
489
+ clearTimeout(timeout);
490
+ }, 500);
491
+ return;
492
+ }
493
+ if (tSpeechList.classList.contains("active") && this._acc.stateValues.speechRate === 1) {
494
+ this._acc.common.injectStyle("*:hover { box-shadow: 2px 2px 2px rgba(180,180,180,0.7); }", { className });
495
+ this._acc.common.deployedObjects.set("." + className, true);
496
+ document.addEventListener("click", this.readBind, false);
497
+ document.addEventListener("keyup", this.readBind, false);
498
+ }
499
+ }
500
+ speechToText(destroy) {
501
+ var _a, _b;
502
+ const sTextList = this._acc.menu.querySelector('[data-access-action="speechToText"]');
503
+ if (!sTextList) return;
504
+ this._acc.onChange(false);
505
+ const className = "_access-speech-to-text";
506
+ const remove = () => {
507
+ var _a2, _b2, _c, _d;
508
+ (_b2 = (_a2 = this._acc.recognition) == null ? void 0 : _a2.stop) == null ? void 0 : _b2.call(_a2);
509
+ this._acc.body.classList.remove("_access-listening");
510
+ (_d = (_c = document.querySelector("." + className)) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.removeChild(document.querySelector("." + className));
511
+ this._acc.common.deployedObjects.remove("." + className);
512
+ document.querySelectorAll("._access-mic").forEach((input) => {
513
+ input.removeEventListener("focus", this._acc.listen.bind(this._acc), false);
514
+ input.classList.remove("_access-mic");
515
+ });
516
+ sTextList.classList.remove("active");
517
+ };
518
+ if (destroy) {
519
+ this._acc.stateValues.speechToText = false;
520
+ return remove();
521
+ }
522
+ this._acc.stateValues.speechToText = !this._acc.stateValues.speechToText;
523
+ if (this._acc.stateValues.speechToText) {
524
+ const iconContent = !((_a = this._acc.options.icon) == null ? void 0 : _a.useEmojis) ? '"mic"' : 'var(--_access-menu-item-icon-mic,"\u{1F3A4}")';
525
+ const fontFamily = !((_b = this._acc.options.icon) == null ? void 0 : _b.useEmojis) ? `font-family: var(--_access-menu-item-icon-font-family-after, ${this._acc.fixedDefaultFont});` : "";
526
+ const css = `
527
+ body:after {
528
+ content: ${iconContent};
529
+ ${fontFamily}
530
+ position: fixed; z-index: 1100; top: 1vw; right: 1vw;
531
+ width: 36px; height: 36px; font-size: 30px; line-height: 36px;
532
+ border-radius: 50%; background: rgba(255,255,255,0.7);
533
+ display: flex; justify-content: center; align-items: center;
534
+ }
535
+ body._access-listening:after { animation: _access-listening-animation 2s infinite ease; }
536
+ @keyframes _access-listening-animation {
537
+ 0% { background-color: transparent; }
538
+ 50% { background-color: #EF9A9A; }
539
+ }
540
+ `;
541
+ this._acc.common.injectStyle(css, { className });
542
+ this._acc.common.deployedObjects.set("." + className, true);
543
+ document.querySelectorAll('input[type="text"], input[type="email"], input[type="tel"], input[type="search"], textarea, [contenteditable]').forEach((input) => {
544
+ input.addEventListener("blur", () => {
545
+ var _a2, _b2;
546
+ return (_b2 = (_a2 = this._acc.recognition) == null ? void 0 : _a2.stop) == null ? void 0 : _b2.call(_a2);
547
+ }, false);
548
+ input.addEventListener("focus", this._acc.listen.bind(this._acc), false);
549
+ input.parentElement.classList.add("_access-mic");
550
+ });
551
+ sTextList.classList.add("active");
552
+ } else {
553
+ remove();
554
+ }
555
+ }
556
+ disableAnimations(destroy) {
557
+ var _a;
558
+ const className = "_access-disable-animations";
559
+ const autoplayStopped = "data-autoplay-stopped";
560
+ const remove = () => {
561
+ var _a2, _b, _c;
562
+ if (!this._acc.options.suppressDomInjection)
563
+ (_a2 = this._acc.menu.querySelector('[data-access-action="disableAnimations"]')) == null ? void 0 : _a2.classList.remove("active");
564
+ this._acc.stateValues.disableAnimations = false;
565
+ (_c = (_b = document.querySelector("." + className)) == null ? void 0 : _b.parentElement) == null ? void 0 : _c.removeChild(document.querySelector("." + className));
566
+ this._acc.common.deployedObjects.remove("." + className);
567
+ document.querySelectorAll("[data-org-src]").forEach((img) => {
568
+ const screenshot = img.src;
569
+ img.setAttribute("src", img.getAttribute("data-org-src"));
570
+ img.setAttribute("data-org-src", screenshot);
571
+ });
572
+ document.querySelectorAll(`video[${autoplayStopped}]`).forEach((v) => {
573
+ v.setAttribute("autoplay", "");
574
+ v.removeAttribute(autoplayStopped);
575
+ v.play();
576
+ });
577
+ };
578
+ if (destroy) {
579
+ remove();
580
+ return;
581
+ }
582
+ this._acc.stateValues.disableAnimations = !this._acc.stateValues.disableAnimations;
583
+ if (!this._acc.stateValues.disableAnimations) {
584
+ remove();
585
+ return;
586
+ }
587
+ if (!this._acc.options.suppressDomInjection)
588
+ (_a = this._acc.menu.querySelector('[data-access-action="disableAnimations"]')) == null ? void 0 : _a.classList.add("active");
589
+ this._acc.common.injectStyle(
590
+ "body * { animation-duration: 0.0ms !important; transition-duration: 0.0ms !important; }",
591
+ { className }
592
+ );
593
+ this._acc.common.deployedObjects.set("." + className, true);
594
+ document.querySelectorAll("img").forEach(async (img) => {
595
+ const ext = this._acc.common.getFileExtension(img.src);
596
+ if ((ext == null ? void 0 : ext.toLowerCase()) === "gif") {
597
+ let screenshot = img.getAttribute("data-org-src");
598
+ if (!screenshot) screenshot = await this._acc.common.createScreenshot(img.src);
599
+ img.setAttribute("data-org-src", img.src);
600
+ img.src = screenshot;
601
+ }
602
+ });
603
+ document.querySelectorAll("video[autoplay]").forEach((v) => {
604
+ v.setAttribute(autoplayStopped, "");
605
+ v.removeAttribute("autoplay");
606
+ v.pause();
607
+ });
608
+ }
609
+ iframeModals(destroy, button) {
610
+ var _a, _b, _c, _d;
611
+ if (!button) destroy = true;
612
+ const close = () => {
613
+ if (this._dialog) {
614
+ this._dialog.classList.add("closing");
615
+ setTimeout(() => {
616
+ this._dialog.classList.remove("closing");
617
+ this._dialog.close();
618
+ this._dialog.remove();
619
+ detach();
620
+ }, 350);
621
+ }
622
+ button == null ? void 0 : button.classList.remove("active");
623
+ };
624
+ const onClose = () => close();
625
+ const detach = () => {
626
+ var _a2, _b2, _c2;
627
+ (_b2 = (_a2 = this._dialog) == null ? void 0 : _a2.querySelector("button")) == null ? void 0 : _b2.removeEventListener("click", onClose, false);
628
+ (_c2 = this._dialog) == null ? void 0 : _c2.removeEventListener("close", onClose);
629
+ };
630
+ if (destroy) {
631
+ close();
632
+ return;
633
+ }
634
+ button.classList.add("active");
635
+ if (!this._dialog) this._dialog = document.createElement("dialog");
636
+ this._dialog.classList.add("_access");
637
+ this._dialog.innerHTML = "";
638
+ this._dialog.appendChild(this._acc.common.jsonToHtml({
639
+ type: "div",
640
+ children: [
641
+ {
642
+ type: "div",
643
+ children: [{
644
+ type: "button",
645
+ attrs: {
646
+ role: "button",
647
+ class: ((_a = this._acc.options.icon) == null ? void 0 : _a.useEmojis) ? "" : (_c = (_b = this._acc.options.icon) == null ? void 0 : _b.fontClass) != null ? _c : "",
648
+ style: "position:absolute;top:5px;cursor:pointer;font-size:24px!important;font-weight:bold;background:transparent;border:none;left:5px;color:#d63c3c;padding:0;"
649
+ },
650
+ children: [{ type: "#text", text: ((_d = this._acc.options.icon) == null ? void 0 : _d.useEmojis) ? "X" : "close" }]
651
+ }]
652
+ },
653
+ {
654
+ type: "div",
655
+ children: [{
656
+ type: "iframe",
657
+ attrs: { src: button.getAttribute("data-access-url"), style: "width:50vw;height:50vh;padding:30px;" }
658
+ }]
659
+ }
660
+ ]
661
+ }));
662
+ document.body.appendChild(this._dialog);
663
+ this._dialog.querySelector("button").addEventListener("click", onClose, false);
664
+ this._dialog.addEventListener("close", onClose);
665
+ this._dialog.showModal();
666
+ }
667
+ customFunctions(destroy, button) {
668
+ if (!button) return;
669
+ const cf = this._acc.options.customFunctions[parseInt(button.getAttribute("data-access-custom-index"))];
670
+ if (cf.toggle && button.classList.contains("active")) destroy = true;
671
+ if (destroy) {
672
+ if (cf.toggle) button.classList.remove("active");
673
+ cf.method(cf, false);
674
+ } else {
675
+ if (cf.toggle) button.classList.add("active");
676
+ cf.method(cf, true);
677
+ }
678
+ }
679
+ dyslexicFont(destroy) {
680
+ var _a, _b;
681
+ const className = "_access-dyslexic-font";
682
+ const btn = this._acc.menu.querySelector('[data-access-action="dyslexicFont"]');
683
+ if (destroy) {
684
+ this._acc.stateValues.dyslexicFont = false;
685
+ btn == null ? void 0 : btn.classList.remove("active");
686
+ (_a = document.querySelector("." + className)) == null ? void 0 : _a.remove();
687
+ return;
688
+ }
689
+ this._acc.stateValues.dyslexicFont = !this._acc.stateValues.dyslexicFont;
690
+ btn == null ? void 0 : btn.classList.toggle("active");
691
+ if (this._acc.stateValues.dyslexicFont) {
692
+ this._acc.common.injectStyle(`
693
+ @font-face {
694
+ font-family: 'OpenDyslexic';
695
+ src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff2') format('woff2');
696
+ font-weight: normal; font-style: normal;
697
+ }
698
+ body *:not(._access):not(._access *) { font-family: OpenDyslexic, Arial, sans-serif !important; }
699
+ `, { className });
700
+ this._acc.common.deployedObjects.set("." + className, false);
701
+ } else {
702
+ (_b = document.querySelector("." + className)) == null ? void 0 : _b.remove();
703
+ }
704
+ }
705
+ hideImages(destroy) {
706
+ var _a, _b;
707
+ const className = "_access-hide-images";
708
+ const btn = this._acc.menu.querySelector('[data-access-action="hideImages"]');
709
+ if (destroy) {
710
+ this._acc.stateValues.hideImages = false;
711
+ btn == null ? void 0 : btn.classList.remove("active");
712
+ (_a = document.querySelector("." + className)) == null ? void 0 : _a.remove();
713
+ return;
714
+ }
715
+ this._acc.stateValues.hideImages = !this._acc.stateValues.hideImages;
716
+ btn == null ? void 0 : btn.classList.toggle("active");
717
+ if (this._acc.stateValues.hideImages) {
718
+ this._acc.common.injectStyle(
719
+ "img, picture, svg:not(._access svg) { visibility: hidden !important; } *:not(._access):not(._access *) { background-image: none !important; }",
720
+ { className }
721
+ );
722
+ this._acc.common.deployedObjects.set("." + className, false);
723
+ } else {
724
+ (_b = document.querySelector("." + className)) == null ? void 0 : _b.remove();
725
+ }
726
+ }
727
+ };
728
+
729
+ // src/storage.ts
730
+ var Storage = class {
731
+ has(key) {
732
+ return Object.prototype.hasOwnProperty.call(window.localStorage, key);
733
+ }
734
+ set(key, value) {
735
+ window.localStorage.setItem(key, JSON.stringify(value));
736
+ }
737
+ get(key) {
738
+ const item = window.localStorage.getItem(key);
739
+ try {
740
+ return JSON.parse(item);
741
+ } catch (e) {
742
+ return item;
743
+ }
744
+ }
745
+ clear() {
746
+ window.localStorage.clear();
747
+ }
748
+ remove(key) {
749
+ window.localStorage.removeItem(key);
750
+ }
751
+ isSupported() {
752
+ const test = "_test";
753
+ try {
754
+ localStorage.setItem(test, test);
755
+ localStorage.removeItem(test);
756
+ return true;
757
+ } catch (e) {
758
+ return false;
759
+ }
760
+ }
761
+ };
762
+
763
+ // src/main.ts
764
+ var _Accessibility = class _Accessibility {
765
+ constructor(options = {}) {
766
+ this._isReading = false;
767
+ var _a, _b, _c, _d;
768
+ this._common = new Common();
769
+ this._storage = new Storage();
770
+ this._fixedDefaultFont = this._common.getFixedFont("Material Icons");
771
+ this._options = this.defaultOptions;
772
+ this.options = this._common.extend(this._options, options);
773
+ this.addModuleOrderIfNotDefined();
774
+ this.addDefaultOptions(options);
775
+ this.disabledUnsupportedFeatures();
776
+ this._onKeyDownBind = this.onKeyDown.bind(this);
777
+ this._sessionState = {
778
+ textSize: 0,
779
+ textSpace: 0,
780
+ lineHeight: 0,
781
+ invertColors: false,
782
+ grayHues: false,
783
+ underlineLinks: false,
784
+ bigCursor: false,
785
+ readingGuide: false
786
+ };
787
+ if ((_a = this.options.icon) == null ? void 0 : _a.useEmojis) {
788
+ this.fontFallback();
789
+ this.build();
790
+ } else {
791
+ this._common.injectIconsFont((_c = (_b = this.options.icon) == null ? void 0 : _b.fontFaceSrc) != null ? _c : [], (hasError) => {
792
+ var _a2;
793
+ this.build();
794
+ if ((_a2 = this.options.icon) == null ? void 0 : _a2.fontFamilyValidation) {
795
+ setTimeout(() => {
796
+ this._common.isFontLoaded(this.options.icon.fontFamilyValidation, (isLoaded) => {
797
+ if (!isLoaded || hasError) {
798
+ this._common.warn(`${this.options.icon.fontFamilyValidation} font not loaded, using emojis`);
799
+ this.fontFallback();
800
+ this.destroy();
801
+ this.build();
802
+ }
803
+ });
804
+ });
805
+ }
806
+ });
807
+ }
808
+ if ((_d = this.options.modules) == null ? void 0 : _d.speechToText) {
809
+ window.addEventListener("beforeunload", () => {
810
+ if (this._isReading) {
811
+ window.speechSynthesis.cancel();
812
+ this._isReading = false;
813
+ }
814
+ });
815
+ }
816
+ }
817
+ get stateValues() {
818
+ return this._stateValues;
819
+ }
820
+ set stateValues(value) {
821
+ this._stateValues = value;
822
+ }
823
+ get html() {
824
+ return this._html;
825
+ }
826
+ get body() {
827
+ return this._body;
828
+ }
829
+ get menu() {
830
+ return this._menu;
831
+ }
832
+ get sessionState() {
833
+ return this._sessionState;
834
+ }
835
+ set sessionState(value) {
836
+ this._sessionState = value;
837
+ }
838
+ get common() {
839
+ return this._common;
840
+ }
841
+ get recognition() {
842
+ return this._recognition;
843
+ }
844
+ get isReading() {
845
+ return this._isReading;
846
+ }
847
+ set isReading(value) {
848
+ this._isReading = value;
849
+ }
850
+ get fixedDefaultFont() {
851
+ return this._fixedDefaultFont;
852
+ }
853
+ get defaultOptions() {
854
+ const res = {
855
+ icon: {
856
+ img: "accessibility",
857
+ fontFaceSrc: ["https://fonts.googleapis.com/icon?family=Material+Icons"],
858
+ fontClass: "material-icons",
859
+ useEmojis: false,
860
+ closeIcon: "close",
861
+ resetIcon: "refresh"
862
+ },
863
+ hotkeys: {
864
+ enabled: false,
865
+ helpTitles: true,
866
+ keys: {
867
+ toggleMenu: ["ctrlKey", "altKey", 65],
868
+ invertColors: ["ctrlKey", "altKey", 73],
869
+ grayHues: ["ctrlKey", "altKey", 71],
870
+ underlineLinks: ["ctrlKey", "altKey", 85],
871
+ bigCursor: ["ctrlKey", "altKey", 67],
872
+ readingGuide: ["ctrlKey", "altKey", 82],
873
+ textToSpeech: ["ctrlKey", "altKey", 84],
874
+ speechToText: ["ctrlKey", "altKey", 83],
875
+ disableAnimations: ["ctrlKey", "altKey", 81]
876
+ }
877
+ },
878
+ guide: { cBorder: "#20ff69", cBackground: "#000000", height: "12px" },
879
+ suppressCssInjection: false,
880
+ suppressDomInjection: false,
881
+ labels: {
882
+ resetTitle: "Reset",
883
+ closeTitle: "Close",
884
+ menuTitle: "Accessibility Options",
885
+ increaseText: "increase text size",
886
+ decreaseText: "decrease text size",
887
+ increaseTextSpacing: "increase text spacing",
888
+ decreaseTextSpacing: "decrease text spacing",
889
+ invertColors: "invert colors",
890
+ grayHues: "gray hues",
891
+ bigCursor: "big cursor",
892
+ readingGuide: "reading guide",
893
+ underlineLinks: "underline links",
894
+ textToSpeech: "text to speech",
895
+ speechToText: "speech to text",
896
+ disableAnimations: "disable animations",
897
+ increaseLineHeight: "increase line height",
898
+ decreaseLineHeight: "decrease line height",
899
+ hotkeyPrefix: "Hotkey: ",
900
+ dyslexicFont: "Dyslexic font",
901
+ hideImages: "Hide images"
902
+ },
903
+ textPixelMode: false,
904
+ textEmlMode: true,
905
+ textSizeFactor: 12.5,
906
+ animations: { buttons: true },
907
+ modules: {
908
+ increaseText: true,
909
+ decreaseText: true,
910
+ increaseTextSpacing: true,
911
+ decreaseTextSpacing: true,
912
+ increaseLineHeight: true,
913
+ decreaseLineHeight: true,
914
+ invertColors: true,
915
+ grayHues: true,
916
+ bigCursor: true,
917
+ readingGuide: true,
918
+ underlineLinks: true,
919
+ textToSpeech: true,
920
+ speechToText: true,
921
+ disableAnimations: true,
922
+ dyslexicFont: true,
923
+ hideImages: true
924
+ },
925
+ modulesOrder: [],
926
+ session: { persistent: true },
927
+ iframeModals: [],
928
+ customFunctions: [],
929
+ statement: { url: "" },
930
+ feedback: { url: "" },
931
+ linkSelector: "a",
932
+ logoImage: "",
933
+ language: { textToSpeechLang: "", speechToTextLang: "" }
934
+ };
935
+ Object.keys(AccessibilityModulesType).filter((k) => !isNaN(parseInt(k))).forEach((k) => {
936
+ const n = parseInt(k);
937
+ res.modulesOrder.push({ type: n, order: n });
938
+ });
939
+ return res;
940
+ }
941
+ initFontSize() {
942
+ if (!this._htmlInitFS) {
943
+ const htmlInitFS = this._common.getFormattedDim(getComputedStyle(this._html).fontSize);
944
+ const bodyInitFS = this._common.getFormattedDim(getComputedStyle(this._body).fontSize);
945
+ this._html.style.fontSize = htmlInitFS.size / 16 * 100 + "%";
946
+ this._htmlOrgFontSize = this._html.style.fontSize;
947
+ this._body.style.fontSize = bodyInitFS.size / htmlInitFS.size + "em";
948
+ }
949
+ }
950
+ fontFallback() {
951
+ this.options.icon.useEmojis = true;
952
+ this.options.icon.img = "\u267F";
953
+ this.options.icon.fontClass = "";
954
+ }
955
+ addDefaultOptions(options) {
956
+ var _a, _b, _c, _d, _e;
957
+ if ((_a = options.icon) == null ? void 0 : _a.closeIconElem) this.options.icon.closeIconElem = options.icon.closeIconElem;
958
+ if ((_b = options.icon) == null ? void 0 : _b.resetIconElem) this.options.icon.resetIconElem = options.icon.resetIconElem;
959
+ if ((_c = options.icon) == null ? void 0 : _c.imgElem) this.options.icon.imgElem = options.icon.imgElem;
960
+ if (!this.options.icon.closeIconElem)
961
+ this.options.icon.closeIconElem = { type: "#text", text: !this.options.icon.useEmojis ? (_d = this.options.icon.closeIcon) != null ? _d : "close" : "X" };
962
+ if (!this.options.icon.resetIconElem)
963
+ this.options.icon.resetIconElem = { type: "#text", text: !this.options.icon.useEmojis ? (_e = this.options.icon.resetIcon) != null ? _e : "refresh" : "\u2672" };
964
+ if (!this.options.icon.imgElem)
965
+ this.options.icon.imgElem = { type: "#text", text: this.options.icon.img };
966
+ }
967
+ addModuleOrderIfNotDefined() {
968
+ this.defaultOptions.modulesOrder.forEach((mo) => {
969
+ if (!this.options.modulesOrder.find((imo) => imo.type === mo.type))
970
+ this.options.modulesOrder.push(mo);
971
+ });
972
+ }
973
+ disabledUnsupportedFeatures() {
974
+ if (!("webkitSpeechRecognition" in window) || location.protocol !== "https:") {
975
+ this._common.warn("speech to text requires a browser with webkitSpeechRecognition and https");
976
+ this.options.modules.speechToText = false;
977
+ }
978
+ const w = window;
979
+ if (!w.SpeechSynthesisUtterance || !w.speechSynthesis) {
980
+ this._common.warn("text to speech is not supported in this browser");
981
+ this.options.modules.textToSpeech = false;
982
+ }
983
+ }
984
+ injectCss(injectFull) {
985
+ var _a;
986
+ const iconTop = "7px", iconLeft = "5px";
987
+ const useEmojis = (_a = this.options.icon) == null ? void 0 : _a.useEmojis;
988
+ const mandatory = `
989
+ html._access_cursor * {
990
+ cursor: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyOS4xODhweCIgaGVpZ2h0PSI0My42MjVweCIgdmlld0JveD0iMCAwIDI5LjE4OCA0My42MjUiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI5LjE4OCA0My42MjUiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxwb2x5Z29uIGZpbGw9IiNGRkZGRkYiIHN0cm9rZT0iI0Q5REFEOSIgc3Ryb2tlLXdpZHRoPSIxLjE0MDYiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgcG9pbnRzPSIyLjgsNC41NDkgMjYuODQ3LDE5LjkwMiAxNi45NjQsMjIuNzAxIDI0LjIzOSwzNy43NDkgMTguMjc4LDQyLjAxNyA5Ljc0MSwzMC43MjQgMS4xMzgsMzUuODA5ICIvPjxnPjxnPjxnPjxwYXRoIGZpbGw9IiMyMTI2MjciIGQ9Ik0yOS4xNzUsMjEuMTU1YzAuMDcxLTAuNjEzLTAuMTY1LTEuMjUzLTAuNjM1LTEuNTczTDIuMTY1LDAuMjU4Yy0wLjQyNC0wLjMyLTAuOTg4LTAuMzQ2LTEuNDM1LTAuMDUzQzAuMjgyLDAuNDk3LDAsMS4wMywwLDEuNjE3djM0LjE3MWMwLDAuNjEzLDAuMzA2LDEuMTQ2LDAuNzc2LDEuNDM5YzAuNDcxLDAuMjY3LDEuMDU5LDAuMjEzLDEuNDgyLTAuMTZsNy40ODItNi4zNDRsNi44NDcsMTIuMTU1YzAuMjU5LDAuNDgsMC43MjksMC43NDYsMS4yLDAuNzQ2YzAuMjM1LDAsMC40OTQtMC4wOCwwLjcwNi0wLjIxM2w2Ljk4OC00LjU4NWMwLjMyOS0wLjIxMywwLjU2NS0wLjU4NiwwLjY1OS0xLjAxM2MwLjA5NC0wLjQyNiwwLjAyNC0wLjg4LTAuMTg4LTEuMjI2bC02LjM3Ni0xMS4zODJsOC42MTEtMi43NDVDMjguNzA1LDIyLjI3NCwyOS4xMDUsMjEuNzY4LDI5LjE3NSwyMS4xNTV6IE0xNi45NjQsMjIuNzAxYy0wLjQyNCwwLjEzMy0wLjc3NiwwLjUwNi0wLjk0MSwwLjk2Yy0wLjE2NSwwLjQ4LTAuMTE4LDEuMDEzLDAuMTE4LDEuNDM5bDYuNTg4LDExLjc4MWwtNC41NDEsMi45ODVsLTYuODk0LTEyLjMxNWMtMC4yMTItMC4zNzMtMC41NDEtMC42NC0wLjk0MS0wLjcyYy0wLjA5NC0wLjAyNy0wLjE2NS0wLjAyNy0wLjI1OS0wLjAyN2MtMC4zMDYsMC0wLjU4OCwwLjEwNy0wLjg0NywwLjMyTDIuOCwzMi41OVY0LjU0OWwyMS41OTksMTUuODA2TDE2Ljk2NCwyMi43MDF6Ii8+PC9nPjwvZz48L2c+PC9nPjwvc3ZnPg==),auto!important;
991
+ }
992
+ @keyframes _access-dialog-backdrop {
993
+ 0% { background: var(--_access-menu-dialog-backdrop-background-start, rgba(0,0,0,0.1)); }
994
+ 100% { background: var(--_access-menu-dialog-backdrop-background-end, rgba(0,0,0,0.5)); }
995
+ }
996
+ dialog._access::backdrop, dialog._access {
997
+ transition-duration: var(--_access-menu-dialog-backdrop-transition-duration, 0.35s);
998
+ transition-timing-function: var(--_access-menu-dialog-backdrop-transition-timing-function, ease-in-out);
999
+ }
1000
+ dialog._access:modal { border-color: transparent; border-width: 0; padding: 0; }
1001
+ dialog._access[open]::backdrop {
1002
+ background: var(--_access-menu-dialog-backdrop-background-end, rgba(0,0,0,0.5));
1003
+ animation: _access-dialog-backdrop var(--_access-menu-dialog-backdrop-transition-duration, 0.35s) ease-in-out;
1004
+ }
1005
+ dialog._access.closing[open]::backdrop { background: var(--_access-menu-dialog-backdrop-background-start, rgba(0,0,0,0.1)); }
1006
+ dialog._access.closing[open] { opacity: 0; }
1007
+ .screen-reader-wrapper { margin: 0; position: absolute; bottom: -4px; width: calc(100% - 2px); left: 1px; }
1008
+ .screen-reader-wrapper-step-1, .screen-reader-wrapper-step-2, .screen-reader-wrapper-step-3 {
1009
+ float: left; background: var(--_access-menu-background-color, #fff);
1010
+ width: 33.33%; height: 3px; border-radius: 10px;
1011
+ }
1012
+ .screen-reader-wrapper-step-1.active, .screen-reader-wrapper-step-2.active, .screen-reader-wrapper-step-3.active {
1013
+ background: var(--_access-menu-item-button-background, #f9f9f9);
1014
+ }
1015
+ .access_read_guide_bar {
1016
+ box-sizing: border-box;
1017
+ background: var(--_access-menu-read-guide-bg, ${this.options.guide.cBackground});
1018
+ width: 100%!important; min-width: 100%!important; position: fixed!important;
1019
+ height: var(--_access-menu-read-guide-height, ${this.options.guide.height}) !important;
1020
+ border: var(--_access-menu-read-guide-border, solid 3px ${this.options.guide.cBorder});
1021
+ border-radius: 5px; top: 15px; z-index: 2147483647;
1022
+ }`;
1023
+ let css = mandatory;
1024
+ if (injectFull) {
1025
+ css = `
1026
+ ._access-scrollbar::-webkit-scrollbar-track { -webkit-box-shadow: var(--_access-scrollbar-track-box-shadow, inset 0 0 6px rgba(0,0,0,0.3)); background-color: var(--_access-scrollbar-track-background-color, #F5F5F5); }
1027
+ ._access-scrollbar::-webkit-scrollbar { width: var(--_access-scrollbar-width, 6px); background-color: var(--_access-scrollbar-background-color, #F5F5F5); }
1028
+ ._access-scrollbar::-webkit-scrollbar-thumb { background-color: var(--_access-scrollbar-thumb-background-color, #999999); }
1029
+ ._access-icon {
1030
+ position: var(--_access-icon-position, fixed);
1031
+ width: var(--_access-icon-width, 50px); height: var(--_access-icon-height, 50px);
1032
+ bottom: var(--_access-icon-bottom, 80px); top: var(--_access-icon-top, unset);
1033
+ left: var(--_access-icon-left, unset); right: var(--_access-icon-right, 10px);
1034
+ z-index: var(--_access-icon-z-index, 9999);
1035
+ font: var(--_access-icon-font, 40px / 45px "Material Icons");
1036
+ background: var(--_access-icon-bg, #4054b2); color: var(--_access-icon-color, #fff);
1037
+ background-repeat: no-repeat; background-size: contain;
1038
+ cursor: pointer; opacity: 0; transition-duration: .35s;
1039
+ user-select: none;
1040
+ ${!useEmojis ? "box-shadow: 1px 1px 5px rgba(0,0,0,.5);" : ""}
1041
+ transform: ${!useEmojis ? "scale(1)" : "skewX(14deg)"};
1042
+ border-radius: 50%;
1043
+ border: 3px solid #FFFFFF;
1044
+ text-align: var(--_access-icon-text-align, center);
1045
+ display: flex; align-items: center; justify-content: center;
1046
+ }
1047
+ .content {
1048
+ display: flex;
1049
+ flex-direction: column;
1050
+ align-items: center;
1051
+ flex: 1;
1052
+ min-height: 0;
1053
+ border-top-left-radius: 20px;
1054
+ border-top-right-radius: 20px;
1055
+ padding: 30px 0px 20px;
1056
+ background: #F3F4F6;
1057
+ overflow-y: auto;
1058
+ }
1059
+ ._access-icon:hover { transform: var(--_access-icon-transform-hover, scale(1.1)); }
1060
+ ._access-menu {
1061
+ user-select: none; position: fixed;
1062
+ width: var(--_access-menu-width, ${_Accessibility.MENU_WIDTH});
1063
+ height: var(--_access-menu-height, auto);
1064
+ padding: 0px;
1065
+ display: flex;
1066
+ flex-direction: column;
1067
+ align-items: center;
1068
+ transition-duration: var(--_access-menu-transition-duration, .35s);
1069
+ z-index: var(--_access-menu-z-index, 99991); opacity: 1;
1070
+ background-color: var(--_access-menu-background-color, #F3F4F6);
1071
+ color: var(--_access-menu-color, #000);
1072
+ border-radius: var(--_access-menu-border-radius, 3px);
1073
+ font-family: var(--_access-menu-font-family, RobotoDraft, Roboto, sans-serif, Arial);
1074
+ min-width: var(--_access-menu-min-width, 300px);
1075
+ box-shadow: var(--_access-menu-box-shadow, -2px -2px 12px rgba(0, 0, 0, 0.2));
1076
+ height: 100%;
1077
+ ${getComputedStyle(this._body).direction === "rtl" ? "text-indent: -5px" : ""}
1078
+ top: var(--_access-menu-top, unset); left: var(--_access-menu-left, unset);
1079
+ bottom: var(--_access-menu-bottom, 0); right: var(--_access-menu-right, 0);
1080
+ padding-bottom: 20px;
1081
+ word-spacing: normal; letter-spacing: normal; line-height: normal;
1082
+ overflow-y: auto;
1083
+ }
1084
+ @media (max-width: 600px) {
1085
+ ._access-menu {
1086
+ height: 100vh !important; /* For\xE7a ocupar toda a altura */
1087
+ height: 100dvh !important; /* Corre\xE7\xE3o para navegadores mobile (Safari/Chrome) */
1088
+ max-height: 100dvh !important;
1089
+ overflow-y: auto; /* Permite rolar os bot\xF5es caso sumam da tela */
1090
+ }
1091
+ }
1092
+ ._access-menu.close {
1093
+ z-index: -1; width: 0; opacity: 0; background-color: transparent;
1094
+ right: calc(-1 * var(--_access-menu-width, ${_Accessibility.MENU_WIDTH}));
1095
+ }
1096
+ ._access-menu ._text-center {
1097
+ font-size: var(--_access-menu-header-font-size, 22px);
1098
+ font-weight: var(--_access-menu-header-font-weight, bold);
1099
+ margin: var(--_access-menu-header-margin, 0px 0 -15px);
1100
+ padding: 40px 30px;
1101
+ color: var(--_access-menu-header-color, #FFFFFF);
1102
+ text-align: var(--_access-menu-header-text-align, left);
1103
+ background: #0048FF;
1104
+ width: 100%;
1105
+ display: flex;
1106
+ flex-direction: row-reverse;
1107
+ align-items: center;
1108
+ justify-content: space-between;
1109
+ gap: 8px;
1110
+
1111
+ }
1112
+
1113
+
1114
+ ._access-menu ._menu-close-btn {
1115
+
1116
+ padding: 10px;
1117
+ color: #FFFFFF;
1118
+ border-radius: 50%;
1119
+ transition: .3s ease;
1120
+ transform: rotate(0deg);
1121
+ -style: normal !important;
1122
+ background: #0d2f8a;
1123
+ blur: 1.2;
1124
+ cursor: pointer;
1125
+ font-size: 24px !important;
1126
+ font-weight: bold;
1127
+ align-self: flex-end;
1128
+ justify-self: flex-end;
1129
+ }
1130
+
1131
+ @media (max-width: 765px) {
1132
+ ._access-menu ._text-center {
1133
+ font-size: 18px;
1134
+ padding: 40px 20px;
1135
+ }
1136
+
1137
+ ._access-menu ._menu-close-btn {
1138
+ font-size: 18px;
1139
+ padding: 5px;
1140
+ }
1141
+ }
1142
+ ._access-menu ._menu-reset-btn {
1143
+ position: relative;
1144
+ width: 90%;
1145
+ padding: 15px;
1146
+ margin: 10px auto;
1147
+ background: #0048FF;
1148
+ color: #FFFFFF;
1149
+ border-radius: 10px;
1150
+ box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
1151
+ cursor: pointer;
1152
+ font-style: normal !important;
1153
+ display: flex; align-items: center; justify-content: center; gap: 6px;
1154
+ }
1155
+ ._access-menu ._menu-close-btn:hover { scale: 1.05; }
1156
+ ._access-menu ._menu-reset-btn:hover { scale: 1.03; }
1157
+
1158
+ ._access-menu ul {
1159
+ width: 90%;
1160
+ padding: 0 0 5px;
1161
+ position: relative;
1162
+ display: flex;
1163
+ flex-wrap: wrap;
1164
+ gap: 4px;
1165
+ font-size: var(--_access-menu-font-size, 18px);
1166
+ margin: 0;
1167
+ max-height: 100hv;
1168
+ background: #F3F4F6;
1169
+ }
1170
+ ${mandatory}
1171
+ ._access-menu ul li {
1172
+ width: 45%;
1173
+ min-height: 100px;
1174
+ position: relative;
1175
+ list-style-type: none;
1176
+ user-select: none;
1177
+ margin: 2px auto;
1178
+ font-size: var(--_access-menu-item-font-size, 18px) !important;
1179
+ line-height: var(--_access-menu-item-line-height, 18px) !important;
1180
+ color: var(--_access-menu-item-color, rgba(0,0,0,.8));
1181
+ }
1182
+ ._access-menu ul li button {
1183
+ display: inline-flex;
1184
+ flex-direction: column;
1185
+ align-items: center;
1186
+ justify-content: center;
1187
+ background: var(--_access-menu-item-button-background, #FFFFFF);
1188
+ padding: 10px;
1189
+ gap: 8px;
1190
+ width: 100%;
1191
+ height: 100%;
1192
+ text-align: center;
1193
+ position: relative;
1194
+ transition-duration: var(--_access-menu-item-button-transition-duration, .35s);
1195
+ box-shadow: 4px 2px 1px rgba(0, 0, 0, 0.1);
1196
+ border-radius: var(--_access-menu-item-button-border-radius, 8px);
1197
+ cursor: pointer;
1198
+ }
1199
+ ._access-menu ul li.position { display: inline-block; width: auto; }
1200
+ ._access-menu ul.before-collapse li button { opacity: var(--_access-menu-item-button-before-collapse-opacity, 0.05); }
1201
+ ._access-menu ul li button.active, ._access-menu ul li button.active:hover {
1202
+ border: 2px solid var(--_access-menu-item-button-active-border-color, #0048FF) !important;
1203
+ }
1204
+ ._access-menu div.active { color: var(--_access-menu-div-active-color, #0048FF); }
1205
+ ._access-menu ul li button.active, ._access-menu ul li button.active:hover, ._access-menu ul li button.active:before, ._access-menu ul li button.active:hover:before { color: var(--_access-menu-item-button-active-color, #0048FF); }
1206
+ ._access-menu ul li button:hover {
1207
+ color: var(--_access-menu-item-button-hover-color, #003366);
1208
+ background-color: var(--_access-menu-item-button-hover-background-color, #FFFFFF);
1209
+ scale: 1.03;
1210
+ }
1211
+ ._access-menu ul li.not-supported { display: none; }
1212
+ ._access-menu ul li button:before {
1213
+ content: ' ';
1214
+ font-family: var(--_access-menu-button-font-family-before, ${this._fixedDefaultFont});
1215
+ text-rendering: optimizeLegibility;
1216
+ font-feature-settings: "liga" 1;
1217
+ font-style: normal;
1218
+ text-transform: none;
1219
+ line-height: ${!useEmojis ? "1" : "1.1"};
1220
+ font-size: ${!useEmojis ? "24px" : "20px"} !important;
1221
+
1222
+ /* Alinhamento corrigido */
1223
+ display: flex;
1224
+ align-items: center;
1225
+ justify-content: center;
1226
+ width: 20px;
1227
+ height: 20px;
1228
+
1229
+ -webkit-font-smoothing: antialiased;
1230
+ color: var(--_access-menu-item-icon-color, rgba(0,0,0,.6));
1231
+ direction: ltr;
1232
+ text-indent: 0;
1233
+ transition-duration: .35s;
1234
+
1235
+ }
1236
+ ._access-menu ul li button svg path { fill: var(--_access-menu-item-icon-color, rgba(0,0,0,.8)); transition-duration: .35s; }
1237
+ ._access-menu ul li button:hover svg path { fill: var(--_access-menu-item-hover-icon-color, #003366); }
1238
+ ._access-menu ul li button.active svg path { fill: var(--_access-menu-item-active-icon-color, #0048FF); }
1239
+ ._access-menu ul li:hover button:before { color: var(--_access-menu-item-hover-icon-color, #003366); }
1240
+ ._access-menu ul li button[data-access-action="increaseText"]:before { content: var(--_access-menu-item-icon-increase-text, ${!useEmojis ? '"zoom_in"' : '"\u{1F53C}"'}); top: var(--_access-menu-item-icon-increase-text-top, ${iconTop}); left: var(--_access-menu-item-icon-increase-text-left, ${iconLeft}); }
1241
+ ._access-menu ul li button[data-access-action="decreaseText"]:before { content: var(--_access-menu-item-icon-decrease-text, ${!useEmojis ? '"zoom_out"' : '"\u{1F53D}"'}); top: ${iconTop}; left: ${iconLeft}; }
1242
+ ._access-menu ul li button[data-access-action="increaseTextSpacing"]:before { content: var(--_access-menu-item-icon-increase-text-spacing, ${!useEmojis ? '"unfold_more"' : '"\u{1F53C}"'}); transform: var(--_access-menu-item-icon-increase-text-spacing-transform, rotate(90deg) translate(-7px, 2px)); top: 14px; left: 0; }
1243
+ ._access-menu ul li button[data-access-action="decreaseTextSpacing"]:before { content: var(--_access-menu-item-icon-decrease-text-spacing, ${!useEmojis ? '"unfold_less"' : '"\u{1F53D}"'}); transform: var(--_access-menu-item-icon-decrease-text-spacing-transform, rotate(90deg) translate(-7px, 2px)); top: 14px; left: 0; }
1244
+ ._access-menu ul li button[data-access-action="invertColors"]:before { content: var(--_access-menu-item-icon-invert-colors, ${!useEmojis ? '"invert_colors"' : '"\u{1F386}"'}); top: ${iconTop}; left: ${iconLeft}; }
1245
+ ._access-menu ul li button[data-access-action="grayHues"]:before { content: var(--_access-menu-item-icon-gray-hues, ${!useEmojis ? '"format_color_reset"' : '"\u{1F32B}\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
1246
+ ._access-menu ul li button[data-access-action="underlineLinks"]:before { content: var(--_access-menu-item-icon-underline-links, ${!useEmojis ? '"format_underlined"' : '"\u{1F517}"'}); top: ${iconTop}; left: ${iconLeft}; }
1247
+ ._access-menu ul li button[data-access-action="bigCursor"]:before { content: var(--_access-menu-item-icon-big-cursor, inherit); top: ${iconTop}; left: ${iconLeft}; }
1248
+ ._access-menu ul li button[data-access-action="readingGuide"]:before { content: var(--_access-menu-item-icon-reading-guide, ${!useEmojis ? '"border_horizontal"' : '"\u2194\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
1249
+ ._access-menu ul li button[data-access-action="textToSpeech"]:before { content: var(--_access-menu-item-icon-text-to-speech, ${!useEmojis ? '"record_voice_over"' : '"\u23FA\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
1250
+ ._access-menu ul li button[data-access-action="speechToText"]:before { content: var(--_access-menu-item-icon-speech-to-text, ${!useEmojis ? '"mic"' : '"\u{1F3A4}"'}); top: ${iconTop}; left: ${iconLeft}; }
1251
+ ._access-menu ul li button[data-access-action="disableAnimations"]:before { content: var(--_access-menu-item-icon-disable-animations, ${!useEmojis ? '"animation"' : '"\u{1F3C3}\u200D\u2642\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
1252
+ ._access-menu ul li button[data-access-action="iframeModals"]:before { content: var(--_access-menu-item-icon-iframe-modals, ${!useEmojis ? '"policy"' : '"\u2696\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
1253
+ ._access-menu ul li button[data-access-action="customFunctions"]:before { content: var(--_access-menu-item-icon-custom-functions, ${!useEmojis ? '"psychology_alt"' : '"\u2753"'}); top: ${iconTop}; left: ${iconLeft}; }
1254
+ ._access-menu ul li button[data-access-action="increaseLineHeight"]:before { content: var(--_access-menu-item-icon-increase-line-height, ${!useEmojis ? '"unfold_more"' : '"\u{1F53C}"'}); top: ${iconTop}; left: ${iconLeft}; }
1255
+ ._access-menu ul li button[data-access-action="decreaseLineHeight"]:before { content: var(--_access-menu-item-icon-decrease-line-height, ${!useEmojis ? '"unfold_less"' : '"\u{1F53D}"'}); top: ${iconTop}; left: ${iconLeft}; }
1256
+ ._access-menu ul li button[data-access-action="dyslexicFont"]:before { content: var(--_access-menu-item-icon-dyslexic-font, ${!useEmojis ? '"font_download"' : '"\u{1F524}"'}); top: ${iconTop}; left: ${iconLeft}; }
1257
+ ._access-menu ul li button[data-access-action="hideImages"]:before { content: var(--_access-menu-item-icon-hide-images, ${!useEmojis ? '"hide_image"' : '"\u{1F6AB}"'}); top: ${iconTop}; left: ${iconLeft}; }
1258
+ ._access-menu-logo {
1259
+ display: block;
1260
+ max-width: 40%;
1261
+ margin: 8px auto 4px;
1262
+ object-fit: contain;
1263
+ }
1264
+ ._access-cycle-indicator { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
1265
+ ._access-cycle-indicator span { width: 16px; height: 3px; border-radius: 2px; background: #ccc; transition: background 0.2s; }
1266
+ ._access-cycle-indicator span.filled { background: #0048FF; }
1267
+ `;
1268
+ }
1269
+ this._common.injectStyle(css, { className: _Accessibility.CSS_CLASS_NAME });
1270
+ this._common.deployedObjects.set(`.${_Accessibility.CSS_CLASS_NAME}`, false);
1271
+ }
1272
+ removeCSS() {
1273
+ var _a;
1274
+ (_a = document.querySelector(`.${_Accessibility.CSS_CLASS_NAME}`)) == null ? void 0 : _a.remove();
1275
+ }
1276
+ injectIcon() {
1277
+ const className = `_access-icon ${this.options.icon.fontClass} _access`;
1278
+ const iconElem = this._common.jsonToHtml({
1279
+ type: "i",
1280
+ attrs: {
1281
+ class: className,
1282
+ title: this.options.hotkeys.enabled ? this.parseKeys(this.options.hotkeys.keys.toggleMenu) : this.options.labels.menuTitle,
1283
+ tabIndex: "0"
1284
+ },
1285
+ children: [this.options.icon.imgElem]
1286
+ });
1287
+ this._body.appendChild(iconElem);
1288
+ this._common.deployedObjects.set("._access-icon", false);
1289
+ return iconElem;
1290
+ }
1291
+ parseKeys(arr) {
1292
+ if (!this.options.hotkeys.enabled) return "";
1293
+ if (!this.options.hotkeys.helpTitles) return "";
1294
+ return this.options.labels.hotkeyPrefix + arr.map((val) => Number.isInteger(val) ? String.fromCharCode(val).toLowerCase() : val.replace("Key", "")).join("+");
1295
+ }
1296
+ injectMenu() {
1297
+ var _a;
1298
+ const labels = this.options.labels;
1299
+ const hotkeys = this.options.hotkeys;
1300
+ const mods = (_a = this.options.modules) != null ? _a : {};
1301
+ const menuItems = [
1302
+ { action: "increaseText", label: labels.increaseText },
1303
+ { action: "decreaseText", label: labels.decreaseText },
1304
+ { action: "increaseTextSpacing", label: labels.increaseTextSpacing },
1305
+ { action: "decreaseTextSpacing", label: labels.decreaseTextSpacing },
1306
+ { action: "increaseLineHeight", label: labels.increaseLineHeight },
1307
+ { action: "decreaseLineHeight", label: labels.decreaseLineHeight },
1308
+ { action: "invertColors", label: labels.invertColors, hotkey: hotkeys.keys.invertColors },
1309
+ { action: "grayHues", label: labels.grayHues, hotkey: hotkeys.keys.grayHues },
1310
+ { action: "underlineLinks", label: labels.underlineLinks, hotkey: hotkeys.keys.underlineLinks },
1311
+ { action: "bigCursor", label: labels.bigCursor, hotkey: hotkeys.keys.bigCursor },
1312
+ { action: "readingGuide", label: labels.readingGuide, hotkey: hotkeys.keys.readingGuide },
1313
+ { action: "disableAnimations", label: labels.disableAnimations, hotkey: hotkeys.keys.disableAnimations },
1314
+ { action: "dyslexicFont", label: labels.dyslexicFont },
1315
+ { action: "hideImages", label: labels.hideImages }
1316
+ ].filter(({ action }) => mods[action] !== false).map(({ action, label, hotkey }) => ({
1317
+ type: "li",
1318
+ children: [{
1319
+ type: "button",
1320
+ attrs: { "data-access-action": action, ...hotkey ? { title: this.parseKeys(hotkey) } : {} },
1321
+ children: [
1322
+ ...action === "bigCursor" ? [{ type: "div", attrs: { id: "iconBigCursor" } }] : [],
1323
+ { type: "#text", text: label }
1324
+ ]
1325
+ }]
1326
+ }));
1327
+ const json = {
1328
+ type: "div",
1329
+ attrs: { class: "_access-menu close _access" },
1330
+ children: [
1331
+ {
1332
+ type: "div",
1333
+ attrs: { class: "_text-center", role: "presentation" },
1334
+ children: [
1335
+ {
1336
+ type: "button",
1337
+ attrs: { class: `_menu-close-btn _menu-btn ${this.options.icon.fontClass}`, style: `font-family: var(--_access-menu-close-btn-font-family, ${this._fixedDefaultFont})`, title: hotkeys.enabled ? this.parseKeys(hotkeys.keys.toggleMenu) : labels.closeTitle },
1338
+ children: [this.options.icon.closeIconElem]
1339
+ },
1340
+ { type: "#text", text: labels.menuTitle }
1341
+ ]
1342
+ },
1343
+ {
1344
+ type: "div",
1345
+ attrs: { class: "content" },
1346
+ children: [
1347
+ { type: "ul", attrs: { class: "before-collapse _access-scrollbar" }, children: menuItems },
1348
+ {
1349
+ type: "button",
1350
+ attrs: { class: "_menu-reset-btn", title: labels.resetTitle },
1351
+ children: [
1352
+ { type: "span", attrs: { class: this.options.icon.fontClass, style: `font-family: var(--_access-menu-reset-btn-font-family, ${this._fixedDefaultFont}); font-size: 18px; line-height: 1;` }, children: [this.options.icon.resetIconElem] },
1353
+ { type: "span", children: [{ type: "#text", text: labels.resetTitle }] }
1354
+ ]
1355
+ }
1356
+ ]
1357
+ },
1358
+ ...this.options.logoImage ? [{
1359
+ type: "img",
1360
+ attrs: { src: this.options.logoImage, alt: "", class: "_access-menu-logo" }
1361
+ }] : []
1362
+ ]
1363
+ };
1364
+ if (this.options.iframeModals) {
1365
+ this.options.iframeModals.forEach((im, i) => {
1366
+ var _a2, _b;
1367
+ const btn = {
1368
+ type: "li",
1369
+ children: [{
1370
+ type: "button",
1371
+ attrs: { "data-access-action": "iframeModals", "data-access-url": im.iframeUrl },
1372
+ children: [{ type: "#text", text: im.buttonText }]
1373
+ }]
1374
+ };
1375
+ const icon = im.icon && !((_a2 = this.options.icon) == null ? void 0 : _a2.useEmojis) ? im.icon : im.emoji && ((_b = this.options.icon) == null ? void 0 : _b.useEmojis) ? im.emoji : null;
1376
+ if (icon) {
1377
+ btn.children[0].attrs["data-access-iframe-index"] = String(i);
1378
+ const className = "_data-access-iframe-index-" + i;
1379
+ this._common.injectStyle(`._access-menu ul li button[data-access-action="iframeModals"][data-access-iframe-index="${i}"]:before { content: "${icon}"; }`, { className });
1380
+ this._common.deployedObjects.set("." + className, false);
1381
+ }
1382
+ const ul = json.children[1].children[0];
1383
+ if (this.options.modules.textToSpeech) ul.children.splice(ul.children.length - 2, 0, btn);
1384
+ else ul.children.push(btn);
1385
+ });
1386
+ }
1387
+ if (this.options.customFunctions) {
1388
+ this.options.customFunctions.forEach((cf, i) => {
1389
+ var _a2, _b;
1390
+ const btn = {
1391
+ type: "li",
1392
+ children: [{
1393
+ type: "button",
1394
+ attrs: { "data-access-action": "customFunctions", "data-access-custom-id": cf.id, "data-access-custom-index": String(i) },
1395
+ children: [{ type: "#text", text: cf.buttonText }]
1396
+ }]
1397
+ };
1398
+ const icon = cf.icon && !((_a2 = this.options.icon) == null ? void 0 : _a2.useEmojis) ? cf.icon : cf.emoji && ((_b = this.options.icon) == null ? void 0 : _b.useEmojis) ? cf.emoji : null;
1399
+ if (icon) {
1400
+ const className = "_data-access-custom-id-" + cf.id;
1401
+ this._common.injectStyle(`._access-menu ul li button[data-access-action="customFunctions"][data-access-custom-id="${cf.id}"]:before { content: "${icon}"; }`, { className });
1402
+ this._common.deployedObjects.set("." + className, false);
1403
+ }
1404
+ const ul = json.children[1].children[0];
1405
+ if (this.options.modules.textToSpeech) ul.children.splice(ul.children.length - 2, 0, btn);
1406
+ else ul.children.push(btn);
1407
+ });
1408
+ }
1409
+ const menuElem = this._common.jsonToHtml(json);
1410
+ this._body.appendChild(menuElem);
1411
+ setTimeout(() => {
1412
+ var _a2;
1413
+ const ic = document.getElementById("iconBigCursor");
1414
+ if (ic) {
1415
+ ic.outerHTML += '<svg version="1.1" id="iconBigCursorSvg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="position:absolute;width:19px;height:19px;top:9px;left:9px" xml:space="preserve"><path d="M 423.547 323.115 l -320 -320 c -3.051 -3.051 -7.637 -3.947 -11.627 -2.304 s -6.592 5.547 -6.592 9.856 V 480 c 0 4.501 2.837 8.533 7.083 10.048 c 4.224 1.536 8.981 0.192 11.84 -3.285 l 85.205 -104.128 l 56.853 123.179 c 1.792 3.883 5.653 6.187 9.685 6.187 c 1.408 0 2.837 -0.277 4.203 -0.875 l 74.667 -32 c 2.645 -1.131 4.736 -3.285 5.76 -5.973 c 1.024 -2.688 0.939 -5.675 -0.277 -8.299 l -57.024 -123.52 h 132.672 c 4.309 0 8.213 -2.603 9.856 -6.592 C 427.515 330.752 426.598 326.187 423.547 323.115 Z"/></svg>';
1416
+ (_a2 = document.getElementById("iconBigCursor")) == null ? void 0 : _a2.remove();
1417
+ }
1418
+ }, 1);
1419
+ this._common.deployedObjects.set("._access-menu", false);
1420
+ const addToggleListener = (el, handler) => {
1421
+ el == null ? void 0 : el.addEventListener("click", () => handler(), false);
1422
+ el == null ? void 0 : el.addEventListener("keyup", (e) => {
1423
+ if (e.key === "Enter") handler();
1424
+ }, false);
1425
+ };
1426
+ addToggleListener(menuElem.querySelector("._menu-close-btn"), () => this.toggleMenu());
1427
+ addToggleListener(menuElem.querySelector("._menu-reset-btn"), () => this.resetAll());
1428
+ return menuElem;
1429
+ }
1430
+ getVoices() {
1431
+ return new Promise((resolve) => {
1432
+ const synth = window.speechSynthesis;
1433
+ const id = setInterval(() => {
1434
+ if (synth.getVoices().length !== 0) {
1435
+ resolve(synth.getVoices());
1436
+ clearInterval(id);
1437
+ }
1438
+ }, 10);
1439
+ });
1440
+ }
1441
+ async injectTts() {
1442
+ const voices = await this.getVoices();
1443
+ const targetLang = this.options.language.textToSpeechLang.toLowerCase();
1444
+ const isLngSupported = !targetLang || voices.some(
1445
+ (v) => v.lang.toLowerCase() === targetLang || v.lang.toLowerCase().startsWith(targetLang.split("-")[0])
1446
+ );
1447
+ if (!isLngSupported) return;
1448
+ const tts = this.common.jsonToHtml({
1449
+ type: "li",
1450
+ children: [{
1451
+ type: "button",
1452
+ attrs: { "data-access-action": "textToSpeech", title: this.parseKeys(this.options.hotkeys.keys.textToSpeech) },
1453
+ children: [
1454
+ { type: "#text", text: this.options.labels.textToSpeech },
1455
+ {
1456
+ type: "div",
1457
+ attrs: { class: "screen-reader-wrapper" },
1458
+ children: [
1459
+ { type: "div", attrs: { class: "screen-reader-wrapper-step-1", tabIndex: "-1" } },
1460
+ { type: "div", attrs: { class: "screen-reader-wrapper-step-2", tabIndex: "-1" } },
1461
+ { type: "div", attrs: { class: "screen-reader-wrapper-step-3", tabIndex: "-1" } }
1462
+ ]
1463
+ }
1464
+ ]
1465
+ }]
1466
+ });
1467
+ const sts = this.common.jsonToHtml({
1468
+ type: "li",
1469
+ children: [{
1470
+ type: "button",
1471
+ attrs: { "data-access-action": "speechToText", title: this.parseKeys(this.options.hotkeys.keys.speechToText) },
1472
+ children: [{ type: "#text", text: this.options.labels.speechToText }]
1473
+ }]
1474
+ });
1475
+ const ul = this._menu.querySelector("ul");
1476
+ ul.appendChild(sts);
1477
+ ul.appendChild(tts);
1478
+ }
1479
+ addListeners() {
1480
+ this._menu.querySelectorAll("ul li").forEach((li) => {
1481
+ ["click", "keyup"].forEach(
1482
+ (evt) => li.addEventListener(evt, (e) => {
1483
+ const ev = e || window.event;
1484
+ if (ev.detail === 0 && ev.key !== "Enter") return;
1485
+ const actionEl = ev.target.closest("[data-access-action]");
1486
+ if (!actionEl) return;
1487
+ this.invoke(actionEl.getAttribute("data-access-action"), actionEl);
1488
+ })
1489
+ );
1490
+ });
1491
+ [
1492
+ ...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-1")),
1493
+ ...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-2")),
1494
+ ...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-3"))
1495
+ ].forEach(
1496
+ (el) => el.addEventListener("click", (e) => {
1497
+ const action = e.target.parentElement.parentElement.getAttribute("data-access-action");
1498
+ this.invoke(action, e.target);
1499
+ }, false)
1500
+ );
1501
+ }
1502
+ sortModuleTypes() {
1503
+ this.options.modulesOrder.sort((a, b) => a.order - b.order);
1504
+ }
1505
+ disableUnsupportedModulesAndSort() {
1506
+ this.sortModuleTypes();
1507
+ const ul = this._menu.querySelector("ul");
1508
+ this.options.modulesOrder.forEach((item) => {
1509
+ const module2 = AccessibilityModulesType[item.type];
1510
+ const enabled = this.options.modules[module2];
1511
+ const btn = this._menu.querySelector(`button[data-access-action="${module2}"]`);
1512
+ if (btn) {
1513
+ btn.parentElement.remove();
1514
+ ul.appendChild(btn.parentElement);
1515
+ if (!enabled) btn.parentElement.classList.add("not-supported");
1516
+ }
1517
+ });
1518
+ }
1519
+ resetAll() {
1520
+ this.menuInterface.textToSpeech(true);
1521
+ this.menuInterface.speechToText(true);
1522
+ this.menuInterface.disableAnimations(true);
1523
+ this.menuInterface.underlineLinks(true);
1524
+ this.menuInterface.grayHues(true);
1525
+ this.menuInterface.invertColors(true);
1526
+ this.menuInterface.bigCursor(true);
1527
+ this.menuInterface.readingGuide(true);
1528
+ this.menuInterface.dyslexicFont(true);
1529
+ this.menuInterface.hideImages(true);
1530
+ this.resetTextSize();
1531
+ this.resetTextSpace();
1532
+ this.resetLineHeight();
1533
+ this.menuInterface.refreshCycleButtons();
1534
+ }
1535
+ resetTextSize() {
1536
+ this.resetIfDefined(this._stateValues.body.fontSize, this._body.style, "fontSize");
1537
+ if (typeof this._htmlOrgFontSize !== "undefined") this._html.style.fontSize = this._htmlOrgFontSize;
1538
+ document.querySelectorAll("[data-init-font-size]").forEach((el) => {
1539
+ el.style.fontSize = el.getAttribute("data-init-font-size");
1540
+ el.removeAttribute("data-init-font-size");
1541
+ });
1542
+ this._sessionState.textSize = 0;
1543
+ this.onChange(true);
1544
+ }
1545
+ resetLineHeight() {
1546
+ this.resetIfDefined(this._stateValues.body.lineHeight, this.body.style, "lineHeight");
1547
+ document.querySelectorAll("[data-init-line-height]").forEach((el) => {
1548
+ el.style.lineHeight = el.getAttribute("data-init-line-height");
1549
+ el.removeAttribute("data-init-line-height");
1550
+ });
1551
+ this.sessionState.lineHeight = 0;
1552
+ this.onChange(true);
1553
+ }
1554
+ resetTextSpace() {
1555
+ this.resetIfDefined(this._stateValues.body.wordSpacing, this._body.style, "wordSpacing");
1556
+ this.resetIfDefined(this._stateValues.body.letterSpacing, this._body.style, "letterSpacing");
1557
+ document.querySelectorAll("[data-init-word-spacing]").forEach((el) => {
1558
+ el.style.wordSpacing = el.getAttribute("data-init-word-spacing");
1559
+ el.removeAttribute("data-init-word-spacing");
1560
+ });
1561
+ document.querySelectorAll("[data-init-letter-spacing]").forEach((el) => {
1562
+ el.style.letterSpacing = el.getAttribute("data-init-letter-spacing");
1563
+ el.removeAttribute("data-init-letter-spacing");
1564
+ });
1565
+ this._sessionState.textSpace = 0;
1566
+ this.onChange(true);
1567
+ }
1568
+ alterTextSize(isIncrease) {
1569
+ this._sessionState.textSize += isIncrease ? 1 : -1;
1570
+ this.onChange(true);
1571
+ let factor = this.options.textSizeFactor * (isIncrease ? 1 : -1);
1572
+ if (this.options.textPixelMode) {
1573
+ const excludeSize = Array.from(document.querySelectorAll("._access *"));
1574
+ document.querySelectorAll("*:not(._access)").forEach((el) => {
1575
+ if (excludeSize.includes(el)) return;
1576
+ const fSize = getComputedStyle(el).fontSize;
1577
+ if (fSize == null ? void 0 : fSize.includes("px")) {
1578
+ if (!el.getAttribute("data-init-font-size")) el.setAttribute("data-init-font-size", fSize);
1579
+ el.style.fontSize = parseInt(fSize) + factor + "px";
1580
+ }
1581
+ });
1582
+ const bodyFs = getComputedStyle(this._body).fontSize;
1583
+ if (bodyFs == null ? void 0 : bodyFs.includes("px")) {
1584
+ if (!this._body.getAttribute("data-init-font-size")) this._body.setAttribute("data-init-font-size", bodyFs);
1585
+ this._body.style.fontSize = parseInt(bodyFs) + factor + "px";
1586
+ }
1587
+ } else if (this.options.textEmlMode) {
1588
+ const fp = this._html.style.fontSize;
1589
+ if (fp.includes("%")) this._html.style.fontSize = parseInt(fp) + factor + "%";
1590
+ else this._common.warn("textEmlMode: html element font-size is not in %.");
1591
+ } else {
1592
+ const fSize = this._common.getFormattedDim(getComputedStyle(this._body).fontSize);
1593
+ if (typeof this._stateValues.body.fontSize === "undefined")
1594
+ this._stateValues.body.fontSize = fSize.size + fSize.suffix;
1595
+ if (fSize == null ? void 0 : fSize.suffix) this._body.style.fontSize = fSize.size + factor + fSize.suffix;
1596
+ }
1597
+ if (this._stateValues.textToSpeech) this.textToSpeech(`Text Size ${isIncrease ? "Increased" : "Decreased"}`);
1598
+ }
1599
+ alterLineHeight(isIncrease) {
1600
+ this.sessionState.lineHeight += isIncrease ? 1 : -1;
1601
+ this.onChange(true);
1602
+ let factor = (isIncrease ? 1 : -1) * (this.options.textEmlMode ? 20 : 2);
1603
+ const exclude = Array.from(document.querySelectorAll("._access *"));
1604
+ document.querySelectorAll("*:not(._access)").forEach((el) => {
1605
+ if (exclude.includes(el)) return;
1606
+ if (this.options.textPixelMode) {
1607
+ const lh = getComputedStyle(el).lineHeight;
1608
+ if (lh == null ? void 0 : lh.includes("px")) {
1609
+ if (!el.getAttribute("data-init-line-height")) el.setAttribute("data-init-line-height", lh);
1610
+ el.style.lineHeight = parseInt(lh) + factor + "px";
1611
+ }
1612
+ } else if (this.options.textEmlMode) {
1613
+ let lh = getComputedStyle(el).lineHeight;
1614
+ const fs = getComputedStyle(el).fontSize;
1615
+ if (lh === "normal") lh = parseInt(fs) * 1.2 + "px";
1616
+ if (lh == null ? void 0 : lh.includes("px")) {
1617
+ const pct = parseInt(lh) * 100 / parseInt(fs);
1618
+ if (!el.getAttribute("data-init-line-height")) el.setAttribute("data-init-line-height", pct + "%");
1619
+ el.style.lineHeight = pct + factor + "%";
1620
+ }
1621
+ if (typeof this._stateValues.body.lineHeight === "undefined") this._stateValues.body.lineHeight = "";
1622
+ }
1623
+ });
1624
+ if (this._stateValues.textToSpeech) this.textToSpeech(`Line Height ${isIncrease ? "Increased" : "Decreased"}`);
1625
+ }
1626
+ alterTextSpace(isIncrease) {
1627
+ this._sessionState.textSpace += isIncrease ? 1 : -1;
1628
+ this.onChange(true);
1629
+ const factor = isIncrease ? 2 : -2;
1630
+ if (this.options.textPixelMode) {
1631
+ const exclude = Array.from(document.querySelectorAll("._access *"));
1632
+ document.querySelectorAll("*:not(._access)").forEach((el) => {
1633
+ if (exclude.includes(el)) return;
1634
+ const ws = el.style.wordSpacing;
1635
+ if (!el.getAttribute("data-init-word-spacing")) el.setAttribute("data-init-word-spacing", ws);
1636
+ el.style.wordSpacing = (ws == null ? void 0 : ws.includes("px")) ? parseInt(ws) + factor + "px" : factor + "px";
1637
+ const ls = el.style.letterSpacing;
1638
+ if (!el.getAttribute("data-init-letter-spacing")) el.setAttribute("data-init-letter-spacing", ls);
1639
+ el.style.letterSpacing = (ls == null ? void 0 : ls.includes("px")) ? parseInt(ls) + factor + "px" : factor + "px";
1640
+ });
1641
+ } else {
1642
+ const ws = this._common.getFormattedDim(getComputedStyle(this._body).wordSpacing);
1643
+ if (typeof this._stateValues.body.wordSpacing === "undefined") this._stateValues.body.wordSpacing = "";
1644
+ if (ws == null ? void 0 : ws.suffix) this._body.style.wordSpacing = ws.size * 1 + factor + ws.suffix;
1645
+ const ls = this._common.getFormattedDim(getComputedStyle(this._body).letterSpacing);
1646
+ if (typeof this._stateValues.body.letterSpacing === "undefined") this._stateValues.body.letterSpacing = "";
1647
+ if (ls == null ? void 0 : ls.suffix) this._body.style.letterSpacing = ls.size * 1 + factor + ls.suffix;
1648
+ }
1649
+ if (this._stateValues.textToSpeech) this.textToSpeech(`Text Spacing ${isIncrease ? "Increased" : "Decreased"}`);
1650
+ }
1651
+ speechToText() {
1652
+ const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
1653
+ if (!SR) return;
1654
+ this._recognition = new SR();
1655
+ this._recognition.continuous = true;
1656
+ this._recognition.interimResults = true;
1657
+ this._recognition.onstart = () => this._body.classList.add("_access-listening");
1658
+ this._recognition.onend = () => this._body.classList.remove("_access-listening");
1659
+ this._recognition.onresult = (event) => {
1660
+ if (typeof event.results === "undefined") return;
1661
+ let final = "";
1662
+ for (let i = event.resultIndex; i < event.results.length; ++i)
1663
+ if (event.results[i].isFinal) final += event.results[i][0].transcript;
1664
+ if (final && this._speechToTextTarget) {
1665
+ this._speechToTextTarget.parentElement.classList.remove("_access-listening");
1666
+ const tag = this._speechToTextTarget.tagName.toLowerCase();
1667
+ if (tag === "input" || tag === "textarea")
1668
+ this._speechToTextTarget.value = final;
1669
+ else if (this._speechToTextTarget.getAttribute("contenteditable") !== null)
1670
+ this._speechToTextTarget.innerText = final;
1671
+ }
1672
+ };
1673
+ this._recognition.lang = this.options.language.speechToTextLang;
1674
+ this._recognition.start();
1675
+ }
1676
+ textToSpeech(text) {
1677
+ const w = window;
1678
+ if (!w.SpeechSynthesisUtterance || !w.speechSynthesis) return;
1679
+ const msg = new w.SpeechSynthesisUtterance(text);
1680
+ msg.lang = this.options.language.textToSpeechLang;
1681
+ msg.rate = this._stateValues.speechRate;
1682
+ msg.onend = () => {
1683
+ this._isReading = false;
1684
+ };
1685
+ const voices = w.speechSynthesis.getVoices();
1686
+ const voice = voices.find((v) => v.lang === msg.lang);
1687
+ if (voice) msg.voice = voice;
1688
+ else this._common.warn("text to speech language not supported!");
1689
+ if (window.speechSynthesis.pending || window.speechSynthesis.speaking) window.speechSynthesis.cancel();
1690
+ window.speechSynthesis.speak(msg);
1691
+ this._isReading = true;
1692
+ }
1693
+ createScreenShot(url) {
1694
+ return this._common.createScreenshot(url);
1695
+ }
1696
+ listen() {
1697
+ var _a, _b, _c;
1698
+ (_b = (_a = this._recognition) == null ? void 0 : _a.stop) == null ? void 0 : _b.call(_a);
1699
+ this._speechToTextTarget = (_c = window.event) == null ? void 0 : _c.target;
1700
+ this.speechToText();
1701
+ }
1702
+ read(e) {
1703
+ var _a, _b, _c, _d, _e, _f, _g;
1704
+ try {
1705
+ e = window.event || e;
1706
+ (_a = e == null ? void 0 : e.preventDefault) == null ? void 0 : _a.call(e);
1707
+ (_b = e == null ? void 0 : e.stopPropagation) == null ? void 0 : _b.call(e);
1708
+ } catch (e2) {
1709
+ }
1710
+ const menuEls = Array.from(document.querySelectorAll("._access-menu *"));
1711
+ if (menuEls.includes((_c = window.event) == null ? void 0 : _c.target) && e instanceof MouseEvent) return;
1712
+ if (e instanceof KeyboardEvent && (e.shiftKey && e.key === "Tab" || e.key === "Tab")) {
1713
+ this.textToSpeech((_e = (_d = window.event) == null ? void 0 : _d.target) == null ? void 0 : _e.innerText);
1714
+ return;
1715
+ }
1716
+ if (this._isReading) {
1717
+ window.speechSynthesis.cancel();
1718
+ this._isReading = false;
1719
+ } else this.textToSpeech((_g = (_f = window.event) == null ? void 0 : _f.target) == null ? void 0 : _g.innerText);
1720
+ }
1721
+ runHotkey(name) {
1722
+ if (name === "toggleMenu") {
1723
+ this.toggleMenu();
1724
+ return;
1725
+ }
1726
+ if (typeof this.menuInterface[name] === "function" && this._options.modules[name])
1727
+ this.menuInterface[name](false);
1728
+ }
1729
+ toggleMenu() {
1730
+ const shouldClose = this._menu.classList.contains("close");
1731
+ setTimeout(() => this._menu.querySelector("ul").classList.toggle("before-collapse"), shouldClose ? 10 : 500);
1732
+ this._menu.classList.toggle("close");
1733
+ this.options.icon.tabIndex = shouldClose ? 0 : -1;
1734
+ this._menu.childNodes.forEach((child) => {
1735
+ if (child.hasChildNodes() && child.nodeType === Node.ELEMENT_NODE && child.tagName === "P")
1736
+ child.tabIndex = -1;
1737
+ });
1738
+ }
1739
+ invoke(action, button) {
1740
+ if (typeof this.menuInterface[action] === "function")
1741
+ this.menuInterface[action](void 0, button);
1742
+ }
1743
+ onKeyDown(e) {
1744
+ const act = Object.entries(this.options.hotkeys.keys).find(
1745
+ ([, keys]) => keys.every((k) => Number.isInteger(k) ? e.keyCode === k : e[k] === true)
1746
+ );
1747
+ if (act) this.runHotkey(act[0]);
1748
+ }
1749
+ build() {
1750
+ this._stateValues = { underlineLinks: false, textToSpeech: false, bigCursor: false, readingGuide: false, speechRate: 1, body: {}, html: {} };
1751
+ this._body = document.body;
1752
+ this._html = document.documentElement;
1753
+ if (this.options.textEmlMode) this.initFontSize();
1754
+ this.injectCss(!this.options.suppressCssInjection && !this.options.suppressDomInjection);
1755
+ if (!this.options.suppressDomInjection) {
1756
+ this._icon = this.injectIcon();
1757
+ this._menu = this.injectMenu();
1758
+ this.injectTts();
1759
+ setTimeout(() => {
1760
+ this.addListeners();
1761
+ this.disableUnsupportedModulesAndSort();
1762
+ }, 10);
1763
+ if (this.options.hotkeys.enabled) document.addEventListener("keydown", this._onKeyDownBind, false);
1764
+ this._icon.addEventListener("click", () => this.toggleMenu(), false);
1765
+ this._icon.addEventListener("keyup", (e) => {
1766
+ if (e.key === "Enter") this.toggleMenu();
1767
+ }, false);
1768
+ setTimeout(() => {
1769
+ this._icon.style.opacity = "1";
1770
+ }, 10);
1771
+ document.addEventListener("keydown", (e) => {
1772
+ if (e.key === "Escape" && !this._menu.classList.contains("close")) this.toggleMenu();
1773
+ }, false);
1774
+ document.addEventListener("click", (e) => {
1775
+ if (this._menu.classList.contains("close")) return;
1776
+ if (this._menu.contains(e.target) || this._icon.contains(e.target)) return;
1777
+ this.toggleMenu();
1778
+ }, false);
1779
+ }
1780
+ this.updateReadGuide = (e) => {
1781
+ const newPos = e.type === "touchmove" ? e.changedTouches[0].clientY : e.y;
1782
+ const bar = document.getElementById("access_read_guide_bar");
1783
+ if (bar) bar.style.top = newPos - (parseInt(this.options.guide.height) + 5) + "px";
1784
+ };
1785
+ this.menuInterface = new MenuInterface(this);
1786
+ if (this.options.session.persistent) this.setSessionFromCache();
1787
+ }
1788
+ updateReadGuide(e) {
1789
+ const newPos = e.type === "touchmove" ? e.changedTouches[0].clientY : e.y;
1790
+ const bar = document.getElementById("access_read_guide_bar");
1791
+ if (bar) bar.style.top = newPos - (parseInt(this.options.guide.height) + 5) + "px";
1792
+ }
1793
+ resetIfDefined(src, dest, prop) {
1794
+ if (typeof src !== "undefined") dest[prop] = src;
1795
+ }
1796
+ onChange(updateSession) {
1797
+ if (updateSession && this.options.session.persistent) this.saveSession();
1798
+ }
1799
+ saveSession() {
1800
+ this._storage.set("_accessState", this.sessionState);
1801
+ }
1802
+ setSessionFromCache() {
1803
+ const s = this._storage.get("_accessState");
1804
+ if (!s) return;
1805
+ if (s.textSize) {
1806
+ let n = s.textSize;
1807
+ if (n > 0) while (n--) this.alterTextSize(true);
1808
+ else while (n++) this.alterTextSize(false);
1809
+ }
1810
+ if (s.textSpace) {
1811
+ let n = s.textSpace;
1812
+ if (n > 0) while (n--) this.alterTextSpace(true);
1813
+ else while (n++) this.alterTextSpace(false);
1814
+ }
1815
+ if (s.lineHeight) {
1816
+ let n = s.lineHeight;
1817
+ if (n > 0) while (n--) this.alterLineHeight(true);
1818
+ else while (n++) this.alterLineHeight(false);
1819
+ }
1820
+ if (s.invertColors) this.menuInterface.invertColors();
1821
+ if (s.grayHues) this.menuInterface.grayHues();
1822
+ if (s.underlineLinks) this.menuInterface.underlineLinks();
1823
+ if (s.bigCursor) this.menuInterface.bigCursor();
1824
+ if (s.readingGuide) this.menuInterface.readingGuide();
1825
+ this.sessionState = s;
1826
+ }
1827
+ destroy() {
1828
+ this._common.deployedObjects.getAll().forEach((_, key) => {
1829
+ var _a, _b;
1830
+ (_b = (_a = document.querySelector(key)) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.removeChild(document.querySelector(key));
1831
+ });
1832
+ document.removeEventListener("keydown", this._onKeyDownBind, false);
1833
+ }
1834
+ };
1835
+ _Accessibility.CSS_CLASS_NAME = "_access-main-css";
1836
+ _Accessibility.MENU_WIDTH = "20vw";
1837
+ var Accessibility = _Accessibility;
1838
+ var main_default = Accessibility;
1839
+
1840
+ // src/theme.ts
1841
+ var VAR_MAP = {
1842
+ primaryColor: ["--_access-icon-bg", "--_access-menu-item-button-active-background-color"],
1843
+ menuBackground: "--_access-menu-background-color",
1844
+ menuColor: "--_access-menu-color",
1845
+ iconBackground: "--_access-icon-bg",
1846
+ iconColor: "--_access-icon-color",
1847
+ menuWidth: "--_access-menu-width",
1848
+ borderRadius: ["--_access-menu-border-radius", "--_access-icon-border-radius", "--_access-menu-item-button-border-radius"],
1849
+ fontFamily: "--_access-menu-font-family",
1850
+ itemColor: "--_access-menu-item-color",
1851
+ itemButtonBackground: "--_access-menu-item-button-background",
1852
+ itemButtonHoverBackground: "--_access-menu-item-button-hover-background-color",
1853
+ itemIconColor: "--_access-menu-item-icon-color",
1854
+ iconBoxShadow: "--_access-icon-box-shadow",
1855
+ menuHeight: "--_access-menu-height",
1856
+ menuMaxHeight: "--_access-menu-max-height",
1857
+ menuTop: "--_access-menu-top"
1858
+ };
1859
+ function createThemeCss(theme) {
1860
+ const declarations = [];
1861
+ for (const [key, value] of Object.entries(theme)) {
1862
+ if (!value) continue;
1863
+ const vars = VAR_MAP[key];
1864
+ if (!vars) continue;
1865
+ const varList = Array.isArray(vars) ? vars : [vars];
1866
+ varList.forEach((v) => declarations.push(` ${v}: ${value};`));
1867
+ }
1868
+ return `:root {
1869
+ ${declarations.join("\n")}
1870
+ }`;
1871
+ }
1872
+ function applyTheme(theme) {
1873
+ const css = createThemeCss(theme);
1874
+ const id = "accessibility-widget-theme";
1875
+ const existing = document.getElementById(id);
1876
+ if (existing) {
1877
+ existing.textContent = css;
1878
+ return;
1879
+ }
1880
+ const style = document.createElement("style");
1881
+ style.id = id;
1882
+ style.textContent = css;
1883
+ document.head.appendChild(style);
1884
+ }
1885
+ function removeTheme() {
1886
+ var _a;
1887
+ (_a = document.getElementById("accessibility-widget-theme")) == null ? void 0 : _a.remove();
1888
+ }
1889
+
1890
+ // src/presets/pt-br.ts
1891
+ var ptBRLabels = {
1892
+ resetTitle: "Resetar",
1893
+ closeTitle: "Fechar",
1894
+ menuTitle: "Menu de Acessibilidade",
1895
+ increaseText: "Aumentar texto",
1896
+ decreaseText: "Diminuir texto",
1897
+ increaseTextSpacing: "Aumentar espa\xE7amento",
1898
+ decreaseTextSpacing: "Diminuir espa\xE7amento",
1899
+ invertColors: "Inverter cores",
1900
+ grayHues: "Tons de cinza",
1901
+ bigCursor: "Cursor grande",
1902
+ readingGuide: "Guia de leitura",
1903
+ underlineLinks: "Sublinhar links",
1904
+ textToSpeech: "Texto para fala",
1905
+ speechToText: "Fala para texto",
1906
+ disableAnimations: "Desativar anima\xE7\xF5es",
1907
+ increaseLineHeight: "Aumentar altura de linha",
1908
+ decreaseLineHeight: "Diminuir altura de linha",
1909
+ hotkeyPrefix: "Atalho: ",
1910
+ dyslexicFont: "Fonte para dislexia",
1911
+ hideImages: "Ocultar imagens"
1912
+ };
1913
+
1914
+ // src/presets/modules.ts
1915
+ function createModule(config) {
1916
+ var _a;
1917
+ return {
1918
+ id: config.id,
1919
+ buttonText: config.label,
1920
+ icon: config.icon,
1921
+ emoji: config.emoji,
1922
+ toggle: (_a = config.toggle) != null ? _a : true,
1923
+ method: (_cf, active) => {
1924
+ var _a2;
1925
+ if (active) config.onActivate();
1926
+ else (_a2 = config.onDeactivate) == null ? void 0 : _a2.call(config);
1927
+ }
1928
+ };
1929
+ }
1930
+ function createModules(configs) {
1931
+ return configs.map(createModule);
1932
+ }
1933
+
1934
+ // src/accessibility.ts
1935
+ if (typeof window !== "undefined") {
1936
+ window.Accessibility = main_default;
1937
+ }
1938
+ var accessibility_default = main_default;
1939
+ //# sourceMappingURL=index.js.map