@yuktishaalaa/yuktai 1.0.13 → 2.0.2
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/README.md +338 -0
- package/dist/index.cjs +5 -19
- package/dist/index.d.cts +43 -9
- package/dist/index.d.ts +43 -9
- package/dist/index.js +5 -19
- package/package.json +56 -5
package/README.md
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# @yuktishaalaa/yuktai
|
|
2
|
+
|
|
3
|
+
> Universal runtime accessibility plugin — automatically fixes WCAG violations on every page, for every user, with zero configuration.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@yuktishaalaa/yuktai)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i @yuktishaalaa/yuktai
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
|
|
20
|
+
yuktai scans every HTML element on the page and automatically injects missing accessibility attributes — `aria-label`, `alt`, `role`, `tabindex`, `scope`, `autocomplete`, `aria-required`, `aria-expanded`, and more. It also:
|
|
21
|
+
|
|
22
|
+
- Injects a skip-to-content link
|
|
23
|
+
- Ensures `<html lang>` and `<title>` are present
|
|
24
|
+
- Fixes `<meta viewport>` if it blocks user zoom
|
|
25
|
+
- Watches for new DOM elements via `MutationObserver` and fixes them as they appear
|
|
26
|
+
- Applies user-controlled visual preferences (high contrast, reduce motion, font scale, dyslexia font, colour-blind simulation)
|
|
27
|
+
|
|
28
|
+
The floating button appears bottom-left. Click it, enable settings, click **Apply settings**.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## React
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
// src/App.tsx
|
|
36
|
+
import { YuktAIWrapper } from "@yuktishaalaa/yuktai";
|
|
37
|
+
|
|
38
|
+
export default function App() {
|
|
39
|
+
return (
|
|
40
|
+
<YuktAIWrapper position="left">
|
|
41
|
+
<YourAppContent />
|
|
42
|
+
</YuktAIWrapper>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Props**
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `position` | `"left" \| "right"` | `"left"` | Side the FAB appears on |
|
|
52
|
+
| `children` | `ReactNode` | required | Your app content |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Next.js (App Router)
|
|
57
|
+
|
|
58
|
+
**Step 1 — next.config.js** (required)
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const nextConfig = {
|
|
62
|
+
transpilePackages: ["@yuktishaalaa/yuktai"],
|
|
63
|
+
};
|
|
64
|
+
module.exports = nextConfig;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Step 2 — app/layout.tsx**
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { YuktAIWrapper } from "@yuktishaalaa/yuktai";
|
|
71
|
+
|
|
72
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
73
|
+
return (
|
|
74
|
+
<html lang="en">
|
|
75
|
+
<body>
|
|
76
|
+
<YuktAIWrapper position="left">
|
|
77
|
+
<main>{children}</main>
|
|
78
|
+
</YuktAIWrapper>
|
|
79
|
+
</body>
|
|
80
|
+
</html>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Pages Router** — use `pages/_app.tsx` instead:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { YuktAIWrapper } from "@yuktishaalaa/yuktai";
|
|
89
|
+
import type { AppProps } from "next/app";
|
|
90
|
+
|
|
91
|
+
export default function MyApp({ Component, pageProps }: AppProps) {
|
|
92
|
+
return (
|
|
93
|
+
<YuktAIWrapper position="left">
|
|
94
|
+
<Component {...pageProps} />
|
|
95
|
+
</YuktAIWrapper>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Vue 3 / Nuxt 3
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<!-- App.vue -->
|
|
106
|
+
<script setup lang="ts">
|
|
107
|
+
import YuktAIWrapper from "@yuktishaalaa/yuktai/vue";
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<YuktAIWrapper position="left">
|
|
112
|
+
<RouterView />
|
|
113
|
+
</YuktAIWrapper>
|
|
114
|
+
</template>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Nuxt 3 — app.vue**
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<script setup lang="ts">
|
|
121
|
+
import YuktAIWrapper from "@yuktishaalaa/yuktai/vue";
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<template>
|
|
125
|
+
<YuktAIWrapper position="left">
|
|
126
|
+
<NuxtLayout>
|
|
127
|
+
<NuxtPage />
|
|
128
|
+
</NuxtLayout>
|
|
129
|
+
</YuktAIWrapper>
|
|
130
|
+
</template>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Nuxt 3 — client plugin** (`plugins/yuktai.client.ts`)
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import YuktAIWrapper from "@yuktishaalaa/yuktai/vue";
|
|
137
|
+
|
|
138
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
139
|
+
nuxtApp.vueApp.component("YuktAIWrapper", YuktAIWrapper);
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Angular
|
|
146
|
+
|
|
147
|
+
**app.module.ts**
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { YuktAIModule } from "@yuktishaalaa/yuktai/angular";
|
|
151
|
+
|
|
152
|
+
@NgModule({
|
|
153
|
+
imports: [BrowserModule, YuktAIModule],
|
|
154
|
+
bootstrap: [AppComponent],
|
|
155
|
+
})
|
|
156
|
+
export class AppModule {}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**app.component.html**
|
|
160
|
+
|
|
161
|
+
```html
|
|
162
|
+
<yuktai-a11y position="left">
|
|
163
|
+
<router-outlet></router-outlet>
|
|
164
|
+
</yuktai-a11y>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Angular 17+ standalone**
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { YuktAIComponent } from "@yuktishaalaa/yuktai/angular";
|
|
171
|
+
|
|
172
|
+
@Component({
|
|
173
|
+
standalone: true,
|
|
174
|
+
imports: [RouterOutlet, YuktAIComponent],
|
|
175
|
+
template: `
|
|
176
|
+
<yuktai-a11y position="left">
|
|
177
|
+
<router-outlet />
|
|
178
|
+
</yuktai-a11y>
|
|
179
|
+
`,
|
|
180
|
+
})
|
|
181
|
+
export class AppComponent {}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Vanilla JavaScript
|
|
187
|
+
|
|
188
|
+
**CDN — no install needed**
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<!-- Add before </body> -->
|
|
192
|
+
<script src="https://cdn.jsdelivr.net/npm/@yuktishaalaa/yuktai/vanilla/index.js"></script>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**npm import**
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
import "@yuktishaalaa/yuktai/vanilla";
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Configure position**
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<script>
|
|
205
|
+
window.YUKTAI_CONFIG = { position: "right" };
|
|
206
|
+
</script>
|
|
207
|
+
<script src="cdn.../vanilla/index.js"></script>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Programmatic API**
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
window.yuktai.apply(); // apply settings
|
|
214
|
+
window.yuktai.reset(); // reset everything
|
|
215
|
+
window.yuktai.wcagPlugin.scan(); // scan without fixing
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Web Component
|
|
221
|
+
|
|
222
|
+
Works in every framework and plain HTML — uses native Custom Elements with Shadow DOM.
|
|
223
|
+
|
|
224
|
+
**Plain HTML**
|
|
225
|
+
|
|
226
|
+
```html
|
|
227
|
+
<script type="module"
|
|
228
|
+
src="https://cdn.jsdelivr.net/npm/@yuktishaalaa/yuktai/web-component/index.js">
|
|
229
|
+
</script>
|
|
230
|
+
|
|
231
|
+
<yuktai-a11y position="left">
|
|
232
|
+
<!-- your content -->
|
|
233
|
+
</yuktai-a11y>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Inside React**
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import "@yuktishaalaa/yuktai/web-component";
|
|
240
|
+
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
<yuktai-a11y position="left">
|
|
243
|
+
<App />
|
|
244
|
+
</yuktai-a11y>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Inside Vue** — add to `vite.config.ts` first:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
plugins: [vue({
|
|
251
|
+
template: {
|
|
252
|
+
compilerOptions: {
|
|
253
|
+
isCustomElement: (tag) => tag === "yuktai-a11y",
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
})]
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
```vue
|
|
260
|
+
<script setup>
|
|
261
|
+
import "@yuktishaalaa/yuktai/web-component";
|
|
262
|
+
</script>
|
|
263
|
+
<template>
|
|
264
|
+
<yuktai-a11y position="left">
|
|
265
|
+
<RouterView />
|
|
266
|
+
</yuktai-a11y>
|
|
267
|
+
</template>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Direct engine API
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import { wcagPlugin } from "@yuktishaalaa/yuktai/core";
|
|
276
|
+
|
|
277
|
+
// Apply all WCAG rules
|
|
278
|
+
const report = wcagPlugin.applyFixes({ enabled: true });
|
|
279
|
+
console.log(report.fixed); // fixes applied
|
|
280
|
+
console.log(report.scanned); // nodes scanned
|
|
281
|
+
console.log(report.renderTime); // ms
|
|
282
|
+
|
|
283
|
+
// Scan only — no DOM changes
|
|
284
|
+
const violations = wcagPlugin.scan();
|
|
285
|
+
|
|
286
|
+
// Auto-fix new elements
|
|
287
|
+
wcagPlugin.startObserver({ enabled: true, autoFix: true });
|
|
288
|
+
wcagPlugin.stopObserver();
|
|
289
|
+
|
|
290
|
+
// Cleanup
|
|
291
|
+
wcagPlugin.removeLiveRegion();
|
|
292
|
+
wcagPlugin.removeColorBlindSvg();
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## HTML elements covered
|
|
298
|
+
|
|
299
|
+
The engine covers every HTML element:
|
|
300
|
+
|
|
301
|
+
- **Headings** — `h1` through `h6`
|
|
302
|
+
- **Text** — `p`, `span`, `abbr`, `mark`, `time`, `meter`, `progress`, and all inline elements
|
|
303
|
+
- **Images & media** — `img`, `area`, `svg`, `canvas`, `video`, `audio`, `iframe`, `object`, `embed`, `figure`
|
|
304
|
+
- **Interactive** — `button`, `a`, clickable `div`/`span`
|
|
305
|
+
- **Forms** — `input` (all types), `select`, `textarea`, `fieldset`, `label`
|
|
306
|
+
- **Tables** — `table`, `th`, `td`, `caption`
|
|
307
|
+
- **Lists** — `ul`, `ol`, `dl`, `li`, `dt`, `dd`
|
|
308
|
+
- **Landmarks** — `nav`, `header`, `footer`, `main`, `aside`, `section`, `article`, `details`, `summary`, `dialog`
|
|
309
|
+
- **Document** — `html`, `head`, `meta viewport`, `body`
|
|
310
|
+
- **ARIA widgets** — `role=tab`, `alert`, `tooltip`, `menu`, `listbox`, `slider`, `checkbox`, `combobox`, `grid`, `tree`, `spinbutton`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## The report
|
|
315
|
+
|
|
316
|
+
After clicking **Apply settings**, the panel shows:
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
✓ 12 fixes applied · 534 nodes · 1.2ms
|
|
320
|
+
✓ 0 fixes needed · 534 nodes clean · 0.8ms
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
`0 fixes needed` is a passing result — it means the page is already accessible. The render time confirms the engine ran.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Design principles
|
|
328
|
+
|
|
329
|
+
- **Zero id attributes** — no injected node ever gets an `id`. All injected nodes are tracked via module-level JavaScript references. The plugin never collides with the host app's ids.
|
|
330
|
+
- **Zero API keys** — the engine runs entirely in the browser. No external calls, no telemetry, no cost.
|
|
331
|
+
- **Zero framework lock-in** — `core/renderer.ts` has no framework imports. It works in Node.js, browsers, and test environments.
|
|
332
|
+
- **One engine, many adapters** — all adapters import from `core/renderer.ts`. The WCAG logic is written once.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## License
|
|
337
|
+
|
|
338
|
+
MIT © yuktai contributors
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
"use strict";"use client";var q=Object.create;var S=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var U=(e,n)=>{for(var s in n)S(e,s,{get:n[s],enumerable:!0})},_=(e,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Y(n))!K.call(e,t)&&t!==s&&S(e,t,{get:()=>n[t],enumerable:!(a=V(n,t))||a.enumerable});return e};var B=(e,n,s)=>(s=e!=null?q(G(e)):{},_(n||!e||!e.__esModule?S(s,"default",{value:e,enumerable:!0}):s,e)),Z=e=>_(S({},"__esModule",{value:!0}),e);var ne={};U(ne,{YuktAI:()=>N,YuktAIWrapper:()=>z,default:()=>te});module.exports=Z(ne);var k=class{plugins=new Map;register(n,s){if(!s||typeof s.execute!="function")throw new Error(`Invalid plugin: ${n}`);this.plugins.set(n,s)}use(n){return this.plugins.get(n)}async run(n,s){try{let a=this.use(n);if(!a)throw new Error(`Plugin not found: ${n}`);return await a.execute(s)}catch(a){throw console.error(`[YuktAI Runtime Error in ${n}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};var E={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var F={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var W=B(require("tesseract.js"),1),p=null,P=null;function J(e){let n=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(n)?"tel":/[\u0900-\u097F]/.test(n)?"hin":/[\u0B80-\u0BFF]/.test(n)?"tam":/[\u4E00-\u9FFF]/.test(n)?"chi_sim":/[\u3040-\u30FF]/.test(n)?"jpn":/[\u0600-\u06FF]/.test(n)?"ara":/[\u0400-\u04FF]/.test(n)?"rus":"eng"}async function Q(e){return p&&P===e||(p&&(await p.terminate(),p=null),p=await W.default.createWorker({langPath:"/tessdata",logger:()=>{}}),await p.loadLanguage(e),await p.initialize(e),P=e),p}var L={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let n=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),s=e.lang||J(await n.arrayBuffer())||"eng",a=await Q(s),{data:t}=await a.recognize(n),r=t.text?.trim();return r?{language:s,confidence:Math.round(t.confidence??0),text:r}:"\u26A0\uFE0F No text detected"}catch(n){return console.error("[ocrSmartPlugin]",n),"\u274C OCR failed"}}};var y=null,w=null,A={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},u={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let n=this.applyFixes(e);return e.autoFix&&this.startObserver(e),`yuktai-a11y: ${n.fixed} fixes applied across ${n.scanned} nodes.`},applyFixes(e){let n={fixed:0,scanned:0,details:[]};if(typeof document>"u")return n;let s=document.querySelectorAll("*");if(n.scanned=s.length,s.forEach(a=>{let t=a,r=t.tagName.toLowerCase();if((r==="a"||r==="button")&&!t.innerText?.trim()&&!t.getAttribute("aria-label")){let l=t.getAttribute("title")||"Interactive element";t.setAttribute("aria-label",l),n.details.push({tag:r,fix:`aria-label="${l}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}if(r==="img"&&!t.hasAttribute("alt")&&(t.setAttribute("alt",""),t.setAttribute("aria-hidden","true"),n.details.push({tag:r,fix:'alt="" aria-hidden="true"',element:t.outerHTML.slice(0,60)}),n.fixed++),(t.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(t).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(r)&&(t.getAttribute("role")||(t.setAttribute("role","button"),n.details.push({tag:r,fix:'role="button"',element:t.outerHTML.slice(0,60)}),n.fixed++),t.tabIndex<0&&(t.tabIndex=0,n.fixed++),t.onkeydown||(t.onkeydown=l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t.click())})),["input","select","textarea"].includes(r)){if(!t.getAttribute("aria-label")&&!t.getAttribute("aria-labelledby")){let f=t.getAttribute("placeholder")||t.getAttribute("name")||r;t.setAttribute("aria-label",f),n.details.push({tag:r,fix:`aria-label="${f}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}t.hasAttribute("required")&&!t.getAttribute("aria-required")&&(t.setAttribute("aria-required","true"),n.fixed++);let l=t;r==="input"&&!l.autocomplete&&(l.name?.includes("email")?l.autocomplete="email":l.name?.includes("tel")&&(l.autocomplete="tel"))}if(r==="table"&&!a.querySelector("th")&&(t.getAttribute("role")||(t.setAttribute("role","grid"),n.details.push({tag:r,fix:'role="grid"',element:t.outerHTML.slice(0,60)}),n.fixed++)),r==="a"){let l=t;if(l.target==="_blank"){l.rel?.includes("noopener")||(l.rel="noopener noreferrer",n.fixed++);let f=l.getAttribute("aria-label")||(l.innerText?.trim()?l.innerText.trim():"link");f.includes("opens in new window")||(l.setAttribute("aria-label",`${f} (opens in new window)`),n.fixed++)}}let g={nav:"navigation",header:"banner",footer:"contentinfo",main:"main"};if(g[r]&&!t.getAttribute("role")&&(t.setAttribute("role",g[r]),n.fixed++),e.highContrast&&(t.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(t.style.transition="none",t.style.animation="none"),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1){let l=parseFloat(window.getComputedStyle(t).fontSize);t.style.fontSize=`${l*e.fontSizeMultiplier}px`}if(e.colorBlindMode&&e.colorBlindMode!=="none"){let l=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${A[e.colorBlindMode]})`;t.style.filter=(t.style.filter?t.style.filter+" ":"")+l}e.keyboardHints&&(t.tabIndex>=0||["button","a","input","select","textarea"].includes(r))&&(t.style.outline="2px solid #007acc",t.style.outlineOffset="2px")}),e.colorBlindMode&&e.colorBlindMode!=="none"&&!w){let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("aria-hidden","true"),a.style.display="none",a.innerHTML=`
|
|
1
|
+
"use strict";var Y=Object.create;var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var Z=(n,a)=>{for(var d in a)E(n,d,{get:a[d],enumerable:!0})},W=(n,a,d,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of j(a))!U.call(n,r)&&r!==d&&E(n,r,{get:()=>a[r],enumerable:!(f=K(a,r))||f.enumerable});return n};var J=(n,a,d)=>(d=n!=null?Y(V(n)):{},W(a||!n||!n.__esModule?E(d,"default",{value:n,enumerable:!0}):d,n)),Q=n=>W(E({},"__esModule",{value:!0}),n);var ne={};Z(ne,{Runtime:()=>A,YuktAI:()=>re,YuktAIWrapper:()=>$,aiPlugin:()=>T,default:()=>$,voicePlugin:()=>C,wcag:()=>p,wcagPlugin:()=>p});module.exports=Q(ne);var v=null,M=null,R={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},z=new Set(["h1","h2","h3","h4","h5","h6"]),q=new Set(["input","select","textarea"]),N=new Set(["button","a","input","select","textarea","details","summary"]),X=new Set(["video","audio"]),ee=new Set(["ul","ol","dl"]);var te=new Set(["span","strong","em","b","i","u","s","small","mark","del","ins","sub","sup","abbr","cite","code","kbd","samp","var","time","q"]),_={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"},p={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(n){if(!n.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let a=this.applyFixes(n);return n.autoFix&&this.startObserver(n),`yuktai-a11y: ${a.fixed} fixes applied across ${a.scanned} nodes in ${a.renderTime}ms.`},scan(){let n={fixed:0,scanned:0,renderTime:0,details:[]};if(typeof document>"u")return n;let a=performance.now(),d=document.querySelectorAll("*");n.scanned=d.length;let f=(r,o,e,t)=>n.details.push({tag:r,fix:o,severity:e,element:t.outerHTML.slice(0,100)});return d.forEach(r=>{let o=r,e=o.tagName.toLowerCase();(e==="a"||e==="button")&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&f(e,"needs aria-label (empty)","critical",o),e==="img"&&!o.hasAttribute("alt")&&f(e,"needs alt text","serious",o),q.has(e)&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")&&f(e,"needs aria-label","serious",o),e==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&f(e,"iframe needs title","serious",o),X.has(e)&&!r.querySelector("track")&&!o.getAttribute("aria-label")&&f(e,"media needs captions/aria-label","serious",o),z.has(e)&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&f(e,"empty heading","moderate",o)}),n.fixed=n.details.length,n.renderTime=parseFloat((performance.now()-a).toFixed(2)),n},applyFixes(n){let a={fixed:0,scanned:0,renderTime:0,details:[]};if(typeof document>"u")return a;let d=performance.now(),f=document.querySelectorAll("*");a.scanned=f.length;let r=(o,e,t,h)=>{a.details.push({tag:o,fix:e,severity:t,element:h.outerHTML.slice(0,100)}),a.fixed++};if(f.forEach(o=>{let e=o,t=e.tagName.toLowerCase();if(t==="html"&&!e.getAttribute("lang")&&(e.setAttribute("lang","en"),r(t,'lang="en" added to <html>',"critical",e)),t==="head"&&!document.title&&(document.title=document.querySelector("h1")?.innerText?.trim()||"Page",r(t,`document.title set to "${document.title}"`,"serious",e)),t==="meta"){let i=e.getAttribute("name"),l=e.getAttribute("content")||"";i==="viewport"&&l.includes("user-scalable=no")&&(e.setAttribute("content",l.replace("user-scalable=no","user-scalable=yes")),r(t,"user-scalable=yes restored","serious",e)),i==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(l)&&(e.setAttribute("content",l.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),r(t,"maximum-scale=5 restored","serious",e))}if(t==="body"&&!document.querySelector("[data-yuktai-skip]")){let i=document.createElement("a");i.setAttribute("href","#main-content"),i.setAttribute("data-yuktai-skip","true"),i.setAttribute("aria-label","Skip to main content"),i.textContent="Skip to main content",i.style.cssText="position:fixed;top:-40px;left:0;background:#0d9488;color:#fff;padding:8px 16px;z-index:99999;font-family:system-ui;font-size:14px;border-radius:0 0 4px 0;text-decoration:none;transition:top 0.2s;",i.addEventListener("focus",()=>{i.style.top="0"}),i.addEventListener("blur",()=>{i.style.top="-40px"}),e.insertBefore(i,e.firstChild),r(t,"skip-to-content link injected","minor",e);let l=document.querySelector("main,[role='main']");l&&!l.getAttribute("tabindex")&&l.setAttribute("tabindex","-1")}if(z.has(t)&&(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",`${t.toUpperCase()} section`),r(t,`aria-label="${t.toUpperCase()} section" (empty heading)`,"moderate",e)),e.hasAttribute("onclick")&&!e.getAttribute("tabindex")&&(e.setAttribute("tabindex","0"),e.onkeydown||(e.onkeydown=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e.click())}),r(t,"tabindex=0 + keydown (clickable heading)","minor",e))),t==="p"&&e.getAttribute("dir")==="rtl"&&!e.getAttribute("lang")&&!document.documentElement.getAttribute("lang")&&(e.setAttribute("lang","ar"),r(t,'lang="ar" (rtl paragraph)',"moderate",e)),t==="img"&&(e.hasAttribute("alt")||(e.setAttribute("alt",""),e.setAttribute("aria-hidden","true"),r(t,'alt="" aria-hidden="true"',"serious",e)),e.getAttribute("role")==="presentation"&&e.getAttribute("alt")!==""&&(e.setAttribute("alt",""),r(t,'alt="" (role=presentation)',"minor",e))),t==="area"&&!e.getAttribute("alt")){let i=e.getAttribute("title")||e.getAttribute("href")||"map area";e.setAttribute("alt",i),r(t,`alt="${i}" on <area>`,"serious",e)}if(t==="svg"){if(!e.getAttribute("aria-hidden")&&!e.getAttribute("aria-label")&&!o.querySelector("title"))if(!e.getAttribute("role")||e.getAttribute("role")==="img"){let i=document.createElementNS("http://www.w3.org/2000/svg","title");i.textContent="graphic",e.prepend(i),e.setAttribute("role","img"),r(t,'role="img" + <title> injected',"moderate",e)}else e.setAttribute("aria-hidden","true"),r(t,'aria-hidden="true" (decorative svg)',"minor",e);e.getAttribute("focusable")||e.setAttribute("focusable","false")}if(t==="canvas"&&(e.getAttribute("role")||(e.setAttribute("role","img"),r(t,'role="img"',"serious",e)),e.getAttribute("aria-label")||(e.setAttribute("aria-label",e.getAttribute("title")||"canvas graphic"),r(t,"aria-label added to canvas","serious",e))),(t==="object"||t==="embed")&&!e.getAttribute("aria-label")&&!e.getAttribute("title")&&(e.setAttribute("aria-label",`embedded ${t} content`),r(t,`aria-label added to <${t}>`,"moderate",e)),t==="video"&&!o.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"video player"),r(t,"aria-label added (no captions track)","serious",e)),t==="audio"&&!o.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"audio player"),r(t,"aria-label added to audio","serious",e)),t==="iframe"&&!e.getAttribute("title")&&!e.getAttribute("aria-label")&&(e.setAttribute("title","embedded content"),e.setAttribute("aria-label","embedded content"),r(t,'title + aria-label="embedded content"',"serious",e)),t==="figure"&&!o.querySelector("figcaption")&&!e.getAttribute("aria-label")){let l=o.querySelector("img")?.getAttribute("alt");l&&(e.setAttribute("aria-label",l),r(t,"aria-label from inner img alt","minor",e))}if(t==="button"){if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let i=e.getAttribute("title")||e.getAttribute("data-label")||"button";e.setAttribute("aria-label",i),r(t,`aria-label="${i}" (empty button)`,"critical",e)}e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),a.fixed++)}if(t==="a"){let i=e;if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let l=e.getAttribute("title")||"link";e.setAttribute("aria-label",l),r(t,`aria-label="${l}" (empty link)`,"critical",e)}if(i.target==="_blank"){i.rel?.includes("noopener")||(i.rel="noopener noreferrer",a.fixed++);let l=i.getAttribute("aria-label")||i.innerText?.trim()||"link";l.includes("opens in new window")||(i.setAttribute("aria-label",`${l} (opens in new window)`),r(t,"aria-label: new-window warning","moderate",e))}!i.href&&!i.getAttribute("role")&&!i.getAttribute("tabindex")&&(i.setAttribute("role","button"),i.setAttribute("tabindex","0"),r(t,'role="button" tabindex=0 (href-less link)',"serious",e))}if((e.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(e).cursor==="pointer")&&!N.has(t)&&(e.getAttribute("role")||(e.setAttribute("role","button"),r(t,'role="button" (clickable non-interactive)',"serious",e)),e.tabIndex<0&&(e.tabIndex=0,a.fixed++),e.onkeydown||(e.onkeydown=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e.click())})),q.has(t)){let i=e;if(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let l=e.getAttribute("placeholder")||e.getAttribute("name")||e.getAttribute("title")||t;e.setAttribute("aria-label",l),r(t,`aria-label="${l}"`,"serious",e)}if(e.hasAttribute("required")&&!e.getAttribute("aria-required")&&(e.setAttribute("aria-required","true"),a.fixed++),e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),a.fixed++),e.hasAttribute("readonly")&&!e.getAttribute("aria-readonly")&&(e.setAttribute("aria-readonly","true"),a.fixed++),t==="input"&&!i.autocomplete){let l=i.name||"";i.type==="email"||l.includes("email")?(i.autocomplete="email",a.fixed++):i.type==="tel"||l.includes("tel")?(i.autocomplete="tel",a.fixed++):i.type==="password"?(i.autocomplete="current-password",a.fixed++):l.includes("firstname")||l.includes("fname")?(i.autocomplete="given-name",a.fixed++):l.includes("lastname")||l.includes("lname")?(i.autocomplete="family-name",a.fixed++):l==="name"||l.includes("fullname")?(i.autocomplete="name",a.fixed++):l.includes("zip")||l.includes("postal")?(i.autocomplete="postal-code",a.fixed++):l.includes("city")?(i.autocomplete="address-level2",a.fixed++):l.includes("country")&&(i.autocomplete="country",a.fixed++)}t==="input"&&i.type==="image"&&!e.getAttribute("alt")&&(e.setAttribute("alt",e.getAttribute("value")||"submit"),r(t,"alt added to input[type=image]","serious",e)),t==="input"&&i.type==="range"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin",i.min||"0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",i.max||"100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",i.value||"50"),a.fixed++)}if(t==="fieldset"&&!o.querySelector("legend")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","form group"),r(t,'aria-label="form group" (no legend)',"moderate",e)),t==="label"){let i=e.getAttribute("for"),l=o.querySelector("input,select,textarea");!i&&!l&&!e.getAttribute("aria-label")&&r(t,"label not associated with any control","moderate",e)}if(t==="table"&&(!o.querySelector("th")&&!e.getAttribute("role")&&(e.setAttribute("role","grid"),r(t,'role="grid" (no <th>)',"serious",e)),!o.querySelector("caption")&&!e.getAttribute("aria-label")&&!e.getAttribute("summary")&&(e.setAttribute("aria-label","data table"),r(t,'aria-label="data table" (no caption)',"moderate",e))),t==="th"&&!e.getAttribute("scope")){let i=e.closest("thead")!==null;e.setAttribute("scope",i?"col":"row"),r(t,`scope="${i?"col":"row"}"`,"moderate",e)}if(ee.has(t)&&(e.getAttribute("role")==="presentation"&&(o.querySelectorAll("li").forEach(i=>{i.getAttribute("role")||i.setAttribute("role","presentation")}),a.fixed++),(t==="ul"||t==="ol")&&!e.getAttribute("aria-label"))){let i=e.closest("nav");i&&(e.setAttribute("aria-label",i.getAttribute("aria-label")||"navigation list"),r(t,"aria-label from parent nav","minor",e))}if(t==="dt"&&!e.getAttribute("aria-label")){let i=e.nextElementSibling;(!i||i.tagName.toLowerCase()!=="dd")&&(e.setAttribute("aria-label",e.innerText?.trim()||"term"),r(t,"aria-label on <dt> (no following <dd>)","minor",e))}if(_[t]&&!e.getAttribute("role")&&(e.setAttribute("role",_[t]),r(t,`role="${_[t]}"`,"minor",e)),["nav","section","article","aside"].includes(t)){let i=o.parentElement?.querySelectorAll(t);if(i&&i.length>1&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let y=o.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim();y&&(e.setAttribute("aria-label",y),r(t,"aria-label from inner heading","moderate",e))}}if(t==="details"&&!o.querySelector("summary")){let i=document.createElement("summary");i.textContent=e.getAttribute("aria-label")||"More details",e.prepend(i),r(t,"<summary> injected","moderate",e)}if(t==="summary"&&!e.innerText?.trim()&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label","Toggle details"),r(t,'aria-label="Toggle details" (empty summary)',"moderate",e)),t==="dialog"){let i=e.getAttribute("role");if(i&&i!=="dialog"&&(e.setAttribute("role","dialog"),r(t,'role corrected to "dialog"',"serious",e)),!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let y=o.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim()||"dialog";e.setAttribute("aria-label",y),r(t,"aria-label added to dialog","serious",e)}}if(t==="abbr"&&!e.getAttribute("title")&&(e.setAttribute("title",e.innerText?.trim()||"abbreviation"),r(t,"title added to <abbr>","minor",e)),t==="time"&&!e.getAttribute("datetime")&&e.innerText?.trim()&&(e.setAttribute("datetime",e.innerText.trim()),r(t,`datetime="${e.innerText.trim()}" added`,"minor",e)),t==="mark"&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",`highlighted: ${e.innerText?.trim()?.slice(0,60)}`),r(t,"aria-label added to <mark>","minor",e)),t==="meter"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"meter"),r(t,"aria-label added to <meter>","moderate",e)),t==="progress"){!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"progress"),r(t,"aria-label added to <progress>","moderate",e));let i=e;e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",String(i.value)),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",String(i.max||1)),a.fixed++}let c=e.getAttribute("role")||"";if(c==="tab"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),a.fixed++),c==="tabpanel"&&(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tab panel"),r(t,'aria-label="tab panel"',"moderate",e)),e.getAttribute("tabindex")||(e.setAttribute("tabindex","0"),a.fixed++)),["alert","status","log","marquee"].includes(c)){if(!e.getAttribute("aria-live")){let i=c==="alert"?"assertive":"polite";e.setAttribute("aria-live",i),r(t,`aria-live="${i}" on role=${c}`,"moderate",e)}e.getAttribute("aria-atomic")||(e.setAttribute("aria-atomic","true"),a.fixed++)}c==="tooltip"&&!e.getAttribute("aria-live")&&(e.setAttribute("aria-live","polite"),a.fixed++),(c==="menu"||c==="menubar")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","menu"),r(t,'aria-label="menu"',"moderate",e)),c==="menuitem"&&e.tabIndex<0&&(e.tabIndex=-1,a.fixed++),c==="listbox"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","listbox"),r(t,'aria-label="listbox"',"moderate",e)),c==="option"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),a.fixed++),c==="slider"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","50"),a.fixed++),(c==="checkbox"||c==="radio")&&!e.getAttribute("aria-checked")&&(e.setAttribute("aria-checked","false"),r(t,`aria-checked="false" on role=${c}`,"serious",e)),c==="combobox"&&(e.getAttribute("aria-expanded")||(e.setAttribute("aria-expanded","false"),r(t,'aria-expanded="false" on combobox',"serious",e)),e.getAttribute("aria-haspopup")||(e.setAttribute("aria-haspopup","listbox"),a.fixed++)),(c==="grid"||c==="treegrid")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","data grid"),r(t,'aria-label="data grid"',"moderate",e)),c==="tree"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tree"),r(t,'aria-label="tree"',"moderate",e)),c==="treeitem"&&o.querySelector('[role="group"]')&&!e.getAttribute("aria-expanded")&&(e.setAttribute("aria-expanded","false"),a.fixed++),c==="spinbutton"&&(e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","0"),e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),a.fixed++);let b=!["html","head","meta","script","style","link","noscript"].includes(t);if(n.highContrast&&b&&!te.has(t)&&(e.style.filter="contrast(1.15) brightness(1.05)"),n.reduceMotion&&b&&(e.style.transition="none",e.style.animation="none"),n.fontSizeMultiplier&&n.fontSizeMultiplier!==1&&b){let i=parseFloat(window.getComputedStyle(e).fontSize);!isNaN(i)&&i>0&&(e.style.fontSize=`${i*n.fontSizeMultiplier}px`)}if(n.colorBlindMode&&n.colorBlindMode!=="none"&&t==="body"){let i=n.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${R[n.colorBlindMode]})`;e.style.filter=i}n.keyboardHints&&(N.has(t)||e.tabIndex>=0)&&(e.style.outline="2px solid #007acc",e.style.outlineOffset="2px")}),n.colorBlindMode&&n.colorBlindMode!=="none"&&!M){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("aria-hidden","true"),o.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",o.innerHTML=`
|
|
2
2
|
<defs>
|
|
3
|
-
<filter id="${
|
|
3
|
+
<filter id="${R.deuteranopia}">
|
|
4
4
|
<feColorMatrix type="matrix" values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
5
5
|
</filter>
|
|
6
|
-
<filter id="${
|
|
6
|
+
<filter id="${R.protanopia}">
|
|
7
7
|
<feColorMatrix type="matrix" values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
8
8
|
</filter>
|
|
9
|
-
<filter id="${
|
|
9
|
+
<filter id="${R.tritanopia}">
|
|
10
10
|
<feColorMatrix type="matrix" values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
|
|
11
11
|
</filter>
|
|
12
|
-
</defs>
|
|
13
|
-
`,document.body.appendChild(a),w=a}return this.ensureLiveRegion(),n},removeColorBlindSvg(){w?.remove(),w=null},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||y)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e),y=e},removeLiveRegion(){y?.remove(),y=null},announce(e){y&&(y.textContent=e)}};var d=B(require("react"),1);var o=require("react/jsx-runtime"),C=null,m=null,H={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},x=[80,90,100,110,120,130,140,150],$=[{id:"highContrast",label:"High contrast",description:"Boosts contrast and brightness on all elements",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables transitions and animations site-wide",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"Re-runs fixes automatically on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing for readability",icon:"Aa"}];function X({checked:e,onChange:n,label:s}){return(0,o.jsxs)("label",{"aria-label":s,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[(0,o.jsx)("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,o.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:99,background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,o.jsx)("span",{style:{position:"absolute",top:3,left:e?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function z({children:e}){let[n,s]=(0,d.useState)(!1),[a,t]=(0,d.useState)(!1),[r,M]=(0,d.useState)(H),[g,l]=(0,d.useState)(null),[f,I]=(0,d.useState)(!1),R=(0,d.useRef)(null),h=(0,d.useRef)(null);(0,d.useEffect)(()=>s(!0),[]),(0,d.useEffect)(()=>{if(C)return;let i=document.createElement("style");return i.innerHTML=`
|
|
14
|
-
*:focus-visible {
|
|
15
|
-
outline: 3px solid #0d9488 !important;
|
|
16
|
-
outline-offset: 2px !important;
|
|
17
|
-
box-shadow: 0 0 0 5px rgba(13,148,136,0.25) !important;
|
|
18
|
-
}
|
|
19
|
-
`,document.head.appendChild(i),C=i,()=>{C?.remove(),C=null}},[]),(0,d.useEffect)(()=>()=>{u.stopObserver(),u.removeLiveRegion(),u.removeColorBlindSvg()},[]),(0,d.useEffect)(()=>{if(!a)return;let i=c=>{R.current&&!R.current.contains(c.target)&&h.current&&!h.current.contains(c.target)&&t(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),(0,d.useEffect)(()=>{let i=c=>{c.key==="Escape"&&a&&(t(!1),h.current?.focus())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[a]);let v=(i,c)=>M(b=>({...b,[i]:c})),D=(0,d.useCallback)(async()=>{let i={enabled:!0,highContrast:r.highContrast,reduceMotion:r.reduceMotion,autoFix:r.autoFix},c=await u.execute(i);console.log("[yuktai-a11y]",c);let b=u.applyFixes(i);if(l(b),document.documentElement.style.fontSize=`${r.fontScale}%`,r.dyslexiaFont){if(!m){let T=document.createElement("style");T.textContent=`
|
|
20
|
-
body, body * {
|
|
21
|
-
font-family: 'Georgia', serif !important;
|
|
22
|
-
letter-spacing: 0.06em !important;
|
|
23
|
-
word-spacing: 0.12em !important;
|
|
24
|
-
line-height: 1.9 !important;
|
|
25
|
-
}
|
|
26
|
-
`,document.head.appendChild(T),m=T}}else m?.remove(),m=null;I(!0),t(!1),u.announce(`yuktai-a11y active. ${b.fixed} fixes applied. `+[r.highContrast&&"High contrast on.",r.reduceMotion&&"Motion reduced.",r.dyslexiaFont&&"Dyslexia font on.",r.fontScale!==100&&`Text at ${r.fontScale}%.`].filter(Boolean).join(" "))},[r]),j=(0,d.useCallback)(async()=>{await u.execute({enabled:!1}),document.documentElement.style.fontSize="",m?.remove(),m=null,document.querySelectorAll("*").forEach(i=>{i.style.filter="",i.style.transition="",i.style.animation=""}),M(H),l(null),I(!1),u.announce("yuktai-a11y disabled. All settings reset to defaults.")},[]);return n?(0,o.jsxs)(o.Fragment,{children:[e,(0,o.jsxs)("button",{ref:h,onClick:()=>t(i=>!i),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":a,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,right:24,width:52,height:52,borderRadius:"50%",background:f?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:i=>i.currentTarget.style.transform="scale(1.08)",onMouseLeave:i=>i.currentTarget.style.transform="scale(1)",onFocus:i=>i.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:i=>i.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[(0,o.jsx)("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:(0,o.jsx)("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),f&&(0,o.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),a&&(0,o.jsxs)("div",{ref:R,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:88,right:24,width:312,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},children:[(0,o.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[(0,o.jsxs)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:["yuktai-a11y v",u.version]}),f&&(0,o.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,o.jsx)("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,o.jsx)("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes for your page"})]}),(0,o.jsx)("button",{onClick:()=>t(!1),"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),(0,o.jsx)("div",{style:{padding:"6px 0"},children:$.map((i,c)=>(0,o.jsxs)(d.default.Fragment,{children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[(0,o.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:i.icon}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:i.label}),(0,o.jsx)("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:i.description})]})]}),(0,o.jsx)(X,{checked:r[i.id],onChange:b=>v(i.id,b),label:`Toggle ${i.label}`})]}),c<$.length-1&&(0,o.jsx)("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},i.id))}),(0,o.jsxs)("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,o.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,o.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[r.fontScale,"%"]})]}),(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,o.jsx)("button",{onClick:()=>{let i=x.indexOf(r.fontScale);i>0&&v("fontScale",x[i-1])},disabled:r.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:r.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,o.jsx)("div",{style:{flex:1,display:"flex",gap:3},children:x.map(i=>(0,o.jsx)("button",{onClick:()=>v("fontScale",i),"aria-label":`Set text size to ${i}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:i<=r.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},i))}),(0,o.jsx)("button",{onClick:()=>{let i=x.indexOf(r.fontScale);i<x.length-1&&v("fontScale",x[i+1])},disabled:r.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:r.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),g&&(0,o.jsxs)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:["\u2713 yuktai-a11y: ",g.fixed," fixes across ",g.scanned," nodes"]}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[(0,o.jsx)("button",{onClick:j,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,o.jsx)("button",{onClick:D,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})]}):(0,o.jsx)(o.Fragment,{children:e})}function ee(){if(!globalThis.__yuktai_runtime__){let e=new k;e.register(E.name,E),e.register(F.name,F),e.register(L.name,L),e.register(u.name,u),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var O=ee(),N={wcagPlugin:u,list(){return O.getPlugins()},use(e){return O.use(e)}},te=N;0&&(module.exports={YuktAI,YuktAIWrapper});
|
|
12
|
+
</defs>`,document.body.appendChild(o),M=o}return this.ensureLiveRegion(),a.renderTime=parseFloat((performance.now()-d).toFixed(2)),a},removeColorBlindSvg(){M?.remove(),M=null},startObserver(n){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(n)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||v)return;let n=document.createElement("div");n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(n),v=n},removeLiveRegion(){v?.remove(),v=null},announce(n){v&&(v.textContent=n)}};var g=require("react");var I=J(require("react"),1),s=require("react/jsx-runtime"),F={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},S=[80,90,100,110,120,130,140,150],H=[{id:"highContrast",label:"High contrast",description:"contrast(1.15) brightness on all nodes",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables all transitions & animations",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"MutationObserver on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing",icon:"Aa"}];function ie({checked:n,onChange:a,label:d}){return(0,s.jsxs)("label",{"aria-label":d,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:f=>a(f.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),(0,s.jsx)("span",{style:{position:"absolute",inset:0,borderRadius:99,background:n?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),(0,s.jsx)("span",{style:{position:"absolute",top:3,left:n?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}var P=(0,I.forwardRef)(({position:n,settings:a,report:d,isActive:f,set:r,onApply:o,onReset:e,onClose:t},h)=>(0,s.jsxs)("div",{ref:h,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:24,...n==="left"?{left:88}:{right:88},width:312,background:"#fff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui,-apple-system,sans-serif"},children:[(0,s.jsxs)("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[(0,s.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v1.0.0"}),f&&(0,s.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),(0,s.jsx)("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),(0,s.jsx)("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes \xB7 Open Source"})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),(0,s.jsx)("div",{style:{padding:"6px 0"},children:H.map((b,i)=>(0,s.jsxs)(I.default.Fragment,{children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[(0,s.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:b.icon}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:b.label}),(0,s.jsx)("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:b.description})]})]}),(0,s.jsx)(ie,{checked:a[b.id],onChange:l=>r(b.id,l),label:`Toggle ${b.label}`})]}),i<H.length-1&&(0,s.jsx)("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},b.id))}),(0,s.jsxs)("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[(0,s.jsx)("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),(0,s.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[a.fontScale,"%"]})]}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,s.jsx)("button",{onClick:()=>{let b=S.indexOf(a.fontScale);b>0&&r("fontScale",S[b-1])},disabled:a.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:a.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:a.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),(0,s.jsx)("div",{style:{flex:1,display:"flex",gap:3},children:S.map(b=>(0,s.jsx)("button",{onClick:()=>r("fontScale",b),"aria-label":`Set text size to ${b}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:b<=a.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},b))}),(0,s.jsx)("button",{onClick:()=>{let b=S.indexOf(a.fontScale);b<S.length-1&&r("fontScale",S[b+1])},disabled:a.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:a.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:a.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),d&&(0,s.jsx)("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:d.fixed>0?`\u2713 ${d.fixed} fixes applied \xB7 ${d.scanned} nodes \xB7 ${d.renderTime}ms`:`\u2713 0 fixes needed \xB7 ${d.scanned} nodes clean \xB7 ${d.renderTime}ms`}),(0,s.jsxs)("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[(0,s.jsx)("button",{onClick:e,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),(0,s.jsx)("button",{onClick:o,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]}));P.displayName="WidgetPanel";var m=require("react/jsx-runtime"),L=null,k=null;function $({children:n,position:a="left"}){let[d,f]=(0,g.useState)(!1),[r,o]=(0,g.useState)(!1),[e,t]=(0,g.useState)(F),[h,c]=(0,g.useState)(null),[b,i]=(0,g.useState)(!1),l=(0,g.useRef)(null),y=(0,g.useRef)(null);(0,g.useEffect)(()=>f(!0),[]),(0,g.useEffect)(()=>{if(L)return;let u=document.createElement("style");return u.innerHTML="*:focus-visible{outline:3px solid #0d9488!important;outline-offset:2px!important;box-shadow:0 0 0 5px rgba(13,148,136,.25)!important;}",document.head.appendChild(u),L=u,()=>{L?.remove(),L=null}},[]),(0,g.useEffect)(()=>()=>{p.stopObserver(),p.removeLiveRegion(),p.removeColorBlindSvg()},[]),(0,g.useEffect)(()=>{if(!r)return;let u=x=>{l.current&&!l.current.contains(x.target)&&y.current&&!y.current.contains(x.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),(0,g.useEffect)(()=>{let u=x=>{x.key==="Escape"&&r&&(o(!1),y.current?.focus())};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);let O=(u,x)=>t(w=>({...w,[u]:x})),G=(0,g.useCallback)(async()=>{let u={enabled:!0,highContrast:e.highContrast,reduceMotion:e.reduceMotion,autoFix:e.autoFix},x=await p.execute(u);if(console.log("[yuktai-a11y]",x),c(p.applyFixes(u)),document.documentElement.style.fontSize=`${e.fontScale}%`,e.dyslexiaFont){if(!k){let w=document.createElement("style");w.textContent="body,body *{font-family:'Georgia',serif!important;letter-spacing:.06em!important;word-spacing:.12em!important;line-height:1.9!important;}",document.head.appendChild(w),k=w}}else k?.remove(),k=null;i(!0),o(!1),p.announce("yuktai-a11y active.")},[e]),D=(0,g.useCallback)(async()=>{await p.execute({enabled:!1}),document.documentElement.style.fontSize="",k?.remove(),k=null,document.querySelectorAll("*").forEach(u=>{u.style.filter="",u.style.transition="",u.style.animation=""}),t(F),c(null),i(!1),p.announce("yuktai-a11y disabled.")},[]);return d?(0,m.jsxs)(m.Fragment,{children:[n,(0,m.jsxs)("button",{ref:y,onClick:()=>o(u=>!u),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":r,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,...a==="left"?{left:24}:{right:24},width:52,height:52,borderRadius:"50%",background:b?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:u=>u.currentTarget.style.transform="scale(1.08)",onMouseLeave:u=>u.currentTarget.style.transform="scale(1)",onFocus:u=>u.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:u=>u.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[(0,m.jsx)("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:(0,m.jsx)("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),b&&(0,m.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),r&&(0,m.jsx)(P,{ref:l,position:a,settings:e,report:h,isActive:b,set:O,onApply:G,onReset:D,onClose:()=>o(!1)})]}):(0,m.jsx)(m.Fragment,{children:n})}var T={name:"ai.text",async execute(n){return`\u{1F916} YuktAI says: ${n}`}};var C={name:"voice.text",async execute(n){return!n||n.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${n}`}};var A=class{plugins=new Map;register(a,d){if(!d||typeof d.execute!="function")throw new Error(`Invalid plugin: ${a}`);this.plugins.set(a,d)}use(a){return this.plugins.get(a)}async run(a,d){try{let f=this.use(a);if(!f)throw new Error(`Plugin not found: ${a}`);return await f.execute(d)}catch(f){throw console.error(`[YuktAI Runtime Error in ${a}]:`,f),f}}getPlugins(){return Array.from(this.plugins.keys())}};function ae(){if(typeof globalThis>"u")return new A;if(!globalThis.__yuktai_runtime__){let n=new A;n.register(p.name,p),n.register(T.name,T),n.register(C.name,C),globalThis.__yuktai_runtime__=n}return globalThis.__yuktai_runtime__}var B=typeof window<"u"?ae():new A,re={wcagPlugin:p,list(){return B.getPlugins()},use(n){return B.use(n)},fix(n){return p.applyFixes({enabled:!0,autoFix:!0,...n})},scan(){return p.scan()}};0&&(module.exports={Runtime,YuktAI,YuktAIWrapper,aiPlugin,voicePlugin,wcag,wcagPlugin});
|
package/dist/index.d.cts
CHANGED
|
@@ -20,28 +20,59 @@ declare class Runtime {
|
|
|
20
20
|
getPlugins(): string[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
type ColorBlindMode = "none" | "deuteranopia" | "protanopia" | "tritanopia" | "achromatopsia";
|
|
24
|
+
type Severity = "critical" | "serious" | "moderate" | "minor";
|
|
23
25
|
interface A11yConfig {
|
|
24
26
|
enabled: boolean;
|
|
25
27
|
highContrast?: boolean;
|
|
26
28
|
reduceMotion?: boolean;
|
|
27
29
|
autoFix?: boolean;
|
|
28
30
|
fontSizeMultiplier?: number;
|
|
29
|
-
colorBlindMode?:
|
|
31
|
+
colorBlindMode?: ColorBlindMode;
|
|
30
32
|
keyboardHints?: boolean;
|
|
31
33
|
}
|
|
34
|
+
interface A11yFix {
|
|
35
|
+
tag: string;
|
|
36
|
+
fix: string;
|
|
37
|
+
severity: Severity;
|
|
38
|
+
element: string;
|
|
39
|
+
}
|
|
32
40
|
interface A11yReport {
|
|
33
41
|
fixed: number;
|
|
34
42
|
scanned: number;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fix: string;
|
|
38
|
-
element: string;
|
|
39
|
-
}[];
|
|
43
|
+
renderTime: number;
|
|
44
|
+
details: A11yFix[];
|
|
40
45
|
}
|
|
46
|
+
declare const wcagPlugin: {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
observer: MutationObserver | null;
|
|
50
|
+
execute(config: A11yConfig): Promise<string>;
|
|
51
|
+
scan(): A11yReport;
|
|
52
|
+
applyFixes(config: A11yConfig): A11yReport;
|
|
53
|
+
removeColorBlindSvg(): void;
|
|
54
|
+
startObserver(config: A11yConfig): void;
|
|
55
|
+
stopObserver(): void;
|
|
56
|
+
ensureLiveRegion(): void;
|
|
57
|
+
removeLiveRegion(): void;
|
|
58
|
+
announce(msg: string): void;
|
|
59
|
+
};
|
|
41
60
|
|
|
42
|
-
|
|
61
|
+
interface YuktAIWrapperProps {
|
|
43
62
|
children?: ReactNode;
|
|
44
|
-
|
|
63
|
+
position?: "left" | "right";
|
|
64
|
+
}
|
|
65
|
+
declare function YuktAIWrapper({ children, position }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
|
|
66
|
+
|
|
67
|
+
declare const aiPlugin: {
|
|
68
|
+
name: string;
|
|
69
|
+
execute(input: string): Promise<string>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare const voicePlugin: {
|
|
73
|
+
name: string;
|
|
74
|
+
execute(input: string): Promise<string>;
|
|
75
|
+
};
|
|
45
76
|
|
|
46
77
|
declare global {
|
|
47
78
|
var __yuktai_runtime__: Runtime | undefined;
|
|
@@ -52,6 +83,7 @@ declare const YuktAI: {
|
|
|
52
83
|
version: string;
|
|
53
84
|
observer: MutationObserver | null;
|
|
54
85
|
execute(config: A11yConfig): Promise<string>;
|
|
86
|
+
scan(): A11yReport;
|
|
55
87
|
applyFixes(config: A11yConfig): A11yReport;
|
|
56
88
|
removeColorBlindSvg(): void;
|
|
57
89
|
startObserver(config: A11yConfig): void;
|
|
@@ -62,6 +94,8 @@ declare const YuktAI: {
|
|
|
62
94
|
};
|
|
63
95
|
list(): string[];
|
|
64
96
|
use(name: string): Plugin | undefined;
|
|
97
|
+
fix(config?: Partial<A11yConfig>): A11yReport;
|
|
98
|
+
scan(): A11yReport;
|
|
65
99
|
};
|
|
66
100
|
|
|
67
|
-
export { YuktAI, YuktAIWrapper,
|
|
101
|
+
export { type A11yConfig, type A11yFix, type A11yReport, type ColorBlindMode, Runtime, type Severity, YuktAI, YuktAIWrapper, type YuktAIWrapperProps, aiPlugin, YuktAIWrapper as default, voicePlugin, wcagPlugin as wcag, wcagPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,28 +20,59 @@ declare class Runtime {
|
|
|
20
20
|
getPlugins(): string[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
type ColorBlindMode = "none" | "deuteranopia" | "protanopia" | "tritanopia" | "achromatopsia";
|
|
24
|
+
type Severity = "critical" | "serious" | "moderate" | "minor";
|
|
23
25
|
interface A11yConfig {
|
|
24
26
|
enabled: boolean;
|
|
25
27
|
highContrast?: boolean;
|
|
26
28
|
reduceMotion?: boolean;
|
|
27
29
|
autoFix?: boolean;
|
|
28
30
|
fontSizeMultiplier?: number;
|
|
29
|
-
colorBlindMode?:
|
|
31
|
+
colorBlindMode?: ColorBlindMode;
|
|
30
32
|
keyboardHints?: boolean;
|
|
31
33
|
}
|
|
34
|
+
interface A11yFix {
|
|
35
|
+
tag: string;
|
|
36
|
+
fix: string;
|
|
37
|
+
severity: Severity;
|
|
38
|
+
element: string;
|
|
39
|
+
}
|
|
32
40
|
interface A11yReport {
|
|
33
41
|
fixed: number;
|
|
34
42
|
scanned: number;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fix: string;
|
|
38
|
-
element: string;
|
|
39
|
-
}[];
|
|
43
|
+
renderTime: number;
|
|
44
|
+
details: A11yFix[];
|
|
40
45
|
}
|
|
46
|
+
declare const wcagPlugin: {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
observer: MutationObserver | null;
|
|
50
|
+
execute(config: A11yConfig): Promise<string>;
|
|
51
|
+
scan(): A11yReport;
|
|
52
|
+
applyFixes(config: A11yConfig): A11yReport;
|
|
53
|
+
removeColorBlindSvg(): void;
|
|
54
|
+
startObserver(config: A11yConfig): void;
|
|
55
|
+
stopObserver(): void;
|
|
56
|
+
ensureLiveRegion(): void;
|
|
57
|
+
removeLiveRegion(): void;
|
|
58
|
+
announce(msg: string): void;
|
|
59
|
+
};
|
|
41
60
|
|
|
42
|
-
|
|
61
|
+
interface YuktAIWrapperProps {
|
|
43
62
|
children?: ReactNode;
|
|
44
|
-
|
|
63
|
+
position?: "left" | "right";
|
|
64
|
+
}
|
|
65
|
+
declare function YuktAIWrapper({ children, position }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
|
|
66
|
+
|
|
67
|
+
declare const aiPlugin: {
|
|
68
|
+
name: string;
|
|
69
|
+
execute(input: string): Promise<string>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare const voicePlugin: {
|
|
73
|
+
name: string;
|
|
74
|
+
execute(input: string): Promise<string>;
|
|
75
|
+
};
|
|
45
76
|
|
|
46
77
|
declare global {
|
|
47
78
|
var __yuktai_runtime__: Runtime | undefined;
|
|
@@ -52,6 +83,7 @@ declare const YuktAI: {
|
|
|
52
83
|
version: string;
|
|
53
84
|
observer: MutationObserver | null;
|
|
54
85
|
execute(config: A11yConfig): Promise<string>;
|
|
86
|
+
scan(): A11yReport;
|
|
55
87
|
applyFixes(config: A11yConfig): A11yReport;
|
|
56
88
|
removeColorBlindSvg(): void;
|
|
57
89
|
startObserver(config: A11yConfig): void;
|
|
@@ -62,6 +94,8 @@ declare const YuktAI: {
|
|
|
62
94
|
};
|
|
63
95
|
list(): string[];
|
|
64
96
|
use(name: string): Plugin | undefined;
|
|
97
|
+
fix(config?: Partial<A11yConfig>): A11yReport;
|
|
98
|
+
scan(): A11yReport;
|
|
65
99
|
};
|
|
66
100
|
|
|
67
|
-
export { YuktAI, YuktAIWrapper,
|
|
101
|
+
export { type A11yConfig, type A11yFix, type A11yReport, type ColorBlindMode, Runtime, type Severity, YuktAI, YuktAIWrapper, type YuktAIWrapperProps, aiPlugin, YuktAIWrapper as default, voicePlugin, wcagPlugin as wcag, wcagPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
"use client";var w=class{plugins=new Map;register(n,d){if(!d||typeof d.execute!="function")throw new Error(`Invalid plugin: ${n}`);this.plugins.set(n,d)}use(n){return this.plugins.get(n)}async run(n,d){try{let a=this.use(n);if(!a)throw new Error(`Plugin not found: ${n}`);return await a.execute(d)}catch(a){throw console.error(`[YuktAI Runtime Error in ${n}]:`,a),a}}getPlugins(){return Array.from(this.plugins.keys())}};var F={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var L={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};import q from"tesseract.js";var p=null,_=null;function V(e){let n=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(n)?"tel":/[\u0900-\u097F]/.test(n)?"hin":/[\u0B80-\u0BFF]/.test(n)?"tam":/[\u4E00-\u9FFF]/.test(n)?"chi_sim":/[\u3040-\u30FF]/.test(n)?"jpn":/[\u0600-\u06FF]/.test(n)?"ara":/[\u0400-\u04FF]/.test(n)?"rus":"eng"}async function Y(e){return p&&_===e||(p&&(await p.terminate(),p=null),p=await q.createWorker({langPath:"/tessdata",logger:()=>{}}),await p.loadLanguage(e),await p.initialize(e),_=e),p}var z={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let n=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),d=e.lang||V(await n.arrayBuffer())||"eng",a=await Y(d),{data:t}=await a.recognize(n),o=t.text?.trim();return o?{language:d,confidence:Math.round(t.confidence??0),text:o}:"\u26A0\uFE0F No text detected"}catch(n){return console.error("[ocrSmartPlugin]",n),"\u274C OCR failed"}}};var y=null,A=null,C={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},u={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(e){if(!e.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let n=this.applyFixes(e);return e.autoFix&&this.startObserver(e),`yuktai-a11y: ${n.fixed} fixes applied across ${n.scanned} nodes.`},applyFixes(e){let n={fixed:0,scanned:0,details:[]};if(typeof document>"u")return n;let d=document.querySelectorAll("*");if(n.scanned=d.length,d.forEach(a=>{let t=a,o=t.tagName.toLowerCase();if((o==="a"||o==="button")&&!t.innerText?.trim()&&!t.getAttribute("aria-label")){let r=t.getAttribute("title")||"Interactive element";t.setAttribute("aria-label",r),n.details.push({tag:o,fix:`aria-label="${r}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}if(o==="img"&&!t.hasAttribute("alt")&&(t.setAttribute("alt",""),t.setAttribute("aria-hidden","true"),n.details.push({tag:o,fix:'alt="" aria-hidden="true"',element:t.outerHTML.slice(0,60)}),n.fixed++),(t.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(t).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(o)&&(t.getAttribute("role")||(t.setAttribute("role","button"),n.details.push({tag:o,fix:'role="button"',element:t.outerHTML.slice(0,60)}),n.fixed++),t.tabIndex<0&&(t.tabIndex=0,n.fixed++),t.onkeydown||(t.onkeydown=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t.click())})),["input","select","textarea"].includes(o)){if(!t.getAttribute("aria-label")&&!t.getAttribute("aria-labelledby")){let f=t.getAttribute("placeholder")||t.getAttribute("name")||o;t.setAttribute("aria-label",f),n.details.push({tag:o,fix:`aria-label="${f}"`,element:t.outerHTML.slice(0,60)}),n.fixed++}t.hasAttribute("required")&&!t.getAttribute("aria-required")&&(t.setAttribute("aria-required","true"),n.fixed++);let r=t;o==="input"&&!r.autocomplete&&(r.name?.includes("email")?r.autocomplete="email":r.name?.includes("tel")&&(r.autocomplete="tel"))}if(o==="table"&&!a.querySelector("th")&&(t.getAttribute("role")||(t.setAttribute("role","grid"),n.details.push({tag:o,fix:'role="grid"',element:t.outerHTML.slice(0,60)}),n.fixed++)),o==="a"){let r=t;if(r.target==="_blank"){r.rel?.includes("noopener")||(r.rel="noopener noreferrer",n.fixed++);let f=r.getAttribute("aria-label")||(r.innerText?.trim()?r.innerText.trim():"link");f.includes("opens in new window")||(r.setAttribute("aria-label",`${f} (opens in new window)`),n.fixed++)}}let g={nav:"navigation",header:"banner",footer:"contentinfo",main:"main"};if(g[o]&&!t.getAttribute("role")&&(t.setAttribute("role",g[o]),n.fixed++),e.highContrast&&(t.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(t.style.transition="none",t.style.animation="none"),e.fontSizeMultiplier&&e.fontSizeMultiplier!==1){let r=parseFloat(window.getComputedStyle(t).fontSize);t.style.fontSize=`${r*e.fontSizeMultiplier}px`}if(e.colorBlindMode&&e.colorBlindMode!=="none"){let r=e.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${C[e.colorBlindMode]})`;t.style.filter=(t.style.filter?t.style.filter+" ":"")+r}e.keyboardHints&&(t.tabIndex>=0||["button","a","input","select","textarea"].includes(o))&&(t.style.outline="2px solid #007acc",t.style.outlineOffset="2px")}),e.colorBlindMode&&e.colorBlindMode!=="none"&&!A){let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("aria-hidden","true"),a.style.display="none",a.innerHTML=`
|
|
1
|
+
var h=null,E=null,M={deuteranopia:"yuktai-cb-d",protanopia:"yuktai-cb-p",tritanopia:"yuktai-cb-t"},W=new Set(["h1","h2","h3","h4","h5","h6"]),z=new Set(["input","select","textarea"]),q=new Set(["button","a","input","select","textarea","details","summary"]),V=new Set(["video","audio"]),U=new Set(["ul","ol","dl"]);var Z=new Set(["span","strong","em","b","i","u","s","small","mark","del","ins","sub","sup","abbr","cite","code","kbd","samp","var","time","q"]),$={nav:"navigation",header:"banner",footer:"contentinfo",main:"main",aside:"complementary"},p={name:"yuktai-a11y",version:"1.0.0",observer:null,async execute(n){if(!n.enabled)return this.stopObserver(),"yuktai-a11y: disabled.";let r=this.applyFixes(n);return n.autoFix&&this.startObserver(n),`yuktai-a11y: ${r.fixed} fixes applied across ${r.scanned} nodes in ${r.renderTime}ms.`},scan(){let n={fixed:0,scanned:0,renderTime:0,details:[]};if(typeof document>"u")return n;let r=performance.now(),b=document.querySelectorAll("*");n.scanned=b.length;let f=(a,o,e,t)=>n.details.push({tag:a,fix:o,severity:e,element:t.outerHTML.slice(0,100)});return b.forEach(a=>{let o=a,e=o.tagName.toLowerCase();(e==="a"||e==="button")&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&f(e,"needs aria-label (empty)","critical",o),e==="img"&&!o.hasAttribute("alt")&&f(e,"needs alt text","serious",o),z.has(e)&&!o.getAttribute("aria-label")&&!o.getAttribute("aria-labelledby")&&f(e,"needs aria-label","serious",o),e==="iframe"&&!o.getAttribute("title")&&!o.getAttribute("aria-label")&&f(e,"iframe needs title","serious",o),V.has(e)&&!a.querySelector("track")&&!o.getAttribute("aria-label")&&f(e,"media needs captions/aria-label","serious",o),W.has(e)&&!o.innerText?.trim()&&!o.getAttribute("aria-label")&&f(e,"empty heading","moderate",o)}),n.fixed=n.details.length,n.renderTime=parseFloat((performance.now()-r).toFixed(2)),n},applyFixes(n){let r={fixed:0,scanned:0,renderTime:0,details:[]};if(typeof document>"u")return r;let b=performance.now(),f=document.querySelectorAll("*");r.scanned=f.length;let a=(o,e,t,A)=>{r.details.push({tag:o,fix:e,severity:t,element:A.outerHTML.slice(0,100)}),r.fixed++};if(f.forEach(o=>{let e=o,t=e.tagName.toLowerCase();if(t==="html"&&!e.getAttribute("lang")&&(e.setAttribute("lang","en"),a(t,'lang="en" added to <html>',"critical",e)),t==="head"&&!document.title&&(document.title=document.querySelector("h1")?.innerText?.trim()||"Page",a(t,`document.title set to "${document.title}"`,"serious",e)),t==="meta"){let i=e.getAttribute("name"),l=e.getAttribute("content")||"";i==="viewport"&&l.includes("user-scalable=no")&&(e.setAttribute("content",l.replace("user-scalable=no","user-scalable=yes")),a(t,"user-scalable=yes restored","serious",e)),i==="viewport"&&/maximum-scale=1(?:[^0-9]|$)/.test(l)&&(e.setAttribute("content",l.replace(/maximum-scale=1(?=[^0-9]|$)/,"maximum-scale=5")),a(t,"maximum-scale=5 restored","serious",e))}if(t==="body"&&!document.querySelector("[data-yuktai-skip]")){let i=document.createElement("a");i.setAttribute("href","#main-content"),i.setAttribute("data-yuktai-skip","true"),i.setAttribute("aria-label","Skip to main content"),i.textContent="Skip to main content",i.style.cssText="position:fixed;top:-40px;left:0;background:#0d9488;color:#fff;padding:8px 16px;z-index:99999;font-family:system-ui;font-size:14px;border-radius:0 0 4px 0;text-decoration:none;transition:top 0.2s;",i.addEventListener("focus",()=>{i.style.top="0"}),i.addEventListener("blur",()=>{i.style.top="-40px"}),e.insertBefore(i,e.firstChild),a(t,"skip-to-content link injected","minor",e);let l=document.querySelector("main,[role='main']");l&&!l.getAttribute("tabindex")&&l.setAttribute("tabindex","-1")}if(W.has(t)&&(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",`${t.toUpperCase()} section`),a(t,`aria-label="${t.toUpperCase()} section" (empty heading)`,"moderate",e)),e.hasAttribute("onclick")&&!e.getAttribute("tabindex")&&(e.setAttribute("tabindex","0"),e.onkeydown||(e.onkeydown=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e.click())}),a(t,"tabindex=0 + keydown (clickable heading)","minor",e))),t==="p"&&e.getAttribute("dir")==="rtl"&&!e.getAttribute("lang")&&!document.documentElement.getAttribute("lang")&&(e.setAttribute("lang","ar"),a(t,'lang="ar" (rtl paragraph)',"moderate",e)),t==="img"&&(e.hasAttribute("alt")||(e.setAttribute("alt",""),e.setAttribute("aria-hidden","true"),a(t,'alt="" aria-hidden="true"',"serious",e)),e.getAttribute("role")==="presentation"&&e.getAttribute("alt")!==""&&(e.setAttribute("alt",""),a(t,'alt="" (role=presentation)',"minor",e))),t==="area"&&!e.getAttribute("alt")){let i=e.getAttribute("title")||e.getAttribute("href")||"map area";e.setAttribute("alt",i),a(t,`alt="${i}" on <area>`,"serious",e)}if(t==="svg"){if(!e.getAttribute("aria-hidden")&&!e.getAttribute("aria-label")&&!o.querySelector("title"))if(!e.getAttribute("role")||e.getAttribute("role")==="img"){let i=document.createElementNS("http://www.w3.org/2000/svg","title");i.textContent="graphic",e.prepend(i),e.setAttribute("role","img"),a(t,'role="img" + <title> injected',"moderate",e)}else e.setAttribute("aria-hidden","true"),a(t,'aria-hidden="true" (decorative svg)',"minor",e);e.getAttribute("focusable")||e.setAttribute("focusable","false")}if(t==="canvas"&&(e.getAttribute("role")||(e.setAttribute("role","img"),a(t,'role="img"',"serious",e)),e.getAttribute("aria-label")||(e.setAttribute("aria-label",e.getAttribute("title")||"canvas graphic"),a(t,"aria-label added to canvas","serious",e))),(t==="object"||t==="embed")&&!e.getAttribute("aria-label")&&!e.getAttribute("title")&&(e.setAttribute("aria-label",`embedded ${t} content`),a(t,`aria-label added to <${t}>`,"moderate",e)),t==="video"&&!o.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"video player"),a(t,"aria-label added (no captions track)","serious",e)),t==="audio"&&!o.querySelector("track")&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",e.getAttribute("title")||"audio player"),a(t,"aria-label added to audio","serious",e)),t==="iframe"&&!e.getAttribute("title")&&!e.getAttribute("aria-label")&&(e.setAttribute("title","embedded content"),e.setAttribute("aria-label","embedded content"),a(t,'title + aria-label="embedded content"',"serious",e)),t==="figure"&&!o.querySelector("figcaption")&&!e.getAttribute("aria-label")){let l=o.querySelector("img")?.getAttribute("alt");l&&(e.setAttribute("aria-label",l),a(t,"aria-label from inner img alt","minor",e))}if(t==="button"){if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let i=e.getAttribute("title")||e.getAttribute("data-label")||"button";e.setAttribute("aria-label",i),a(t,`aria-label="${i}" (empty button)`,"critical",e)}e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),r.fixed++)}if(t==="a"){let i=e;if(!e.innerText?.trim()&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let l=e.getAttribute("title")||"link";e.setAttribute("aria-label",l),a(t,`aria-label="${l}" (empty link)`,"critical",e)}if(i.target==="_blank"){i.rel?.includes("noopener")||(i.rel="noopener noreferrer",r.fixed++);let l=i.getAttribute("aria-label")||i.innerText?.trim()||"link";l.includes("opens in new window")||(i.setAttribute("aria-label",`${l} (opens in new window)`),a(t,"aria-label: new-window warning","moderate",e))}!i.href&&!i.getAttribute("role")&&!i.getAttribute("tabindex")&&(i.setAttribute("role","button"),i.setAttribute("tabindex","0"),a(t,'role="button" tabindex=0 (href-less link)',"serious",e))}if((e.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(e).cursor==="pointer")&&!q.has(t)&&(e.getAttribute("role")||(e.setAttribute("role","button"),a(t,'role="button" (clickable non-interactive)',"serious",e)),e.tabIndex<0&&(e.tabIndex=0,r.fixed++),e.onkeydown||(e.onkeydown=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e.click())})),z.has(t)){let i=e;if(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let l=e.getAttribute("placeholder")||e.getAttribute("name")||e.getAttribute("title")||t;e.setAttribute("aria-label",l),a(t,`aria-label="${l}"`,"serious",e)}if(e.hasAttribute("required")&&!e.getAttribute("aria-required")&&(e.setAttribute("aria-required","true"),r.fixed++),e.hasAttribute("disabled")&&!e.getAttribute("aria-disabled")&&(e.setAttribute("aria-disabled","true"),r.fixed++),e.hasAttribute("readonly")&&!e.getAttribute("aria-readonly")&&(e.setAttribute("aria-readonly","true"),r.fixed++),t==="input"&&!i.autocomplete){let l=i.name||"";i.type==="email"||l.includes("email")?(i.autocomplete="email",r.fixed++):i.type==="tel"||l.includes("tel")?(i.autocomplete="tel",r.fixed++):i.type==="password"?(i.autocomplete="current-password",r.fixed++):l.includes("firstname")||l.includes("fname")?(i.autocomplete="given-name",r.fixed++):l.includes("lastname")||l.includes("lname")?(i.autocomplete="family-name",r.fixed++):l==="name"||l.includes("fullname")?(i.autocomplete="name",r.fixed++):l.includes("zip")||l.includes("postal")?(i.autocomplete="postal-code",r.fixed++):l.includes("city")?(i.autocomplete="address-level2",r.fixed++):l.includes("country")&&(i.autocomplete="country",r.fixed++)}t==="input"&&i.type==="image"&&!e.getAttribute("alt")&&(e.setAttribute("alt",e.getAttribute("value")||"submit"),a(t,"alt added to input[type=image]","serious",e)),t==="input"&&i.type==="range"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin",i.min||"0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",i.max||"100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",i.value||"50"),r.fixed++)}if(t==="fieldset"&&!o.querySelector("legend")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","form group"),a(t,'aria-label="form group" (no legend)',"moderate",e)),t==="label"){let i=e.getAttribute("for"),l=o.querySelector("input,select,textarea");!i&&!l&&!e.getAttribute("aria-label")&&a(t,"label not associated with any control","moderate",e)}if(t==="table"&&(!o.querySelector("th")&&!e.getAttribute("role")&&(e.setAttribute("role","grid"),a(t,'role="grid" (no <th>)',"serious",e)),!o.querySelector("caption")&&!e.getAttribute("aria-label")&&!e.getAttribute("summary")&&(e.setAttribute("aria-label","data table"),a(t,'aria-label="data table" (no caption)',"moderate",e))),t==="th"&&!e.getAttribute("scope")){let i=e.closest("thead")!==null;e.setAttribute("scope",i?"col":"row"),a(t,`scope="${i?"col":"row"}"`,"moderate",e)}if(U.has(t)&&(e.getAttribute("role")==="presentation"&&(o.querySelectorAll("li").forEach(i=>{i.getAttribute("role")||i.setAttribute("role","presentation")}),r.fixed++),(t==="ul"||t==="ol")&&!e.getAttribute("aria-label"))){let i=e.closest("nav");i&&(e.setAttribute("aria-label",i.getAttribute("aria-label")||"navigation list"),a(t,"aria-label from parent nav","minor",e))}if(t==="dt"&&!e.getAttribute("aria-label")){let i=e.nextElementSibling;(!i||i.tagName.toLowerCase()!=="dd")&&(e.setAttribute("aria-label",e.innerText?.trim()||"term"),a(t,"aria-label on <dt> (no following <dd>)","minor",e))}if($[t]&&!e.getAttribute("role")&&(e.setAttribute("role",$[t]),a(t,`role="${$[t]}"`,"minor",e)),["nav","section","article","aside"].includes(t)){let i=o.parentElement?.querySelectorAll(t);if(i&&i.length>1&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let m=o.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim();m&&(e.setAttribute("aria-label",m),a(t,"aria-label from inner heading","moderate",e))}}if(t==="details"&&!o.querySelector("summary")){let i=document.createElement("summary");i.textContent=e.getAttribute("aria-label")||"More details",e.prepend(i),a(t,"<summary> injected","moderate",e)}if(t==="summary"&&!e.innerText?.trim()&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label","Toggle details"),a(t,'aria-label="Toggle details" (empty summary)',"moderate",e)),t==="dialog"){let i=e.getAttribute("role");if(i&&i!=="dialog"&&(e.setAttribute("role","dialog"),a(t,'role corrected to "dialog"',"serious",e)),!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")){let m=o.querySelector("h1,h2,h3,h4,h5,h6")?.textContent?.trim()||"dialog";e.setAttribute("aria-label",m),a(t,"aria-label added to dialog","serious",e)}}if(t==="abbr"&&!e.getAttribute("title")&&(e.setAttribute("title",e.innerText?.trim()||"abbreviation"),a(t,"title added to <abbr>","minor",e)),t==="time"&&!e.getAttribute("datetime")&&e.innerText?.trim()&&(e.setAttribute("datetime",e.innerText.trim()),a(t,`datetime="${e.innerText.trim()}" added`,"minor",e)),t==="mark"&&!e.getAttribute("aria-label")&&(e.setAttribute("aria-label",`highlighted: ${e.innerText?.trim()?.slice(0,60)}`),a(t,"aria-label added to <mark>","minor",e)),t==="meter"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"meter"),a(t,"aria-label added to <meter>","moderate",e)),t==="progress"){!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label",e.getAttribute("title")||"progress"),a(t,"aria-label added to <progress>","moderate",e));let i=e;e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow",String(i.value)),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax",String(i.max||1)),r.fixed++}let u=e.getAttribute("role")||"";if(u==="tab"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),r.fixed++),u==="tabpanel"&&(!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tab panel"),a(t,'aria-label="tab panel"',"moderate",e)),e.getAttribute("tabindex")||(e.setAttribute("tabindex","0"),r.fixed++)),["alert","status","log","marquee"].includes(u)){if(!e.getAttribute("aria-live")){let i=u==="alert"?"assertive":"polite";e.setAttribute("aria-live",i),a(t,`aria-live="${i}" on role=${u}`,"moderate",e)}e.getAttribute("aria-atomic")||(e.setAttribute("aria-atomic","true"),r.fixed++)}u==="tooltip"&&!e.getAttribute("aria-live")&&(e.setAttribute("aria-live","polite"),r.fixed++),(u==="menu"||u==="menubar")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","menu"),a(t,'aria-label="menu"',"moderate",e)),u==="menuitem"&&e.tabIndex<0&&(e.tabIndex=-1,r.fixed++),u==="listbox"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","listbox"),a(t,'aria-label="listbox"',"moderate",e)),u==="option"&&!e.getAttribute("aria-selected")&&(e.setAttribute("aria-selected","false"),r.fixed++),u==="slider"&&(e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","50"),r.fixed++),(u==="checkbox"||u==="radio")&&!e.getAttribute("aria-checked")&&(e.setAttribute("aria-checked","false"),a(t,`aria-checked="false" on role=${u}`,"serious",e)),u==="combobox"&&(e.getAttribute("aria-expanded")||(e.setAttribute("aria-expanded","false"),a(t,'aria-expanded="false" on combobox',"serious",e)),e.getAttribute("aria-haspopup")||(e.setAttribute("aria-haspopup","listbox"),r.fixed++)),(u==="grid"||u==="treegrid")&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","data grid"),a(t,'aria-label="data grid"',"moderate",e)),u==="tree"&&!e.getAttribute("aria-label")&&!e.getAttribute("aria-labelledby")&&(e.setAttribute("aria-label","tree"),a(t,'aria-label="tree"',"moderate",e)),u==="treeitem"&&o.querySelector('[role="group"]')&&!e.getAttribute("aria-expanded")&&(e.setAttribute("aria-expanded","false"),r.fixed++),u==="spinbutton"&&(e.getAttribute("aria-valuenow")||e.setAttribute("aria-valuenow","0"),e.getAttribute("aria-valuemin")||e.setAttribute("aria-valuemin","0"),e.getAttribute("aria-valuemax")||e.setAttribute("aria-valuemax","100"),r.fixed++);let d=!["html","head","meta","script","style","link","noscript"].includes(t);if(n.highContrast&&d&&!Z.has(t)&&(e.style.filter="contrast(1.15) brightness(1.05)"),n.reduceMotion&&d&&(e.style.transition="none",e.style.animation="none"),n.fontSizeMultiplier&&n.fontSizeMultiplier!==1&&d){let i=parseFloat(window.getComputedStyle(e).fontSize);!isNaN(i)&&i>0&&(e.style.fontSize=`${i*n.fontSizeMultiplier}px`)}if(n.colorBlindMode&&n.colorBlindMode!=="none"&&t==="body"){let i=n.colorBlindMode==="achromatopsia"?"grayscale(100%)":`url(#${M[n.colorBlindMode]})`;e.style.filter=i}n.keyboardHints&&(q.has(t)||e.tabIndex>=0)&&(e.style.outline="2px solid #007acc",e.style.outlineOffset="2px")}),n.colorBlindMode&&n.colorBlindMode!=="none"&&!E){let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("aria-hidden","true"),o.style.cssText="position:absolute;width:0;height:0;overflow:hidden;",o.innerHTML=`
|
|
2
2
|
<defs>
|
|
3
|
-
<filter id="${
|
|
3
|
+
<filter id="${M.deuteranopia}">
|
|
4
4
|
<feColorMatrix type="matrix" values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"/>
|
|
5
5
|
</filter>
|
|
6
|
-
<filter id="${
|
|
6
|
+
<filter id="${M.protanopia}">
|
|
7
7
|
<feColorMatrix type="matrix" values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"/>
|
|
8
8
|
</filter>
|
|
9
|
-
<filter id="${
|
|
9
|
+
<filter id="${M.tritanopia}">
|
|
10
10
|
<feColorMatrix type="matrix" values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"/>
|
|
11
11
|
</filter>
|
|
12
|
-
</defs>
|
|
13
|
-
`,document.body.appendChild(a),A=a}return this.ensureLiveRegion(),n},removeColorBlindSvg(){A?.remove(),A=null},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(e)),this.observer.observe(document.body,{childList:!0,subtree:!0}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||y)return;let e=document.createElement("div");e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e),y=e},removeLiveRegion(){y?.remove(),y=null},announce(e){y&&(y.textContent=e)}};import G,{useState as h,useEffect as v,useRef as B,useCallback as P}from"react";import{Fragment as $,jsx as l,jsxs as s}from"react/jsx-runtime";var M=null,m=null,W={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},x=[80,90,100,110,120,130,140,150],H=[{id:"highContrast",label:"High contrast",description:"Boosts contrast and brightness on all elements",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables transitions and animations site-wide",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"Re-runs fixes automatically on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing for readability",icon:"Aa"}];function K({checked:e,onChange:n,label:d}){return s("label",{"aria-label":d,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[l("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),l("span",{style:{position:"absolute",inset:0,borderRadius:99,background:e?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),l("span",{style:{position:"absolute",top:3,left:e?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}function O({children:e}){let[n,d]=h(!1),[a,t]=h(!1),[o,R]=h(W),[g,r]=h(null),[f,I]=h(!1),T=B(null),S=B(null);v(()=>d(!0),[]),v(()=>{if(M)return;let i=document.createElement("style");return i.innerHTML=`
|
|
14
|
-
*:focus-visible {
|
|
15
|
-
outline: 3px solid #0d9488 !important;
|
|
16
|
-
outline-offset: 2px !important;
|
|
17
|
-
box-shadow: 0 0 0 5px rgba(13,148,136,0.25) !important;
|
|
18
|
-
}
|
|
19
|
-
`,document.head.appendChild(i),M=i,()=>{M?.remove(),M=null}},[]),v(()=>()=>{u.stopObserver(),u.removeLiveRegion(),u.removeColorBlindSvg()},[]),v(()=>{if(!a)return;let i=c=>{T.current&&!T.current.contains(c.target)&&S.current&&!S.current.contains(c.target)&&t(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]),v(()=>{let i=c=>{c.key==="Escape"&&a&&(t(!1),S.current?.focus())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[a]);let k=(i,c)=>R(b=>({...b,[i]:c})),D=P(async()=>{let i={enabled:!0,highContrast:o.highContrast,reduceMotion:o.reduceMotion,autoFix:o.autoFix},c=await u.execute(i);console.log("[yuktai-a11y]",c);let b=u.applyFixes(i);if(r(b),document.documentElement.style.fontSize=`${o.fontScale}%`,o.dyslexiaFont){if(!m){let E=document.createElement("style");E.textContent=`
|
|
20
|
-
body, body * {
|
|
21
|
-
font-family: 'Georgia', serif !important;
|
|
22
|
-
letter-spacing: 0.06em !important;
|
|
23
|
-
word-spacing: 0.12em !important;
|
|
24
|
-
line-height: 1.9 !important;
|
|
25
|
-
}
|
|
26
|
-
`,document.head.appendChild(E),m=E}}else m?.remove(),m=null;I(!0),t(!1),u.announce(`yuktai-a11y active. ${b.fixed} fixes applied. `+[o.highContrast&&"High contrast on.",o.reduceMotion&&"Motion reduced.",o.dyslexiaFont&&"Dyslexia font on.",o.fontScale!==100&&`Text at ${o.fontScale}%.`].filter(Boolean).join(" "))},[o]),j=P(async()=>{await u.execute({enabled:!1}),document.documentElement.style.fontSize="",m?.remove(),m=null,document.querySelectorAll("*").forEach(i=>{i.style.filter="",i.style.transition="",i.style.animation=""}),R(W),r(null),I(!1),u.announce("yuktai-a11y disabled. All settings reset to defaults.")},[]);return n?s($,{children:[e,s("button",{ref:S,onClick:()=>t(i=>!i),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":a,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,right:24,width:52,height:52,borderRadius:"50%",background:f?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:i=>i.currentTarget.style.transform="scale(1.08)",onMouseLeave:i=>i.currentTarget.style.transform="scale(1)",onFocus:i=>i.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:i=>i.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[l("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:l("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),f&&l("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),a&&s("div",{ref:T,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:88,right:24,width:312,background:"#ffffff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif"},children:[s("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[s("div",{children:[s("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[s("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:["yuktai-a11y v",u.version]}),f&&l("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),l("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),l("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes for your page"})]}),l("button",{onClick:()=>t(!1),"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),l("div",{style:{padding:"6px 0"},children:H.map((i,c)=>s(G.Fragment,{children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[s("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[l("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:i.icon}),s("div",{children:[l("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:i.label}),l("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:i.description})]})]}),l(K,{checked:o[i.id],onChange:b=>k(i.id,b),label:`Toggle ${i.label}`})]}),c<H.length-1&&l("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},i.id))}),s("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[s("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[l("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),s("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[o.fontScale,"%"]})]}),s("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l("button",{onClick:()=>{let i=x.indexOf(o.fontScale);i>0&&k("fontScale",x[i-1])},disabled:o.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:o.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:o.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),l("div",{style:{flex:1,display:"flex",gap:3},children:x.map(i=>l("button",{onClick:()=>k("fontScale",i),"aria-label":`Set text size to ${i}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:i<=o.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},i))}),l("button",{onClick:()=>{let i=x.indexOf(o.fontScale);i<x.length-1&&k("fontScale",x[i+1])},disabled:o.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:o.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:o.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),g&&s("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:["\u2713 yuktai-a11y: ",g.fixed," fixes across ",g.scanned," nodes"]}),s("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[l("button",{onClick:j,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),l("button",{onClick:D,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]})]}):l($,{children:e})}function U(){if(!globalThis.__yuktai_runtime__){let e=new w;e.register(F.name,F),e.register(L.name,L),e.register(z.name,z),e.register(u.name,u),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var N=U(),Z={wcagPlugin:u,list(){return N.getPlugins()},use(e){return N.use(e)}},ge=Z;export{Z as YuktAI,O as YuktAIWrapper,ge as default};
|
|
12
|
+
</defs>`,document.body.appendChild(o),E=o}return this.ensureLiveRegion(),r.renderTime=parseFloat((performance.now()-b).toFixed(2)),r},removeColorBlindSvg(){E?.remove(),E=null},startObserver(n){this.observer||typeof document>"u"||(this.observer=new MutationObserver(()=>this.applyFixes(n)),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer?.disconnect(),this.observer=null},ensureLiveRegion(){if(typeof document>"u"||h)return;let n=document.createElement("div");n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(n),h=n},removeLiveRegion(){h?.remove(),h=null},announce(n){h&&(h.textContent=n)}};import{useState as w,useEffect as T,useRef as H,useCallback as B}from"react";import J,{forwardRef as Q}from"react";import{jsx as c,jsxs as g}from"react/jsx-runtime";var _={highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100},v=[80,90,100,110,120,130,140,150],N=[{id:"highContrast",label:"High contrast",description:"contrast(1.15) brightness on all nodes",icon:"\u25D1"},{id:"reduceMotion",label:"Reduce motion",description:"Disables all transitions & animations",icon:"\u23F8"},{id:"autoFix",label:"Auto-fix ARIA",description:"MutationObserver on new DOM nodes",icon:"\u267F"},{id:"dyslexiaFont",label:"Dyslexia-friendly font",description:"Wider letter & word spacing",icon:"Aa"}];function X({checked:n,onChange:r,label:b}){return g("label",{"aria-label":b,style:{position:"relative",display:"inline-flex",width:40,height:24,cursor:"pointer",flexShrink:0},children:[c("input",{type:"checkbox",checked:n,onChange:f=>r(f.target.checked),style:{opacity:0,width:0,height:0,position:"absolute"}}),c("span",{style:{position:"absolute",inset:0,borderRadius:99,background:n?"#0d9488":"#cbd5e1",transition:"background 0.2s"}}),c("span",{style:{position:"absolute",top:3,left:n?19:3,width:18,height:18,background:"#fff",borderRadius:"50%",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)",pointerEvents:"none"}})]})}var F=Q(({position:n,settings:r,report:b,isActive:f,set:a,onApply:o,onReset:e,onClose:t},A)=>g("div",{ref:A,role:"dialog","aria-modal":"true","aria-label":"yuktai-a11y accessibility options",style:{position:"fixed",bottom:24,...n==="left"?{left:88}:{right:88},width:312,background:"#fff",border:"1px solid #e2e8f0",borderRadius:16,boxShadow:"0 8px 32px rgba(0,0,0,0.12)",zIndex:9998,overflow:"hidden",fontFamily:"system-ui,-apple-system,sans-serif"},children:[g("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid #f1f5f9",display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[g("div",{children:[g("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:5},children:[c("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0d9488",letterSpacing:"0.05em",fontFamily:"monospace"},children:"@yuktishaalaa/yuktai v1.0.0"}),f&&c("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:99,background:"#f0fdfa",color:"#0f766e",border:"1px solid #99f6e4"},children:"\u25CF ACTIVE"})]}),c("p",{style:{margin:"0 0 2px",fontSize:15,fontWeight:600,color:"#0f172a"},children:"Accessibility"}),c("p",{style:{margin:0,fontSize:12,color:"#64748b"},children:"Zero-config WCAG fixes \xB7 Open Source"})]}),c("button",{onClick:t,"aria-label":"Close panel",style:{background:"none",border:"none",cursor:"pointer",padding:4,color:"#94a3b8",fontSize:18,lineHeight:1,borderRadius:6},children:"\xD7"})]}),c("div",{style:{padding:"6px 0"},children:N.map((d,i)=>g(J.Fragment,{children:[g("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",gap:12},children:[g("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1},children:[c("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:"#f0fdfa",color:"#0d9488",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,flexShrink:0,fontWeight:700},children:d.icon}),g("div",{children:[c("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:d.label}),c("p",{style:{margin:0,fontSize:11,color:"#94a3b8"},children:d.description})]})]}),c(X,{checked:r[d.id],onChange:l=>a(d.id,l),label:`Toggle ${d.label}`})]}),i<N.length-1&&c("div",{style:{height:1,background:"#f8fafc",margin:"0 18px"}})]},d.id))}),g("div",{style:{padding:"10px 18px 14px",borderTop:"1px solid #f1f5f9"},children:[g("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[c("p",{style:{margin:0,fontSize:13,fontWeight:500,color:"#0f172a"},children:"Text size"}),g("span",{style:{fontSize:12,fontWeight:600,color:"#0d9488",background:"#f0fdfa",padding:"2px 8px",borderRadius:99},children:[r.fontScale,"%"]})]}),g("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c("button",{onClick:()=>{let d=v.indexOf(r.fontScale);d>0&&a("fontScale",v[d-1])},disabled:r.fontScale<=80,"aria-label":"Decrease text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale<=80?"not-allowed":"pointer",fontSize:16,color:r.fontScale<=80?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"\u2212"}),c("div",{style:{flex:1,display:"flex",gap:3},children:v.map(d=>c("button",{onClick:()=>a("fontScale",d),"aria-label":`Set text size to ${d}%`,style:{flex:1,height:6,borderRadius:99,border:"none",cursor:"pointer",padding:0,background:d<=r.fontScale?"#0d9488":"#e2e8f0",transition:"background 0.15s"}},d))}),c("button",{onClick:()=>{let d=v.indexOf(r.fontScale);d<v.length-1&&a("fontScale",v[d+1])},disabled:r.fontScale>=150,"aria-label":"Increase text size",style:{width:30,height:30,borderRadius:8,border:"1px solid #e2e8f0",background:"#fff",cursor:r.fontScale>=150?"not-allowed":"pointer",fontSize:16,color:r.fontScale>=150?"#cbd5e1":"#0f172a",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"+"})]})]}),b&&c("div",{role:"status",style:{margin:"0 14px",padding:"8px 12px",background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,fontSize:12,color:"#0f766e",fontWeight:500,fontFamily:"monospace"},children:b.fixed>0?`\u2713 ${b.fixed} fixes applied \xB7 ${b.scanned} nodes \xB7 ${b.renderTime}ms`:`\u2713 0 fixes needed \xB7 ${b.scanned} nodes clean \xB7 ${b.renderTime}ms`}),g("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[c("button",{onClick:e,style:{flex:1,padding:"8px 0",fontSize:13,fontWeight:500,borderRadius:9,border:"1px solid #e2e8f0",background:"#fff",color:"#64748b",cursor:"pointer"},children:"Reset"}),c("button",{onClick:o,style:{flex:2,padding:"8px 0",fontSize:13,fontWeight:600,borderRadius:9,border:"none",background:"#0d9488",color:"#fff",cursor:"pointer"},children:"Apply settings"})]})]}));F.displayName="WidgetPanel";import{Fragment as O,jsx as C,jsxs as G}from"react/jsx-runtime";var R=null,S=null;function P({children:n,position:r="left"}){let[b,f]=w(!1),[a,o]=w(!1),[e,t]=w(_),[A,u]=w(null),[d,i]=w(!1),l=H(null),m=H(null);T(()=>f(!0),[]),T(()=>{if(R)return;let s=document.createElement("style");return s.innerHTML="*:focus-visible{outline:3px solid #0d9488!important;outline-offset:2px!important;box-shadow:0 0 0 5px rgba(13,148,136,.25)!important;}",document.head.appendChild(s),R=s,()=>{R?.remove(),R=null}},[]),T(()=>()=>{p.stopObserver(),p.removeLiveRegion(),p.removeColorBlindSvg()},[]),T(()=>{if(!a)return;let s=y=>{l.current&&!l.current.contains(y.target)&&m.current&&!m.current.contains(y.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[a]),T(()=>{let s=y=>{y.key==="Escape"&&a&&(o(!1),m.current?.focus())};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[a]);let Y=(s,y)=>t(k=>({...k,[s]:y})),K=B(async()=>{let s={enabled:!0,highContrast:e.highContrast,reduceMotion:e.reduceMotion,autoFix:e.autoFix},y=await p.execute(s);if(console.log("[yuktai-a11y]",y),u(p.applyFixes(s)),document.documentElement.style.fontSize=`${e.fontScale}%`,e.dyslexiaFont){if(!S){let k=document.createElement("style");k.textContent="body,body *{font-family:'Georgia',serif!important;letter-spacing:.06em!important;word-spacing:.12em!important;line-height:1.9!important;}",document.head.appendChild(k),S=k}}else S?.remove(),S=null;i(!0),o(!1),p.announce("yuktai-a11y active.")},[e]),j=B(async()=>{await p.execute({enabled:!1}),document.documentElement.style.fontSize="",S?.remove(),S=null,document.querySelectorAll("*").forEach(s=>{s.style.filter="",s.style.transition="",s.style.animation=""}),t(_),u(null),i(!1),p.announce("yuktai-a11y disabled.")},[]);return b?G(O,{children:[n,G("button",{ref:m,onClick:()=>o(s=>!s),"aria-label":"Open yuktai-a11y accessibility options","aria-expanded":a,"aria-haspopup":"dialog",style:{position:"fixed",bottom:24,...r==="left"?{left:24}:{right:24},width:52,height:52,borderRadius:"50%",background:d?"#0f766e":"#0d9488",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 14px rgba(0,0,0,0.18)",zIndex:9999,transition:"background 0.2s, transform 0.15s",outline:"none"},onMouseEnter:s=>s.currentTarget.style.transform="scale(1.08)",onMouseLeave:s=>s.currentTarget.style.transform="scale(1)",onFocus:s=>s.currentTarget.style.boxShadow="0 0 0 4px rgba(13,148,136,0.45)",onBlur:s=>s.currentTarget.style.boxShadow="0 4px 14px rgba(0,0,0,0.18)",children:[C("svg",{viewBox:"0 0 24 24",style:{width:26,height:26,fill:"#fff"},"aria-hidden":"true",children:C("path",{d:"M12 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4zm9 4.5l-5-.5-2-.2V5l-4 .5-4-.5v.8L4 6.5 3 7l1 3 4-.5v2.3L6 17h2l2-4.5L12 14l2 2.5L16 17h2l-2-4.2V9.5l4 .5 1-3z"})}),d&&C("span",{"aria-hidden":"true",style:{position:"absolute",top:4,right:4,width:10,height:10,borderRadius:"50%",background:"#5eead4",border:"2px solid #fff"}})]}),a&&C(F,{ref:l,position:r,settings:e,report:A,isActive:d,set:Y,onApply:K,onReset:j,onClose:()=>o(!1)})]}):C(O,{children:n})}var I={name:"ai.text",async execute(n){return`\u{1F916} YuktAI says: ${n}`}};var L={name:"voice.text",async execute(n){return!n||n.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${n}`}};var x=class{plugins=new Map;register(r,b){if(!b||typeof b.execute!="function")throw new Error(`Invalid plugin: ${r}`);this.plugins.set(r,b)}use(r){return this.plugins.get(r)}async run(r,b){try{let f=this.use(r);if(!f)throw new Error(`Plugin not found: ${r}`);return await f.execute(b)}catch(f){throw console.error(`[YuktAI Runtime Error in ${r}]:`,f),f}}getPlugins(){return Array.from(this.plugins.keys())}};function ee(){if(typeof globalThis>"u")return new x;if(!globalThis.__yuktai_runtime__){let n=new x;n.register(p.name,p),n.register(I.name,I),n.register(L.name,L),globalThis.__yuktai_runtime__=n}return globalThis.__yuktai_runtime__}var D=typeof window<"u"?ee():new x,we={wcagPlugin:p,list(){return D.getPlugins()},use(n){return D.use(n)},fix(n){return p.applyFixes({enabled:!0,autoFix:!0,...n})},scan(){return p.scan()}};export{x as Runtime,we as YuktAI,P as YuktAIWrapper,I as aiPlugin,P as default,L as voicePlugin,p as wcag,p as wcagPlugin};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuktishaalaa/yuktai",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Privacy-first, offline-first Indic language AI
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Privacy-first, offline-first universal accessibility engine with WCAG auto-fix, OCR, voice, and Indic language AI support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -11,6 +11,41 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./core": {
|
|
16
|
+
"types": "./dist/core/renderer.d.ts",
|
|
17
|
+
"import": "./dist/core/renderer.js",
|
|
18
|
+
"require": "./dist/core/renderer.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/core/YuktAIWrapper.d.ts",
|
|
22
|
+
"import": "./dist/core/YuktAIWrapper.js",
|
|
23
|
+
"require": "./dist/core/YuktAIWrapper.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./next": {
|
|
26
|
+
"types": "./dist/core/YuktAIWrapper.d.ts",
|
|
27
|
+
"import": "./dist/core/YuktAIWrapper.js",
|
|
28
|
+
"require": "./dist/core/YuktAIWrapper.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./plugins/ai": {
|
|
31
|
+
"types": "./dist/plugins/ai.d.ts",
|
|
32
|
+
"import": "./dist/plugins/ai.js",
|
|
33
|
+
"require": "./dist/plugins/ai.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./plugins/ocr": {
|
|
36
|
+
"types": "./dist/plugins/ocr.d.ts",
|
|
37
|
+
"import": "./dist/plugins/ocr.js",
|
|
38
|
+
"require": "./dist/plugins/ocr.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./plugins/voice": {
|
|
41
|
+
"types": "./dist/plugins/voice.d.ts",
|
|
42
|
+
"import": "./dist/plugins/voice.js",
|
|
43
|
+
"require": "./dist/plugins/voice.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./plugins/wcag": {
|
|
46
|
+
"types": "./dist/plugins/wcag.d.ts",
|
|
47
|
+
"import": "./dist/plugins/wcag.js",
|
|
48
|
+
"require": "./dist/plugins/wcag.cjs"
|
|
14
49
|
}
|
|
15
50
|
},
|
|
16
51
|
"publishConfig": {
|
|
@@ -31,12 +66,20 @@
|
|
|
31
66
|
"url": "git+https://github.com/sandeepmiriyala03/yuktai.git"
|
|
32
67
|
},
|
|
33
68
|
"keywords": [
|
|
69
|
+
"accessibility",
|
|
70
|
+
"a11y",
|
|
71
|
+
"wcag",
|
|
72
|
+
"aria",
|
|
34
73
|
"indic",
|
|
35
74
|
"ocr",
|
|
36
|
-
"
|
|
37
|
-
"vibe-coding",
|
|
75
|
+
"voice",
|
|
38
76
|
"offline-ai",
|
|
39
|
-
"
|
|
77
|
+
"react",
|
|
78
|
+
"nextjs",
|
|
79
|
+
"vue",
|
|
80
|
+
"angular",
|
|
81
|
+
"yuktai",
|
|
82
|
+
"vibe-coding"
|
|
40
83
|
],
|
|
41
84
|
"author": "Sandeep Miriyala",
|
|
42
85
|
"license": "ISC",
|
|
@@ -44,6 +87,14 @@
|
|
|
44
87
|
"react": ">=18",
|
|
45
88
|
"react-dom": ">=18"
|
|
46
89
|
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"react": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"react-dom": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
47
98
|
"dependencies": {
|
|
48
99
|
"idb-keyval": "^6.2.2",
|
|
49
100
|
"tesseract.js": "^7.0.0",
|