@wcag-checkr/ci 1.0.0-rc.378 → 1.0.0-rc.379

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-Y9f60-qy.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-KD5f4utB.js","assets/diff-RnwNJg4F.js","assets/ai-usage-log-CYyG5MT2.js","assets/copy-ai-fixer-prompt-Cy0vn92r.js","assets/site-report-renderer-Fg6z2lun.js"])))=>i.map(i=>d[i]);
2
- var pn=Object.defineProperty;var hn=(t,s,a)=>s in t?pn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var bs=(t,s,a)=>hn(t,typeof s!="symbol"?s+"":s,a);import{R as Je,k as he,r as m,j as e,M as We,C as Ve,A as vs}from"./styles--3_xfDyE.js";import{n as Xt,o as mn,p as xn,q as ys,t as da,u as me,v as ua,w as De,S as Me,g as Xe,b as gn,c as fn,x as Re,y as Oe,z as Zt,A as pa,B as bn,C as vn,D as yn,E as wn,j as jn,F as Nn,f as kn,h as es,G as Sn,H as An,N as Cn,I as Vt,J as ha,K as Wt,L as In,e as et,l as En,O as Rn,M as vt,P as Tn,Q as $n,R as ws,T as Ln,U as Un,V as _n,W as Dn,X as On,Y as Fn,Z as Mn,_ as Pn,$ as Gn,a0 as ma,a1 as Vn,a2 as js,a3 as Ns,a4 as Lt,a5 as Wn,a6 as ks,a7 as Bn,a8 as Hn,a9 as Kn,k as zn,m as qn}from"./scheduled-audit-runner-Y9f60-qy.js";import{o as be,a as se,f as je,s as Q,c as xa,h as ve,r as Te,j as ga,T as Qn}from"./crash-reporter-KD5f4utB.js";import{_ as ke}from"./preload-helper-D7HrI6pR.js";import{g as fa,f as At,t as rt,r as Yn,B as Pe,h as Jn,i as ts,j as fe,e as ss,k as Xn,o as _e,m as ba,n as Ct,p as Zn,q as er,u as tr,v as sr,T as ar,w as nr}from"./ai-usage-log-CYyG5MT2.js";import{g as va,a as ya}from"./diff-RnwNJg4F.js";import{s as rr,t as ir}from"./design-system-audit-DpxJrxnb.js";const Ss=t=>{let s;const a=new Set,n=(p,c)=>{const d=typeof p=="function"?p(s):p;if(!Object.is(d,s)){const h=s;s=c??(typeof d!="object"||d===null)?d:Object.assign({},s,d),a.forEach(g=>g(s,h))}},r=()=>s,i={setState:n,getState:r,getInitialState:()=>u,subscribe:p=>(a.add(p),()=>a.delete(p))},u=s=t(n,r,i);return i},or=t=>t?Ss(t):Ss,lr=t=>t;function cr(t,s=lr){const a=Je.useSyncExternalStore(t.subscribe,Je.useCallback(()=>s(t.getState()),[t,s]),Je.useCallback(()=>s(t.getInitialState()),[t,s]));return Je.useDebugValue(a),a}const As=t=>{const s=or(t),a=n=>cr(s,n);return Object.assign(a,s),a},dr=t=>t?As(t):As,b=dr(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"free",seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null,crawlNavContext:null,resolutionsByUrl:{},pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,pendingAreaExpand:null,auditStartedAtMs:null,lastAuditWallClockMs:null,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,auditStartedAtMs:Date.now(),crawlNavContext:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t(r=>{const o=r.auditStartedAtMs?Date.now()-r.auditStartedAtMs:null;return{results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0,lastAuditWallClockMs:o,auditStartedAtMs:null}}),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,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}),setFindingsLens:s=>t({findingsLens:s}),setPendingAreaExpand:s=>t({pendingAreaExpand:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setCrawlNavContext:s=>t({crawlNavContext:s}),setResolutionsForUrl:(s,a)=>t(n=>({resolutionsByUrl:{...n.resolutionsByUrl,[s]:a}})),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Xt(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setCrawlDiscoveryStatus:s=>t({crawlDiscoveryStatus:s}),setCrawlDiscoveryProgress:(s,a)=>t({crawlDiscoveryFound:s,crawlDiscoveryLastUrl:a}),setCrawlDiscoveryUrls:s=>t({crawlDiscoveryUrls:s}),resetCrawlDiscovery:()=>t({crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null}),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}}),dismissedKeys:new Set,setDismissedKeys:s=>t({dismissedKeys:s}),markDismissed:s=>t(a=>({dismissedKeys:new Set(a.dismissedKeys).add(s)})),markUndismissed:s=>t(a=>{const n=new Set(a.dismissedKeys);return n.delete(s),{dismissedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(i=>i.id!==s?i:a==="seen"?{...i,seen:!0}:a==="dismissed"?{...i,dismissed:!0}:a==="acknowledged"?{...i,acknowledged:!0}:a==="clicked"?{...i,clicked:!0}:i).filter(i=>i.severity==="critical"?!i.acknowledged:!i.dismissed),o=r.filter(i=>!i.seen).length,l=r.some(i=>i.severity==="critical"&&!i.acknowledged);return{messages:r,unreadMessageCount:o,criticalUnacked:l}})})),yt="sidePanel:lastAudit";function ur(){const t=[];return t.push(be("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState(),n=a.status==="running",r=a.siteCrawlStatus==="running";a.setProgress({current:s.current,total:s.total,currentState:s.currentState}),r||(a.setStatus("running"),n||he.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(be("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((u,p)=>u+p.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"}.`;he.polite(r);const o=b.getState().view;["compliance","guided","crawl"].includes(o)||(b.getState().setView("report"),b.getState().setFindingsLens("overview")),hr({results:s.results,delta:s.delta,componentId:s.componentId}),pr(s.results,s.delta,s.componentId)})),t.push(be("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(be("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||he.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(be("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(be("SCORECARD_UPDATED_EVENT",()=>{wt()})),t.push(be("LICENSE_CHANGED_EVENT",()=>{wa()})),t.push(be("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&&he.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(be("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),he.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(u=>u.aJ);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(u=>u.aL);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3,4])),o=await n();if(!o||o.length===0)return;const l=b.getState().setResolutionsForUrl;await Promise.all(o.map(async i=>{try{const u=await r(i.url);l(i.url,u)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(be("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),he.assertive(`Site crawl failed: ${s.error.message}`)})),t.push(be("CRAWL_DISCOVERY_PROGRESS_EVENT",s=>{const a=b.getState();a.crawlDiscoveryStatus!=="discovering"&&a.setCrawlDiscoveryStatus("discovering"),a.setCrawlDiscoveryProgress(s.found,s.url),s.found===1&&he.polite("Discovering pages to review.")})),t.push(be("CRAWL_DISCOVERY_COMPLETE_EVENT",s=>{const a=b.getState();a.setCrawlDiscoveryUrls(s.urls),a.setCrawlDiscoveryStatus("reviewing"),he.polite(`Discovery complete. ${s.urls.length} page${s.urls.length===1?"":"s"} found — review and choose which to audit.`)})),t.push(be("CRAWL_DISCOVERY_FAILED_EVENT",s=>{const a=b.getState();a.resetCrawlDiscovery(),a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),he.assertive(`Page discovery failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function pr(t,s,a){var n,r;if(t.length!==0)try{const o=await fa();if(!o.enabled)return;const l=b.getState().tier;if(da(l)||!je(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",u=[],p=b.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const d=await se({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:p});if(typeof d.content!="string"||d.content.length<200)continue;const h=At(c,a??null);rt(d.content,h),i&&await Yn({url:i,exportedAt:new Date().toISOString(),format:c,filename:h}),u.push(h)}catch(d){console.warn(`[auto-export] format ${c} failed:`,d)}u.length>0&&he.polite(`Audit auto-exported ${u.length} file${u.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function hr(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[yt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function mr(){const s=(await chrome.storage.local.get(yt))[yt];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function xr(){await chrome.storage.local.remove(yt)}async function It(){const t=b.getState();t.clearResults(),t.setSiteCrawlReport(null),t.setSiteCrawlError(null),t.setSiteCrawlStatus("idle"),await xr();const{saveSiteCrawlReport:s}=await ke(async()=>{const{saveSiteCrawlReport:n}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(r=>r.aJ);return{saveSiteCrawlReport:n}},__vite__mapDeps([0,1,2,3,4]));await s(null);const{clearAllCachedAudits:a}=await ke(async()=>{const{clearAllCachedAudits:n}=await import("./ai-usage-log-CYyG5MT2.js").then(r=>r.Q);return{clearAllCachedAudits:n}},__vite__mapDeps([4,2]));await a()}async function wt(){const t=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function wa(t){const s=await se({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ja()}async function ja(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ar);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 gr(){async function t(){const s=await mn();if(!s||xn(s)==="expired"){ys(null);return}ys(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function fr(){const s=(await se({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;b.getState().setUserMode(a)}function br(){return chrome.runtime.connect({name:"audit-keepalive"})}let jt=null;async function vr(){if(jt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(jt=t.id)}catch{}}function as(){if(jt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:jt}).catch(()=>{})}function Ne(t){as(),b.getState().setSiteCrawlReport(null),Xt(null).catch(()=>{}),Q(t)}function yr(t){as(),b.getState().setSiteCrawlReport(null),Xt(null).catch(()=>{}),Q(t)}const Bt="dismissedFindings";function Et(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function tt(t){return`reading-order::${t}`}function st(t){return`tab-order::${t}`}function ns(t){return`violation::${t}`}async function Rt(){try{const t=await chrome.storage.local.get(Bt),s=t==null?void 0:t[Bt];if(s&&typeof s=="object")return s}catch{}return{}}async function rs(t){await chrome.storage.local.set({[Bt]:t})}async function is(t){return(await Rt())[Et(t)]??{}}async function os(t,s,a,n){const r=await Rt(),o=Et(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await rs(r)}async function at(t,s){if(s.length===0)return;const a=await Rt(),n=Et(t),r=a[n]??{},o=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:o,snippet:l.snippet};a[n]=r,await rs(a)}async function ls(t,s){const a=await Rt(),n=Et(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await rs(a))}const pd=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:os,addDismissals:at,dismissalKeyForReadingOrder:tt,dismissalKeyForTabOrder:st,dismissalKeyForViolation:ns,getDismissalsForUrl:is,removeDismissal:ls},Symbol.toStringTag,{value:"Module"}));function wr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[o,l]=m.useState(!0),[i,u]=m.useState(""),[p,c]=m.useState(!1),[d,h]=m.useState(null);async function g(f){var v;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const w=await se({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});w.success?(h({ok:!0,msg:`Sent (ref: ${w.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((v=w.error)==null?void 0:v.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:g,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:f=>a(f.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:f=>r(f.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:i,onChange:f=>u(f.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:o,onChange:f=>l(f.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)."})]}),d&&e.jsx("p",{id:"support-form-result",role:d.ok?"status":"alert",className:`text-xs ${d.ok?"text-green-700":"text-red-700"}`,children:d.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 Cs({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 Nt=xa("messages-client"),jr="https://api.wcagcheckr.com",Na="wcagcheckr",Nr=1e4;function kr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ka(t,s){const a=await va();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":kr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${jr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Nr)})}async function Sr(t){if(!await va())return null;try{const s=await ka(`/v1/products/${Na}/messages`,{userMode:t??null});return s.ok?await s.json():(Nt.warn("fetchMessages http",s.status),null)}catch(s){return Nt.warn("fetchMessages failed",s),null}}async function Ge(t,s){try{const a=await ka(`/v1/products/${Na}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Nt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Nt.warn("ackMessage failed",a),!1}}const Ar=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Ge,fetchMessages:Sr},Symbol.toStringTag,{value:"Module"})),Cr=["http:","https:"];function Ir(t){try{const s=new URL(t);return Cr.includes(s.protocol)}catch{return!1}}function Is(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const o=t.indexOf("]",a+1);if(o!==-1&&t[o+1]==="("){const l=t.indexOf(")",o+2);if(l!==-1){const i=t.slice(a+1,o),u=t.slice(o+2,l);Ir(u)?s.push(e.jsx("a",{href:u,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:i},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:i},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const o=t.indexOf("**",a+2);if(o!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,o)},`b-${n++}`)),a=o+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const o=t.indexOf("*",a+1);if(o!==-1&&t[o+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,o)},`i-${n++}`)),a=o+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Sa({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],o=0;function l(){if(r.length===0)return;const u=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Is(u)},`p-${o++}`)),r=[]}function i(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((u,p)=>e.jsx("li",{children:Is(u)},p))},`u-${o++}`)),n=[])}for(const u of s){const p=u.trimEnd();if(p===""){l(),i();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){l(),n.push(c[1]);continue}i(),r.push(p)}return l(),i(),e.jsx("div",{className:"space-y-1.5",children:a})}const Er={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Rr={critical:"bg-rose-50 border-rose-200"};function Aa(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),o=m.useRef(-1),[l,i]=m.useState(!1);m.useEffect(()=>{const h=s.filter(f=>!f.seen);if(h.length===0)return;const g=Math.max(...h.map(f=>f.id));if(g>o.current){o.current=g,i(!0);const f=setTimeout(()=>i(!1),1500);return()=>clearTimeout(f)}},[s]);async function u(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Ge(g.id,"seen")}function p(){const h=!n;r(h),h&&u()}async function c(h){a(h.id,"dismissed"),await Ge(h.id,"dismissed")}async function d(h){h.ctaUrl&&(a(h.id,"clicked"),Ge(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Tr,{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($r,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:d})]})}function Tr({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 $r({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const o=i=>{r.current&&(r.current.contains(i.target)||s())},l=i=>{i.key==="Escape"&&s()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",o),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:()=>{ja()},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(o=>e.jsx("li",{className:`p-3 ${o.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Er[o.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:o.title}),o.dismissible&&o.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(o),"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(Sa,{source:o.bodyMd})}),o.ctaLabel&&o.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(o),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:o.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(o.createdAt).toLocaleString()})]})]})},o.id))})]})}function Ca(){const t=b(o=>o.messages),s=b(o=>o.applyMessageAck),a=t.find(o=>o.severity==="critical"&&!o.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 ${Rr.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(Sa,{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 Lr=[{id:"owner",label:"Owner",tooltip:"Site owners. Focuses on the specific issues demand-letter mills flag, with plain-language fix recipes per issue. Goal: get off the lawsuit-bot radar."},{id:"power",label:"Power user",tooltip:"Compliance verdict + full audit findings without the granular surfaces. Streamlined for people who want the answer, not the deep dive."},{id:"dev",label:"Dev",tooltip:"Everything. Multi-state matrix, baselines + delta, all exports, all specialized views (forensic log, schedules, ax-tree, design tokens, etc.)."}];function Ia(){const t=b(n=>n.userMode)??"owner",s=b(n=>n.setUserMode);function a(n){n!==t&&(s(n),chrome.storage.local.set({userMode:n,v2UiEnabled:n==="power"}),Q({type:"SETTINGS_SET",key:"userMode",value:n}))}return e.jsx("div",{className:"inline-flex rounded-md border border-slate-300 bg-white p-0.5 text-[11px] font-medium",role:"tablist","aria-label":"View mode",children:Lr.map(n=>{const r=t===n.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":r,onClick:()=>a(n.id),title:n.tooltip,className:r?"px-2.5 py-1 rounded bg-slate-900 text-white":"px-2.5 py-1 rounded text-slate-600 hover:bg-slate-100",children:n.label},n.id)})})}const Ur=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function _r(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Dr(){var p,c;const t=b(d=>d.view),s=b(d=>d.setView);b(d=>d.setUserMode);const a=b(d=>d.results),n=b(d=>d.status),[r,o]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),i=_r(l),u=a.length>0&&n!=="running";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.jsx(Ia,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{}),e.jsx(Cs,{onClick:()=>void Q({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Cs,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),e.jsx("div",{className:"flex items-baseline 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]})]})}),u&&i&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${i}`,children:i}),e.jsx("button",{type:"button",onClick:()=>void It(),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(Or,{view:t,setView:s}),e.jsx(We,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(wr,{onClose:()=>o(!1)})})]})}function Or({view:t,setView:s}){const a=m.useRef([]),n=b(i=>i.results),r=Ur.filter(i=>!i.hideWhenIdle||n.length>0);function o(i){var c;const u=(i+r.length)%r.length,p=r[u];p&&(s(p.slug),(c=a.current[u])==null||c.focus())}function l(i,u){switch(i.key){case"ArrowRight":i.preventDefault(),o(u+1);break;case"ArrowLeft":i.preventDefault(),o(u-1);break;case"Home":i.preventDefault(),o(0);break;case"End":i.preventDefault(),o(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((i,u)=>{const p=t===i.slug;return e.jsx("button",{ref:c=>{a.current[u]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(i.slug),onKeyDown:c=>l(c,u),className:p?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:i.label},i.slug)})})}function Fr({feature:t,upgradeUrl:s}){const[a,n]=m.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(Ve,{open:a,onClose:()=>n(!1)})]})}const Mr="https://wcagcheckr.com/upgrade";function Pr(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(null),[u,p]=m.useState(Pe),[c,d]=m.useState(Pe[0].id),[h,g]=m.useState("none"),[f,v]=m.useState(null),w=b(U=>U.status),R=b(U=>U.tier),E=b(U=>U.results.length>0),C=w==="running";m.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"matrixPresets"}),se({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,F])=>{const q=Array.isArray(U.data)?U.data:null;p(q&&q.length>0?q:Pe),typeof F.data=="string"&&d(F.data)})},[]);function j(U){const F=u.find(q=>q.id===U);F&&(d(U),Q({type:"SETTINGS_SET",key:"activePresetId",value:U}),Q({type:"SETTINGS_SET",key:"stateMatrix",value:F.matrix}))}const N=je(R,"storybookAutoIterate");m.useEffect(()=>{const U=be("ELEMENT_PICKED_EVENT",(q,T)=>{n(!1);const Y=T.frameId;P(Y),o({selector:q.selector,frameId:Y,speech:q.speech})}),F=be("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),F()}},[]);async function x(){const U=await me();U&&(n(!0),await ve(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function A(){r&&(P(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function I(){if(!N){i("storybook:auto-iterate");return}P(),Ne({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function k(){P(),Ne({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function _(){P(),Ne({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function D(){P(),Ne({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),b.getState().startNewScan()}function W(){P(),Ne({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function Z(){P(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function S(){Q({type:"CANCEL_AUDIT"})}async function P(U){b.getState().setPinned(null);const F=await me();if(F)try{await ve(F,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:F},U)}catch{}}async function L(U){v(null);const F=await me();if(!F){v("No audited tab; open a page first.");return}if(U==="none"){const T=await se({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:F});T.ok||v(T.error??"Failed to clear throttle."),g("none");return}const q=await se({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:F,profile:U});if(!q.ok){v(q.error??"Failed to apply throttle.");return}g(U)}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:C||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)",N?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>j(U.target.value),disabled:C||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:u.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:U=>void L(U.target.value),disabled:C||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${h==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(Vr,{picking:a,picked:r,isRunning:C,onPick:x,onRun:A,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:_,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}),e.jsx("button",{onClick:D,disabled:C||!E,className:"text-xs px-3 py-1 border border-emerald-400 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed",title:E?"Re-runs the audit but skips walkthroughs that already passed or are human-acked. Faster + cheaper after a fix/ack pass.":"Run a full Scan page first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.",children:C?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:W,disabled:C,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:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:Z,disabled:C,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:C?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:k,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:I,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all stories"}),C&&e.jsx("button",{onClick:S,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&E&&e.jsx("button",{type:"button",onClick:()=>void It(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),f&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",f]}),t==="single-element"&&r&&!a&&!C&&e.jsx(Wr,{selector:r.selector,onRepick:x,onClear:()=>o(null)})]}),e.jsx(We,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(Fr,{feature:l??"",upgradeUrl:Mr})})]})}function Gr({speech:t}){if(!t)return null;const s=[];if(t.name&&s.push(t.name),t.role&&!["none","presentation","generic"].includes(t.role)&&s.push(t.role),s.push(...t.states),t.group&&s.push(t.group),s.length===0)return e.jsxs("span",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",title:"A screen reader would announce nothing for this element. Either it has no accessible name + a silent role (generic/presentation), or it's hidden from AT entirely.","data-testid":"sr-speech-preview",children:["SR: ",e.jsx("em",{children:"(silent)"})]});const a=s.join(", ");return e.jsxs("span",{className:"text-[10px] text-slate-700 bg-slate-100 border border-slate-200 rounded px-2 py-0.5 max-w-[280px] truncate",title:`Predicted screen-reader announcement when this element receives focus: "${a}"`,"data-testid":"sr-speech-preview",children:["SR: ",e.jsx("strong",{children:a})]})}function Vr({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:o}){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.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[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(Gr,{speech:s.speech})]}):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 Wr({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 Br={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Hr={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Kr(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),u=b(f=>f.results),p=b(f=>f.tier),c=u.flatMap(f=>f.violations);if(!je(p,"visualizers"))return null;async function d(f){const v=await me();v&&(i(f),f==="off"?await ve(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await ve(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function h(f){const v=await me();if(v){if(t&&await ve(v,{type:Br[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await ve(v,{type:Hr[f],tabId:v}).catch(()=>{}),s(f)}}async function g(){const f=await me();if(f){if(a){await ve(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),o(null);return}if(c.length===0){o("Run an audit first.");return}try{const v=await Te(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:c});n(!0),o(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{o("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(He,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(He,{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:()=>h("tab-order")}),e.jsx(He,{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:()=>h("reading-order")}),e.jsx(He,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>h("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(He,{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:g}),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:f=>void d(f.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 He({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 Ae({feature:t,label:s,children:a}){const n=b(r=>r.tier);return je(n,t)?e.jsx(e.Fragment,{children:a}):e.jsxs("div",{className:"p-6 text-center",children:[e.jsxs("div",{className:"mb-2 text-sm font-semibold text-slate-700",children:[s," isn’t available on your current plan"]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to unlock this feature."})]})}function zr(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 qr(){const t=b(u=>u.status),s=b(u=>u.progress),a=b(u=>u.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,o=n?"reading order · tab order · typography · CSS vars · AI candidates":zr(s.currentState),l=n?100:s.current/s.total*100,i=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(Es,{label:r,detail:o,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"}),i&&e.jsx(Es,{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 Es({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:o,barClass:l,fillClass:i}){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":o,children:e.jsx("div",{className:`h-full transition-all ${i}`,style:{width:`${a}%`}})})]})}function Rs(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function Qr({onView:t,viewingRun:s,crawlOnly:a}){var u,p;const n=b(c=>c.siteCrawlReport),r=b(c=>c.results),o=b(c=>c.siteCrawlStatus)==="running",l=b(c=>c.status)==="running";if(s||o||l)return null;let i=null;if(n)i=`Last crawl · ${Rs(n.startUrl)} · ${n.pagesAudited} page${n.pagesAudited===1?"":"s"} · grade ${n.siteGrade}`;else if(!a&&r.length>0){const c=((u=r[0])==null?void 0:u.pageUrl)??((p=r[0])==null?void 0:p.scope),d=r.reduce((h,g)=>h+g.violations.length,0);i=`Last audit · ${Rs(c)} · ${d} finding${d===1?"":"s"}`}return i?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-brand-50 border-b border-brand-200 text-[11px] text-brand-900",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{className:"flex-1 min-w-0 truncate",title:i,children:i}),e.jsx("button",{type:"button",onClick:t,className:"shrink-0 px-2 py-0.5 rounded bg-brand-600 text-white hover:bg-brand-700 font-medium",children:"View"})]}):null}function Yr(){const t=new Set;for(const s of Me)for(const a of s.axeRules)t.add(a);return t}function Ea(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||r.add(`${o.ruleId}::${o.target.selector}`);for(const o of s)o.verdict==="fail"&&r.add(`${o.ruleId}::${o.selector}`);return r.size}function Jr(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||o.wcagCriterion&&r.add(o.wcagCriterion);for(const o of s)o.verdict==="fail"&&o.wcagCriterion&&r.add(o.wcagCriterion);return Array.from(r).sort()}function Xr(t,s,a={}){const n=Yr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=ua(o),i={critical:0,serious:0,moderate:0,minor:0};for(const c of l)i[c.impact]++;const u=new Set(l.map(c=>De(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const d=De(c.ruleId,c.selector);u.has(d)||(u.add(d),i.serious++)}return{total:i.critical+i.serious+i.moderate+i.minor,counts:i,representatives:l}}function Ts(t,s){var n;const a=new Set;for(const r of s)for(const o of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const l of o.elements??[])a.add(`${o.ruleId}::${l.selector}`);return t.map(gn).map(fn).filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function cs(t){var o,l;const s=((o=t[0])==null?void 0:o.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=b(i=>i.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const i=b.getState().resolutionsByUrl[s];return i?Ts(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return Xe(s).then(u=>{i||(a(s,u),r(Ts(u,t)))}),()=>{i=!0}},[s,t,a]),n}const Zr=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function ei(){const t=b(n=>n.results),s=b(n=>n.status),a=b(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(ti,{results:t,status:s,setView:a}),e.jsx(si,{setView:a})]})}function ti({results:t,status:s,setView:a}){var g,f;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(v=>v.violations),r=ua(n),o=((g=t[0])==null?void 0:g.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",l=t.length,i=cs(t),u=b(v=>v.acknowledgedKeys),p=b(v=>v.dismissedKeys),c=Ea(n,i,u,p),d=3,h=c>0&&c<=d?r.slice(0,d):[];return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",l," state",l===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:o,children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]}),h.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:h.map(v=>{var E;const w=((E=v.target)==null?void 0:E.selector)??"(no selector)",R=w.length>50?w.slice(0,47)+"…":w;return e.jsx("li",{className:"px-3.5 py-2",children:e.jsxs("button",{type:"button",onClick:()=>a("report"),className:"w-full text-left flex items-center gap-2 hover:bg-slate-50 -mx-3.5 -my-2 px-3.5 py-2 transition-colors",title:`${v.description??v.ruleId} — ${w}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${v.impact==="critical"?"bg-rose-200 text-rose-900":v.impact==="serious"?"bg-orange-200 text-orange-900":v.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:v.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:v.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:R})]})},`${v.ruleId}::${w}`)})})]})}function si({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Zr.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const it="aiConfig";function ds(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(it).then(r=>a(r[it])).catch(()=>s(!1));const n=(r,o)=>{var l;o!=="local"||!(it in r)||a((l=r[it])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const ai={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},ni={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 ri({violations:t,componentId:s,hideOverallHeader:a=!1}){var ae,$,B,H,le,ge,de,ie;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,u]=m.useState([]),[p,c]=m.useState([]),[d,h]=m.useState(new Set),[g,f]=m.useState(null),[v,w]=m.useState({}),[R,E]=m.useState(new Set),[C,j]=m.useState(null),N=b(G=>G.status),x=b(G=>G.progress),A=b(G=>G.freshThisSession),I=b(G=>G.results),k=(ae=I[0])==null?void 0:ae.startedAt,_=(($=I[0])==null?void 0:$.pageUrl)??((B=I[0])==null?void 0:B.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let G=!1;return chrome.storage.local.get("igtRuns").then(te=>{if(G)return;const oe=((te==null?void 0:te.igtRuns)??{})[s]??{};r(Object.values(oe))}),Promise.all([Re(s),Oe([s])]).then(([te,xe])=>{if(G)return;const oe=new Set(xe.map(ee=>ee.criterionId)),X={},ye=[];for(const ee of te){const ce=oe.has(ee.criterionId)?"pass":ee.verdict;ee.criterionId==="2.4.3"?X.focusOrder=ce:ee.criterionId==="2.1.2"?X.keyboardTrap=ce:ee.criterionId==="2.4.7"?X.focusVisible=ce:ee.criterionId==="1.3.2"?X.readingOrder=ce:ee.criterionId==="1.4.11"&&(X.nonTextContrast=ce),ye.push({criterionId:ee.criterionId,ruleId:`ai-walkthrough-${ee.criterionId}`,pageUrl:ee.pageUrl,verdict:ce,reasoning:oe.has(ee.criterionId)?`Human verified: ${ee.reasoning}`:ee.reasoning})}l(X),u(ye)}),()=>{G=!0}},[s]),m.useEffect(()=>{if(!_){c([]);return}let G=!1;return Xe(_).then(te=>{G||c(te)}),()=>{G=!0}},[_,I]);const D=cs(I);if(N==="running")return e.jsx(pi,{current:x==null?void 0:x.current,total:x==null?void 0:x.total});const W=Zt({violations:t,auditRan:I.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((le=(H=I[0])==null?void 0:H.tabOrderIssues)==null?void 0:le.length)??0,readingOrder:((de=(ge=I[0])==null?void 0:ge.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:D.map(G=>({ruleId:G.ruleId,impact:"serious",selector:G.selector}))}),Z=b(G=>G.acknowledgedKeys),P=new Set(I.map(G=>G.pageUrl??G.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",L=I.length>0?pa(I,{runs:n,workflows:fe},"2.1","AA",Z,p,i,P):void 0,U=I.length>0?Jn(ts({audits:I,igtRuns:n,workflows:fe,acknowledgedMatchKeys:Z,incompleteResolutions:p,interactiveAuditResults:i,auditScope:P}),fe):void 0,F=W.overallLetter,T=(L?L.failingCriteria.length+L.inconclusiveCriteria.length+L.untestedCriteria.length:0)===0&&!!L;async function Y(G){var ye;if(!_||!((ye=L==null?void 0:L.inconclusiveReasons)!=null&&ye[G]))return;const xe=L.inconclusiveReasons[G].filter(ee=>ee.source==="axe-incomplete"&&ee.elements&&ee.elements.length>0);if(xe.length===0)return;h(ee=>new Set(ee).add(G)),f(null);const oe=[];let X=0;try{for(const ce of xe){const Se=await Q({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ce.ruleOrStepId,pageUrl:ce.pageUrl??_,wcagCriterion:G,elements:ce.elements??[],targetLevel:"AA"});if(Se!=null&&Se.unavailableReason){f(Se.unavailableReason);break}Se!=null&&Se.resolutions&&(oe.push(...Se.resolutions),X+=Se.totalCostUsd??0)}if(_){const ce=await Xe(_);c(ce)}const ee={total:oe.length,pass:oe.filter(ce=>ce.verdict==="pass").length,fail:oe.filter(ce=>ce.verdict==="fail").length,uncertain:oe.filter(ce=>ce.verdict==="uncertain").length,costUsd:X,resolutions:oe};w(ce=>({...ce,[G]:ee}))}finally{h(ee=>{const ce=new Set(ee);return ce.delete(G),ce})}}function J(G){E(te=>{const xe=new Set(te);return xe.has(G)?xe.delete(G):xe.add(G),xe})}const K=((ie=I[0])==null?void 0:ie.startedAt)??null,re=s&&K?`${s}::${K}`:null;m.useEffect(()=>{if(!re||!L||C===re||N!=="complete")return;const G=L.inconclusiveCriteria.filter(te=>{var oe;return(((oe=L.inconclusiveReasons)==null?void 0:oe[te])??[]).some(X=>X.source==="axe-incomplete"&&X.elements&&X.elements.length>0)});if(G.length===0){j(re);return}j(re),(async()=>{for(const te of G)try{await Y(te)}catch{}})()},[re,L,N]);async function pe(G){var Se,fs;if(!_)return;const te=((Se=L==null?void 0:L.inconclusiveReasons)==null?void 0:Se[G])??[],xe=((fs=L==null?void 0:L.failingReasons)==null?void 0:fs[G])??[],oe=[],X=new Set;for(const ue of te){if(ue.source!=="axe-incomplete"||!ue.elements)continue;const Ie=ue.pageUrl??_;for(const Ee of ue.elements){const Be=`${Ie}::${ue.ruleOrStepId}::${Ee.selector}`;X.has(Be)||(X.add(Be),oe.push({ruleId:ue.ruleOrStepId,pageUrl:Ie,selector:Ee.selector}))}}for(const ue of xe){if(ue.source!=="ai"||!ue.selector)continue;const Ie=ue.ruleOrStepId.startsWith("ai-resolved::")?ue.ruleOrStepId.slice(13):ue.ruleOrStepId,Ee=ue.pageUrl??_,Be=`${Ee}::${Ie}::${ue.selector}`;X.has(Be)||(X.add(Be),oe.push({ruleId:Ie,pageUrl:Ee,selector:ue.selector}))}if(oe.length===0)return;const ye=new Date().toISOString(),ee=[];for(const ue of oe){const Ie=p.find(Ee=>Ee.pageUrl===ue.pageUrl&&Ee.ruleId===ue.ruleId&&Ee.selector===ue.selector);Ie&&Ie.verdict==="pass"&&Ie.reasoning.startsWith("Marked as visually verified")||ee.push({pageUrl:ue.pageUrl,ruleId:ue.ruleId,selector:ue.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${ye.slice(0,10)}.`,resolvedAt:ye,costUsd:0,wcagCriterion:G})}if(ee.length===0)return;await bn(ee);const ce=await Xe(_);c(ce),w(ue=>({...ue,[G]:{total:ee.length,pass:ee.length,fail:0,uncertain:0,costUsd:0,resolutions:ee}}))}const y=(()=>{if(!L)return null;if(T)return{kind:"conformant",text:`WCAG ${L.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const G=L.inconclusiveCriteria.length,te=L.failingCriteria.length,xe=L.untestedCriteria.length,oe=[];if(te>0){const ye=L.failingCriteria.slice(0,4).join(", ")+(te>4?`, +${te-4}`:"");oe.push(`${te} ${te===1?"criterion":"criteria"} failing (${ye})`)}if(G>0){const ye=L.inconclusiveCriteria.slice(0,4).join(", ")+(G>4?`, +${G-4}`:"");oe.push(`${G} inconclusive (${ye})`)}if(xe>0){const ye=L.untestedCriteria.slice(0,4).join(", ")+(xe>4?`, +${xe-4}`:"");oe.push(`${xe} untested (${ye})`)}const X=te>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":xe>0?"Mark untested via Guided Tests, OR confirm the tool gap (no axe rule + no AI walkthrough + no IGT step).":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return{kind:"not-conformant",text:`WCAG ${L.targetLevel} Status: Not conformant`,detail:`${oe.join(" · ")}. ${X}`}})();let O=0;for(const G of fe){const te=n.find(oe=>oe.workflowId===G.id);if(!te)continue;G.steps.every(oe=>{const X=te.steps[oe.id];return(X==null?void 0:X.status)==="pass"||(X==null?void 0:X.status)==="fail"||(X==null?void 0:X.status)==="skip"||(X==null?void 0:X.status)==="not-applicable"})&&O++}const z=new Set;for(const G of t)Z.has(G.matchKey)||z.add(`${G.ruleId}::${G.target.selector}`);for(const G of D)G.verdict==="fail"&&z.add(`${G.ruleId}::${G.selector}`);const V=z.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!A&&k&&e.jsx(hi,{scannedAt:k}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ai[F]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:F})}),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 ",W.subGrades.length," verification areas below. Untested areas count as F until verified."]}),y&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${y.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[y.kind==="conformant"?"✓ ":"✗ ",y.text]}),e.jsx("p",{className:"mt-0.5",children:y.detail})]})]})]}),a&&y&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${y.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[y.kind==="conformant"?"✓ ":"✗ ",y.text]}),e.jsx("p",{className:"mt-0.5",children:y.detail})]}),W.isLawsuitRisk&&e.jsx(li,{areas:W.warningAreas}),e.jsx(ci,{grades:W.subGrades,uncategorized:Xr(t,p,{excludeAckedMatchKeys:Z})}),L&&e.jsx(ii,{coverage:L,onResolveWithAi:Y,onMarkVisuallyVerified:pe,resolving:d,resolveError:g,lastResolveResult:v,expandedResultFor:R,onToggleResultDetail:J,violations:t}),U&&e.jsx(oi,{layers:U}),e.jsx(ui,{violationsRemaining:V,manualCompleted:O,manualTotal:fe.length}),O>0||I.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:O})," of ",e.jsx("strong",{children:fe.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:`${O/fe.length*100}%`}})})]}):null]})}function ii({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:u}){const p=b(C=>C.setView),c=b(C=>C.setFindingsLens),d=b(C=>C.setPendingAreaExpand);function h(C){const j=vn(C,u);p("report"),j?(c("per-area"),d(j)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,v]=m.useState(g>0&&g<=3),w=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),R=t.canClaimConformance,E=[];return t.failingCriteria.length>0&&E.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&E.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&E.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${R?"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 ${R?"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 (",w,"%)"]}),R&&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)."]}),!R&&(()=>{const C=[];t.failingCriteria.length>0&&C.push("failing"),t.inconclusiveCriteria.length>0&&C.push("inconclusive"),t.untestedCriteria.length>0&&C.push("untested");const j=C.length===0?"unresolved":C.length===1?C[0]:C.length===2?`${C[0]} or ${C[1]}`:`${C.slice(0,-1).join(", ")}, or ${C[C.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!R&&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."]}),!R&&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."]})]}),!R&&E.length>0&&e.jsx("button",{type:"button",onClick:()=>v(C=>!C),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!R&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[E.map(C=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${C.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[C.kind==="untested"?"Untested":C.kind==="inconclusive"?"Inconclusive":"Failing"," (",C.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:C.ids.map(j=>{var W,Z;const N=C.kind==="inconclusive"?(W=t.inconclusiveReasons)==null?void 0:W[j]:void 0,x=C.kind==="failing"?(Z=t.failingReasons)==null?void 0:Z[j]:void 0,A=N==null?void 0:N.some(S=>S.source==="axe-incomplete"&&S.elements&&S.elements.length>0),I=x==null?void 0:x.some(S=>S.source==="ai"),k=(n==null?void 0:n.has(j))??!1,_=o==null?void 0:o[j],D=(l==null?void 0:l.has(j))??!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("button",{type:"button",onClick:()=>h(j),className:"font-mono text-[11px] text-left underline-offset-2 hover:underline text-brand-700 hover:text-brand-800 cursor-pointer",title:`Jump to the verification area covering ${j}`,children:["· ",j]}),(C.kind==="inconclusive"&&A||C.kind==="failing"&&I)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C.kind==="inconclusive"&&s&&j!=="1.4.3"&&j!=="1.4.6"&&e.jsx("button",{type:"button",disabled:k,onClick:()=>s(j),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:k?"Resolving…":_?"✨ Resolve again →":"✨ Resolve with AI →"}),C.kind==="inconclusive"&&(j==="1.4.3"||j==="1.4.6")&&e.jsx("span",{className:"text-[10px] text-slate-500 italic",title:"The pixel-contrast sampler runs automatically and produces the authoritative verdict for color-contrast. Mark visually verified if the AI was wrong about a specific element.",children:"Pixel sampler ran automatically — use Mark visually verified if needed"}),a&&e.jsx("button",{type:"button",disabled:k,onClick:()=>a(j),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:C.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"})]})]}),_&&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 ",_.total," ",_.total===1?"verdict":"verdicts",":",_.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",_.pass," pass"]}),_.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",_.fail," fail"]}),_.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",_.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",_.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(j),className:"ml-auto text-[10px] underline text-brand-700",children:D?"hide reasoning":"show reasoning"})]}),_.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",_.uncertain," ",_.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),_.pass===_.total&&_.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."]}),D&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:_.resolutions.map((S,P)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:S.verdict==="pass"?"text-emerald-700 font-semibold":S.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:S.verdict==="pass"?"✓":S.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:S.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:S.reasoning})]},P))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((S,P)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[S.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),S.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:S.selector}),S.notes&&e.jsx("span",{className:"text-rose-700",children:S.notes})]},P))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((S,P)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[S.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," skipped — "]}),S.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.resolutionHint,S.elements&&S.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",S.elements.length===1?"element":`${S.elements.length} elements`,":"," ",S.elements.slice(0,3).map((L,U,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),U<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},U)),S.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",S.elements.length-3," more"]})]})]},P))}):C.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.)"})]},j)})})]},C.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 $s={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 oi({layers:t}){const s=b(o=>o.setView),a=b(o=>o.setFindingsLens);function n(){s("report"),a("violations")}const r=["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:r.map(o=>{const l=t[o],i=l.coveredCriteria.length,u=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,d=l.cleared,h=u>0||p>0,g=i>0&&!h&&c===0,f=g?"text-emerald-700":u>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 ${g?"bg-emerald-500 text-white":u>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:g?"✓":u>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:$s[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:i===0?"no coverage yet":`${d}/${i}`}),u>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-rose-700 hover:underline cursor-pointer",title:`Confirmed fails (action: fix the underlying issue + re-audit, OR mark visually verified): ${l.failing.join(", ")}`,children:["· ",u," failing"]}),p>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-amber-700 hover:underline cursor-pointer",title:`Inconclusive — this layer couldn't determine (action: try "Resolve with AI" below, OR mark via Guided Tests): ${l.inconclusive.join(", ")}`,children:["· ",p," inconclusive"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:$s[o].hint}),o==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},o)})})]})}function li({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 ci({grades:t,uncategorized:s}){const a=b(i=>i.setView),n=b(i=>i.setFindingsLens),r=b(i=>i.setPendingAreaExpand);function o(i){a("report"),n("per-area"),r(i)}function l(i){const u=i.counts;return u.critical+u.serious+u.moderate+u.minor>0}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.jsxs("ul",{className:"grid grid-cols-1 gap-1.5",children:[t.map(i=>{const u=l(i),p="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=u?"cursor-pointer hover:bg-slate-100":"cursor-default",d=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${ni[i.letter]}`,"aria-label":`Grade ${i.letter}`,children:i.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:i.label}),e.jsx(di,{grade:i,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:u?e.jsx("button",{type:"button",onClick:()=>o(i.id),className:`${p} ${c}`,"aria-label":`Open ${i.label} violations`,children:d}):e.jsx("div",{className:p,children:d})},i.id)}),s&&s.total>0&&e.jsxs("li",{className:"flex items-center gap-2 text-[11px] mt-1 pt-1.5 border-t border-dashed border-slate-200",title:`These findings come from rules not mapped to any of the ${t.length} verification areas above. Listing them here so the headline count and the area cards agree. Rules: ${s.representatives.map(i=>i.ruleId).join(", ")}`,children:[e.jsx("span",{className:"w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold bg-slate-300 text-slate-700","aria-label":"Other findings",children:"?"}),e.jsxs("span",{className:"font-medium text-slate-700 flex-1 min-w-0",children:["Other findings",e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal italic",children:"rules not mapped to a category"})]}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:(()=>{const i=[];return s.counts.critical>0&&i.push(`${s.counts.critical} critical`),s.counts.serious>0&&i.push(`${s.counts.serious} serious`),s.counts.moderate>0&&i.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&i.push(`${s.counts.minor} minor`),i.join(" · ")})()})]})]})]})}function di({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const u=fe.find(p=>p.id===i);return(u==null?void 0:u.name)??i};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 i=t.verifiedAt?Ra(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",i?` ${i} ago`:""]})}const{critical:n,serious:r,moderate:o,minor:l}=t.counts;if(n>0||r>0||o>0||l>0){const i=[];return n>0&&i.push({label:"critical",n,cls:"text-rose-700"}),r>0&&i.push({label:"serious",n:r,cls:"text-orange-700"}),o>0&&i.push({label:"moderate",n:o,cls:"text-amber-700"}),l>0&&i.push({label:"minor",n:l,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:i.map((u,p)=>e.jsxs("span",{children:[p>0&&" · ",e.jsxs("span",{className:u.cls,children:[u.n," ",u.label]})]},u.label))})}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)," →"]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function ui({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.setView),r=b(l=>l.setFindingsLens),o=[{status:t===0?"done":"next",label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:t>0?()=>{n("report"),r("violations")}:void 0,tooltip:t>0?"Open the Violations list — each finding card has inline Acknowledge / Not a real issue / Locate / Fix recipe affordances.":void 0},{status:"optional",label:a>0?`Optional: spot-check via Guided Tests (${s}/${a} done — AI walkthroughs cover most)`:"Optional: spot-check via Guided Tests (AI walkthroughs cover most)",action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The 5 AI walkthroughs auto-run after every audit and verdict the criteria that previously required manual keyboard / vision checks. Run these workflows only for belt-and-suspenders confidence on a formal conformance claim."},{status:t===0?"next":"pending",label:"Export AI fix prompt → sign-and-seal in Compliance",action:()=>n("delta"),tooltip:'Switches to the Delta lens. Export menu → "AI fix prompt" produces markdown for ChatGPT / Claude / Copilot with code-level fix recipes for every automated finding, including false-positive guidance. Then jump to the Compliance tile from Dashboard to sign-and-seal the audit for a chain-of-custody record.'}];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:o.map((l,i)=>{const u=l.status==="done"?"text-emerald-700":l.status==="next"?"text-brand-600 font-semibold":l.status==="optional"?"text-slate-500":"text-slate-400";return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:`font-mono shrink-0 ${u}`,"aria-hidden":"true",children:[i+1,"."]}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:l.status==="next"?"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:l.status==="done"?"text-slate-500 line-through leading-snug":l.status==="next"?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label}),l.status==="done"&&e.jsx("span",{className:"text-emerald-700 shrink-0 font-mono","aria-label":"step complete",children:"✓"})]},i)})})]})}function pi({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 hi({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 (",Ra(s)," old). Re-scan to grade the current page state."]})]})}function Ra(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 Ta(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Ls(t){if(!Ta())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-Y9f60-qy.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-KD5f4utB.js","assets/diff-RnwNJg4F.js","assets/ai-usage-log-CYyG5MT2.js","assets/copy-ai-fixer-prompt-D1dxQZUr.js","assets/site-report-renderer-Fg6z2lun.js"])))=>i.map(i=>d[i]);
2
+ var pn=Object.defineProperty;var hn=(t,s,a)=>s in t?pn(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var bs=(t,s,a)=>hn(t,typeof s!="symbol"?s+"":s,a);import{R as Je,k as he,r as m,j as e,M as We,C as Ve,A as vs}from"./styles-UtsXCSpR.js";import{n as Xt,o as mn,p as xn,q as ys,t as da,u as me,v as ua,w as De,S as Me,g as Xe,b as gn,c as fn,x as Re,y as Oe,z as Zt,A as pa,B as bn,C as vn,D as yn,E as wn,j as jn,F as Nn,f as kn,h as es,G as Sn,H as An,N as Cn,I as Vt,J as ha,K as Wt,L as In,e as et,l as En,O as Rn,M as vt,P as Tn,Q as $n,R as ws,T as Ln,U as Un,V as _n,W as Dn,X as On,Y as Fn,Z as Mn,_ as Pn,$ as Gn,a0 as ma,a1 as Vn,a2 as js,a3 as Ns,a4 as Lt,a5 as Wn,a6 as ks,a7 as Bn,a8 as Hn,a9 as Kn,k as zn,m as qn}from"./scheduled-audit-runner-Y9f60-qy.js";import{o as be,a as se,f as je,s as Q,c as xa,h as ve,r as Te,j as ga,T as Qn}from"./crash-reporter-KD5f4utB.js";import{_ as ke}from"./preload-helper-D7HrI6pR.js";import{g as fa,f as At,t as rt,r as Yn,B as Pe,h as Jn,i as ts,j as fe,e as ss,k as Xn,o as _e,m as ba,n as Ct,p as Zn,q as er,u as tr,v as sr,T as ar,w as nr}from"./ai-usage-log-CYyG5MT2.js";import{g as va,a as ya}from"./diff-RnwNJg4F.js";import{s as rr,t as ir}from"./design-system-audit-DpxJrxnb.js";const Ss=t=>{let s;const a=new Set,n=(p,c)=>{const d=typeof p=="function"?p(s):p;if(!Object.is(d,s)){const h=s;s=c??(typeof d!="object"||d===null)?d:Object.assign({},s,d),a.forEach(g=>g(s,h))}},r=()=>s,i={setState:n,getState:r,getInitialState:()=>u,subscribe:p=>(a.add(p),()=>a.delete(p))},u=s=t(n,r,i);return i},or=t=>t?Ss(t):Ss,lr=t=>t;function cr(t,s=lr){const a=Je.useSyncExternalStore(t.subscribe,Je.useCallback(()=>s(t.getState()),[t,s]),Je.useCallback(()=>s(t.getInitialState()),[t,s]));return Je.useDebugValue(a),a}const As=t=>{const s=or(t),a=n=>cr(s,n);return Object.assign(a,s),a},dr=t=>t?As(t):As,b=dr(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"free",seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",findingsLens:"overview",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null,crawlNavContext:null,resolutionsByUrl:{},pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,pendingAreaExpand:null,auditStartedAtMs:null,lastAuditWallClockMs:null,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,auditStartedAtMs:Date.now(),crawlNavContext:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t(r=>{const o=r.auditStartedAtMs?Date.now()-r.auditStartedAtMs:null;return{results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0,lastAuditWallClockMs:o,auditStartedAtMs:null}}),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,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}),setFindingsLens:s=>t({findingsLens:s}),setPendingAreaExpand:s=>t({pendingAreaExpand:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setCrawlNavContext:s=>t({crawlNavContext:s}),setResolutionsForUrl:(s,a)=>t(n=>({resolutionsByUrl:{...n.resolutionsByUrl,[s]:a}})),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Xt(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setCrawlDiscoveryStatus:s=>t({crawlDiscoveryStatus:s}),setCrawlDiscoveryProgress:(s,a)=>t({crawlDiscoveryFound:s,crawlDiscoveryLastUrl:a}),setCrawlDiscoveryUrls:s=>t({crawlDiscoveryUrls:s}),resetCrawlDiscovery:()=>t({crawlDiscoveryStatus:"idle",crawlDiscoveryUrls:[],crawlDiscoveryFound:0,crawlDiscoveryLastUrl:null}),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}}),dismissedKeys:new Set,setDismissedKeys:s=>t({dismissedKeys:s}),markDismissed:s=>t(a=>({dismissedKeys:new Set(a.dismissedKeys).add(s)})),markUndismissed:s=>t(a=>{const n=new Set(a.dismissedKeys);return n.delete(s),{dismissedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(i=>i.id!==s?i:a==="seen"?{...i,seen:!0}:a==="dismissed"?{...i,dismissed:!0}:a==="acknowledged"?{...i,acknowledged:!0}:a==="clicked"?{...i,clicked:!0}:i).filter(i=>i.severity==="critical"?!i.acknowledged:!i.dismissed),o=r.filter(i=>!i.seen).length,l=r.some(i=>i.severity==="critical"&&!i.acknowledged);return{messages:r,unreadMessageCount:o,criticalUnacked:l}})})),yt="sidePanel:lastAudit";function ur(){const t=[];return t.push(be("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState(),n=a.status==="running",r=a.siteCrawlStatus==="running";a.setProgress({current:s.current,total:s.total,currentState:s.currentState}),r||(a.setStatus("running"),n||he.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`))})),t.push(be("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((u,p)=>u+p.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"}.`;he.polite(r);const o=b.getState().view;["compliance","guided","crawl"].includes(o)||(b.getState().setView("report"),b.getState().setFindingsLens("overview")),hr({results:s.results,delta:s.delta,componentId:s.componentId}),pr(s.results,s.delta,s.componentId)})),t.push(be("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(be("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||he.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(be("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(be("SCORECARD_UPDATED_EVENT",()=>{wt()})),t.push(be("LICENSE_CHANGED_EVENT",()=>{wa()})),t.push(be("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&&he.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(be("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),he.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`),(async()=>{try{const{loadSiteCrawlPerUrlResults:n}=await ke(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(u=>u.aJ);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await ke(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(u=>u.aL);return{getResolutionsForPage:i}},__vite__mapDeps([0,1,2,3,4])),o=await n();if(!o||o.length===0)return;const l=b.getState().setResolutionsForUrl;await Promise.all(o.map(async i=>{try{const u=await r(i.url);l(i.url,u)}catch{}}))}catch(n){console.warn("[site-crawl] failed to pre-warm resolutions cache",n)}})()})),t.push(be("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),he.assertive(`Site crawl failed: ${s.error.message}`)})),t.push(be("CRAWL_DISCOVERY_PROGRESS_EVENT",s=>{const a=b.getState();a.crawlDiscoveryStatus!=="discovering"&&a.setCrawlDiscoveryStatus("discovering"),a.setCrawlDiscoveryProgress(s.found,s.url),s.found===1&&he.polite("Discovering pages to review.")})),t.push(be("CRAWL_DISCOVERY_COMPLETE_EVENT",s=>{const a=b.getState();a.setCrawlDiscoveryUrls(s.urls),a.setCrawlDiscoveryStatus("reviewing"),he.polite(`Discovery complete. ${s.urls.length} page${s.urls.length===1?"":"s"} found — review and choose which to audit.`)})),t.push(be("CRAWL_DISCOVERY_FAILED_EVENT",s=>{const a=b.getState();a.resetCrawlDiscovery(),a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),he.assertive(`Page discovery failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function pr(t,s,a){var n,r;if(t.length!==0)try{const o=await fa();if(!o.enabled)return;const l=b.getState().tier;if(da(l)||!je(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",u=[],p=b.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const d=await se({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:p});if(typeof d.content!="string"||d.content.length<200)continue;const h=At(c,a??null);rt(d.content,h),i&&await Yn({url:i,exportedAt:new Date().toISOString(),format:c,filename:h}),u.push(h)}catch(d){console.warn(`[auto-export] format ${c} failed:`,d)}u.length>0&&he.polite(`Audit auto-exported ${u.length} file${u.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function hr(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[yt]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function mr(){const s=(await chrome.storage.local.get(yt))[yt];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function xr(){await chrome.storage.local.remove(yt)}async function It(){const t=b.getState();t.clearResults(),t.setSiteCrawlReport(null),t.setSiteCrawlError(null),t.setSiteCrawlStatus("idle"),await xr();const{saveSiteCrawlReport:s}=await ke(async()=>{const{saveSiteCrawlReport:n}=await import("./scheduled-audit-runner-Y9f60-qy.js").then(r=>r.aJ);return{saveSiteCrawlReport:n}},__vite__mapDeps([0,1,2,3,4]));await s(null);const{clearAllCachedAudits:a}=await ke(async()=>{const{clearAllCachedAudits:n}=await import("./ai-usage-log-CYyG5MT2.js").then(r=>r.Q);return{clearAllCachedAudits:n}},__vite__mapDeps([4,2]));await a()}async function wt(){const t=await se({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function wa(t){const s=await se({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ja()}async function ja(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ar);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 gr(){async function t(){const s=await mn();if(!s||xn(s)==="expired"){ys(null);return}ys(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function fr(){const s=(await se({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;b.getState().setUserMode(a)}function br(){return chrome.runtime.connect({name:"audit-keepalive"})}let jt=null;async function vr(){if(jt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(jt=t.id)}catch{}}function as(){if(jt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:jt}).catch(()=>{})}function Ne(t){as(),b.getState().setSiteCrawlReport(null),Xt(null).catch(()=>{}),Q(t)}function yr(t){as(),b.getState().setSiteCrawlReport(null),Xt(null).catch(()=>{}),Q(t)}const Bt="dismissedFindings";function Et(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function tt(t){return`reading-order::${t}`}function st(t){return`tab-order::${t}`}function ns(t){return`violation::${t}`}async function Rt(){try{const t=await chrome.storage.local.get(Bt),s=t==null?void 0:t[Bt];if(s&&typeof s=="object")return s}catch{}return{}}async function rs(t){await chrome.storage.local.set({[Bt]:t})}async function is(t){return(await Rt())[Et(t)]??{}}async function os(t,s,a,n){const r=await Rt(),o=Et(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await rs(r)}async function at(t,s){if(s.length===0)return;const a=await Rt(),n=Et(t),r=a[n]??{},o=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:o,snippet:l.snippet};a[n]=r,await rs(a)}async function ls(t,s){const a=await Rt(),n=Et(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await rs(a))}const pd=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:os,addDismissals:at,dismissalKeyForReadingOrder:tt,dismissalKeyForTabOrder:st,dismissalKeyForViolation:ns,getDismissalsForUrl:is,removeDismissal:ls},Symbol.toStringTag,{value:"Module"}));function wr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[o,l]=m.useState(!0),[i,u]=m.useState(""),[p,c]=m.useState(!1),[d,h]=m.useState(null);async function g(f){var v;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const w=await se({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});w.success?(h({ok:!0,msg:`Sent (ref: ${w.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((v=w.error)==null?void 0:v.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:g,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:f=>a(f.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:f=>r(f.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:i,onChange:f=>u(f.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:o,onChange:f=>l(f.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)."})]}),d&&e.jsx("p",{id:"support-form-result",role:d.ok?"status":"alert",className:`text-xs ${d.ok?"text-green-700":"text-red-700"}`,children:d.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 Cs({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 Nt=xa("messages-client"),jr="https://api.wcagcheckr.com",Na="wcagcheckr",Nr=1e4;function kr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ka(t,s){const a=await va();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":kr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${jr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Nr)})}async function Sr(t){if(!await va())return null;try{const s=await ka(`/v1/products/${Na}/messages`,{userMode:t??null});return s.ok?await s.json():(Nt.warn("fetchMessages http",s.status),null)}catch(s){return Nt.warn("fetchMessages failed",s),null}}async function Ge(t,s){try{const a=await ka(`/v1/products/${Na}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Nt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Nt.warn("ackMessage failed",a),!1}}const Ar=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Ge,fetchMessages:Sr},Symbol.toStringTag,{value:"Module"})),Cr=["http:","https:"];function Ir(t){try{const s=new URL(t);return Cr.includes(s.protocol)}catch{return!1}}function Is(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const o=t.indexOf("]",a+1);if(o!==-1&&t[o+1]==="("){const l=t.indexOf(")",o+2);if(l!==-1){const i=t.slice(a+1,o),u=t.slice(o+2,l);Ir(u)?s.push(e.jsx("a",{href:u,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:i},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:i},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const o=t.indexOf("**",a+2);if(o!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,o)},`b-${n++}`)),a=o+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const o=t.indexOf("*",a+1);if(o!==-1&&t[o+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,o)},`i-${n++}`)),a=o+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Sa({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],o=0;function l(){if(r.length===0)return;const u=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Is(u)},`p-${o++}`)),r=[]}function i(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((u,p)=>e.jsx("li",{children:Is(u)},p))},`u-${o++}`)),n=[])}for(const u of s){const p=u.trimEnd();if(p===""){l(),i();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){l(),n.push(c[1]);continue}i(),r.push(p)}return l(),i(),e.jsx("div",{className:"space-y-1.5",children:a})}const Er={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Rr={critical:"bg-rose-50 border-rose-200"};function Aa(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),o=m.useRef(-1),[l,i]=m.useState(!1);m.useEffect(()=>{const h=s.filter(f=>!f.seen);if(h.length===0)return;const g=Math.max(...h.map(f=>f.id));if(g>o.current){o.current=g,i(!0);const f=setTimeout(()=>i(!1),1500);return()=>clearTimeout(f)}},[s]);async function u(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Ge(g.id,"seen")}function p(){const h=!n;r(h),h&&u()}async function c(h){a(h.id,"dismissed"),await Ge(h.id,"dismissed")}async function d(h){h.ctaUrl&&(a(h.id,"clicked"),Ge(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Tr,{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($r,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:d})]})}function Tr({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 $r({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const o=i=>{r.current&&(r.current.contains(i.target)||s())},l=i=>{i.key==="Escape"&&s()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",o),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:()=>{ja()},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(o=>e.jsx("li",{className:`p-3 ${o.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Er[o.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:o.title}),o.dismissible&&o.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(o),"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(Sa,{source:o.bodyMd})}),o.ctaLabel&&o.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(o),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:o.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(o.createdAt).toLocaleString()})]})]})},o.id))})]})}function Ca(){const t=b(o=>o.messages),s=b(o=>o.applyMessageAck),a=t.find(o=>o.severity==="critical"&&!o.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 ${Rr.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(Sa,{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 Lr=[{id:"owner",label:"Owner",tooltip:"Site owners. Focuses on the specific issues demand-letter mills flag, with plain-language fix recipes per issue. Goal: get off the lawsuit-bot radar."},{id:"power",label:"Power user",tooltip:"Compliance verdict + full audit findings without the granular surfaces. Streamlined for people who want the answer, not the deep dive."},{id:"dev",label:"Dev",tooltip:"Everything. Multi-state matrix, baselines + delta, all exports, all specialized views (forensic log, schedules, ax-tree, design tokens, etc.)."}];function Ia(){const t=b(n=>n.userMode)??"owner",s=b(n=>n.setUserMode);function a(n){n!==t&&(s(n),chrome.storage.local.set({userMode:n,v2UiEnabled:n==="power"}),Q({type:"SETTINGS_SET",key:"userMode",value:n}))}return e.jsx("div",{className:"inline-flex rounded-md border border-slate-300 bg-white p-0.5 text-[11px] font-medium",role:"tablist","aria-label":"View mode",children:Lr.map(n=>{const r=t===n.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":r,onClick:()=>a(n.id),title:n.tooltip,className:r?"px-2.5 py-1 rounded bg-slate-900 text-white":"px-2.5 py-1 rounded text-slate-600 hover:bg-slate-100",children:n.label},n.id)})})}const Ur=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function _r(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Dr(){var p,c;const t=b(d=>d.view),s=b(d=>d.setView);b(d=>d.setUserMode);const a=b(d=>d.results),n=b(d=>d.status),[r,o]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),i=_r(l),u=a.length>0&&n!=="running";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.jsx(Ia,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{}),e.jsx(Cs,{onClick:()=>void Q({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Cs,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),e.jsx("div",{className:"flex items-baseline 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]})]})}),u&&i&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${i}`,children:i}),e.jsx("button",{type:"button",onClick:()=>void It(),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(Or,{view:t,setView:s}),e.jsx(We,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(wr,{onClose:()=>o(!1)})})]})}function Or({view:t,setView:s}){const a=m.useRef([]),n=b(i=>i.results),r=Ur.filter(i=>!i.hideWhenIdle||n.length>0);function o(i){var c;const u=(i+r.length)%r.length,p=r[u];p&&(s(p.slug),(c=a.current[u])==null||c.focus())}function l(i,u){switch(i.key){case"ArrowRight":i.preventDefault(),o(u+1);break;case"ArrowLeft":i.preventDefault(),o(u-1);break;case"Home":i.preventDefault(),o(0);break;case"End":i.preventDefault(),o(r.length-1);break}}return e.jsx("nav",{className:"flex gap-1","aria-label":"Primary navigation",role:"tablist",children:r.map((i,u)=>{const p=t===i.slug;return e.jsx("button",{ref:c=>{a.current[u]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(i.slug),onKeyDown:c=>l(c,u),className:p?"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md bg-slate-900 text-white shadow-sm":"text-xs font-medium tracking-tight px-3.5 py-1.5 rounded-md text-slate-600 hover:bg-slate-100 border border-transparent hover:border-slate-200",children:i.label},i.slug)})})}function Fr({feature:t,upgradeUrl:s}){const[a,n]=m.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(Ve,{open:a,onClose:()=>n(!1)})]})}const Mr="https://wcagcheckr.com/upgrade";function Pr(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(null),[u,p]=m.useState(Pe),[c,d]=m.useState(Pe[0].id),[h,g]=m.useState("none"),[f,v]=m.useState(null),w=b(U=>U.status),R=b(U=>U.tier),E=b(U=>U.results.length>0),C=w==="running";m.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"matrixPresets"}),se({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,F])=>{const q=Array.isArray(U.data)?U.data:null;p(q&&q.length>0?q:Pe),typeof F.data=="string"&&d(F.data)})},[]);function j(U){const F=u.find(q=>q.id===U);F&&(d(U),Q({type:"SETTINGS_SET",key:"activePresetId",value:U}),Q({type:"SETTINGS_SET",key:"stateMatrix",value:F.matrix}))}const N=je(R,"storybookAutoIterate");m.useEffect(()=>{const U=be("ELEMENT_PICKED_EVENT",(q,T)=>{n(!1);const Y=T.frameId;P(Y),o({selector:q.selector,frameId:Y,speech:q.speech})}),F=be("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),F()}},[]);async function x(){const U=await me();U&&(n(!0),await ve(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function A(){r&&(P(r.frameId),Ne({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function I(){if(!N){i("storybook:auto-iterate");return}P(),Ne({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function k(){P(),Ne({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function _(){P(),Ne({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function D(){P(),Ne({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),b.getState().startNewScan()}function W(){P(),Ne({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function Z(){P(),Ne({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function S(){Q({type:"CANCEL_AUDIT"})}async function P(U){b.getState().setPinned(null);const F=await me();if(F)try{await ve(F,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:F},U)}catch{}}async function L(U){v(null);const F=await me();if(!F){v("No audited tab; open a page first.");return}if(U==="none"){const T=await se({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:F});T.ok||v(T.error??"Failed to clear throttle."),g("none");return}const q=await se({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:F,profile:U});if(!q.ok){v(q.error??"Failed to apply throttle.");return}g(U)}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:C||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)",N?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>j(U.target.value),disabled:C||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:u.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:U=>void L(U.target.value),disabled:C||a,title:"Apply CDP network + CPU throttling to the audited tab. Catch contrast / focus / loading-state issues that only manifest under realistic conditions.",className:`text-xs border rounded px-2 py-1 ${h==="none"?"border-slate-300":"border-amber-400 bg-amber-50"}`,children:[e.jsx("option",{value:"none",children:"⚡ Throttle: off"}),e.jsx("option",{value:"3g-slow",children:"⚡ Slow 3G + 6× CPU"}),e.jsx("option",{value:"3g-fast",children:"⚡ Fast 3G + 4× CPU"}),e.jsx("option",{value:"4g",children:"⚡ 4G LTE + 2× CPU"}),e.jsx("option",{value:"cpu-2x",children:"⚡ CPU 2× only"}),e.jsx("option",{value:"cpu-4x",children:"⚡ CPU 4× only"})]}),t==="single-element"?e.jsx(Vr,{picking:a,picked:r,isRunning:C,onPick:x,onRun:A,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:_,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Scan page"}),e.jsx("button",{onClick:D,disabled:C||!E,className:"text-xs px-3 py-1 border border-emerald-400 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed",title:E?"Re-runs the audit but skips walkthroughs that already passed or are human-acked. Faster + cheaper after a fix/ack pass.":"Run a full Scan page first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.",children:C?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:W,disabled:C,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:C?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:Z,disabled:C,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:C?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:k,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:I,disabled:C,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:C?"Auditing…":"Audit all stories"}),C&&e.jsx("button",{onClick:S,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!C&&E&&e.jsx("button",{type:"button",onClick:()=>void It(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),f&&e.jsxs("p",{className:"text-[11px] text-rose-700",role:"alert",children:["⚡ ",f]}),t==="single-element"&&r&&!a&&!C&&e.jsx(Wr,{selector:r.selector,onRepick:x,onClear:()=>o(null)})]}),e.jsx(We,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(Fr,{feature:l??"",upgradeUrl:Mr})})]})}function Gr({speech:t}){if(!t)return null;const s=[];if(t.name&&s.push(t.name),t.role&&!["none","presentation","generic"].includes(t.role)&&s.push(t.role),s.push(...t.states),t.group&&s.push(t.group),s.length===0)return e.jsxs("span",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",title:"A screen reader would announce nothing for this element. Either it has no accessible name + a silent role (generic/presentation), or it's hidden from AT entirely.","data-testid":"sr-speech-preview",children:["SR: ",e.jsx("em",{children:"(silent)"})]});const a=s.join(", ");return e.jsxs("span",{className:"text-[10px] text-slate-700 bg-slate-100 border border-slate-200 rounded px-2 py-0.5 max-w-[280px] truncate",title:`Predicted screen-reader announcement when this element receives focus: "${a}"`,"data-testid":"sr-speech-preview",children:["SR: ",e.jsx("strong",{children:a})]})}function Vr({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:o}){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.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[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(Gr,{speech:s.speech})]}):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 Wr({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 Br={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Hr={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Kr(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),u=b(f=>f.results),p=b(f=>f.tier),c=u.flatMap(f=>f.violations);if(!je(p,"visualizers"))return null;async function d(f){const v=await me();v&&(i(f),f==="off"?await ve(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await ve(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function h(f){const v=await me();if(v){if(t&&await ve(v,{type:Br[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await ve(v,{type:Hr[f],tabId:v}).catch(()=>{}),s(f)}}async function g(){const f=await me();if(f){if(a){await ve(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),o(null);return}if(c.length===0){o("Run an audit first.");return}try{const v=await Te(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:c});n(!0),o(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{o("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(He,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(He,{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:()=>h("tab-order")}),e.jsx(He,{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:()=>h("reading-order")}),e.jsx(He,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>h("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(He,{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:g}),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:f=>void d(f.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 He({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 Ae({feature:t,label:s,children:a}){const n=b(r=>r.tier);return je(n,t)?e.jsx(e.Fragment,{children:a}):e.jsxs("div",{className:"p-6 text-center",children:[e.jsxs("div",{className:"mb-2 text-sm font-semibold text-slate-700",children:[s," isn’t available on your current plan"]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to unlock this feature."})]})}function zr(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 qr(){const t=b(u=>u.status),s=b(u=>u.progress),a=b(u=>u.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,o=n?"reading order · tab order · typography · CSS vars · AI candidates":zr(s.currentState),l=n?100:s.current/s.total*100,i=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(Es,{label:r,detail:o,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"}),i&&e.jsx(Es,{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 Es({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:o,barClass:l,fillClass:i}){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":o,children:e.jsx("div",{className:`h-full transition-all ${i}`,style:{width:`${a}%`}})})]})}function Rs(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function Qr({onView:t,viewingRun:s,crawlOnly:a}){var u,p;const n=b(c=>c.siteCrawlReport),r=b(c=>c.results),o=b(c=>c.siteCrawlStatus)==="running",l=b(c=>c.status)==="running";if(s||o||l)return null;let i=null;if(n)i=`Last crawl · ${Rs(n.startUrl)} · ${n.pagesAudited} page${n.pagesAudited===1?"":"s"} · grade ${n.siteGrade}`;else if(!a&&r.length>0){const c=((u=r[0])==null?void 0:u.pageUrl)??((p=r[0])==null?void 0:p.scope),d=r.reduce((h,g)=>h+g.violations.length,0);i=`Last audit · ${Rs(c)} · ${d} finding${d===1?"":"s"}`}return i?e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-brand-50 border-b border-brand-200 text-[11px] text-brand-900",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{className:"flex-1 min-w-0 truncate",title:i,children:i}),e.jsx("button",{type:"button",onClick:t,className:"shrink-0 px-2 py-0.5 rounded bg-brand-600 text-white hover:bg-brand-700 font-medium",children:"View"})]}):null}function Yr(){const t=new Set;for(const s of Me)for(const a of s.axeRules)t.add(a);return t}function Ea(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||r.add(`${o.ruleId}::${o.target.selector}`);for(const o of s)o.verdict==="fail"&&r.add(`${o.ruleId}::${o.selector}`);return r.size}function Jr(t,s,a,n){const r=new Set;for(const o of t)a.has(o.matchKey)||n.has(`violation::${o.matchKey}`)||o.wcagCriterion&&r.add(o.wcagCriterion);for(const o of s)o.verdict==="fail"&&o.wcagCriterion&&r.add(o.wcagCriterion);return Array.from(r).sort()}function Xr(t,s,a={}){const n=Yr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=ua(o),i={critical:0,serious:0,moderate:0,minor:0};for(const c of l)i[c.impact]++;const u=new Set(l.map(c=>De(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const d=De(c.ruleId,c.selector);u.has(d)||(u.add(d),i.serious++)}return{total:i.critical+i.serious+i.moderate+i.minor,counts:i,representatives:l}}function Ts(t,s){var n;const a=new Set;for(const r of s)for(const o of((n=r.axeRulesEvaluated)==null?void 0:n.incomplete)??[])for(const l of o.elements??[])a.add(`${o.ruleId}::${l.selector}`);return t.map(gn).map(fn).filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function cs(t){var o,l;const s=((o=t[0])==null?void 0:o.pageUrl)??((l=t[0])==null?void 0:l.scope)??"",a=b(i=>i.setResolutionsForUrl),[n,r]=m.useState(()=>{if(!s)return[];const i=b.getState().resolutionsByUrl[s];return i?Ts(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return Xe(s).then(u=>{i||(a(s,u),r(Ts(u,t)))}),()=>{i=!0}},[s,t,a]),n}const Zr=[{slug:"delta",label:"Delta",blurb:"Compare against the last baseline; export the prompt",marker:"Δ"},{slug:"guided",label:"Guided",blurb:"Step through manual IGT workflows",marker:"G"},{slug:"compliance",label:"Compliance",blurb:"WCAG-EM report builder + sign-and-seal",marker:"§"},{slug:"scorecard",label:"Components",blurb:"Every tracked component baseline at a glance",marker:"◍"},{slug:"forensic",label:"Forensic",blurb:"Audit history + RFC 3161 timestamps",marker:"⧉"},{slug:"schedules",label:"Schedules",blurb:"Recurring audits + alerts",marker:"⟳"},{slug:"risk",label:"Risk",blurb:"Posture summary across scheduled audits",marker:"⌖"},{slug:"crawl",label:"Site crawl",blurb:"Audit a multi-page site",marker:"↺"},{slug:"flows",label:"Flows",blurb:"Record + replay user-action sequences",marker:"▷"},{slug:"copilot",label:"Co-pilot",blurb:"Chat with AI grounded on the current audit",marker:"✦"},{slug:"ax-tree",label:"AX tree",blurb:"Browser's accessibility-tree viewer",marker:"⌥"},{slug:"tokens",label:"Design tokens",blurb:"CSS custom-properties usage map",marker:"#"}];function ei(){const t=b(n=>n.results),s=b(n=>n.status),a=b(n=>n.setView);return e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsx(ti,{results:t,status:s,setView:a}),e.jsx(si,{setView:a})]})}function ti({results:t,status:s,setView:a}){var g,f;if(s==="running")return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"audit in progress"}),e.jsxs("p",{className:"text-sm font-medium text-slate-900 mt-1",children:["The matrix is iterating. Progress is shown above; results land in ",e.jsx("strong",{children:"Findings"})," when done."]})]});if(t.length===0)return e.jsxs("section",{className:"border border-dashed border-slate-300 rounded-lg bg-slate-50 px-4 py-5 text-center",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"no audit yet"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-1",children:"Pick an audit mode above and run a scan."}),e.jsx("p",{className:"text-xs text-slate-500 mt-1.5 max-w-md mx-auto",children:"Or jump into a specialized tool below — site crawl, multi-page schedules, IGT workflows, the AI co-pilot, the forensic log."})]});const n=t.flatMap(v=>v.violations),r=ua(n),o=((g=t[0])==null?void 0:g.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",l=t.length,i=cs(t),u=b(v=>v.acknowledgedKeys),p=b(v=>v.dismissedKeys),c=Ea(n,i,u,p),d=3,h=c>0&&c<=d?r.slice(0,d):[];return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 truncate",children:["last audit · ",l," state",l===1?"":"s"]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 truncate mt-0.5",title:o,children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`})]}),e.jsx("button",{type:"button",onClick:()=>a("report"),className:"shrink-0 text-xs font-medium px-3.5 py-1.5 bg-slate-900 text-white rounded-md hover:bg-slate-800",children:"View findings →"})]}),h.length>0&&e.jsx("ul",{className:"border-t border-slate-200 divide-y divide-slate-100","aria-label":"Violations inline list",children:h.map(v=>{var E;const w=((E=v.target)==null?void 0:E.selector)??"(no selector)",R=w.length>50?w.slice(0,47)+"…":w;return e.jsx("li",{className:"px-3.5 py-2",children:e.jsxs("button",{type:"button",onClick:()=>a("report"),className:"w-full text-left flex items-center gap-2 hover:bg-slate-50 -mx-3.5 -my-2 px-3.5 py-2 transition-colors",title:`${v.description??v.ruleId} — ${w}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${v.impact==="critical"?"bg-rose-200 text-rose-900":v.impact==="serious"?"bg-orange-200 text-orange-900":v.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:v.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:v.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:R})]})},`${v.ruleId}::${w}`)})})]})}function si({setView:t}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Zr.map(s=>e.jsxs("button",{type:"button",onClick:()=>t(s.slug),className:"text-left rounded-lg border border-slate-200 bg-white hover:bg-slate-50 hover:border-slate-300 transition-colors px-3 py-2.5 flex flex-col gap-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",children:[e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-slate-400",children:[e.jsx("span",{className:"text-slate-700 mr-1.5",children:s.marker}),s.slug]}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 leading-tight mt-0.5",children:s.label}),e.jsx("span",{className:"text-[11px] text-slate-500 leading-snug",children:s.blurb})]},s.slug))})]})}const it="aiConfig";function ds(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(it).then(r=>a(r[it])).catch(()=>s(!1));const n=(r,o)=>{var l;o!=="local"||!(it in r)||a((l=r[it])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const ai={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},ni={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 ri({violations:t,componentId:s,hideOverallHeader:a=!1}){var ae,$,B,H,le,ge,de,ie;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,u]=m.useState([]),[p,c]=m.useState([]),[d,h]=m.useState(new Set),[g,f]=m.useState(null),[v,w]=m.useState({}),[R,E]=m.useState(new Set),[C,j]=m.useState(null),N=b(G=>G.status),x=b(G=>G.progress),A=b(G=>G.freshThisSession),I=b(G=>G.results),k=(ae=I[0])==null?void 0:ae.startedAt,_=(($=I[0])==null?void 0:$.pageUrl)??((B=I[0])==null?void 0:B.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let G=!1;return chrome.storage.local.get("igtRuns").then(te=>{if(G)return;const oe=((te==null?void 0:te.igtRuns)??{})[s]??{};r(Object.values(oe))}),Promise.all([Re(s),Oe([s])]).then(([te,xe])=>{if(G)return;const oe=new Set(xe.map(ee=>ee.criterionId)),X={},ye=[];for(const ee of te){const ce=oe.has(ee.criterionId)?"pass":ee.verdict;ee.criterionId==="2.4.3"?X.focusOrder=ce:ee.criterionId==="2.1.2"?X.keyboardTrap=ce:ee.criterionId==="2.4.7"?X.focusVisible=ce:ee.criterionId==="1.3.2"?X.readingOrder=ce:ee.criterionId==="1.4.11"&&(X.nonTextContrast=ce),ye.push({criterionId:ee.criterionId,ruleId:`ai-walkthrough-${ee.criterionId}`,pageUrl:ee.pageUrl,verdict:ce,reasoning:oe.has(ee.criterionId)?`Human verified: ${ee.reasoning}`:ee.reasoning})}l(X),u(ye)}),()=>{G=!0}},[s]),m.useEffect(()=>{if(!_){c([]);return}let G=!1;return Xe(_).then(te=>{G||c(te)}),()=>{G=!0}},[_,I]);const D=cs(I);if(N==="running")return e.jsx(pi,{current:x==null?void 0:x.current,total:x==null?void 0:x.total});const W=Zt({violations:t,auditRan:I.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((le=(H=I[0])==null?void 0:H.tabOrderIssues)==null?void 0:le.length)??0,readingOrder:((de=(ge=I[0])==null?void 0:ge.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:D.map(G=>({ruleId:G.ruleId,impact:"serious",selector:G.selector}))}),Z=b(G=>G.acknowledgedKeys),P=new Set(I.map(G=>G.pageUrl??G.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",L=I.length>0?pa(I,{runs:n,workflows:fe},"2.1","AA",Z,p,i,P):void 0,U=I.length>0?Jn(ts({audits:I,igtRuns:n,workflows:fe,acknowledgedMatchKeys:Z,incompleteResolutions:p,interactiveAuditResults:i,auditScope:P}),fe):void 0,F=W.overallLetter,T=(L?L.failingCriteria.length+L.inconclusiveCriteria.length+L.untestedCriteria.length:0)===0&&!!L;async function Y(G){var ye;if(!_||!((ye=L==null?void 0:L.inconclusiveReasons)!=null&&ye[G]))return;const xe=L.inconclusiveReasons[G].filter(ee=>ee.source==="axe-incomplete"&&ee.elements&&ee.elements.length>0);if(xe.length===0)return;h(ee=>new Set(ee).add(G)),f(null);const oe=[];let X=0;try{for(const ce of xe){const Se=await Q({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ce.ruleOrStepId,pageUrl:ce.pageUrl??_,wcagCriterion:G,elements:ce.elements??[],targetLevel:"AA"});if(Se!=null&&Se.unavailableReason){f(Se.unavailableReason);break}Se!=null&&Se.resolutions&&(oe.push(...Se.resolutions),X+=Se.totalCostUsd??0)}if(_){const ce=await Xe(_);c(ce)}const ee={total:oe.length,pass:oe.filter(ce=>ce.verdict==="pass").length,fail:oe.filter(ce=>ce.verdict==="fail").length,uncertain:oe.filter(ce=>ce.verdict==="uncertain").length,costUsd:X,resolutions:oe};w(ce=>({...ce,[G]:ee}))}finally{h(ee=>{const ce=new Set(ee);return ce.delete(G),ce})}}function J(G){E(te=>{const xe=new Set(te);return xe.has(G)?xe.delete(G):xe.add(G),xe})}const K=((ie=I[0])==null?void 0:ie.startedAt)??null,re=s&&K?`${s}::${K}`:null;m.useEffect(()=>{if(!re||!L||C===re||N!=="complete")return;const G=L.inconclusiveCriteria.filter(te=>{var oe;return(((oe=L.inconclusiveReasons)==null?void 0:oe[te])??[]).some(X=>X.source==="axe-incomplete"&&X.elements&&X.elements.length>0)});if(G.length===0){j(re);return}j(re),(async()=>{for(const te of G)try{await Y(te)}catch{}})()},[re,L,N]);async function pe(G){var Se,fs;if(!_)return;const te=((Se=L==null?void 0:L.inconclusiveReasons)==null?void 0:Se[G])??[],xe=((fs=L==null?void 0:L.failingReasons)==null?void 0:fs[G])??[],oe=[],X=new Set;for(const ue of te){if(ue.source!=="axe-incomplete"||!ue.elements)continue;const Ie=ue.pageUrl??_;for(const Ee of ue.elements){const Be=`${Ie}::${ue.ruleOrStepId}::${Ee.selector}`;X.has(Be)||(X.add(Be),oe.push({ruleId:ue.ruleOrStepId,pageUrl:Ie,selector:Ee.selector}))}}for(const ue of xe){if(ue.source!=="ai"||!ue.selector)continue;const Ie=ue.ruleOrStepId.startsWith("ai-resolved::")?ue.ruleOrStepId.slice(13):ue.ruleOrStepId,Ee=ue.pageUrl??_,Be=`${Ee}::${Ie}::${ue.selector}`;X.has(Be)||(X.add(Be),oe.push({ruleId:Ie,pageUrl:Ee,selector:ue.selector}))}if(oe.length===0)return;const ye=new Date().toISOString(),ee=[];for(const ue of oe){const Ie=p.find(Ee=>Ee.pageUrl===ue.pageUrl&&Ee.ruleId===ue.ruleId&&Ee.selector===ue.selector);Ie&&Ie.verdict==="pass"&&Ie.reasoning.startsWith("Marked as visually verified")||ee.push({pageUrl:ue.pageUrl,ruleId:ue.ruleId,selector:ue.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${ye.slice(0,10)}.`,resolvedAt:ye,costUsd:0,wcagCriterion:G})}if(ee.length===0)return;await bn(ee);const ce=await Xe(_);c(ce),w(ue=>({...ue,[G]:{total:ee.length,pass:ee.length,fail:0,uncertain:0,costUsd:0,resolutions:ee}}))}const y=(()=>{if(!L)return null;if(T)return{kind:"conformant",text:`WCAG ${L.targetLevel} Status: Conformant`,detail:"All applicable criteria pass automated + AI checks."};const G=L.inconclusiveCriteria.length,te=L.failingCriteria.length,xe=L.untestedCriteria.length,oe=[];if(te>0){const ye=L.failingCriteria.slice(0,4).join(", ")+(te>4?`, +${te-4}`:"");oe.push(`${te} ${te===1?"criterion":"criteria"} failing (${ye})`)}if(G>0){const ye=L.inconclusiveCriteria.slice(0,4).join(", ")+(G>4?`, +${G-4}`:"");oe.push(`${G} inconclusive (${ye})`)}if(xe>0){const ye=L.untestedCriteria.slice(0,4).join(", ")+(xe>4?`, +${xe-4}`:"");oe.push(`${xe} untested (${ye})`)}const X=te>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":xe>0?"Mark untested via Guided Tests, OR confirm the tool gap (no axe rule + no AI walkthrough + no IGT step).":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return{kind:"not-conformant",text:`WCAG ${L.targetLevel} Status: Not conformant`,detail:`${oe.join(" · ")}. ${X}`}})();let O=0;for(const G of fe){const te=n.find(oe=>oe.workflowId===G.id);if(!te)continue;G.steps.every(oe=>{const X=te.steps[oe.id];return(X==null?void 0:X.status)==="pass"||(X==null?void 0:X.status)==="fail"||(X==null?void 0:X.status)==="skip"||(X==null?void 0:X.status)==="not-applicable"})&&O++}const z=new Set;for(const G of t)Z.has(G.matchKey)||z.add(`${G.ruleId}::${G.target.selector}`);for(const G of D)G.verdict==="fail"&&z.add(`${G.ruleId}::${G.selector}`);const V=z.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!A&&k&&e.jsx(hi,{scannedAt:k}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ai[F]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:F})}),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 ",W.subGrades.length," verification areas below. Untested areas count as F until verified."]}),y&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${y.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[y.kind==="conformant"?"✓ ":"✗ ",y.text]}),e.jsx("p",{className:"mt-0.5",children:y.detail})]})]})]}),a&&y&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${y.kind==="conformant"?"bg-emerald-50 border-emerald-200 text-emerald-900":"bg-amber-50 border-amber-200 text-amber-900"}`,children:[e.jsxs("p",{className:"font-medium",children:[y.kind==="conformant"?"✓ ":"✗ ",y.text]}),e.jsx("p",{className:"mt-0.5",children:y.detail})]}),W.isLawsuitRisk&&e.jsx(li,{areas:W.warningAreas}),e.jsx(ci,{grades:W.subGrades,uncategorized:Xr(t,p,{excludeAckedMatchKeys:Z})}),L&&e.jsx(ii,{coverage:L,onResolveWithAi:Y,onMarkVisuallyVerified:pe,resolving:d,resolveError:g,lastResolveResult:v,expandedResultFor:R,onToggleResultDetail:J,violations:t}),U&&e.jsx(oi,{layers:U}),e.jsx(ui,{violationsRemaining:V,manualCompleted:O,manualTotal:fe.length}),O>0||I.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:O})," of ",e.jsx("strong",{children:fe.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:`${O/fe.length*100}%`}})})]}):null]})}function ii({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:u}){const p=b(C=>C.setView),c=b(C=>C.setFindingsLens),d=b(C=>C.setPendingAreaExpand);function h(C){const j=vn(C,u);p("report"),j?(c("per-area"),d(j)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,v]=m.useState(g>0&&g<=3),w=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),R=t.canClaimConformance,E=[];return t.failingCriteria.length>0&&E.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&E.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&E.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${R?"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 ${R?"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 (",w,"%)"]}),R&&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)."]}),!R&&(()=>{const C=[];t.failingCriteria.length>0&&C.push("failing"),t.inconclusiveCriteria.length>0&&C.push("inconclusive"),t.untestedCriteria.length>0&&C.push("untested");const j=C.length===0?"unresolved":C.length===1?C[0]:C.length===2?`${C[0]} or ${C[1]}`:`${C.slice(0,-1).join(", ")}, or ${C[C.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!R&&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."]}),!R&&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."]})]}),!R&&E.length>0&&e.jsx("button",{type:"button",onClick:()=>v(C=>!C),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!R&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[E.map(C=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${C.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[C.kind==="untested"?"Untested":C.kind==="inconclusive"?"Inconclusive":"Failing"," (",C.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:C.ids.map(j=>{var W,Z;const N=C.kind==="inconclusive"?(W=t.inconclusiveReasons)==null?void 0:W[j]:void 0,x=C.kind==="failing"?(Z=t.failingReasons)==null?void 0:Z[j]:void 0,A=N==null?void 0:N.some(S=>S.source==="axe-incomplete"&&S.elements&&S.elements.length>0),I=x==null?void 0:x.some(S=>S.source==="ai"),k=(n==null?void 0:n.has(j))??!1,_=o==null?void 0:o[j],D=(l==null?void 0:l.has(j))??!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("button",{type:"button",onClick:()=>h(j),className:"font-mono text-[11px] text-left underline-offset-2 hover:underline text-brand-700 hover:text-brand-800 cursor-pointer",title:`Jump to the verification area covering ${j}`,children:["· ",j]}),(C.kind==="inconclusive"&&A||C.kind==="failing"&&I)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C.kind==="inconclusive"&&s&&j!=="1.4.3"&&j!=="1.4.6"&&e.jsx("button",{type:"button",disabled:k,onClick:()=>s(j),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:k?"Resolving…":_?"✨ Resolve again →":"✨ Resolve with AI →"}),C.kind==="inconclusive"&&(j==="1.4.3"||j==="1.4.6")&&e.jsx("span",{className:"text-[10px] text-slate-500 italic",title:"The pixel-contrast sampler runs automatically and produces the authoritative verdict for color-contrast. Mark visually verified if the AI was wrong about a specific element.",children:"Pixel sampler ran automatically — use Mark visually verified if needed"}),a&&e.jsx("button",{type:"button",disabled:k,onClick:()=>a(j),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:C.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"})]})]}),_&&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 ",_.total," ",_.total===1?"verdict":"verdicts",":",_.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",_.pass," pass"]}),_.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",_.fail," fail"]}),_.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",_.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",_.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(j),className:"ml-auto text-[10px] underline text-brand-700",children:D?"hide reasoning":"show reasoning"})]}),_.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",_.uncertain," ",_.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),_.pass===_.total&&_.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."]}),D&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:_.resolutions.map((S,P)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:S.verdict==="pass"?"text-emerald-700 font-semibold":S.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:S.verdict==="pass"?"✓":S.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:S.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:S.reasoning})]},P))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((S,P)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[S.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),S.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:S.selector}),S.notes&&e.jsx("span",{className:"text-rose-700",children:S.notes})]},P))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((S,P)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[S.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," skipped — "]}),S.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.resolutionHint,S.elements&&S.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",S.elements.length===1?"element":`${S.elements.length} elements`,":"," ",S.elements.slice(0,3).map((L,U,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),U<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},U)),S.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",S.elements.length-3," more"]})]})]},P))}):C.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.)"})]},j)})})]},C.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 $s={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 oi({layers:t}){const s=b(o=>o.setView),a=b(o=>o.setFindingsLens);function n(){s("report"),a("violations")}const r=["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:r.map(o=>{const l=t[o],i=l.coveredCriteria.length,u=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,d=l.cleared,h=u>0||p>0,g=i>0&&!h&&c===0,f=g?"text-emerald-700":u>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 ${g?"bg-emerald-500 text-white":u>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:g?"✓":u>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:$s[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:i===0?"no coverage yet":`${d}/${i}`}),u>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-rose-700 hover:underline cursor-pointer",title:`Confirmed fails (action: fix the underlying issue + re-audit, OR mark visually verified): ${l.failing.join(", ")}`,children:["· ",u," failing"]}),p>0&&e.jsxs("button",{type:"button",onClick:n,className:"text-[10px] text-amber-700 hover:underline cursor-pointer",title:`Inconclusive — this layer couldn't determine (action: try "Resolve with AI" below, OR mark via Guided Tests): ${l.inconclusive.join(", ")}`,children:["· ",p," inconclusive"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:$s[o].hint}),o==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},o)})})]})}function li({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 ci({grades:t,uncategorized:s}){const a=b(i=>i.setView),n=b(i=>i.setFindingsLens),r=b(i=>i.setPendingAreaExpand);function o(i){a("report"),n("per-area"),r(i)}function l(i){const u=i.counts;return u.critical+u.serious+u.moderate+u.minor>0}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.jsxs("ul",{className:"grid grid-cols-1 gap-1.5",children:[t.map(i=>{const u=l(i),p="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=u?"cursor-pointer hover:bg-slate-100":"cursor-default",d=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${ni[i.letter]}`,"aria-label":`Grade ${i.letter}`,children:i.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:i.label}),e.jsx(di,{grade:i,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:u?e.jsx("button",{type:"button",onClick:()=>o(i.id),className:`${p} ${c}`,"aria-label":`Open ${i.label} violations`,children:d}):e.jsx("div",{className:p,children:d})},i.id)}),s&&s.total>0&&e.jsxs("li",{className:"flex items-center gap-2 text-[11px] mt-1 pt-1.5 border-t border-dashed border-slate-200",title:`These findings come from rules not mapped to any of the ${t.length} verification areas above. Listing them here so the headline count and the area cards agree. Rules: ${s.representatives.map(i=>i.ruleId).join(", ")}`,children:[e.jsx("span",{className:"w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold bg-slate-300 text-slate-700","aria-label":"Other findings",children:"?"}),e.jsxs("span",{className:"font-medium text-slate-700 flex-1 min-w-0",children:["Other findings",e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal italic",children:"rules not mapped to a category"})]}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:(()=>{const i=[];return s.counts.critical>0&&i.push(`${s.counts.critical} critical`),s.counts.serious>0&&i.push(`${s.counts.serious} serious`),s.counts.moderate>0&&i.push(`${s.counts.moderate} moderate`),s.counts.minor>0&&i.push(`${s.counts.minor} minor`),i.join(" · ")})()})]})]})]})}function di({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const u=fe.find(p=>p.id===i);return(u==null?void 0:u.name)??i};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 i=t.verifiedAt?Ra(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",i?` ${i} ago`:""]})}const{critical:n,serious:r,moderate:o,minor:l}=t.counts;if(n>0||r>0||o>0||l>0){const i=[];return n>0&&i.push({label:"critical",n,cls:"text-rose-700"}),r>0&&i.push({label:"serious",n:r,cls:"text-orange-700"}),o>0&&i.push({label:"moderate",n:o,cls:"text-amber-700"}),l>0&&i.push({label:"minor",n:l,cls:"text-slate-600"}),e.jsx("span",{className:"text-slate-500 text-[10px]",children:i.map((u,p)=>e.jsxs("span",{children:[p>0&&" · ",e.jsxs("span",{className:u.cls,children:[u.n," ",u.label]})]},u.label))})}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)," →"]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function ui({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.setView),r=b(l=>l.setFindingsLens),o=[{status:t===0?"done":"next",label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:t>0?()=>{n("report"),r("violations")}:void 0,tooltip:t>0?"Open the Violations list — each finding card has inline Acknowledge / Not a real issue / Locate / Fix recipe affordances.":void 0},{status:"optional",label:a>0?`Optional: spot-check via Guided Tests (${s}/${a} done — AI walkthroughs cover most)`:"Optional: spot-check via Guided Tests (AI walkthroughs cover most)",action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The 5 AI walkthroughs auto-run after every audit and verdict the criteria that previously required manual keyboard / vision checks. Run these workflows only for belt-and-suspenders confidence on a formal conformance claim."},{status:t===0?"next":"pending",label:"Export AI fix prompt → sign-and-seal in Compliance",action:()=>n("delta"),tooltip:'Switches to the Delta lens. Export menu → "AI fix prompt" produces markdown for ChatGPT / Claude / Copilot with code-level fix recipes for every automated finding, including false-positive guidance. Then jump to the Compliance tile from Dashboard to sign-and-seal the audit for a chain-of-custody record.'}];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:o.map((l,i)=>{const u=l.status==="done"?"text-emerald-700":l.status==="next"?"text-brand-600 font-semibold":l.status==="optional"?"text-slate-500":"text-slate-400";return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:`font-mono shrink-0 ${u}`,"aria-hidden":"true",children:[i+1,"."]}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:l.status==="next"?"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:l.status==="done"?"text-slate-500 line-through leading-snug":l.status==="next"?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label}),l.status==="done"&&e.jsx("span",{className:"text-emerald-700 shrink-0 font-mono","aria-label":"step complete",children:"✓"})]},i)})})]})}function pi({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 hi({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 (",Ra(s)," old). Re-scan to grade the current page state."]})]})}function Ra(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 Ta(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Ls(t){if(!Ta())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
3
3
  try {
4
4
  var el = document.querySelector(${JSON.stringify(t)});
5
5
  if (el) { inspect(el); return true; }
@@ -15,7 +15,7 @@ var pn=Object.defineProperty;var hn=(t,s,a)=>s in t?pn(t,s,{enumerable:!0,config
15
15
  `),p=new URLSearchParams({"[Title]":l,"[Description]":u});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>zs&&(c=c.slice(0,zs)),{url:c,title:l,description:u}}const qs=7800;function ho(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const d=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===d);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const o=`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 c of r)l.push(`### \`${c.ruleId}\` — ${c.impact}`),l.push(""),l.push(c.description),l.push(""),l.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),l.push(`- **Selector:** \`${c.target.selector}\``),l.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&l.push(`- **More info:** ${c.helpUrl}`),l.push(""),l.push("```html"),l.push(c.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const i=l.join(`
