@wcag-checkr/ci 1.0.0-rc.55 → 1.0.0-rc.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ErrorBoundary-DPLiiAy6.js → ErrorBoundary-BAHGUDLJ.js} +3 -3
- package/dist/assets/{devtools-panel-DWl-VJ0U.js → devtools-panel-D91BV3XS.js} +1 -1
- package/dist/assets/{forensic-log-DnL4TESg.js → forensic-log-CFr7laxK.js} +2 -2
- package/dist/assets/{service-worker.ts-wTsghIGK.js → service-worker.ts-BqvCrPiF.js} +1 -1
- package/dist/assets/{side-panel-n00D7nXL.js → side-panel-DXvEY1w6.js} +1 -1
- package/dist/assets/{site-report-renderer-DVR-2PA8.js → site-report-renderer-vVi-sd9N.js} +1 -1
- package/dist/devtools/panel.html +3 -3
- package/dist/manifest.json +2 -2
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-
|
|
2
|
-
var Jt=Object.defineProperty;var Yt=(t,s,a)=>s in t?Jt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var qe=(t,s,a)=>Yt(t,typeof s!="symbol"?s+"":s,a);import{R as pe,i as q,r as x,j as e,M as ie,C as De,l as Xt,o as Me,t as Pe,m as ft,s as bt,k as Re}from"./styles-BQt6R4jA.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as K,r as P,s as M,c as vt,b as Q,d as me}from"./crash-reporter-Dc5lvxvY.js";import{g as Zt,a as W,u as es,b as ts,c as ss,d as as,e as yt,l as ns,f as jt,A as G,h as Ve,s as rs,O as is,i as os,j as ls,k as Qe,m as cs,n as wt,o as ds,p as us,q as ps,r as hs,T as ms,t as xs,v as gs}from"./forensic-log-DnL4TESg.js";import{B as Ee,i as Nt,b as kt,T as St}from"./state-PELIq3oj.js";const Je=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(f=>f(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,l);return l},fs=t=>t?Je(t):Je,bs=t=>t;function vs(t,s=bs){const a=pe.useSyncExternalStore(t.subscribe,pe.useCallback(()=>s(t.getState()),[t,s]),pe.useCallback(()=>s(t.getInitialState()),[t,s]));return pe.useDebugValue(a),a}const Ye=t=>{const s=fs(t),a=n=>vs(s,n);return Object.assign(a,s),a},ys=t=>t?Ye(t):Ye,m=ys(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),ye="sidePanel:lastAudit";function js(){const t=[];return t.push(K("AUDIT_PROGRESS_EVENT",s=>{const a=m.getState().status==="running";m.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),m.getState().setStatus("running"),a||q.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(K("AUDIT_COMPLETE_EVENT",s=>{var i;m.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;q.polite(r),ws({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(K("AUDIT_FAILED_EVENT",s=>{m.getState().setError(s.error.message)})),t.push(K("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=m.getState().aiProgress;m.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||q.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(K("AI_AUGMENTATION_FAILED_EVENT",s=>{m.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(K("SCORECARD_UPDATED_EVENT",()=>{je()})),t.push(K("LICENSE_CHANGED_EVENT",()=>{At()})),t.push(K("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&q.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(K("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),q.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(K("SITE_CRAWL_FAILED_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),q.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function ws(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ye]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ns(){const s=(await chrome.storage.local.get(ye))[ye];s&&m.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ks(){await chrome.storage.local.remove(ye)}async function We(){m.getState().clearResults(),await ks()}async function je(){const t=await P({type:"BASELINE_LIST"});m.getState().setBaselineList(t.items)}async function At(t){const s=await P({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});m.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ct()}async function Ct(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>_s);return{fetchMessages:n}},void 0),s=m.getState().userMode,a=await t(s);a&&m.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ss(){const s=(await P({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;m.getState().setUserMode(a)}function As(){return chrome.runtime.connect({name:"audit-keepalive"})}let we=null;async function Cs(){if(we===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(we=t.id)}catch{}}function Rt(){if(we===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:we}).catch(()=>{})}function Y(t){Rt(),M(t)}function Rs({onClose:t}){const[s,a]=x.useState(""),[n,r]=x.useState(""),[i,o]=x.useState(!0),[l,d]=x.useState(""),[p,c]=x.useState(!1),[u,h]=x.useState(null);async function f(b){var w;if(b.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const A=await P({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});A.success?(h({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=A.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:b=>a(b.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:b=>r(b.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:b=>d(b.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:b=>o(b.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function Xe({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Ne=vt("messages-client"),Es="https://api.wcagcheckr.com",Et="wcagcheckr",Ts=1e4;function Is(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Tt(t,s){const a=await Zt();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Is()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Es}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Ts)})}async function $s(t){try{const s=await Tt(`/v1/products/${Et}/messages`,{userMode:t??null});return s.ok?await s.json():(Ne.warn("fetchMessages http",s.status),null)}catch(s){return Ne.warn("fetchMessages failed",s),null}}async function ae(t,s){try{const a=await Tt(`/v1/products/${Et}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ne.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ne.warn("ackMessage failed",a),!1}}const _s=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ae,fetchMessages:$s},Symbol.toStringTag,{value:"Module"})),Ls=["http:","https:"];function Us(t){try{const s=new URL(t);return Ls.includes(s.protocol)}catch{return!1}}function Ze(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Us(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(x.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function It({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Ze(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:Ze(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){o(),n.push(c[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ds={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Fs={critical:"bg-rose-50 border-rose-200"};function $t(){const t=m(h=>h.unreadMessageCount),s=m(h=>h.messages),a=m(h=>h.applyMessageAck),[n,r]=x.useState(!1),i=x.useRef(-1),[o,l]=x.useState(!1);x.useEffect(()=>{const h=s.filter(b=>!b.seen);if(h.length===0)return;const f=Math.max(...h.map(b=>b.id));if(f>i.current){i.current=f,l(!0);const b=setTimeout(()=>l(!1),1500);return()=>clearTimeout(b)}},[s]);async function d(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)a(f.id,"seen"),ae(f.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await ae(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ae(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Os,{active:t>0}),t>0&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-rose-500 ring-2 ring-white"})]}),n&&e.jsx(Ms,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Os({active:t}){return e.jsx("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",fill:"currentColor",className:t?"text-rose-500":"",children:e.jsx("path",{d:"M10 2a5 5 0 00-5 5v3l-1.6 2.4a1 1 0 00.84 1.6h11.52a1 1 0 00.84-1.6L15 10V7a5 5 0 00-5-5zm-1.5 13a1.5 1.5 0 003 0h-3z"})})}function Ms({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=x.useRef(null);return x.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{Ct()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Ds[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(It,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function _t(){const t=m(i=>i.messages),s=m(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ae(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ae(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Fs.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(It,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const le=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ps(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Gs(){var u,h;const t=m(f=>f.view),s=m(f=>f.setView),a=m(f=>f.setUserMode),n=m(f=>f.results),r=m(f=>f.status),[i,o]=x.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=Ps(l),p=n.length>0&&r!=="running";function c(){a("owner"),M({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx($t,{}),e.jsx(Xe,{onClick:()=>void M({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Xe,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void We(),className:"shrink-0 text-[11px] px-2 py-0.5 rounded border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400",title:"Clear these results so you can run a fresh audit",children:"Clear"})]}),e.jsx(Vs,{view:t,setView:s}),e.jsx(ie,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Rs,{onClose:()=>o(!1)})})]})}function Vs({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+le.length)%le.length,l=le[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(le.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:le.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Ws({feature:t,upgradeUrl:s}){const[a,n]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(De,{open:a,onClose:()=>n(!1)})]})}const Bs="https://wcagcheckr.com/upgrade";function Hs(){const[t,s]=x.useState("single-element"),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState(null),[d,p]=x.useState(Ee),[c,u]=x.useState(Ee[0].id),h=m(k=>k.status),f=m(k=>k.tier),b=m(k=>k.results.length>0),w=h==="running";x.useEffect(()=>{Promise.all([P({type:"SETTINGS_GET",key:"matrixPresets"}),P({type:"SETTINGS_GET",key:"activePresetId"})]).then(([k,C])=>{const _=Array.isArray(k.data)?k.data:null;p(_&&_.length>0?_:Ee),typeof C.data=="string"&&u(C.data)})},[]);function A(k){const C=d.find(_=>_.id===k);C&&(u(k),M({type:"SETTINGS_SET",key:"activePresetId",value:k}),M({type:"SETTINGS_SET",key:"stateMatrix",value:C.matrix}))}const I=Nt(f,"storybookAutoIterate");x.useEffect(()=>{const k=K("ELEMENT_PICKED_EVENT",(_,T)=>{n(!1);const U=T.frameId;N(U),i({selector:_.selector,frameId:U})}),C=K("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{k(),C()}},[]);async function g(){const k=await W();k&&(n(!0),await Q(k,{type:"PICKER_ACTIVATE_REQUEST",tabId:k}))}function y(){r&&(N(r.frameId),Y({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),m.getState().startNewScan())}function j(){if(!I){l("storybook:auto-iterate");return}N(),Y({type:"START_AUDIT",mode:"storybook-all"}),m.getState().startNewScan()}function E(){N(),Y({type:"START_AUDIT",mode:"all-frames"}),m.getState().startNewScan()}function $(){N(),Y({type:"START_AUDIT",mode:"full-page"}),m.getState().startNewScan()}function v(){M({type:"CANCEL_AUDIT"})}async function N(k){m.getState().setPinned(null);const C=await W();if(C)try{await Q(C,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:C},k)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:k=>s(k.target.value),disabled:w||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:k=>A(k.target.value),disabled:w||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))}),t==="single-element"?e.jsx(zs,{picking:a,picked:r,isRunning:w,onPick:g,onRun:y,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:$,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:E,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:j,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:v,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&b&&e.jsx("button",{type:"button",onClick:()=>void We(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!w&&e.jsx(Ks,{selector:r.selector,onRepick:g,onClear:()=>i(null)})]}),e.jsx(ie,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Ws,{feature:o??"",upgradeUrl:Bs})})]})}function zs({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ks({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const qs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Qs={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Js(){const[t,s]=x.useState(null),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState("off"),p=m(f=>f.results).flatMap(f=>f.violations);async function c(f){const b=await W();b&&(l(f),f==="off"?await Q(b,{type:"VISION_SIMULATOR_CLEAR",tabId:b}).catch(()=>{}):await Q(b,{type:"VISION_SIMULATOR_APPLY",tabId:b,mode:f}).catch(()=>{}))}async function u(f){const b=await W();if(b){if(t&&await Q(b,{type:qs[t],tabId:b}).catch(()=>{}),t===f){s(null);return}await Q(b,{type:Qs[f],tabId:b}).catch(()=>{}),s(f)}}async function h(){const f=await W();if(f){if(a){await Q(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const b=await me(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});n(!0),i(`Previewing ${b.visualFixCount} visual fix${b.visualFixCount===1?"":"es"} + ${b.annotationCount} annotation${b.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(ce,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ce,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(ce,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(ce,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ce,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void c(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ce({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Ys(t){if(!t)return"";const s=[t.pseudoState];return t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),s.join(" · ")}function Xs(){const t=m(p=>p.status),s=m(p=>p.progress),a=m(p=>p.aiProgress);if(t!=="running"||!s)return null;const n=a!=null,r=!n&&s.current>=s.total,i=n?a.current/a.total*100:s.current/s.total*100,o=n?a.current:s.current,l=n?a.total:s.total,d=n?`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:n?e.jsxs(e.Fragment,{children:["AI augmentation… ",a.current,"/",a.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:n?a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Ys(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void M({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${n?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const de={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Zs(t){return/^wcag\d/.test(t.wcagCriterion)?[de["ada-iii"],de[508],de.eaa,de["en-301-549"],de.aoda]:[]}const ea={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function ke({violation:t,alreadyAcknowledged:s}){const a=m(g=>g.pinnedMatchKey),n=m(g=>g.pinnedFound),r=m(g=>g.setPinned),i=m(g=>{var y;return(y=g.results[0])==null?void 0:y.frameId}),o=m(g=>{var y;return(y=g.results[0])==null?void 0:y.scope}),l=m(g=>g.results),d=m(g=>g.acknowledgedKeys.has(t.matchKey)),p=m(g=>g.markAcknowledged),c=m(g=>g.markUnacknowledged),u=s||d,h=a===t.matchKey,f=h&&!n;async function b(g){try{return(await me(g,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:g,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const g=await W();if(!g)return;if(h){r(null);try{await Q(g,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:g},i)}catch{}return}const y=await b(g);r(t.matchKey,y)}function A(g){g.stopPropagation(),t.currentState.breakpoint.width<=640&&Rt(),(async()=>{const y=await W();if(!y)return;try{await P({type:"STATE_DRIVE_REQUEST",tabId:y,state:t.currentState,scope:o,frameId:i})}catch{}const j=await b(y);r(t.matchKey,j)})()}async function I(g){g.stopPropagation();const y=await W();if(!y)return;try{await P({type:"STATE_DRIVE_REQUEST",tabId:y,state:na(),scope:o,frameId:i})}catch{M({type:"STATE_RESET_REQUEST",tabId:y})}const j=await b(y);r(t.matchKey,j)}return e.jsxs("button",{type:"button",onClick:w,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-vVi-sd9N.js","assets/forensic-log-CFr7laxK.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Jt=Object.defineProperty;var Yt=(t,s,a)=>s in t?Jt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var qe=(t,s,a)=>Yt(t,typeof s!="symbol"?s+"":s,a);import{R as pe,i as q,r as x,j as e,M as ie,C as De,l as Xt,o as Me,t as Pe,m as ft,s as bt,k as Re}from"./styles-BQt6R4jA.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as K,r as P,s as M,c as vt,b as Q,d as me}from"./crash-reporter-Dc5lvxvY.js";import{g as Zt,a as W,u as es,b as ts,c as ss,d as as,e as yt,l as ns,f as jt,A as G,h as Ve,s as rs,O as is,i as os,j as ls,k as Qe,m as cs,n as wt,o as ds,p as us,q as ps,r as hs,T as ms,t as xs,v as gs}from"./forensic-log-CFr7laxK.js";import{B as Ee,i as Nt,b as kt,T as St}from"./state-PELIq3oj.js";const Je=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(f=>f(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,l);return l},fs=t=>t?Je(t):Je,bs=t=>t;function vs(t,s=bs){const a=pe.useSyncExternalStore(t.subscribe,pe.useCallback(()=>s(t.getState()),[t,s]),pe.useCallback(()=>s(t.getInitialState()),[t,s]));return pe.useDebugValue(a),a}const Ye=t=>{const s=fs(t),a=n=>vs(s,n);return Object.assign(a,s),a},ys=t=>t?Ye(t):Ye,m=ys(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),ye="sidePanel:lastAudit";function js(){const t=[];return t.push(K("AUDIT_PROGRESS_EVENT",s=>{const a=m.getState().status==="running";m.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),m.getState().setStatus("running"),a||q.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(K("AUDIT_COMPLETE_EVENT",s=>{var i;m.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;q.polite(r),ws({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(K("AUDIT_FAILED_EVENT",s=>{m.getState().setError(s.error.message)})),t.push(K("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=m.getState().aiProgress;m.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||q.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(K("AI_AUGMENTATION_FAILED_EVENT",s=>{m.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(K("SCORECARD_UPDATED_EVENT",()=>{je()})),t.push(K("LICENSE_CHANGED_EVENT",()=>{At()})),t.push(K("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&q.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(K("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),q.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(K("SITE_CRAWL_FAILED_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),q.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function ws(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ye]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ns(){const s=(await chrome.storage.local.get(ye))[ye];s&&m.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ks(){await chrome.storage.local.remove(ye)}async function We(){m.getState().clearResults(),await ks()}async function je(){const t=await P({type:"BASELINE_LIST"});m.getState().setBaselineList(t.items)}async function At(t){const s=await P({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});m.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ct()}async function Ct(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>_s);return{fetchMessages:n}},void 0),s=m.getState().userMode,a=await t(s);a&&m.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ss(){const s=(await P({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;m.getState().setUserMode(a)}function As(){return chrome.runtime.connect({name:"audit-keepalive"})}let we=null;async function Cs(){if(we===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(we=t.id)}catch{}}function Rt(){if(we===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:we}).catch(()=>{})}function Y(t){Rt(),M(t)}function Rs({onClose:t}){const[s,a]=x.useState(""),[n,r]=x.useState(""),[i,o]=x.useState(!0),[l,d]=x.useState(""),[p,c]=x.useState(!1),[u,h]=x.useState(null);async function f(b){var w;if(b.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const A=await P({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});A.success?(h({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=A.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:b=>a(b.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:b=>r(b.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:b=>d(b.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:b=>o(b.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function Xe({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Ne=vt("messages-client"),Es="https://api.wcagcheckr.com",Et="wcagcheckr",Ts=1e4;function Is(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Tt(t,s){const a=await Zt();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Is()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Es}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Ts)})}async function $s(t){try{const s=await Tt(`/v1/products/${Et}/messages`,{userMode:t??null});return s.ok?await s.json():(Ne.warn("fetchMessages http",s.status),null)}catch(s){return Ne.warn("fetchMessages failed",s),null}}async function ae(t,s){try{const a=await Tt(`/v1/products/${Et}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ne.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ne.warn("ackMessage failed",a),!1}}const _s=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ae,fetchMessages:$s},Symbol.toStringTag,{value:"Module"})),Ls=["http:","https:"];function Us(t){try{const s=new URL(t);return Ls.includes(s.protocol)}catch{return!1}}function Ze(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Us(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(x.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function It({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Ze(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:Ze(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){o(),n.push(c[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ds={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Fs={critical:"bg-rose-50 border-rose-200"};function $t(){const t=m(h=>h.unreadMessageCount),s=m(h=>h.messages),a=m(h=>h.applyMessageAck),[n,r]=x.useState(!1),i=x.useRef(-1),[o,l]=x.useState(!1);x.useEffect(()=>{const h=s.filter(b=>!b.seen);if(h.length===0)return;const f=Math.max(...h.map(b=>b.id));if(f>i.current){i.current=f,l(!0);const b=setTimeout(()=>l(!1),1500);return()=>clearTimeout(b)}},[s]);async function d(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)a(f.id,"seen"),ae(f.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await ae(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ae(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Os,{active:t>0}),t>0&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-rose-500 ring-2 ring-white"})]}),n&&e.jsx(Ms,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Os({active:t}){return e.jsx("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",fill:"currentColor",className:t?"text-rose-500":"",children:e.jsx("path",{d:"M10 2a5 5 0 00-5 5v3l-1.6 2.4a1 1 0 00.84 1.6h11.52a1 1 0 00.84-1.6L15 10V7a5 5 0 00-5-5zm-1.5 13a1.5 1.5 0 003 0h-3z"})})}function Ms({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=x.useRef(null);return x.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{Ct()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Ds[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(It,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function _t(){const t=m(i=>i.messages),s=m(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ae(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ae(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Fs.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(It,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const le=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ps(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Gs(){var u,h;const t=m(f=>f.view),s=m(f=>f.setView),a=m(f=>f.setUserMode),n=m(f=>f.results),r=m(f=>f.status),[i,o]=x.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=Ps(l),p=n.length>0&&r!=="running";function c(){a("owner"),M({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx($t,{}),e.jsx(Xe,{onClick:()=>void M({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Xe,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void We(),className:"shrink-0 text-[11px] px-2 py-0.5 rounded border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400",title:"Clear these results so you can run a fresh audit",children:"Clear"})]}),e.jsx(Vs,{view:t,setView:s}),e.jsx(ie,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Rs,{onClose:()=>o(!1)})})]})}function Vs({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+le.length)%le.length,l=le[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(le.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:le.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Ws({feature:t,upgradeUrl:s}){const[a,n]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(De,{open:a,onClose:()=>n(!1)})]})}const Bs="https://wcagcheckr.com/upgrade";function Hs(){const[t,s]=x.useState("single-element"),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState(null),[d,p]=x.useState(Ee),[c,u]=x.useState(Ee[0].id),h=m(k=>k.status),f=m(k=>k.tier),b=m(k=>k.results.length>0),w=h==="running";x.useEffect(()=>{Promise.all([P({type:"SETTINGS_GET",key:"matrixPresets"}),P({type:"SETTINGS_GET",key:"activePresetId"})]).then(([k,C])=>{const _=Array.isArray(k.data)?k.data:null;p(_&&_.length>0?_:Ee),typeof C.data=="string"&&u(C.data)})},[]);function A(k){const C=d.find(_=>_.id===k);C&&(u(k),M({type:"SETTINGS_SET",key:"activePresetId",value:k}),M({type:"SETTINGS_SET",key:"stateMatrix",value:C.matrix}))}const I=Nt(f,"storybookAutoIterate");x.useEffect(()=>{const k=K("ELEMENT_PICKED_EVENT",(_,T)=>{n(!1);const U=T.frameId;N(U),i({selector:_.selector,frameId:U})}),C=K("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{k(),C()}},[]);async function g(){const k=await W();k&&(n(!0),await Q(k,{type:"PICKER_ACTIVATE_REQUEST",tabId:k}))}function y(){r&&(N(r.frameId),Y({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),m.getState().startNewScan())}function j(){if(!I){l("storybook:auto-iterate");return}N(),Y({type:"START_AUDIT",mode:"storybook-all"}),m.getState().startNewScan()}function E(){N(),Y({type:"START_AUDIT",mode:"all-frames"}),m.getState().startNewScan()}function $(){N(),Y({type:"START_AUDIT",mode:"full-page"}),m.getState().startNewScan()}function v(){M({type:"CANCEL_AUDIT"})}async function N(k){m.getState().setPinned(null);const C=await W();if(C)try{await Q(C,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:C},k)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:k=>s(k.target.value),disabled:w||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:k=>A(k.target.value),disabled:w||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))}),t==="single-element"?e.jsx(zs,{picking:a,picked:r,isRunning:w,onPick:g,onRun:y,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:$,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:E,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:j,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:v,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&b&&e.jsx("button",{type:"button",onClick:()=>void We(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!w&&e.jsx(Ks,{selector:r.selector,onRepick:g,onClear:()=>i(null)})]}),e.jsx(ie,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Ws,{feature:o??"",upgradeUrl:Bs})})]})}function zs({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ks({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const qs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Qs={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Js(){const[t,s]=x.useState(null),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState("off"),p=m(f=>f.results).flatMap(f=>f.violations);async function c(f){const b=await W();b&&(l(f),f==="off"?await Q(b,{type:"VISION_SIMULATOR_CLEAR",tabId:b}).catch(()=>{}):await Q(b,{type:"VISION_SIMULATOR_APPLY",tabId:b,mode:f}).catch(()=>{}))}async function u(f){const b=await W();if(b){if(t&&await Q(b,{type:qs[t],tabId:b}).catch(()=>{}),t===f){s(null);return}await Q(b,{type:Qs[f],tabId:b}).catch(()=>{}),s(f)}}async function h(){const f=await W();if(f){if(a){await Q(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const b=await me(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});n(!0),i(`Previewing ${b.visualFixCount} visual fix${b.visualFixCount===1?"":"es"} + ${b.annotationCount} annotation${b.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(ce,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ce,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(ce,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(ce,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ce,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void c(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ce({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Ys(t){if(!t)return"";const s=[t.pseudoState];return t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),s.join(" · ")}function Xs(){const t=m(p=>p.status),s=m(p=>p.progress),a=m(p=>p.aiProgress);if(t!=="running"||!s)return null;const n=a!=null,r=!n&&s.current>=s.total,i=n?a.current/a.total*100:s.current/s.total*100,o=n?a.current:s.current,l=n?a.total:s.total,d=n?`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:n?e.jsxs(e.Fragment,{children:["AI augmentation… ",a.current,"/",a.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:n?a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Ys(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void M({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${n?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const de={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Zs(t){return/^wcag\d/.test(t.wcagCriterion)?[de["ada-iii"],de[508],de.eaa,de["en-301-549"],de.aoda]:[]}const ea={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function ke({violation:t,alreadyAcknowledged:s}){const a=m(g=>g.pinnedMatchKey),n=m(g=>g.pinnedFound),r=m(g=>g.setPinned),i=m(g=>{var y;return(y=g.results[0])==null?void 0:y.frameId}),o=m(g=>{var y;return(y=g.results[0])==null?void 0:y.scope}),l=m(g=>g.results),d=m(g=>g.acknowledgedKeys.has(t.matchKey)),p=m(g=>g.markAcknowledged),c=m(g=>g.markUnacknowledged),u=s||d,h=a===t.matchKey,f=h&&!n;async function b(g){try{return(await me(g,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:g,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const g=await W();if(!g)return;if(h){r(null);try{await Q(g,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:g},i)}catch{}return}const y=await b(g);r(t.matchKey,y)}function A(g){g.stopPropagation(),t.currentState.breakpoint.width<=640&&Rt(),(async()=>{const y=await W();if(!y)return;try{await P({type:"STATE_DRIVE_REQUEST",tabId:y,state:t.currentState,scope:o,frameId:i})}catch{}const j=await b(y);r(t.matchKey,j)})()}async function I(g){g.stopPropagation();const y=await W();if(!y)return;try{await P({type:"STATE_DRIVE_REQUEST",tabId:y,state:na(),scope:o,frameId:i})}catch{M({type:"STATE_RESET_REQUEST",tabId:y})}const j=await b(y);r(t.matchKey,j)}return e.jsxs("button",{type:"button",onClick:w,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
3
|
${h?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${ea[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(ra,{violation:t}),e.jsx(la,{violation:t}),e.jsx(oa,{violation:t}),e.jsx(ia,{text:t.target.failureSummary}),e.jsx(ca,{ruleId:t.ruleId}),h&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",ta(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:A,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),A(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:I,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),I(g))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),f&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),c(t.matchKey),aa(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),p(t.matchKey),sa(t,l)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function ta(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function sa(t,s){await ts({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Lt(t.componentId,s)}async function aa(t,s){await es(t.componentId,t.matchKey),await Lt(t.componentId,s)}async function Lt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await P({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});m.getState().setDelta(n.delta)}catch{}}function na(){const t=kt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ut(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function ra({violation:t}){const s=Ut(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function ia({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function oa({violation:t}){const s=Zs(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function la({violation:t}){const s=Ut(t),[a,n]=x.useState({kind:"idle"});if(!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await P({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);n(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function ca({ruleId:t}){const s=ss(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const da=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]},{id:"other-manual",label:"Other manual checks",axeRules:[],igtWorkflowIds:["reflow","hover-focus-content","pointer","time-based","error-prevention","consistency"]}];function ua(t){const s=da.map(i=>pa(i,t)),a=s.reduce((i,o)=>i+ha(o.letter),0)/Math.max(1,s.length),n=ma(Math.round(a)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function pa(t,s){const a=new Set(t.axeRules),n=s.violations.filter(v=>a.has(v.ruleId)),r=s.manualRuns.filter(v=>t.igtWorkflowIds.includes(v.workflowId)),i=t.igtWorkflowIds.map(v=>s.workflows.find(N=>N.id===v)).filter(v=>v!=null);let o=i.length>0;for(const v of i){const N=r.find(C=>C.workflowId===v.id);if((N?Object.keys(N.steps).length:0)!==v.steps.length){o=!1;break}}const l=r.some(v=>Object.keys(v.steps).length>0),d=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(v=>d.includes(v.workflowId)),c=d.map(v=>s.workflows.find(N=>N.id===v)).filter(v=>v!=null);let u=d.length>0&&c.length===d.length;for(const v of c){const N=p.find(C=>C.workflowId===v.id);if((N?Object.keys(N.steps).length:0)!==v.steps.length){u=!1;break}}let h=null;if(u)for(const v of p)v.completedAt&&(h===null||v.completedAt>h)&&(h=v.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,b=d[0]??t.igtWorkflowIds[0]??null;if(u&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:b,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,A=t.igtWorkflowIds.length>0;let I=!1;if(w&&A?I=!s.auditRan&&!l:w?I=!s.auditRan:A?I=!l:I=!0,I)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:A||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:b,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const g={critical:0,serious:0,moderate:0,minor:0};for(const v of as(n))g[v.impact]++;g.serious+=f;for(const v of r){const N=i.find(k=>k.id===v.workflowId);if(N)for(const k of N.steps){const C=v.steps[k.id];(C==null?void 0:C.status)==="fail"&&(k.severity==="required"?g.serious++:g.moderate++)}}const y=g.critical>0,j=g.serious>0;let E;g.critical>=5?E="F":g.critical>=1?E="D":g.serious>=1?E="C":g.moderate>=1?E="B":E="A";const $=A&&!o||d.length>0&&!u;return{id:t.id,label:t.label,letter:E,untested:!1,needsIgt:$,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:b,counts:g,caps:{cappedAtC:y,cappedAtB:j}}}function ha(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function ma(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const xa={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},ga={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function fa({violations:t,componentId:s}){var g,y,j,E,$;const[a,n]=x.useState([]),r=m(v=>v.status),i=m(v=>v.progress),o=m(v=>v.freshThisSession),l=m(v=>v.results),d=(g=l[0])==null?void 0:g.startedAt;if(x.useEffect(()=>{if(!s){n([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(N=>{if(v)return;const C=((N==null?void 0:N.igtRuns)??{})[s]??{};n(Object.values(C))}),()=>{v=!0}},[s]),r==="running")return e.jsx(ka,{current:i==null?void 0:i.current,total:i==null?void 0:i.total});const p=ua({violations:t,auditRan:l.length>0,manualRuns:a,workflows:G,heuristicCounts:{tabOrder:((j=(y=l[0])==null?void 0:y.tabOrderIssues)==null?void 0:j.length)??0,readingOrder:(($=(E=l[0])==null?void 0:E.readingOrderIssues)==null?void 0:$.length)??0}}),c=m(v=>v.acknowledgedKeys),u=l.length>0?yt(l,{runs:a,workflows:G},"2.1","AA",c):void 0,h=l.length>0?ns(jt({audits:l,igtRuns:a,workflows:G,acknowledgedMatchKeys:c}),G):void 0,f=u?!u.canClaimConformance:!1,b=f&&p.overallLetter==="A"?"B":p.overallLetter,w=(()=>{if(!f||p.overallLetter!=="A"||!u)return null;const v=u.untestedCriteria.length,N=u.inconclusiveCriteria.length,k=[];return v>0&&k.push(`${v} WCAG ${u.targetLevel} ${v===1?"criterion":"criteria"} still untested`),N>0&&k.push(`${N} WCAG ${u.targetLevel} ${N===1?"criterion":"criteria"} inconclusive`),`Capped at B — ${k.join(" + ")}. ${N>0?"Resolve axe-incomplete + IGT-skip items to claim conformance.":"Open Guided Tests to evaluate them."}`})();let A=0;for(const v of G){const N=a.find(C=>C.workflowId===v.id);if(!N)continue;v.steps.every(C=>{const _=N.steps[C.id];return(_==null?void 0:_.status)==="pass"||(_==null?void 0:_.status)==="fail"||(_==null?void 0:_.status)==="skip"||(_==null?void 0:_.status)==="not-applicable"})&&A++}const I=t.length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!o&&d&&e.jsx(Sa,{scannedAt:d}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${xa[b]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:b})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",p.subGrades.length," verification areas below. Untested areas count as F until verified."]}),w&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:w})]})]}),p.isLawsuitRisk&&e.jsx(ya,{areas:p.warningAreas}),e.jsx(ja,{grades:p.subGrades}),u&&e.jsx(ba,{coverage:u}),h&&e.jsx(va,{layers:h}),e.jsx(Na,{violationsRemaining:I,manualCompleted:A,manualTotal:G.length}),A>0||l.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:A})," of ",e.jsx("strong",{children:G.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${A/G.length*100}%`}})})]}):null]})}function ba({coverage:t}){const s=t.untestedCriteria.length+t.inconclusiveCriteria.length,[a,n]=x.useState(s>0&&s<=3),r=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),i=t.canClaimConformance,o=[];return t.untestedCriteria.length>0&&o.push({kind:"untested",ids:t.untestedCriteria}),t.inconclusiveCriteria.length>0&&o.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),e.jsxs("div",{className:`border-t ${i?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${i?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",r,"%)"]}),i&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!i&&e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain",t.untestedCriteria.length>0?" untested":"",t.untestedCriteria.length>0&&t.inconclusiveCriteria.length>0?" or":"",t.inconclusiveCriteria.length>0?" inconclusive":"","."]}),!i&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!i&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!i&&o.length>0&&e.jsx("button",{type:"button",onClick:()=>n(l=>!l),className:"text-[11px] underline shrink-0 self-start",children:a?"hide":"show list"})]}),a&&!i&&e.jsx("div",{className:"mt-1.5 space-y-1.5",children:o.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-amber-900",children:[l.kind==="untested"?"Untested":"Inconclusive"," (",l.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:l.ids.map(d=>{var c;const p=l.kind==="inconclusive"?(c=t.inconclusiveReasons)==null?void 0:c[d]:void 0;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("code",{className:"font-mono",children:["· ",d]}),p&&p.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:p.map((u,h)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[u.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleOrStepId})," — "]}),u.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:u.ruleOrStepId})," skipped — "]}),u.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:u.ruleOrStepId})," — "]}),u.resolutionHint]},h))}):l.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},d)})})]},l.kind))})]})}const et={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function va({layers:t}){const s=m(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,d=r.cleared,p=i>0&&o===0&&l===0,c=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:et[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:et[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function ya({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function ja({grades:t}){const s=m(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${ga[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(wa,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function wa({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=G.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?Dt(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Na({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=m(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:s===a,label:`Run Guided Tests (${s}/${a} workflows complete)`,action:()=>n("guided"),tooltip:'12 separate workflows total. Click → pick a workflow → mark each step pass/fail/skip → "Back to workflows" → click again for the next. Repeat until 12/12.'},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const d=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function ka({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function Sa({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",Dt(s)," old). Re-scan to grade the current page state."]})]})}function Dt(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}const Fe="dismissedFindings";function Ae(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ne(t){return`reading-order::${t}`}function re(t){return`tab-order::${t}`}async function Ce(){try{const t=await chrome.storage.local.get(Fe),s=t==null?void 0:t[Fe];if(s&&typeof s=="object")return s}catch{}return{}}async function Be(t){await chrome.storage.local.set({[Fe]:t})}async function Se(t){return(await Ce())[Ae(t)]??{}}async function Ft(t,s,a,n){const r=await Ce(),i=Ae(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Be(r)}async function xe(t,s){if(s.length===0)return;const a=await Ce(),n=Ae(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await Be(a)}async function Ot(t,s){const a=await Ce(),n=Ae(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Be(a))}const Aa=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ft,addDismissals:xe,dismissalKeyForReadingOrder:ne,dismissalKeyForTabOrder:re,getDismissalsForUrl:Se,removeDismissal:Ot},Symbol.toStringTag,{value:"Module"}));function Mt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Pt(t){return`${Ve(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Ca(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Pt(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const tt={critical:0,serious:1,moderate:2,minor:3};function Ra(){var b,w,A,I;const t=m(g=>g.results),s=m(g=>g.componentId),a=m(g=>g.setView),n=((b=t[0])==null?void 0:b.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(new Set);if(x.useEffect(()=>{if(!n)return;Se(n).then(i);const g=()=>{document.visibilityState==="visible"&&n&&Se(n).then(i)};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[n]),x.useEffect(()=>{if(!s){l(new Set);return}let g=!1;const y=async()=>{const E=await chrome.storage.local.get("igtRuns");if(g)return;const v=((E==null?void 0:E.igtRuns)??{})[s]??{},N=new Set;for(const k of G){const C=v[k.id];C&&Object.keys(C.steps).length===k.steps.length&&N.add(k.id)}l(N)};y();const j=()=>{document.visibilityState==="visible"&&y()};return document.addEventListener("visibilitychange",j),()=>{g=!0,document.removeEventListener("visibilitychange",j)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((g,y)=>g+y.durationMs,0),p=t.reduce((g,y)=>g+y.violations.length,0),c=Ca(t);c.sort((g,y)=>{const j=tt[g.representative.impact]??99,E=tt[y.representative.impact]??99;return j!==E?j-E:y.states.length-g.states.length});const u=t.map(g=>Mt(g.state)).join(`
|
|
4
4
|
`),h=o.has("keyboard")?0:(((A=t[0])==null?void 0:A.tabOrderIssues)??[]).filter(g=>!(re(g.selector)in r)).length,f=o.has("page-structure")?0:(((I=t[0])==null?void 0:I.readingOrderIssues)??[]).filter(g=>!(ne(g.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(fa,{violations:t.flatMap(g=>g.violations),componentId:s}),(h>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:h})," tab-order issue",h===1?"":"s"," (WCAG 2.4.3)"]}),h>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:u,"aria-label":`${t.length} states tested: ${u.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",c.length," unique ",c.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),c.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:c.map(g=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(ke,{violation:g.representative}),e.jsx(Ea,{states:g.states,totalStates:t.length})]},Pt(g.representative)))})]})}function Ea({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(Mt))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
5
5
|
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const Ta={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ia({ruleId:t,violations:s}){const[a,n]=x.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(ke,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ta[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(ke,{violation:d},p))})]})}function $a(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const _a={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Gt({open:t,onClose:s,format:a,content:n,filename:r}){const i=Xt(new Blob([n]).size);function o(){Pe(n,r),s()}function l(){Me(n),s()}return e.jsxs(ie,{open:t,onClose:s,title:_a[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const st=7800;function La(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
@@ -25,7 +25,7 @@ document.getElementById('copy').addEventListener('click', () => {
|
|
|
25
25
|
<\/script>
|
|
26
26
|
</body></html>`,X=new Blob([B],{type:"text/html"}),te=URL.createObjectURL(X);window.open(te,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(te),6e4);return}const N=y==="json"?"application/json":y==="sarif"?"application/sarif+json":"application/xml",k=y==="junit"?"xml":y,C=new Blob([v.content],{type:N}),_=URL.createObjectURL(C),T=document.createElement("a");T.href=_,T.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${k}`,T.click(),URL.revokeObjectURL(_)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("button",{onClick:A,disabled:!w,title:w?void 0:`Free tier limits you to ${f} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),b&&e.jsx("button",{onClick:I,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx(Pa,{disabled:!h,onExport:g,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!w&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const y=Te(t.new),j=Te(t.persistent),E=Te(t.fixed),$=[...y.review,...j.review];return e.jsxs(e.Fragment,{children:[e.jsx(ue,{title:"New",violations:y.findings,count:y.findings.length,accent:"red",actions:[...o&&y.findings.length>0?[{label:"File GitHub issue",onClick:()=>Oa(o,s,y.findings)}]:[],...d&&y.findings.length>0?[{label:"File Jira issue",onClick:()=>Ma(d,s,y.findings)}]:[]]}),e.jsx(ue,{title:"Persistent",violations:j.findings,count:j.findings.length,accent:"slate"}),e.jsx(ue,{title:"Fixed",violations:E.findings,count:t.fixedCount,accent:"green"}),$.length>0&&e.jsx(ue,{title:"Needs review (does not affect grade)",violations:$,count:$.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ue,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),c&&e.jsx(Gt,{open:c.open,onClose:()=>u(null),format:c.format,content:c.content,filename:c.filename})]})}const Fa={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Te(t){const s=[],a=[];for(const n of t)n.needsReview?a.push(n):s.push(n);return{findings:s,review:a,fixed:0}}function ue({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=x.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Fa[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(ke,{violation:d,alreadyAcknowledged:!0},p)):$a(s).map(d=>e.jsx(Ia,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Oa(t,s,a){if(a.length===0)return;const{url:n}=La(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Ma(t,s,a){if(a.length===0)return;const{url:n}=Ua(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Pa({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=x.useState(!1),[i,o]=x.useState(!1);function l(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ee,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ee,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ee,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ee,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ee,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ee,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ee,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ee,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ee({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const nt="igtRuns";async function Ga(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}async function Va(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Ga())[t];if(i)for(const d of G){const p=i[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await xe(n,f.map(b=>({key:re(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await xe(n,f.map(b=>({key:ne(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}}}}const Wa=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),Ba=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function Ha(t){return Wa.has(t.ruleId)}function za(t){return Ba.has(t.ruleId)}function Ka(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function qa(){var N,k,C,_;const t=m(T=>T.results),s=m(T=>T.delta),a=m(T=>T.componentId),n=((N=t[0])==null?void 0:N.pageUrl)??((k=t[0])==null?void 0:k.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(0);x.useEffect(()=>{if(!n)return;let T=!1;return(async()=>{if(a&&t.length>0)try{await Va(a,t)}catch{}if(T)return;const U=await Se(n);T||i(U)})(),()=>{T=!0}},[n,o,a,t]);async function d(T,U){if(!n)return;const O=window.prompt(`Why is this finding a false positive?
|
|
27
27
|
|
|
28
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await Ft(n,T,O||"(no reason given)",U),l(D=>D+1))}async function p(T){n&&(await Ot(n,T),l(U=>U+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((T,U)=>{var O;return T+(((O=U.announcements)==null?void 0:O.length)??0)},0),u=t.reduce((T,U)=>{var O;return T+(((O=U.focusEvents)==null?void 0:O.length)??0)},0),h=t.reduce((T,U)=>{var O;return T+(((O=U.focusEvents)==null?void 0:O.filter(D=>D.isFocusReset).length)??0)},0),f=rt(t,Ha),b=rt(t,za),w=f.length,A=b.length,I=((C=t[0])==null?void 0:C.readingOrderIssues)??[],g=((_=t[0])==null?void 0:_.tabOrderIssues)??[],y=I.filter(T=>!(ne(T.selector)in r)),j=I.filter(T=>ne(T.selector)in r),E=g.filter(T=>!(re(T.selector)in r)),$=g.filter(T=>re(T.selector)in r);if(c===0&&u===0&&w===0&&A===0&&y.length===0&&E.length===0&&j.length===0&&$.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const v=j.length+$.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[w," structural · ",A," form ·"," ",E.length," tab-order ·"," ",y.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),v>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",v," dismissed"]})]}),E.length>0&&e.jsx(Ya,{issues:E,onDismiss:d}),y.length>0&&e.jsx(Xa,{issues:y,onDismiss:d}),v>0&&e.jsx(Za,{dismissedReadingOrder:j,dismissedTabOrder:$,dismissals:r,onRestore:p}),w>0&&e.jsx(it,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:f}),A>0&&e.jsx(it,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:b}),e.jsx(Qa,{delta:s}),t.map((T,U)=>{const O=T.announcements??[],D=T.focusEvents??[];return O.length===0&&D.length===0?null:e.jsx(Ja,{state:T.state,announcements:O,focusEvents:D},U)})]})}function Qa({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function rt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Ve(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function it({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Ja({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Ka(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Ya({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Xa({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Za({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Oe="igtRuns";async function en(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await xe(r,o.map(l=>({key:re(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await xe(r,o.map(l=>({key:ne(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const tn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},sn={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},an={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ot(t,s){const a=await W();if(!a)return;const n=s?tn[t]:sn[t];try{await Q(a,n)}catch{}}async function nn(){const s=(await chrome.storage.local.get(Oe))[Oe];return s&&typeof s=="object"?s:{}}async function lt(t){await chrome.storage.local.set({[Oe]:t})}function rn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function on(){const t=m(c=>c.componentId),s=m(c=>c.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{nn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,u,h){var b;const f={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((b=o[c])==null?void 0:b.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(f),lt(f),h.status==="pass"){const w=G.find(I=>I.id===c),A=w==null?void 0:w.steps.find(I=>I.id===u);A!=null&&A.autoDismissActivity&&en(A.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[c];const h={...a,[t]:u};n(h),lt(h)}const p=G.find(c=>c.id===r);if(p){const c=o[p.id];return e.jsx(ln,{workflow:p,run:c,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),G.map(c=>{const u=o[c.id],h=u?rs(u,c):null,f=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",b={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${b}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function ln({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=x.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=rn(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ot(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",an[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ot(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(ge,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:u=>n(d.id,{status:c.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const cn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function ge({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?cn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const be="savedFlows";async function dn(){const t=await chrome.storage.local.get(be);return Array.isArray(t[be])?t[be]:[]}async function ct(t){await chrome.storage.local.set({[be]:t})}function un(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{dn().then(s)},[]);async function o(){const c=await W();if(!c){i("No audit-target tab found.");return}try{await Q(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await W();if(c)try{const u=await me(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},b=[f,...t];s(b),await ct(b),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await W();if(u){i(`Replaying "${c.name}"…`);try{const h=await me(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==c);s(u),await ct(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function pn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(hn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function hn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function mn(){const t=m(l=>l.baselineList),s=m(l=>l.tier),a=St[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=x.useState(!1);if(x.useEffect(()=>{je().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await M({type:"BASELINE_DELETE",componentId:l}),await je()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=pn(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const xn={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function se({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${xn[t]}`,children:a})}const gn={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},fn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},bn={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Vt({onBack:t}){const s=m(u=>u.siteCrawlStatus),a=m(u=>u.siteCrawlProgress),n=m(u=>u.siteCrawlReport),r=m(u=>u.siteCrawlError),[i,o]=x.useState(""),[l,d]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),Y({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){M({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(vn,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function vn({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-DVR-2PA8.js");return{renderSiteReportHtml:a}},__vite__mapDeps([0,1,2,3])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${gn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${fn[t.siteRisk]}`,children:is[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=os(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${bn[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const Ie="onboardingDismissed",$e=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function yn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(Ie).then(l=>{l[Ie]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ie]:!0}),s(!1),n(0)}const i=a===$e.length-1,o=$e[a];return e.jsxs(ie,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",$e.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function jn(){const t=m(n=>n.status),s=m(n=>n.errorMessage),a=m(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function wn(){const t=m(d=>d.aiFailure),s=m(d=>d.clearAiFailure),[a,n]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function dt(){const[t,s]=x.useState(!1);return x.useEffect(()=>K("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),m.getState().setStatus("idle"))}),[]),e.jsxs(ie,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Nn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{ls().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Qe(),m.getState().startNewScan(),t.mode==="storybook-all"?Y({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Y({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Qe(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const _e="storybook:hintDismissed";function kn(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(_e))[_e])return;const o=await W();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[_e]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Sn(){var i;const t=m(o=>o.results),s=m(o=>o.baselineList),a=m(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${An(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function An(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Cn(){const t=m(l=>l.results),s=m(l=>l.componentId),[a,n]=x.useState([]);if(x.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=cs(r,a.length>0?{runs:a,workflows:G}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Rn(){const t=m(a=>a.setUserMode);function s(a){t(a),M({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const En=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Tn={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function In(t){const s=new Set(En),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Tn[o]}}const Wt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},$n={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Wt]},_n={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Wt]};function He(t){return t==="thorough"?_n:$n}function ut(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const ve="wcagcheckr";function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function he(t){try{const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1,timeZoneName:"short"})}catch{return t}}function Ln(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Un(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function Dn(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function Fn(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function On(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${L(t.receipt.tsaName)}) — anchored ${L(he(t.receipt.anchoredAt))}</td></tr>
|
|
28
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await Ft(n,T,O||"(no reason given)",U),l(D=>D+1))}async function p(T){n&&(await Ot(n,T),l(U=>U+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((T,U)=>{var O;return T+(((O=U.announcements)==null?void 0:O.length)??0)},0),u=t.reduce((T,U)=>{var O;return T+(((O=U.focusEvents)==null?void 0:O.length)??0)},0),h=t.reduce((T,U)=>{var O;return T+(((O=U.focusEvents)==null?void 0:O.filter(D=>D.isFocusReset).length)??0)},0),f=rt(t,Ha),b=rt(t,za),w=f.length,A=b.length,I=((C=t[0])==null?void 0:C.readingOrderIssues)??[],g=((_=t[0])==null?void 0:_.tabOrderIssues)??[],y=I.filter(T=>!(ne(T.selector)in r)),j=I.filter(T=>ne(T.selector)in r),E=g.filter(T=>!(re(T.selector)in r)),$=g.filter(T=>re(T.selector)in r);if(c===0&&u===0&&w===0&&A===0&&y.length===0&&E.length===0&&j.length===0&&$.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const v=j.length+$.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[w," structural · ",A," form ·"," ",E.length," tab-order ·"," ",y.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),v>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",v," dismissed"]})]}),E.length>0&&e.jsx(Ya,{issues:E,onDismiss:d}),y.length>0&&e.jsx(Xa,{issues:y,onDismiss:d}),v>0&&e.jsx(Za,{dismissedReadingOrder:j,dismissedTabOrder:$,dismissals:r,onRestore:p}),w>0&&e.jsx(it,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:f}),A>0&&e.jsx(it,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:b}),e.jsx(Qa,{delta:s}),t.map((T,U)=>{const O=T.announcements??[],D=T.focusEvents??[];return O.length===0&&D.length===0?null:e.jsx(Ja,{state:T.state,announcements:O,focusEvents:D},U)})]})}function Qa({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function rt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Ve(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function it({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Ja({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Ka(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Ya({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Xa({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Za({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Oe="igtRuns";async function en(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await xe(r,o.map(l=>({key:re(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await xe(r,o.map(l=>({key:ne(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const tn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},sn={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},an={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ot(t,s){const a=await W();if(!a)return;const n=s?tn[t]:sn[t];try{await Q(a,n)}catch{}}async function nn(){const s=(await chrome.storage.local.get(Oe))[Oe];return s&&typeof s=="object"?s:{}}async function lt(t){await chrome.storage.local.set({[Oe]:t})}function rn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function on(){const t=m(c=>c.componentId),s=m(c=>c.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{nn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,u,h){var b;const f={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((b=o[c])==null?void 0:b.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(f),lt(f),h.status==="pass"){const w=G.find(I=>I.id===c),A=w==null?void 0:w.steps.find(I=>I.id===u);A!=null&&A.autoDismissActivity&&en(A.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[c];const h={...a,[t]:u};n(h),lt(h)}const p=G.find(c=>c.id===r);if(p){const c=o[p.id];return e.jsx(ln,{workflow:p,run:c,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),G.map(c=>{const u=o[c.id],h=u?rs(u,c):null,f=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",b={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${b}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function ln({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=x.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=rn(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ot(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",an[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ot(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(ge,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(ge,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:u=>n(d.id,{status:c.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const cn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function ge({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?cn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const be="savedFlows";async function dn(){const t=await chrome.storage.local.get(be);return Array.isArray(t[be])?t[be]:[]}async function ct(t){await chrome.storage.local.set({[be]:t})}function un(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{dn().then(s)},[]);async function o(){const c=await W();if(!c){i("No audit-target tab found.");return}try{await Q(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await W();if(c)try{const u=await me(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},b=[f,...t];s(b),await ct(b),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await W();if(u){i(`Replaying "${c.name}"…`);try{const h=await me(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==c);s(u),await ct(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function pn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(hn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function hn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function mn(){const t=m(l=>l.baselineList),s=m(l=>l.tier),a=St[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=x.useState(!1);if(x.useEffect(()=>{je().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await M({type:"BASELINE_DELETE",componentId:l}),await je()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=pn(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const xn={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function se({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${xn[t]}`,children:a})}const gn={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},fn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},bn={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Vt({onBack:t}){const s=m(u=>u.siteCrawlStatus),a=m(u=>u.siteCrawlProgress),n=m(u=>u.siteCrawlReport),r=m(u=>u.siteCrawlError),[i,o]=x.useState(""),[l,d]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),Y({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){M({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(vn,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function vn({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-vVi-sd9N.js");return{renderSiteReportHtml:a}},__vite__mapDeps([0,1,2,3])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${gn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${fn[t.siteRisk]}`,children:is[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=os(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${bn[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const Ie="onboardingDismissed",$e=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function yn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(Ie).then(l=>{l[Ie]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ie]:!0}),s(!1),n(0)}const i=a===$e.length-1,o=$e[a];return e.jsxs(ie,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",$e.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function jn(){const t=m(n=>n.status),s=m(n=>n.errorMessage),a=m(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function wn(){const t=m(d=>d.aiFailure),s=m(d=>d.clearAiFailure),[a,n]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function dt(){const[t,s]=x.useState(!1);return x.useEffect(()=>K("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),m.getState().setStatus("idle"))}),[]),e.jsxs(ie,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Nn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{ls().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Qe(),m.getState().startNewScan(),t.mode==="storybook-all"?Y({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&Y({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Qe(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const _e="storybook:hintDismissed";function kn(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(_e))[_e])return;const o=await W();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[_e]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Sn(){var i;const t=m(o=>o.results),s=m(o=>o.baselineList),a=m(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${An(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function An(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Cn(){const t=m(l=>l.results),s=m(l=>l.componentId),[a,n]=x.useState([]);if(x.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=cs(r,a.length>0?{runs:a,workflows:G}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Rn(){const t=m(a=>a.setUserMode);function s(a){t(a),M({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const En=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Tn={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function In(t){const s=new Set(En),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Tn[o]}}const Wt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},$n={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Wt]},_n={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Wt]};function He(t){return t==="thorough"?_n:$n}function ut(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const ve="wcagcheckr";function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function he(t){try{const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1,timeZoneName:"short"})}catch{return t}}function Ln(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Un(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function Dn(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function Fn(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function On(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${L(t.receipt.tsaName)}) — anchored ${L(he(t.receipt.anchoredAt))}</td></tr>
|
|
29
29
|
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${L(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
30
30
|
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${L(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${L(ve)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
31
31
|
<article class="entry">
|