@wcag-checkr/ci 1.0.0-rc.135 → 1.0.0-rc.136
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-C_uPVPR8.js → ErrorBoundary-1xI8bejt.js} +4 -4
- package/dist/assets/{copy-ai-fixer-prompt-DuLQ1mwo.js → copy-ai-fixer-prompt-DbbEfLo6.js} +2 -2
- package/dist/assets/{devtools-panel-BDTB7zC0.js → devtools-panel-DSZuNabW.js} +1 -1
- package/dist/assets/{parallel-tab-flow-DE4wbeMj.js → parallel-tab-flow-BbWRe96L.js} +1 -1
- package/dist/assets/{scheduled-audit-runner-SsZF0LGq.js → scheduled-audit-runner-3nAUxKGr.js} +2 -2
- package/dist/assets/{service-worker.ts-Y3OxkpZv.js → service-worker.ts-RIqN3wTG.js} +184 -177
- package/dist/assets/{side-panel-8uFQzAaH.js → side-panel-BZNlTsVt.js} +1 -1
- package/dist/assets/{site-report-renderer-ErZrhshM.js → site-report-renderer-CzL3uuvq.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,14 +1,14 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-
|
|
2
|
-
var Ms=Object.defineProperty;var Fs=(t,s,a)=>s in t?Ms(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var jt=(t,s,a)=>Fs(t,typeof s!="symbol"?s+"":s,a);import{R as Ce,i as ne,r as h,j as e,M as ve,C as et,l as Ps,o as ot,t as ct,m as Zt,s as es,k as Ee}from"./styles-oDRJ6qA5.js";import{s as Vs,g as Gs,a as ae,b as Ws,u as Bs,c as Hs,d as zs,e as Ks,f as dt,h as ts,A as te,l as ut,i as qs,j as De,k as ss,m as Qs,n as pt,o as Ys,p as Js,N as Xs,q as Zs,O as ea,r as ta,t as sa,v as aa,w as Nt,x as na,y as as,z as ra,B as ia,C as la,D as oa,E as ca,F as da,T as ua,G as pa,H as ma,I as ha,J as ns,K as xa,L as kt,M as St,P as Ke,Q as ga,R as At,S as fa,U as ba,V as va,W as ya,X as wa,Y as ja}from"./scheduled-audit-runner-SsZF0LGq.js";import{_ as mt}from"./diff-DA41zYPc.js";import{o as le,r as se,s as ee,c as rs,b as ie,d as xe}from"./crash-reporter-Dc5lvxvY.js";import{B as qe,i as is,f as ls,T as os}from"./ai-usage-log-DBBVxutJ.js";const Ct=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const m=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,m))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},Na=t=>t?Ct(t):Ct,ka=t=>t;function Sa(t,s=ka){const a=Ce.useSyncExternalStore(t.subscribe,Ce.useCallback(()=>s(t.getState()),[t,s]),Ce.useCallback(()=>s(t.getInitialState()),[t,s]));return Ce.useDebugValue(a),a}const It=t=>{const s=Na(t),a=n=>Sa(s,n);return Object.assign(a,s),a},Aa=t=>t?It(t):It,b=Aa(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}),Vs(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),Me="sidePanel:lastAudit";function Ca(){const t=[];return t.push(le("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||ne.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(le("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.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"}.`;ne.polite(r),Ia({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(le("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(le("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ne.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(le("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(le("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(le("LICENSE_CHANGED_EVENT",()=>{cs()})),t.push(le("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ne.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(le("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ne.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(le("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ne.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ia(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Me]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ra(){const s=(await chrome.storage.local.get(Me))[Me];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ea(){await chrome.storage.local.remove(Me)}async function Be(){b.getState().clearResults(),await Ea()}async function Fe(){const t=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function cs(t){const s=await se({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ds()}async function ds(){const{fetchMessages:t}=await mt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Fa);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ta(){const s=(await se({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function $a(){return chrome.runtime.connect({name:"audit-keepalive"})}let Pe=null;async function Ua(){if(Pe===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Pe=t.id)}catch{}}function us(){if(Pe===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Pe}).catch(()=>{})}function de(t){us(),ee(t)}function La({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,l]=h.useState(!0),[o,c]=h.useState(""),[p,d]=h.useState(!1),[u,m]=h.useState(null);async function x(g){var w;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const S=await se({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});S.success?(m({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((w=S.error)==null?void 0:w.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,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:g=>a(g.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:g=>r(g.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:o,onChange:g=>c(g.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:g=>l(g.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 Rt({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 Ve=rs("messages-client"),Da="https://api.wcagcheckr.com",ps="wcagcheckr",_a=1e4;function Oa(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ms(t,s){const a=await Gs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Oa()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Da}${t}`,{...s,headers:n,signal:AbortSignal.timeout(_a)})}async function Ma(t){try{const s=await ms(`/v1/products/${ps}/messages`,{userMode:t??null});return s.ok?await s.json():(Ve.warn("fetchMessages http",s.status),null)}catch(s){return Ve.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await ms(`/v1/products/${ps}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ve.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ve.warn("ackMessage failed",a),!1}}const Fa=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:Ma},Symbol.toStringTag,{value:"Module"})),Pa=["http:","https:"];function Va(t){try{const s=new URL(t);return Pa.includes(s.protocol)}catch{return!1}}function Et(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 l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Va(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:o},`l-${n++}`)),a=l+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(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function hs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Et(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:Et(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ga={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Wa={critical:"bg-rose-50 border-rose-200"};function xs(){const t=b(m=>m.unreadMessageCount),s=b(m=>m.messages),a=b(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[l,o]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),ge(x.id,"seen")}function p(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await ge(m.id,"dismissed")}async function u(m){m.ctaUrl&&(a(m.id,"clicked"),ge(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.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 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ba,{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(Ha,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Ba({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 Ha({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[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:()=>{ds()},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 ${Ga[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(hs,{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 gs(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Wa.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(hs,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","forensic","compliance"];function za(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ka(){var u,m;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(x=>x.status),[i,l]=h.useState(!1),o=((u=n[0])==null?void 0:u.pageUrl)??((m=n[0])==null?void 0:m.scope),c=za(o),p=n.length>0&&r!=="running";function d(){a("owner"),ee({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:d,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(xs,{}),e.jsx(Rt,{onClick:()=>void ee({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Rt,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&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:o??"",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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Be(),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(qa,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(La,{onClose:()=>l(!1)})})]})}function qa({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const l=(i+ye.length)%ye.length,o=ye[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"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 Qa({feature:t,upgradeUrl:s}){const[a,n]=h.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(et,{open:a,onClose:()=>n(!1)})]})}const Ya="https://wcagcheckr.com/upgrade";function Ja(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState(null),[c,p]=h.useState(qe),[d,u]=h.useState(qe[0].id),m=b(U=>U.status),x=b(U=>U.tier),g=b(U=>U.results.length>0),w=m==="running";h.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"matrixPresets"}),se({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,k])=>{const O=Array.isArray(U.data)?U.data:null;p(O&&O.length>0?O:qe),typeof k.data=="string"&&u(k.data)})},[]);function S(U){const k=c.find(O=>O.id===U);k&&(u(U),ee({type:"SETTINGS_SET",key:"activePresetId",value:U}),ee({type:"SETTINGS_SET",key:"stateMatrix",value:k.matrix}))}const T=is(x,"storybookAutoIterate");h.useEffect(()=>{const U=le("ELEMENT_PICKED_EVENT",(O,M)=>{n(!1);const q=M.frameId;D(q),i({selector:O.selector,frameId:q})}),k=le("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),k()}},[]);async function N(){const U=await ae();U&&(n(!0),await ie(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function E(){r&&(D(r.frameId),de({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function v(){if(!T){o("storybook:auto-iterate");return}D(),de({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function A(){D(),de({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function j(){D(),de({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function R(){D(),de({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function L(){D(),de({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function y(){ee({type:"CANCEL_AUDIT"})}async function D(U){b.getState().setPinned(null);const k=await ae();if(k)try{await ie(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},U)}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:U=>s(U.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:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:U=>S(U.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:c.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),t==="single-element"?e.jsx(Xa,{picking:a,picked:r,isRunning:w,onPick:N,onRun:E,onClearPick:()=>i(null)}):t==="full-page"?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…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:R,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:w?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:L,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:w?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:A,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:v,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:y,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&g&&e.jsx("button",{type:"button",onClick:()=>void Be(),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(Za,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(ve,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(Qa,{feature:l??"",upgradeUrl:Ya})})]})}function Xa({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 Za({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 en={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},tn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function sn(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState("off"),p=b(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(o(x),x==="off"?await ie(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ie(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await ae();if(g){if(t&&await ie(g,{type:en[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ie(g,{type:tn[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await ae();if(x){if(a){await ie(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await xe(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.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(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(we,{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(we,{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(we,{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(we,{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:m}),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:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="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 we({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 an(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 nn(){const t=b(c=>c.status),s=b(c=>c.progress),a=b(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":an(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Tt,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Tt,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Tt({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const je={"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 rn(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const ln={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 Ge({violation:t,alreadyAcknowledged:s}){const a=b(N=>N.pinnedMatchKey),n=b(N=>N.pinnedFound),r=b(N=>N.setPinned),i=b(N=>{var E;return(E=N.results[0])==null?void 0:E.frameId}),l=b(N=>{var E;return(E=N.results[0])==null?void 0:E.scope}),o=b(N=>N.results),c=b(N=>N.acknowledgedKeys.has(t.matchKey)),p=b(N=>N.markAcknowledged),d=b(N=>N.markUnacknowledged),u=s||c,m=a===t.matchKey,x=m&&!n;async function g(N){try{return(await xe(N,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:N,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const N=await ae();if(!N)return;if(m){r(null);try{await ie(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},i)}catch{}return}const E=await g(N);r(t.matchKey,E)}function S(N){N.stopPropagation(),t.currentState.breakpoint.width<=640&&us(),(async()=>{const E=await ae();if(!E)return;try{await se({type:"STATE_DRIVE_REQUEST",tabId:E,state:t.currentState,scope:l,frameId:i})}catch{}const v=await g(E);r(t.matchKey,v)})()}async function T(N){N.stopPropagation();const E=await ae();if(!E)return;try{await se({type:"STATE_DRIVE_REQUEST",tabId:E,state:un(),scope:l,frameId:i})}catch{ee({type:"STATE_RESET_REQUEST",tabId:E})}const v=await g(E);r(t.matchKey,v)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:w,"aria-pressed":m,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/copy-ai-fixer-prompt-DbbEfLo6.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-CzL3uuvq.js","assets/scheduled-audit-runner-3nAUxKGr.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Ms=Object.defineProperty;var Fs=(t,s,a)=>s in t?Ms(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var jt=(t,s,a)=>Fs(t,typeof s!="symbol"?s+"":s,a);import{R as Ce,i as ne,r as h,j as e,M as ve,C as et,l as Ps,o as ot,t as ct,m as Zt,s as es,k as Ee}from"./styles-oDRJ6qA5.js";import{s as Vs,g as Gs,a as ae,b as Ws,u as Bs,c as Hs,d as zs,e as Ks,f as dt,h as ts,A as te,l as ut,i as qs,j as De,k as ss,m as Qs,n as pt,o as Ys,p as Js,N as Xs,q as Zs,O as ea,r as ta,t as sa,v as aa,w as Nt,x as na,y as as,z as ra,B as ia,C as la,D as oa,E as ca,F as da,T as ua,G as pa,H as ma,I as ha,J as ns,K as xa,L as kt,M as St,P as Ke,Q as ga,R as At,S as fa,U as ba,V as va,W as ya,X as wa,Y as ja}from"./scheduled-audit-runner-3nAUxKGr.js";import{_ as mt}from"./diff-DA41zYPc.js";import{o as le,r as se,s as ee,c as rs,b as ie,d as xe}from"./crash-reporter-Dc5lvxvY.js";import{B as qe,i as is,f as ls,T as os}from"./ai-usage-log-DBBVxutJ.js";const Ct=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const m=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,m))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},Na=t=>t?Ct(t):Ct,ka=t=>t;function Sa(t,s=ka){const a=Ce.useSyncExternalStore(t.subscribe,Ce.useCallback(()=>s(t.getState()),[t,s]),Ce.useCallback(()=>s(t.getInitialState()),[t,s]));return Ce.useDebugValue(a),a}const It=t=>{const s=Na(t),a=n=>Sa(s,n);return Object.assign(a,s),a},Aa=t=>t?It(t):It,b=Aa(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}),Vs(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),Me="sidePanel:lastAudit";function Ca(){const t=[];return t.push(le("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||ne.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(le("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.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"}.`;ne.polite(r),Ia({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(le("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(le("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ne.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(le("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(le("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(le("LICENSE_CHANGED_EVENT",()=>{cs()})),t.push(le("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ne.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(le("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ne.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(le("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ne.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ia(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Me]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ra(){const s=(await chrome.storage.local.get(Me))[Me];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ea(){await chrome.storage.local.remove(Me)}async function Be(){b.getState().clearResults(),await Ea()}async function Fe(){const t=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function cs(t){const s=await se({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ds()}async function ds(){const{fetchMessages:t}=await mt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Fa);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ta(){const s=(await se({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function $a(){return chrome.runtime.connect({name:"audit-keepalive"})}let Pe=null;async function Ua(){if(Pe===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Pe=t.id)}catch{}}function us(){if(Pe===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Pe}).catch(()=>{})}function de(t){us(),ee(t)}function La({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,l]=h.useState(!0),[o,c]=h.useState(""),[p,d]=h.useState(!1),[u,m]=h.useState(null);async function x(g){var w;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const S=await se({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});S.success?(m({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((w=S.error)==null?void 0:w.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,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:g=>a(g.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:g=>r(g.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:o,onChange:g=>c(g.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:g=>l(g.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 Rt({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 Ve=rs("messages-client"),Da="https://api.wcagcheckr.com",ps="wcagcheckr",_a=1e4;function Oa(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ms(t,s){const a=await Gs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Oa()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Da}${t}`,{...s,headers:n,signal:AbortSignal.timeout(_a)})}async function Ma(t){try{const s=await ms(`/v1/products/${ps}/messages`,{userMode:t??null});return s.ok?await s.json():(Ve.warn("fetchMessages http",s.status),null)}catch(s){return Ve.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await ms(`/v1/products/${ps}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ve.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ve.warn("ackMessage failed",a),!1}}const Fa=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:Ma},Symbol.toStringTag,{value:"Module"})),Pa=["http:","https:"];function Va(t){try{const s=new URL(t);return Pa.includes(s.protocol)}catch{return!1}}function Et(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 l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Va(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:o},`l-${n++}`)),a=l+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(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function hs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Et(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:Et(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ga={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Wa={critical:"bg-rose-50 border-rose-200"};function xs(){const t=b(m=>m.unreadMessageCount),s=b(m=>m.messages),a=b(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[l,o]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),ge(x.id,"seen")}function p(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await ge(m.id,"dismissed")}async function u(m){m.ctaUrl&&(a(m.id,"clicked"),ge(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.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 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ba,{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(Ha,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Ba({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 Ha({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[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:()=>{ds()},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 ${Ga[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(hs,{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 gs(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Wa.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(hs,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","forensic","compliance"];function za(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ka(){var u,m;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(x=>x.status),[i,l]=h.useState(!1),o=((u=n[0])==null?void 0:u.pageUrl)??((m=n[0])==null?void 0:m.scope),c=za(o),p=n.length>0&&r!=="running";function d(){a("owner"),ee({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:d,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(xs,{}),e.jsx(Rt,{onClick:()=>void ee({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Rt,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&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:o??"",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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Be(),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(qa,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(La,{onClose:()=>l(!1)})})]})}function qa({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const l=(i+ye.length)%ye.length,o=ye[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"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 Qa({feature:t,upgradeUrl:s}){const[a,n]=h.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(et,{open:a,onClose:()=>n(!1)})]})}const Ya="https://wcagcheckr.com/upgrade";function Ja(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState(null),[c,p]=h.useState(qe),[d,u]=h.useState(qe[0].id),m=b(U=>U.status),x=b(U=>U.tier),g=b(U=>U.results.length>0),w=m==="running";h.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"matrixPresets"}),se({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,k])=>{const O=Array.isArray(U.data)?U.data:null;p(O&&O.length>0?O:qe),typeof k.data=="string"&&u(k.data)})},[]);function S(U){const k=c.find(O=>O.id===U);k&&(u(U),ee({type:"SETTINGS_SET",key:"activePresetId",value:U}),ee({type:"SETTINGS_SET",key:"stateMatrix",value:k.matrix}))}const T=is(x,"storybookAutoIterate");h.useEffect(()=>{const U=le("ELEMENT_PICKED_EVENT",(O,M)=>{n(!1);const q=M.frameId;D(q),i({selector:O.selector,frameId:q})}),k=le("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),k()}},[]);async function N(){const U=await ae();U&&(n(!0),await ie(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function E(){r&&(D(r.frameId),de({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function v(){if(!T){o("storybook:auto-iterate");return}D(),de({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function A(){D(),de({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function j(){D(),de({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function R(){D(),de({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function L(){D(),de({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function y(){ee({type:"CANCEL_AUDIT"})}async function D(U){b.getState().setPinned(null);const k=await ae();if(k)try{await ie(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},U)}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:U=>s(U.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:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:U=>S(U.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:c.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),t==="single-element"?e.jsx(Xa,{picking:a,picked:r,isRunning:w,onPick:N,onRun:E,onClearPick:()=>i(null)}):t==="full-page"?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…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:R,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:w?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:L,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:w?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:A,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:v,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:y,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&g&&e.jsx("button",{type:"button",onClick:()=>void Be(),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(Za,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(ve,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(Qa,{feature:l??"",upgradeUrl:Ya})})]})}function Xa({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 Za({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 en={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},tn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function sn(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState("off"),p=b(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(o(x),x==="off"?await ie(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ie(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await ae();if(g){if(t&&await ie(g,{type:en[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ie(g,{type:tn[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await ae();if(x){if(a){await ie(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await xe(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.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(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(we,{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(we,{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(we,{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(we,{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:m}),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:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="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 we({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 an(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 nn(){const t=b(c=>c.status),s=b(c=>c.progress),a=b(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":an(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Tt,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Tt,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Tt({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const je={"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 rn(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const ln={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 Ge({violation:t,alreadyAcknowledged:s}){const a=b(N=>N.pinnedMatchKey),n=b(N=>N.pinnedFound),r=b(N=>N.setPinned),i=b(N=>{var E;return(E=N.results[0])==null?void 0:E.frameId}),l=b(N=>{var E;return(E=N.results[0])==null?void 0:E.scope}),o=b(N=>N.results),c=b(N=>N.acknowledgedKeys.has(t.matchKey)),p=b(N=>N.markAcknowledged),d=b(N=>N.markUnacknowledged),u=s||c,m=a===t.matchKey,x=m&&!n;async function g(N){try{return(await xe(N,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:N,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const N=await ae();if(!N)return;if(m){r(null);try{await ie(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},i)}catch{}return}const E=await g(N);r(t.matchKey,E)}function S(N){N.stopPropagation(),t.currentState.breakpoint.width<=640&&us(),(async()=>{const E=await ae();if(!E)return;try{await se({type:"STATE_DRIVE_REQUEST",tabId:E,state:t.currentState,scope:l,frameId:i})}catch{}const v=await g(E);r(t.matchKey,v)})()}async function T(N){N.stopPropagation();const E=await ae();if(!E)return;try{await se({type:"STATE_DRIVE_REQUEST",tabId:E,state:un(),scope:l,frameId:i})}catch{ee({type:"STATE_RESET_REQUEST",tabId:E})}const v=await g(E);r(t.matchKey,v)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:w,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
3
|
${m?"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 ${ln[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(pn,{violation:t}),e.jsx(xn,{violation:t}),e.jsx(hn,{violation:t}),e.jsx(mn,{text:t.target.failureSummary}),e.jsx(gn,{ruleId:t.ruleId}),m&&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: ",on(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),S(N))},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:T,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),T(N))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),x&&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:N=>{N.stopPropagation(),d(t.matchKey),dn(t,o)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.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:N=>{N.stopPropagation(),p(t.matchKey),cn(t,o)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.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:N=>N.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function on(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 cn(t,s){await Hs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await fs(t.componentId,s)}async function dn(t,s){await Bs(t.componentId,t.matchKey),await fs(t.componentId,s)}async function fs(t,s){const a=s.flatMap(n=>n.violations);try{const n=await se({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function un(){const t=ls.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function bs(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 pn({violation:t}){const s=bs(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 mn({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 hn({violation:t}){const s=rn(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 xn({violation:t}){const s=bs(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ws(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await se({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await zs(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.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,l)=>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})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function gn({ruleId:t}){const s=Ks(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 tt=[{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","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],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"]}];function ht(t){const s=tt.map(r=>bn(r,t)),a=fn(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function fn(t){const s=t.filter(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function bn(t,s){const a=new Set(t.axeRules),n=s.violations.filter(k=>a.has(k.ruleId)),r=s.manualRuns.filter(k=>t.igtWorkflowIds.includes(k.workflowId)),i=t.igtWorkflowIds.map(k=>s.workflows.find(O=>O.id===k)).filter(k=>k!=null);let l=i.length>0;for(const k of i){const O=r.find(q=>q.workflowId===k.id);if((O?Object.keys(O.steps).length:0)!==k.steps.length){l=!1;break}}const o=r.some(k=>Object.keys(k.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(k=>c.includes(k.workflowId)),d=c.map(k=>s.workflows.find(O=>O.id===k)).filter(k=>k!=null);let u=c.length>0&&d.length===c.length;for(const k of d){const O=p.find(q=>q.workflowId===k.id);if((O?Object.keys(O.steps).length:0)!==k.steps.length){u=!1;break}}let m=null;if(u)for(const k of p)k.completedAt&&(m===null||k.completedAt>m)&&(m=k.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,w=s.interactiveAuditVerdicts,S=[];w&&(t.id==="tab-order"&&w.focusOrder&&S.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&S.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&S.push({verdict:w.focusVisible,criterionId:"2.4.7"})));const T=S.some(k=>k.verdict==="fail");if(S.length>0&&S.every(k=>k.verdict==="pass")&&c.length>0&&!u)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:S.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:S.map(k=>k.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const E=t.axeRules.length>0||t.heuristic!=null,v=t.igtWorkflowIds.length>0;if(E?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:v||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j={critical:0,serious:0,moderate:0,minor:0};for(const k of dt(n))j[k.impact]++;S.length>0&&S.every(k=>k.verdict==="pass")||(j.serious+=x),T&&(j.serious+=S.filter(k=>k.verdict==="fail").length);for(const k of r){const O=i.find(M=>M.id===k.workflowId);if(O)for(const M of O.steps){const q=k.steps[M.id];(q==null?void 0:q.status)==="fail"&&(M.severity==="required"?j.serious++:j.moderate++)}}const L=j.critical>0,y=j.serious>0;let D;j.critical>=5?D="F":j.critical>=1?D="D":j.serious>=1?D="C":j.moderate>=1?D="B":D="A";const U=D!=="A"&&(v&&!l||c.length>0&&!u);return{id:t.id,label:t.label,letter:D,untested:!1,needsIgt:U,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:j,caps:{cappedAtC:L,cappedAtB:y}}}const st="dismissedFindings";function He(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function fe(t){return`reading-order::${t}`}function be(t){return`tab-order::${t}`}async function ze(){try{const t=await chrome.storage.local.get(st),s=t==null?void 0:t[st];if(s&&typeof s=="object")return s}catch{}return{}}async function xt(t){await chrome.storage.local.set({[st]:t})}async function We(t){return(await ze())[He(t)]??{}}async function vs(t,s,a,n){const r=await ze(),i=He(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await xt(r)}async function Re(t,s){if(s.length===0)return;const a=await ze(),n=He(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await xt(a)}async function ys(t,s){const a=await ze(),n=He(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await xt(a))}const Cl=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:vs,addDismissals:Re,dismissalKeyForReadingOrder:fe,dismissalKeyForTabOrder:be,getDismissalsForUrl:We,removeDismissal:ys},Symbol.toStringTag,{value:"Module"}));function ws(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function js(t){return`${ut(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function vn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=js(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 $t={critical:0,serious:1,moderate:2,minor:3};function yn(){var N,E,v,A;const t=b(j=>j.results),s=b(j=>j.componentId),a=b(j=>j.setView),n=((N=t[0])==null?void 0:N.pageUrl)??((E=t[0])==null?void 0:E.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(new Set),[c,p]=h.useState({});if(h.useEffect(()=>{if(!s){p({});return}let j=!1;const R=async()=>{const y=await ts(s);if(j)return;const D={};for(const U of y)U.criterionId==="2.4.3"?D.focusOrder=U.verdict:U.criterionId==="2.1.2"?D.keyboardTrap=U.verdict:U.criterionId==="2.4.7"?D.focusVisible=U.verdict:U.criterionId==="1.3.2"&&(D.readingOrder=U.verdict);p(D)};R();const L=y=>{y.interactiveAuditResults&&R()};return chrome.storage.local.onChanged.addListener(L),()=>{j=!0,chrome.storage.local.onChanged.removeListener(L)}},[s]),h.useEffect(()=>{if(!n)return;We(n).then(i);const j=()=>{document.visibilityState==="visible"&&n&&We(n).then(i)};return document.addEventListener("visibilitychange",j),()=>document.removeEventListener("visibilitychange",j)},[n]),h.useEffect(()=>{if(!s){o(new Set);return}let j=!1;const R=async()=>{const y=await chrome.storage.local.get("igtRuns");if(j)return;const U=((y==null?void 0:y.igtRuns)??{})[s]??{},k=new Set;for(const O of te){const M=U[O.id];M&&Object.keys(M.steps).length===O.steps.length&&k.add(O.id)}o(k)};R();const L=()=>{document.visibilityState==="visible"&&R()};return document.addEventListener("visibilitychange",L),()=>{j=!0,document.removeEventListener("visibilitychange",L)}},[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((j,R)=>j+R.durationMs,0),u=t.reduce((j,R)=>j+R.violations.length,0),m=vn(t);m.sort((j,R)=>{const L=$t[j.representative.impact]??99,y=$t[R.representative.impact]??99;return L!==y?L-y:R.states.length-j.states.length});const x=t.map(j=>ws(j.state)).join(`
|
|
4
4
|
`),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",w=l.has("keyboard")||g?0:(((v=t[0])==null?void 0:v.tabOrderIssues)??[]).filter(j=>!(be(j.selector)in r)).length,S=c.readingOrder!==void 0,T=l.has("page-structure")||S?0:(((A=t[0])==null?void 0:A.readingOrderIssues)??[]).filter(j=>!(fe(j.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(kn,{violations:t.flatMap(j=>j.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(w>0||T>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:[w>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:w})," tab-order issue",w===1?"":"s"," (WCAG 2.4.3)"]}),w>0&&T>0&&" · ",T>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:T})," reading-order issue",T===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:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(jn,{groups:m,totalStates:t.length,violations:t.flatMap(j=>j.violations),interactiveVerdicts:c})]})}const wn={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 jn({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=ht({violations:a,auditRan:!0,manualRuns:[],workflows:te,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,l=new Set;for(const c of tt){for(const p of c.axeRules)l.add(p);i.set(c.id,[])}const o=[];for(const c of t){let p=!1;for(const d of tt)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||o.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const p=i.get(c.id)??[];return e.jsx(Ut,{subGrade:c,groups:p,totalStates:s},c.id)}),o.length>0&&e.jsx(Ut,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:o,totalStates:s})]})}function Ut({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,l]=h.useState("idle"),[o,c]=h.useState(null),[p,d]=h.useState(0),u=s.length>0,m=wn[t.letter],x=s.filter(S=>S.representative.ruleId==="color-contrast"||S.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function w(S){S.stopPropagation(),l("loading"),c(null);try{const T=x.map(E=>{const v=E.representative.target.outerHTML,A=E.representative.target.failureSummary,j=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(A),R=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(A);if(!j||!R)return null;const L=E.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:E.representative.matchKey,foreground:j[1],background:R[1],fontSize:16,fontWeight:400,targetLevel:L,_html:v}}).filter(E=>E!==null);if(T.length===0){l("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const N=await se({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:E,...v})=>v)});if(N.unavailableReason&&N.results.length===0){l("error"),c(N.unavailableReason);return}await qs(N.results),l("done"),d(E=>E+1),n||r(!0)}catch(T){l("error"),c(T instanceof Error?T.message:String(T))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(S=>!S),"aria-expanded":n,disabled:!u,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${m}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:u?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:S=>void w(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w(S))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),u&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&o&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:o}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(S=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ge,{violation:S.representative}),e.jsx(Sn,{states:S.states,totalStates:a})]},`${js(S.representative)}::${p}`))})]})}const Nn={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 kn({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=b(p=>p.setView),l=ht({violations:t,auditRan:!0,manualRuns:a,workflows:te,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=dt(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${Nn[l]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:l})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function Sn({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(ws))),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 An={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Cn={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 In({violations:t,componentId:s}){var pe,me,ue,f,P,B,G;const[a,n]=h.useState([]),[r,i]=h.useState([]),[l,o]=h.useState(new Set),[c,p]=h.useState(null),[d,u]=h.useState({}),[m,x]=h.useState(new Set),g=b(C=>C.status),w=b(C=>C.progress),S=b(C=>C.freshThisSession),T=b(C=>C.results),N=(pe=T[0])==null?void 0:pe.startedAt,E=((me=T[0])==null?void 0:me.pageUrl)??((ue=T[0])==null?void 0:ue.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let C=!1;return chrome.storage.local.get("igtRuns").then(F=>{if(C)return;const W=((F==null?void 0:F.igtRuns)??{})[s]??{};n(Object.values(W))}),()=>{C=!0}},[s]),h.useEffect(()=>{if(!E){i([]);return}let C=!1;return De(E).then(F=>{C||i(F)}),()=>{C=!0}},[E]),g==="running")return e.jsx(Dn,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const v=ht({violations:t,auditRan:T.length>0,manualRuns:a,workflows:te,heuristicCounts:{tabOrder:((P=(f=T[0])==null?void 0:f.tabOrderIssues)==null?void 0:P.length)??0,readingOrder:((G=(B=T[0])==null?void 0:B.readingOrderIssues)==null?void 0:G.length)??0}}),A=b(C=>C.acknowledgedKeys),j=T.length>0?ss(T,{runs:a,workflows:te},"2.1","AA",A,r):void 0,R=T.length>0?Qs(pt({audits:T,igtRuns:a,workflows:te,acknowledgedMatchKeys:A,incompleteResolutions:r}),te):void 0,L=j?j.failingCriteria.length>0||j.inconclusiveCriteria.length>0:!1,y=L&&v.overallLetter==="A"?"B":v.overallLetter;async function D(C){var ce;if(!E||!((ce=j==null?void 0:j.inconclusiveReasons)!=null&&ce[C]))return;const V=j.inconclusiveReasons[C].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(V.length===0)return;o(J=>new Set(J).add(C)),p(null);const W=[];let Y=0;try{for(const H of V){const I=await ee({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:H.ruleOrStepId,pageUrl:H.pageUrl??E,wcagCriterion:C,elements:H.elements??[],targetLevel:"AA"});if(I!=null&&I.unavailableReason){p(I.unavailableReason);break}I!=null&&I.resolutions&&(W.push(...I.resolutions),Y+=I.totalCostUsd??0)}if(E){const H=await De(E);i(H)}const J={total:W.length,pass:W.filter(H=>H.verdict==="pass").length,fail:W.filter(H=>H.verdict==="fail").length,uncertain:W.filter(H=>H.verdict==="uncertain").length,costUsd:Y,resolutions:W};u(H=>({...H,[C]:J}))}finally{o(J=>{const H=new Set(J);return H.delete(C),H})}}function U(C){x(F=>{const V=new Set(F);return V.has(C)?V.delete(C):V.add(C),V})}async function k(C){var I,z;if(!E)return;const F=((I=j==null?void 0:j.inconclusiveReasons)==null?void 0:I[C])??[],V=((z=j==null?void 0:j.failingReasons)==null?void 0:z[C])??[],W=[],Y=new Set;for(const _ of F){if(_.source!=="axe-incomplete"||!_.elements)continue;const K=_.pageUrl??E;for(const X of _.elements){const Z=`${K}::${_.ruleOrStepId}::${X.selector}`;Y.has(Z)||(Y.add(Z),W.push({ruleId:_.ruleOrStepId,pageUrl:K,selector:X.selector}))}}for(const _ of V){if(_.source!=="ai"||!_.selector)continue;const K=_.ruleOrStepId.startsWith("ai-resolved::")?_.ruleOrStepId.slice(13):_.ruleOrStepId,X=_.pageUrl??E,Z=`${X}::${K}::${_.selector}`;Y.has(Z)||(Y.add(Z),W.push({ruleId:K,pageUrl:X,selector:_.selector}))}if(W.length===0)return;const ce=new Date().toISOString(),J=[];for(const _ of W){const K=r.find(X=>X.pageUrl===_.pageUrl&&X.ruleId===_.ruleId&&X.selector===_.selector);K&&K.verdict==="pass"&&K.reasoning.startsWith("Marked as visually verified")||J.push({pageUrl:_.pageUrl,ruleId:_.ruleId,selector:_.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${ce.slice(0,10)}.`,resolvedAt:ce,costUsd:0,wcagCriterion:C})}if(J.length===0)return;await Ys(J);const H=await De(E);i(H),u(_=>({..._,[C]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const O=(()=>{if(!L||v.overallLetter!=="A"||!j)return null;const C=j.inconclusiveCriteria.length,F=j.failingCriteria.length,V=[];F>0&&V.push(`${F} WCAG ${j.targetLevel} ${F===1?"criterion":"criteria"} failing`),C>0&&V.push(`${C} WCAG ${j.targetLevel} ${C===1?"criterion":"criteria"} inconclusive`);const W=F>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${V.join(" + ")}. ${W}`})();let M=0;for(const C of te){const F=a.find(W=>W.workflowId===C.id);if(!F)continue;C.steps.every(W=>{const Y=F.steps[W.id];return(Y==null?void 0:Y.status)==="pass"||(Y==null?void 0:Y.status)==="fail"||(Y==null?void 0:Y.status)==="skip"||(Y==null?void 0:Y.status)==="not-applicable"})&&M++}const q=dt(t.filter(C=>!A.has(C.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!S&&N&&e.jsx(_n,{scannedAt:N}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${An[y]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:y})}),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 ",v.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&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:O})]})]}),v.isLawsuitRisk&&e.jsx(Tn,{areas:v.warningAreas}),e.jsx($n,{grades:v.subGrades}),j&&e.jsx(Rn,{coverage:j,onResolveWithAi:D,onMarkVisuallyVerified:k,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:U}),R&&e.jsx(En,{layers:R}),e.jsx(Ln,{violationsRemaining:q,manualCompleted:M,manualTotal:te.length}),M>0||T.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:M})," of ",e.jsx("strong",{children:te.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:`${M/te.length*100}%`}})})]}):null]})}function Rn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=h.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${m?"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 ${m?"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 (",u,"%)"]}),m&&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)."]}),!m&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const w=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",w,"."]})})(),!m&&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."]}),!m&&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."]})]}),!m&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!m&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(w=>{var R,L;const S=g.kind==="inconclusive"?(R=t.inconclusiveReasons)==null?void 0:R[w]:void 0,T=g.kind==="failing"?(L=t.failingReasons)==null?void 0:L[w]:void 0,N=S==null?void 0:S.some(y=>y.source==="axe-incomplete"&&y.elements&&y.elements.length>0),E=T==null?void 0:T.some(y=>y.source==="ai"),v=(n==null?void 0:n.has(w))??!1,A=i==null?void 0:i[w],j=(l==null?void 0:l.has(w))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",w]}),(g.kind==="inconclusive"&&N||g.kind==="failing"&&E)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(w),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":A?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:v,onClick:()=>a(w),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:g.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),A&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",A.total," ",A.total===1?"verdict":"verdicts",":",A.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",A.pass," pass"]}),A.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",A.fail," fail"]}),A.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",A.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",A.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(w),className:"ml-auto text-[10px] underline text-brand-700",children:j?"hide reasoning":"show reasoning"})]}),A.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",A.uncertain," ",A.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),A.pass===A.total&&A.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),j&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:A.resolutions.map((y,D)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:y.verdict==="pass"?"text-emerald-700 font-semibold":y.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:y.verdict==="pass"?"✓":y.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:y.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:y.reasoning})]},D))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((y,D)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[y.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),y.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:y.selector}),y.notes&&e.jsx("span",{className:"text-rose-700",children:y.notes})]},D))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((y,D)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[y.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," skipped — "]}),y.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.resolutionHint,y.elements&&y.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",y.elements.length===1?"element":`${y.elements.length} elements`,":"," ",y.elements.slice(0,3).map((U,k,O)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:U.selector}),k<O.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},k)),y.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",y.elements.length-3," more"]})]})]},D))}):g.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.)"})]},w)})})]},g.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const Lt={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 En({layers:t}){const s=b(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,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,p=i>0&&l===0&&o===0,d=p?"text-emerald-700":l>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":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":l>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:Lt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Lt[n].hint}),n==="human"&&o>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 Tn({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 $n({grades:t}){const s=b(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 ${Cn[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(Un,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Un({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=te.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?Ns(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 Ln({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.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:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{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(l=>!l.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((l,o)=>{const c=o===i,p=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"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:[l.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Dn({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 _n({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 (",Ns(s)," old). Re-scan to grade the current page state."]})]})}function Ns(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`}function On(){const t=b(a=>a.results),s=b(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(In,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(Mn,{})]})}function Mn(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(Ne,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(Ne,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(Ne,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(Ne,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(Ne,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function Ne({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Fn={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 Pn({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ge,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),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 ${Fn[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:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),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((c,p)=>e.jsx(Ge,{violation:c},p))})]})}function Vn(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 Gn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function ks({open:t,onClose:s,format:a,content:n,filename:r}){const i=Ps(new Blob([n]).size);function l(){ct(n,r),s()}function o(){ot(n),s()}return e.jsxs(ve,{open:t,onClose:s,title:Gn[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:o,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:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Dt=7800;function Wn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
|
|
6
6
|
`),c=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${c.toString()}`;return p.length>Dt&&(p=p.slice(0,Dt)),{url:p,title:i,body:o}}const _t=7800;function Bn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`Rule: ${d.ruleId} (${d.impact})`),l.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),l.push(`Description: ${d.description}`),l.push(`Selector: ${d.target.selector}`),l.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&l.push(`More info: ${d.helpUrl}`),l.push(""),l.push(`HTML: ${d.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
|
|
7
7
|
`),c=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>_t&&(p=p.slice(0,_t)),{url:p,summary:i,description:o}}const Ot=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Hn=["wcag-component-auditor","wcag-forensic-log"];async function zn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Ot);s=Object.keys(n).length,await chrome.storage.local.remove(Ot)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Hn)try{await Kn(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function Kn(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const at="accessibilityStatementInputs:v1";async function qn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:null}async function Qn(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[at]:t})}function Yn({open:t,onClose:s,results:a}){const[n,r]=h.useState("eaa"),[i,l]=h.useState(""),[o,c]=h.useState(""),[p,d]=h.useState("partial"),[u,m]=h.useState(""),[x,g]=h.useState(""),[w,S]=h.useState(""),[T,N]=h.useState(""),[E,v]=h.useState("English"),[A,j]=h.useState("wcagcheckr (self-evaluation)"),[R,L]=h.useState("2.1"),[y,D]=h.useState("AA"),[U,k]=h.useState(!1),[O,M]=h.useState(null),q=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var P,B,G,C;const f=await qn();if(f&&(f.framing&&r(f.framing),f.organizationName&&l(f.organizationName),f.siteUrl&&c(f.siteUrl),f.conformanceStatus&&d(f.conformanceStatus),(P=f.contact)!=null&&P.email&&m(f.contact.email),(B=f.contact)!=null&&B.phone&&g(f.contact.phone),(G=f.contact)!=null&&G.formUrl&&S(f.contact.formUrl),f.countryCode&&N(f.countryCode),f.language&&v(f.language),f.auditedBy&&j(f.auditedBy),f.wcagVersion&&L(f.wcagVersion),f.wcagLevel&&D(f.wcagLevel)),!(f!=null&&f.siteUrl)&&((C=a[0])!=null&&C.pageUrl))try{const F=new URL(a[0].pageUrl);c(`${F.protocol}//${F.host}/`)}catch{}f!=null&&f.conformanceStatus||d(Js(a)),setTimeout(()=>{var F;return(F=q.current)==null?void 0:F.focus()},50)})()},[t,a]),!t)return null;function pe(){var G;const f=new Date().toISOString().slice(0,10),P=(G=a[0])!=null&&G.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):f,B={};return u.trim()&&(B.email=u.trim()),x.trim()&&(B.phone=x.trim()),w.trim()&&(B.formUrl=w.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:p,preparedAt:f,evaluatedAt:P,contact:B,countryCode:T||null,language:E.trim()||"English",auditedBy:A.trim()||"wcagcheckr (self-evaluation)",wcagVersion:R,wcagLevel:y}}function me(f){if(!f.organizationName)return"Organization name is required.";if(!f.siteUrl)return"Site URL is required.";try{new URL(f.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!f.contact.email&&!f.contact.phone&&!f.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function ue(f){M(null);const P=pe(),B=me(P);if(B){M(B);return}k(!0);try{await Qn(P);const G=await se({type:"EXPORT_REQUEST",format:f==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:P}),C=(G==null?void 0:G.content)??"";if(!C||C.startsWith("# Accessibility statement — error")){M(C||"Export failed — no response.");return}try{await navigator.clipboard.writeText(C)}catch{}const F=new Blob([C],{type:f==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),V=URL.createObjectURL(F);window.open(V,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(V),6e4),s()}catch(G){M(G instanceof Error?G.message:String(G))}finally{k(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:n==="eaa",onChange:()=>r("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:n==="wad",onChange:()=>r("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:q,type:"text",value:i,onChange:f=>l(f.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:f=>c(f.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:p,onChange:f=>d(f.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:R,onChange:f=>L(f.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:y,onChange:f=>D(f.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:u,onChange:f=>m(f.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:f=>g(f.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:w,onChange:f=>S(f.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:T,onChange:f=>N(f.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Xs).map(([f,P])=>e.jsxs("option",{value:f,children:[f," — ",P.name.replace(/^[A-Z]+\s*—\s*/,"")]},f))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:E,onChange:f=>v(f.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:A,onChange:f=>j(f.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),O&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:O})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void ue("markdown"),disabled:U,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:U?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void ue("html"),disabled:U,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:U?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:U,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function Jn(){const t=b(f=>f.delta),s=b(f=>f.componentId),a=b(f=>f.results),n=b(f=>f.tier),r=b(f=>f.baselineList),i=b(f=>f.siteCrawlReport),[l,o]=h.useState(""),[c,p]=h.useState(""),[d,u]=h.useState(!1),[m,x]=h.useState(!1),[g,w]=h.useState(null),[S,T]=h.useState(null),[N,E]=h.useState(!1),[v,A]=h.useState(!1),[j,R]=h.useState(null),[L,y]=h.useState(!1);h.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"githubRepoUrl"}),se({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([f,P])=>{o(typeof f.data=="string"?f.data:""),p(typeof P.data=="string"?P.data:"")})},[]),h.useEffect(()=>le("BADGE_CLICKED_EVENT",P=>{const B=`viol-row-${P.violationId}`,G=document.getElementById(B);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-rose-500"),setTimeout(()=>G.classList.remove("ring-2","ring-rose-500"),1500))}),[]),h.useEffect(()=>()=>{(async()=>{const f=await ae();f&&(v&&await ie(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),L&&await ie(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}))})()},[]);async function D(){const f=await ae();if(!f){ne.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(v){await ie(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),A(!1),R(null);return}const P={critical:4,serious:3,moderate:2,minor:1},B=new Map;for(const V of a)for(const W of V.violations)B.has(W.matchKey)||B.set(W.matchKey,W);const C=Array.from(B.values()).sort((V,W)=>P[W.impact]-P[V.impact]).map((V,W)=>({id:V.matchKey,index:W+1,selector:V.target.selector,impact:V.impact,ruleId:V.ruleId,wcagCriterion:V.wcagCriterion}));if(C.length===0){ne.polite("No violations to badge.");return}const F=await xe(f,{type:"BADGES_SHOW_REQUEST",tabId:f,violations:C}).catch(()=>null);F&&(A(!0),R({rendered:F.rendered,requested:F.requested,clustered:F.clustered}),ne.polite(`${F.rendered} violation badges shown on the page.`))}async function U(){const f=await ae();if(!f){ne.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(L){await ie(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}),y(!1);return}const P=new Map;for(const C of a)for(const F of C.violations)P.has(F.matchKey)||P.set(F.matchKey,F);const B=Array.from(P.values()).map(C=>({selector:C.target.selector,impact:C.impact}));if(B.length===0){ne.polite("No violations to heatmap.");return}const G=await xe(f,{type:"HEATMAP_SHOW_REQUEST",tabId:f,violations:B}).catch(()=>null);G&&(y(!0),ne.polite(`Heatmap shown with ${G.rendered} violation blobs.`))}const k=is(n,"exportJson"),O=os[n].maxBaselines,M=r.some(f=>f.componentId===s),q=M||r.length<O;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function pe(){if(!s||a.length===0)return;const f=a.flatMap(W=>W.violations),P=a.flatMap(W=>W.announcements??[]),B=a.flatMap(W=>W.focusEvents??[]),G=a[0],F=(await se({type:"SETTINGS_GET",key:"stateMatrix"})).data??ls;await ee({type:"BASELINE_SET",componentId:s,violations:f,announcements:P,focusEvents:B,snapshotMeta:{url:window.location.href,axeVersion:G.axeVersion,matrixConfig:F,capturedAt:new Date().toISOString()}});const V=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:f,announcements:P,focusEvents:B,currentMatrix:F});b.getState().setDelta(V.delta),ne.polite(`Baseline saved for ${s}.`)}async function me(){if(!s||!M||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
8
8
|
|
|
9
|
-
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await ee({type:"BASELINE_DELETE",componentId:s});const P=a.flatMap(V=>V.violations),B=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),C=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:P,announcements:B,focusEvents:G});b.getState().setDelta(C.delta);const F=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(F.items),ne.polite(`Baseline cleared for ${s}.`)}async function ue(f,P=!1){if(a.length===0)return;if(f==="ai-prompt"){const{copyAiFixerPrompt:H}=await mt(async()=>{const{copyAiFixerPrompt:I}=await import("./copy-ai-fixer-prompt-DuLQ1mwo.js");return{copyAiFixerPrompt:I}},__vite__mapDeps([0,1,2]));await H({results:a,componentId:s,delta:P?void 0:t,siteCrawlReport:i});return}let B;if((f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet")&&s){const H=await chrome.storage.local.get("igtRuns"),z=((H==null?void 0:H.igtRuns)??{})[s]??{};B=Object.values(z)}const F=await se({type:"EXPORT_REQUEST",format:f,results:a,delta:P?void 0:t??void 0,manualRuns:B,dismissedKeys:void 0,incompleteResolutions:void 0});if(f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet"){const H=Zt(f,s);await es()?ct(F.content,H):T({open:!0,format:f,content:F.content,filename:H});return}if(f==="html-print"||f==="vpat"||f==="methodology-doc"||f==="conformance-crosswalk"){ot(F.content);return}const V=f==="json"?"application/json":f==="sarif"?"application/sarif+json":"application/xml",W=f==="junit"?"xml":f,Y=new Blob([F.content],{type:V}),ce=URL.createObjectURL(Y),J=document.createElement("a");J.href=ce,J.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${W}`,J.click(),URL.revokeObjectURL(ce)}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:pe,disabled:!q,title:q?void 0:`Free tier limits you to ${O} 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"}),M&&e.jsx("button",{onClick:me,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("button",{onClick:()=>u(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void D(),"aria-pressed":v,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:v?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:v?"Hide badges":"Show badges 🎯"}),v&&j&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[j.rendered," of ",j.requested," rendered",j.clustered>0?` · ${j.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":L,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:L?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:L?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(tr,{disabled:!k,onExport:ue,onAccessibilityStatement:()=>E(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!q&&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 f=Qe(t.new),P=Qe(t.persistent),B=Qe(t.fixed),G=[...f.review,...P.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:f.findings,count:f.findings.length,accent:"red",actions:[...l&&f.findings.length>0?[{label:"File GitHub issue",onClick:()=>Zn(l,s,f.findings)}]:[],...c&&f.findings.length>0?[{label:"File Jira issue",onClick:()=>er(c,s,f.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:P.findings,count:P.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:B.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(ks,{open:S.open,onClose:()=>T(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Yn,{open:N,onClose:()=>E(!1),results:a}),d&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{u(!1),w(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>u(!1),disabled:m,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{x(!0);try{const f=await zn();w(f),await Be(),ne.polite("Audit data reset. Ready for a fresh scan.")}catch(f){w({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[f instanceof Error?f.message:String(f)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const Xn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Qe(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=h.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 ${Xn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?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((c,p)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},p)):Vn(s).map(c=>e.jsx(Pn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Zn(t,s,a){if(a.length===0)return;const{url:n}=Wn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function er(t,s,a){if(a.length===0)return;const{url:n}=Bn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function tr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[l,o]=h.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),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 ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!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:[n&&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:l,onChange:p=>o(p.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(oe,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(oe,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(oe,{onClick:()=>c("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(oe,{onClick:()=>c("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(oe,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(oe,{onClick:()=>c("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(oe,{onClick:()=>c("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(oe,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(oe,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(oe,{onClick:()=>c("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(oe,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(oe,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function oe({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 Mt="igtRuns";async function sr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Mt))[Mt];return s&&typeof s=="object"?s:{}}async function ar(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await sr())[t];if(i)for(const c of te){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const nr=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"]),rr=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 ir(t){return nr.has(t.ruleId)}function lr(t){return rr.has(t.ruleId)}function or(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function cr(){var L,y,D,U;const t=b(k=>k.results),s=b(k=>k.delta),a=b(k=>k.componentId),n=((L=t[0])==null?void 0:L.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(0);h.useEffect(()=>{if(!n)return;let k=!1;return(async()=>{if(a&&t.length>0)try{await ar(a,t)}catch{}if(k)return;const O=await We(n);k||i(O)})(),()=>{k=!0}},[n,l,a,t]);async function c(k,O){if(!n)return;const M=window.prompt(`Why is this finding a false positive?
|
|
9
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await ee({type:"BASELINE_DELETE",componentId:s});const P=a.flatMap(V=>V.violations),B=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),C=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:P,announcements:B,focusEvents:G});b.getState().setDelta(C.delta);const F=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(F.items),ne.polite(`Baseline cleared for ${s}.`)}async function ue(f,P=!1){if(a.length===0)return;if(f==="ai-prompt"){const{copyAiFixerPrompt:H}=await mt(async()=>{const{copyAiFixerPrompt:I}=await import("./copy-ai-fixer-prompt-DbbEfLo6.js");return{copyAiFixerPrompt:I}},__vite__mapDeps([0,1,2]));await H({results:a,componentId:s,delta:P?void 0:t,siteCrawlReport:i});return}let B;if((f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet")&&s){const H=await chrome.storage.local.get("igtRuns"),z=((H==null?void 0:H.igtRuns)??{})[s]??{};B=Object.values(z)}const F=await se({type:"EXPORT_REQUEST",format:f,results:a,delta:P?void 0:t??void 0,manualRuns:B,dismissedKeys:void 0,incompleteResolutions:void 0});if(f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet"){const H=Zt(f,s);await es()?ct(F.content,H):T({open:!0,format:f,content:F.content,filename:H});return}if(f==="html-print"||f==="vpat"||f==="methodology-doc"||f==="conformance-crosswalk"){ot(F.content);return}const V=f==="json"?"application/json":f==="sarif"?"application/sarif+json":f==="ticket-bundle"?"text/markdown":"application/xml",W=f==="junit"?"xml":f==="ticket-bundle"?"md":f,Y=new Blob([F.content],{type:V}),ce=URL.createObjectURL(Y),J=document.createElement("a");J.href=ce,J.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${W}`,J.click(),URL.revokeObjectURL(ce)}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:pe,disabled:!q,title:q?void 0:`Free tier limits you to ${O} 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"}),M&&e.jsx("button",{onClick:me,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("button",{onClick:()=>u(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void D(),"aria-pressed":v,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:v?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:v?"Hide badges":"Show badges 🎯"}),v&&j&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[j.rendered," of ",j.requested," rendered",j.clustered>0?` · ${j.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":L,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:L?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:L?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(tr,{disabled:!k,onExport:ue,onAccessibilityStatement:()=>E(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!q&&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 f=Qe(t.new),P=Qe(t.persistent),B=Qe(t.fixed),G=[...f.review,...P.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:f.findings,count:f.findings.length,accent:"red",actions:[...l&&f.findings.length>0?[{label:"File GitHub issue",onClick:()=>Zn(l,s,f.findings)}]:[],...c&&f.findings.length>0?[{label:"File Jira issue",onClick:()=>er(c,s,f.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:P.findings,count:P.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:B.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),S&&e.jsx(ks,{open:S.open,onClose:()=>T(null),format:S.format,content:S.content,filename:S.filename}),e.jsx(Yn,{open:N,onClose:()=>E(!1),results:a}),d&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{u(!1),w(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>u(!1),disabled:m,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{x(!0);try{const f=await zn();w(f),await Be(),ne.polite("Audit data reset. Ready for a fresh scan.")}catch(f){w({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[f instanceof Error?f.message:String(f)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const Xn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Qe(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=h.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 ${Xn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?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((c,p)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},p)):Vn(s).map(c=>e.jsx(Pn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Zn(t,s,a){if(a.length===0)return;const{url:n}=Wn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function er(t,s,a){if(a.length===0)return;const{url:n}=Bn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function tr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[l,o]=h.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),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 ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!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:[n&&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:l,onChange:p=>o(p.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(oe,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(oe,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(oe,{onClick:()=>c("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(oe,{onClick:()=>c("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(oe,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(oe,{onClick:()=>c("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(oe,{onClick:()=>c("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(oe,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(oe,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(oe,{onClick:()=>c("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(oe,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(oe,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(oe,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function oe({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 Mt="igtRuns";async function sr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Mt))[Mt];return s&&typeof s=="object"?s:{}}async function ar(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await sr())[t];if(i)for(const c of te){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const nr=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"]),rr=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 ir(t){return nr.has(t.ruleId)}function lr(t){return rr.has(t.ruleId)}function or(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function cr(){var L,y,D,U;const t=b(k=>k.results),s=b(k=>k.delta),a=b(k=>k.componentId),n=((L=t[0])==null?void 0:L.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(0);h.useEffect(()=>{if(!n)return;let k=!1;return(async()=>{if(a&&t.length>0)try{await ar(a,t)}catch{}if(k)return;const O=await We(n);k||i(O)})(),()=>{k=!0}},[n,l,a,t]);async function c(k,O){if(!n)return;const M=window.prompt(`Why is this finding a false positive?
|
|
10
10
|
|
|
11
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");M!==null&&(await vs(n,k,M||"(no reason given)",O),o(q=>q+1))}async function p(k){n&&(await ys(n,k),o(O=>O+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 d=t.reduce((k,O)=>{var M;return k+(((M=O.announcements)==null?void 0:M.length)??0)},0),u=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.length)??0)},0),m=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.filter(q=>q.isFocusReset).length)??0)},0),x=Ft(t,ir),g=Ft(t,lr),w=x.length,S=g.length,T=((D=t[0])==null?void 0:D.readingOrderIssues)??[],N=((U=t[0])==null?void 0:U.tabOrderIssues)??[],E=T.filter(k=>!(fe(k.selector)in r)),v=T.filter(k=>fe(k.selector)in r),A=N.filter(k=>!(be(k.selector)in r)),j=N.filter(k=>be(k.selector)in r);if(d===0&&u===0&&w===0&&S===0&&E.length===0&&A.length===0&&v.length===0&&j.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 R=v.length+j.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 · ",S," form ·"," ",A.length," tab-order ·"," ",E.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),R>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",R," dismissed"]})]}),A.length>0&&e.jsx(pr,{issues:A,onDismiss:c}),E.length>0&&e.jsx(mr,{issues:E,onDismiss:c}),R>0&&e.jsx(hr,{dismissedReadingOrder:v,dismissedTabOrder:j,dismissals:r,onRestore:p}),w>0&&e.jsx(Pt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),S>0&&e.jsx(Pt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(dr,{delta:s}),t.map((k,O)=>{const M=k.announcements??[],q=k.focusEvents??[];return M.length===0&&q.length===0?null:e.jsx(ur,{state:k.state,announcements:M,focusEvents:q},O)})]})}function dr({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 Ft(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ut(r.ruleId,r.target.selector),l=a.get(i);l?l.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 Pt({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 ur({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:or(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 pr({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 mr({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 hr({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),l=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 (",l,")"]}),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(o=>{const c=`tab-order::${o.selector}`,p=a[c];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:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];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:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const nt="igtRuns";async function xr(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 l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:be(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const gr={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"}},fr={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"}},br={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Vt(t,s){const a=await ae();if(!a)return;const n=s?gr[t]:fr[t];try{await ie(a,n)}catch{}}async function vr(){const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}async function Gt(t){await chrome.storage.local.set({[nt]:t})}function yr(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 wr(){const t=b(d=>d.componentId),s=b(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{vr().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 l=a[t]??{};function o(d,u,m){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[u]:m},completedAt:new Date().toISOString()}}};if(n(x),Gt(x),m.status==="pass"){const w=te.find(T=>T.id===d),S=w==null?void 0:w.steps.find(T=>T.id===u);S!=null&&S.autoDismissActivity&&xr(S.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[d];const m={...a,[t]:u};n(m),Gt(m)}const p=te.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx(jr,{workflow:p,run:d,results:s,onAnswer:(u,m)=>o(p.id,u,m),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."}),te.map(d=>{const u=l[d.id],m=u?Zs(u,d):null,x=u?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",g={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"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function jr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=yr(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.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}),o>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:[o," step",o===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:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.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:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.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."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.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."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.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})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Vt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",br[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Vt(c.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(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Nr={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 Te({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?Nr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const _e="savedFlows";async function kr(){const t=await chrome.storage.local.get(_e);return Array.isArray(t[_e])?t[_e]:[]}async function Wt(t){await chrome.storage.local.set({[_e]:t})}function Sr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{kr().then(s)},[]);async function l(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await ie(d,{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 o(){const d=await ae();if(d)try{const u=await xe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Wt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await ae();if(u){i(`Replaying "${d.name}"…`);try{const m=await xe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(m=>m.id!==d);s(u),await Wt(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:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,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(d=>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:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),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(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function Ar(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),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(Cr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Cr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ir(){const t=b(o=>o.baselineList),s=b(o=>o.tier),a=os[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>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"})]},o))});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 l(o){await ee({type:"BASELINE_DELETE",componentId:o}),await Fe()}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(o=>{const c=Ar(o.componentId),p=o.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:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Rr={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Rr[t]}`,children:a})}const Er={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"},Tr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},$r={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 Ss({onBack:t}){const s=b(u=>u.siteCrawlStatus),a=b(u=>u.siteCrawlProgress),n=b(u=>u.siteCrawlReport),r=b(u=>u.siteCrawlError),[i,l]=h.useState(""),[o,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const m=(x=u[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&l(m)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${o*5} minutes. Proceed?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),de({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){ee({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=>l(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:o,onChange:u=>c(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. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),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:d,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(Ur,{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 Ur({report:t}){function s(){mt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-ErZrhshM.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Er[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Tr[t.siteRisk]}`,children:ea[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.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),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(i=>{const l=ta(i.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 ${$r[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.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.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Lr(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function Lr(t){try{const s=await sa(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){b.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}b.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ye="onboardingDismissed",Je=[{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 Dr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Ye).then(o=>{o[Ye]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1),n(0)}const i=a===Je.length-1,l=Je[a];return e.jsxs(ve,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.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," / ",Je.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-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(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function _r(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(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 Or(){const t=b(c=>c.aiFailure),s=b(c=>c.clearAiFailure),[a,n]=h.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",l="⚠",o=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:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),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((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Bt(){const[t,s]=h.useState(!1);return h.useEffect(()=>le("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ve,{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 Mr(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{aa().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await Nt(),b.getState().startNewScan(),t.mode==="storybook-all"?de({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&de({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Nt(),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 Xe="storybook:hintDismissed";function Fr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Xe))[Xe])return;const l=await ae();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Xe]:!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 Pr(){var i;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.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 ${Vr(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 Vr(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 l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function Gr(){const t=b(o=>o.results),s=b(o=>o.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=na(r,a.length>0?{runs:a,workflows:te}:void 0),l=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."})," ",l?"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 Wr(){const t=b(a=>a.setUserMode);function s(a){t(a),ee({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 Br=["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"],Hr={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 zr(t){const s=new Set(Br),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Hr[l]}}const As={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Kr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[As]},qr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[As]};function gt(t){return t==="thorough"?qr:Kr}function Ht(t){const s=gt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function Q(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ie(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 Qr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Yr(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 Jr(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 Xr(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 Zr(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 (${Q(t.receipt.tsaName)}) — anchored ${Q(Ie(t.receipt.anchoredAt))}</td></tr>
|
|
11
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");M!==null&&(await vs(n,k,M||"(no reason given)",O),o(q=>q+1))}async function p(k){n&&(await ys(n,k),o(O=>O+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 d=t.reduce((k,O)=>{var M;return k+(((M=O.announcements)==null?void 0:M.length)??0)},0),u=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.length)??0)},0),m=t.reduce((k,O)=>{var M;return k+(((M=O.focusEvents)==null?void 0:M.filter(q=>q.isFocusReset).length)??0)},0),x=Ft(t,ir),g=Ft(t,lr),w=x.length,S=g.length,T=((D=t[0])==null?void 0:D.readingOrderIssues)??[],N=((U=t[0])==null?void 0:U.tabOrderIssues)??[],E=T.filter(k=>!(fe(k.selector)in r)),v=T.filter(k=>fe(k.selector)in r),A=N.filter(k=>!(be(k.selector)in r)),j=N.filter(k=>be(k.selector)in r);if(d===0&&u===0&&w===0&&S===0&&E.length===0&&A.length===0&&v.length===0&&j.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 R=v.length+j.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 · ",S," form ·"," ",A.length," tab-order ·"," ",E.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),R>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",R," dismissed"]})]}),A.length>0&&e.jsx(pr,{issues:A,onDismiss:c}),E.length>0&&e.jsx(mr,{issues:E,onDismiss:c}),R>0&&e.jsx(hr,{dismissedReadingOrder:v,dismissedTabOrder:j,dismissals:r,onRestore:p}),w>0&&e.jsx(Pt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),S>0&&e.jsx(Pt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(dr,{delta:s}),t.map((k,O)=>{const M=k.announcements??[],q=k.focusEvents??[];return M.length===0&&q.length===0?null:e.jsx(ur,{state:k.state,announcements:M,focusEvents:q},O)})]})}function dr({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 Ft(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ut(r.ruleId,r.target.selector),l=a.get(i);l?l.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 Pt({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 ur({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:or(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 pr({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 mr({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 hr({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),l=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 (",l,")"]}),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(o=>{const c=`tab-order::${o.selector}`,p=a[c];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:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];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:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const nt="igtRuns";async function xr(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 l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:be(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const gr={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"}},fr={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"}},br={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Vt(t,s){const a=await ae();if(!a)return;const n=s?gr[t]:fr[t];try{await ie(a,n)}catch{}}async function vr(){const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}async function Gt(t){await chrome.storage.local.set({[nt]:t})}function yr(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 wr(){const t=b(d=>d.componentId),s=b(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{vr().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 l=a[t]??{};function o(d,u,m){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[u]:m},completedAt:new Date().toISOString()}}};if(n(x),Gt(x),m.status==="pass"){const w=te.find(T=>T.id===d),S=w==null?void 0:w.steps.find(T=>T.id===u);S!=null&&S.autoDismissActivity&&xr(S.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[d];const m={...a,[t]:u};n(m),Gt(m)}const p=te.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx(jr,{workflow:p,run:d,results:s,onAnswer:(u,m)=>o(p.id,u,m),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."}),te.map(d=>{const u=l[d.id],m=u?Zs(u,d):null,x=u?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",g={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"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function jr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=yr(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.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}),o>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:[o," step",o===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:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.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:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.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."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.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."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.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})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Vt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",br[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Vt(c.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(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Nr={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 Te({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?Nr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const _e="savedFlows";async function kr(){const t=await chrome.storage.local.get(_e);return Array.isArray(t[_e])?t[_e]:[]}async function Wt(t){await chrome.storage.local.set({[_e]:t})}function Sr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{kr().then(s)},[]);async function l(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await ie(d,{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 o(){const d=await ae();if(d)try{const u=await xe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Wt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await ae();if(u){i(`Replaying "${d.name}"…`);try{const m=await xe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(m=>m.id!==d);s(u),await Wt(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:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,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(d=>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:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),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(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function Ar(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),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(Cr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Cr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Ir(){const t=b(o=>o.baselineList),s=b(o=>o.tier),a=os[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>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"})]},o))});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 l(o){await ee({type:"BASELINE_DELETE",componentId:o}),await Fe()}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(o=>{const c=Ar(o.componentId),p=o.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:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Rr={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Rr[t]}`,children:a})}const Er={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"},Tr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},$r={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 Ss({onBack:t}){const s=b(u=>u.siteCrawlStatus),a=b(u=>u.siteCrawlProgress),n=b(u=>u.siteCrawlReport),r=b(u=>u.siteCrawlError),[i,l]=h.useState(""),[o,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const m=(x=u[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&l(m)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${o*5} minutes. Proceed?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),de({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){ee({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=>l(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:o,onChange:u=>c(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. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),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:d,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(Ur,{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 Ur({report:t}){function s(){mt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-CzL3uuvq.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Er[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Tr[t.siteRisk]}`,children:ea[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.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),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(i=>{const l=ta(i.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 ${$r[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.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.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Lr(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function Lr(t){try{const s=await sa(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){b.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}b.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ye="onboardingDismissed",Je=[{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 Dr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Ye).then(o=>{o[Ye]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1),n(0)}const i=a===Je.length-1,l=Je[a];return e.jsxs(ve,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.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," / ",Je.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-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(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function _r(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(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 Or(){const t=b(c=>c.aiFailure),s=b(c=>c.clearAiFailure),[a,n]=h.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",l="⚠",o=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:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),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((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Bt(){const[t,s]=h.useState(!1);return h.useEffect(()=>le("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ve,{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 Mr(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{aa().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await Nt(),b.getState().startNewScan(),t.mode==="storybook-all"?de({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&de({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Nt(),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 Xe="storybook:hintDismissed";function Fr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Xe))[Xe])return;const l=await ae();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Xe]:!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 Pr(){var i;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.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 ${Vr(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 Vr(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 l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function Gr(){const t=b(o=>o.results),s=b(o=>o.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=na(r,a.length>0?{runs:a,workflows:te}:void 0),l=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."})," ",l?"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 Wr(){const t=b(a=>a.setUserMode);function s(a){t(a),ee({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 Br=["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"],Hr={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 zr(t){const s=new Set(Br),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Hr[l]}}const As={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Kr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[As]},qr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[As]};function gt(t){return t==="thorough"?qr:Kr}function Ht(t){const s=gt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function Q(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ie(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 Qr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Yr(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 Jr(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 Xr(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 Zr(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 (${Q(t.receipt.tsaName)}) — anchored ${Q(Ie(t.receipt.anchoredAt))}</td></tr>
|
|
12
12
|
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${Q(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
13
13
|
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${Q(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${Q(Oe)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
14
14
|
<article class="entry">
|