16
16
  `),u=new URLSearchParams({"issue[title]":o,"issue[description]":i});let p=`${n}/-/issues/new?${u.toString()}`;return p.length>qs&&(p=p.slice(0,qs)),{url:p,title:o,description:i}}const Qs=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],mo=["wcag-component-auditor","wcag-forensic-log"];async function xo(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Qs);s=Object.keys(n).length,await chrome.storage.local.remove(Qs)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of mo)try{await go(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 go(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 Ht="accessibilityStatementInputs:v1";async function fo(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Ht))[Ht];return s&&typeof s=="object"?s:null}async function bo(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Ht]:t})}function Da({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,o]=m.useState("eaa"),[l,i]=m.useState(""),[u,p]=m.useState(""),[c,d]=m.useState("partial"),[h,g]=m.useState(""),[f,v]=m.useState(""),[w,R]=m.useState(""),[E,C]=m.useState(""),[j,N]=m.useState("English"),[x,A]=m.useState("wcagcheckr (self-evaluation)"),[I,k]=m.useState("2.1"),[_,D]=m.useState("AA"),[W,Z]=m.useState(!1),[S,P]=m.useState(null),L=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var Y,J,K,re;const T=await fo();if(T&&(T.framing&&o(T.framing),T.organizationName&&i(T.organizationName),T.siteUrl&&p(T.siteUrl),T.conformanceStatus&&d(T.conformanceStatus),(Y=T.contact)!=null&&Y.email&&g(T.contact.email),(J=T.contact)!=null&&J.phone&&v(T.contact.phone),(K=T.contact)!=null&&K.formUrl&&R(T.contact.formUrl),T.countryCode&&C(T.countryCode),T.language&&N(T.language),T.auditedBy&&A(T.auditedBy),T.wcagVersion&&k(T.wcagVersion),T.wcagLevel&&D(T.wcagLevel)),!(T!=null&&T.siteUrl)&&((re=a[0])!=null&&re.pageUrl))try{const pe=new URL(a[0].pageUrl);p(`${pe.protocol}//${pe.host}/`)}catch{}T!=null&&T.conformanceStatus||d(An(a)),setTimeout(()=>{var pe;return(pe=L.current)==null?void 0:pe.focus()},50)})()},[t,a]),!t)return null;function U(){var K;const T=new Date().toISOString().slice(0,10),Y=(K=a[0])!=null&&K.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):T,J={};return h.trim()&&(J.email=h.trim()),f.trim()&&(J.phone=f.trim()),w.trim()&&(J.formUrl=w.trim()),{framing:r,organizationName:l.trim(),siteUrl:u.trim(),conformanceStatus:c,preparedAt:T,evaluatedAt:Y,contact:J,countryCode:E||null,language:j.trim()||"English",auditedBy:x.trim()||"wcagcheckr (self-evaluation)",wcagVersion:I,wcagLevel:_}}function F(T){if(!T.organizationName)return"Organization name is required.";if(!T.siteUrl)return"Site URL is required.";try{new URL(T.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!T.contact.email&&!T.contact.phone&&!T.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 q(T){var K;P(null);const Y=U(),J=F(Y);if(J){P(J);return}Z(!0);try{await bo(Y);const re=await se({type:"EXPORT_REQUEST",format:T==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:Y}),pe=(re==null?void 0:re.content)??"";if(!pe||pe.startsWith("# Accessibility statement — error")){P(pe||"Export failed — no response.");return}try{await navigator.clipboard.writeText(pe)}catch{}const y=new Blob([pe],{type:T==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),O=URL.createObjectURL(y);typeof chrome<"u"&&((K=chrome.tabs)!=null&&K.create)?await chrome.tabs.create({url:O,active:!0}).catch(()=>{window.open(O,"_blank","noopener,noreferrer")}):window.open(O,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(O),6e4),s()}catch(re){P(re instanceof Error?re.message:String(re))}finally{Z(!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:T=>T.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:r==="eaa",onChange:()=>o("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:r==="wad",onChange:()=>o("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:L,type:"text",value:l,onChange:T=>i(T.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:u,onChange:T=>p(T.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:c,onChange:T=>d(T.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:I,onChange:T=>k(T.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:_,onChange:T=>D(T.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:h,onChange:T=>g(T.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:f,onChange:T=>v(T.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:T=>R(T.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:E,onChange:T=>C(T.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(Cn).map(([T,Y])=>e.jsxs("option",{value:T,children:[T," — ",Y.name.replace(/^[A-Z]+\s*—\s*/,"")]},T))]}),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:j,onChange:T=>N(T.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:x,onChange:T=>A(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),S&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:S})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void q("markdown"),disabled:W,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:W?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void q("html"),disabled:W,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:W?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:W,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 Oa(){const t=b(y=>y.delta),s=b(y=>y.componentId),a=b(y=>y.results),n=b(y=>y.tier),r=b(y=>y.baselineList),o=b(y=>y.siteCrawlReport),[l,i]=m.useState(""),[u,p]=m.useState(""),[c,d]=m.useState(""),[h,g]=m.useState(""),[f,v]=m.useState(!1),[w,R]=m.useState(!1),[E,C]=m.useState(null),[j,N]=m.useState(null),[x,A]=m.useState(!1),[I,k]=m.useState(!1),[_,D]=m.useState(!1),[W,Z]=m.useState(null),[S,P]=m.useState(!1);m.useEffect(()=>{Promise.all([se({type:"SETTINGS_GET",key:"githubRepoUrl"}),se({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),se({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),se({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([y,O,z,V])=>{i(typeof y.data=="string"?y.data:""),p(typeof O.data=="string"?O.data:""),d(typeof z.data=="string"?z.data:""),g(typeof V.data=="string"?V.data:"")})},[]),m.useEffect(()=>be("BADGE_CLICKED_EVENT",O=>{const z=`viol-row-${O.violationId}`,V=document.getElementById(z);V&&(V.scrollIntoView({behavior:"smooth",block:"center"}),V.classList.add("ring-2","ring-rose-500"),setTimeout(()=>V.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const y=await me();y&&(_&&await ve(y,{type:"BADGES_HIDE_REQUEST",tabId:y}).catch(()=>{}),S&&await ve(y,{type:"HEATMAP_HIDE_REQUEST",tabId:y}).catch(()=>{}))})()},[]);async function L(){const y=await me();if(!y){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(_){await ve(y,{type:"BADGES_HIDE_REQUEST",tabId:y}).catch(()=>{}),D(!1),Z(null);return}const O={critical:4,serious:3,moderate:2,minor:1},z=new Map;for(const B of a)for(const H of B.violations)z.has(H.matchKey)||z.set(H.matchKey,H);const ae=Array.from(z.values()).sort((B,H)=>O[H.impact]-O[B.impact]).map((B,H)=>({id:B.matchKey,index:H+1,selector:B.target.selector,impact:B.impact,ruleId:B.ruleId,wcagCriterion:B.wcagCriterion}));if(ae.length===0){he.polite("No violations to badge.");return}const $=await Te(y,{type:"BADGES_SHOW_REQUEST",tabId:y,violations:ae}).catch(()=>null);$&&(D(!0),Z({rendered:$.rendered,requested:$.requested,clustered:$.clustered}),he.polite(`${$.rendered} violation badges shown on the page.`))}async function U(){const y=await me();if(!y){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(S){await ve(y,{type:"HEATMAP_HIDE_REQUEST",tabId:y}).catch(()=>{}),P(!1);return}const O=new Map;for(const ae of a)for(const $ of ae.violations)O.has($.matchKey)||O.set($.matchKey,$);const z=Array.from(O.values()).map(ae=>({selector:ae.target.selector,impact:ae.impact}));if(z.length===0){he.polite("No violations to heatmap.");return}const V=await Te(y,{type:"HEATMAP_SHOW_REQUEST",tabId:y,violations:z}).catch(()=>null);V&&(P(!0),he.polite(`Heatmap shown with ${V.rendered} violation blobs.`))}const F=je(n,"exportJson"),q=je(n,"issueTrackers"),T=ga(n).maxBaselines,Y=r.some(y=>y.componentId===s),J=Y||r.length<T;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 K(){if(!s||a.length===0)return;const y=a.flatMap(H=>H.violations),O=a.flatMap(H=>H.announcements??[]),z=a.flatMap(H=>H.focusEvents??[]),V=a[0],$=(await se({type:"SETTINGS_GET",key:"stateMatrix"})).data??ss;await Q({type:"BASELINE_SET",componentId:s,violations:y,announcements:O,focusEvents:z,snapshotMeta:{url:window.location.href,axeVersion:V.axeVersion,matrixConfig:$,capturedAt:new Date().toISOString()}});const B=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:O,focusEvents:z,currentMatrix:$});b.getState().setDelta(B.delta),he.polite(`Baseline saved for ${s}.`)}async function re(){if(!s||!Y||!window.confirm(`Remove the saved baseline for "${s}"?
17
17
 
18
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Q({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(B=>B.violations),z=a.flatMap(B=>B.announcements??[]),V=a.flatMap(B=>B.focusEvents??[]),ae=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:z,focusEvents:V});b.getState().setDelta(ae.delta);const $=await se({type:"BASELINE_LIST"});b.getState().setBaselineList($.items),he.polite(`Baseline cleared for ${s}.`)}async function pe(y,O=!1){if(a.length===0)return;if(y==="ai-prompt"){const{copyAiFixerPrompt:ie}=await ke(async()=>{const{copyAiFixerPrompt:G}=await import("./copy-ai-fixer-prompt-Cy0vn92r.js");return{copyAiFixerPrompt:G}},__vite__mapDeps([5,1,2]));await ie({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:o});return}let z;if((y==="defense-bundle"||y==="evidence-bundle"||y==="deposition-packet")&&s){const ie=await chrome.storage.local.get("igtRuns"),te=((ie==null?void 0:ie.igtRuns)??{})[s]??{};z=Object.values(te)}const $=await se({type:"EXPORT_REQUEST",format:y,results:a,delta:O?void 0:t??void 0,manualRuns:z,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(y==="defense-bundle"||y==="evidence-bundle"||y==="deposition-packet"){const ie=At(y,s);await ba()?rt($.content,ie):N({open:!0,format:y,content:$.content,filename:ie});return}if(y==="html-print"||y==="vpat"||y==="methodology-doc"||y==="conformance-crosswalk"||y==="executive-report"){_e($.content);return}const B=y==="json"?"application/json":y==="sarif"?"application/sarif+json":y==="ticket-bundle"?"text/markdown":"application/xml",H=y==="junit"?"xml":y==="ticket-bundle"?"md":y,le=new Blob([$.content],{type:B}),ge=URL.createObjectURL(le),de=document.createElement("a");de.href=ge,de.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${H}`,de.click(),URL.revokeObjectURL(ge)}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:K,disabled:!J,title:J?void 0:`Free tier limits you to ${T} 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"}),Y&&e.jsx("button",{onClick:re,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:()=>v(!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 L(),"aria-pressed":_,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:_?"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:_?"Hide badges":"Show badges 🎯"}),_&&W&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[W.rendered," of ",W.requested," rendered",W.clustered>0?` · ${W.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":S,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:S?"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:S?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(ko,{disabled:!F,onExport:pe,onAccessibilityStatement:()=>A(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta),canExport:y=>Ue(n,y),onUpgrade:()=>k(!0)}),!J&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const y=_t(t.new),O=_t(t.persistent),z=_t(t.fixed),V=[...y.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"New",violations:y.findings,count:y.findings.length,accent:"red",actions:[...q&&l&&y.findings.length>0?[{label:"File GitHub issue",onClick:()=>yo(l,s,y.findings)}]:[],...q&&u&&y.findings.length>0?[{label:"File Jira issue",onClick:()=>wo(u,s,y.findings)}]:[],...q&&c&&y.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>jo(c,s,y.findings)}]:[],...q&&h&&y.findings.length>0?[{label:"File GitLab issue",onClick:()=>No(h,s,y.findings)}]:[]]}),e.jsx(ze,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ze,{title:"Fixed",violations:z.findings,count:t.fixedCount,accent:"green"}),V.length>0&&e.jsx(ze,{title:"Needs review (does not affect grade)",violations:V,count:V.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ze,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),j&&e.jsx(_a,{open:j.open,onClose:()=>N(null),format:j.format,content:j.content,filename:j.filename}),e.jsx(Da,{open:x,onClose:()=>A(!1),results:a}),e.jsx(Ve,{open:I,onClose:()=>k(!1)}),f&&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"})]})]}),E&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",E.chromeStorageKeysCleared," chrome.storage key",E.chromeStorageKeysCleared===1?"":"s"," + ",E.indexedDbsCleared.length," database",E.indexedDbsCleared.length===1?"":"s",".",E.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",E.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:E?e.jsx("button",{type:"button",onClick:()=>{v(!1),C(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:()=>v(!1),disabled:w,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()=>{R(!0);try{const y=await xo();C(y),await It(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(y){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[y instanceof Error?y.message:String(y)]})}finally{R(!1)}},disabled:w,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:w?"Resetting…":"Reset everything"})]})})]})})]})}const vo={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function _t(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 ze({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:o}){const[l,i]=m.useState(!o);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 ${vo[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(u=>!u):void 0,children:[o&&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(u=>e.jsx("button",{type:"button",onClick:u.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:u.label},u.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:o?s.map((u,p)=>e.jsx(nt,{violation:u,alreadyAcknowledged:!0},p)):io(s).map(u=>e.jsx(ro,{ruleId:u.ruleId,violations:u.violations},u.ruleId))}):null]})}function yo(t,s,a){if(a.length===0)return;const{url:n}=co(t,s,a);Ct(n)}function wo(t,s,a){if(a.length===0)return;const{url:n}=uo(t,s,a);Ct(n)}function jo(t,s,a){if(a.length===0)return;const{url:n}=po(t,s,a);Ct(n)}function No(t,s,a){if(a.length===0)return;const{url:n}=ho(t,s,a);Ct(n)}function ko({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n,canExport:r,onUpgrade:o}){const[l,i]=m.useState(!1),[u,p]=m.useState(!1);function c(d){if(i(!1),!r(d)){o();return}s(d,u)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),l&&!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 right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] 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:u,onChange:d=>p(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(we,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(we,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(we,{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(we,{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(we,{onClick:()=>c("vpat"),locked:!r("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(we,{onClick:()=>c("defense-bundle"),locked:!r("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(we,{onClick:()=>c("evidence-bundle"),locked:!r("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(we,{onClick:()=>c("deposition-packet"),locked:!r("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(we,{onClick:()=>c("methodology-doc"),locked:!r("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(we,{onClick:()=>c("conformance-crosswalk"),locked:!r("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(we,{onClick:()=>c("ai-prompt"),locked:!r("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(we,{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(we,{onClick:()=>c("executive-report"),locked:!r("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(we,{locked:!r("accessibility-statement-html"),onClick:()=>{if(i(!1),!r("accessibility-statement-html")){o();return}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 we({onClick:t,title:s,children:a,locked:n=!1}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:n?"Paid feature — upgrade to generate this export":s,className:n?"flex w-full items-center justify-between gap-2 text-left text-xs px-3 py-1 hover:bg-amber-50 text-slate-600":"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["🔒 ",a]}),e.jsx("span",{className:"text-[10px] text-amber-700 font-medium shrink-0",children:"Upgrade"})]}):a})}const So="2024-07-25",Ao="Based on the W3C WCAG 3 Working Draft published 2024-07-25. Outcomes may shift before WCAG 3.0 reaches Recommendation; treat this view as a directional preview, not a conformance claim.",Fa=[{id:"text-alternatives",category:"perceive",title:"Non-text content has a text alternative",description:"Images, icons, audio, and video have descriptive text alternatives so users who cannot perceive the original modality still get the meaning.",wcag2Criteria:["1.1.1","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5"]},{id:"visual-distinction",category:"perceive",title:"Visual content is distinguishable",description:"Foreground content has sufficient contrast from background, both for text (APCA Lc thresholds in 3.0) and for non-text UI elements.",wcag2Criteria:["1.4.3","1.4.6","1.4.11"]},{id:"adaptable-presentation",category:"perceive",title:"Content adapts to user preferences",description:"Text spacing, zoom, reflow, and orientation respect user-agent and OS preferences without breaking layout or losing functionality.",wcag2Criteria:["1.3.4","1.4.4","1.4.10","1.4.12"]},{id:"meaningful-structure",category:"perceive",title:"Content structure is programmatically determinable",description:"Headings, lists, tables, regions, and other semantic structures are exposed in the accessibility tree so assistive technology can navigate them.",wcag2Criteria:["1.3.1","1.3.2","2.4.1","2.4.6"]},{id:"keyboard-operable",category:"operate",title:"All functionality is keyboard-operable",description:"Every interaction (including drag, pointer-gesture-driven, and complex widget interactions) has a keyboard equivalent that does not require timing or precision.",wcag2Criteria:["2.1.1","2.1.2","2.1.4","2.5.1","2.5.2","2.5.7"]},{id:"focus-management",category:"operate",title:"Focus is visible, ordered, and never obscured",description:"Keyboard focus is visually distinct, moves in a sensible order, never moves unexpectedly, and is never hidden by sticky headers or modals.",wcag2Criteria:["2.4.3","2.4.7","2.4.11","2.4.12"]},{id:"enough-time",category:"operate",title:"Users have enough time to complete tasks",description:"Time limits are adjustable, pauseable, or absent. Moving / blinking content can be paused. No content flashes more than three times per second.",wcag2Criteria:["2.2.1","2.2.2","2.3.1"]},{id:"navigable-content",category:"operate",title:"Content is navigable",description:"Pages have titles, link text describes the destination, multiple ways exist to find content, and skip-links bypass repeated blocks.",wcag2Criteria:["2.4.2","2.4.4","2.4.5"]},{id:"target-size",category:"operate",title:"Pointer targets are sufficiently sized",description:"Interactive targets are large enough to operate without precision-tap difficulty. Drag operations have a single-pointer alternative.",wcag2Criteria:["2.5.8","2.5.7"]},{id:"language-of-content",category:"understand",title:"Language of content is identified",description:"Page and language-of-parts are programmatically determinable so text-to-speech and other AT can pronounce content correctly.",wcag2Criteria:["3.1.1","3.1.2"]},{id:"predictable-behavior",category:"understand",title:"UI behavior is predictable",description:"Focusing or selecting an element does not cause unexpected context changes. Navigation and identification of repeated components is consistent across pages.",wcag2Criteria:["3.2.1","3.2.2","3.2.3","3.2.4","3.2.6"]},{id:"input-assistance",category:"understand",title:"Forms help users avoid and correct errors",description:"Required fields are labeled, errors are identified clearly, suggestions are offered when possible, and legal / financial forms have prevention mechanisms.",wcag2Criteria:["3.3.1","3.3.2","3.3.3","3.3.4","3.3.7"]},{id:"accessible-auth",category:"understand",title:"Authentication does not require cognitive function tests",description:"Login flows do not depend on memorizing characters, transcribing puzzles, or other cognitive function tests with no accessible alternative.",wcag2Criteria:["3.3.8","3.3.9"]},{id:"name-role-value",category:"robust",title:"UI components expose name, role, and value",description:"Every interactive element has a programmatically determinable name, role, and current state. Status messages reach assistive technology without focus changes.",wcag2Criteria:["4.1.2","4.1.3"]}];new Set(Fa.flatMap(t=>t.wcag2Criteria));function Co(t,s){return Fa.map(a=>{const n=a.wcag2Criteria.filter(l=>t.has(l)),r=a.wcag2Criteria.some(l=>s.has(l));let o;return n.length>0?o="has-violations":r?o="clean":o="not-evaluated",{outcome:a,violatedCriteria:n,status:o}})}const Io={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Ma(){const t=b(c=>c.results),s=b(c=>c.acknowledgedKeys),a=b(c=>c.dismissedKeys);if(t.length===0)return e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"wcag3-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. This view re-projects the audit's WCAG 2.x findings onto the WCAG 3 outcome structure."})]});const n=new Set,r=new Set;for(const c of t){for(const h of c.violations){if(h.needsReview){r.add(h.wcagCriterion);continue}if(s.has(h.matchKey)){r.add(h.wcagCriterion);continue}if(a.has(`violation::${h.matchKey}`)){r.add(h.wcagCriterion);continue}n.add(h.wcagCriterion),r.add(h.wcagCriterion)}const d=c.axeRulesEvaluated;if(d){for(const h of d.passed)r.add(h.wcagCriterion);for(const h of d.inapplicable)r.add(h.wcagCriterion);for(const h of d.incomplete)r.add(h.wcagCriterion)}}const o=Co(n,r),l=new Map;for(const c of o){const d=l.get(c.outcome.category)??[];d.push(c),l.set(c.outcome.category,d)}const i=o.filter(c=>c.status==="clean").length,u=o.filter(c=>c.status==="has-violations").length,p=o.filter(c=>c.status==="not-evaluated").length;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"wcag3-view-root",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-1",children:"Re-projects this audit's WCAG 2.x findings onto the WCAG 3 outcome structure."}),e.jsxs("p",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1 mt-2",role:"status","data-testid":"wcag3-source-badge",children:["⚠ Preview based on WCAG 3 Working Draft ",e.jsx("strong",{children:So}),"."," ",Ao]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded bg-emerald-100 text-emerald-800",children:[i," clean"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-rose-100 text-rose-900",children:[u," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[p," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const d=l.get(c)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${c}`,children:[e.jsxs("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:[Io[c]," · ",d.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:d.map(h=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(Eo,{status:h.status}),e.jsx("strong",{className:"text-xs",children:h.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:h.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",h.outcome.wcag2Criteria.join(", ")]}),h.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:h.violatedCriteria.join(", ")})]})]},h.outcome.id))})]},c)})]})}function Eo({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const Ro=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],To={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function $o(){const t=b(d=>d.results),s=b(d=>d.componentId),a=b(d=>d.findingsLens),n=b(d=>d.setFindingsLens),r=b(d=>d.setView),o=b(d=>d.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let d=!1;return(async()=>{const h=await Re(s),g=await Oe([s]);if(d)return;const f=new Set(g.map(w=>w.criterionId)),v={};for(const w of h){const R=f.has(w.criterionId)?"pass":w.verdict;w.criterionId==="2.4.3"?v.focusOrder=R:w.criterionId==="2.1.2"?v.keyboardTrap=R:w.criterionId==="2.4.7"?v.focusVisible=R:w.criterionId==="1.3.2"?v.readingOrder=R:w.criterionId==="1.4.11"&&(v.nonTextContrast=R)}i(v)})(),()=>{d=!0}},[s]);const u=cs(t),[p,c]=m.useState([]);return m.useEffect(()=>{if(!s){c([]);return}let d=!1;return chrome.storage.local.get("igtRuns").then(h=>{if(d)return;const f=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{d=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Ys,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:o==="running"?"Audit in progress. Findings appear here when the matrix completes.":o==="failed"||o==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Ys,{setView:r}),e.jsx(Uo,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:u}),e.jsx(Lo,{results:t}),e.jsx(_o,{lens:a,setLens:n}),e.jsx(Do,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:u})]})}function Ys({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function Lo({results:t}){const s=b(p=>p.crawlNavContext),a=b(p=>p.setCrawlNavContext),n=b(p=>p.setView);if(t.length===0)return null;const r=new Set(t.map(p=>p.pageUrl??p.scope??"").filter(Boolean)),o=r.size>1,l=o?null:Array.from(r)[0]??"(unknown)",i=(s==null?void 0:s.mode)==="page";function u(){a(null),n("crawl")}return e.jsxs("div",{className:`border rounded-lg px-3 py-2 text-[11px] leading-snug ${o?"border-blue-200 bg-blue-50 text-blue-900":i?"border-amber-200 bg-amber-50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}`,role:"note","aria-label":"Audit scope",children:[i&&e.jsx("button",{type:"button",onClick:()=>u(),className:"float-right text-[10px] font-semibold px-2 py-0.5 rounded border border-amber-400 bg-white text-amber-900 hover:bg-amber-100",children:"← Back to crawl report"}),o?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Site crawl · ",r.size," pages."]})," ","This grade reflects the site overall, not any individual page. Per-page drilldown is available in the Crawl tab."]}):i?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["One page from site crawl · ",l,"."]})," ",'This is the full per-page audit data for this URL — same lenses as a fresh single-page audit. Use the "Back to crawl report" button to return to the do-the-work report covering all crawled pages.']}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Single-page audit · ",l,"."]})," ","This grade reflects this page only. Multi-page criteria (3.2.3 Consistent Navigation, 3.2.4 Consistent Identification, 3.2.6 Consistent Help) are treated as N/A here — run a"," ",e.jsx("strong",{children:"Site Crawl"})," to evaluate them for the whole site."]})]})}function Uo({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,v,w,R;const r=t.flatMap(E=>E.violations),o=b(E=>E.lastAuditWallClockMs),l=b(E=>E.acknowledgedKeys),i=b(E=>E.dismissedKeys),p=Zt({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((v=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:v.length)??0,readingOrder:((R=(w=t[0])==null?void 0:w.readingOrderIssues)==null?void 0:R.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(E=>({ruleId:E.ruleId,impact:"serious",selector:E.selector}))}).overallLetter,c=Ea(r,n,l,i),d=Jr(r,n,l,i),h=t.length,g=o??t.reduce((E,C)=>E+C.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${To[p]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:p})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:"Graded by breadth — how many of the 9 areas have issues (1–3 → B, 4–6 → C). The Power-user view grades by severity (the worst finding sets the letter), so its letter can differ."}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&d.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",d.length," WCAG criterion",d.length===1?"":"a"," (",d.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[h," state",h===1?"":"s"," tested · ",(g/1e3).toFixed(1),"s"]})]})]})})}function _o({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:Ro.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function Do({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var o,l;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(Oo,{componentId:a,results:s}),e.jsx(Go,{componentId:a}),e.jsx(ri,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(Ko,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(Vo,{})]}):t==="per-area"?e.jsx(Wi,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(Bo,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ua,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Oa,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ma,{})}):null}const kt={critical:0,serious:1,moderate:2,minor:3};function Kt(t){return`${De(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Oo({componentId:t,results:s}){var f,v;const a=b(w=>w.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,u]=m.useState(0);m.useEffect(()=>{let w=!1;return(async()=>{if(!t){r({}),l({});return}const R=await Re(t);if(w)return;const E={};for(const N of R)E[N.criterionId]=N;r(E);const C=await Oe([t]);if(w)return;const j={};for(const N of C)j[`${N.criterionId}::${N.pageUrl}`]=N;l(j)})(),()=>{w=!0}},[t,i]);const p=((f=s[0])==null?void 0:f.pageUrl)??((v=s[0])==null?void 0:v.scope)??"",c=xt.map(w=>({crit:w,record:n[w.id]??null})).filter(({record:w})=>w&&(w.verdict==="fail"||w.verdict==="uncertain")).filter(({crit:w})=>!o[`${w.id}::${p}`]),d=new Set,h=[];for(const w of s)for(const R of w.violations){if(R.needsReview)continue;const E=De(R.ruleId,R.target.selector);d.has(E)||(d.add(E),h.push(R))}h.sort((w,R)=>(kt[w.impact]??99)-(kt[R.impact]??99));const g=c.length+h.length;return g===0?e.jsxs("section",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✓"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Nothing needs your attention on this page."})]}),e.jsx("p",{className:"text-[11px] text-emerald-800 mt-1 leading-snug",children:"No axe violations, no AI walkthrough fails, no uncertain findings. The sub-grades and WCAG coverage below are informational — you've done the work here. Move on to the next page or export your defense bundle."})]}):e.jsxs("section",{className:"border border-rose-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 bg-rose-50 border-b border-rose-200",children:[e.jsxs("p",{className:"text-sm font-semibold text-rose-900",children:[g," item",g===1?"":"s"," need",g===1?"s":""," your attention"]}),e.jsx("p",{className:"text-[11px] text-rose-800 mt-0.5 leading-snug",children:"Each row below is one thing to fix or sign off on. Use the inline buttons — you don't need to leave this view."})]}),e.jsxs("ul",{className:"divide-y divide-slate-100",children:[c.map(({crit:w,record:R})=>e.jsx(Fo,{componentId:t??"",pageUrl:p,criterionId:w.id,label:w.label,blurb:w.blurb,record:R,onChanged:()=>u(E=>E+1)},`wt::${w.id}`)),h.map(w=>e.jsx(Mo,{violation:w,onOpen:()=>a("violations")},`axe::${Kt(w)}`))]})]})}function Fo({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,u]=m.useState(!1),[p,c]=m.useState(""),[d,h]=m.useState(!1),[g,f]=m.useState(null),[v,w]=m.useState(!1),[R,E]=m.useState(!1),C=ds(),j=o.verdict,N=j==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function x(){h(!0),f(null);try{if(!p.trim()){f("Note is required — explain how you manually verified this."),h(!1);return}await es({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:j}),l()}catch(I){f(I instanceof Error?I.message:String(I))}finally{h(!1)}}async function A(){var I;E(!0),f(null);try{const _=(I=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:I.id;if(!_){f("No active tab — open the audited page first."),E(!1);return}const W=await Q({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:_,componentId:t,pageUrl:s});W.ok||f(W.error??"Re-run failed."),l()}catch(k){f(k instanceof Error?k.message:String(k))}finally{E(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${N}`,children:j}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:j==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>w(I=>!I),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:v?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void A(),disabled:R||!C,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",title:C?"Re-run AI walkthrough after fixing the page (will switch to the active tab)":"AI walkthroughs need an Anthropic API key. Add one in Settings → AI.",children:R?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{u(I=>!I),f(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 mt-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:o.reasoning})]}),i&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5 mt-1",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:p,onChange:I=>c(I.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),g&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void x(),disabled:d,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:d?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{u(!1),c(""),f(null)},disabled:d,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),g&&!i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g})]})}function Mo({violation:t,onOpen:s}){const a=t.impact==="critical"?"bg-rose-200 text-rose-900":t.impact==="serious"?"bg-orange-200 text-orange-900":t.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700";return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${a}`,children:t.impact}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:t.wcagCriterion||"wcag"}),e.jsx("code",{className:"text-[11px] text-slate-700 bg-slate-100 px-1 rounded",children:t.ruleId})]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:t.description}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-0.5 font-mono break-all",children:t.target.selector})]})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("button",{type:"button",onClick:s,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Open in Violations →"})})]})}const xt=[{id:"2.4.3",label:"Focus order",blurb:"AI walks Tab/Shift+Tab and judges screenshot-by-screenshot whether focus reaches every interactive element."},{id:"2.1.2",label:"No keyboard trap",blurb:"AI Tab-cycles forward then Shift+Tab back; verifies every focusable can be left."},{id:"2.4.7",label:"Focus visible",blurb:"AI inspects each focus-state screenshot for a visible indicator (outline/ring/underline)."},{id:"1.3.2",label:"Meaningful sequence",blurb:"AI vision over the page screenshot judges whether DOM-flagged divergences are real reading-order breaks or layout artifacts."},{id:"1.4.11",label:"Non-text contrast",blurb:"AI vision evaluates UI controls + state indicators for adequate contrast against their adjacent colors."},{id:"2.5.3",label:"Label in Name",blurb:"DOM walker collects {visibleText, accessibleName} pairs across every interactive control; AI judges ambiguous cases (icons, plurals, smart-quotes)."}],Po={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function Go({componentId:t}){const[s,a]=m.useState({}),[n,r]=m.useState({});m.useEffect(()=>{let d=!1;return(async()=>{if(!t){a({}),r({});return}const[h,g]=await Promise.all([Re(t),Oe([t])]);if(d)return;const f={};for(const w of h)f[w.criterionId]=w;a(f);const v={};for(const w of g)v[w.criterionId]=w;r(v)})(),()=>{d=!0}},[t]);const o={};for(const[d,h]of Object.entries(s))o[d]=n[d]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(d=>d==="pass").length,u=Object.values(o).filter(d=>d==="fail").length,p=Object.values(o).filter(d=>d==="uncertain").length,c=Object.keys(n).length;return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 border-b border-slate-100 flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-900",children:"AI verified"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-500",children:l===0?`not configured · all ${xt.length} criteria pending human verification`:`${l}/${xt.length} · ${i} pass · ${u} fail · ${p} uncertain${c>0?` · ${c} human-verified`:""}`})]}),l===0?e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-slate-600 leading-snug",children:["When an Anthropic API key is set in ",e.jsx("strong",{children:"Settings → AI"}),', these 5 criteria run automatically after every audit — replacing manual keyboard and vision checks. Without a key, they show as "pending human verification" in the Evidence layers below.']}):e.jsx("ul",{className:"divide-y divide-slate-100",children:xt.map(d=>{const h=s[d.id],g=n[d.id],f=h==null?void 0:h.verdict,v=g?"pass":f,w=h?Vt(h.reasoning):!1,R=h?ha(h.reasoning):!1,E=h?Wt(h.reasoning):null;return e.jsxs("li",{className:"px-3 py-2 flex items-start gap-2.5",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-medium rounded px-1.5 py-0.5 ${g?"bg-emerald-500 text-white":v?Po[v]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${f})`:v?`AI verdict: ${v}${E?` (cascade ${E})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":v||"not run"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:d.id}),d.label,R&&e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal",children:"· manual override"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:d.blurb}),w&&!R&&!g&&h&&e.jsxs("div",{className:"mt-1.5 bg-amber-50 border border-amber-300 rounded p-2 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-amber-900 font-medium",children:"AI cascade flagged this — fix the issue and re-audit."}),e.jsxs("details",{className:"text-[10px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-32 overflow-y-auto bg-white/50 p-1.5 rounded",children:h.reasoning})]})]}),g&&e.jsxs("div",{className:"mt-1.5 bg-emerald-50 border border-emerald-300 rounded p-2",children:[e.jsxs("p",{className:"text-[10px] text-emerald-900",children:[e.jsx("strong",{children:"Human verified:"})," ",g.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(g.acknowledgedAt).toLocaleString(),". Original AI verdict: ",f,"."]})]})]})]},d.id)})})]})}function Vo(){return e.jsxs("div",{className:"border-t border-slate-200 pt-3 space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"how to read this"}),e.jsx($e,{title:"The overall grade",body:'Count-based aggregation of the 9 verification areas (rc.110). The headline letter is the worst sub-grade letter you have N of — one C drops the overall off A regardless of how clean the other 8 areas look. This keeps a single bad area from hiding behind a high arithmetic mean. It is separate from "WCAG 2.1 AA Status," which is the legal-conformance answer (binary: conformant or not). The grade can be A while AA Status says "Not conformant" if there are unresolved criterion-level items — those are different questions and both are reported.'}),e.jsx($e,{title:"WCAG 2.1 AA Status",body:"Separate from the letter grade. Says whether you can claim WCAG 2.1 AA conformance. It is binary: Conformant or Not conformant. When Not conformant, the breakdown shows how many criteria are failing (real axe/AI violations) and how many are inconclusive (items that need user disposition). Fix or mark verified to flip to Conformant."}),e.jsx($e,{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. Areas below A show "verify with X →" — but when an AI walkthrough has already produced a verdict for that criterion, the prompt is suppressed automatically.`}),e.jsx($e,{title:"AI does most of the human work",body:"Six AI walkthroughs auto-run when an Anthropic API key is configured: 2.4.3 Focus Order, 2.1.2 No Keyboard Trap, 2.4.7 Focus Visible, 1.3.2 Meaningful Sequence, 1.4.11 Non-text Contrast, 2.5.3 Label in Name. They drive real keyboard input + take screenshots + judge them with vision (and parse DOM accessible-name vs visible-text for 2.5.3) — exactly the work IGT manual workflows used to require. Their verdicts feed the Tab order / Keyboard / Reading order / Color & contrast / Forms sub-grades automatically. When AI returns a definitive pass or fail for an area, the heuristic findings for that area become supporting evidence rather than independent severity (rc.227). Humans only spot-check + attest before signing the formal report."}),e.jsx($e,{title:"Fix recipes",body:'Every finding includes specific remediation instructions in the AI fix prompt export (Delta lens → Export menu). The prompt also includes false-positive guidance (skip-links, multi-column layouts, portal-rendered modals) so AI can ask before "fixing" intentional patterns.'}),e.jsx($e,{title:"WCAG 2.1 AA coverage",body:"Of 50 applicable Level AA criteria, how many have a definite verdict from any layer (automation, AI, or human). Untested criteria don't cap your grade — automation did everything it could — but for a formal conformance claim, those still need explicit evaluation. Run a Site Crawl or open Compliance to fill the gaps."}),e.jsx($e,{title:"Path to full compliance",body:"The shortest sequence of actions: fix automated violations, let AI walkthroughs auto-resolve the keyboard/vision criteria, optionally spot-check via Compliance → Sign and seal. Export the AI fix prompt from the Delta lens for code-level walkthroughs of each issue."})]})}function $e({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded bg-slate-50",children:[e.jsx("summary",{className:"px-2.5 py-1.5 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded",children:t}),e.jsx("p",{className:"px-2.5 pb-2 text-[11px] text-slate-700 leading-snug",children:s})]})}function Wo({componentId:t,records:s,stateCount:a}){const[n,r]=m.useState(0),[o,l]=m.useState({});return m.useEffect(()=>{if(!t){l({});return}let i=!1;return Oe([t]).then(u=>{if(i)return;const p={};for(const c of u)p[c.criterionId]=c;l(p)}),()=>{i=!0}},[t,n]),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[s.length," AI walkthrough finding",s.length===1?"":"s"," · axe found none"]}),e.jsxs("p",{className:"text-[11px] text-slate-600 px-0.5 leading-snug",children:["axe-core ran clean across ",a," state",a===1?"":"s",", but AI walkthroughs flagged something axe can't detect. Use the inline buttons on each row — no need to navigate elsewhere."]}),s.map(i=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(us,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(u=>u+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function Bo({results:t}){const s=b(i=>i.dismissedKeys),a=b(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const u of i.violations){if(s.has(`violation::${u.matchKey}`))continue;const p=Kt(u);n.has(p)||(n.add(p),r.push(u))}r.sort((i,u)=>{const p=kt[i.impact]??99,c=kt[u.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Re(a).then(u=>{i||l(u.filter(p=>p.verdict!=="pass"))}),()=>{i=!0}},[a]),r.length===0&&o.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No issues detected on this page — no axe violations and no AI walkthrough findings. The grade reflects sub-grading on areas that may have heuristic observations (visible under ",e.jsx("strong",{children:"Per-area"}),")."]}):r.length===0&&o.length>0?e.jsx(Wo,{componentId:a,records:o,stateCount:t.length}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[r.length," unique violation",r.length===1?"":"s"," · sorted by impact"]}),r.map(i=>e.jsx(nt,{violation:i},Kt(i)))]})}const Ho={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Ko({pageUrl:t}){const s=b(p=>p.tier),a=da(),n=je(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await fa();if(p||o(c),t){const d=await Zn(t);p||i(d)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const u=r.formats.length===1?Ho[r.formats[0]].split(" · ")[0]:`${r.formats.length} formats`;return e.jsxs("div",{className:"border border-emerald-200 rounded-lg bg-emerald-50 p-2.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold text-emerald-900",children:"✓ Remediation trail active"}),e.jsx("span",{className:"text-[10px] text-emerald-800 font-mono",children:u})]}),l?e.jsxs("p",{className:"text-[10px] text-emerald-800 leading-snug",children:["Last exported ",e.jsx("span",{className:"font-mono",children:new Date(l.exportedAt).toLocaleString()})," ","as ",e.jsx("span",{className:"font-mono",children:l.filename})]}):e.jsx("p",{className:"text-[10px] text-emerald-800 italic",children:"No audit has auto-exported on this page yet. Your next audit will download to Downloads automatically."})]})}const zt="igtRuns";async function zo(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const o=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:st(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:tt(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const qo={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"}},Qo={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"}},Yo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Js(t,s){const a=await me();if(!a)return;const n=s?qo[t]:Qo[t];try{await ve(a,n)}catch{}}async function Jo(){const s=(await chrome.storage.local.get(zt))[zt];return s&&typeof s=="object"?s:{}}async function Xs(t){await chrome.storage.local.set({[zt]:t})}function Xo(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 Zo(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Jo().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 i(c,d,h){var f;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((f=l[c])==null?void 0:f.steps)??{},[d]:h},completedAt:new Date().toISOString()}}};if(n(g),Xs(g),h.status==="pass"){const v=fe.find(R=>R.id===c),w=v==null?void 0:v.steps.find(R=>R.id===d);w!=null&&w.autoDismissActivity&&zo(w.autoDismissActivity,s,d)}}function u(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const d={...l};delete d[c];const h={...a,[t]:d};n(h),Xs(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(el,{workflow:p,run:c,results:s,onAnswer:(d,h)=>i(p.id,d,h),onBack:()=>o(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."}),fe.map(c=>{const d=l[c.id],h=d?er(d,c):null,g=d?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",f={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"}[g];return e.jsxs("button",{type:"button",onClick:()=>o(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${f}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),g==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),g==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),d&&e.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),u(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function el({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const u={};for(const p of t.steps)u[p.id]=Xo(p,a);return u},[t,a]);function l(){for(const u of t.steps){const p=o[u.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[u.id])&&n(u.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const i=t.steps.filter(u=>{var p;return((p=o[u.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[u.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}),i>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:[i," step",i===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 ",i," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((u,p)=>{const c=s==null?void 0:s.steps[u.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[u.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),u.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",u.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",u.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",u.question]}),u.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:u.relatedAxeRule})]}),(()=>{const d=o[u.id];return d?d.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:d.ruleId})," ran clean across ",d.statesAudited," state",d.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(u.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${d.ruleId}, ${d.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:d.ruleId})," already found ",d.violationCount," violation",d.violationCount===1?"":"s"," in"," ",d.states.length," state",d.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(u.id,{status:"fail",notes:`Auto-flagged via axe violations (${d.ruleId}, ${d.violationCount} hits in: ${d.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})(),u.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Js(u.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Yo[u.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Js(u.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(ot,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(u.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(u.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(u.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(u.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:d=>n(u.id,{status:c.status,notes:d.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},u.id)})})]})}const tl={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 ot({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?tl[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const gt="savedFlows";async function sl(){const t=await chrome.storage.local.get(gt);return Array.isArray(t[gt])?t[gt]:[]}async function Zs(t){await chrome.storage.local.set({[gt]:t})}function al(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{sl().then(s)},[]);async function l(){const c=await me();if(!c){o("No audit-target tab found.");return}try{await ve(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),o("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{o("Failed to start recording.")}}async function i(){const c=await me();if(c)try{const d=await Te(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),d.steps.length===0){o("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${d.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){o("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:d.steps,savedAt:new Date().toISOString()},f=[g,...t];s(f),await Zs(f),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(d){o(`Stop failed: ${d instanceof Error?d.message:String(d)}`)}}async function u(c){const d=await me();if(d){o(`Replaying "${c.name}"…`);try{const h=await Te(d,{type:"FLOW_PLAY_REQUEST",steps:c.steps});o(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){o(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const d=t.filter(h=>h.id!==c);s(d),await Zs(d)}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:i,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(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>u(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function nl(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 o=n.slice(0,r),l=n.slice(r+1);return o==="story"?{primary:l.split("--").map(u=>u.split("-").map(rl).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function rl(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function il(){const t=b(i=>i.baselineList),s=b(i=>i.tier),a=Qn[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{wt().finally(()=>o(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(i=>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"})]},i))});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(i){await Q({type:"BASELINE_DELETE",componentId:i}),await wt()}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(i=>{const u=nl(i.componentId),p=i.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:i.componentId,children:u.primary}),u.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:u.secondary,children:u.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[i.violationCount," ",i.violationCount===1?"violation":"violations"," ·"," ",new Date(i.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[i.seenOnUrlsCount&&i.seenOnUrlsCount>1&&e.jsxs(Le,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(Le,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(Le,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(Le,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(Le,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(Le,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(Le,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(i.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},i.componentId)})]})}const ol={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 Le({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${ol[t]}`,children:a})}const Pa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ll={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Pa]},cl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Pa]};function $t(t){return t==="thorough"?cl:ll}function qt(t){const s=$t(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ga({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(ea,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${qt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(ea,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${qt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function ea({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:o}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:o})]})}const Va={ruleIds:["image-alt","label","button-name","link-name","color-contrast","document-title","html-has-lang"],thresholds:{moderate:1,high:2,critical:4},headlines:{low:"Low risk. Your site passes the checks common automated lawsuit-targeting scanners run today — not low-hanging fruit. This isn't a guarantee: scanners add checks over time, so re-audit as your site changes.",moderate:"Moderate risk. A demand-letter scanner could flag at least one issue. Fix to drop off the easy-target list.",high:"High risk. Multiple findings here are common patterns demand-letter mills target.",critical:"Critical risk. Your site has many high-frequency patterns ADA-targeting firms scan for."},version:0};Va.ruleIds;function Wa(){var t;return((t=In())==null?void 0:t.lawfare)??Va}function ft(t,s=Wa()){return s.ruleIds.includes(t)}function Ba(t,s=Wa()){const a=new Set(s.ruleIds),n=new Map;for(const p of t)a.has(p.ruleId)&&n.set(p.ruleId,(n.get(p.ruleId)??0)+1);const r=Array.from(n.entries()).map(([p,c])=>({ruleId:p,instanceCount:c})).sort((p,c)=>c.instanceCount-p.instanceCount),o=r.length,l=Array.from(n.values()).reduce((p,c)=>p+c,0);let i;return o<s.thresholds.moderate?i="low":o<s.thresholds.high?i="moderate":o<s.thresholds.critical?i="high":i="critical",{tier:i,letter:i==="low"?"A":i==="moderate"?"C":i==="high"?"D":"F",flaggedRuleCount:o,flaggedInstanceCount:l,flaggedRules:r,headline:s.headlines[i],rubricVersion:s.version}}const ps={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"};function Ha(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return(async()=>{const o=(await et()??[]).flatMap(p=>p.results),l=await En(o);if(n)return;const i=l.acknowledgedMatchKeys,u=o.flatMap(p=>p.violations).filter(p=>!p.needsReview&&!i.has(p.matchKey));a(Ba(u))})(),()=>{n=!0}},[t.startUrl,t.finishedAt]),s}const bt="wcagcheckr";function ne(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ze(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 dl(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function ul(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 pl(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 hl(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 ml(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 (${ne(t.receipt.tsaName)}) — anchored ${ne(Ze(t.receipt.anchoredAt))}</td></tr>
18
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Q({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(B=>B.violations),z=a.flatMap(B=>B.announcements??[]),V=a.flatMap(B=>B.focusEvents??[]),ae=await se({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:z,focusEvents:V});b.getState().setDelta(ae.delta);const $=await se({type:"BASELINE_LIST"});b.getState().setBaselineList($.items),he.polite(`Baseline cleared for ${s}.`)}async function pe(y,O=!1){if(a.length===0)return;if(y==="ai-prompt"){const{copyAiFixerPrompt:ie}=await ke(async()=>{const{copyAiFixerPrompt:G}=await import("./copy-ai-fixer-prompt-D1dxQZUr.js");return{copyAiFixerPrompt:G}},__vite__mapDeps([5,1,2]));await ie({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:o});return}let z;if((y==="defense-bundle"||y==="evidence-bundle"||y==="deposition-packet")&&s){const ie=await chrome.storage.local.get("igtRuns"),te=((ie==null?void 0:ie.igtRuns)??{})[s]??{};z=Object.values(te)}const $=await se({type:"EXPORT_REQUEST",format:y,results:a,delta:O?void 0:t??void 0,manualRuns:z,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(y==="defense-bundle"||y==="evidence-bundle"||y==="deposition-packet"){const ie=At(y,s);await ba()?rt($.content,ie):N({open:!0,format:y,content:$.content,filename:ie});return}if(y==="html-print"||y==="vpat"||y==="methodology-doc"||y==="conformance-crosswalk"||y==="executive-report"){_e($.content);return}const B=y==="json"?"application/json":y==="sarif"?"application/sarif+json":y==="ticket-bundle"?"text/markdown":"application/xml",H=y==="junit"?"xml":y==="ticket-bundle"?"md":y,le=new Blob([$.content],{type:B}),ge=URL.createObjectURL(le),de=document.createElement("a");de.href=ge,de.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${H}`,de.click(),URL.revokeObjectURL(ge)}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:K,disabled:!J,title:J?void 0:`Free tier limits you to ${T} 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"}),Y&&e.jsx("button",{onClick:re,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:()=>v(!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 L(),"aria-pressed":_,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:_?"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:_?"Hide badges":"Show badges 🎯"}),_&&W&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[W.rendered," of ",W.requested," rendered",W.clustered>0?` · ${W.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void U(),"aria-pressed":S,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:S?"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:S?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(ko,{disabled:!F,onExport:pe,onAccessibilityStatement:()=>A(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta),canExport:y=>Ue(n,y),onUpgrade:()=>k(!0)}),!J&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const y=_t(t.new),O=_t(t.persistent),z=_t(t.fixed),V=[...y.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"New",violations:y.findings,count:y.findings.length,accent:"red",actions:[...q&&l&&y.findings.length>0?[{label:"File GitHub issue",onClick:()=>yo(l,s,y.findings)}]:[],...q&&u&&y.findings.length>0?[{label:"File Jira issue",onClick:()=>wo(u,s,y.findings)}]:[],...q&&c&&y.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>jo(c,s,y.findings)}]:[],...q&&h&&y.findings.length>0?[{label:"File GitLab issue",onClick:()=>No(h,s,y.findings)}]:[]]}),e.jsx(ze,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ze,{title:"Fixed",violations:z.findings,count:t.fixedCount,accent:"green"}),V.length>0&&e.jsx(ze,{title:"Needs review (does not affect grade)",violations:V,count:V.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ze,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),j&&e.jsx(_a,{open:j.open,onClose:()=>N(null),format:j.format,content:j.content,filename:j.filename}),e.jsx(Da,{open:x,onClose:()=>A(!1),results:a}),e.jsx(Ve,{open:I,onClose:()=>k(!1)}),f&&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"})]})]}),E&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",E.chromeStorageKeysCleared," chrome.storage key",E.chromeStorageKeysCleared===1?"":"s"," + ",E.indexedDbsCleared.length," database",E.indexedDbsCleared.length===1?"":"s",".",E.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",E.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:E?e.jsx("button",{type:"button",onClick:()=>{v(!1),C(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:()=>v(!1),disabled:w,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()=>{R(!0);try{const y=await xo();C(y),await It(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(y){C({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[y instanceof Error?y.message:String(y)]})}finally{R(!1)}},disabled:w,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:w?"Resetting…":"Reset everything"})]})})]})})]})}const vo={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function _t(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 ze({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:o}){const[l,i]=m.useState(!o);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 ${vo[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(u=>!u):void 0,children:[o&&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(u=>e.jsx("button",{type:"button",onClick:u.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:u.label},u.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:o?s.map((u,p)=>e.jsx(nt,{violation:u,alreadyAcknowledged:!0},p)):io(s).map(u=>e.jsx(ro,{ruleId:u.ruleId,violations:u.violations},u.ruleId))}):null]})}function yo(t,s,a){if(a.length===0)return;const{url:n}=co(t,s,a);Ct(n)}function wo(t,s,a){if(a.length===0)return;const{url:n}=uo(t,s,a);Ct(n)}function jo(t,s,a){if(a.length===0)return;const{url:n}=po(t,s,a);Ct(n)}function No(t,s,a){if(a.length===0)return;const{url:n}=ho(t,s,a);Ct(n)}function ko({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n,canExport:r,onUpgrade:o}){const[l,i]=m.useState(!1),[u,p]=m.useState(!1);function c(d){if(i(!1),!r(d)){o();return}s(d,u)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),l&&!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 right-0 top-full mt-1 z-50 w-[260px] max-w-[calc(100vw-1rem)] 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:u,onChange:d=>p(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(we,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(we,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(we,{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(we,{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(we,{onClick:()=>c("vpat"),locked:!r("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(we,{onClick:()=>c("defense-bundle"),locked:!r("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(we,{onClick:()=>c("evidence-bundle"),locked:!r("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(we,{onClick:()=>c("deposition-packet"),locked:!r("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(we,{onClick:()=>c("methodology-doc"),locked:!r("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(we,{onClick:()=>c("conformance-crosswalk"),locked:!r("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(we,{onClick:()=>c("ai-prompt"),locked:!r("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(we,{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(we,{onClick:()=>c("executive-report"),locked:!r("executive-report"),title:"Single-page executive HTML report: grade hero, top 3 risks, recommended next steps. Print-ready (Ctrl+P → Save as PDF). For stakeholder distribution rather than developer remediation.",children:"Executive report 📊"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(we,{locked:!r("accessibility-statement-html"),onClick:()=>{if(i(!1),!r("accessibility-statement-html")){o();return}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 we({onClick:t,title:s,children:a,locked:n=!1}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:n?"Paid feature — upgrade to generate this export":s,className:n?"flex w-full items-center justify-between gap-2 text-left text-xs px-3 py-1 hover:bg-amber-50 text-slate-600":"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["🔒 ",a]}),e.jsx("span",{className:"text-[10px] text-amber-700 font-medium shrink-0",children:"Upgrade"})]}):a})}const So="2024-07-25",Ao="Based on the W3C WCAG 3 Working Draft published 2024-07-25. Outcomes may shift before WCAG 3.0 reaches Recommendation; treat this view as a directional preview, not a conformance claim.",Fa=[{id:"text-alternatives",category:"perceive",title:"Non-text content has a text alternative",description:"Images, icons, audio, and video have descriptive text alternatives so users who cannot perceive the original modality still get the meaning.",wcag2Criteria:["1.1.1","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5"]},{id:"visual-distinction",category:"perceive",title:"Visual content is distinguishable",description:"Foreground content has sufficient contrast from background, both for text (APCA Lc thresholds in 3.0) and for non-text UI elements.",wcag2Criteria:["1.4.3","1.4.6","1.4.11"]},{id:"adaptable-presentation",category:"perceive",title:"Content adapts to user preferences",description:"Text spacing, zoom, reflow, and orientation respect user-agent and OS preferences without breaking layout or losing functionality.",wcag2Criteria:["1.3.4","1.4.4","1.4.10","1.4.12"]},{id:"meaningful-structure",category:"perceive",title:"Content structure is programmatically determinable",description:"Headings, lists, tables, regions, and other semantic structures are exposed in the accessibility tree so assistive technology can navigate them.",wcag2Criteria:["1.3.1","1.3.2","2.4.1","2.4.6"]},{id:"keyboard-operable",category:"operate",title:"All functionality is keyboard-operable",description:"Every interaction (including drag, pointer-gesture-driven, and complex widget interactions) has a keyboard equivalent that does not require timing or precision.",wcag2Criteria:["2.1.1","2.1.2","2.1.4","2.5.1","2.5.2","2.5.7"]},{id:"focus-management",category:"operate",title:"Focus is visible, ordered, and never obscured",description:"Keyboard focus is visually distinct, moves in a sensible order, never moves unexpectedly, and is never hidden by sticky headers or modals.",wcag2Criteria:["2.4.3","2.4.7","2.4.11","2.4.12"]},{id:"enough-time",category:"operate",title:"Users have enough time to complete tasks",description:"Time limits are adjustable, pauseable, or absent. Moving / blinking content can be paused. No content flashes more than three times per second.",wcag2Criteria:["2.2.1","2.2.2","2.3.1"]},{id:"navigable-content",category:"operate",title:"Content is navigable",description:"Pages have titles, link text describes the destination, multiple ways exist to find content, and skip-links bypass repeated blocks.",wcag2Criteria:["2.4.2","2.4.4","2.4.5"]},{id:"target-size",category:"operate",title:"Pointer targets are sufficiently sized",description:"Interactive targets are large enough to operate without precision-tap difficulty. Drag operations have a single-pointer alternative.",wcag2Criteria:["2.5.8","2.5.7"]},{id:"language-of-content",category:"understand",title:"Language of content is identified",description:"Page and language-of-parts are programmatically determinable so text-to-speech and other AT can pronounce content correctly.",wcag2Criteria:["3.1.1","3.1.2"]},{id:"predictable-behavior",category:"understand",title:"UI behavior is predictable",description:"Focusing or selecting an element does not cause unexpected context changes. Navigation and identification of repeated components is consistent across pages.",wcag2Criteria:["3.2.1","3.2.2","3.2.3","3.2.4","3.2.6"]},{id:"input-assistance",category:"understand",title:"Forms help users avoid and correct errors",description:"Required fields are labeled, errors are identified clearly, suggestions are offered when possible, and legal / financial forms have prevention mechanisms.",wcag2Criteria:["3.3.1","3.3.2","3.3.3","3.3.4","3.3.7"]},{id:"accessible-auth",category:"understand",title:"Authentication does not require cognitive function tests",description:"Login flows do not depend on memorizing characters, transcribing puzzles, or other cognitive function tests with no accessible alternative.",wcag2Criteria:["3.3.8","3.3.9"]},{id:"name-role-value",category:"robust",title:"UI components expose name, role, and value",description:"Every interactive element has a programmatically determinable name, role, and current state. Status messages reach assistive technology without focus changes.",wcag2Criteria:["4.1.2","4.1.3"]}];new Set(Fa.flatMap(t=>t.wcag2Criteria));function Co(t,s){return Fa.map(a=>{const n=a.wcag2Criteria.filter(l=>t.has(l)),r=a.wcag2Criteria.some(l=>s.has(l));let o;return n.length>0?o="has-violations":r?o="clean":o="not-evaluated",{outcome:a,violatedCriteria:n,status:o}})}const Io={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function Ma(){const t=b(c=>c.results),s=b(c=>c.acknowledgedKeys),a=b(c=>c.dismissedKeys);if(t.length===0)return e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"wcag3-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. This view re-projects the audit's WCAG 2.x findings onto the WCAG 3 outcome structure."})]});const n=new Set,r=new Set;for(const c of t){for(const h of c.violations){if(h.needsReview){r.add(h.wcagCriterion);continue}if(s.has(h.matchKey)){r.add(h.wcagCriterion);continue}if(a.has(`violation::${h.matchKey}`)){r.add(h.wcagCriterion);continue}n.add(h.wcagCriterion),r.add(h.wcagCriterion)}const d=c.axeRulesEvaluated;if(d){for(const h of d.passed)r.add(h.wcagCriterion);for(const h of d.inapplicable)r.add(h.wcagCriterion);for(const h of d.incomplete)r.add(h.wcagCriterion)}}const o=Co(n,r),l=new Map;for(const c of o){const d=l.get(c.outcome.category)??[];d.push(c),l.set(c.outcome.category,d)}const i=o.filter(c=>c.status==="clean").length,u=o.filter(c=>c.status==="has-violations").length,p=o.filter(c=>c.status==="not-evaluated").length;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"wcag3-view-root",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"WCAG 3 readiness preview"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-1",children:"Re-projects this audit's WCAG 2.x findings onto the WCAG 3 outcome structure."}),e.jsxs("p",{className:"text-[10px] text-amber-800 bg-amber-50 border border-amber-200 rounded px-2 py-1 mt-2",role:"status","data-testid":"wcag3-source-badge",children:["⚠ Preview based on WCAG 3 Working Draft ",e.jsx("strong",{children:So}),"."," ",Ao]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"px-2 py-1 rounded bg-emerald-100 text-emerald-800",children:[i," clean"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-rose-100 text-rose-900",children:[u," with violations"]}),e.jsxs("span",{className:"px-2 py-1 rounded bg-slate-100 text-slate-700",children:[p," not evaluated"]})]}),["perceive","operate","understand","robust"].map(c=>{const d=l.get(c)??[];return e.jsxs("section",{className:"border border-slate-200 rounded bg-white","data-testid":`wcag3-category-${c}`,children:[e.jsxs("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:[Io[c]," · ",d.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:d.map(h=>e.jsxs("li",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx(Eo,{status:h.status}),e.jsx("strong",{className:"text-xs",children:h.outcome.title})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:h.outcome.description}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1 font-mono",children:["WCAG 2: ",h.outcome.wcag2Criteria.join(", ")]}),h.violatedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 mt-1",children:["Violated: ",e.jsx("strong",{children:h.violatedCriteria.join(", ")})]})]},h.outcome.id))})]},c)})]})}function Eo({status:t}){return t==="clean"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"✓ clean"}):t==="has-violations"?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-900",children:"✗ violations"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"— not evaluated"})}const Ro=[{id:"overview",label:"Overview",hint:"Verification areas + WCAG coverage + evidence layers"},{id:"per-area",label:"Per-area",hint:"Drill into the 9 verification areas"},{id:"violations",label:"Violations",hint:"Flat list of every unique finding"},{id:"activity",label:"Activity",hint:"Live regions · focus events · tab/reading order"},{id:"delta",label:"Delta",hint:"Compared to the last accepted baseline"},{id:"wcag3",label:"WCAG 3",hint:"Forward-looking projection on the WCAG 3 outcome map"}],To={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-amber-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function $o(){const t=b(d=>d.results),s=b(d=>d.componentId),a=b(d=>d.findingsLens),n=b(d=>d.setFindingsLens),r=b(d=>d.setView),o=b(d=>d.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let d=!1;return(async()=>{const h=await Re(s),g=await Oe([s]);if(d)return;const f=new Set(g.map(w=>w.criterionId)),v={};for(const w of h){const R=f.has(w.criterionId)?"pass":w.verdict;w.criterionId==="2.4.3"?v.focusOrder=R:w.criterionId==="2.1.2"?v.keyboardTrap=R:w.criterionId==="2.4.7"?v.focusVisible=R:w.criterionId==="1.3.2"?v.readingOrder=R:w.criterionId==="1.4.11"&&(v.nonTextContrast=R)}i(v)})(),()=>{d=!0}},[s]);const u=cs(t),[p,c]=m.useState([]);return m.useEffect(()=>{if(!s){c([]);return}let d=!1;return chrome.storage.local.get("igtRuns").then(h=>{if(d)return;const f=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{d=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(Ys,{setView:r}),e.jsx("div",{className:"mt-6 text-center text-sm text-slate-600",children:e.jsx("p",{children:o==="running"?"Audit in progress. Findings appear here when the matrix completes.":o==="failed"||o==="interrupted"?"Last audit didn't complete. Re-run the scan from the controls above.":"No audit results yet. Run a scan from the controls above."})})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Ys,{setView:r}),e.jsx(Uo,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:u}),e.jsx(Lo,{results:t}),e.jsx(_o,{lens:a,setLens:n}),e.jsx(Do,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:u})]})}function Ys({setView:t}){return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>t("matrix"),className:"text-xs text-slate-600 hover:text-slate-900 hover:underline font-mono px-0.5",children:"← Dashboard"}),e.jsx("span",{className:"text-[11px] font-mono uppercase tracking-widest text-slate-400",children:"findings"})]})}function Lo({results:t}){const s=b(p=>p.crawlNavContext),a=b(p=>p.setCrawlNavContext),n=b(p=>p.setView);if(t.length===0)return null;const r=new Set(t.map(p=>p.pageUrl??p.scope??"").filter(Boolean)),o=r.size>1,l=o?null:Array.from(r)[0]??"(unknown)",i=(s==null?void 0:s.mode)==="page";function u(){a(null),n("crawl")}return e.jsxs("div",{className:`border rounded-lg px-3 py-2 text-[11px] leading-snug ${o?"border-blue-200 bg-blue-50 text-blue-900":i?"border-amber-200 bg-amber-50 text-amber-900":"border-slate-200 bg-slate-50 text-slate-700"}`,role:"note","aria-label":"Audit scope",children:[i&&e.jsx("button",{type:"button",onClick:()=>u(),className:"float-right text-[10px] font-semibold px-2 py-0.5 rounded border border-amber-400 bg-white text-amber-900 hover:bg-amber-100",children:"← Back to crawl report"}),o?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Site crawl · ",r.size," pages."]})," ","This grade reflects the site overall, not any individual page. Per-page drilldown is available in the Crawl tab."]}):i?e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["One page from site crawl · ",l,"."]})," ",'This is the full per-page audit data for this URL — same lenses as a fresh single-page audit. Use the "Back to crawl report" button to return to the do-the-work report covering all crawled pages.']}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["Single-page audit · ",l,"."]})," ","This grade reflects this page only. Multi-page criteria (3.2.3 Consistent Navigation, 3.2.4 Consistent Identification, 3.2.6 Consistent Help) are treated as N/A here — run a"," ",e.jsx("strong",{children:"Site Crawl"})," to evaluate them for the whole site."]})]})}function Uo({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,v,w,R;const r=t.flatMap(E=>E.violations),o=b(E=>E.lastAuditWallClockMs),l=b(E=>E.acknowledgedKeys),i=b(E=>E.dismissedKeys),p=Zt({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((v=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:v.length)??0,readingOrder:((R=(w=t[0])==null?void 0:w.readingOrderIssues)==null?void 0:R.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(E=>({ruleId:E.ruleId,impact:"serious",selector:E.selector}))}).overallLetter,c=Ea(r,n,l,i),d=Jr(r,n,l,i),h=t.length,g=o??t.reduce((E,C)=>E+C.durationMs,0);return e.jsx("section",{className:"sticky top-0 z-10 border border-slate-200 rounded-lg bg-white overflow-hidden shadow-sm","aria-label":"Audit grade summary",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${To[p]}`,children:e.jsx("span",{className:"text-4xl font-display font-semibold leading-none tracking-tight",children:p})}),e.jsxs("div",{className:"flex-1 px-3.5 py-3",children:[e.jsx("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500",children:"overall grade · 9 verification areas"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:"Graded by breadth — how many of the 9 areas have issues (1–3 → B, 4–6 → C). The Power-user view grades by severity (the worst finding sets the letter), so its letter can differ."}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-0.5",children:c===0?"No issues found by automation":`Fix ${c} element${c===1?"":"s"}`}),c>0&&d.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",d.length," WCAG criterion",d.length===1?"":"a"," (",d.join(", "),")"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:[h," state",h===1?"":"s"," tested · ",(g/1e3).toFixed(1),"s"]})]})]})})}function _o({lens:t,setLens:s}){return e.jsx("nav",{className:"flex flex-wrap gap-1 border-b border-slate-200 pb-1.5",role:"tablist","aria-label":"Findings lens",children:Ro.map(a=>{const n=t===a.id;return e.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>s(a.id),title:a.hint,className:n?"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md bg-slate-900 text-white":"text-[11px] font-medium tracking-tight px-2.5 py-1 rounded-md text-slate-600 hover:bg-slate-100",children:a.label},a.id)})})}function Do({lens:t,results:s,componentId:a,interactiveVerdicts:n,aiResolvedFails:r}){var o,l;return t==="overview"?e.jsxs("div",{className:"space-y-3",children:[e.jsx(Oo,{componentId:a,results:s}),e.jsx(Go,{componentId:a}),e.jsx(ri,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(Ko,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(Vo,{})]}):t==="per-area"?e.jsx(Wi,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(Bo,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ua,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Oa,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ma,{})}):null}const kt={critical:0,serious:1,moderate:2,minor:3};function Kt(t){return`${De(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Oo({componentId:t,results:s}){var f,v;const a=b(w=>w.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,u]=m.useState(0);m.useEffect(()=>{let w=!1;return(async()=>{if(!t){r({}),l({});return}const R=await Re(t);if(w)return;const E={};for(const N of R)E[N.criterionId]=N;r(E);const C=await Oe([t]);if(w)return;const j={};for(const N of C)j[`${N.criterionId}::${N.pageUrl}`]=N;l(j)})(),()=>{w=!0}},[t,i]);const p=((f=s[0])==null?void 0:f.pageUrl)??((v=s[0])==null?void 0:v.scope)??"",c=xt.map(w=>({crit:w,record:n[w.id]??null})).filter(({record:w})=>w&&(w.verdict==="fail"||w.verdict==="uncertain")).filter(({crit:w})=>!o[`${w.id}::${p}`]),d=new Set,h=[];for(const w of s)for(const R of w.violations){if(R.needsReview)continue;const E=De(R.ruleId,R.target.selector);d.has(E)||(d.add(E),h.push(R))}h.sort((w,R)=>(kt[w.impact]??99)-(kt[R.impact]??99));const g=c.length+h.length;return g===0?e.jsxs("section",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base",children:"✓"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Nothing needs your attention on this page."})]}),e.jsx("p",{className:"text-[11px] text-emerald-800 mt-1 leading-snug",children:"No axe violations, no AI walkthrough fails, no uncertain findings. The sub-grades and WCAG coverage below are informational — you've done the work here. Move on to the next page or export your defense bundle."})]}):e.jsxs("section",{className:"border border-rose-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 bg-rose-50 border-b border-rose-200",children:[e.jsxs("p",{className:"text-sm font-semibold text-rose-900",children:[g," item",g===1?"":"s"," need",g===1?"s":""," your attention"]}),e.jsx("p",{className:"text-[11px] text-rose-800 mt-0.5 leading-snug",children:"Each row below is one thing to fix or sign off on. Use the inline buttons — you don't need to leave this view."})]}),e.jsxs("ul",{className:"divide-y divide-slate-100",children:[c.map(({crit:w,record:R})=>e.jsx(Fo,{componentId:t??"",pageUrl:p,criterionId:w.id,label:w.label,blurb:w.blurb,record:R,onChanged:()=>u(E=>E+1)},`wt::${w.id}`)),h.map(w=>e.jsx(Mo,{violation:w,onOpen:()=>a("violations")},`axe::${Kt(w)}`))]})]})}function Fo({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,u]=m.useState(!1),[p,c]=m.useState(""),[d,h]=m.useState(!1),[g,f]=m.useState(null),[v,w]=m.useState(!1),[R,E]=m.useState(!1),C=ds(),j=o.verdict,N=j==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function x(){h(!0),f(null);try{if(!p.trim()){f("Note is required — explain how you manually verified this."),h(!1);return}await es({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:j}),l()}catch(I){f(I instanceof Error?I.message:String(I))}finally{h(!1)}}async function A(){var I;E(!0),f(null);try{const _=(I=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:I.id;if(!_){f("No active tab — open the audited page first."),E(!1);return}const W=await Q({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:_,componentId:t,pageUrl:s});W.ok||f(W.error??"Re-run failed."),l()}catch(k){f(k instanceof Error?k.message:String(k))}finally{E(!1)}}return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${N}`,children:j}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:a}),n]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:j==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>w(I=>!I),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:v?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void A(),disabled:R||!C,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",title:C?"Re-run AI walkthrough after fixing the page (will switch to the active tab)":"AI walkthroughs need an Anthropic API key. Add one in Settings → AI.",children:R?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{u(I=>!I),f(null)},className:"text-[10px] px-2 py-0.5 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50 font-medium",children:"Mark verified manually"})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2 mt-1",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"What the walkthrough does"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:r}),e.jsx("p",{className:"text-[10px] text-slate-500 mb-1 font-mono uppercase tracking-wide",children:"AI reasoning"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap font-mono",children:o.reasoning})]}),i&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5 mt-1",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"How did you verify? (required, goes into the forensic record)"}),e.jsx("textarea",{value:p,onChange:I=>c(I.target.value),placeholder:"e.g., Tested with VoiceOver on Safari — focus order matches visual order, all interactive elements reachable.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),g&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void x(),disabled:d,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:d?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{u(!1),c(""),f(null)},disabled:d,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"})]})]}),g&&!i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:g})]})}function Mo({violation:t,onOpen:s}){const a=t.impact==="critical"?"bg-rose-200 text-rose-900":t.impact==="serious"?"bg-orange-200 text-orange-900":t.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700";return e.jsxs("li",{className:"px-3 py-2.5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase ${a}`,children:t.impact}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:t.wcagCriterion||"wcag"}),e.jsx("code",{className:"text-[11px] text-slate-700 bg-slate-100 px-1 rounded",children:t.ruleId})]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:t.description}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-0.5 font-mono break-all",children:t.target.selector})]})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("button",{type:"button",onClick:s,className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Open in Violations →"})})]})}const xt=[{id:"2.4.3",label:"Focus order",blurb:"AI walks Tab/Shift+Tab and judges screenshot-by-screenshot whether focus reaches every interactive element."},{id:"2.1.2",label:"No keyboard trap",blurb:"AI Tab-cycles forward then Shift+Tab back; verifies every focusable can be left."},{id:"2.4.7",label:"Focus visible",blurb:"AI inspects each focus-state screenshot for a visible indicator (outline/ring/underline)."},{id:"1.3.2",label:"Meaningful sequence",blurb:"AI vision over the page screenshot judges whether DOM-flagged divergences are real reading-order breaks or layout artifacts."},{id:"1.4.11",label:"Non-text contrast",blurb:"AI vision evaluates UI controls + state indicators for adequate contrast against their adjacent colors."},{id:"2.5.3",label:"Label in Name",blurb:"DOM walker collects {visibleText, accessibleName} pairs across every interactive control; AI judges ambiguous cases (icons, plurals, smart-quotes)."}],Po={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function Go({componentId:t}){const[s,a]=m.useState({}),[n,r]=m.useState({});m.useEffect(()=>{let d=!1;return(async()=>{if(!t){a({}),r({});return}const[h,g]=await Promise.all([Re(t),Oe([t])]);if(d)return;const f={};for(const w of h)f[w.criterionId]=w;a(f);const v={};for(const w of g)v[w.criterionId]=w;r(v)})(),()=>{d=!0}},[t]);const o={};for(const[d,h]of Object.entries(s))o[d]=n[d]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(d=>d==="pass").length,u=Object.values(o).filter(d=>d==="fail").length,p=Object.values(o).filter(d=>d==="uncertain").length,c=Object.keys(n).length;return e.jsxs("section",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("header",{className:"px-3 py-2 border-b border-slate-100 flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-900",children:"AI verified"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-500",children:l===0?`not configured · all ${xt.length} criteria pending human verification`:`${l}/${xt.length} · ${i} pass · ${u} fail · ${p} uncertain${c>0?` · ${c} human-verified`:""}`})]}),l===0?e.jsxs("div",{className:"px-3 py-2.5 text-[11px] text-slate-600 leading-snug",children:["When an Anthropic API key is set in ",e.jsx("strong",{children:"Settings → AI"}),', these 5 criteria run automatically after every audit — replacing manual keyboard and vision checks. Without a key, they show as "pending human verification" in the Evidence layers below.']}):e.jsx("ul",{className:"divide-y divide-slate-100",children:xt.map(d=>{const h=s[d.id],g=n[d.id],f=h==null?void 0:h.verdict,v=g?"pass":f,w=h?Vt(h.reasoning):!1,R=h?ha(h.reasoning):!1,E=h?Wt(h.reasoning):null;return e.jsxs("li",{className:"px-3 py-2 flex items-start gap-2.5",children:[e.jsx("span",{className:`shrink-0 inline-flex items-center justify-center font-mono text-[10px] font-medium rounded px-1.5 py-0.5 ${g?"bg-emerald-500 text-white":v?Po[v]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${f})`:v?`AI verdict: ${v}${E?` (cascade ${E})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":v||"not run"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-slate-500 mr-1.5",children:d.id}),d.label,R&&e.jsx("span",{className:"ml-2 text-[10px] text-slate-500 font-normal",children:"· manual override"})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:d.blurb}),w&&!R&&!g&&h&&e.jsxs("div",{className:"mt-1.5 bg-amber-50 border border-amber-300 rounded p-2 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] text-amber-900 font-medium",children:"AI cascade flagged this — fix the issue and re-audit."}),e.jsxs("details",{className:"text-[10px] text-amber-900",children:[e.jsx("summary",{className:"cursor-pointer hover:underline select-none font-medium",children:"What AI saw (click to expand)"}),e.jsx("p",{className:"mt-1 leading-snug whitespace-pre-wrap font-mono text-[10px] text-amber-900 max-h-32 overflow-y-auto bg-white/50 p-1.5 rounded",children:h.reasoning})]})]}),g&&e.jsxs("div",{className:"mt-1.5 bg-emerald-50 border border-emerald-300 rounded p-2",children:[e.jsxs("p",{className:"text-[10px] text-emerald-900",children:[e.jsx("strong",{children:"Human verified:"})," ",g.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(g.acknowledgedAt).toLocaleString(),". Original AI verdict: ",f,"."]})]})]})]},d.id)})})]})}function Vo(){return e.jsxs("div",{className:"border-t border-slate-200 pt-3 space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:"how to read this"}),e.jsx($e,{title:"The overall grade",body:'Count-based aggregation of the 9 verification areas (rc.110). The headline letter is the worst sub-grade letter you have N of — one C drops the overall off A regardless of how clean the other 8 areas look. This keeps a single bad area from hiding behind a high arithmetic mean. It is separate from "WCAG 2.1 AA Status," which is the legal-conformance answer (binary: conformant or not). The grade can be A while AA Status says "Not conformant" if there are unresolved criterion-level items — those are different questions and both are reported.'}),e.jsx($e,{title:"WCAG 2.1 AA Status",body:"Separate from the letter grade. Says whether you can claim WCAG 2.1 AA conformance. It is binary: Conformant or Not conformant. When Not conformant, the breakdown shows how many criteria are failing (real axe/AI violations) and how many are inconclusive (items that need user disposition). Fix or mark verified to flip to Conformant."}),e.jsx($e,{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. Areas below A show "verify with X →" — but when an AI walkthrough has already produced a verdict for that criterion, the prompt is suppressed automatically.`}),e.jsx($e,{title:"AI does most of the human work",body:"Six AI walkthroughs auto-run when an Anthropic API key is configured: 2.4.3 Focus Order, 2.1.2 No Keyboard Trap, 2.4.7 Focus Visible, 1.3.2 Meaningful Sequence, 1.4.11 Non-text Contrast, 2.5.3 Label in Name. They drive real keyboard input + take screenshots + judge them with vision (and parse DOM accessible-name vs visible-text for 2.5.3) — exactly the work IGT manual workflows used to require. Their verdicts feed the Tab order / Keyboard / Reading order / Color & contrast / Forms sub-grades automatically. When AI returns a definitive pass or fail for an area, the heuristic findings for that area become supporting evidence rather than independent severity (rc.227). Humans only spot-check + attest before signing the formal report."}),e.jsx($e,{title:"Fix recipes",body:'Every finding includes specific remediation instructions in the AI fix prompt export (Delta lens → Export menu). The prompt also includes false-positive guidance (skip-links, multi-column layouts, portal-rendered modals) so AI can ask before "fixing" intentional patterns.'}),e.jsx($e,{title:"WCAG 2.1 AA coverage",body:"Of 50 applicable Level AA criteria, how many have a definite verdict from any layer (automation, AI, or human). Untested criteria don't cap your grade — automation did everything it could — but for a formal conformance claim, those still need explicit evaluation. Run a Site Crawl or open Compliance to fill the gaps."}),e.jsx($e,{title:"Path to full compliance",body:"The shortest sequence of actions: fix automated violations, let AI walkthroughs auto-resolve the keyboard/vision criteria, optionally spot-check via Compliance → Sign and seal. Export the AI fix prompt from the Delta lens for code-level walkthroughs of each issue."})]})}function $e({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded bg-slate-50",children:[e.jsx("summary",{className:"px-2.5 py-1.5 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded",children:t}),e.jsx("p",{className:"px-2.5 pb-2 text-[11px] text-slate-700 leading-snug",children:s})]})}function Wo({componentId:t,records:s,stateCount:a}){const[n,r]=m.useState(0),[o,l]=m.useState({});return m.useEffect(()=>{if(!t){l({});return}let i=!1;return Oe([t]).then(u=>{if(i)return;const p={};for(const c of u)p[c.criterionId]=c;l(p)}),()=>{i=!0}},[t,n]),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[s.length," AI walkthrough finding",s.length===1?"":"s"," · axe found none"]}),e.jsxs("p",{className:"text-[11px] text-slate-600 px-0.5 leading-snug",children:["axe-core ran clean across ",a," state",a===1?"":"s",", but AI walkthroughs flagged something axe can't detect. Use the inline buttons on each row — no need to navigate elsewhere."]}),s.map(i=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(us,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(u=>u+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function Bo({results:t}){const s=b(i=>i.dismissedKeys),a=b(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const u of i.violations){if(s.has(`violation::${u.matchKey}`))continue;const p=Kt(u);n.has(p)||(n.add(p),r.push(u))}r.sort((i,u)=>{const p=kt[i.impact]??99,c=kt[u.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Re(a).then(u=>{i||l(u.filter(p=>p.verdict!=="pass"))}),()=>{i=!0}},[a]),r.length===0&&o.length===0?e.jsxs("div",{className:"text-center text-sm text-slate-600 py-6",children:["No issues detected on this page — no axe violations and no AI walkthrough findings. The grade reflects sub-grading on areas that may have heuristic observations (visible under ",e.jsx("strong",{children:"Per-area"}),")."]}):r.length===0&&o.length>0?e.jsx(Wo,{componentId:a,records:o,stateCount:t.length}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-mono uppercase tracking-wider text-slate-500 px-0.5",children:[r.length," unique violation",r.length===1?"":"s"," · sorted by impact"]}),r.map(i=>e.jsx(nt,{violation:i},Kt(i)))]})}const Ho={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Ko({pageUrl:t}){const s=b(p=>p.tier),a=da(),n=je(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await fa();if(p||o(c),t){const d=await Zn(t);p||i(d)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const u=r.formats.length===1?Ho[r.formats[0]].split(" · ")[0]:`${r.formats.length} formats`;return e.jsxs("div",{className:"border border-emerald-200 rounded-lg bg-emerald-50 p-2.5 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-[12px] font-semibold text-emerald-900",children:"✓ Remediation trail active"}),e.jsx("span",{className:"text-[10px] text-emerald-800 font-mono",children:u})]}),l?e.jsxs("p",{className:"text-[10px] text-emerald-800 leading-snug",children:["Last exported ",e.jsx("span",{className:"font-mono",children:new Date(l.exportedAt).toLocaleString()})," ","as ",e.jsx("span",{className:"font-mono",children:l.filename})]}):e.jsx("p",{className:"text-[10px] text-emerald-800 italic",children:"No audit has auto-exported on this page yet. Your next audit will download to Downloads automatically."})]})}const zt="igtRuns";async function zo(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const o=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:st(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await at(r,l.map(i=>({key:tt(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const qo={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"}},Qo={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"}},Yo={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Js(t,s){const a=await me();if(!a)return;const n=s?qo[t]:Qo[t];try{await ve(a,n)}catch{}}async function Jo(){const s=(await chrome.storage.local.get(zt))[zt];return s&&typeof s=="object"?s:{}}async function Xs(t){await chrome.storage.local.set({[zt]:t})}function Xo(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 Zo(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Jo().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 i(c,d,h){var f;const g={...a,[t]:{...l,[c]:{...l[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((f=l[c])==null?void 0:f.steps)??{},[d]:h},completedAt:new Date().toISOString()}}};if(n(g),Xs(g),h.status==="pass"){const v=fe.find(R=>R.id===c),w=v==null?void 0:v.steps.find(R=>R.id===d);w!=null&&w.autoDismissActivity&&zo(w.autoDismissActivity,s,d)}}function u(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const d={...l};delete d[c];const h={...a,[t]:d};n(h),Xs(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(el,{workflow:p,run:c,results:s,onAnswer:(d,h)=>i(p.id,d,h),onBack:()=>o(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."}),fe.map(c=>{const d=l[c.id],h=d?er(d,c):null,g=d?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",f={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"}[g];return e.jsxs("button",{type:"button",onClick:()=>o(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${f}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),g==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),g==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),d&&e.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),u(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function el({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const u={};for(const p of t.steps)u[p.id]=Xo(p,a);return u},[t,a]);function l(){for(const u of t.steps){const p=o[u.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[u.id])&&n(u.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const i=t.steps.filter(u=>{var p;return((p=o[u.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[u.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}),i>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:[i," step",i===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 ",i," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((u,p)=>{const c=s==null?void 0:s.steps[u.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[u.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),u.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",u.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",u.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",u.question]}),u.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:u.relatedAxeRule})]}),(()=>{const d=o[u.id];return d?d.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:d.ruleId})," ran clean across ",d.statesAudited," state",d.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(u.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${d.ruleId}, ${d.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:d.ruleId})," already found ",d.violationCount," violation",d.violationCount===1?"":"s"," in"," ",d.states.length," state",d.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(u.id,{status:"fail",notes:`Auto-flagged via axe violations (${d.ruleId}, ${d.violationCount} hits in: ${d.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})(),u.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Js(u.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Yo[u.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Js(u.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(ot,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(u.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(u.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(u.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(ot,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(u.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:d=>n(u.id,{status:c.status,notes:d.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},u.id)})})]})}const tl={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 ot({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?tl[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const gt="savedFlows";async function sl(){const t=await chrome.storage.local.get(gt);return Array.isArray(t[gt])?t[gt]:[]}async function Zs(t){await chrome.storage.local.set({[gt]:t})}function al(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{sl().then(s)},[]);async function l(){const c=await me();if(!c){o("No audit-target tab found.");return}try{await ve(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),o("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{o("Failed to start recording.")}}async function i(){const c=await me();if(c)try{const d=await Te(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),d.steps.length===0){o("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${d.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){o("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:d.steps,savedAt:new Date().toISOString()},f=[g,...t];s(f),await Zs(f),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(d){o(`Stop failed: ${d instanceof Error?d.message:String(d)}`)}}async function u(c){const d=await me();if(d){o(`Replaying "${c.name}"…`);try{const h=await Te(d,{type:"FLOW_PLAY_REQUEST",steps:c.steps});o(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){o(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const d=t.filter(h=>h.id!==c);s(d),await Zs(d)}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:i,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(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>u(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function nl(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 o=n.slice(0,r),l=n.slice(r+1);return o==="story"?{primary:l.split("--").map(u=>u.split("-").map(rl).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function rl(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function il(){const t=b(i=>i.baselineList),s=b(i=>i.tier),a=Qn[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{wt().finally(()=>o(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(i=>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"})]},i))});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(i){await Q({type:"BASELINE_DELETE",componentId:i}),await wt()}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(i=>{const u=nl(i.componentId),p=i.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:i.componentId,children:u.primary}),u.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:u.secondary,children:u.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[i.violationCount," ",i.violationCount===1?"violation":"violations"," ·"," ",new Date(i.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[i.seenOnUrlsCount&&i.seenOnUrlsCount>1&&e.jsxs(Le,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",i.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(Le,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(Le,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(Le,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(Le,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(Le,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(Le,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(i.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},i.componentId)})]})}const ol={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 Le({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${ol[t]}`,children:a})}const Pa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ll={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Pa]},cl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Pa]};function $t(t){return t==="thorough"?cl:ll}function qt(t){const s=$t(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ga({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(ea,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${qt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(ea,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${qt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function ea({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:o}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:o})]})}const Va={ruleIds:["image-alt","label","button-name","link-name","color-contrast","document-title","html-has-lang"],thresholds:{moderate:1,high:2,critical:4},headlines:{low:"Low risk. Your site passes the checks common automated lawsuit-targeting scanners run today — not low-hanging fruit. This isn't a guarantee: scanners add checks over time, so re-audit as your site changes.",moderate:"Moderate risk. A demand-letter scanner could flag at least one issue. Fix to drop off the easy-target list.",high:"High risk. Multiple findings here are common patterns demand-letter mills target.",critical:"Critical risk. Your site has many high-frequency patterns ADA-targeting firms scan for."},version:0};Va.ruleIds;function Wa(){var t;return((t=In())==null?void 0:t.lawfare)??Va}function ft(t,s=Wa()){return s.ruleIds.includes(t)}function Ba(t,s=Wa()){const a=new Set(s.ruleIds),n=new Map;for(const p of t)a.has(p.ruleId)&&n.set(p.ruleId,(n.get(p.ruleId)??0)+1);const r=Array.from(n.entries()).map(([p,c])=>({ruleId:p,instanceCount:c})).sort((p,c)=>c.instanceCount-p.instanceCount),o=r.length,l=Array.from(n.values()).reduce((p,c)=>p+c,0);let i;return o<s.thresholds.moderate?i="low":o<s.thresholds.high?i="moderate":o<s.thresholds.critical?i="high":i="critical",{tier:i,letter:i==="low"?"A":i==="moderate"?"C":i==="high"?"D":"F",flaggedRuleCount:o,flaggedInstanceCount:l,flaggedRules:r,headline:s.headlines[i],rubricVersion:s.version}}const ps={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"};function Ha(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return(async()=>{const o=(await et()??[]).flatMap(p=>p.results),l=await En(o);if(n)return;const i=l.acknowledgedMatchKeys,u=o.flatMap(p=>p.violations).filter(p=>!p.needsReview&&!i.has(p.matchKey));a(Ba(u))})(),()=>{n=!0}},[t.startUrl,t.finishedAt]),s}const bt="wcagcheckr";function ne(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ze(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 dl(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function ul(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 pl(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 hl(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 ml(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 (${ne(t.receipt.tsaName)}) — anchored ${ne(Ze(t.receipt.anchoredAt))}</td></tr>
19
19
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${ne(t.receipt.serverKeyFingerprint)}</code></td></tr>
20
20
  ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${ne(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${ne(bt)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
21
21
  <article class="entry">
@@ -591,4 +591,4 @@ Rules:
591
591
  ${t.auditContext}
592
592
  </audit-context>`);const r=await fetch(Bc,{method:"POST",headers:{"content-type":"application/json","x-api-key":t.apiKey,"anthropic-version":Hc,"anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:s,max_tokens:a,system:n,messages:t.messages}),signal:t.signal});if(!r.ok){const c=await r.text().catch(()=>"");throw new Error(`Anthropic API ${r.status}: ${c.slice(0,300)}`)}const o=await r.json(),l=o.content.filter(c=>c.type==="text").map(c=>c.text).join(`
593
593
  `).trim(),i=o.usage.input_tokens,u=o.usage.output_tokens,p=Yc(i,u,s);if(t.maxCostUsd!==void 0&&p>t.maxCostUsd)throw new Error(`chat turn cost $${p.toFixed(4)} exceeded maxCostUsd $${t.maxCostUsd.toFixed(4)}`);return{text:l,inputTokens:i,outputTokens:u,costUsd:p,model:o.model}}function Xc(t){const s=[];t.pageUrl&&s.push(`page: ${t.pageUrl}`),t.componentId&&s.push(`component: ${t.componentId}`),s.push(`violations: ${t.violations.length}`),s.push("");const a=new Set;for(const n of t.violations){const r=`${n.ruleId}::${n.target.selector}`;if(a.has(r))continue;a.add(r);const o=n.target.outerHTML.length>200?n.target.outerHTML.slice(0,197)+"...":n.target.outerHTML;s.push(`- [${n.impact}] ${n.ruleId} (WCAG ${n.wcagCriterion} ${n.wcagLevel})`),s.push(` selector: ${n.target.selector}`),s.push(` html: ${o}`),s.push(` axe says: ${n.description}`),s.push("")}return s.join(`
594
- `)}const ht="aiConfig";function Zc(){var C;const t=b(j=>j.results),s=b(j=>j.componentId),[a,n]=m.useState([]),[r,o]=m.useState(""),[l,i]=m.useState(!1),[u,p]=m.useState(!1),[c,d]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),g=m.useRef(null);m.useEffect(()=>{function j(x){h.current=(x==null?void 0:x.apiKey)??"",p(!!(x!=null&&x.apiKey)),x!=null&&x.model&&d(x.model)}(async()=>{const x=await chrome.storage.local.get(ht);j(x[ht])})();const N=(x,A)=>{var k;if(A!=="local"||!(ht in x))return;const I=(k=x[ht])==null?void 0:k.newValue;j(I)};return chrome.storage.onChanged.addListener(N),()=>chrome.storage.onChanged.removeListener(N)},[]),m.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[a.length]);const f=t.flatMap(j=>j.violations),v=Xc({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:f.map(j=>({ruleId:j.ruleId,wcagCriterion:j.wcagCriterion,wcagLevel:j.wcagLevel,impact:j.impact,description:j.description,target:{selector:j.target.selector,outerHTML:j.target.outerHTML}}))}),w=a.reduce((j,N)=>j+(N.costUsd??0),0);async function R(){const j=r.trim();if(!j||l||!h.current)return;o("");const N={role:"user",content:j},x=[...a,N];n(x),i(!0);try{const A=x.map(k=>({role:k.role,content:k.content})),I=await Jc({apiKey:h.current,model:c,messages:A,auditContext:v});n([...x,{role:"assistant",content:I.text,costUsd:I.costUsd,inputTokens:I.inputTokens,outputTokens:I.outputTokens}])}catch(A){n([...x,{role:"assistant",content:"",error:A instanceof Error?A.message:String(A)}])}finally{i(!1)}}function E(){n([])}return u?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",w.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:E,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",f.length," violation",f.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((j,N)=>e.jsxs("div",{className:j.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:j.role==="user"?"You":"Co-pilot"}),j.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:j.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:j.content}),j.role==="assistant"&&j.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",j.costUsd.toFixed(4)," · ",j.inputTokens,"→",j.outputTokens," tok"]})]},N)),l&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),R()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:j=>o(j.target.value),placeholder:"Ask about this audit…",disabled:l,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:l||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:l?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function ed(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(""),[u,p]=m.useState(new Set);async function c(){o(null),n(!0);try{const g=await me();if(!g){o("No audited tab. Open a page to audit, then return here.");return}const f=await se({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:g});if(!f.ok||!f.nodes){o(f.error??"Snapshot failed for an unknown reason.");return}s(f.nodes)}finally{n(!1)}}function d(g){p(f=>{const v=new Set(f);return v.has(g)?v.delete(g):v.add(g),v})}const h=t&&l?t.filter(g=>g.role.toLowerCase().includes(l.toLowerCase())||g.name.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(h==null?void 0:h.length)??0," node",((h==null?void 0:h.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&h&&e.jsx(td,{nodes:t,filtered:h,collapsed:u,onToggle:d})]})]})}function td({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(l=>e.jsx("li",{role:"treeitem",children:e.jsx(un,{node:l,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},l.nodeId))});const r=new Map;for(const l of t){const i=l.parentId,u=r.get(i)??[];u.push(l),r.set(i,u)}const o=r.get(void 0)??t.filter(l=>!l.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:o.map(l=>e.jsx(dn,{node:l,depth:0,byParent:r,collapsed:a,onToggle:n},l.nodeId))})}function dn({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const o=a.get(t.nodeId)??[],l=o.length>0,i=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":l?!i:void 0,children:[e.jsx(un,{node:t,depth:s,collapsed:i,onToggle:()=>r(t.nodeId),hasChildren:l}),!i&&l&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:o.map(u=>e.jsx(dn,{node:u,depth:s+1,byParent:a,collapsed:n,onToggle:r},u.nodeId))})]})}function un({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const o=t.properties.filter(l=>l.value!==!1&&l.value!==""&&l.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),o.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:o.map(l=>`${l.name}=${String(l.value)}`).join(" · ")})]})}function sd(){const t=b(p=>p.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[o,l]=m.useState(null);async function i(){r(null),a(!0);try{const p=await me();if(!p){r("No audited tab. Open a page first.");return}const c=await Te(p,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:p});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const d=new Map;for(const f of t)for(const v of f.violations)d.has(v.target.selector)||d.set(v.target.selector,v.matchKey);const h=c.references.map(f=>({violationMatchKey:d.get(f.selector)??null,referencedTokens:f.referencedTokens})),g=c.tokens;l(ir(g,h))}finally{a(!1)}}const u=o?rr(o):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":o?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),u&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ye,{label:"Total tokens",value:u.totalTokens}),e.jsx(Ye,{label:"Color tokens",value:u.colorTokens}),e.jsx(Ye,{label:"Used",value:u.usedTokens}),e.jsx(Ye,{label:"Unused",value:u.unusedTokens,tint:u.unusedTokens>0?"amber":"slate"}),e.jsx(Ye,{label:"In violations",value:u.violatingTokens,tint:u.violatingTokens>0?"rose":"slate"})]}),o&&o.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:o.map(p=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:p.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:p.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",p.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:p.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[p.usageCount," usage",p.usageCount===1?"":"s"]}),p.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[p.violationMatchKeys.length," violation",p.violationMatchKeys.length===1?"":"s"]})]})]})]},p.token.name))})]}):o?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ye({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const Pt="onboarding:dismissed",Gt="onboarding:exportTried",mt="onboarding:collapsed";function ad(){const t=b(A=>A.tier),s=b(A=>A.results),a=b(A=>A.baselineList),[n,r]=m.useState(!1),[o,l]=m.useState(!1),[i,u]=m.useState(!1),[p,c]=m.useState(!1),[d,h]=m.useState(null);m.useEffect(()=>{(async()=>{const A=await chrome.storage.local.get([Pt,Gt,mt]);r(A[Pt]===!0),u(A[Gt]===!0),typeof A[mt]=="boolean"&&h(A[mt]);const I=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],k=await Promise.all(I.map(_=>se({type:"SETTINGS_GET",key:_})));c(k.some(_=>typeof _.data=="string"&&_.data.length>0)),l(!0)})()},[]);const g=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:i?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],f=g.filter(A=>!A.optional),v=g.filter(A=>A.state==="done").length,w=f.filter(A=>A.state==="done").length,R=v===g.length,E=w===f.length;if(!o||n||E)return null;async function C(){r(!0),await chrome.storage.local.set({[Pt]:!0})}async function j(){const A=!i;u(A),await chrome.storage.local.set({[Gt]:A})}const N=d??v>0;async function x(){const A=!N;h(A),await chrome.storage.local.set({[mt]:A})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void x(),"aria-expanded":!N,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:N?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",v," of ",g.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void C(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!N&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",R?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:g.map(A=>e.jsx("li",{className:"flex items-start gap-1.5",children:A.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:A.state==="done",onChange:()=>void j(),className:"mt-0.5","aria-label":A.label}),e.jsx("span",{className:A.state==="done"?"line-through text-amber-700":"text-amber-900",children:A.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:A.state==="done"?"✓":"○"}),e.jsxs("span",{className:A.state==="done"?"line-through text-amber-700":"text-amber-900",children:[A.label,A.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},A.id))})]})]})}function hd(){const t=b(r=>r.view),s=b(r=>r.userMode);b(r=>r.tier);const[a,n]=m.useState(!1);return m.useEffect(()=>{const r=setTimeout(()=>n(!0),600);return()=>clearTimeout(r)},[]),m.useEffect(()=>{const r=br(),l=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=ur();wa({forceRefresh:!0}).catch(()=>{}),wt().catch(()=>{}),fr().catch(()=>{}),gr().catch(()=>{}),vr().catch(()=>{}),mr().catch(()=>{}),zn().then(c=>{b.getState().setAcknowledgedKeys(new Set(c.map(d=>d.matchKey)))}).catch(()=>{});const u=b.subscribe((c,d)=>{var f,v;const h=(f=c.results[0])==null?void 0:f.pageUrl,g=(v=d.results[0])==null?void 0:v.pageUrl;!h||h===g||is(h).then(w=>{b.getState().setDismissedKeys(new Set(Object.keys(w)))}).catch(()=>{})});qn().then(c=>{c&&b.setState(d=>{const h={siteCrawlReport:c};return d.view==="matrix"&&d.results.length===0&&(h.view="crawl"),h})}).catch(()=>{});const p=c=>{if(c.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:h,results:g}=b.getState();d&&(h(null),me().then(f=>{var v;f&&ve(f,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:f},(v=g[0])==null?void 0:v.frameId).catch(()=>{})}))};return window.addEventListener("keydown",p),()=>{i(),r.disconnect(),l==null||l.disconnect(),window.removeEventListener("keydown",p),u()}},[]),s==="owner"||s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ol,{}),e.jsx(aa,{}),e.jsx(vs,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(Ja,{}),e.jsx(Ca,{}),e.jsx(Dr,{}),e.jsx(ad,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(Pr,{}),e.jsx(Kr,{}),e.jsx(Il,{}),e.jsx(Cl,{})]}),e.jsx(qr,{}),e.jsx(kl,{}),e.jsx(Sl,{}),e.jsx(Qa,{}),e.jsx(Qr,{viewingRun:t==="crawl"||t==="report",onView:()=>b.getState().setView(b.getState().siteCrawlReport?"crawl":"report")}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(ei,{}),t==="report"&&e.jsx($o,{}),t==="delta"&&e.jsx(Oa,{}),t==="activity"&&e.jsx(Ua,{}),t==="guided"&&e.jsx(Ae,{feature:"igtWorkflows",label:"Intelligent Guided Tests",children:e.jsx(Zo,{})}),t==="flows"&&e.jsx(Ae,{feature:"flowRecorder",label:"Flow recorder",children:e.jsx(al,{})}),t==="scorecard"&&e.jsx(il,{}),t==="crawl"&&e.jsx(Ae,{feature:"siteCrawl",label:"Site crawl",children:e.jsx(za,{})}),t==="forensic"&&e.jsx(Ae,{feature:"forensicLog",label:"Forensic log",children:e.jsx(Ya,{})}),t==="compliance"&&e.jsx(Ae,{feature:"wcagEmReport",label:"WCAG-EM conformance report",children:e.jsx(Rc,{})}),t==="schedules"&&e.jsx(Ae,{feature:"scheduledAudits",label:"Scheduled audits",children:e.jsx(Dc,{})}),t==="risk"&&e.jsx(Ae,{feature:"riskDashboard",label:"Risk dashboard",children:e.jsx(Wc,{})}),t==="copilot"&&e.jsx(Ae,{feature:"aiCopilot",label:"AI Copilot",children:e.jsx(Zc,{})}),t==="ax-tree"&&e.jsx(Ae,{feature:"axTreeViewer",label:"AX-tree viewer",children:e.jsx(ed,{})}),t==="wcag3"&&e.jsx(Ae,{feature:"wcag3Preview",label:"WCAG 3 preview",children:e.jsx(Ma,{})}),t==="tokens"&&e.jsx(Ae,{feature:"designSystemAudit",label:"Design-system audit",children:e.jsx(sd,{})})]})]}),e.jsx(Tl,{}),e.jsx(El,{}),e.jsx(Nl,{}),e.jsx(aa,{}),e.jsx(vs,{})]})}class md extends Je.Component{constructor(){super(...arguments);bs(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Sl as A,md as E,Ia as P,It as a,yr as b,Jc as c,ds as d,wt as e,fr as f,gr as g,mr as h,Ue as i,Qa as j,hd as k,Ne as l,pd as m,vr as p,wa as r,br as s,b as u,ur as w};
594
+ `)}const ht="aiConfig";function Zc(){var C;const t=b(j=>j.results),s=b(j=>j.componentId),[a,n]=m.useState([]),[r,o]=m.useState(""),[l,i]=m.useState(!1),[u,p]=m.useState(!1),[c,d]=m.useState("claude-sonnet-4-6"),h=m.useRef(""),g=m.useRef(null);m.useEffect(()=>{function j(x){h.current=(x==null?void 0:x.apiKey)??"",p(!!(x!=null&&x.apiKey)),x!=null&&x.model&&d(x.model)}(async()=>{const x=await chrome.storage.local.get(ht);j(x[ht])})();const N=(x,A)=>{var k;if(A!=="local"||!(ht in x))return;const I=(k=x[ht])==null?void 0:k.newValue;j(I)};return chrome.storage.onChanged.addListener(N),()=>chrome.storage.onChanged.removeListener(N)},[]),m.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[a.length]);const f=t.flatMap(j=>j.violations),v=Xc({componentId:s??void 0,pageUrl:(C=t[0])==null?void 0:C.pageUrl,violations:f.map(j=>({ruleId:j.ruleId,wcagCriterion:j.wcagCriterion,wcagLevel:j.wcagLevel,impact:j.impact,description:j.description,target:{selector:j.target.selector,outerHTML:j.target.outerHTML}}))}),w=a.reduce((j,N)=>j+(N.costUsd??0),0);async function R(){const j=r.trim();if(!j||l||!h.current)return;o("");const N={role:"user",content:j},x=[...a,N];n(x),i(!0);try{const A=x.map(k=>({role:k.role,content:k.content})),I=await Jc({apiKey:h.current,model:c,messages:A,auditContext:v});n([...x,{role:"assistant",content:I.text,costUsd:I.costUsd,inputTokens:I.inputTokens,outputTokens:I.outputTokens}])}catch(A){n([...x,{role:"assistant",content:"",error:A instanceof Error?A.message:String(A)}])}finally{i(!1)}}function E(){n([])}return u?t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Run an audit first. The co-pilot answers questions about the audit's structured data (violations, WCAG criteria, components) — it needs that data to ground its answers."})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs flex flex-col h-full","data-testid":"copilot-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["Session cost: $",w.toFixed(4)]}),a.length>0&&e.jsx("button",{type:"button",onClick:E,className:"text-slate-600 hover:text-slate-900 underline",children:"Clear"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Ask questions about THIS audit (",f.length," violation",f.length===1?"":"s","). The model answers from the structured audit data only — it won't invent findings or check the live page."]}),e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto space-y-2 border border-slate-200 rounded p-2 bg-white min-h-[200px]","data-testid":"copilot-transcript",children:[a.length===0?e.jsx("p",{className:"text-slate-400 italic text-[11px]",children:`Try: "Which 3 issues are highest priority?" · "Explain finding #1 in plain language" · "What's the cheapest fix on this page?"`}):a.map((j,N)=>e.jsxs("div",{className:j.role==="user"?"border-l-2 border-brand-400 pl-2 py-1":"border-l-2 border-emerald-400 pl-2 py-1",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:j.role==="user"?"You":"Co-pilot"}),j.error?e.jsx("p",{className:"text-rose-700 whitespace-pre-wrap",children:j.error}):e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:j.content}),j.role==="assistant"&&j.costUsd!==void 0&&e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:["$",j.costUsd.toFixed(4)," · ",j.inputTokens,"→",j.outputTokens," tok"]})]},N)),l&&e.jsx("div",{className:"border-l-2 border-emerald-200 pl-2 py-1 text-[11px] text-slate-400 italic",children:"Thinking…"})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),R()},className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:j=>o(j.target.value),placeholder:"Ask about this audit…",disabled:l,"aria-label":"Co-pilot prompt",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50"}),e.jsx("button",{type:"submit",disabled:l||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:l?"Sending…":"Send"})]})]}):e.jsxs("div",{className:"p-3 space-y-2 text-xs","data-testid":"copilot-view-root",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI co-pilot"}),e.jsxs("p",{className:"text-slate-600 leading-snug",children:["The co-pilot uses your own Anthropic API key (BYOK) to answer questions about the current audit. Configure your key in ",e.jsx("strong",{children:"Settings → AI"})," to enable."]})]})}function ed(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(""),[u,p]=m.useState(new Set);async function c(){o(null),n(!0);try{const g=await me();if(!g){o("No audited tab. Open a page to audit, then return here.");return}const f=await se({type:"AX_TREE_SNAPSHOT_REQUEST",tabId:g});if(!f.ok||!f.nodes){o(f.error??"Snapshot failed for an unknown reason.");return}s(f.nodes)}finally{n(!1)}}function d(g){p(f=>{const v=new Set(f);return v.has(g)?v.delete(g):v.add(g),v})}const h=t&&l?t.filter(g=>g.role.toLowerCase().includes(l.toLowerCase())||g.name.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"p-3 text-xs flex flex-col h-full","data-testid":"ax-tree-view",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Accessibility tree"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"Snapshot of the browser's computed AX tree — what screen readers actually consume."})]}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:a,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:a?"Snapshotting…":t?"Re-snapshot":"Snapshot tree"})]}),r&&e.jsx("div",{className:"text-rose-700 text-[11px] mb-2",role:"alert",children:r}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-[11px]",children:[e.jsx("input",{type:"text",value:l,onChange:g=>i(g.target.value),placeholder:"Filter by role or name…","aria-label":"Filter ax-tree",className:"flex-1 min-w-[140px] border border-slate-300 rounded px-2 py-1"}),e.jsxs("span",{className:"text-slate-500","data-testid":"ax-tree-node-count",children:[(h==null?void 0:h.length)??0," node",((h==null?void 0:h.length)??0)===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto border border-slate-200 rounded bg-white p-2 font-mono text-[11px]",children:[!t&&!a&&e.jsxs("p",{className:"text-slate-400 italic text-center pt-8",children:["Click ",e.jsx("strong",{children:"Snapshot tree"})," above to capture the audited tab's accessibility tree."]}),t&&h&&e.jsx(td,{nodes:t,filtered:h,collapsed:u,onToggle:d})]})]})}function td({nodes:t,filtered:s,collapsed:a,onToggle:n}){if(s.length!==t.length)return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:s.map(l=>e.jsx("li",{role:"treeitem",children:e.jsx(un,{node:l,depth:0,collapsed:!1,onToggle:()=>{},hasChildren:!1})},l.nodeId))});const r=new Map;for(const l of t){const i=l.parentId,u=r.get(i)??[];u.push(l),r.set(i,u)}const o=r.get(void 0)??t.filter(l=>!l.parentId);return e.jsx("ul",{role:"tree",className:"space-y-0.5",children:o.map(l=>e.jsx(dn,{node:l,depth:0,byParent:r,collapsed:a,onToggle:n},l.nodeId))})}function dn({node:t,depth:s,byParent:a,collapsed:n,onToggle:r}){const o=a.get(t.nodeId)??[],l=o.length>0,i=n.has(t.nodeId);return e.jsxs("li",{role:"treeitem","aria-expanded":l?!i:void 0,children:[e.jsx(un,{node:t,depth:s,collapsed:i,onToggle:()=>r(t.nodeId),hasChildren:l}),!i&&l&&e.jsx("ul",{role:"group",className:"space-y-0.5",children:o.map(u=>e.jsx(dn,{node:u,depth:s+1,byParent:a,collapsed:n,onToggle:r},u.nodeId))})]})}function un({node:t,depth:s,collapsed:a,onToggle:n,hasChildren:r}){const o=t.properties.filter(l=>l.value!==!1&&l.value!==""&&l.value!==null).slice(0,6);return e.jsxs("div",{style:{paddingLeft:`${s*12}px`},className:`flex items-baseline gap-1.5 py-0.5 hover:bg-slate-50 rounded ${t.ignored?"opacity-40":""}`,children:[r?e.jsx("button",{type:"button",onClick:n,"aria-label":a?"Expand":"Collapse",className:"text-slate-500 hover:text-slate-900 w-3 shrink-0",children:a?"▸":"▾"}):e.jsx("span",{className:"w-3 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"font-semibold text-brand-700",children:t.role}),t.name&&e.jsxs("span",{className:"text-slate-700",children:['"',t.name,'"']}),t.ignored&&e.jsx("span",{className:"text-[10px] px-1 py-0 rounded bg-slate-200 text-slate-600",children:"ignored"}),o.length>0&&e.jsx("span",{className:"text-[10px] text-slate-500",children:o.map(l=>`${l.name}=${String(l.value)}`).join(" · ")})]})}function sd(){const t=b(p=>p.results),[s,a]=m.useState(!1),[n,r]=m.useState(null),[o,l]=m.useState(null);async function i(){r(null),a(!0);try{const p=await me();if(!p){r("No audited tab. Open a page first.");return}const c=await Te(p,{type:"DESIGN_SYSTEM_SNAPSHOT_REQUEST",tabId:p});if(!c.ok||!c.tokens||!c.references){r(c.error??"Snapshot failed.");return}const d=new Map;for(const f of t)for(const v of f.violations)d.has(v.target.selector)||d.set(v.target.selector,v.matchKey);const h=c.references.map(f=>({violationMatchKey:d.get(f.selector)??null,referencedTokens:f.referencedTokens})),g=c.tokens;l(ir(g,h))}finally{a(!1)}}const u=o?rr(o):null;return e.jsxs("div",{className:"p-3 space-y-3 text-xs","data-testid":"design-system-view-root",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Design-system audit"}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:"CSS custom-property tokens declared on the audited page + usage rollup. Tokens involved in violations are surfaced first."})]}),e.jsx("button",{type:"button",onClick:()=>void i(),disabled:s,className:"text-xs px-2 py-1 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50",children:s?"Snapshotting…":o?"Re-snapshot":"Snapshot tokens"})]}),n&&e.jsx("div",{className:"text-rose-700 text-[11px]",role:"alert",children:n}),u&&e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white flex flex-wrap gap-2","data-testid":"design-system-summary",children:[e.jsx(Ye,{label:"Total tokens",value:u.totalTokens}),e.jsx(Ye,{label:"Color tokens",value:u.colorTokens}),e.jsx(Ye,{label:"Used",value:u.usedTokens}),e.jsx(Ye,{label:"Unused",value:u.unusedTokens,tint:u.unusedTokens>0?"amber":"slate"}),e.jsx(Ye,{label:"In violations",value:u.violatingTokens,tint:u.violatingTokens>0?"rose":"slate"})]}),o&&o.length>0?e.jsxs("section",{className:"border border-slate-200 rounded bg-white",children:[e.jsx("h3",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-500 border-b border-slate-100",children:"Tokens"}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-[500px] overflow-y-auto",children:o.map(p=>e.jsxs("li",{className:"px-3 py-2 space-y-1","data-testid":"ds-token-row",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p.token.isColor&&e.jsx("span",{"aria-hidden":"true",className:"w-4 h-4 rounded border border-slate-300 shrink-0",style:{background:p.token.value}}),e.jsx("code",{className:"font-mono text-[11px] font-semibold",children:p.token.name}),e.jsxs("span",{className:"text-[10px] text-slate-500 font-mono break-all",children:["= ",p.token.value]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-slate-500",children:[e.jsxs("span",{children:["declared on ",e.jsx("code",{children:p.token.declaredOn})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[p.usageCount," usage",p.usageCount===1?"":"s"]}),p.violationMatchKeys.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"text-rose-700 font-semibold",children:[p.violationMatchKeys.length," violation",p.violationMatchKeys.length===1?"":"s"]})]})]})]},p.token.name))})]}):o?e.jsx("p",{className:"text-slate-500 italic text-[11px]",children:"No CSS custom-property tokens detected on this page. Design-system audit works best on sites that use a token-based theme (Tailwind v4, Material UI, Radix Theme, etc.)."}):e.jsxs("p",{className:"text-slate-500 italic text-[11px]",children:["Click ",e.jsx("strong",{children:"Snapshot tokens"})," above to walk the audited tab's stylesheets and tally per-token usage."]})]})}function Ye({label:t,value:s,tint:a}){const n={slate:"bg-slate-50 text-slate-700",amber:"bg-amber-50 text-amber-800",rose:"bg-rose-50 text-rose-900"};return e.jsxs("div",{className:`px-2 py-1.5 rounded ${n[a??"slate"]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide",children:t}),e.jsx("div",{className:"text-base font-semibold leading-tight",children:s})]})}const Pt="onboarding:dismissed",Gt="onboarding:exportTried",mt="onboarding:collapsed";function ad(){const t=b(A=>A.tier),s=b(A=>A.results),a=b(A=>A.baselineList),[n,r]=m.useState(!1),[o,l]=m.useState(!1),[i,u]=m.useState(!1),[p,c]=m.useState(!1),[d,h]=m.useState(null);m.useEffect(()=>{(async()=>{const A=await chrome.storage.local.get([Pt,Gt,mt]);r(A[Pt]===!0),u(A[Gt]===!0),typeof A[mt]=="boolean"&&h(A[mt]);const I=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],k=await Promise.all(I.map(_=>se({type:"SETTINGS_GET",key:_})));c(k.some(_=>typeof _.data=="string"&&_.data.length>0)),l(!0)})()},[]);const g=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:i?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],f=g.filter(A=>!A.optional),v=g.filter(A=>A.state==="done").length,w=f.filter(A=>A.state==="done").length,R=v===g.length,E=w===f.length;if(!o||n||E)return null;async function C(){r(!0),await chrome.storage.local.set({[Pt]:!0})}async function j(){const A=!i;u(A),await chrome.storage.local.set({[Gt]:A})}const N=d??v>0;async function x(){const A=!N;h(A),await chrome.storage.local.set({[mt]:A})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-1.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void x(),"aria-expanded":!N,"aria-controls":"onboarding-checklist-body",className:"flex-1 text-left flex items-center gap-1.5 hover:text-amber-950",children:[e.jsx("span",{className:"text-amber-800 text-[10px]","aria-hidden":"true",children:N?"▸":"▾"}),e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",v," of ",g.length," done"]})]}),e.jsx("button",{type:"button",onClick:()=>void C(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none",children:"✕"})]}),!N&&e.jsxs("div",{id:"onboarding-checklist-body",className:"mt-1.5",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug mb-1.5",children:["Quick checklist to get you started. ",R?"All steps complete — nice!":"Auto-checks as you go."]}),e.jsx("ul",{className:"space-y-1",children:g.map(A=>e.jsx("li",{className:"flex items-start gap-1.5",children:A.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:A.state==="done",onChange:()=>void j(),className:"mt-0.5","aria-label":A.label}),e.jsx("span",{className:A.state==="done"?"line-through text-amber-700":"text-amber-900",children:A.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:A.state==="done"?"✓":"○"}),e.jsxs("span",{className:A.state==="done"?"line-through text-amber-700":"text-amber-900",children:[A.label,A.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},A.id))})]})]})}function hd(){const t=b(r=>r.view),s=b(r=>r.userMode);b(r=>r.tier);const[a,n]=m.useState(!1);return m.useEffect(()=>{const r=setTimeout(()=>n(!0),600);return()=>clearTimeout(r)},[]),m.useEffect(()=>{const r=br(),l=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=ur();wa({forceRefresh:!0}).catch(()=>{}),wt().catch(()=>{}),fr().catch(()=>{}),gr().catch(()=>{}),vr().catch(()=>{}),mr().catch(()=>{}),zn().then(c=>{b.getState().setAcknowledgedKeys(new Set(c.map(d=>d.matchKey)))}).catch(()=>{});const u=b.subscribe((c,d)=>{var f,v;const h=(f=c.results[0])==null?void 0:f.pageUrl,g=(v=d.results[0])==null?void 0:v.pageUrl;!h||h===g||is(h).then(w=>{b.getState().setDismissedKeys(new Set(Object.keys(w)))}).catch(()=>{})});qn().then(c=>{c&&b.setState(d=>{const h={siteCrawlReport:c};return d.view==="matrix"&&d.results.length===0&&(h.view="crawl"),h})}).catch(()=>{});const p=c=>{if(c.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:h,results:g}=b.getState();d&&(h(null),me().then(f=>{var v;f&&ve(f,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:f},(v=g[0])==null?void 0:v.frameId).catch(()=>{})}))};return window.addEventListener("keydown",p),()=>{i(),r.disconnect(),l==null||l.disconnect(),window.removeEventListener("keydown",p),u()}},[]),s==="owner"||s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ol,{}),e.jsx(aa,{}),e.jsx(vs,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(Ja,{}),e.jsx(Ca,{}),e.jsx(Dr,{}),e.jsx(ad,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[t==="matrix"&&e.jsxs(e.Fragment,{children:[e.jsx(Pr,{}),e.jsx(Kr,{}),e.jsx(Il,{}),e.jsx(Cl,{})]}),e.jsx(qr,{}),e.jsx(kl,{}),e.jsx(Sl,{}),e.jsx(Qa,{}),e.jsx(Qr,{viewingRun:t==="crawl"||t==="report",onView:()=>b.getState().setView(b.getState().siteCrawlReport?"crawl":"report")}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(ei,{}),t==="report"&&e.jsx($o,{}),t==="delta"&&e.jsx(Oa,{}),t==="activity"&&e.jsx(Ua,{}),t==="guided"&&e.jsx(Ae,{feature:"igtWorkflows",label:"Intelligent Guided Tests",children:e.jsx(Zo,{})}),t==="flows"&&e.jsx(Ae,{feature:"flowRecorder",label:"Flow recorder",children:e.jsx(al,{})}),t==="scorecard"&&e.jsx(il,{}),t==="crawl"&&e.jsx(Ae,{feature:"siteCrawl",label:"Site crawl",children:e.jsx(za,{})}),t==="forensic"&&e.jsx(Ae,{feature:"forensicLog",label:"Forensic log",children:e.jsx(Ya,{})}),t==="compliance"&&e.jsx(Ae,{feature:"wcagEmReport",label:"WCAG-EM conformance report",children:e.jsx(Rc,{})}),t==="schedules"&&e.jsx(Ae,{feature:"scheduledAudits",label:"Scheduled audits",children:e.jsx(Dc,{})}),t==="risk"&&e.jsx(Ae,{feature:"riskDashboard",label:"Risk dashboard",children:e.jsx(Wc,{})}),t==="copilot"&&e.jsx(Ae,{feature:"aiCopilot",label:"AI Copilot",children:e.jsx(Zc,{})}),t==="ax-tree"&&e.jsx(Ae,{feature:"axTreeViewer",label:"AX-tree viewer",children:e.jsx(ed,{})}),t==="wcag3"&&e.jsx(Ae,{feature:"wcag3Preview",label:"WCAG 3 preview",children:e.jsx(Ma,{})}),t==="tokens"&&e.jsx(Ae,{feature:"designSystemAudit",label:"Design-system audit",children:e.jsx(sd,{})})]})]}),e.jsx(Tl,{}),e.jsx(El,{}),e.jsx(Nl,{}),e.jsx(aa,{}),e.jsx(vs,{})]})}class md extends Je.Component{constructor(){super(...arguments);bs(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Sl as A,md as E,Aa as M,Ia as P,It as a,yr as b,Jc as c,ds as d,wt as e,fr as f,gr as g,mr as h,Ue as i,Qa as j,hd as k,Ne as l,pd as m,vr as p,wa as r,br as s,b as u,ur as w};